tntd 2.0.13 → 2.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/array-input/index.js +31 -6
- package/es/columns/index.js +12 -6
- package/es/development-login/LoginModal.js +10 -4
- package/es/drawer/drawer.js +8 -4
- package/es/ellipsis/index.js +25 -14
- package/es/empty/empty.js +13 -9
- package/es/handle/index.js +27 -14
- package/es/img/Contain.js +19 -13
- package/es/img/Cover.js +24 -13
- package/es/img/index.js +21 -14
- package/es/index.js +1 -0
- package/es/loading-button/index.js +13 -6
- package/es/locale/default.js +2 -0
- package/es/locale/en_US.js +2 -0
- package/es/locale/zh_CN.js +2 -0
- package/es/page/Box.js +28 -19
- package/es/page/index.js +38 -22
- package/es/page/utils.js +5 -0
- package/es/prev-locale.js +3 -0
- package/es/query-form/Field/Checkbox.js +8 -4
- package/es/query-form/Field/Select.js +17 -10
- package/es/query-form/Field/SelectInput.js +18 -4
- package/es/query-form/Field/fieldsMap.js +1 -0
- package/es/query-form/Field/index.js +11 -2
- package/es/query-form/createActions.js +8 -0
- package/es/query-form/index.js +34 -2
- package/es/query-list-scene/List.js +39 -18
- package/es/query-list-scene/QueryForm.js +19 -10
- package/es/query-list-scene/QueryListScene.js +2 -0
- package/es/query-list-scene/Toolbar.js +10 -6
- package/es/query-list-scene/createActions.js +3 -0
- package/es/render-empty/render-empty.js +2 -0
- package/es/steps/steps.js +17 -9
- package/es/steps/style/nav.less +3 -1
- package/es/svg-components/illustration-403.js +2 -0
- package/es/svg-components/illustration-404.js +2 -0
- package/es/svg-components/illustration-500.js +2 -0
- package/es/svg-components/illustration-empty.js +2 -0
- package/es/svg-components/illustration-failure.js +2 -0
- package/es/svg-components/illustration-no-access.js +2 -0
- package/es/svg-components/illustration-no-chart.js +2 -0
- package/es/svg-components/illustration-no-result.js +2 -0
- package/es/svg-components/illustration-offline.js +2 -0
- package/es/svg-components/illustration-success.js +2 -0
- package/es/table/assets/image-loading-background.js +2 -0
- package/es/table/assets/image-loading.js +2 -0
- package/es/table/hooks/use-column-setting.js +1 -0
- package/es/table/table.js +19 -14
- package/es/table/table.stories.js +2 -0
- package/es/table/utils.js +6 -2
- package/es/title/index.js +14 -10
- package/es/tntd-cascader/AntdCascader/component/context.js +4 -2
- package/es/tntd-cascader/AntdCascader/component/defaultRenderEmpty.js +2 -0
- package/es/tntd-cascader/AntdCascader/component/getIcons.js +15 -6
- package/es/tntd-cascader/AntdCascader/config/utils.js +2 -0
- package/es/tntd-cascader/AntdCascader/config/warning.js +8 -4
- package/es/tntd-cascader/AntdCascader/index.js +73 -51
- package/es/tntd-cascader/rc-cascader/Cascader.js +113 -86
- package/es/tntd-cascader/rc-cascader/OptionList/Column.js +26 -16
- package/es/tntd-cascader/rc-cascader/OptionList/index.js +43 -26
- package/es/tntd-cascader/rc-cascader/OptionList/useActive.js +7 -5
- package/es/tntd-cascader/rc-cascader/OptionList/useKeyboard.js +41 -12
- package/es/tntd-cascader/rc-cascader/hooks/useDisplayValues.js +10 -4
- package/es/tntd-cascader/rc-cascader/hooks/useEntities.js +4 -2
- package/es/tntd-cascader/rc-cascader/hooks/useMissingValues.js +1 -0
- package/es/tntd-cascader/rc-cascader/hooks/useRefFunc.js +1 -0
- package/es/tntd-cascader/rc-cascader/hooks/useSearchConfig.js +7 -2
- package/es/tntd-cascader/rc-cascader/hooks/useSearchOptions.js +15 -8
- package/es/tntd-cascader/rc-cascader/utils/commonUtil.js +6 -2
- package/es/tntd-cascader/rc-cascader/utils/treeUtil.js +4 -2
- package/es/tntd-cascader/rc-cascader/utils/warningPropsUtil.js +7 -2
- package/es/tntd-icon/fonts/iconfont.js +12 -7
- package/es/tntd-icon/index.js +9 -5
- package/es/tntd-layout/ActionsContext.js +2 -2
- package/es/tntd-layout/AppList.js +14 -2
- package/es/tntd-layout/Application.js +4 -0
- package/es/tntd-layout/Avatar.js +4 -0
- package/es/tntd-layout/CompatibleLanguage.js +13 -0
- package/es/tntd-layout/EnterpriseLayout/Avatar.js +4 -0
- package/es/tntd-layout/EnterpriseLayout/Language.js +6 -0
- package/es/tntd-layout/EnterpriseLayout/Theme.js +4 -0
- package/es/tntd-layout/EnterpriseLayout/index.js +2 -2
- package/es/tntd-layout/GlobalNavigation/NavigationPopup.js +33 -2
- package/es/tntd-layout/GlobalNavigation/index.js +6 -0
- package/es/tntd-layout/HeaderActions.js +32 -28
- package/es/tntd-layout/HeaderNavs.js +14 -6
- package/es/tntd-layout/HeaderTabs.js +35 -14
- package/es/tntd-layout/Language.js +6 -0
- package/es/tntd-layout/Layout.js +7 -2
- package/es/tntd-layout/Logo.js +11 -4
- package/es/tntd-layout/OrgAppList.js +39 -22
- package/es/tntd-layout/SideMenu.js +45 -8
- package/es/tntd-layout/Theme.js +6 -0
- package/es/tntd-layout/index.js +17 -9
- package/es/tntd-layout/paaslayout/CompactSideMenu.js +15 -0
- package/es/tntd-layout/paaslayout/SideMenu.js +15 -0
- package/es/tntd-layout/paaslayout/index.js +13 -4
- package/es/tntd-layout/storage.js +2 -2
- package/es/tntd-modal/index.js +18 -12
- package/es/tntd-second-page/index.js +3 -0
- package/es/tntd-select/DropDownWrap.js +8 -4
- package/es/tntd-select/index.js +118 -74
- package/es/utils/checkAuth.js +1 -0
- package/es/utils/findMenuInfoByPath.js +3 -0
- package/es/utils/index.js +11 -2
- package/lib/affix/index.js +10 -4
- package/lib/alert/index.js +10 -4
- package/lib/anchor/index.js +10 -4
- package/lib/array-input/icon.js +7 -1
- package/lib/array-input/index.js +91 -41
- package/lib/auth-context/index.js +3 -0
- package/lib/auto-complete/index.js +10 -4
- package/lib/avatar/index.js +10 -4
- package/lib/back-top/index.js +10 -4
- package/lib/badge/index.js +10 -4
- package/lib/breadcrumb/index.js +10 -4
- package/lib/button/index.js +10 -4
- package/lib/calendar/index.js +10 -4
- package/lib/card/index.js +10 -4
- package/lib/carousel/index.js +10 -4
- package/lib/cascader/index.js +10 -4
- package/lib/checkbox/index.js +10 -4
- package/lib/col/index.js +10 -4
- package/lib/collapse/index.js +11 -4
- package/lib/columns/index.js +28 -14
- package/lib/comment/index.js +10 -4
- package/lib/config-provider/config-provider.js +2 -0
- package/lib/config-provider/index.js +10 -4
- package/lib/date-picker/index.js +10 -4
- package/lib/descriptions/index.js +10 -4
- package/lib/development-login/LoginModal.js +50 -25
- package/lib/development-login/index.js +22 -11
- package/lib/divider/index.js +10 -4
- package/lib/drawer/drawer.js +16 -6
- package/lib/drawer/index.js +5 -1
- package/lib/dropdown/index.js +10 -4
- package/lib/ellipsis/Svg/CopySVG.js +4 -0
- package/lib/ellipsis/Svg/TickSVG.js +4 -0
- package/lib/ellipsis/index.js +73 -42
- package/lib/empty/empty.js +30 -14
- package/lib/empty/empty.stories.js +21 -3
- package/lib/empty/index.js +5 -1
- package/lib/exception/exception.js +14 -7
- package/lib/exception/index.js +4 -1
- package/lib/form/index.js +10 -4
- package/lib/handle/index.js +46 -19
- package/lib/icon/index.js +10 -4
- package/lib/img/Contain.js +23 -12
- package/lib/img/Cover.js +53 -31
- package/lib/img/index.js +47 -29
- package/lib/index.js +187 -100
- package/lib/input/index.js +10 -4
- package/lib/input-number/index.js +10 -4
- package/lib/layout/index.js +10 -4
- package/lib/list/index.js +10 -4
- package/lib/loading-button/index.js +32 -15
- package/lib/locale/default.js +5 -0
- package/lib/locale/en_US.js +4 -0
- package/lib/locale/index.js +6 -3
- package/lib/locale/zh_CN.js +4 -0
- package/lib/locale-provider/index.js +10 -4
- package/lib/mention/index.js +10 -4
- package/lib/mentions/index.js +10 -4
- package/lib/menu/index.js +10 -4
- package/lib/message/index.js +11 -4
- package/lib/modal/index.js +11 -4
- package/lib/notification/index.js +10 -4
- package/lib/page/Box.js +37 -24
- package/lib/page/index.js +66 -37
- package/lib/page/utils.js +9 -1
- package/lib/page-header/index.js +10 -4
- package/lib/pagination/index.js +10 -4
- package/lib/popconfirm/index.js +10 -4
- package/lib/popover/index.js +10 -4
- package/lib/prev-locale.js +10 -1
- package/lib/progress/index.js +10 -4
- package/lib/query-form/Field/Checkbox.js +11 -2
- package/lib/query-form/Field/Select.js +45 -27
- package/lib/query-form/Field/SelectInput.js +46 -21
- package/lib/query-form/Field/fieldsMap.js +12 -1
- package/lib/query-form/Field/index.js +70 -38
- package/lib/query-form/createActions.js +7 -0
- package/lib/query-form/index.js +121 -52
- package/lib/query-form/useForm.js +4 -0
- package/lib/query-list-scene/List.js +111 -58
- package/lib/query-list-scene/QueryForm.js +67 -37
- package/lib/query-list-scene/QueryListScene.js +42 -21
- package/lib/query-list-scene/Title.js +5 -1
- package/lib/query-list-scene/Toolbar.js +15 -8
- package/lib/query-list-scene/createActions.js +6 -0
- package/lib/query-list-scene/index.js +10 -0
- package/lib/query-list-scene/useActions.js +4 -0
- package/lib/radio/index.js +10 -4
- package/lib/rate/index.js +10 -4
- package/lib/render-empty/index.js +2 -0
- package/lib/render-empty/render-empty.js +8 -0
- package/lib/result/index.js +10 -4
- package/lib/row/index.js +10 -4
- package/lib/select/index.js +10 -4
- package/lib/skeleton/index.js +10 -4
- package/lib/slider/index.js +10 -4
- package/lib/spin/index.js +10 -4
- package/lib/statistic/index.js +10 -4
- package/lib/steps/index.js +5 -1
- package/lib/steps/steps.js +29 -12
- package/lib/steps/style/nav.less +3 -1
- package/lib/svg-components/illustration-403.js +9 -3
- package/lib/svg-components/illustration-404.js +9 -3
- package/lib/svg-components/illustration-500.js +9 -3
- package/lib/svg-components/illustration-empty.js +9 -3
- package/lib/svg-components/illustration-failure.js +9 -3
- package/lib/svg-components/illustration-no-access.js +9 -3
- package/lib/svg-components/illustration-no-chart.js +9 -3
- package/lib/svg-components/illustration-no-result.js +9 -3
- package/lib/svg-components/illustration-offline.js +9 -3
- package/lib/svg-components/illustration-success.js +9 -3
- package/lib/svg-components/index.js +11 -0
- package/lib/switch/index.js +10 -4
- package/lib/table/assets/image-loading-background.js +9 -3
- package/lib/table/assets/image-loading.js +9 -3
- package/lib/table/context.js +2 -0
- package/lib/table/hooks/index.js +2 -1
- package/lib/table/hooks/use-column-setting.js +16 -8
- package/lib/table/index.js +5 -1
- package/lib/table/table.js +63 -34
- package/lib/table/table.stories.js +11 -2
- package/lib/table/utils.js +11 -2
- package/lib/tabs/index.js +10 -4
- package/lib/tag/index.js +10 -4
- package/lib/time-picker/index.js +10 -4
- package/lib/timeline/index.js +10 -4
- package/lib/title/index.js +20 -10
- package/lib/tntd-cascader/AntdCascader/component/DisabledContext.js +11 -4
- package/lib/tntd-cascader/AntdCascader/component/FormItemInputContext.js +8 -3
- package/lib/tntd-cascader/AntdCascader/component/SizeContext.js +8 -3
- package/lib/tntd-cascader/AntdCascader/component/context.js +9 -3
- package/lib/tntd-cascader/AntdCascader/component/defaultRenderEmpty.js +12 -4
- package/lib/tntd-cascader/AntdCascader/component/getIcons.js +37 -19
- package/lib/tntd-cascader/AntdCascader/component/useCompactItemContext.js +17 -8
- package/lib/tntd-cascader/AntdCascader/config/utils.js +15 -6
- package/lib/tntd-cascader/AntdCascader/config/warning.js +15 -7
- package/lib/tntd-cascader/AntdCascader/index.js +133 -80
- package/lib/tntd-cascader/AntdCascader/interface.js +3 -0
- package/lib/tntd-cascader/index.js +2 -0
- package/lib/tntd-cascader/rc-cascader/Cascader.js +188 -123
- package/lib/tntd-cascader/rc-cascader/OptionList/Checkbox.js +21 -11
- package/lib/tntd-cascader/rc-cascader/OptionList/Column.js +88 -60
- package/lib/tntd-cascader/rc-cascader/OptionList/index.js +109 -65
- package/lib/tntd-cascader/rc-cascader/OptionList/useActive.js +33 -18
- package/lib/tntd-cascader/rc-cascader/OptionList/useKeyboard.js +106 -56
- package/lib/tntd-cascader/rc-cascader/context.js +8 -3
- package/lib/tntd-cascader/rc-cascader/hooks/useDisplayValues.js +31 -14
- package/lib/tntd-cascader/rc-cascader/hooks/useEntities.js +15 -5
- package/lib/tntd-cascader/rc-cascader/hooks/useMissingValues.js +11 -3
- package/lib/tntd-cascader/rc-cascader/hooks/useRefFunc.js +8 -3
- package/lib/tntd-cascader/rc-cascader/hooks/useSearchConfig.js +15 -3
- package/lib/tntd-cascader/rc-cascader/hooks/useSearchOptions.js +41 -26
- package/lib/tntd-cascader/rc-cascader/index.js +3 -0
- package/lib/tntd-cascader/rc-cascader/utils/commonUtil.js +20 -9
- package/lib/tntd-cascader/rc-cascader/utils/treeUtil.js +8 -0
- package/lib/tntd-cascader/rc-cascader/utils/warningPropsUtil.js +14 -7
- package/lib/tntd-icon/fonts/iconfont.js +12 -7
- package/lib/tntd-icon/index.js +17 -6
- package/lib/tntd-layout/ActionsContext.js +3 -0
- package/lib/tntd-layout/AppList.js +105 -30
- package/lib/tntd-layout/Application.js +84 -22
- package/lib/tntd-layout/Avatar.js +72 -18
- package/lib/tntd-layout/CompatibleLanguage.js +105 -32
- package/lib/tntd-layout/EnterpriseLayout/Avatar.js +80 -24
- package/lib/tntd-layout/EnterpriseLayout/Language.js +45 -14
- package/lib/tntd-layout/EnterpriseLayout/Theme.js +46 -16
- package/lib/tntd-layout/EnterpriseLayout/index.js +12 -4
- package/lib/tntd-layout/GlobalNavigation/NavigationPopup.js +174 -45
- package/lib/tntd-layout/GlobalNavigation/index.js +70 -19
- package/lib/tntd-layout/Header.js +54 -20
- package/lib/tntd-layout/HeaderActions.js +64 -33
- package/lib/tntd-layout/HeaderNavs.js +59 -19
- package/lib/tntd-layout/HeaderTabs.js +111 -43
- package/lib/tntd-layout/Iconfont.js +5 -0
- package/lib/tntd-layout/Language.js +45 -14
- package/lib/tntd-layout/Layout.js +113 -74
- package/lib/tntd-layout/Logo.js +41 -14
- package/lib/tntd-layout/OrgAppList.js +119 -51
- package/lib/tntd-layout/SideMenu.js +120 -42
- package/lib/tntd-layout/Theme.js +71 -19
- package/lib/tntd-layout/createActions.js +5 -0
- package/lib/tntd-layout/images/index.js +28 -0
- package/lib/tntd-layout/index.js +49 -21
- package/lib/tntd-layout/paaslayout/CompactSideMenu.js +81 -29
- package/lib/tntd-layout/paaslayout/Header.js +47 -14
- package/lib/tntd-layout/paaslayout/Logo.js +19 -2
- package/lib/tntd-layout/paaslayout/SideMenu.js +82 -31
- package/lib/tntd-layout/paaslayout/index.js +108 -62
- package/lib/tntd-layout/storage.d.ts +1 -1
- package/lib/tntd-layout/storage.d.ts.map +1 -1
- package/lib/tntd-layout/storage.js +33 -3
- package/lib/tntd-modal/index.js +51 -32
- package/lib/tntd-second-page/index.js +24 -14
- package/lib/tntd-select/DropDownWrap.js +45 -24
- package/lib/tntd-select/index.js +206 -117
- package/lib/tooltip/index.js +10 -4
- package/lib/transfer/index.js +10 -4
- package/lib/tree/index.js +10 -4
- package/lib/tree-select/index.js +10 -4
- package/lib/typography/index.js +10 -4
- package/lib/upload/index.js +10 -4
- package/lib/utils/checkAuth.js +10 -4
- package/lib/utils/findMenuInfoByPath.js +7 -1
- package/lib/utils/index.js +41 -13
- package/lib/version/index.js +10 -4
- package/package.json +1 -1
- package/es/array-input/style/index.js +0 -1
- package/es/array-input/style/index.js.map +0 -1
- package/es/auth-context/style/index.js +0 -1
- package/es/auth-context/style/index.js.map +0 -1
- package/es/development-login/style/index.js +0 -1
- package/es/development-login/style/index.js.map +0 -1
- package/es/ellipsis/style/index.js +0 -1
- package/es/ellipsis/style/index.js.map +0 -1
- package/es/empty/render-empty.js +0 -22
- package/es/empty/render-empty.js.map +0 -1
- package/es/empty/style/index.js +0 -2
- package/es/empty/style/index.js.map +0 -1
- package/es/handle/style/index.js +0 -1
- package/es/handle/style/index.js.map +0 -1
- package/es/icon-list/style/index.js +0 -1
- package/es/icon-list/style/index.js.map +0 -1
- package/es/img/style/index.js +0 -1
- package/es/img/style/index.js.map +0 -1
- package/es/loading-button/style/index.js +0 -1
- package/es/loading-button/style/index.js.map +0 -1
- package/es/page/style/index.js +0 -1
- package/es/page/style/index.js.map +0 -1
- package/es/query-form/style/index.js +0 -1
- package/es/query-form/style/index.js.map +0 -1
- package/es/query-list-scene/style/index.js +0 -1
- package/es/query-list-scene/style/index.js.map +0 -1
- package/es/render-empty/style/index.js +0 -1
- package/es/render-empty/style/index.js.map +0 -1
- package/es/table/style/index.js +0 -2
- package/es/table/style/index.js.map +0 -1
- package/es/title/style/index.js +0 -1
- package/es/title/style/index.js.map +0 -1
- package/es/tntd-icon/style/index.js +0 -1
- package/es/tntd-icon/style/index.js.map +0 -1
- package/es/tntd-layout/style/index.js +0 -1
- package/es/tntd-layout/style/index.js.map +0 -1
- package/es/tntd-modal/style/index.js +0 -1
- package/es/tntd-modal/style/index.js.map +0 -1
- package/es/tntd-select/style/index.js +0 -1
- package/es/tntd-select/style/index.js.map +0 -1
- package/lib/array-input/style/index.d.ts +0 -1
- package/lib/array-input/style/index.d.ts.map +0 -1
- package/lib/array-input/style/index.js +0 -1
- package/lib/array-input/style/index.js.map +0 -1
- package/lib/auth-context/style/index.d.ts +0 -1
- package/lib/auth-context/style/index.d.ts.map +0 -1
- package/lib/auth-context/style/index.js +0 -1
- package/lib/auth-context/style/index.js.map +0 -1
- package/lib/development-login/style/index.d.ts +0 -1
- package/lib/development-login/style/index.d.ts.map +0 -1
- package/lib/development-login/style/index.js +0 -1
- package/lib/development-login/style/index.js.map +0 -1
- package/lib/ellipsis/style/index.d.ts +0 -1
- package/lib/ellipsis/style/index.d.ts.map +0 -1
- package/lib/ellipsis/style/index.js +0 -1
- package/lib/ellipsis/style/index.js.map +0 -1
- package/lib/empty/render-empty.d.ts +0 -3
- package/lib/empty/render-empty.d.ts.map +0 -1
- package/lib/empty/render-empty.js +0 -32
- package/lib/empty/render-empty.js.map +0 -1
- package/lib/empty/style/index.d.ts +0 -3
- package/lib/empty/style/index.d.ts.map +0 -1
- package/lib/empty/style/index.js +0 -4
- package/lib/empty/style/index.js.map +0 -1
- package/lib/handle/style/index.d.ts +0 -1
- package/lib/handle/style/index.d.ts.map +0 -1
- package/lib/handle/style/index.js +0 -1
- package/lib/handle/style/index.js.map +0 -1
- package/lib/icon-list/style/index.d.ts +0 -3
- package/lib/icon-list/style/index.d.ts.map +0 -1
- package/lib/icon-list/style/index.js +0 -8
- package/lib/icon-list/style/index.js.map +0 -1
- package/lib/img/style/index.d.ts +0 -1
- package/lib/img/style/index.d.ts.map +0 -1
- package/lib/img/style/index.js +0 -1
- package/lib/img/style/index.js.map +0 -1
- package/lib/loading-button/style/index.d.ts +0 -1
- package/lib/loading-button/style/index.d.ts.map +0 -1
- package/lib/loading-button/style/index.js +0 -1
- package/lib/loading-button/style/index.js.map +0 -1
- package/lib/page/style/index.d.ts +0 -1
- package/lib/page/style/index.d.ts.map +0 -1
- package/lib/page/style/index.js +0 -1
- package/lib/page/style/index.js.map +0 -1
- package/lib/query-form/style/index.d.ts +0 -1
- package/lib/query-form/style/index.d.ts.map +0 -1
- package/lib/query-form/style/index.js +0 -1
- package/lib/query-form/style/index.js.map +0 -1
- package/lib/query-list-scene/style/index.d.ts +0 -1
- package/lib/query-list-scene/style/index.d.ts.map +0 -1
- package/lib/query-list-scene/style/index.js +0 -1
- package/lib/query-list-scene/style/index.js.map +0 -1
- package/lib/render-empty/style/index.d.ts +0 -2
- package/lib/render-empty/style/index.d.ts.map +0 -1
- package/lib/render-empty/style/index.js +0 -3
- package/lib/render-empty/style/index.js.map +0 -1
- package/lib/table/style/index.d.ts +0 -3
- package/lib/table/style/index.d.ts.map +0 -1
- package/lib/table/style/index.js +0 -4
- package/lib/table/style/index.js.map +0 -1
- package/lib/title/style/index.d.ts +0 -1
- package/lib/title/style/index.d.ts.map +0 -1
- package/lib/title/style/index.js +0 -1
- package/lib/title/style/index.js.map +0 -1
- package/lib/tntd-icon/style/index.d.ts +0 -1
- package/lib/tntd-icon/style/index.d.ts.map +0 -1
- package/lib/tntd-icon/style/index.js +0 -1
- package/lib/tntd-icon/style/index.js.map +0 -1
- package/lib/tntd-layout/style/index.d.ts +0 -1
- package/lib/tntd-layout/style/index.d.ts.map +0 -1
- package/lib/tntd-layout/style/index.js +0 -1
- package/lib/tntd-layout/style/index.js.map +0 -1
- package/lib/tntd-modal/style/index.d.ts +0 -1
- package/lib/tntd-modal/style/index.d.ts.map +0 -1
- package/lib/tntd-modal/style/index.js +0 -1
- package/lib/tntd-modal/style/index.js.map +0 -1
- package/lib/tntd-select/style/index.d.ts +0 -1
- package/lib/tntd-select/style/index.d.ts.map +0 -1
- package/lib/tntd-select/style/index.js +0 -1
- package/lib/tntd-select/style/index.js.map +0 -1
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
var __rest = this && this.__rest || function (s, e) {
|
|
2
2
|
var t = {};
|
|
3
|
+
|
|
3
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
5
|
+
|
|
4
6
|
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
5
7
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
6
8
|
}
|
|
7
9
|
return t;
|
|
8
10
|
};
|
|
11
|
+
|
|
9
12
|
import { BaseSelect } from 'rc-select';
|
|
10
13
|
import useId from 'rc-select/lib/hooks/useId';
|
|
11
14
|
import { conductCheck } from 'rc-tree/lib/utils/conductUtil';
|
|
@@ -24,78 +27,87 @@ import { formatStrategyValues, toPathOptions } from './utils/treeUtil';
|
|
|
24
27
|
import warningProps, { warningNullOptions } from './utils/warningPropsUtil';
|
|
25
28
|
import './context';
|
|
26
29
|
import './index.less';
|
|
30
|
+
|
|
27
31
|
function isMultipleValue(value) {
|
|
28
32
|
return Array.isArray(value) && Array.isArray(value[0]);
|
|
29
33
|
}
|
|
34
|
+
|
|
30
35
|
function toRawValues(value) {
|
|
31
36
|
if (!value) {
|
|
32
37
|
return [];
|
|
33
38
|
}
|
|
39
|
+
|
|
34
40
|
if (isMultipleValue(value)) {
|
|
35
41
|
return value;
|
|
36
42
|
}
|
|
43
|
+
|
|
37
44
|
return (value.length === 0 ? [] : [value]).map(val => Array.isArray(val) ? val : [val]);
|
|
38
45
|
}
|
|
46
|
+
|
|
39
47
|
const Cascader = React.forwardRef((props, ref) => {
|
|
40
48
|
const {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
49
|
+
// MISC
|
|
50
|
+
id,
|
|
51
|
+
prefixCls = 'rc-cascader',
|
|
52
|
+
fieldNames,
|
|
53
|
+
// Value
|
|
54
|
+
defaultValue,
|
|
55
|
+
value,
|
|
56
|
+
changeOnSelect,
|
|
57
|
+
onChange,
|
|
58
|
+
displayRender,
|
|
59
|
+
checkable,
|
|
60
|
+
// Search
|
|
61
|
+
searchValue,
|
|
62
|
+
onSearch,
|
|
63
|
+
showSearch,
|
|
64
|
+
// Trigger
|
|
65
|
+
expandTrigger,
|
|
66
|
+
// Options
|
|
67
|
+
options,
|
|
68
|
+
dropdownPrefixCls,
|
|
69
|
+
loadData,
|
|
70
|
+
// Open
|
|
71
|
+
popupVisible,
|
|
72
|
+
open,
|
|
73
|
+
popupClassName,
|
|
74
|
+
dropdownClassName,
|
|
75
|
+
dropdownMenuColumnStyle,
|
|
76
|
+
popupPlacement,
|
|
77
|
+
placement,
|
|
78
|
+
onDropdownVisibleChange,
|
|
79
|
+
onPopupVisibleChange,
|
|
80
|
+
renderItem,
|
|
81
|
+
// Icon
|
|
82
|
+
expandIcon = '>',
|
|
83
|
+
loadingIcon,
|
|
84
|
+
// Children
|
|
85
|
+
children,
|
|
86
|
+
dropdownMatchSelectWidth = false,
|
|
87
|
+
showCheckedStrategy = SHOW_PARENT
|
|
88
|
+
} = props,
|
|
89
|
+
restProps = __rest(props, ["id", "prefixCls", "fieldNames", "defaultValue", "value", "changeOnSelect", "onChange", "displayRender", "checkable", "searchValue", "onSearch", "showSearch", "expandTrigger", "options", "dropdownPrefixCls", "loadData", "popupVisible", "open", "popupClassName", "dropdownClassName", "dropdownMenuColumnStyle", "popupPlacement", "placement", "onDropdownVisibleChange", "onPopupVisibleChange", "renderItem", "expandIcon", "loadingIcon", "children", "dropdownMatchSelectWidth", "showCheckedStrategy"]);
|
|
90
|
+
|
|
82
91
|
const mergedId = useId(id);
|
|
83
92
|
const multiple = !!checkable;
|
|
84
|
-
const [dropdownVisible, setDropdownVisible] = React.useState(false);
|
|
85
|
-
|
|
93
|
+
const [dropdownVisible, setDropdownVisible] = React.useState(false); // =========================== Values ===========================
|
|
94
|
+
|
|
86
95
|
const [rawValues, setRawValues] = useMergedState(defaultValue, {
|
|
87
96
|
value,
|
|
88
97
|
postState: toRawValues
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
const mergedFieldNames = React.useMemo(() => fillFieldNames(fieldNames),
|
|
98
|
+
}); // ========================= FieldNames =========================
|
|
99
|
+
|
|
100
|
+
const mergedFieldNames = React.useMemo(() => fillFieldNames(fieldNames),
|
|
101
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
92
102
|
[JSON.stringify(fieldNames)]
|
|
93
|
-
/* eslint-enable react-hooks/exhaustive-deps */
|
|
94
|
-
// =========================== Option ===========================
|
|
95
|
-
|
|
96
|
-
// Only used in multiple mode, this fn will not call in single mode
|
|
103
|
+
/* eslint-enable react-hooks/exhaustive-deps */
|
|
104
|
+
); // =========================== Option ===========================
|
|
105
|
+
|
|
106
|
+
const mergedOptions = React.useMemo(() => options || [], [options]); // Only used in multiple mode, this fn will not call in single mode
|
|
107
|
+
|
|
97
108
|
const getPathKeyEntities = useEntities(mergedOptions, mergedFieldNames);
|
|
98
109
|
/** Convert path key back to value format */
|
|
110
|
+
|
|
99
111
|
const getValueByKeyPath = React.useCallback(pathKeys => {
|
|
100
112
|
const keyPathEntities = getPathKeyEntities();
|
|
101
113
|
return pathKeys.map(pathKey => {
|
|
@@ -104,35 +116,40 @@ const Cascader = React.forwardRef((props, ref) => {
|
|
|
104
116
|
} = keyPathEntities[pathKey];
|
|
105
117
|
return nodes.map(node => node[mergedFieldNames.value]);
|
|
106
118
|
});
|
|
107
|
-
}, [getPathKeyEntities, mergedFieldNames]);
|
|
108
|
-
|
|
119
|
+
}, [getPathKeyEntities, mergedFieldNames]); // =========================== Search ===========================
|
|
120
|
+
|
|
109
121
|
const [mergedSearchValue, setSearchValue] = useMergedState('', {
|
|
110
122
|
value: searchValue,
|
|
111
123
|
postState: search => search || ''
|
|
112
124
|
});
|
|
125
|
+
|
|
113
126
|
const onInternalSearch = (searchText, info) => {
|
|
114
127
|
setSearchValue(searchText);
|
|
128
|
+
|
|
115
129
|
if (info.source !== 'blur' && onSearch) {
|
|
116
130
|
onSearch(searchText);
|
|
117
131
|
}
|
|
118
132
|
};
|
|
133
|
+
|
|
119
134
|
const [mergedShowSearch, searchConfig] = useSearchConfig(showSearch);
|
|
120
|
-
const searchOptions = useSearchOptions(mergedSearchValue, mergedOptions, mergedFieldNames, dropdownPrefixCls || prefixCls, searchConfig, changeOnSelect);
|
|
121
|
-
|
|
122
|
-
const getMissingValues = useMissingValues(mergedOptions, mergedFieldNames);
|
|
123
|
-
|
|
135
|
+
const searchOptions = useSearchOptions(mergedSearchValue, mergedOptions, mergedFieldNames, dropdownPrefixCls || prefixCls, searchConfig, changeOnSelect); // =========================== Values ===========================
|
|
136
|
+
|
|
137
|
+
const getMissingValues = useMissingValues(mergedOptions, mergedFieldNames); // Fill `rawValues` with checked conduction values
|
|
138
|
+
|
|
124
139
|
const [checkedValues, halfCheckedValues, missingCheckedValues] = React.useMemo(() => {
|
|
125
140
|
const [existValues, missingValues] = getMissingValues(rawValues);
|
|
141
|
+
|
|
126
142
|
if (!multiple || !rawValues.length) {
|
|
127
143
|
return [existValues, [], missingValues];
|
|
128
144
|
}
|
|
145
|
+
|
|
129
146
|
const keyPathValues = toPathKeys(existValues);
|
|
130
147
|
const keyPathEntities = getPathKeyEntities();
|
|
131
148
|
const {
|
|
132
149
|
checkedKeys,
|
|
133
150
|
halfCheckedKeys
|
|
134
|
-
} = conductCheck(keyPathValues, true, keyPathEntities);
|
|
135
|
-
|
|
151
|
+
} = conductCheck(keyPathValues, true, keyPathEntities); // Convert key back to value cells
|
|
152
|
+
|
|
136
153
|
return [getValueByKeyPath(checkedKeys), getValueByKeyPath(halfCheckedKeys), missingValues];
|
|
137
154
|
}, [multiple, rawValues, getPathKeyEntities, getValueByKeyPath, getMissingValues]);
|
|
138
155
|
const deDuplicatedValues = React.useMemo(() => {
|
|
@@ -140,11 +157,11 @@ const Cascader = React.forwardRef((props, ref) => {
|
|
|
140
157
|
const deduplicateKeys = formatStrategyValues(checkedKeys, getPathKeyEntities, showCheckedStrategy);
|
|
141
158
|
return [...missingCheckedValues, ...getValueByKeyPath(deduplicateKeys)];
|
|
142
159
|
}, [checkedValues, getPathKeyEntities, getValueByKeyPath, missingCheckedValues, showCheckedStrategy]);
|
|
143
|
-
const displayValues = useDisplayValues(deDuplicatedValues, mergedOptions, mergedFieldNames, multiple, displayRender);
|
|
144
|
-
|
|
160
|
+
const displayValues = useDisplayValues(deDuplicatedValues, mergedOptions, mergedFieldNames, multiple, displayRender); // =========================== Change ===========================
|
|
161
|
+
|
|
145
162
|
const triggerChange = useRefFunc(nextValues => {
|
|
146
|
-
setRawValues(nextValues);
|
|
147
|
-
|
|
163
|
+
setRawValues(nextValues); // Save perf if no need trigger event
|
|
164
|
+
|
|
148
165
|
if (onChange) {
|
|
149
166
|
const nextRawValues = toRawValues(nextValues);
|
|
150
167
|
const valueOptions = nextRawValues.map(valueCells => toPathOptions(valueCells, mergedOptions, mergedFieldNames).map(valueOpt => valueOpt.option));
|
|
@@ -152,10 +169,11 @@ const Cascader = React.forwardRef((props, ref) => {
|
|
|
152
169
|
const triggerOptions = multiple ? valueOptions : valueOptions[0];
|
|
153
170
|
onChange(triggerValues, triggerOptions);
|
|
154
171
|
}
|
|
155
|
-
});
|
|
156
|
-
|
|
172
|
+
}); // =========================== Select ===========================
|
|
173
|
+
|
|
157
174
|
const onInternalSelect = useRefFunc(valuePath => {
|
|
158
175
|
setSearchValue('');
|
|
176
|
+
|
|
159
177
|
if (!multiple) {
|
|
160
178
|
triggerChange(valuePath);
|
|
161
179
|
} else {
|
|
@@ -164,19 +182,21 @@ const Cascader = React.forwardRef((props, ref) => {
|
|
|
164
182
|
const checkedPathKeys = toPathKeys(checkedValues);
|
|
165
183
|
const halfCheckedPathKeys = toPathKeys(halfCheckedValues);
|
|
166
184
|
const existInChecked = checkedPathKeys.includes(pathKey);
|
|
167
|
-
const existInMissing = missingCheckedValues.some(valueCells => toPathKey(valueCells) === pathKey);
|
|
168
|
-
|
|
185
|
+
const existInMissing = missingCheckedValues.some(valueCells => toPathKey(valueCells) === pathKey); // Do update
|
|
186
|
+
|
|
169
187
|
let nextCheckedValues = checkedValues;
|
|
170
188
|
let nextMissingValues = missingCheckedValues;
|
|
189
|
+
|
|
171
190
|
if (existInMissing && !existInChecked) {
|
|
172
191
|
// Missing value only do filter
|
|
173
192
|
nextMissingValues = missingCheckedValues.filter(valueCells => toPathKey(valueCells) !== pathKey);
|
|
174
193
|
} else {
|
|
175
194
|
// Update checked key first
|
|
176
195
|
const nextRawCheckedKeys = existInChecked ? checkedPathKeys.filter(key => key !== pathKey) : [...checkedPathKeys, pathKey];
|
|
177
|
-
const pathKeyEntities = getPathKeyEntities();
|
|
178
|
-
|
|
196
|
+
const pathKeyEntities = getPathKeyEntities(); // Conduction by selected or not
|
|
197
|
+
|
|
179
198
|
let checkedKeys;
|
|
199
|
+
|
|
180
200
|
if (existInChecked) {
|
|
181
201
|
;
|
|
182
202
|
({
|
|
@@ -190,41 +210,48 @@ const Cascader = React.forwardRef((props, ref) => {
|
|
|
190
210
|
({
|
|
191
211
|
checkedKeys
|
|
192
212
|
} = conductCheck(nextRawCheckedKeys, true, pathKeyEntities));
|
|
193
|
-
}
|
|
194
|
-
|
|
213
|
+
} // Roll up to parent level keys
|
|
214
|
+
|
|
215
|
+
|
|
195
216
|
const deDuplicatedKeys = formatStrategyValues(checkedKeys, getPathKeyEntities, showCheckedStrategy);
|
|
196
217
|
nextCheckedValues = getValueByKeyPath(deDuplicatedKeys);
|
|
197
218
|
}
|
|
219
|
+
|
|
198
220
|
triggerChange([...nextMissingValues, ...nextCheckedValues]);
|
|
199
221
|
}
|
|
200
|
-
});
|
|
201
|
-
|
|
222
|
+
}); // Display Value change logic
|
|
223
|
+
|
|
202
224
|
const onDisplayValuesChange = (_, info) => {
|
|
203
225
|
if (info.type === 'clear') {
|
|
204
226
|
triggerChange([]);
|
|
205
227
|
return;
|
|
206
|
-
}
|
|
207
|
-
|
|
228
|
+
} // Cascader do not support `add` type. Only support `remove`
|
|
229
|
+
|
|
230
|
+
|
|
208
231
|
const {
|
|
209
232
|
valueCells
|
|
210
233
|
} = info.values[0];
|
|
211
234
|
onInternalSelect(valueCells);
|
|
212
|
-
};
|
|
213
|
-
|
|
235
|
+
}; // ============================ Open ============================
|
|
236
|
+
|
|
237
|
+
|
|
214
238
|
const mergedOpen = open !== undefined ? open : popupVisible;
|
|
215
239
|
const mergedDropdownClassName = dropdownClassName || popupClassName;
|
|
216
240
|
const mergedPlacement = placement || popupPlacement;
|
|
241
|
+
|
|
217
242
|
const onInternalDropdownVisibleChange = nextVisible => {
|
|
218
243
|
onDropdownVisibleChange === null || onDropdownVisibleChange === void 0 ? void 0 : onDropdownVisibleChange(nextVisible);
|
|
219
244
|
onPopupVisibleChange === null || onPopupVisibleChange === void 0 ? void 0 : onPopupVisibleChange(nextVisible);
|
|
220
245
|
setDropdownVisible(nextVisible);
|
|
221
|
-
};
|
|
222
|
-
|
|
246
|
+
}; // ========================== Warning ===========================
|
|
247
|
+
|
|
248
|
+
|
|
223
249
|
if (process.env.NODE_ENV !== 'production') {
|
|
224
250
|
warningProps(props);
|
|
225
251
|
warningNullOptions(mergedOptions, mergedFieldNames);
|
|
226
|
-
}
|
|
227
|
-
|
|
252
|
+
} // ========================== Context ===========================
|
|
253
|
+
|
|
254
|
+
|
|
228
255
|
const cascaderContext = React.useMemo(() => ({
|
|
229
256
|
options: mergedOptions,
|
|
230
257
|
fieldNames: mergedFieldNames,
|
|
@@ -242,15 +269,13 @@ const Cascader = React.forwardRef((props, ref) => {
|
|
|
242
269
|
dropdownMenuColumnStyle,
|
|
243
270
|
renderItem,
|
|
244
271
|
dropdownVisible
|
|
245
|
-
}), [mergedOptions, mergedFieldNames, checkedValues, halfCheckedValues, changeOnSelect, onInternalSelect, checkable, searchOptions, dropdownPrefixCls, loadData, expandTrigger, expandIcon, loadingIcon, dropdownMenuColumnStyle, renderItem, dropdownVisible]);
|
|
246
|
-
// ==============================================================
|
|
272
|
+
}), [mergedOptions, mergedFieldNames, checkedValues, halfCheckedValues, changeOnSelect, onInternalSelect, checkable, searchOptions, dropdownPrefixCls, loadData, expandTrigger, expandIcon, loadingIcon, dropdownMenuColumnStyle, renderItem, dropdownVisible]); // ==============================================================
|
|
247
273
|
// == Render ==
|
|
248
274
|
// ==============================================================
|
|
275
|
+
|
|
249
276
|
const emptyOptions = !(mergedSearchValue ? searchOptions : mergedOptions).length;
|
|
250
|
-
const dropdownStyle =
|
|
251
|
-
//
|
|
252
|
-
mergedSearchValue && searchConfig.matchInputWidth ||
|
|
253
|
-
// Empty keep the width
|
|
277
|
+
const dropdownStyle = // Search to match width
|
|
278
|
+
mergedSearchValue && searchConfig.matchInputWidth || // Empty keep the width
|
|
254
279
|
emptyOptions ? {} : {
|
|
255
280
|
minWidth: 'auto'
|
|
256
281
|
};
|
|
@@ -283,9 +308,11 @@ const Cascader = React.forwardRef((props, ref) => {
|
|
|
283
308
|
getRawInputElement: () => children
|
|
284
309
|
})));
|
|
285
310
|
});
|
|
311
|
+
|
|
286
312
|
if (process.env.NODE_ENV !== 'production') {
|
|
287
313
|
Cascader.displayName = 'Cascader';
|
|
288
314
|
}
|
|
315
|
+
|
|
289
316
|
Cascader.SHOW_PARENT = SHOW_PARENT;
|
|
290
317
|
Cascader.SHOW_CHILD = SHOW_CHILD;
|
|
291
318
|
export default Cascader;
|
|
@@ -39,42 +39,47 @@ export default function Column({
|
|
|
39
39
|
} = React.useContext(CascaderContext);
|
|
40
40
|
const hoverOpen = expandTrigger === 'hover';
|
|
41
41
|
/** 单选情况下滚动到相应的位置 */
|
|
42
|
+
|
|
42
43
|
React.useEffect(() => {
|
|
43
44
|
let timer = null;
|
|
45
|
+
|
|
44
46
|
if (ref.current && ref.current.scrollTo && !multiple && dropdownVisible) {
|
|
45
47
|
const index = options.findIndex(it => it[fieldNames.value] === activeValue);
|
|
48
|
+
|
|
46
49
|
if (index > 0 && !isNaN(index)) {
|
|
47
50
|
timer = window.setTimeout(() => {
|
|
48
51
|
ref.current.scrollTo((optionHeight || 36) * index);
|
|
49
52
|
}, 5);
|
|
50
53
|
}
|
|
51
54
|
}
|
|
55
|
+
|
|
52
56
|
return () => {
|
|
53
57
|
if (timer) {
|
|
54
58
|
window.clearTimeout(timer);
|
|
55
59
|
}
|
|
60
|
+
|
|
56
61
|
timer = null;
|
|
57
62
|
};
|
|
58
|
-
}, [multiple, activeValue, options, fieldNames, dropdownVisible, optionHeight]);
|
|
59
|
-
|
|
63
|
+
}, [multiple, activeValue, options, fieldNames, dropdownVisible, optionHeight]); // ============================ Option ============================
|
|
64
|
+
|
|
60
65
|
const optionInfoList = React.useMemo(() => options.map(option => {
|
|
61
66
|
var _a;
|
|
67
|
+
|
|
62
68
|
const {
|
|
63
69
|
disabled
|
|
64
70
|
} = option;
|
|
65
71
|
const searchOptions = option[SEARCH_MARK];
|
|
66
72
|
const label = (_a = option[FIX_LABEL]) !== null && _a !== void 0 ? _a : option[fieldNames.label];
|
|
67
73
|
const value = option[fieldNames.value];
|
|
68
|
-
const isMergedLeaf = isLeaf(option, fieldNames);
|
|
69
|
-
|
|
70
|
-
const fullPath = searchOptions ?
|
|
71
|
-
// @ts-ignore
|
|
74
|
+
const isMergedLeaf = isLeaf(option, fieldNames); // Get real value of option. Search option is different way.
|
|
75
|
+
|
|
76
|
+
const fullPath = searchOptions ? // @ts-ignore
|
|
72
77
|
searchOptions.map(opt => opt[fieldNames.value]) : [...prevValuePath, value];
|
|
73
78
|
const fullPathKey = toPathKey(fullPath);
|
|
74
|
-
const isLoading = loadingKeys.includes(fullPathKey);
|
|
75
|
-
|
|
76
|
-
const checked = checkedSet.has(fullPathKey);
|
|
77
|
-
|
|
79
|
+
const isLoading = loadingKeys.includes(fullPathKey); // >>>>> checked
|
|
80
|
+
|
|
81
|
+
const checked = checkedSet.has(fullPathKey); // >>>>> halfChecked
|
|
82
|
+
|
|
78
83
|
const halfChecked = halfCheckedSet.has(fullPathKey);
|
|
79
84
|
return {
|
|
80
85
|
disabled,
|
|
@@ -88,8 +93,8 @@ export default function Column({
|
|
|
88
93
|
fullPath,
|
|
89
94
|
fullPathKey
|
|
90
95
|
};
|
|
91
|
-
}), [options, checkedSet, fieldNames, halfCheckedSet, loadingKeys, prevValuePath]);
|
|
92
|
-
|
|
96
|
+
}), [options, checkedSet, fieldNames, halfCheckedSet, loadingKeys, prevValuePath]); // ============================ Render ============================
|
|
97
|
+
|
|
93
98
|
return React.createElement("ul", {
|
|
94
99
|
className: menuPrefixCls,
|
|
95
100
|
role: "menu"
|
|
@@ -117,20 +122,24 @@ export default function Column({
|
|
|
117
122
|
if (!disabled && (!hoverOpen || !isMergedLeaf)) {
|
|
118
123
|
onActive(fullPath);
|
|
119
124
|
}
|
|
120
|
-
};
|
|
121
|
-
|
|
125
|
+
}; // >>>>> Selection
|
|
126
|
+
|
|
127
|
+
|
|
122
128
|
const triggerSelect = () => {
|
|
123
129
|
if (isSelectable(option)) {
|
|
124
130
|
onSelect(fullPath, isMergedLeaf);
|
|
125
131
|
}
|
|
126
|
-
};
|
|
127
|
-
|
|
132
|
+
}; // >>>>> Title
|
|
133
|
+
|
|
134
|
+
|
|
128
135
|
let title;
|
|
136
|
+
|
|
129
137
|
if (typeof option.title === 'string') {
|
|
130
138
|
title = option.title;
|
|
131
139
|
} else if (typeof label === 'string') {
|
|
132
140
|
title = label;
|
|
133
141
|
}
|
|
142
|
+
|
|
134
143
|
return React.createElement("li", {
|
|
135
144
|
key: fullPathKey,
|
|
136
145
|
className: classNames(menuItemPrefixCls, {
|
|
@@ -147,6 +156,7 @@ export default function Column({
|
|
|
147
156
|
"data-path-key": fullPathKey,
|
|
148
157
|
onClick: () => {
|
|
149
158
|
triggerOpenPath();
|
|
159
|
+
|
|
150
160
|
if (!multiple || isMergedLeaf) {
|
|
151
161
|
triggerSelect();
|
|
152
162
|
}
|
|
@@ -11,6 +11,7 @@ import useActive from './useActive';
|
|
|
11
11
|
import useKeyboard from './useKeyboard';
|
|
12
12
|
const RefOptionList = React.forwardRef((props, ref) => {
|
|
13
13
|
var _a, _b;
|
|
14
|
+
|
|
14
15
|
const {
|
|
15
16
|
prefixCls,
|
|
16
17
|
multiple,
|
|
@@ -36,26 +37,30 @@ const RefOptionList = React.forwardRef((props, ref) => {
|
|
|
36
37
|
renderItem,
|
|
37
38
|
dropdownVisible
|
|
38
39
|
} = React.useContext(CascaderContext);
|
|
39
|
-
const mergedPrefixCls = dropdownPrefixCls || prefixCls;
|
|
40
|
-
|
|
40
|
+
const mergedPrefixCls = dropdownPrefixCls || prefixCls; // ========================= loadData =========================
|
|
41
|
+
|
|
41
42
|
const [loadingKeys, setLoadingKeys] = React.useState([]);
|
|
43
|
+
|
|
42
44
|
const internalLoadData = valueCells => {
|
|
43
45
|
// Do not load when search
|
|
44
46
|
if (!loadData || searchValue) {
|
|
45
47
|
return;
|
|
46
48
|
}
|
|
49
|
+
|
|
47
50
|
const optionList = toPathOptions(valueCells, options, fieldNames);
|
|
48
51
|
const rawOptions = optionList.map(({
|
|
49
52
|
option
|
|
50
53
|
}) => option);
|
|
51
54
|
const lastOption = rawOptions[rawOptions.length - 1];
|
|
55
|
+
|
|
52
56
|
if (lastOption && !isLeaf(lastOption, fieldNames)) {
|
|
53
57
|
const pathKey = toPathKey(valueCells);
|
|
54
58
|
setLoadingKeys(keys => [...keys, pathKey]);
|
|
55
59
|
loadData(rawOptions);
|
|
56
60
|
}
|
|
57
|
-
};
|
|
58
|
-
|
|
61
|
+
}; // zombieJ: This is bad. We should make this same as `rc-tree` to use Promise instead.
|
|
62
|
+
|
|
63
|
+
|
|
59
64
|
React.useEffect(() => {
|
|
60
65
|
if (loadingKeys.length) {
|
|
61
66
|
loadingKeys.forEach(loadingKey => {
|
|
@@ -64,23 +69,25 @@ const RefOptionList = React.forwardRef((props, ref) => {
|
|
|
64
69
|
option
|
|
65
70
|
}) => option);
|
|
66
71
|
const lastOption = optionList[optionList.length - 1];
|
|
72
|
+
|
|
67
73
|
if (!lastOption || lastOption[fieldNames.children] || isLeaf(lastOption, fieldNames)) {
|
|
68
74
|
setLoadingKeys(keys => keys.filter(key => key !== loadingKey));
|
|
69
75
|
}
|
|
70
76
|
});
|
|
71
77
|
}
|
|
72
|
-
}, [options, loadingKeys, fieldNames]);
|
|
73
|
-
|
|
78
|
+
}, [options, loadingKeys, fieldNames]); // ========================== Values ==========================
|
|
79
|
+
|
|
74
80
|
const checkedSet = React.useMemo(() => new Set(toPathKeys(values)), [values]);
|
|
75
|
-
const halfCheckedSet = React.useMemo(() => new Set(toPathKeys(halfValues)), [halfValues]);
|
|
76
|
-
|
|
77
|
-
const [activeValueCells, setActiveValueCells] = useActive();
|
|
78
|
-
|
|
81
|
+
const halfCheckedSet = React.useMemo(() => new Set(toPathKeys(halfValues)), [halfValues]); // ====================== Accessibility =======================
|
|
82
|
+
|
|
83
|
+
const [activeValueCells, setActiveValueCells] = useActive(); // =========================== Path ===========================
|
|
84
|
+
|
|
79
85
|
const onPathOpen = nextValueCells => {
|
|
80
|
-
setActiveValueCells(nextValueCells);
|
|
81
|
-
|
|
86
|
+
setActiveValueCells(nextValueCells); // Trigger loadData
|
|
87
|
+
|
|
82
88
|
internalLoadData(nextValueCells);
|
|
83
89
|
};
|
|
90
|
+
|
|
84
91
|
const isSelectable = option => {
|
|
85
92
|
const {
|
|
86
93
|
disabled
|
|
@@ -88,49 +95,59 @@ const RefOptionList = React.forwardRef((props, ref) => {
|
|
|
88
95
|
const isMergedLeaf = isLeaf(option, fieldNames);
|
|
89
96
|
return !disabled && (isMergedLeaf || changeOnSelect || multiple);
|
|
90
97
|
};
|
|
98
|
+
|
|
91
99
|
const onPathSelect = (valuePath, leaf, fromKeyboard = false) => {
|
|
92
100
|
onSelect(valuePath);
|
|
101
|
+
|
|
93
102
|
if (!multiple && (leaf || changeOnSelect && (expandTrigger === 'hover' || fromKeyboard))) {
|
|
94
103
|
toggleOpen(false);
|
|
95
104
|
}
|
|
96
|
-
};
|
|
97
|
-
|
|
105
|
+
}; // ========================== Option ==========================
|
|
106
|
+
|
|
107
|
+
|
|
98
108
|
const mergedOptions = React.useMemo(() => {
|
|
99
109
|
if (searchValue) {
|
|
100
110
|
return searchOptions;
|
|
101
111
|
}
|
|
112
|
+
|
|
102
113
|
return options;
|
|
103
|
-
}, [searchValue, searchOptions, options]);
|
|
104
|
-
|
|
114
|
+
}, [searchValue, searchOptions, options]); // ========================== Column ==========================
|
|
115
|
+
|
|
105
116
|
const optionColumns = React.useMemo(() => {
|
|
106
117
|
const optionList = [{
|
|
107
118
|
options: mergedOptions
|
|
108
119
|
}];
|
|
109
120
|
let currentList = mergedOptions;
|
|
121
|
+
|
|
110
122
|
for (let i = 0; i < activeValueCells.length; i += 1) {
|
|
111
123
|
const activeValueCell = activeValueCells[i];
|
|
112
124
|
const currentOption = currentList.find(option => option[fieldNames.value] === activeValueCell);
|
|
113
125
|
const subOptions = currentOption === null || currentOption === void 0 ? void 0 : currentOption[fieldNames.children];
|
|
126
|
+
|
|
114
127
|
if (!(subOptions === null || subOptions === void 0 ? void 0 : subOptions.length)) {
|
|
115
128
|
break;
|
|
116
129
|
}
|
|
130
|
+
|
|
117
131
|
currentList = subOptions;
|
|
118
132
|
optionList.push({
|
|
119
133
|
options: subOptions
|
|
120
134
|
});
|
|
121
135
|
}
|
|
136
|
+
|
|
122
137
|
return optionList;
|
|
123
|
-
}, [mergedOptions, activeValueCells, fieldNames]);
|
|
124
|
-
|
|
138
|
+
}, [mergedOptions, activeValueCells, fieldNames]); // ========================= Keyboard =========================
|
|
139
|
+
|
|
125
140
|
const onKeyboardSelect = (selectValueCells, option) => {
|
|
126
141
|
if (isSelectable(option)) {
|
|
127
142
|
onPathSelect(selectValueCells, isLeaf(option, fieldNames), true);
|
|
128
143
|
}
|
|
129
144
|
};
|
|
130
|
-
|
|
131
|
-
// >>>>> Active Scroll
|
|
145
|
+
|
|
146
|
+
useKeyboard(ref, mergedOptions, fieldNames, activeValueCells, onPathOpen, onKeyboardSelect); // >>>>> Active Scroll
|
|
147
|
+
|
|
132
148
|
React.useEffect(() => {
|
|
133
149
|
var _a;
|
|
150
|
+
|
|
134
151
|
for (let i = 0; i < activeValueCells.length; i += 1) {
|
|
135
152
|
const cellPath = activeValueCells.slice(0, i + 1);
|
|
136
153
|
const cellKeyPath = toPathKey(cellPath);
|
|
@@ -141,9 +158,9 @@ const RefOptionList = React.forwardRef((props, ref) => {
|
|
|
141
158
|
scrollIntoParentView(ele);
|
|
142
159
|
}
|
|
143
160
|
}
|
|
144
|
-
}, [activeValueCells]);
|
|
145
|
-
// ========================== Render ==========================
|
|
161
|
+
}, [activeValueCells]); // ========================== Render ==========================
|
|
146
162
|
// >>>>> Empty
|
|
163
|
+
|
|
147
164
|
const isEmpty = !((_b = (_a = optionColumns[0]) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.length);
|
|
148
165
|
const emptyList = [{
|
|
149
166
|
[fieldNames.value]: '__EMPTY__',
|
|
@@ -159,8 +176,8 @@ const RefOptionList = React.forwardRef((props, ref) => {
|
|
|
159
176
|
halfCheckedSet,
|
|
160
177
|
loadingKeys,
|
|
161
178
|
isSelectable
|
|
162
|
-
});
|
|
163
|
-
|
|
179
|
+
}); // >>>>> Columns
|
|
180
|
+
|
|
164
181
|
const mergedOptionColumns = isEmpty ? [{
|
|
165
182
|
options: emptyList
|
|
166
183
|
}] : optionColumns;
|
|
@@ -180,8 +197,8 @@ const RefOptionList = React.forwardRef((props, ref) => {
|
|
|
180
197
|
activeValue: activeValue,
|
|
181
198
|
renderItem: renderItem
|
|
182
199
|
}));
|
|
183
|
-
});
|
|
184
|
-
|
|
200
|
+
}); // >>>>> Render
|
|
201
|
+
|
|
185
202
|
return React.createElement("div", {
|
|
186
203
|
className: classNames(`${mergedPrefixCls}-menus`, {
|
|
187
204
|
[`${mergedPrefixCls}-menu-empty`]: isEmpty,
|
|
@@ -5,6 +5,7 @@ import { useBaseProps } from 'rc-select';
|
|
|
5
5
|
/**
|
|
6
6
|
* Control the active open options path.
|
|
7
7
|
*/
|
|
8
|
+
|
|
8
9
|
export default (() => {
|
|
9
10
|
const {
|
|
10
11
|
multiple,
|
|
@@ -12,18 +13,19 @@ export default (() => {
|
|
|
12
13
|
} = useBaseProps();
|
|
13
14
|
const {
|
|
14
15
|
values
|
|
15
|
-
} = React.useContext(CascaderContext);
|
|
16
|
-
// Record current dropdown active options
|
|
16
|
+
} = React.useContext(CascaderContext); // Record current dropdown active options
|
|
17
17
|
// This also control the open status
|
|
18
|
+
|
|
18
19
|
const [activeValueCells, setActiveValueCells] = React.useState([]);
|
|
19
20
|
React.useEffect(() => {
|
|
20
21
|
if (open && !multiple) {
|
|
21
22
|
const firstValueCells = values[0];
|
|
22
23
|
setActiveValueCells(firstValueCells || []);
|
|
23
24
|
}
|
|
24
|
-
},
|
|
25
|
+
},
|
|
26
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
25
27
|
[open]
|
|
26
|
-
/* eslint-enable react-hooks/exhaustive-deps */
|
|
27
|
-
|
|
28
|
+
/* eslint-enable react-hooks/exhaustive-deps */
|
|
29
|
+
);
|
|
28
30
|
return [activeValueCells, setActiveValueCells];
|
|
29
31
|
});
|