1.3.1 • Published 3 years ago

antd-multi-cascader v1.3.1

Weekly downloads
127
License
MIT
Repository
github
Last release
3 years ago

antd-multi-cascader

Test PRs Welcome MIT license Codecov Coverage Storybook npm

A multiple cascader component for antd

antd-multi-cascader

Online DemoHow it works?

How to use?

npm install antd-multi-cascader or yarn add antd-multi-cascader
const [value, setValue] = React.useState<string[]>([]);

return (
  <MultiCascader
    value={value}
    onChange={setValue}
    data={options}
    placeholder="Select Cities"
  />
)

Props

PropsTypeDescription
valuestring[]Selected value
dataTreeNode[]Cascader options TreeNode { title: string, value: string, children?: TreeNode, isLeaf?: boolean }
allowClearbooleanWhether allow clear
placeholderstringThe input placeholder
onChange(newVal) => voidCallback when finishing value select
selectAllbooleanWhether allow select all
classNamebooleanThe additional css class
styleReact.CSSPropertiesThe additional style
disabledbooleanWhether disabled select
okTextstringThe text of the Confirm button
cancelTextstringThe text of the Cancel button
selectAllTextstringThe text of the SelectAll radio
onCascaderChange(node: TreeNode, operations: { add: (children: TreeNode[]) => TreeNode[] }) => voidTrigger when click a menu item
popupTransitionNamestringShould set 'ant-slide-up' manually if antd version greater than 4.13.0
getPopupContainer(props: any) => HTMLElementParent Node which the selector should be rendered to. Default to body. When position issues happen, try to modify it into scrollable content and position it relative
maxTagCountMax tag count to show. responsive will cost render performancenumber | responsive

Async Data Example

const [asyncOptions, setAsyncOptions] = React.useState([
  {
    value: 'ParentNode1',
    title: 'ParentNode1',
    // tell component this node is not a leaf node
    isLeaf: false,
  },
  {
    value: 'ParentNode2',
    title: 'ParentNode2',
  },
])

const handleCascaderChange = React.useCallback((node, { add }) => {
  // call add function to append children nodes
  if (node.value === 'ParentNode1' && !node.children) {
    setTimeout(() => {
      setAsyncOptions(
        add([
          {
            value: 'ParentNode1-1',
            title: 'ParentNode1-1',
          },
        ])
      )
    }, 1000)
  }
}, [])

<MultiCascader
  selectAll
  data={asyncOptions}
  onCascaderChange={handleCascaderChange}
  placeholder="Async Data"
/>
1.3.1

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.0.12

3 years ago

0.1.0

3 years ago

0.1.1

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago