import { CompDefault, MetaProps } from '../data-channel';
import React from 'react';
import { View } from '@tarojs/components';
import connect from '../connect';

export interface Props extends MetaProps {
  onChange?: Function;
}

export interface State {}

/**
 * 默认值
 */
const defaultValue: CompDefault<Props, State> = {
  props: {
    onChange: (_value) => {},
  },
  meta: {
    output: { tags: ['check-tab', 'search-item'] },
  },
};

/**
 * 下拉tab
 */
const TabExpand: React.FC<Props> = ({ onChange, meta }) => {
  return (
    <View>
      {['综合', '最新', '评论'].map((item, idx) => {
        return (
          <View
            key={idx}
            onClick={() => {
              onChange({ value: idx, meta });
            }}>
            {item}
          </View>
        );
      })}
    </View>
  );
};

export default connect(TabExpand, defaultValue);
