0.1.14 • Published 9 months ago

@kne/super-select v0.1.14

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

super-select

描述

用于复杂信息选择.

安装

npm i --save @kne/super-select

示例

示例样式

.max-width-150 {
  max-width: 150px;
}

示例代码

const { SelectInput } = _SuperSelect;
const { Space, Flex } = antd;

const BaseExample = () => {
  return <Flex vertical gap={8}>
    <Space>
      <SelectInput />
      <SelectInput defaultValue={[{ value: 0, label: '第一项' }, { value: 1, label: '第二项' }]} />
      <SelectInput defaultValue={[{ value: 'all', label: '全选' }]} />
      <SelectInput className="max-width-150" defaultValue={Array.from({ length: 10 }).map((value, index) => {
        return { value: index, label: `第${index}项` };
      })} />
      <SelectInput defaultValue={[{ value: 0, label: '第一项' }, { value: 1, label: '第二项' }]} disabled />
    </Space>
    <Space>
      <SelectInput isPopup={false}/>
    </Space>
  </Flex>;
};

render(<BaseExample />);
const { default: SuperSelect } = _SuperSelect;
const { Space, Button } = antd;

const optionList = Array.from({ length: 20 }).map((item, key) => {
  return {
    label: `第${key + 1}项`, value: key + 1, disabled: key === 1
  };
});

const BaseExample = () => {
  return <Space wrap>
    <SuperSelect options={optionList} suffix={<Button type="text">预览</Button>}
                 prefix={<Button type="text">查看</Button>} />
    <SuperSelect single options={[...optionList, {
      value: 'other', label: '超长label项超长label项超长label项超长label项超长label项超长label项超长label项超长label项'
    }]} />
    <SuperSelect allowSelectedAll options={optionList} maxLength={10} getSearchCallback={({ searchText }, item) => {
      return !searchText || item.label.indexOf(searchText) > -1;
    }} />
    <SuperSelect allowSelectedAll options={optionList} isPopup={false} getSearchCallback={({ searchText }, item) => {
      return !searchText || item.label.indexOf(searchText) > -1;
    }} />
    <SuperSelect api={{
      data: {}, loader: ({ data }) => {
        const { searchText } = data.searchProps;
        if (!searchText) {
          return {
            pageData: optionList, totalCount: optionList.length
          };
        }
        const newOptionList = optionList.filter((item) => !searchText || item.label.indexOf(searchText) > -1);
        return {
          pageData: newOptionList, totalCount: newOptionList.length
        };
      }
    }} isPopup={false} getSearchProps={({ searchText }) => {
      return { searchText };
    }} />

    <SuperSelect defaultOpen options={optionList} inputRender={({ value }) => {
      return <Button type="link">编辑</Button>;
    }} />
  </Space>;
};

render(<BaseExample />);
const { SelectTableList } = _SuperSelect;
const { Space, Button } = antd;

const optionList = Array.from({ length: 20 }).map((item, key) => {
  return {
    id: key + 1, label: `名称${key + 1}`, count: key + 1, description: `描述${key + 1}`, disabled: key === 1
  };
});

const columns = [{
  name: 'label', title: '名称', span: 8
}, {
  name: 'count', title: '数量', span: 8
}, {
  name: 'description', title: '描述', span: 8
}];

const BaseExample = () => {
  return <Space wrap>
    <SelectTableList options={optionList} columns={columns} valueKey="id" />
    <SelectTableList single options={optionList} columns={columns} valueKey="id" />
    <SelectTableList allowSelectedAll options={optionList} columns={columns} valueKey="id" />
    <SelectTableList options={optionList} columns={columns} isPopup={false} valueKey="id" />
    <SelectTableList allowSelectedAll options={optionList} columns={columns} isPopup={false} valueKey="id" />
    <SelectTableList single options={optionList} columns={columns} isPopup={false} valueKey="id" />
  </Space>;
};

render(<BaseExample />);
const { default: SuperSelect } = _SuperSelect;
const { Space, Button } = antd;
const { useRef } = React;

const optionList = Array.from({ length: 20 }).map((item, key) => {
  return {
    label: `第${key + 1}项`, value: key + 1, disabled: key === 1
  };
});

const BaseExample = () => {
  const ref = useRef();
  return <Space wrap>
    <SuperSelect options={optionList} ref={ref} />
    <Button onClick={() => {
      ref.current.onOpenChange(true);
    }}>打开弹窗</Button>
  </Space>;
};

render(<BaseExample />);

API

属性名说明类型默认值
0.1.13

9 months ago

0.1.14

9 months ago

0.1.10

9 months ago

0.1.11

9 months ago

0.1.12

9 months ago

0.1.8

9 months ago

0.1.7

9 months ago

0.1.9

9 months ago

0.1.6

9 months ago

0.1.5

9 months ago

0.1.4

9 months ago

0.1.3

9 months ago

0.1.2

9 months ago

0.1.1

9 months ago

0.1.0

9 months ago