tntd 2.7.3 → 2.7.5
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/LICENSE +21 -0
- package/README.md +72 -0
- package/es/actions/index.js +12 -0
- package/es/actions/index.js.map +1 -0
- package/es/actions/index.less +70 -0
- package/es/check-card/group.js +149 -0
- package/es/check-card/group.js.map +1 -0
- package/es/check-card/index.js +120 -0
- package/es/check-card/index.js.map +1 -0
- package/es/check-card/index.less +179 -0
- package/es/color-picker/ColorPicker.js +1 -1
- package/es/color-picker/ColorPicker.js.map +1 -1
- package/es/color-picker/index.less +1 -1
- package/es/ellipsis/index.js +13 -3
- package/es/ellipsis/index.js.map +1 -1
- package/es/ellipsis/index.less +2 -2
- package/es/handle/handle.js +102 -0
- package/es/handle/handle.js.map +1 -0
- package/es/handle/index.js +20 -9
- package/es/handle/index.js.map +1 -1
- package/es/handle/index.less +1 -1
- package/es/index.js +7 -0
- package/es/index.js.map +1 -1
- package/es/index.less +5 -0
- package/es/locale/en_US.js +3 -1
- package/es/locale/en_US.js.map +1 -1
- package/es/locale/zh_CN.js +3 -1
- package/es/locale/zh_CN.js.map +1 -1
- package/es/mention/index.js +4 -0
- package/es/mention/index.js.map +1 -0
- package/es/page/Box.js +1 -1
- package/es/page/Box.js.map +1 -1
- package/es/page/index.js +1 -1
- package/es/page/index.js.map +1 -1
- package/es/page/index.less +5 -5
- package/es/prev-locale.js +1 -1
- package/es/prev-locale.js.map +1 -1
- package/es/query-form/Field/SelectInput.js +2 -2
- package/es/query-form/Field/SelectInput.js.map +1 -1
- package/es/query-form/Field/index.js +2 -1
- package/es/query-form/Field/index.js.map +1 -1
- package/es/query-list-scene/QueryForm.js +2 -2
- package/es/query-list-scene/QueryForm.js.map +1 -1
- package/es/segmented/index.js +50 -0
- package/es/segmented/index.js.map +1 -0
- package/es/segmented/index.less +138 -0
- package/es/table/constants.js +53 -0
- package/es/table/constants.js.map +1 -1
- package/es/table/context.js.map +1 -1
- package/es/table/hooks/use-column-setting.js.map +1 -1
- package/es/table/table.js +119 -6
- package/es/table/table.js.map +1 -1
- package/es/table/table.less +3 -1
- package/es/table/total-shower.js +6 -0
- package/es/table/total-shower.js.map +1 -0
- package/es/title/index.js +5 -5
- package/es/title/index.js.map +1 -1
- package/es/title/index.less +10 -10
- package/es/tntd-form/Form.js +1 -1
- package/es/tntd-form/Form.js.map +1 -1
- package/es/tntd-form/TntdForm/components/Item.js +42 -30
- package/es/tntd-form/TntdForm/components/ItemComp.js +167 -158
- package/es/tntd-form/TntdForm/components/List.js +89 -78
- package/es/tntd-form/TntdForm/index.js +38 -33
- package/es/tntd-form/TntdForm/interface.js +1 -2
- package/es/tntd-form/TntdForm/store.js +1 -2
- package/es/tntd-form/TntdForm/utils.js +158 -168
- package/es/tntd-modal/index.js +54 -21
- package/es/tntd-modal/index.js.map +1 -1
- package/es/tntd-modal/index.less +83 -63
- package/es/utils/index.js +1 -0
- package/es/utils/index.js.map +1 -1
- package/es/utils/simple-template.js +11 -0
- package/es/utils/simple-template.js.map +1 -0
- package/es/water-mark/index.js +99 -0
- package/es/water-mark/index.js.map +1 -0
- package/lib/actions/index.d.ts +15 -0
- package/lib/actions/index.d.ts.map +1 -0
- package/lib/actions/index.js +17 -0
- package/lib/actions/index.js.map +1 -0
- package/lib/actions/index.less +70 -0
- package/lib/check-card/group.d.ts +130 -0
- package/lib/check-card/group.d.ts.map +1 -0
- package/lib/check-card/group.js +179 -0
- package/lib/check-card/group.js.map +1 -0
- package/lib/check-card/index.d.ts +136 -0
- package/lib/check-card/index.d.ts.map +1 -0
- package/lib/check-card/index.js +148 -0
- package/lib/check-card/index.js.map +1 -0
- package/lib/check-card/index.less +179 -0
- package/lib/color-picker/ColorPicker.js +1 -1
- package/lib/color-picker/ColorPicker.js.map +1 -1
- package/lib/color-picker/index.less +1 -1
- package/lib/ellipsis/index.d.ts.map +1 -1
- package/lib/ellipsis/index.js +13 -3
- package/lib/ellipsis/index.js.map +1 -1
- package/lib/ellipsis/index.less +2 -2
- package/lib/handle/handle.d.ts +3 -0
- package/lib/handle/handle.d.ts.map +1 -0
- package/lib/handle/handle.js +130 -0
- package/lib/handle/handle.js.map +1 -0
- package/lib/handle/index.d.ts.map +1 -1
- package/lib/handle/index.js +20 -9
- package/lib/handle/index.js.map +1 -1
- package/lib/handle/index.less +1 -1
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +11 -1
- package/lib/index.js.map +1 -1
- package/lib/index.less +5 -0
- package/lib/locale/default.d.ts +1 -0
- package/lib/locale/default.d.ts.map +1 -1
- package/lib/locale/en_US.d.ts +1 -0
- package/lib/locale/en_US.d.ts.map +1 -1
- package/lib/locale/en_US.js +3 -1
- package/lib/locale/en_US.js.map +1 -1
- package/lib/locale/zh_CN.d.ts +1 -0
- package/lib/locale/zh_CN.d.ts.map +1 -1
- package/lib/locale/zh_CN.js +3 -1
- package/lib/locale/zh_CN.js.map +1 -1
- package/lib/mention/index.js +25 -0
- package/lib/page/Box.js +1 -1
- package/lib/page/Box.js.map +1 -1
- package/lib/page/index.js +1 -1
- package/lib/page/index.js.map +1 -1
- package/lib/page/index.less +5 -5
- package/lib/prev-locale.js +1 -1
- package/lib/prev-locale.js.map +1 -1
- package/lib/query-form/Field/SelectInput.d.ts.map +1 -1
- package/lib/query-form/Field/SelectInput.js +2 -2
- package/lib/query-form/Field/SelectInput.js.map +1 -1
- package/lib/query-form/Field/index.d.ts.map +1 -1
- package/lib/query-form/Field/index.js +2 -1
- package/lib/query-form/Field/index.js.map +1 -1
- package/lib/query-list-scene/QueryForm.d.ts +1 -1
- package/lib/query-list-scene/QueryForm.d.ts.map +1 -1
- package/lib/query-list-scene/QueryForm.js +2 -2
- package/lib/query-list-scene/QueryForm.js.map +1 -1
- package/lib/segmented/index.d.ts +23 -0
- package/lib/segmented/index.d.ts.map +1 -0
- package/lib/segmented/index.js +78 -0
- package/lib/segmented/index.js.map +1 -0
- package/lib/segmented/index.less +138 -0
- package/lib/table/constants.d.ts +2 -0
- package/lib/table/constants.d.ts.map +1 -1
- package/lib/table/constants.js +54 -1
- package/lib/table/constants.js.map +1 -1
- package/lib/table/context.d.ts +1 -0
- package/lib/table/context.d.ts.map +1 -1
- package/lib/table/context.js.map +1 -1
- package/lib/table/hooks/use-column-setting.d.ts +4 -1
- package/lib/table/hooks/use-column-setting.d.ts.map +1 -1
- package/lib/table/hooks/use-column-setting.js.map +1 -1
- package/lib/table/table.d.ts +2 -1
- package/lib/table/table.d.ts.map +1 -1
- package/lib/table/table.js +119 -6
- package/lib/table/table.js.map +1 -1
- package/lib/table/table.less +3 -1
- package/lib/table/total-shower.d.ts +9 -0
- package/lib/table/total-shower.d.ts.map +1 -0
- package/lib/table/total-shower.js +13 -0
- package/lib/table/total-shower.js.map +1 -0
- package/lib/title/index.d.ts +11 -1
- package/lib/title/index.d.ts.map +1 -1
- package/lib/title/index.js +5 -5
- package/lib/title/index.js.map +1 -1
- package/lib/title/index.less +10 -10
- package/lib/tntd-form/Form.js +1 -1
- package/lib/tntd-form/Form.js.map +1 -1
- package/lib/tntd-form/TntdForm/components/Item.js +55 -61
- package/lib/tntd-form/TntdForm/components/ItemComp.js +203 -190
- package/lib/tntd-form/TntdForm/components/List.js +118 -111
- package/lib/tntd-form/TntdForm/index.js +61 -67
- package/lib/tntd-form/TntdForm/interface.js +4 -2
- package/lib/tntd-form/TntdForm/store.js +8 -7
- package/lib/tntd-form/TntdForm/utils.js +182 -184
- package/lib/tntd-modal/index.d.ts +15 -2
- package/lib/tntd-modal/index.d.ts.map +1 -1
- package/lib/tntd-modal/index.js +58 -23
- package/lib/tntd-modal/index.js.map +1 -1
- package/lib/tntd-modal/index.less +83 -63
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +1 -0
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/simple-template.d.ts +9 -0
- package/lib/utils/simple-template.d.ts.map +1 -0
- package/lib/utils/simple-template.js +15 -0
- package/lib/utils/simple-template.js.map +1 -0
- package/lib/water-mark/index.d.ts +49 -0
- package/lib/water-mark/index.d.ts.map +1 -0
- package/lib/water-mark/index.js +129 -0
- package/lib/water-mark/index.js.map +1 -0
- package/package.json +21 -3
- package/es/_util/colors.js +0 -3
- package/es/_util/colors.js.map +0 -1
- package/es/_util/easings.js +0 -9
- package/es/_util/easings.js.map +0 -1
- package/es/_util/getDataOrAriaProps.js +0 -8
- package/es/_util/getDataOrAriaProps.js.map +0 -1
- package/es/_util/getScroll.js +0 -14
- package/es/_util/getScroll.js.map +0 -1
- package/es/_util/interopDefault.js +0 -5
- package/es/_util/interopDefault.js.map +0 -1
- package/es/_util/isNumeric.js +0 -4
- package/es/_util/isNumeric.js.map +0 -1
- package/es/_util/motion.js +0 -22
- package/es/_util/motion.js.map +0 -1
- package/es/_util/openAnimation.js +0 -51
- package/es/_util/openAnimation.js.map +0 -1
- package/es/_util/raf.js +0 -25
- package/es/_util/raf.js.map +0 -1
- package/es/_util/reactNode.js +0 -6
- package/es/_util/reactNode.js.map +0 -1
- package/es/_util/ref.js +0 -15
- package/es/_util/ref.js.map +0 -1
- package/es/_util/responsiveObserve.js +0 -82
- package/es/_util/responsiveObserve.js.map +0 -1
- package/es/_util/scrollTo.js +0 -29
- package/es/_util/scrollTo.js.map +0 -1
- package/es/_util/styleChecker.js +0 -12
- package/es/_util/styleChecker.js.map +0 -1
- package/es/_util/throttleByAnimationFrame.js +0 -40
- package/es/_util/throttleByAnimationFrame.js.map +0 -1
- package/es/_util/transButton.js +0 -103
- package/es/_util/transButton.js.map +0 -1
- package/es/_util/triggerEvent.js +0 -8
- package/es/_util/triggerEvent.js.map +0 -1
- package/es/_util/type.js +0 -3
- package/es/_util/type.js.map +0 -1
- package/es/_util/warning.js +0 -5
- package/es/_util/warning.js.map +0 -1
- package/es/_util/wave.js +0 -228
- package/es/_util/wave.js.map +0 -1
- package/es/config-provider/context.js +0 -41
- package/es/config-provider/context.js.map +0 -1
- package/es/tntd-form/__tests__/demo-extend.test.js +0 -3
- package/es/tntd-form/__tests__/demo-extend.test.js.map +0 -1
- package/es/tntd-form/__tests__/demo.test.js +0 -3
- package/es/tntd-form/__tests__/demo.test.js.map +0 -1
- package/es/tntd-form/__tests__/image.test.js +0 -5
- package/es/tntd-form/__tests__/image.test.js.map +0 -1
- package/es/tntd-form/__tests__/index.test.js +0 -957
- package/es/tntd-form/__tests__/index.test.js.map +0 -1
- package/es/tntd-form/__tests__/list-noStyle.test.js +0 -41
- package/es/tntd-form/__tests__/list-noStyle.test.js.map +0 -1
- package/es/tntd-form/__tests__/list.test.js +0 -164
- package/es/tntd-form/__tests__/list.test.js.map +0 -1
- package/es/tntd-form/__tests__/ref.test.js +0 -45
- package/es/tntd-form/__tests__/ref.test.js.map +0 -1
- package/es/tntd-form/__tests__/type.test.js +0 -74
- package/es/tntd-form/__tests__/type.test.js.map +0 -1
- package/lib/_util/colors.d.ts +0 -3
- package/lib/_util/colors.d.ts.map +0 -1
- package/lib/_util/colors.js +0 -7
- package/lib/_util/colors.js.map +0 -1
- package/lib/_util/easings.d.ts +0 -2
- package/lib/_util/easings.d.ts.map +0 -1
- package/lib/_util/easings.js +0 -14
- package/lib/_util/easings.js.map +0 -1
- package/lib/_util/getDataOrAriaProps.d.ts +0 -2
- package/lib/_util/getDataOrAriaProps.d.ts.map +0 -1
- package/lib/_util/getDataOrAriaProps.js +0 -13
- package/lib/_util/getDataOrAriaProps.js.map +0 -1
- package/lib/_util/getScroll.d.ts +0 -2
- package/lib/_util/getScroll.d.ts.map +0 -1
- package/lib/_util/getScroll.js +0 -18
- package/lib/_util/getScroll.js.map +0 -1
- package/lib/_util/interopDefault.d.ts +0 -2
- package/lib/_util/interopDefault.d.ts.map +0 -1
- package/lib/_util/interopDefault.js +0 -9
- package/lib/_util/interopDefault.js.map +0 -1
- package/lib/_util/isNumeric.d.ts +0 -3
- package/lib/_util/isNumeric.d.ts.map +0 -1
- package/lib/_util/isNumeric.js +0 -7
- package/lib/_util/isNumeric.js.map +0 -1
- package/lib/_util/motion.d.ts +0 -24
- package/lib/_util/motion.d.ts.map +0 -1
- package/lib/_util/motion.js +0 -17
- package/lib/_util/motion.js.map +0 -1
- package/lib/_util/openAnimation.d.ts +0 -7
- package/lib/_util/openAnimation.d.ts.map +0 -1
- package/lib/_util/openAnimation.js +0 -58
- package/lib/_util/openAnimation.js.map +0 -1
- package/lib/_util/raf.d.ts +0 -10
- package/lib/_util/raf.d.ts.map +0 -1
- package/lib/_util/raf.js +0 -34
- package/lib/_util/raf.js.map +0 -1
- package/lib/_util/reactNode.d.ts +0 -3
- package/lib/_util/reactNode.d.ts.map +0 -1
- package/lib/_util/reactNode.js +0 -31
- package/lib/_util/reactNode.js.map +0 -1
- package/lib/_util/ref.d.ts +0 -4
- package/lib/_util/ref.d.ts.map +0 -1
- package/lib/_util/ref.js +0 -22
- package/lib/_util/ref.js.map +0 -1
- package/lib/_util/responsiveObserve.d.ts +0 -14
- package/lib/_util/responsiveObserve.d.ts.map +0 -1
- package/lib/_util/responsiveObserve.js +0 -83
- package/lib/_util/responsiveObserve.js.map +0 -1
- package/lib/_util/scrollTo.d.ts +0 -11
- package/lib/_util/scrollTo.d.ts.map +0 -1
- package/lib/_util/scrollTo.js +0 -34
- package/lib/_util/scrollTo.js.map +0 -1
- package/lib/_util/styleChecker.d.ts +0 -4
- package/lib/_util/styleChecker.d.ts.map +0 -1
- package/lib/_util/styleChecker.js +0 -14
- package/lib/_util/styleChecker.js.map +0 -1
- package/lib/_util/throttleByAnimationFrame.d.ts +0 -6
- package/lib/_util/throttleByAnimationFrame.d.ts.map +0 -1
- package/lib/_util/throttleByAnimationFrame.js +0 -49
- package/lib/_util/throttleByAnimationFrame.js.map +0 -1
- package/lib/_util/transButton.d.ts +0 -21
- package/lib/_util/transButton.d.ts.map +0 -1
- package/lib/_util/transButton.js +0 -112
- package/lib/_util/transButton.js.map +0 -1
- package/lib/_util/triggerEvent.d.ts +0 -2
- package/lib/_util/triggerEvent.d.ts.map +0 -1
- package/lib/_util/triggerEvent.js +0 -12
- package/lib/_util/triggerEvent.js.map +0 -1
- package/lib/_util/type.d.ts +0 -4
- package/lib/_util/type.d.ts.map +0 -1
- package/lib/_util/type.js +0 -9
- package/lib/_util/type.js.map +0 -1
- package/lib/_util/warning.d.ts +0 -5
- package/lib/_util/warning.d.ts.map +0 -1
- package/lib/_util/warning.js +0 -28
- package/lib/_util/warning.js.map +0 -1
- package/lib/_util/wave.d.ts +0 -26
- package/lib/_util/wave.d.ts.map +0 -1
- package/lib/_util/wave.js +0 -249
- package/lib/_util/wave.js.map +0 -1
- package/lib/config-provider/context.d.ts +0 -61
- package/lib/config-provider/context.d.ts.map +0 -1
- package/lib/config-provider/context.js +0 -64
- package/lib/config-provider/context.js.map +0 -1
- package/lib/tntd-form/TntdForm/components/Item.d.ts +0 -5
- package/lib/tntd-form/TntdForm/components/Item.d.ts.map +0 -1
- package/lib/tntd-form/TntdForm/components/Item.js.map +0 -1
- package/lib/tntd-form/TntdForm/components/ItemComp.d.ts +0 -5
- package/lib/tntd-form/TntdForm/components/ItemComp.d.ts.map +0 -1
- package/lib/tntd-form/TntdForm/components/ItemComp.js.map +0 -1
- package/lib/tntd-form/TntdForm/components/List.d.ts +0 -5
- package/lib/tntd-form/TntdForm/components/List.d.ts.map +0 -1
- package/lib/tntd-form/TntdForm/components/List.js.map +0 -1
- package/lib/tntd-form/TntdForm/index.d.ts +0 -10
- package/lib/tntd-form/TntdForm/index.d.ts.map +0 -1
- package/lib/tntd-form/TntdForm/index.js.map +0 -1
- package/lib/tntd-form/TntdForm/interface.d.ts +0 -93
- package/lib/tntd-form/TntdForm/interface.d.ts.map +0 -1
- package/lib/tntd-form/TntdForm/interface.js.map +0 -1
- package/lib/tntd-form/TntdForm/store.d.ts +0 -4
- package/lib/tntd-form/TntdForm/store.d.ts.map +0 -1
- package/lib/tntd-form/TntdForm/store.js.map +0 -1
- package/lib/tntd-form/TntdForm/utils.d.ts +0 -48
- package/lib/tntd-form/TntdForm/utils.d.ts.map +0 -1
- package/lib/tntd-form/TntdForm/utils.js.map +0 -1
- package/lib/tntd-form/__tests__/demo-extend.test.d.ts +0 -2
- package/lib/tntd-form/__tests__/demo-extend.test.d.ts.map +0 -1
- package/lib/tntd-form/__tests__/demo-extend.test.js +0 -5
- package/lib/tntd-form/__tests__/demo-extend.test.js.map +0 -1
- package/lib/tntd-form/__tests__/demo.test.d.ts +0 -2
- package/lib/tntd-form/__tests__/demo.test.d.ts.map +0 -1
- package/lib/tntd-form/__tests__/demo.test.js +0 -8
- package/lib/tntd-form/__tests__/demo.test.js.map +0 -1
- package/lib/tntd-form/__tests__/image.test.d.ts +0 -2
- package/lib/tntd-form/__tests__/image.test.d.ts.map +0 -1
- package/lib/tntd-form/__tests__/image.test.js +0 -7
- package/lib/tntd-form/__tests__/image.test.js.map +0 -1
- package/lib/tntd-form/__tests__/index.test.d.ts +0 -2
- package/lib/tntd-form/__tests__/index.test.d.ts.map +0 -1
- package/lib/tntd-form/__tests__/index.test.js +0 -981
- package/lib/tntd-form/__tests__/index.test.js.map +0 -1
- package/lib/tntd-form/__tests__/list-noStyle.test.d.ts +0 -2
- package/lib/tntd-form/__tests__/list-noStyle.test.d.ts.map +0 -1
- package/lib/tntd-form/__tests__/list-noStyle.test.js +0 -46
- package/lib/tntd-form/__tests__/list-noStyle.test.js.map +0 -1
- package/lib/tntd-form/__tests__/list.test.d.ts +0 -2
- package/lib/tntd-form/__tests__/list.test.d.ts.map +0 -1
- package/lib/tntd-form/__tests__/list.test.js +0 -169
- package/lib/tntd-form/__tests__/list.test.js.map +0 -1
- package/lib/tntd-form/__tests__/ref.test.d.ts +0 -2
- package/lib/tntd-form/__tests__/ref.test.d.ts.map +0 -1
- package/lib/tntd-form/__tests__/ref.test.js +0 -50
- package/lib/tntd-form/__tests__/ref.test.js.map +0 -1
- package/lib/tntd-form/__tests__/type.test.d.ts +0 -2
- package/lib/tntd-form/__tests__/type.test.d.ts.map +0 -1
- package/lib/tntd-form/__tests__/type.test.js +0 -98
- package/lib/tntd-form/__tests__/type.test.js.map +0 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SegmentedLabeledOption as RcSegmentedLabeledOption, SegmentedProps as RCSegmentedProps, SegmentedRawOption } from 'rc-segmented';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import './index.less';
|
|
4
|
+
export declare type SizeType = 'small' | 'middle' | 'large' | undefined;
|
|
5
|
+
export type { SegmentedValue } from 'rc-segmented';
|
|
6
|
+
interface SegmentedLabeledOptionWithoutIcon extends RcSegmentedLabeledOption {
|
|
7
|
+
label: RcSegmentedLabeledOption['label'];
|
|
8
|
+
}
|
|
9
|
+
interface SegmentedLabeledOptionWithIcon extends Omit<RcSegmentedLabeledOption, 'label'> {
|
|
10
|
+
label?: RcSegmentedLabeledOption['label'];
|
|
11
|
+
/** Set icon for Segmented item */
|
|
12
|
+
icon: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare type SegmentedLabeledOption = SegmentedLabeledOptionWithIcon | SegmentedLabeledOptionWithoutIcon;
|
|
15
|
+
export interface SegmentedProps extends Omit<RCSegmentedProps, 'size' | 'options'> {
|
|
16
|
+
rootClassName?: string;
|
|
17
|
+
options: (SegmentedRawOption | SegmentedLabeledOption)[];
|
|
18
|
+
block?: boolean;
|
|
19
|
+
size?: SizeType;
|
|
20
|
+
}
|
|
21
|
+
declare const Segmented: React.ForwardRefExoticComponent<Pick<SegmentedProps, "cite" | "data" | "form" | "label" | "slot" | "span" | "style" | "summary" | "title" | "pattern" | "children" | "key" | "open" | "id" | "name" | "prefixCls" | "disabled" | "className" | "size" | "autoFocus" | "onFocus" | "onBlur" | "value" | "defaultValue" | "placeholder" | "onChange" | "onMouseEnter" | "onMouseLeave" | "options" | "onSelect" | "tabIndex" | "default" | "multiple" | "start" | "block" | "onSubmit" | "acceptCharset" | "action" | "autoComplete" | "encType" | "method" | "noValidate" | "target" | "rel" | "defaultChecked" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "lang" | "nonce" | "spellCheck" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "direction" | "list" | "step" | "height" | "type" | "motionName" | "wrap" | "width" | "htmlFor" | "required" | "max" | "min" | "classID" | "accept" | "alt" | "capture" | "checked" | "crossOrigin" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "maxLength" | "minLength" | "readOnly" | "src" | "content" | "media" | "href" | "cols" | "rows" | "download" | "hrefLang" | "shape" | "as" | "headers" | "allowFullScreen" | "allowTransparency" | "async" | "autoPlay" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "colSpan" | "controls" | "coords" | "dateTime" | "defer" | "frameBorder" | "high" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "mediaGroup" | "muted" | "optimum" | "playsInline" | "poster" | "preload" | "reversed" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "selected" | "sizes" | "srcDoc" | "srcLang" | "srcSet" | "useMap" | "wmode" | "rootClassName"> & React.RefAttributes<HTMLDivElement>>;
|
|
22
|
+
export default Segmented;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/segmented/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,IAAI,wBAAwB,EAClD,cAAc,IAAI,gBAAgB,EAClC,kBAAkB,EACnB,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,cAAc,CAAA;AAErB,oBAAY,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAA;AAG/D,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAElD,UAAU,iCAAkC,SAAQ,wBAAwB;IAC1E,KAAK,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAA;CACzC;AAED,UAAU,8BAA+B,SAAQ,IAAI,CAAC,wBAAwB,EAAE,OAAO,CAAC;IACtF,KAAK,CAAC,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAA;IACzC,kCAAkC;IAClC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;CACtB;AAQD,oBAAY,sBAAsB,GAC9B,8BAA8B,GAC9B,iCAAiC,CAAA;AAErC,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IAChF,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,CAAC,kBAAkB,GAAG,sBAAsB,CAAC,EAAE,CAAA;IACxD,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB;AAED,QAAA,MAAM,SAAS,84LA2Db,CAAA;AAMF,eAAe,SAAS,CAAA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
41
|
+
const rc_segmented_1 = __importDefault(require("rc-segmented"));
|
|
42
|
+
const React = __importStar(require("react"));
|
|
43
|
+
require("./index.less");
|
|
44
|
+
const SizeContext = React.createContext(undefined);
|
|
45
|
+
function isSegmentedLabeledOptionWithIcon(option) {
|
|
46
|
+
return typeof option === 'object' && !!(option === null || option === void 0 ? void 0 : option.icon);
|
|
47
|
+
}
|
|
48
|
+
const Segmented = React.forwardRef((props, ref) => {
|
|
49
|
+
const { prefixCls: customizePrefixCls, className, rootClassName, block, options = [], size: customSize = 'middle', style } = props, restProps = __rest(props, ["prefixCls", "className", "rootClassName", "block", "options", "size", "style"]);
|
|
50
|
+
const prefixCls = 'tntd-segmented';
|
|
51
|
+
// ===================== Size =====================
|
|
52
|
+
const size = React.useContext(SizeContext);
|
|
53
|
+
const mergedSize = customSize || size;
|
|
54
|
+
// syntactic sugar to support `icon` for Segmented Item
|
|
55
|
+
const extendedOptions = React.useMemo(() => options.map((option) => {
|
|
56
|
+
if (isSegmentedLabeledOptionWithIcon(option)) {
|
|
57
|
+
const { icon, label } = option, restOption = __rest(option, ["icon", "label"]);
|
|
58
|
+
return Object.assign(Object.assign({}, restOption), { label: (React.createElement(React.Fragment, null,
|
|
59
|
+
React.createElement("span", { className: `${prefixCls}-item-icon` }, icon),
|
|
60
|
+
label && React.createElement("span", null, label))) });
|
|
61
|
+
}
|
|
62
|
+
return option;
|
|
63
|
+
}), [options, prefixCls]);
|
|
64
|
+
const cls = (0, classnames_1.default)(className, rootClassName, {
|
|
65
|
+
[`${prefixCls}-block`]: block,
|
|
66
|
+
[`${prefixCls}-sm`]: mergedSize === 'small',
|
|
67
|
+
[`${prefixCls}-lg`]: mergedSize === 'large',
|
|
68
|
+
});
|
|
69
|
+
const mergedStyle = Object.assign({}, style);
|
|
70
|
+
return (React.createElement(rc_segmented_1.default, Object.assign({}, restProps, { className: cls, style: mergedStyle, options: extendedOptions,
|
|
71
|
+
// options={options}
|
|
72
|
+
ref: ref, rev: "", prefixCls: prefixCls })));
|
|
73
|
+
});
|
|
74
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
75
|
+
Segmented.displayName = 'Segmented';
|
|
76
|
+
}
|
|
77
|
+
exports.default = Segmented;
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/segmented/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAmC;AAMnC,gEAAsC;AACtC,6CAA8B;AAE9B,wBAAqB;AAGrB,MAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAW,SAAS,CAAC,CAAA;AAc5D,SAAS,gCAAgC,CACvC,MAA+F;IAE/F,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,MAAyC,aAAzC,MAAM,uBAAN,MAAM,CAAqC,IAAI,CAAA,CAAA;AACzF,CAAC;AAaD,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAiC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAChF,MAAM,EACJ,SAAS,EAAE,kBAAkB,EAC7B,SAAS,EACT,aAAa,EACb,KAAK,EACL,OAAO,GAAG,EAAE,EACZ,IAAI,EAAE,UAAU,GAAG,QAAQ,EAC3B,KAAK,KAEH,KAAK,EADJ,SAAS,UACV,KAAK,EATH,gFASL,CAAQ,CAAA;IAET,MAAM,SAAS,GAAG,gBAAgB,CAAA;IAElC,mDAAmD;IACnD,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;IAC1C,MAAM,UAAU,GAAG,UAAU,IAAI,IAAI,CAAA;IAErC,uDAAuD;IACvD,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CACnC,GAAG,EAAE,CACH,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACrB,IAAI,gCAAgC,CAAC,MAAM,CAAC,EAAE;YAC5C,MAAM,EAAE,IAAI,EAAE,KAAK,KAAoB,MAAM,EAArB,UAAU,UAAK,MAAM,EAAvC,iBAA8B,CAAS,CAAA;YAC7C,uCACK,UAAU,KACb,KAAK,EAAE,CACL;oBACE,8BAAM,SAAS,EAAE,GAAG,SAAS,YAAY,IAAG,IAAI,CAAQ;oBACvD,KAAK,IAAI,kCAAO,KAAK,CAAQ,CAC7B,CACJ,IACF;SACF;QACD,OAAO,MAAM,CAAA;IACf,CAAC,CAAC,EACJ,CAAC,OAAO,EAAE,SAAS,CAAC,CACrB,CAAA;IAED,MAAM,GAAG,GAAG,IAAA,oBAAU,EAAC,SAAS,EAAE,aAAa,EAAE;QAC/C,CAAC,GAAG,SAAS,QAAQ,CAAC,EAAE,KAAK;QAC7B,CAAC,GAAG,SAAS,KAAK,CAAC,EAAE,UAAU,KAAK,OAAO;QAC3C,CAAC,GAAG,SAAS,KAAK,CAAC,EAAE,UAAU,KAAK,OAAO;KAC5C,CAAC,CAAA;IAEF,MAAM,WAAW,qBAA6B,KAAK,CAAE,CAAA;IAErD,OAAO,CACL,oBAAC,sBAAW,oBACN,SAAS,IACb,SAAS,EAAE,GAAG,EACd,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,eAAe;QACxB,sBAAsB;QACtB,GAAG,EAAE,GAAG,EACR,GAAG,EAAC,EAAE,EACN,SAAS,EAAE,SAAS,IACpB,CACH,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;IACzC,SAAS,CAAC,WAAW,GAAG,WAAW,CAAA;CACpC;AAED,kBAAe,SAAS,CAAA","sourcesContent":["import classNames from 'classnames'\nimport type {\n SegmentedLabeledOption as RcSegmentedLabeledOption,\n SegmentedProps as RCSegmentedProps,\n SegmentedRawOption,\n} from 'rc-segmented'\nimport RcSegmented from 'rc-segmented'\nimport * as React from 'react'\n\nimport './index.less'\n\nexport type SizeType = 'small' | 'middle' | 'large' | undefined\nconst SizeContext = React.createContext<SizeType>(undefined)\n\nexport type { SegmentedValue } from 'rc-segmented'\n\ninterface SegmentedLabeledOptionWithoutIcon extends RcSegmentedLabeledOption {\n label: RcSegmentedLabeledOption['label']\n}\n\ninterface SegmentedLabeledOptionWithIcon extends Omit<RcSegmentedLabeledOption, 'label'> {\n label?: RcSegmentedLabeledOption['label']\n /** Set icon for Segmented item */\n icon: React.ReactNode\n}\n\nfunction isSegmentedLabeledOptionWithIcon(\n option: SegmentedRawOption | SegmentedLabeledOptionWithIcon | SegmentedLabeledOptionWithoutIcon\n): option is SegmentedLabeledOptionWithIcon {\n return typeof option === 'object' && !!(option as SegmentedLabeledOptionWithIcon)?.icon\n}\n\nexport type SegmentedLabeledOption =\n | SegmentedLabeledOptionWithIcon\n | SegmentedLabeledOptionWithoutIcon\n\nexport interface SegmentedProps extends Omit<RCSegmentedProps, 'size' | 'options'> {\n rootClassName?: string\n options: (SegmentedRawOption | SegmentedLabeledOption)[]\n block?: boolean\n size?: SizeType\n}\n\nconst Segmented = React.forwardRef<HTMLDivElement, SegmentedProps>((props, ref) => {\n const {\n prefixCls: customizePrefixCls,\n className,\n rootClassName,\n block,\n options = [],\n size: customSize = 'middle',\n style,\n ...restProps\n } = props\n\n const prefixCls = 'tntd-segmented'\n\n // ===================== Size =====================\n const size = React.useContext(SizeContext)\n const mergedSize = customSize || size\n\n // syntactic sugar to support `icon` for Segmented Item\n const extendedOptions = React.useMemo<RCSegmentedProps['options']>(\n () =>\n options.map((option) => {\n if (isSegmentedLabeledOptionWithIcon(option)) {\n const { icon, label, ...restOption } = option\n return {\n ...restOption,\n label: (\n <>\n <span className={`${prefixCls}-item-icon`}>{icon}</span>\n {label && <span>{label}</span>}\n </>\n ),\n }\n }\n return option\n }),\n [options, prefixCls]\n )\n\n const cls = classNames(className, rootClassName, {\n [`${prefixCls}-block`]: block,\n [`${prefixCls}-sm`]: mergedSize === 'small',\n [`${prefixCls}-lg`]: mergedSize === 'large',\n })\n\n const mergedStyle: React.CSSProperties = { ...style }\n\n return (\n <RcSegmented\n {...restProps}\n className={cls}\n style={mergedStyle}\n options={extendedOptions}\n // options={options}\n ref={ref}\n rev=\"\"\n prefixCls={prefixCls}\n />\n )\n})\n\nif (process.env.NODE_ENV !== 'production') {\n Segmented.displayName = 'Segmented'\n}\n\nexport default Segmented\n"]}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
.tntd-segmented {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
margin: 0;
|
|
4
|
+
padding: 0;
|
|
5
|
+
color: rgba(0,0,0,.65);
|
|
6
|
+
font-size: 14px;
|
|
7
|
+
line-height: 1.5715;
|
|
8
|
+
list-style: none;
|
|
9
|
+
|
|
10
|
+
display: inline-block;
|
|
11
|
+
padding: 2px;
|
|
12
|
+
color: rgba(0,0,0,.65);
|
|
13
|
+
background-color: rgba(0,0,0,.04);
|
|
14
|
+
border-radius: 2px;
|
|
15
|
+
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
16
|
+
font-family: initial;
|
|
17
|
+
|
|
18
|
+
.tntd-segmented-group {
|
|
19
|
+
position: relative;
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: stretch;
|
|
22
|
+
justify-items: flex-start;
|
|
23
|
+
width: 100%;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// item styles
|
|
27
|
+
.tntd-segmented-item {
|
|
28
|
+
position: relative;
|
|
29
|
+
text-align: center;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
transition: color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
32
|
+
|
|
33
|
+
&-selected {
|
|
34
|
+
background-color: #fff;
|
|
35
|
+
border-radius: 2px;
|
|
36
|
+
box-shadow: 0 2px 8px -2px rgba(0,0,0,.05), 0 1px 4px -1px rgba(0,0,0,.07),
|
|
37
|
+
0 0 1px rgba(0,0,0,.08);
|
|
38
|
+
color: #262626;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&:hover,
|
|
42
|
+
&:focus {
|
|
43
|
+
color: #262626;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&-label {
|
|
47
|
+
min-height: 28px;
|
|
48
|
+
padding: 0 12px;
|
|
49
|
+
line-height: 28px;
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
white-space: nowrap;
|
|
52
|
+
text-overflow: ellipsis;
|
|
53
|
+
word-break: keep-all;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// syntactic sugar to add `icon` for Segmented Item
|
|
57
|
+
&-icon + * {
|
|
58
|
+
margin-left: 6px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&-input {
|
|
62
|
+
position: absolute;
|
|
63
|
+
top: 0;
|
|
64
|
+
left: 0;
|
|
65
|
+
width: 0;
|
|
66
|
+
height: 0;
|
|
67
|
+
opacity: 0;
|
|
68
|
+
pointer-events: none;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// disabled styles
|
|
73
|
+
.tntd-segmented-item-disabled {
|
|
74
|
+
&,
|
|
75
|
+
&:hover,
|
|
76
|
+
&:focus {
|
|
77
|
+
color: rgba(0,0,0,.25);
|
|
78
|
+
cursor: not-allowed;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// thumb styles
|
|
83
|
+
.tntd-segmented-thumb {
|
|
84
|
+
background-color: #fff;
|
|
85
|
+
border-radius: 2px;
|
|
86
|
+
box-shadow: 0 2px 8px -2px rgba(0,0,0,.05), 0 1px 4px -1px rgba(0,0,0,.07),
|
|
87
|
+
0 0 1px rgba(0,0,0,.08);
|
|
88
|
+
|
|
89
|
+
position: absolute;
|
|
90
|
+
top: 0;
|
|
91
|
+
left: 0;
|
|
92
|
+
width: 0;
|
|
93
|
+
height: 100%;
|
|
94
|
+
padding: 4px 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// transition effect when `appear-active`
|
|
98
|
+
.tntd-segmented-thumb-motion-appear-active {
|
|
99
|
+
transition: transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), width 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
100
|
+
transition-property: all !important;
|
|
101
|
+
will-change: transform, width;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// hover/focus styles
|
|
105
|
+
&:not(&-disabled) {
|
|
106
|
+
&:hover,
|
|
107
|
+
&:focus {
|
|
108
|
+
background-color: rgba(0,0,0,.06);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.tntd-segmented-block {
|
|
114
|
+
display: flex;
|
|
115
|
+
|
|
116
|
+
.tntd-segmented-item {
|
|
117
|
+
flex: 1;
|
|
118
|
+
min-width: 0;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// size styles
|
|
123
|
+
.tntd-segmented-lg {
|
|
124
|
+
.tntd-segmented-item-label {
|
|
125
|
+
min-height: 36px;
|
|
126
|
+
padding: 0 12px;
|
|
127
|
+
font-size: 16px;
|
|
128
|
+
line-height: 36px;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.tntd-segmented-sm {
|
|
133
|
+
.tntd-segmented-item-label {
|
|
134
|
+
min-height: 22px;
|
|
135
|
+
line-height: 22px;
|
|
136
|
+
padding: 0 7px;
|
|
137
|
+
}
|
|
138
|
+
}
|
package/lib/table/constants.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/table/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,yBAAyB,CAAA"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/table/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,yBAAyB,CAAA;AAE5D,eAAO,MAAM,YAAY,EAAE,MAAM,EAmDhC,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,MAAM,EAAuB,CAAA"}
|
package/lib/table/constants.js
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TABLE_SIZE_STORAGE_KEY = void 0;
|
|
3
|
+
exports.articles = exports.prepositions = exports.TABLE_SIZE_STORAGE_KEY = void 0;
|
|
4
4
|
exports.TABLE_SIZE_STORAGE_KEY = '__$table-custom-size';
|
|
5
|
+
exports.prepositions = [
|
|
6
|
+
'about',
|
|
7
|
+
'above',
|
|
8
|
+
'across',
|
|
9
|
+
'after',
|
|
10
|
+
'against',
|
|
11
|
+
'along',
|
|
12
|
+
'among',
|
|
13
|
+
'around',
|
|
14
|
+
'as',
|
|
15
|
+
'at',
|
|
16
|
+
'before',
|
|
17
|
+
'behind',
|
|
18
|
+
'below',
|
|
19
|
+
'beneath',
|
|
20
|
+
'beside',
|
|
21
|
+
'between',
|
|
22
|
+
'beyond',
|
|
23
|
+
'by',
|
|
24
|
+
'down',
|
|
25
|
+
'during',
|
|
26
|
+
'except',
|
|
27
|
+
'for',
|
|
28
|
+
'from',
|
|
29
|
+
'in',
|
|
30
|
+
'inside',
|
|
31
|
+
'into',
|
|
32
|
+
'like',
|
|
33
|
+
'near',
|
|
34
|
+
'of',
|
|
35
|
+
'off',
|
|
36
|
+
'on',
|
|
37
|
+
'onto',
|
|
38
|
+
'out',
|
|
39
|
+
'outside',
|
|
40
|
+
'over',
|
|
41
|
+
'past',
|
|
42
|
+
'round',
|
|
43
|
+
'since',
|
|
44
|
+
'through',
|
|
45
|
+
'throughout',
|
|
46
|
+
'to',
|
|
47
|
+
'toward',
|
|
48
|
+
'under',
|
|
49
|
+
'underneath',
|
|
50
|
+
'until',
|
|
51
|
+
'up',
|
|
52
|
+
'upon',
|
|
53
|
+
'with',
|
|
54
|
+
'within',
|
|
55
|
+
'without',
|
|
56
|
+
];
|
|
57
|
+
exports.articles = ['the', 'a', 'an'];
|
|
5
58
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/table/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG,sBAAsB,CAAA","sourcesContent":["export const TABLE_SIZE_STORAGE_KEY = '__$table-custom-size'\n"]}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/table/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG,sBAAsB,CAAA;AAE/C,QAAA,YAAY,GAAa;IACpC,OAAO;IACP,OAAO;IACP,QAAQ;IACR,OAAO;IACP,SAAS;IACT,OAAO;IACP,OAAO;IACP,QAAQ;IACR,IAAI;IACJ,IAAI;IACJ,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,SAAS;IACT,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,IAAI;IACJ,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,KAAK;IACL,MAAM;IACN,IAAI;IACJ,QAAQ;IACR,MAAM;IACN,MAAM;IACN,MAAM;IACN,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,MAAM;IACN,KAAK;IACL,SAAS;IACT,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,SAAS;IACT,YAAY;IACZ,IAAI;IACJ,QAAQ;IACR,OAAO;IACP,YAAY;IACZ,OAAO;IACP,IAAI;IACJ,MAAM;IACN,MAAM;IACN,QAAQ;IACR,SAAS;CACV,CAAA;AAEY,QAAA,QAAQ,GAAa,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA","sourcesContent":["export const TABLE_SIZE_STORAGE_KEY = '__$table-custom-size'\n\nexport const prepositions: string[] = [\n 'about',\n 'above',\n 'across',\n 'after',\n 'against',\n 'along',\n 'among',\n 'around',\n 'as',\n 'at',\n 'before',\n 'behind',\n 'below',\n 'beneath',\n 'beside',\n 'between',\n 'beyond',\n 'by',\n 'down',\n 'during',\n 'except',\n 'for',\n 'from',\n 'in',\n 'inside',\n 'into',\n 'like',\n 'near',\n 'of',\n 'off',\n 'on',\n 'onto',\n 'out',\n 'outside',\n 'over',\n 'past',\n 'round',\n 'since',\n 'through',\n 'throughout',\n 'to',\n 'toward',\n 'under',\n 'underneath',\n 'until',\n 'up',\n 'upon',\n 'with',\n 'within',\n 'without',\n]\n\nexport const articles: string[] = ['the', 'a', 'an']\n"]}
|
package/lib/table/context.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/table/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAA;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAE/D,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAO/B;;OAEG;IACH,cAAc,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,CAAA;IAE1C;;OAEG;IACH,gBAAgB,CAAC,CAAC,aAAa,EAAE,aAAa,EAAE,GAAG,SAAS,GAAG,IAAI,CAAA;IAEnE;;OAEG;IACH,OAAO,CAAC,IAAI,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/table/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAA;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAE/D,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAO/B;;OAEG;IACH,cAAc,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,CAAA;IAE1C;;OAEG;IACH,gBAAgB,CAAC,CAAC,aAAa,EAAE,aAAa,EAAE,GAAG,SAAS,GAAG,IAAI,CAAA;IAEnE;;OAEG;IACH,OAAO,CAAC,IAAI,IAAI,CAAA;IAEhB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;CAM3B;AAED,eAAO,MAAM,YAAY,4CAAuC,CAAA"}
|
package/lib/table/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/table/context.ts"],"names":[],"mappings":";;;AAAA,iCAAgD;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/table/context.ts"],"names":[],"mappings":";;;AAAA,iCAAgD;AAsCnC,QAAA,YAAY,GAAG,IAAA,qBAAa,EAAoB,EAAE,CAAC,CAAA","sourcesContent":["import { createContext, RefObject } from 'react'\n\nimport type { ColumnSetting } from './hooks/use-column-setting'\n\nexport interface TableContextValue {\n /**\n * column setting\n */\n columnSetting?: ColumnSetting[]\n\n // /**\n // * size\n // */\n // size?: TableProps<unknown>['size']\n\n /**\n * container ref\n */\n tableContainer?: RefObject<HTMLDivElement>\n\n /**\n * set column setting function\n */\n setColumnSetting?(columnSetting: ColumnSetting[] | undefined): void\n\n /**\n * refresh function\n */\n refresh?(): void\n\n upperCaseIgnore?: string[]\n\n // /**\n // * set size function\n // */\n // setSize?(size: TableProps<unknown>['size']): void\n}\n\nexport const TableContext = createContext<TableContextValue>({})\n"]}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type { ColumnProps } from 'antd/es/table';
|
|
1
|
+
import type { ColumnProps as AntdColumnProps } from 'antd/es/table';
|
|
2
2
|
import type { Dispatch, SetStateAction } from 'react';
|
|
3
3
|
export interface ColumnSetting {
|
|
4
4
|
key: string;
|
|
5
5
|
order: number;
|
|
6
6
|
enable: boolean;
|
|
7
7
|
}
|
|
8
|
+
export declare type ColumnProps<T> = AntdColumnProps<T> & {
|
|
9
|
+
placement?: 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
10
|
+
};
|
|
8
11
|
export declare const useColumnSetting: <T>(columns: ColumnProps<T>[], storageKey?: string | undefined) => [ColumnProps<T>[], ColumnSetting[] | undefined, Dispatch<SetStateAction<ColumnSetting[] | undefined>>];
|
|
9
12
|
//# sourceMappingURL=use-column-setting.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-column-setting.d.ts","sourceRoot":"","sources":["../../../src/table/hooks/use-column-setting.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"use-column-setting.d.ts","sourceRoot":"","sources":["../../../src/table/hooks/use-column-setting.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAGrD,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,oBAAY,WAAW,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,GAAG;IAChD,SAAS,CAAC,EACN,KAAK,GACL,MAAM,GACN,OAAO,GACP,QAAQ,GACR,SAAS,GACT,UAAU,GACV,YAAY,GACZ,aAAa,GACb,SAAS,GACT,YAAY,GACZ,UAAU,GACV,aAAa,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,gBAAgB,2KAyB5B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-column-setting.js","sourceRoot":"","sources":["../../../src/table/hooks/use-column-setting.ts"],"names":[],"mappings":";;;AAAA,4CAA0D;AAG1D,iCAA+B;
|
|
1
|
+
{"version":3,"file":"use-column-setting.js","sourceRoot":"","sources":["../../../src/table/hooks/use-column-setting.ts"],"names":[],"mappings":";;;AAAA,4CAA0D;AAG1D,iCAA+B;AAwBxB,MAAM,gBAAgB,GAAG,CAC9B,OAAyB,EACzB,UAAmB,EAKnB,EAAE;IACF,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,+BAAuB,EAAkB,UAAU,EAAE,EAAE,CAAC,CAAA;IAClG,MAAM,cAAc,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAClC,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAChD,OAAO,OAAO,CAAA;SACf;QAED,OAAO,OAAO;aACX,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC;aAC/E,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACb,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAA;YACrE,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAA;YAErE,OAAO,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,KAAI,CAAC,CAAC,GAAG,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,KAAI,CAAC,CAAC,CAAA;QACpD,CAAC,CAAC,CAAA;IACN,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAA;IAE5B,OAAO,CAAC,cAAc,EAAE,aAAa,EAAE,gBAAgB,CAAC,CAAA;AAC1D,CAAC,CAAA;AAzBY,QAAA,gBAAgB,oBAyB5B","sourcesContent":["import { useLocalStorageMayEmpty } from '@stellaris/hooks'\nimport type { ColumnProps as AntdColumnProps } from 'antd/es/table'\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useMemo } from 'react'\n\nexport interface ColumnSetting {\n key: string\n order: number\n enable: boolean\n}\n\nexport type ColumnProps<T> = AntdColumnProps<T> & {\n placement?:\n | 'top'\n | 'left'\n | 'right'\n | 'bottom'\n | 'topLeft'\n | 'topRight'\n | 'bottomLeft'\n | 'bottomRight'\n | 'leftTop'\n | 'leftBottom'\n | 'rightTop'\n | 'rightBottom'\n}\n\nexport const useColumnSetting = <T>(\n columns: ColumnProps<T>[],\n storageKey?: string\n): [\n ColumnProps<T>[],\n ColumnSetting[] | undefined,\n Dispatch<SetStateAction<ColumnSetting[] | undefined>>\n] => {\n const [columnSetting, setColumnSetting] = useLocalStorageMayEmpty<ColumnSetting[]>(storageKey, [])\n const displayColumns = useMemo(() => {\n if (!columnSetting || columnSetting.length === 0) {\n return columns\n }\n\n return columns\n .filter((column) => columnSetting.some((setting) => setting.key === column.key))\n .sort((a, b) => {\n const aIndex = columnSetting.find((setting) => setting.key === a.key)\n const bIndex = columnSetting.find((setting) => setting.key === b.key)\n\n return (aIndex?.order || 0) - (bIndex?.order || 0)\n })\n }, [columnSetting, columns])\n\n return [displayColumns, columnSetting, setColumnSetting]\n}\n"]}
|
package/lib/table/table.d.ts
CHANGED
|
@@ -13,9 +13,10 @@ export declare type TableProps<T> = Omit<AntdTableProps<T>, 'locale'> & {
|
|
|
13
13
|
emptyText?: string;
|
|
14
14
|
};
|
|
15
15
|
refresh?(): void;
|
|
16
|
+
upperCaseIgnore?: string[];
|
|
16
17
|
};
|
|
17
18
|
export declare const Table: {
|
|
18
|
-
<T>({ className, locale, bordered, size, storageKey, columns, children, shadowed, striped, showCellBorders,
|
|
19
|
+
<T>({ className, locale, bordered, size, storageKey, columns, children, shadowed, striped, showCellBorders, enableToolbar, refresh, upperCaseIgnore, ...rest }: TableProps<T>): JSX.Element;
|
|
19
20
|
Column: typeof Column;
|
|
20
21
|
ColumnGroup: typeof ColumnGroup;
|
|
21
22
|
displayName: string;
|
package/lib/table/table.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/table/table.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/table/table.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,EACV,UAAU,IAAI,cAAc,EAI7B,MAAM,eAAe,CAAA;AAEtB,OAAO,MAAM,MAAM,sBAAsB,CAAA;AACzC,OAAO,WAAW,MAAM,2BAA2B,CAAA;AAkBnD,oBAAY,UAAU,CAAC,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG;QACrC,kBAAkB,CAAC,EAAE,MAAM,CAAA;QAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,OAAO,CAAC,IAAI,IAAI,CAAA;IAChB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;CAC3B,CAAA;AAMD,eAAO,MAAM,KAAK;;;;;CAoNjB,CAAA"}
|
package/lib/table/table.js
CHANGED
|
@@ -45,13 +45,26 @@ const Column_1 = __importDefault(require("antd/es/table/Column"));
|
|
|
45
45
|
const ColumnGroup_1 = __importDefault(require("antd/es/table/ColumnGroup"));
|
|
46
46
|
const classnames_1 = __importDefault(require("classnames"));
|
|
47
47
|
const react_1 = __importStar(require("react"));
|
|
48
|
+
const ellipsis_1 = __importDefault(require("../ellipsis"));
|
|
48
49
|
const context_1 = require("./context");
|
|
49
50
|
const hooks_1 = require("./hooks");
|
|
50
51
|
const utils_1 = require("./utils");
|
|
52
|
+
const total_shower_1 = require("./total-shower");
|
|
53
|
+
const prev_locale_1 = require("../prev-locale");
|
|
54
|
+
const constants_1 = require("./constants");
|
|
55
|
+
const sizeWidthMap = {
|
|
56
|
+
default: 40,
|
|
57
|
+
middle: 20,
|
|
58
|
+
small: 20,
|
|
59
|
+
xs: 16, // 8
|
|
60
|
+
};
|
|
61
|
+
const getDefaultPagination = (locale) => ({
|
|
62
|
+
showTotal: (total) => react_1.default.createElement(total_shower_1.TotalShower, { total: total, locale: locale }),
|
|
63
|
+
});
|
|
51
64
|
const Table = (_a) => {
|
|
52
|
-
var { className, locale, bordered, size, storageKey, columns, children, shadowed = !bordered, striped = false, showCellBorders = false,
|
|
53
|
-
|
|
54
|
-
|
|
65
|
+
var { className, locale, bordered, size, storageKey, columns, children, shadowed = !bordered, striped = false, showCellBorders = false,
|
|
66
|
+
// pagination,
|
|
67
|
+
enableToolbar = false, refresh, upperCaseIgnore } = _a, rest = __rest(_a, ["className", "locale", "bordered", "size", "storageKey", "columns", "children", "shadowed", "striped", "showCellBorders", "enableToolbar", "refresh", "upperCaseIgnore"]);
|
|
55
68
|
const tableContainer = (0, react_1.useRef)(null);
|
|
56
69
|
// const [innerSize, setInnerSize] = useLocalStorage<TableProps<T>['size']>(
|
|
57
70
|
// TABLE_SIZE_STORAGE_KEY,
|
|
@@ -59,6 +72,102 @@ const Table = (_a) => {
|
|
|
59
72
|
// )
|
|
60
73
|
const normalizedColumns = (0, react_1.useMemo)(() => columns || (0, utils_1.normalizeColumns)(children), [children, columns]);
|
|
61
74
|
const [displayColumns, columnSetting, setColumnSetting] = (0, hooks_1.useColumnSetting)(normalizedColumns, storageKey);
|
|
75
|
+
const titleHandle = (str) => {
|
|
76
|
+
const words = str.split(' ');
|
|
77
|
+
const capitalizedWords = words.map((word, i) => {
|
|
78
|
+
const lowerCaseWord = word.toLowerCase();
|
|
79
|
+
let ignoreList = constants_1.prepositions.concat(constants_1.articles);
|
|
80
|
+
if (upperCaseIgnore === null || upperCaseIgnore === void 0 ? void 0 : upperCaseIgnore.length) {
|
|
81
|
+
ignoreList = ignoreList.concat(upperCaseIgnore);
|
|
82
|
+
ignoreList = Array.from(new Set(ignoreList));
|
|
83
|
+
}
|
|
84
|
+
if (ignoreList.includes(lowerCaseWord) && i !== 0) {
|
|
85
|
+
return lowerCaseWord;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
return capitalizedWords.join(' ');
|
|
92
|
+
};
|
|
93
|
+
// 表头转换为首字母大写
|
|
94
|
+
const titleCaseUpper = (str) => {
|
|
95
|
+
if (!str) {
|
|
96
|
+
return str;
|
|
97
|
+
}
|
|
98
|
+
// 有斜杠根据斜杠划分
|
|
99
|
+
if (str === null || str === void 0 ? void 0 : str.includes('/')) {
|
|
100
|
+
const parWords = str.split('/');
|
|
101
|
+
return parWords
|
|
102
|
+
.map((str1) => {
|
|
103
|
+
return titleHandle(str1);
|
|
104
|
+
})
|
|
105
|
+
.join('/');
|
|
106
|
+
}
|
|
107
|
+
return titleHandle(str);
|
|
108
|
+
};
|
|
109
|
+
const lang = (0, prev_locale_1.getLanguage)();
|
|
110
|
+
let newColumns = displayColumns;
|
|
111
|
+
// 非中文做处理
|
|
112
|
+
if (lang !== 'cn') {
|
|
113
|
+
newColumns = displayColumns === null || displayColumns === void 0 ? void 0 : displayColumns.map((column) => {
|
|
114
|
+
return Object.assign(Object.assign({}, column), { title: (options) => {
|
|
115
|
+
let title = column.title;
|
|
116
|
+
if (typeof title === 'function') {
|
|
117
|
+
title = title(options);
|
|
118
|
+
}
|
|
119
|
+
if (react_1.default.isValidElement(title)) {
|
|
120
|
+
const renderChildren = (children) => {
|
|
121
|
+
if (react_1.default.isValidElement(children) || Array.isArray(children)) {
|
|
122
|
+
return react_1.default.Children.map(children, (child) => {
|
|
123
|
+
var _a;
|
|
124
|
+
if (react_1.default.isValidElement(child)) {
|
|
125
|
+
const childProps = (child.props || {});
|
|
126
|
+
return react_1.default.cloneElement(child, Object.assign(Object.assign({}, childProps), { children: ((_a = childProps.children) === null || _a === void 0 ? void 0 : _a.length)
|
|
127
|
+
? renderChildren(childProps.children)
|
|
128
|
+
: childProps.children, title: titleCaseUpper(childProps === null || childProps === void 0 ? void 0 : childProps.title) }));
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
return titleCaseUpper(child);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return titleCaseUpper(children);
|
|
136
|
+
};
|
|
137
|
+
return renderChildren(title.props.children);
|
|
138
|
+
}
|
|
139
|
+
if (typeof title === 'string') {
|
|
140
|
+
return titleCaseUpper(title);
|
|
141
|
+
}
|
|
142
|
+
} });
|
|
143
|
+
});
|
|
144
|
+
newColumns = newColumns === null || newColumns === void 0 ? void 0 : newColumns.map((column) => {
|
|
145
|
+
if (!(column.width && !String(column.width).includes('%'))) {
|
|
146
|
+
return column;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
return Object.assign(Object.assign({}, column), { title: (options) => {
|
|
150
|
+
let title = column.title;
|
|
151
|
+
if (typeof title === 'function') {
|
|
152
|
+
title = title(options);
|
|
153
|
+
}
|
|
154
|
+
let widthLimitObj = {};
|
|
155
|
+
if (column.width && !String(column.width).includes('%')) {
|
|
156
|
+
let width = column.width;
|
|
157
|
+
if (typeof width === 'string') {
|
|
158
|
+
width = width.replace(/[^\d]/g, ' ');
|
|
159
|
+
}
|
|
160
|
+
widthLimitObj = {
|
|
161
|
+
widthLimit: Number(width) -
|
|
162
|
+
Number(sizeWidthMap[size || 'default']) -
|
|
163
|
+
(column.sorter ? 20 : 0),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
return (react_1.default.createElement(ellipsis_1.default, Object.assign({}, widthLimitObj, { placement: (column === null || column === void 0 ? void 0 : column.placement) || 'topLeft', title: title })));
|
|
167
|
+
} });
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
62
171
|
/**
|
|
63
172
|
* update the innerSize when props size changes
|
|
64
173
|
*/
|
|
@@ -72,6 +181,7 @@ const Table = (_a) => {
|
|
|
72
181
|
tableContainer,
|
|
73
182
|
columnSetting,
|
|
74
183
|
refresh,
|
|
184
|
+
upperCaseIgnore,
|
|
75
185
|
// setSize: setInnerSize,
|
|
76
186
|
setColumnSetting,
|
|
77
187
|
} },
|
|
@@ -79,8 +189,11 @@ const Table = (_a) => {
|
|
|
79
189
|
const prefixCls = getPrefixCls('table');
|
|
80
190
|
return (react_1.default.createElement("div", { ref: tableContainer },
|
|
81
191
|
react_1.default.createElement(LocaleReceiver_1.default, { componentName: "Table", defaultLocale: locale }, (localeObject) => {
|
|
82
|
-
const locale = localeObject
|
|
83
|
-
|
|
192
|
+
// const locale = localeObject as Record<string, string>
|
|
193
|
+
// const paginationConfig = pagination ? getDefaultPagination(locale) : pagination
|
|
194
|
+
return (react_1.default.createElement(table_1.default, Object.assign({ className: (0, classnames_1.default)(
|
|
195
|
+
// prefixCls,
|
|
196
|
+
'tnt-table-wrapper', {
|
|
84
197
|
[`${prefixCls}-borderless`]: !bordered,
|
|
85
198
|
[`${prefixCls}-hide-cell-borders`]: !showCellBorders,
|
|
86
199
|
[`${prefixCls}-size-small`]: size === 'small',
|
|
@@ -88,7 +201,7 @@ const Table = (_a) => {
|
|
|
88
201
|
[`${prefixCls}-size-middle`]: size === 'middle',
|
|
89
202
|
[`${prefixCls}-striped`]: striped,
|
|
90
203
|
[`${prefixCls}-shadowed`]: shadowed,
|
|
91
|
-
}, className), locale: locale, bordered: bordered, size: size, columns:
|
|
204
|
+
}, className), locale: locale, bordered: bordered, size: size, columns: newColumns }, rest)));
|
|
92
205
|
})));
|
|
93
206
|
})));
|
|
94
207
|
};
|