@oceanbase/design 1.0.0-alpha.2 → 1.0.0-alpha.21
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/dist/design.min.css +1 -1
- package/dist/design.min.js +1 -1
- package/dist/reset.css +2 -1
- package/dist/static/Inter-Medium.ea234620.woff2 +0 -0
- package/dist/static/Inter-Regular.34ba43c9.woff2 +0 -0
- package/dist/static/Inter-SemiBold.95439fb4.woff2 +0 -0
- package/es/_util/document.d.ts +11 -0
- package/es/_util/document.js +65 -0
- package/es/_util/genComponentStyleHook.d.ts +21 -4
- package/es/_util/genComponentStyleHook.js +68 -20
- package/es/_util/index.d.ts +2 -0
- package/es/_util/index.js +28 -1
- package/es/_util/styleChecker.js +1 -0
- package/es/affix/index.js +1 -0
- package/es/alert/index.d.ts +2 -2
- package/es/alert/index.js +27 -6
- package/es/alert/style/index.d.ts +2 -5
- package/es/alert/style/index.js +162 -67
- package/es/anchor/index.js +1 -0
- package/es/app/index.d.ts +8 -0
- package/es/app/index.js +44 -1
- package/es/app/style/index.d.ts +6 -0
- package/es/app/style/index.js +9 -0
- package/es/auto-complete/index.js +1 -0
- package/es/avatar/index.js +1 -0
- package/es/badge/index.d.ts +2 -0
- package/es/badge/index.js +38 -14
- package/es/badge/style/index.d.ts +2 -5
- package/es/badge/style/index.js +9 -9
- package/es/breadcrumb/Breadcrumb.js +1 -0
- package/es/breadcrumb/index.js +1 -0
- package/es/button/index.js +19 -6
- package/es/button/style/index.d.ts +4 -5
- package/es/button/style/index.js +49 -7
- package/es/calendar/index.js +1 -0
- package/es/card/index.d.ts +10 -0
- package/es/card/index.js +106 -11
- package/es/card/style/index.d.ts +2 -5
- package/es/card/style/index.js +113 -31
- package/es/carousel/index.js +1 -0
- package/es/cascader/index.js +1 -0
- package/es/checkbox/index.js +10 -2
- package/es/checkbox/style/index.d.ts +2 -5
- package/es/checkbox/style/index.js +14 -11
- package/es/collapse/index.js +1 -0
- package/es/color-picker/index.js +1 -0
- package/es/config-provider/DefaultRenderEmpty.js +1 -0
- package/es/config-provider/context.d.ts +11 -0
- package/es/config-provider/context.js +2 -1
- package/es/config-provider/index.d.ts +9 -3
- package/es/config-provider/index.js +137 -41
- package/es/date-picker/index.js +1 -0
- package/es/descriptions/hooks/useItems.d.ts +3 -3
- package/es/descriptions/hooks/useItems.js +1 -0
- package/es/descriptions/index.d.ts +10 -0
- package/es/descriptions/index.js +63 -5
- package/es/descriptions/style/index.d.ts +3 -6
- package/es/descriptions/style/index.js +68 -9
- package/es/divider/index.js +1 -0
- package/es/drawer/index.d.ts +2 -0
- package/es/drawer/index.js +44 -8
- package/es/drawer/style/index.d.ts +2 -5
- package/es/drawer/style/index.js +66 -17
- package/es/dropdown/dropdown-button.js +27 -6
- package/es/dropdown/index.js +29 -3
- package/es/dropdown/style/index.d.ts +6 -0
- package/es/{_util/genStyle.js → dropdown/style/index.js} +18 -12
- package/es/empty/colored.js +1 -0
- package/es/empty/database.js +1 -0
- package/es/empty/default.js +1 -0
- package/es/empty/guide.js +1 -0
- package/es/empty/index.js +5 -3
- package/es/empty/style/index.d.ts +2 -5
- package/es/empty/style/index.js +11 -10
- package/es/filter/FilterContext.d.ts +27 -0
- package/es/filter/FilterContext.js +26 -0
- package/es/filter/components/ClearIcon.d.ts +6 -0
- package/es/filter/components/ClearIcon.js +26 -0
- package/es/filter/components/CountNumber.d.ts +8 -0
- package/es/filter/components/CountNumber.js +20 -0
- package/es/filter/components/FilterButton.d.ts +34 -0
- package/es/filter/components/FilterButton.js +221 -0
- package/es/filter/components/FilterCascader/components/CascaderOption/OptionCheckbox.d.ts +20 -0
- package/es/filter/components/FilterCascader/components/CascaderOption/OptionCheckbox.js +101 -0
- package/es/filter/components/FilterCascader/components/CascaderOption/OptionItem.d.ts +13 -0
- package/es/filter/components/FilterCascader/components/CascaderOption/OptionItem.js +44 -0
- package/es/filter/components/FilterCascader/components/FlatCascaderContent/index.d.ts +17 -0
- package/es/filter/components/FilterCascader/components/FlatCascaderContent/index.js +78 -0
- package/es/filter/components/FilterCascader/components/NormalCascaderContent.d.ts +24 -0
- package/es/filter/components/FilterCascader/components/NormalCascaderContent.js +279 -0
- package/es/filter/components/FilterCascader/constants.d.ts +7 -0
- package/es/filter/components/FilterCascader/constants.js +8 -0
- package/es/filter/components/FilterCascader/hooks/useCascaderCallbacks.d.ts +12 -0
- package/es/filter/components/FilterCascader/hooks/useCascaderCallbacks.js +101 -0
- package/es/filter/components/FilterCascader/hooks/useCascaderLabels.d.ts +9 -0
- package/es/filter/components/FilterCascader/hooks/useCascaderLabels.js +50 -0
- package/es/filter/components/FilterCascader/hooks/useNormalizedValue.d.ts +7 -0
- package/es/filter/components/FilterCascader/hooks/useNormalizedValue.js +53 -0
- package/es/filter/components/FilterCascader/index.d.ts +5 -0
- package/es/filter/components/FilterCascader/index.js +317 -0
- package/es/filter/components/FilterCascader/types.d.ts +56 -0
- package/es/filter/components/FilterCascader/types.js +1 -0
- package/es/filter/components/FilterCascader/utils/countUtils.d.ts +13 -0
- package/es/filter/components/FilterCascader/utils/countUtils.js +48 -0
- package/es/filter/components/FilterCascader/utils/pathUtils.d.ts +17 -0
- package/es/filter/components/FilterCascader/utils/pathUtils.js +91 -0
- package/es/filter/components/FilterCheckbox.d.ts +26 -0
- package/es/filter/components/FilterCheckbox.js +358 -0
- package/es/filter/components/FilterInput.d.ts +18 -0
- package/es/filter/components/FilterInput.js +148 -0
- package/es/filter/components/FilterRange.d.ts +19 -0
- package/es/filter/components/FilterRange.js +201 -0
- package/es/filter/components/FilterSelect.d.ts +23 -0
- package/es/filter/components/FilterSelect.js +245 -0
- package/es/filter/components/FilterSlot.d.ts +28 -0
- package/es/filter/components/FilterSlot.js +189 -0
- package/es/filter/components/FilterSwitch.d.ts +13 -0
- package/es/filter/components/FilterSwitch.js +102 -0
- package/es/filter/components/FilterWrap.d.ts +20 -0
- package/es/filter/components/FilterWrap.js +329 -0
- package/es/filter/components/ResponsiveFilterGroup.d.ts +27 -0
- package/es/filter/components/ResponsiveFilterGroup.js +477 -0
- package/es/filter/components/WrappedTagsDisplay.d.ts +22 -0
- package/es/filter/components/WrappedTagsDisplay.js +80 -0
- package/es/filter/hooks/index.d.ts +4 -0
- package/es/filter/hooks/index.js +3 -0
- package/es/filter/hooks/useControlledState.d.ts +9 -0
- package/es/filter/hooks/useControlledState.js +37 -0
- package/es/filter/hooks/useFilterCollapsed.d.ts +8 -0
- package/es/filter/hooks/useFilterCollapsed.js +15 -0
- package/es/filter/hooks/useFilterTooltip.d.ts +29 -0
- package/es/filter/hooks/useFilterTooltip.js +127 -0
- package/es/filter/index.d.ts +24 -0
- package/es/filter/index.js +27 -0
- package/es/filter/style/index.d.ts +15 -0
- package/es/filter/style/index.js +245 -0
- package/es/filter/type.d.ts +41 -0
- package/es/filter/type.js +1 -0
- package/es/filter/utils.d.ts +50 -0
- package/es/filter/utils.js +189 -0
- package/es/float-button/index.js +1 -0
- package/es/fonts/Inter-Medium.woff2 +0 -0
- package/es/fonts/Inter-Regular.woff2 +0 -0
- package/es/fonts/Inter-SemiBold.woff2 +0 -0
- package/es/form/FormItem.d.ts +1 -0
- package/es/form/FormItem.js +27 -11
- package/es/form/index.js +10 -2
- package/es/form/style/index.d.ts +2 -5
- package/es/form/style/index.js +21 -8
- package/es/grid/col.js +1 -0
- package/es/grid/index.js +1 -0
- package/es/grid/row.js +1 -0
- package/es/image/index.js +1 -0
- package/es/index.d.ts +182 -4
- package/es/index.js +4 -2
- package/es/input/Input.d.ts +2 -0
- package/es/input/Input.js +31 -7
- package/es/input/Password.js +25 -5
- package/es/input/Search.js +25 -5
- package/es/input/TextArea.js +25 -5
- package/es/input/index.js +1 -0
- package/es/input/style/index.d.ts +6 -0
- package/es/input/style/index.js +31 -0
- package/es/input-number/index.d.ts +2 -1
- package/es/input-number/index.js +19 -4
- package/es/input-number/style/index.d.ts +6 -0
- package/es/input-number/style/index.js +26 -0
- package/es/layout/index.js +1 -0
- package/es/list/index.js +1 -0
- package/es/locale/en-US.js +10 -2
- package/es/locale/index.d.ts +11 -0
- package/es/locale/index.js +1 -0
- package/es/locale/ja-JP.d.ts +3 -0
- package/es/locale/ja-JP.js +36 -0
- package/es/locale/zh-CN.js +10 -2
- package/es/locale/zh-TW.js +10 -2
- package/es/lottie/index.js +1 -0
- package/es/mentions/index.js +1 -0
- package/es/menu/index.js +1 -0
- package/es/message/index.js +1 -0
- package/es/modal/Modal.d.ts +3 -1
- package/es/modal/Modal.js +69 -14
- package/es/modal/Progress.js +1 -0
- package/es/modal/index.js +1 -0
- package/es/modal/style/index.d.ts +2 -5
- package/es/modal/style/index.js +96 -26
- package/es/notification/index.js +1 -0
- package/es/pagination/index.js +1 -0
- package/es/popconfirm/index.js +1 -0
- package/es/popover/index.js +1 -0
- package/es/progress/index.js +1 -0
- package/es/qrcode/index.js +1 -0
- package/es/radio/RadioButton.d.ts +8 -0
- package/es/radio/RadioButton.js +42 -0
- package/es/radio/index.d.ts +4 -0
- package/es/radio/index.js +12 -3
- package/es/radio/style/index.d.ts +2 -5
- package/es/radio/style/index.js +30 -10
- package/es/rate/index.js +1 -0
- package/es/result/403.js +1 -0
- package/es/result/404.js +1 -0
- package/es/result/500.js +1 -0
- package/es/result/Error.js +1 -0
- package/es/result/Processing.js +1 -0
- package/es/result/Success.js +1 -0
- package/es/result/Warning.js +1 -0
- package/es/result/index.d.ts +2 -2
- package/es/result/index.js +15 -6
- package/es/result/style/index.d.ts +2 -5
- package/es/result/style/index.js +3 -6
- package/es/segmented/index.d.ts +1 -0
- package/es/segmented/index.js +25 -9
- package/es/segmented/style/index.d.ts +1 -4
- package/es/segmented/style/index.js +4 -6
- package/es/select/index.js +10 -2
- package/es/select/style/index.d.ts +2 -5
- package/es/select/style/index.js +13 -8
- package/es/skeleton/index.js +1 -0
- package/es/slider/index.js +10 -2
- package/es/slider/style/index.d.ts +2 -5
- package/es/slider/style/index.js +11 -11
- package/es/space/index.js +10 -2
- package/es/space/style/index.d.ts +2 -5
- package/es/space/style/index.js +3 -6
- package/es/spin/assets/spin-gray.json +1 -1
- package/es/spin/assets/spin.json +1 -1
- package/es/spin/index.js +10 -2
- package/es/spin/style/index.d.ts +2 -5
- package/es/spin/style/index.js +26 -29
- package/es/static-function/index.d.ts +176 -1
- package/es/static-function/index.js +18 -5
- package/es/statistic/index.js +1 -0
- package/es/steps/index.js +1 -0
- package/es/style/global.d.ts +9 -0
- package/es/style/global.js +166 -0
- package/es/style/reset.css +2 -1
- package/es/switch/index.js +10 -2
- package/es/switch/style/index.d.ts +2 -5
- package/es/switch/style/index.js +7 -8
- package/es/table/index.d.ts +1 -4
- package/es/table/index.js +264 -22
- package/es/table/style/index.d.ts +2 -5
- package/es/table/style/index.js +188 -50
- package/es/tabs/TabPane.js +1 -0
- package/es/tabs/hooks/useLegacyItems.js +1 -0
- package/es/tabs/index.js +10 -2
- package/es/tabs/style/index.d.ts +2 -5
- package/es/tabs/style/index.js +9 -8
- package/es/tag/index.d.ts +1 -0
- package/es/tag/index.js +21 -5
- package/es/tag/style/index.d.ts +3 -8
- package/es/tag/style/index.js +50 -39
- package/es/theme/compact.d.ts +1 -1
- package/es/theme/compact.js +2 -6
- package/es/theme/dark.d.ts +1 -48
- package/es/theme/default.d.ts +65 -2
- package/es/theme/default.js +368 -65
- package/es/theme/index.d.ts +22 -57
- package/es/theme/index.js +13 -1
- package/es/theme/interface.d.ts +147 -0
- package/es/theme/interface.js +4 -1
- package/es/theme/obToken.d.ts +206 -0
- package/es/theme/obToken.js +255 -0
- package/es/theme/obTokenMeta.d.ts +24 -0
- package/es/theme/obTokenMeta.js +937 -0
- package/es/theme/style/aliyun.less +41 -41
- package/es/theme/style/compact.less +159 -130
- package/es/theme/style/dark.less +54 -54
- package/es/theme/style/default.less +160 -131
- package/es/time-picker/index.js +1 -0
- package/es/timeline/index.js +1 -0
- package/es/tooltip/MouseTooltip.js +1 -0
- package/es/tooltip/ReactStickyMouseTooltip.js +1 -0
- package/es/tooltip/index.js +5 -4
- package/es/tooltip/style/index.d.ts +2 -5
- package/es/tooltip/style/index.js +10 -13
- package/es/tour/index.js +1 -0
- package/es/transfer/index.js +1 -0
- package/es/tree/index.js +1 -0
- package/es/tree-select/index.js +10 -2
- package/es/tree-select/style/index.d.ts +2 -5
- package/es/tree-select/style/index.js +3 -6
- package/es/typography/Link.js +10 -2
- package/es/typography/Paragraph.js +10 -2
- package/es/typography/Text.d.ts +1 -0
- package/es/typography/Text.js +13 -4
- package/es/typography/Title.js +10 -2
- package/es/typography/hooks/useClassName.d.ts +1 -1
- package/es/typography/hooks/useClassName.js +2 -2
- package/es/typography/index.d.ts +12 -1
- package/es/typography/index.js +3 -1
- package/es/typography/style/index.d.ts +2 -5
- package/es/typography/style/index.js +37 -28
- package/es/upload/index.js +1 -0
- package/es/watermark/index.js +1 -0
- package/lib/_util/document.d.ts +11 -0
- package/lib/_util/document.js +74 -0
- package/lib/_util/genComponentStyleHook.d.ts +21 -4
- package/lib/_util/genComponentStyleHook.js +69 -57
- package/lib/_util/getEllipsisConfig.js +16 -39
- package/lib/_util/index.d.ts +2 -0
- package/lib/_util/index.js +51 -29
- package/lib/_util/styleChecker.js +32 -53
- package/lib/_util/type.js +4 -16
- package/lib/_util/useFlexGapSupport.js +11 -36
- package/lib/affix/index.js +15 -22
- package/lib/alert/index.d.ts +2 -2
- package/lib/alert/index.js +70 -79
- package/lib/alert/style/index.d.ts +2 -5
- package/lib/alert/style/index.js +199 -105
- package/lib/anchor/index.js +26 -24
- package/lib/app/index.d.ts +8 -0
- package/lib/app/index.js +49 -22
- package/lib/app/style/index.d.ts +6 -0
- package/lib/app/style/index.js +18 -0
- package/lib/auto-complete/index.js +15 -22
- package/lib/avatar/index.js +26 -24
- package/lib/badge/index.d.ts +2 -0
- package/lib/badge/index.js +108 -102
- package/lib/badge/style/index.d.ts +2 -5
- package/lib/badge/style/index.js +26 -46
- package/lib/breadcrumb/Breadcrumb.js +15 -22
- package/lib/breadcrumb/index.js +31 -32
- package/lib/button/index.js +56 -60
- package/lib/button/style/index.d.ts +4 -5
- package/lib/button/style/index.js +73 -35
- package/lib/calendar/index.js +15 -22
- package/lib/card/Card.js +14 -21
- package/lib/card/index.d.ts +10 -0
- package/lib/card/index.js +202 -114
- package/lib/card/style/index.d.ts +2 -5
- package/lib/card/style/index.js +219 -88
- package/lib/carousel/index.js +15 -22
- package/lib/cascader/index.js +15 -22
- package/lib/checkbox/index.js +52 -69
- package/lib/checkbox/style/index.d.ts +2 -5
- package/lib/checkbox/style/index.js +25 -38
- package/lib/collapse/index.js +15 -22
- package/lib/color-picker/index.js +15 -22
- package/lib/color-picker/interface.js +14 -21
- package/lib/config-provider/DefaultRenderEmpty.js +34 -48
- package/lib/config-provider/SizeContext.js +14 -21
- package/lib/config-provider/context.d.ts +11 -0
- package/lib/config-provider/context.js +14 -21
- package/lib/config-provider/index.d.ts +9 -3
- package/lib/config-provider/index.js +254 -135
- package/lib/config-provider/navigate.js +4 -16
- package/lib/date-picker/index.js +15 -22
- package/lib/descriptions/Item.js +6 -24
- package/lib/descriptions/hooks/useItems.d.ts +3 -3
- package/lib/descriptions/hooks/useItems.js +50 -72
- package/lib/descriptions/index.d.ts +10 -0
- package/lib/descriptions/index.js +104 -75
- package/lib/descriptions/style/index.d.ts +3 -6
- package/lib/descriptions/style/index.js +138 -50
- package/lib/divider/index.js +15 -22
- package/lib/drawer/index.d.ts +2 -0
- package/lib/drawer/index.js +140 -118
- package/lib/drawer/style/index.d.ts +2 -5
- package/lib/drawer/style/index.js +94 -52
- package/lib/dropdown/dropdown-button.js +34 -39
- package/lib/dropdown/index.js +47 -47
- package/lib/dropdown/style/index.d.ts +6 -0
- package/lib/dropdown/style/index.js +35 -0
- package/lib/empty/colored.js +325 -356
- package/lib/empty/database.js +227 -251
- package/lib/empty/default.js +53 -54
- package/lib/empty/guide.js +147 -210
- package/lib/empty/index.js +77 -91
- package/lib/empty/style/index.d.ts +2 -5
- package/lib/empty/style/index.js +32 -47
- package/lib/filter/FilterContext.d.ts +27 -0
- package/lib/filter/FilterContext.js +33 -0
- package/lib/filter/components/ClearIcon.d.ts +6 -0
- package/lib/filter/components/ClearIcon.js +35 -0
- package/lib/filter/components/CountNumber.d.ts +8 -0
- package/lib/filter/components/CountNumber.js +30 -0
- package/lib/filter/components/FilterButton.d.ts +34 -0
- package/lib/filter/components/FilterButton.js +194 -0
- package/lib/filter/components/FilterCascader/components/CascaderOption/OptionCheckbox.d.ts +20 -0
- package/lib/filter/components/FilterCascader/components/CascaderOption/OptionCheckbox.js +91 -0
- package/lib/filter/components/FilterCascader/components/CascaderOption/OptionItem.d.ts +13 -0
- package/lib/filter/components/FilterCascader/components/CascaderOption/OptionItem.js +51 -0
- package/lib/filter/components/FilterCascader/components/FlatCascaderContent/index.d.ts +17 -0
- package/lib/filter/components/FilterCascader/components/FlatCascaderContent/index.js +77 -0
- package/lib/filter/components/FilterCascader/components/NormalCascaderContent.d.ts +24 -0
- package/lib/filter/components/FilterCascader/components/NormalCascaderContent.js +258 -0
- package/lib/filter/components/FilterCascader/constants.d.ts +7 -0
- package/lib/filter/components/FilterCascader/constants.js +14 -0
- package/lib/filter/components/FilterCascader/hooks/useCascaderCallbacks.d.ts +12 -0
- package/lib/filter/components/FilterCascader/hooks/useCascaderCallbacks.js +81 -0
- package/lib/filter/components/FilterCascader/hooks/useCascaderLabels.d.ts +9 -0
- package/lib/filter/components/FilterCascader/hooks/useCascaderLabels.js +56 -0
- package/lib/filter/components/FilterCascader/hooks/useNormalizedValue.d.ts +7 -0
- package/lib/filter/components/FilterCascader/hooks/useNormalizedValue.js +48 -0
- package/lib/filter/components/FilterCascader/index.d.ts +5 -0
- package/lib/filter/components/FilterCascader/index.js +298 -0
- package/lib/filter/components/FilterCascader/types.d.ts +56 -0
- package/lib/filter/components/FilterCascader/types.js +5 -0
- package/lib/filter/components/FilterCascader/utils/countUtils.d.ts +13 -0
- package/lib/filter/components/FilterCascader/utils/countUtils.js +49 -0
- package/lib/filter/components/FilterCascader/utils/pathUtils.d.ts +17 -0
- package/lib/filter/components/FilterCascader/utils/pathUtils.js +56 -0
- package/lib/filter/components/FilterCheckbox.d.ts +26 -0
- package/lib/filter/components/FilterCheckbox.js +319 -0
- package/lib/filter/components/FilterInput.d.ts +18 -0
- package/lib/filter/components/FilterInput.js +134 -0
- package/lib/filter/components/FilterRange.d.ts +19 -0
- package/lib/filter/components/FilterRange.js +186 -0
- package/lib/filter/components/FilterSelect.d.ts +23 -0
- package/lib/filter/components/FilterSelect.js +221 -0
- package/lib/filter/components/FilterSlot.d.ts +28 -0
- package/lib/filter/components/FilterSlot.js +174 -0
- package/lib/filter/components/FilterSwitch.d.ts +13 -0
- package/lib/filter/components/FilterSwitch.js +91 -0
- package/lib/filter/components/FilterWrap.d.ts +20 -0
- package/lib/filter/components/FilterWrap.js +306 -0
- package/lib/filter/components/ResponsiveFilterGroup.d.ts +27 -0
- package/lib/filter/components/ResponsiveFilterGroup.js +412 -0
- package/lib/filter/components/WrappedTagsDisplay.d.ts +22 -0
- package/lib/filter/components/WrappedTagsDisplay.js +84 -0
- package/lib/filter/hooks/index.d.ts +4 -0
- package/lib/filter/hooks/index.js +26 -0
- package/lib/filter/hooks/useControlledState.d.ts +9 -0
- package/lib/filter/hooks/useControlledState.js +34 -0
- package/lib/filter/hooks/useFilterCollapsed.d.ts +8 -0
- package/lib/filter/hooks/useFilterCollapsed.js +21 -0
- package/lib/filter/hooks/useFilterTooltip.d.ts +29 -0
- package/lib/filter/hooks/useFilterTooltip.js +121 -0
- package/lib/filter/index.d.ts +24 -0
- package/lib/filter/index.js +45 -0
- package/lib/filter/style/index.d.ts +15 -0
- package/lib/filter/style/index.js +308 -0
- package/lib/filter/type.d.ts +41 -0
- package/lib/filter/type.js +5 -0
- package/lib/filter/utils.d.ts +50 -0
- package/lib/filter/utils.js +192 -0
- package/lib/float-button/index.js +15 -22
- package/lib/float-button/interface.js +14 -21
- package/lib/fonts/Inter-Medium.woff2 +0 -0
- package/lib/fonts/Inter-Regular.woff2 +0 -0
- package/lib/fonts/Inter-SemiBold.woff2 +0 -0
- package/lib/form/FormItem.d.ts +1 -0
- package/lib/form/FormItem.js +81 -77
- package/lib/form/index.js +58 -76
- package/lib/form/interface.js +14 -21
- package/lib/form/style/index.d.ts +2 -5
- package/lib/form/style/index.js +42 -38
- package/lib/grid/col.js +28 -45
- package/lib/grid/index.js +25 -44
- package/lib/grid/row.js +30 -45
- package/lib/image/index.js +15 -22
- package/lib/index.d.ts +182 -4
- package/lib/index.js +363 -152
- package/lib/input/Input.d.ts +2 -0
- package/lib/input/Input.js +62 -52
- package/lib/input/Password.js +59 -59
- package/lib/input/Search.js +55 -53
- package/lib/input/TextArea.js +59 -59
- package/lib/input/index.js +30 -50
- package/lib/input/style/index.d.ts +6 -0
- package/lib/input/style/index.js +55 -0
- package/lib/input-number/index.d.ts +2 -1
- package/lib/input-number/index.js +56 -61
- package/lib/input-number/style/index.d.ts +6 -0
- package/lib/input-number/style/index.js +43 -0
- package/lib/layout/index.js +15 -22
- package/lib/list/index.js +52 -59
- package/lib/locale/en-US.js +29 -48
- package/lib/locale/index.d.ts +11 -0
- package/lib/locale/index.js +24 -38
- package/lib/locale/ja-JP.d.ts +3 -0
- package/lib/locale/ja-JP.js +41 -0
- package/lib/locale/useLocale.js +6 -24
- package/lib/locale/zh-CN.js +29 -48
- package/lib/locale/zh-TW.js +29 -48
- package/lib/lottie/index.js +61 -80
- package/lib/mentions/index.js +15 -22
- package/lib/menu/index.js +15 -22
- package/lib/menu/interface.js +14 -21
- package/lib/message/index.js +15 -22
- package/lib/message/interface.js +14 -21
- package/lib/modal/Modal.d.ts +3 -1
- package/lib/modal/Modal.js +112 -70
- package/lib/modal/Progress.js +44 -58
- package/lib/modal/index.js +23 -43
- package/lib/modal/interface.js +14 -21
- package/lib/modal/style/index.d.ts +2 -5
- package/lib/modal/style/index.js +136 -60
- package/lib/notification/index.js +15 -22
- package/lib/notification/interface.js +14 -21
- package/lib/pagination/index.js +15 -22
- package/lib/popconfirm/index.js +15 -22
- package/lib/popover/index.js +15 -22
- package/lib/progress/index.js +26 -24
- package/lib/progress/progress.js +14 -21
- package/lib/qrcode/index.js +15 -22
- package/lib/qrcode/interface.js +14 -21
- package/lib/radio/RadioButton.d.ts +8 -0
- package/lib/radio/RadioButton.js +44 -0
- package/lib/radio/index.d.ts +4 -0
- package/lib/radio/index.js +54 -62
- package/lib/radio/interface.js +14 -21
- package/lib/radio/style/index.d.ts +2 -5
- package/lib/radio/style/index.js +60 -38
- package/lib/rate/index.js +15 -22
- package/lib/result/403.js +166 -163
- package/lib/result/404.js +302 -305
- package/lib/result/500.js +226 -292
- package/lib/result/Error.js +126 -133
- package/lib/result/Processing.js +348 -248
- package/lib/result/Success.js +207 -203
- package/lib/result/Warning.js +513 -550
- package/lib/result/index.d.ts +2 -2
- package/lib/result/index.js +65 -80
- package/lib/result/style/index.d.ts +2 -5
- package/lib/result/style/index.js +16 -39
- package/lib/segmented/index.d.ts +1 -0
- package/lib/segmented/index.js +86 -73
- package/lib/segmented/style/index.d.ts +1 -4
- package/lib/segmented/style/index.js +21 -40
- package/lib/select/index.js +63 -81
- package/lib/select/style/index.d.ts +2 -5
- package/lib/select/style/index.js +29 -37
- package/lib/skeleton/index.js +15 -22
- package/lib/slider/index.js +48 -58
- package/lib/slider/style/index.d.ts +2 -5
- package/lib/slider/style/index.js +23 -40
- package/lib/space/index.js +62 -68
- package/lib/space/style/index.d.ts +2 -5
- package/lib/space/style/index.js +17 -40
- package/lib/spin/assets/spin-gray.json +1 -1
- package/lib/spin/assets/spin.json +1 -1
- package/lib/spin/index.js +58 -76
- package/lib/spin/style/index.d.ts +2 -5
- package/lib/spin/style/index.js +51 -60
- package/lib/static-function/index.d.ts +176 -1
- package/lib/static-function/index.js +52 -69
- package/lib/statistic/index.js +15 -22
- package/lib/steps/index.js +15 -22
- package/lib/style/global.d.ts +9 -0
- package/lib/style/global.js +210 -0
- package/lib/style/reset.css +2 -1
- package/lib/switch/index.js +52 -60
- package/lib/switch/style/index.d.ts +2 -5
- package/lib/switch/style/index.js +17 -37
- package/lib/table/hooks/useDefaultPagination.js +18 -46
- package/lib/table/index.d.ts +1 -4
- package/lib/table/index.js +412 -177
- package/lib/table/interface.js +14 -21
- package/lib/table/style/index.d.ts +2 -5
- package/lib/table/style/index.js +313 -106
- package/lib/tabs/TabPane.js +7 -25
- package/lib/tabs/hooks/useLegacyItems.js +27 -44
- package/lib/tabs/index.js +107 -120
- package/lib/tabs/style/index.d.ts +2 -5
- package/lib/tabs/style/index.js +31 -41
- package/lib/tag/index.d.ts +1 -0
- package/lib/tag/index.js +81 -89
- package/lib/tag/style/index.d.ts +3 -8
- package/lib/tag/style/index.js +71 -78
- package/lib/theme/aliyun.js +7 -34
- package/lib/theme/compact.d.ts +1 -1
- package/lib/theme/compact.js +9 -40
- package/lib/theme/dark.d.ts +1 -48
- package/lib/theme/dark.js +9 -36
- package/lib/theme/default.d.ts +65 -2
- package/lib/theme/default.js +388 -105
- package/lib/theme/index.d.ts +22 -57
- package/lib/theme/index.js +61 -56
- package/lib/theme/interface.d.ts +147 -0
- package/lib/theme/interface.js +14 -21
- package/lib/theme/internal.js +14 -21
- package/lib/theme/obToken.d.ts +206 -0
- package/lib/theme/obToken.js +462 -0
- package/lib/theme/obTokenMeta.d.ts +24 -0
- package/lib/theme/obTokenMeta.js +943 -0
- package/lib/theme/style/aliyun.less +41 -41
- package/lib/theme/style/compact.less +159 -130
- package/lib/theme/style/dark.less +54 -54
- package/lib/theme/style/default.less +160 -131
- package/lib/theme/themes/compact/index.js +19 -39
- package/lib/theme/themes/dark/index.js +19 -39
- package/lib/theme/themes/default/index.js +19 -39
- package/lib/theme/themes/seed.js +24 -43
- package/lib/theme/util/alias.js +19 -39
- package/lib/theme/util/format.js +15 -35
- package/lib/time-picker/index.js +15 -22
- package/lib/timeline/index.js +15 -22
- package/lib/tooltip/MouseTooltip.js +66 -77
- package/lib/tooltip/ReactStickyMouseTooltip.js +62 -87
- package/lib/tooltip/hooks/useTooltipTypeList.js +28 -61
- package/lib/tooltip/index.js +122 -133
- package/lib/tooltip/style/index.d.ts +2 -5
- package/lib/tooltip/style/index.js +26 -50
- package/lib/tour/index.js +15 -22
- package/lib/tour/interface.js +14 -21
- package/lib/transfer/index.js +15 -22
- package/lib/transfer/interface.js +14 -21
- package/lib/tree/index.js +15 -22
- package/lib/tree-select/index.js +66 -84
- package/lib/tree-select/style/index.d.ts +2 -5
- package/lib/tree-select/style/index.js +10 -35
- package/lib/typography/Link.js +54 -68
- package/lib/typography/Paragraph.js +54 -68
- package/lib/typography/Text.d.ts +1 -0
- package/lib/typography/Text.js +55 -68
- package/lib/typography/Title.js +54 -68
- package/lib/typography/hooks/useClassName.d.ts +1 -1
- package/lib/typography/hooks/useClassName.js +12 -42
- package/lib/typography/index.d.ts +12 -1
- package/lib/typography/index.js +89 -58
- package/lib/typography/style/index.d.ts +2 -5
- package/lib/typography/style/index.js +57 -64
- package/lib/upload/index.js +15 -22
- package/lib/upload/interface.js +14 -21
- package/lib/watermark/index.js +15 -22
- package/package.json +11 -10
- package/dist/static/Inter.f6bcdfb6.woff2 +0 -0
- package/es/_util/genStyle.d.ts +0 -2
- package/es/_util/getWeakenBorderColor.d.ts +0 -1
- package/es/_util/getWeakenBorderColor.js +0 -4
- package/es/fonts/Inter.woff2 +0 -0
- package/es/global.css +0 -48
- package/lib/_util/genStyle.d.ts +0 -2
- package/lib/_util/genStyle.js +0 -43
- package/lib/_util/getWeakenBorderColor.d.ts +0 -1
- package/lib/_util/getWeakenBorderColor.js +0 -32
- package/lib/fonts/Inter.woff2 +0 -0
- package/lib/global.css +0 -48
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
17
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
|
+
import React, { Children, isValidElement, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
19
|
+
import { Flex } from 'antd';
|
|
20
|
+
import { FilterOutlined } from '@oceanbase/icons';
|
|
21
|
+
import Button from "../../button";
|
|
22
|
+
import FilterWrap from "./FilterWrap";
|
|
23
|
+
import ConfigProvider from "../../config-provider";
|
|
24
|
+
import defaultLocale from "../../locale/en-US";
|
|
25
|
+
import { FilterProvider } from "../FilterContext";
|
|
26
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
+
// 检查元素是否是 Filter 组件(通过 __isFilterComponent 静态标记识别)
|
|
29
|
+
var isFilterComponent = function isFilterComponent(child) {
|
|
30
|
+
var _child$props;
|
|
31
|
+
var type = child.type;
|
|
32
|
+
if (type !== null && type !== void 0 && type.__isFilterComponent) return true;
|
|
33
|
+
if ((_child$props = child.props) !== null && _child$props !== void 0 && _child$props.children && /*#__PURE__*/isValidElement(child.props.children)) {
|
|
34
|
+
var innerType = child.props.children.type;
|
|
35
|
+
if (innerType !== null && innerType !== void 0 && innerType.__isFilterComponent) return true;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// 检查子元素是否可以被折叠(只有 Filter 组件默认可折叠,其他组件需要显式设置 collapsible)
|
|
41
|
+
var isCollapsibleCheck = function isCollapsibleCheck(child) {
|
|
42
|
+
var childProps = child.props;
|
|
43
|
+
if ((childProps === null || childProps === void 0 ? void 0 : childProps.collapsible) !== undefined) {
|
|
44
|
+
return childProps.collapsible !== false;
|
|
45
|
+
}
|
|
46
|
+
if (childProps !== null && childProps !== void 0 && childProps.children && /*#__PURE__*/isValidElement(childProps.children)) {
|
|
47
|
+
var _innerChild$props;
|
|
48
|
+
var innerChild = childProps.children;
|
|
49
|
+
if (((_innerChild$props = innerChild.props) === null || _innerChild$props === void 0 ? void 0 : _innerChild$props.collapsible) !== undefined) {
|
|
50
|
+
return innerChild.props.collapsible !== false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return isFilterComponent(child);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// 检查子元素是否应该始终折叠
|
|
57
|
+
var isAlwaysCollapseCheck = function isAlwaysCollapseCheck(child) {
|
|
58
|
+
var childProps = child.props;
|
|
59
|
+
if ((childProps === null || childProps === void 0 ? void 0 : childProps.alwaysCollapse) !== undefined) {
|
|
60
|
+
return childProps.alwaysCollapse === true;
|
|
61
|
+
}
|
|
62
|
+
if (childProps !== null && childProps !== void 0 && childProps.children && /*#__PURE__*/isValidElement(childProps.children)) {
|
|
63
|
+
var _innerChild$props2;
|
|
64
|
+
var innerChild = childProps.children;
|
|
65
|
+
if (((_innerChild$props2 = innerChild.props) === null || _innerChild$props2 === void 0 ? void 0 : _innerChild$props2.alwaysCollapse) !== undefined) {
|
|
66
|
+
return innerChild.props.alwaysCollapse === true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
};
|
|
71
|
+
var ResponsiveFilterGroup = function ResponsiveFilterGroup(_ref) {
|
|
72
|
+
var children = _ref.children,
|
|
73
|
+
_ref$gap = _ref.gap,
|
|
74
|
+
gap = _ref$gap === void 0 ? 8 : _ref$gap,
|
|
75
|
+
label = _ref.label,
|
|
76
|
+
_ref$icon = _ref.icon,
|
|
77
|
+
icon = _ref$icon === void 0 ? /*#__PURE__*/_jsx(FilterOutlined, {}) : _ref$icon,
|
|
78
|
+
onApply = _ref.onApply,
|
|
79
|
+
onClearAll = _ref.onClearAll,
|
|
80
|
+
_ref$showActions = _ref.showActions,
|
|
81
|
+
showActions = _ref$showActions === void 0 ? true : _ref$showActions,
|
|
82
|
+
style = _ref.style,
|
|
83
|
+
extra = _ref.extra,
|
|
84
|
+
_ref$showCount = _ref.showCount,
|
|
85
|
+
showCount = _ref$showCount === void 0 ? true : _ref$showCount,
|
|
86
|
+
customLocale = _ref.locale;
|
|
87
|
+
var _useContext = useContext(ConfigProvider.ConfigContext),
|
|
88
|
+
contextLocale = _useContext.locale;
|
|
89
|
+
var filterLocale = _objectSpread(_objectSpread(_objectSpread({}, defaultLocale.Filter), contextLocale === null || contextLocale === void 0 ? void 0 : contextLocale.Filter), customLocale);
|
|
90
|
+
var filterLabel = label !== null && label !== void 0 ? label : filterLocale === null || filterLocale === void 0 ? void 0 : filterLocale.filters;
|
|
91
|
+
var containerRef = useRef(null);
|
|
92
|
+
var filterButtonRef = useRef(null);
|
|
93
|
+
var moreButtonMeasureRef = useRef(null);
|
|
94
|
+
var cachedWidths = useRef([]);
|
|
95
|
+
var _useState = useState(null),
|
|
96
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
97
|
+
visibleCount = _useState2[0],
|
|
98
|
+
setVisibleCount = _useState2[1];
|
|
99
|
+
var _useState3 = useState([]),
|
|
100
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
101
|
+
filterValues = _useState4[0],
|
|
102
|
+
setFilterValues = _useState4[1];
|
|
103
|
+
var childrenArray = useMemo(function () {
|
|
104
|
+
return Children.toArray(children).filter(isValidElement);
|
|
105
|
+
}, [children]);
|
|
106
|
+
var childInfo = useMemo(function () {
|
|
107
|
+
return childrenArray.map(function (child, index) {
|
|
108
|
+
return {
|
|
109
|
+
child: child,
|
|
110
|
+
index: index,
|
|
111
|
+
isCollapsible: isCollapsibleCheck(child),
|
|
112
|
+
isAlwaysCollapse: isAlwaysCollapseCheck(child)
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
}, [childrenArray]);
|
|
116
|
+
var collapsibleItems = useMemo(function () {
|
|
117
|
+
return childInfo.filter(function (item) {
|
|
118
|
+
return item.isCollapsible;
|
|
119
|
+
});
|
|
120
|
+
}, [childInfo]);
|
|
121
|
+
var alwaysCollapseItems = useMemo(function () {
|
|
122
|
+
return collapsibleItems.filter(function (item) {
|
|
123
|
+
return item.isAlwaysCollapse;
|
|
124
|
+
});
|
|
125
|
+
}, [collapsibleItems]);
|
|
126
|
+
var normalCollapsibleItems = useMemo(function () {
|
|
127
|
+
return collapsibleItems.filter(function (item) {
|
|
128
|
+
return !item.isAlwaysCollapse;
|
|
129
|
+
});
|
|
130
|
+
}, [collapsibleItems]);
|
|
131
|
+
|
|
132
|
+
// 当 children 结构变化(增删/重排)时才重置为测量模式
|
|
133
|
+
// 不能用 childrenArray 引用比较,因为 JSX 每次渲染都产生新引用
|
|
134
|
+
var childrenStructureKey = childrenArray.map(function (c) {
|
|
135
|
+
var _c$key;
|
|
136
|
+
return (_c$key = c.key) !== null && _c$key !== void 0 ? _c$key : c.type;
|
|
137
|
+
}).join(',');
|
|
138
|
+
var _useState5 = useState(childrenStructureKey),
|
|
139
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
140
|
+
prevStructureKey = _useState6[0],
|
|
141
|
+
setPrevStructureKey = _useState6[1];
|
|
142
|
+
if (childrenStructureKey !== prevStructureKey) {
|
|
143
|
+
setPrevStructureKey(childrenStructureKey);
|
|
144
|
+
setVisibleCount(null);
|
|
145
|
+
}
|
|
146
|
+
var isMeasuring = visibleCount === null;
|
|
147
|
+
|
|
148
|
+
// 纯计算函数:根据容器宽度计算可显示的可折叠项数量
|
|
149
|
+
var calculateVisibleCount = useCallback(function (containerWidth) {
|
|
150
|
+
var _moreButtonMeasureRef;
|
|
151
|
+
if (normalCollapsibleItems.length === 0) return 0;
|
|
152
|
+
var widths = cachedWidths.current;
|
|
153
|
+
if (widths.length === 0) return normalCollapsibleItems.length;
|
|
154
|
+
var uncollapsibleTotalWidth = 0;
|
|
155
|
+
var uncollapsibleCount = 0;
|
|
156
|
+
childInfo.forEach(function (info) {
|
|
157
|
+
if (!info.isCollapsible) {
|
|
158
|
+
uncollapsibleTotalWidth += widths[info.index] || 0;
|
|
159
|
+
uncollapsibleCount++;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
var moreWidth = ((_moreButtonMeasureRef = moreButtonMeasureRef.current) === null || _moreButtonMeasureRef === void 0 ? void 0 : _moreButtonMeasureRef.offsetWidth) || 0;
|
|
163
|
+
var hasAlwaysCollapse = alwaysCollapseItems.length > 0;
|
|
164
|
+
var visibleWidth = 0;
|
|
165
|
+
var count = 0;
|
|
166
|
+
for (var i = 0; i < normalCollapsibleItems.length; i++) {
|
|
167
|
+
var itemWidth = widths[normalCollapsibleItems[i].index] || 0;
|
|
168
|
+
var newWidth = visibleWidth + itemWidth;
|
|
169
|
+
var remaining = normalCollapsibleItems.length - i - 1;
|
|
170
|
+
var needMore = remaining > 0 || hasAlwaysCollapse;
|
|
171
|
+
var totalItems = uncollapsibleCount + count + 1 + (needMore ? 1 : 0);
|
|
172
|
+
var totalGaps = totalItems > 1 ? (totalItems - 1) * gap : 0;
|
|
173
|
+
var totalWidth = uncollapsibleTotalWidth + newWidth + (needMore ? moreWidth : 0) + totalGaps;
|
|
174
|
+
if (totalWidth <= containerWidth) {
|
|
175
|
+
visibleWidth = newWidth;
|
|
176
|
+
count++;
|
|
177
|
+
} else {
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return count;
|
|
182
|
+
}, [childInfo, normalCollapsibleItems, alwaysCollapseItems, gap]);
|
|
183
|
+
|
|
184
|
+
// 使用 ref 保存最新的计算函数,避免 ResizeObserver 等 effect 频繁重建
|
|
185
|
+
var calculateRef = useRef(calculateVisibleCount);
|
|
186
|
+
calculateRef.current = calculateVisibleCount;
|
|
187
|
+
|
|
188
|
+
// Effect 1: 测量模式下,读取所有子元素宽度并计算 visibleCount
|
|
189
|
+
useLayoutEffect(function () {
|
|
190
|
+
if (!containerRef.current || !isMeasuring) return;
|
|
191
|
+
var items = containerRef.current.querySelectorAll('[data-filter-item]');
|
|
192
|
+
var newWidths = [];
|
|
193
|
+
items.forEach(function (el) {
|
|
194
|
+
var idx = Number(el.dataset.filterItem);
|
|
195
|
+
if (!isNaN(idx)) {
|
|
196
|
+
newWidths[idx] = el.offsetWidth;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
cachedWidths.current = newWidths;
|
|
200
|
+
var count = calculateRef.current(containerRef.current.offsetWidth);
|
|
201
|
+
setVisibleCount(count);
|
|
202
|
+
}, [isMeasuring]);
|
|
203
|
+
|
|
204
|
+
// Effect 2: 监听容器大小变化,用缓存宽度重新计算(不需要重新测量)
|
|
205
|
+
useEffect(function () {
|
|
206
|
+
if (!containerRef.current) return;
|
|
207
|
+
var el = containerRef.current;
|
|
208
|
+
var ro = new ResizeObserver(function () {
|
|
209
|
+
if (cachedWidths.current.length === 0) return;
|
|
210
|
+
var count = calculateRef.current(el.offsetWidth);
|
|
211
|
+
setVisibleCount(function (prev) {
|
|
212
|
+
return prev === count ? prev : count;
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
ro.observe(el);
|
|
216
|
+
return function () {
|
|
217
|
+
return ro.disconnect();
|
|
218
|
+
};
|
|
219
|
+
}, []);
|
|
220
|
+
|
|
221
|
+
// Effect 3: filterValues 变化时,more 按钮 badge 可能变化,需要重新计算
|
|
222
|
+
useEffect(function () {
|
|
223
|
+
if (!containerRef.current || cachedWidths.current.length === 0) return;
|
|
224
|
+
var count = calculateRef.current(containerRef.current.offsetWidth);
|
|
225
|
+
setVisibleCount(function (prev) {
|
|
226
|
+
return prev === count ? prev : count;
|
|
227
|
+
});
|
|
228
|
+
}, [filterValues]);
|
|
229
|
+
|
|
230
|
+
// Effect 4: 监听子元素的宽度变化(如筛选值变化导致按钮变宽),
|
|
231
|
+
// 更新缓存宽度并重新计算可见数量。
|
|
232
|
+
// 依赖 visibleCount 以便在显隐切换后重新查询 DOM 元素。
|
|
233
|
+
useEffect(function () {
|
|
234
|
+
if (!containerRef.current || isMeasuring) return;
|
|
235
|
+
var el = containerRef.current;
|
|
236
|
+
var items = el.querySelectorAll('[data-filter-item]');
|
|
237
|
+
if (items.length === 0) return;
|
|
238
|
+
var ro = new ResizeObserver(function () {
|
|
239
|
+
var widthChanged = false;
|
|
240
|
+
items.forEach(function (item) {
|
|
241
|
+
var idx = Number(item.dataset.filterItem);
|
|
242
|
+
if (isNaN(idx)) return;
|
|
243
|
+
var w = item.offsetWidth;
|
|
244
|
+
if (w > 0 && Math.abs(w - (cachedWidths.current[idx] || 0)) > 1) {
|
|
245
|
+
cachedWidths.current[idx] = w;
|
|
246
|
+
widthChanged = true;
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
if (widthChanged) {
|
|
250
|
+
var count = calculateRef.current(el.offsetWidth);
|
|
251
|
+
setVisibleCount(function (prev) {
|
|
252
|
+
return prev === count ? prev : count;
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
items.forEach(function (item) {
|
|
257
|
+
return ro.observe(item);
|
|
258
|
+
});
|
|
259
|
+
return function () {
|
|
260
|
+
return ro.disconnect();
|
|
261
|
+
};
|
|
262
|
+
}, [isMeasuring, visibleCount]);
|
|
263
|
+
|
|
264
|
+
// --- 派生状态 ---
|
|
265
|
+
var visibleIndexSet = useMemo(function () {
|
|
266
|
+
if (visibleCount === null) return null;
|
|
267
|
+
return new Set(normalCollapsibleItems.slice(0, visibleCount).map(function (item) {
|
|
268
|
+
return item.index;
|
|
269
|
+
}));
|
|
270
|
+
}, [visibleCount, normalCollapsibleItems]);
|
|
271
|
+
var hiddenCollapsibleItems = useMemo(function () {
|
|
272
|
+
if (!visibleIndexSet) return [];
|
|
273
|
+
return normalCollapsibleItems.filter(function (item) {
|
|
274
|
+
return !visibleIndexSet.has(item.index);
|
|
275
|
+
});
|
|
276
|
+
}, [visibleIndexSet, normalCollapsibleItems]);
|
|
277
|
+
var allHiddenItems = useMemo(function () {
|
|
278
|
+
return [].concat(_toConsumableArray(alwaysCollapseItems), _toConsumableArray(hiddenCollapsibleItems));
|
|
279
|
+
}, [alwaysCollapseItems, hiddenCollapsibleItems]);
|
|
280
|
+
|
|
281
|
+
// --- 值管理 ---
|
|
282
|
+
var updateFilterValue = useCallback(function (id, _filterLabel, value, options, componentName) {
|
|
283
|
+
setFilterValues(function (prev) {
|
|
284
|
+
var isEmpty = value === undefined || value === null || value === '' || componentName === 'switch' && value === false || Array.isArray(value) && value.length === 0;
|
|
285
|
+
if (isEmpty) {
|
|
286
|
+
var filtered = prev.filter(function (item) {
|
|
287
|
+
return item.id !== id;
|
|
288
|
+
});
|
|
289
|
+
return filtered.length === prev.length ? prev : filtered;
|
|
290
|
+
}
|
|
291
|
+
var existingIndex = prev.findIndex(function (item) {
|
|
292
|
+
return item.id === id;
|
|
293
|
+
});
|
|
294
|
+
if (existingIndex >= 0) {
|
|
295
|
+
var existing = prev[existingIndex];
|
|
296
|
+
var optionsEqual = existing.options === options || existing.options === undefined && options === undefined || existing.options !== undefined && options !== undefined && JSON.stringify(existing.options) === JSON.stringify(options);
|
|
297
|
+
if (existing.value === value && optionsEqual && existing.componentName === componentName && existing.label === _filterLabel) {
|
|
298
|
+
return prev;
|
|
299
|
+
}
|
|
300
|
+
var newValues = _toConsumableArray(prev);
|
|
301
|
+
newValues[existingIndex] = {
|
|
302
|
+
id: id,
|
|
303
|
+
label: _filterLabel,
|
|
304
|
+
value: value,
|
|
305
|
+
options: options,
|
|
306
|
+
componentName: componentName
|
|
307
|
+
};
|
|
308
|
+
return newValues;
|
|
309
|
+
}
|
|
310
|
+
return [].concat(_toConsumableArray(prev), [{
|
|
311
|
+
id: id,
|
|
312
|
+
label: _filterLabel,
|
|
313
|
+
value: value,
|
|
314
|
+
options: options,
|
|
315
|
+
componentName: componentName
|
|
316
|
+
}]);
|
|
317
|
+
});
|
|
318
|
+
}, []);
|
|
319
|
+
var handleClearAll = function handleClearAll() {
|
|
320
|
+
allHiddenItems.forEach(function (item) {
|
|
321
|
+
if ( /*#__PURE__*/isValidElement(item.child)) {
|
|
322
|
+
var childProps = item.child.props;
|
|
323
|
+
if (childProps.children && /*#__PURE__*/isValidElement(childProps.children)) {
|
|
324
|
+
var _innerChildProps$onCh;
|
|
325
|
+
var innerChildProps = childProps.children.props;
|
|
326
|
+
(_innerChildProps$onCh = innerChildProps.onChange) === null || _innerChildProps$onCh === void 0 || _innerChildProps$onCh.call(innerChildProps, undefined);
|
|
327
|
+
} else {
|
|
328
|
+
var _childProps$onChange;
|
|
329
|
+
(_childProps$onChange = childProps.onChange) === null || _childProps$onChange === void 0 || _childProps$onChange.call(childProps, undefined);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
setFilterValues([]);
|
|
334
|
+
onClearAll === null || onClearAll === void 0 || onClearAll();
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
// --- 渲染 FilterWrap(收起的筛选项) ---
|
|
338
|
+
var renderHiddenChildren = function renderHiddenChildren() {
|
|
339
|
+
if (allHiddenItems.length === 0) return null;
|
|
340
|
+
return /*#__PURE__*/_jsx(FilterProvider, {
|
|
341
|
+
isCollapsed: true,
|
|
342
|
+
filterValues: filterValues,
|
|
343
|
+
updateFilterValue: updateFilterValue,
|
|
344
|
+
children: /*#__PURE__*/_jsx(FilterWrap, {
|
|
345
|
+
collapsed: true,
|
|
346
|
+
filterButtonRef: filterButtonRef,
|
|
347
|
+
icon: icon,
|
|
348
|
+
label: filterLabel,
|
|
349
|
+
extra: extra,
|
|
350
|
+
onClearAll: handleClearAll,
|
|
351
|
+
showCount: showCount,
|
|
352
|
+
footer: showActions && /*#__PURE__*/_jsxs(Flex, {
|
|
353
|
+
justify: "space-between",
|
|
354
|
+
children: [onApply && /*#__PURE__*/_jsx(Button, {
|
|
355
|
+
type: "primary",
|
|
356
|
+
size: "small",
|
|
357
|
+
onClick: function onClick() {
|
|
358
|
+
var _filterButtonRef$curr;
|
|
359
|
+
onApply === null || onApply === void 0 || onApply();
|
|
360
|
+
(_filterButtonRef$curr = filterButtonRef.current) === null || _filterButtonRef$curr === void 0 || _filterButtonRef$curr.closePopover();
|
|
361
|
+
},
|
|
362
|
+
children: filterLocale === null || filterLocale === void 0 ? void 0 : filterLocale.apply
|
|
363
|
+
}), onClearAll && /*#__PURE__*/_jsx(Button, {
|
|
364
|
+
type: "link",
|
|
365
|
+
size: "small",
|
|
366
|
+
onClick: handleClearAll,
|
|
367
|
+
children: filterLocale === null || filterLocale === void 0 ? void 0 : filterLocale.clearAll
|
|
368
|
+
})]
|
|
369
|
+
}),
|
|
370
|
+
children: allHiddenItems.map(function (item, index) {
|
|
371
|
+
if ( /*#__PURE__*/isValidElement(item.child)) {
|
|
372
|
+
var stableKey = item.child.key || "responsive-filter-child-".concat(index);
|
|
373
|
+
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
374
|
+
children: item.child
|
|
375
|
+
}, stableKey);
|
|
376
|
+
}
|
|
377
|
+
return item.child;
|
|
378
|
+
})
|
|
379
|
+
})
|
|
380
|
+
});
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
// --- 渲染子元素 ---
|
|
384
|
+
// 所有子元素始终保持在 Flex 中的稳定位置(FilterProvider + div 包裹 + 稳定 key),
|
|
385
|
+
// 通过 CSS display 控制显隐,避免在可见/折叠间切换时卸载重挂载导致表单值丢失。
|
|
386
|
+
// FilterProvider 使隐藏的原始组件能直接感知 isCollapsed 并上报值,无需依赖 Popover 中的克隆。
|
|
387
|
+
var renderChildren = function renderChildren() {
|
|
388
|
+
var elements = [];
|
|
389
|
+
var filterWrapInserted = false;
|
|
390
|
+
var collapsibleIdx = 0;
|
|
391
|
+
childrenArray.forEach(function (child, index) {
|
|
392
|
+
var info = childInfo[index];
|
|
393
|
+
var stableKey = child.key || "filter-item-".concat(index);
|
|
394
|
+
var display;
|
|
395
|
+
var isHidden = false;
|
|
396
|
+
if (isMeasuring) {
|
|
397
|
+
display = 'inline-flex';
|
|
398
|
+
} else if (!info.isCollapsible) {
|
|
399
|
+
display = undefined;
|
|
400
|
+
} else if (info.isAlwaysCollapse) {
|
|
401
|
+
display = 'none';
|
|
402
|
+
isHidden = true;
|
|
403
|
+
} else {
|
|
404
|
+
var isVisible = collapsibleIdx < visibleCount;
|
|
405
|
+
display = isVisible ? undefined : 'none';
|
|
406
|
+
isHidden = !isVisible;
|
|
407
|
+
collapsibleIdx++;
|
|
408
|
+
}
|
|
409
|
+
elements.push( /*#__PURE__*/_jsx(FilterProvider, {
|
|
410
|
+
isCollapsed: !isMeasuring && isHidden,
|
|
411
|
+
filterValues: filterValues,
|
|
412
|
+
updateFilterValue: updateFilterValue,
|
|
413
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
414
|
+
"data-filter-item": index,
|
|
415
|
+
style: {
|
|
416
|
+
display: display,
|
|
417
|
+
flexShrink: 0
|
|
418
|
+
},
|
|
419
|
+
children: child
|
|
420
|
+
})
|
|
421
|
+
}, stableKey));
|
|
422
|
+
if (!isMeasuring && isHidden && !filterWrapInserted && allHiddenItems.length > 0) {
|
|
423
|
+
filterWrapInserted = true;
|
|
424
|
+
elements.push( /*#__PURE__*/_jsx(React.Fragment, {
|
|
425
|
+
children: renderHiddenChildren()
|
|
426
|
+
}, "filter-wrap"));
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
if (!isMeasuring && !filterWrapInserted && allHiddenItems.length > 0) {
|
|
430
|
+
elements.push( /*#__PURE__*/_jsx(React.Fragment, {
|
|
431
|
+
children: renderHiddenChildren()
|
|
432
|
+
}, "filter-wrap"));
|
|
433
|
+
}
|
|
434
|
+
return elements;
|
|
435
|
+
};
|
|
436
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
437
|
+
ref: containerRef,
|
|
438
|
+
className: "responsive-filter-group",
|
|
439
|
+
style: _objectSpread({
|
|
440
|
+
flex: '1 1 auto',
|
|
441
|
+
minWidth: 0,
|
|
442
|
+
position: 'relative',
|
|
443
|
+
overflow: 'hidden',
|
|
444
|
+
visibility: isMeasuring ? 'hidden' : undefined
|
|
445
|
+
}, style),
|
|
446
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
447
|
+
ref: moreButtonMeasureRef,
|
|
448
|
+
style: {
|
|
449
|
+
position: 'absolute',
|
|
450
|
+
visibility: 'hidden',
|
|
451
|
+
pointerEvents: 'none',
|
|
452
|
+
top: -9999,
|
|
453
|
+
left: -9999,
|
|
454
|
+
display: 'inline-flex'
|
|
455
|
+
},
|
|
456
|
+
children: /*#__PURE__*/_jsx(FilterProvider, {
|
|
457
|
+
isCollapsed: true,
|
|
458
|
+
filterValues: filterValues,
|
|
459
|
+
updateFilterValue: updateFilterValue,
|
|
460
|
+
children: /*#__PURE__*/_jsx(FilterWrap, {
|
|
461
|
+
collapsed: true,
|
|
462
|
+
icon: icon,
|
|
463
|
+
label: filterLabel,
|
|
464
|
+
showCount: showCount,
|
|
465
|
+
onClearAll: handleClearAll,
|
|
466
|
+
children: /*#__PURE__*/_jsx("div", {})
|
|
467
|
+
})
|
|
468
|
+
})
|
|
469
|
+
}), /*#__PURE__*/_jsx(Flex, {
|
|
470
|
+
gap: gap,
|
|
471
|
+
align: "center",
|
|
472
|
+
wrap: "nowrap",
|
|
473
|
+
children: renderChildren()
|
|
474
|
+
})]
|
|
475
|
+
});
|
|
476
|
+
};
|
|
477
|
+
export default ResponsiveFilterGroup;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface TagItem {
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export interface WrappedTagsDisplayProps {
|
|
8
|
+
/** 选中的标签列表 */
|
|
9
|
+
tags: TagItem[];
|
|
10
|
+
/** 最多显示的标签数量,默认为 2 */
|
|
11
|
+
maxVisibleTags?: number;
|
|
12
|
+
/** 移除标签的回调 */
|
|
13
|
+
onRemove?: (value: string) => void;
|
|
14
|
+
/** 标签的最大宽度,默认为 80 */
|
|
15
|
+
tagMaxWidth?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Wrapped 模式下的 Tag 展示组件
|
|
19
|
+
* 用于 FilterCheckbox、FilterCascader 等多选组件在 wrapped 模式下展示选中值
|
|
20
|
+
*/
|
|
21
|
+
declare const WrappedTagsDisplay: React.FC<WrappedTagsDisplayProps>;
|
|
22
|
+
export default WrappedTagsDisplay;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import { Flex } from 'antd';
|
|
4
|
+
import Tag from "../../tag";
|
|
5
|
+
import Tooltip from "../../tooltip";
|
|
6
|
+
import theme from "../../theme";
|
|
7
|
+
import ConfigProvider from "../../config-provider";
|
|
8
|
+
import enUS from "../../locale/en-US";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
/**
|
|
12
|
+
* Wrapped 模式下的 Tag 展示组件
|
|
13
|
+
* 用于 FilterCheckbox、FilterCascader 等多选组件在 wrapped 模式下展示选中值
|
|
14
|
+
*/
|
|
15
|
+
var WrappedTagsDisplay = function WrappedTagsDisplay(_ref) {
|
|
16
|
+
var tags = _ref.tags,
|
|
17
|
+
_ref$maxVisibleTags = _ref.maxVisibleTags,
|
|
18
|
+
maxVisibleTags = _ref$maxVisibleTags === void 0 ? 2 : _ref$maxVisibleTags,
|
|
19
|
+
onRemove = _ref.onRemove,
|
|
20
|
+
_ref$tagMaxWidth = _ref.tagMaxWidth,
|
|
21
|
+
tagMaxWidth = _ref$tagMaxWidth === void 0 ? 80 : _ref$tagMaxWidth;
|
|
22
|
+
var _theme$useToken = theme.useToken(),
|
|
23
|
+
token = _theme$useToken.token;
|
|
24
|
+
var _useContext = useContext(ConfigProvider.ConfigContext),
|
|
25
|
+
contextLocale = _useContext.locale;
|
|
26
|
+
var filterLocale = (contextLocale === null || contextLocale === void 0 ? void 0 : contextLocale.Filter) || enUS.Filter;
|
|
27
|
+
var hasValue = tags.length > 0;
|
|
28
|
+
var visibleTags = tags.slice(0, maxVisibleTags);
|
|
29
|
+
var hiddenTags = tags.slice(maxVisibleTags);
|
|
30
|
+
var hiddenCount = hiddenTags.length;
|
|
31
|
+
if (!hasValue) {
|
|
32
|
+
return /*#__PURE__*/_jsx("span", {
|
|
33
|
+
style: {
|
|
34
|
+
color: token.colorTextPlaceholder
|
|
35
|
+
},
|
|
36
|
+
children: filterLocale === null || filterLocale === void 0 ? void 0 : filterLocale.pleaseSelect
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return /*#__PURE__*/_jsxs(Flex, {
|
|
40
|
+
align: "center",
|
|
41
|
+
style: {
|
|
42
|
+
overflow: 'hidden',
|
|
43
|
+
flex: 1
|
|
44
|
+
},
|
|
45
|
+
children: [visibleTags.map(function (item) {
|
|
46
|
+
return /*#__PURE__*/_jsx(Tag, {
|
|
47
|
+
closable: !!onRemove,
|
|
48
|
+
onClose: function onClose(e) {
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
e.stopPropagation();
|
|
51
|
+
onRemove === null || onRemove === void 0 || onRemove(item.value);
|
|
52
|
+
},
|
|
53
|
+
style: {
|
|
54
|
+
maxWidth: tagMaxWidth,
|
|
55
|
+
marginRight: 4
|
|
56
|
+
},
|
|
57
|
+
children: item.label
|
|
58
|
+
}, item.value);
|
|
59
|
+
}), hiddenCount > 0 && /*#__PURE__*/_jsx(Tooltip, {
|
|
60
|
+
title: hiddenTags.map(function (item) {
|
|
61
|
+
return /*#__PURE__*/_jsx(Tag, {
|
|
62
|
+
closable: !!onRemove,
|
|
63
|
+
onClose: function onClose(e) {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
e.stopPropagation();
|
|
66
|
+
onRemove === null || onRemove === void 0 || onRemove(item.value);
|
|
67
|
+
},
|
|
68
|
+
children: item.label
|
|
69
|
+
}, item.value);
|
|
70
|
+
}),
|
|
71
|
+
children: /*#__PURE__*/_jsx(Tag, {
|
|
72
|
+
style: {
|
|
73
|
+
margin: 0
|
|
74
|
+
},
|
|
75
|
+
children: ".."
|
|
76
|
+
})
|
|
77
|
+
})]
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
export default WrappedTagsDisplay;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 处理受控/非受控组件状态的通用 Hook
|
|
3
|
+
* @param value 外部传入的受控值
|
|
4
|
+
* @param defaultValue 默认值
|
|
5
|
+
* @param onChange 值变化时的回调
|
|
6
|
+
* @returns [currentValue, setValue, isControlled]
|
|
7
|
+
*/
|
|
8
|
+
export declare function useControlledState<T>(value: T | undefined, defaultValue: T, onChange?: (value: T) => void): [T, (value: T) => void, boolean];
|
|
9
|
+
export default useControlledState;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { useCallback, useState } from 'react';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 处理受控/非受控组件状态的通用 Hook
|
|
11
|
+
* @param value 外部传入的受控值
|
|
12
|
+
* @param defaultValue 默认值
|
|
13
|
+
* @param onChange 值变化时的回调
|
|
14
|
+
* @returns [currentValue, setValue, isControlled]
|
|
15
|
+
*/
|
|
16
|
+
export function useControlledState(value, defaultValue, onChange) {
|
|
17
|
+
var isControlled = value !== undefined;
|
|
18
|
+
var _useState = useState(defaultValue),
|
|
19
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
20
|
+
internalValue = _useState2[0],
|
|
21
|
+
setInternalValue = _useState2[1];
|
|
22
|
+
|
|
23
|
+
// 使用受控值或内部值
|
|
24
|
+
var currentValue = isControlled ? value : internalValue;
|
|
25
|
+
|
|
26
|
+
// 统一的 setValue 方法
|
|
27
|
+
var setValue = useCallback(function (newValue) {
|
|
28
|
+
// 如果是非受控组件,更新内部状态
|
|
29
|
+
if (!isControlled) {
|
|
30
|
+
setInternalValue(newValue);
|
|
31
|
+
}
|
|
32
|
+
// 总是调用 onChange 回调
|
|
33
|
+
onChange === null || onChange === void 0 || onChange(newValue);
|
|
34
|
+
}, [isControlled, onChange]);
|
|
35
|
+
return [currentValue, setValue, isControlled];
|
|
36
|
+
}
|
|
37
|
+
export default useControlledState;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useFilterContext } from "../FilterContext";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 判断 Filter 组件是否处于折叠模式
|
|
5
|
+
* 支持通过 context 或 prop 来判断
|
|
6
|
+
* @param isCollapsedProp 通过 prop 传入的 _isCollapsed 值
|
|
7
|
+
* @returns 是否处于折叠模式
|
|
8
|
+
*/
|
|
9
|
+
export function useFilterCollapsed() {
|
|
10
|
+
var isCollapsedProp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
11
|
+
var _useFilterContext = useFilterContext(),
|
|
12
|
+
isCollapsedFromContext = _useFilterContext.isCollapsed;
|
|
13
|
+
return isCollapsedFromContext || isCollapsedProp;
|
|
14
|
+
}
|
|
15
|
+
export default useFilterCollapsed;
|