2.0.4 ā€¢ Published 12 months ago

antd-multi-asl-cascader-new v2.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

šŸŽ‰šŸŽ‰šŸŽ‰ News

Antd@4.17.0 has supported multiple cascader features. Should consider it first.

antd-multi-cascader

Test PRs Welcome MIT license Codecov Coverage Storybook npm

A multiple cascader component for antd

antd-multi-cascader

Online Demoļ¼ŒHow 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

šŸšØ Please install 1.3.0 version or set popupTransitionName=slide-up manually if your antd version below 4.13.0
šŸšØ å¦‚ęžœä½ ä½æē”Øēš„ antd ē‰ˆęœ¬å°äŗŽ 4.13.0ļ¼ŒčÆ·å®‰č£… 1.3.0 ēš„ē‰ˆęœ¬ļ¼Œęˆ–ꉋåŠØč®¾ē½® popupTransitionName=slide-up

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
classNamestringThe 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 'slide-up' manually if antd version below 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"
/>
2.0.4

12 months ago

2.0.3

12 months ago

2.0.2

12 months ago

2.0.1

12 months ago