Coder Social home page Coder Social logo

helkyle / antd-multi-cascader Goto Github PK

View Code? Open in Web Editor NEW
89.0 1.0 23.0 5.48 MB

A multiple cascader component for antd

Home Page: https://codesandbox.io/s/dreamy-jennings-2y1ff?file=/src/App.tsx

License: MIT License

JavaScript 2.49% TypeScript 92.91% Less 4.60%
antd cascader typescript cascader-multiselect antd-multi-cascader

antd-multi-cascader's Introduction

🎉🎉🎉 News

[email protected] 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 DemoHow it works?

demo

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

Props Type Description
value string[] Selected value
data TreeNode[] Cascader options TreeNode { title: string, value: string, children?: TreeNode, isLeaf?: boolean }
allowClear boolean Whether allow clear
placeholder string The input placeholder
onChange (newVal) => void Callback when finishing value select
selectAll boolean Whether allow select all
className string The additional css class
style React.CSSProperties The additional style
disabled boolean Whether disabled select
okText string The text of the Confirm button
cancelText string The text of the Cancel button
selectAllText string The text of the SelectAll radio
onCascaderChange (node: TreeNode, operations: { add: (children: TreeNode[]) => TreeNode[] }) => void Trigger when click a menu item
popupTransitionName string Should set 'slide-up' manually if antd version below 4.13.0
getPopupContainer (props: any) => HTMLElement Parent 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
maxTagCount Max tag count to show. responsive will cost render performance number | 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"
/>

antd-multi-cascader's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

antd-multi-cascader's Issues

popupvisible没有生效

我用rc-trigger时 popupVisible 已经为false了 但是弹窗还是展开态 是怎么回事呢

使用高版本的antd时,无法交互

我是使用的15.3的antd,无法点击,在您的codesandbox里面更换antd的一些较高版本后也是无法点击,无法关闭,好像是rc-trigger 有点问题

getPopupContainer is not working

index.js:1406 Warning: React does not recognize the getPopupContainer prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase getpopupcontainer instead. If you accidentally passed it from a parent component, remove it from the DOM element.
in div (created by Selector)
in Selector (created by ForwardRef)
in Trigger (created by ForwardRef)
in ForwardRef
in ForwardRef (created by ForwardRef)
in Provider (created by ForwardRef)

The whole module is not working now

Last time forgot to restart the server
TypeError: Cannot read property '_context' of undefined
getting this error on the latest version the older version is still working

使用高版本的antd时,无法交互

我是使用的15.3的antd,无法点击,在您的codesandbox里面更换antd的一些较高版本后也是无法点击,无法关闭,好像是rc-trigger 有点问题

动态渲染data会报错,如下

export default function App() {
  const [options, setOptions] = React.useState<any[]>([]);
  React.useEffect(()=>{
      setTimeout(()=>{
        setOptions([{
          value: 'Node1',
          title: 'Node1'
      },
      {
          value: 'Node2-1',
          title: 'Node2',
          children: [ ]
      }])
    },500);
  },[]);

  return (
    <div className="App">
      <section>
        <header>Form Control</header>
        <MultiCascader
          data={options}
          placeholder="Select Nodes"
        />
      </section>
    </div>
  );
}

Not exactly an issue just suggestion, to add maxTagCount and check on text click

There's an attribute called maxTagCount in antd Select which lets you select the number of tags that can be displayed it would be helpful if that was present here because as of right now if there are multiple tags selected and the component has a fixed width and height then the tags will either overflow or there will be a scrollbar inside the component.
And the other would be a quality of life change, to select a checkbox currently the user has to click on the checkbox it won't work if someone clicked on the text, it would be better if the user could click on the text as well to check the checkbox.

This dependency was not found

rc-trigger in ./node_modules/antd-multi-cascader/dist/components/MultiCascader.js
请问使用这个插件,需要额外安装rc-trigger这个依赖吗

能否支持Antd TreeSelect的showCheckedStrategy属性呢?

antd的树选择器有三种选中策略:
TreeSelect.SHOW_ALL: 显示所有选中节点(包括父节点)。
TreeSelect.SHOW_PARENT: 只显示父节点(当父节点下所有子节点都选中时)。
TreeSelect.SHOW_CHILD: 默认只显示子节点

期望支持SHOW_CHILD,选中父节点时只展示所有叶子节点,并且组件的值也是所有叶子节点value

虽然现在可以通过ref拿到matchAllLeafValue方法,但是每次都得调用比较麻烦.

Menu无法点击

在antd4.13.0及以上的环境下,下拉菜单会不可点击,并且无法收起

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.