tntd 2.7.2 → 2.7.4
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/affix/index.js +2 -1
- package/es/alert/index.js +2 -1
- package/es/anchor/index.js +2 -1
- package/es/array-input/icon.js +6 -24
- package/es/array-input/index.js +119 -203
- package/es/auth-context/index.js +2 -1
- package/es/auto-complete/index.js +2 -1
- package/es/avatar/index.js +2 -1
- package/es/back-top/index.js +2 -1
- package/es/badge/index.js +2 -1
- package/es/breadcrumb/index.js +2 -1
- package/es/button/index.js +2 -1
- package/es/calendar/index.js +2 -1
- package/es/card/index.js +2 -1
- package/es/carousel/index.js +2 -1
- package/es/cascader/index.js +2 -1
- 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/checkbox/checkbox-group.js +2 -1
- package/es/checkbox/index.js +2 -1
- package/es/col/index.js +2 -1
- package/es/collapse/index.js +2 -1
- package/es/color-picker/ColorPicker.js +81 -127
- package/es/color-picker/ColorPicker.js.map +1 -1
- package/es/color-picker/index.js +5 -8
- package/es/color-picker/index.less +5 -1
- package/es/columns/index.js +30 -66
- package/es/columns/style/index.js +2 -1
- package/es/comment/index.js +2 -1
- package/es/config-provider/DisabledContext.js +5 -9
- package/es/config-provider/SizeContext.js +3 -7
- package/es/config-provider/config-provider.js +2 -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/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 +2 -2
- 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/switch/switch.js.map +1 -1
- 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 +107 -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 +13 -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-form/tntd-form.stories.js +7 -5
- package/es/tntd-form/tntd-form.stories.js.map +1 -1
- package/es/tntd-layout/HeaderActions.js +1 -1
- package/es/tntd-layout/HeaderActions.js.map +1 -1
- 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/tree-select/index.js.map +1 -1
- 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 +5 -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/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 +2 -2
- 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/switch/switch.d.ts +1 -1
- package/lib/switch/switch.d.ts.map +1 -1
- package/lib/switch/switch.js.map +1 -1
- 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 +107 -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.d.ts.map +1 -1
- package/lib/tntd-form/Form.js +12 -0
- 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-form/tntd-form.stories.d.ts.map +1 -1
- package/lib/tntd-form/tntd-form.stories.js +7 -5
- package/lib/tntd-form/tntd-form.stories.js.map +1 -1
- package/lib/tntd-layout/HeaderActions.js +1 -1
- package/lib/tntd-layout/HeaderActions.js.map +1 -1
- 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/tree-select/index.d.ts +7 -5
- package/lib/tree-select/index.d.ts.map +1 -1
- package/lib/tree-select/index.js.map +1 -1
- 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
|
@@ -10,41 +10,46 @@ import { validateFields, getFieldsValue, getFieldValue } from './utils';
|
|
|
10
10
|
import { FormContext } from './store';
|
|
11
11
|
import List from './components/List';
|
|
12
12
|
import Item from './components/Item';
|
|
13
|
-
const TntdForm = ({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
const TntdForm = ({
|
|
14
|
+
form,
|
|
15
|
+
initialValues,
|
|
16
|
+
children
|
|
17
|
+
}) => {
|
|
18
|
+
const updateRefs = useRef({
|
|
19
|
+
shouldUpdateList: [],
|
|
20
|
+
dependencies: {}
|
|
21
|
+
});
|
|
22
|
+
const compsRefs = useRef({});
|
|
23
|
+
return React.createElement(FormContext.Provider, {
|
|
24
|
+
value: {
|
|
25
|
+
form,
|
|
26
|
+
initialValues,
|
|
27
|
+
updateRefs,
|
|
28
|
+
compsRefs
|
|
29
|
+
}
|
|
30
|
+
}, children);
|
|
25
31
|
};
|
|
26
32
|
TntdForm.useForm = () => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
const form = useRef({
|
|
34
|
+
dataLevel: {},
|
|
35
|
+
formData: {},
|
|
36
|
+
validateFields: () => validateFields(form.current),
|
|
37
|
+
getFieldsValue: () => getFieldsValue(form.current),
|
|
38
|
+
getFieldValue: field => getFieldValue(form.current, field),
|
|
39
|
+
setFieldsValue: obj => {
|
|
40
|
+
for (const i in obj) {
|
|
41
|
+
if (Object.prototype.hasOwnProperty.call(obj, i)) {
|
|
42
|
+
const prefix = (i === null || i === void 0 ? void 0 : i.split('.')) || [];
|
|
43
|
+
const attr = prefix.pop();
|
|
44
|
+
if (attr && form.current.formData[prefix.join('.')][attr]) {
|
|
45
|
+
form.current.formData[prefix.join('.')][attr].setItemValue(obj[i]);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return [form.current];
|
|
46
52
|
};
|
|
47
53
|
TntdForm.List = List;
|
|
48
54
|
TntdForm.Item = Item;
|
|
49
|
-
export default TntdForm;
|
|
50
|
-
//# sourceMappingURL=index.js.map
|
|
55
|
+
export default TntdForm;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=interface.js.map
|
|
1
|
+
export {};
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
export const isValidKey = (key, object) => {
|
|
2
|
-
|
|
2
|
+
return key in object;
|
|
3
3
|
};
|
|
4
4
|
/**
|
|
5
5
|
* 将xx.xx.xx 转换为数组
|
|
6
6
|
* @param {*} name
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
|
-
export const getNames =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return attrs;
|
|
9
|
+
export const getNames = name => {
|
|
10
|
+
let attrs = [];
|
|
11
|
+
if (Array.isArray(name)) {
|
|
12
|
+
const [str, ...rest] = name;
|
|
13
|
+
attrs = str.split('.').concat(rest);
|
|
14
|
+
} else {
|
|
15
|
+
attrs = typeof name === 'string' ? name.split('.') : [];
|
|
16
|
+
}
|
|
17
|
+
return attrs;
|
|
19
18
|
};
|
|
20
19
|
/**
|
|
21
20
|
* 对数据进行校验
|
|
@@ -25,34 +24,32 @@ export const getNames = (name) => {
|
|
|
25
24
|
* @returns
|
|
26
25
|
*/
|
|
27
26
|
export const recursionCheck = (list, dataLevel, formData, errorList = []) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
});
|
|
27
|
+
try {
|
|
28
|
+
if (Array.isArray(list)) {
|
|
29
|
+
list.forEach(item => {
|
|
30
|
+
const key = item.name;
|
|
31
|
+
const attrs = Object.keys(formData[key]);
|
|
32
|
+
attrs.forEach(attr => {
|
|
33
|
+
var _a;
|
|
34
|
+
const error = (_a = formData[item.name][attr]) === null || _a === void 0 ? void 0 : _a.checkItem();
|
|
35
|
+
if (error) {
|
|
36
|
+
errorList.push(`${[item.name + '.' + attr]}:`, error);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
if (dataLevel[key]) {
|
|
40
|
+
recursionCheck(dataLevel[key], dataLevel, formData, errorList);
|
|
44
41
|
}
|
|
45
|
-
|
|
42
|
+
});
|
|
46
43
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
throw e;
|
|
44
|
+
return errorList;
|
|
45
|
+
} catch (e) {
|
|
46
|
+
if (typeof e === 'string') {
|
|
47
|
+
throw e.toUpperCase();
|
|
48
|
+
} else if (e instanceof Error) {
|
|
49
|
+
throw e.message;
|
|
55
50
|
}
|
|
51
|
+
throw e;
|
|
52
|
+
}
|
|
56
53
|
};
|
|
57
54
|
/**
|
|
58
55
|
* 将数据进行排序
|
|
@@ -63,78 +60,74 @@ export const recursionCheck = (list, dataLevel, formData, errorList = []) => {
|
|
|
63
60
|
* @returns
|
|
64
61
|
*/
|
|
65
62
|
export const recursionSort = (list, dataLevel, formData) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return total;
|
|
91
|
-
}, {});
|
|
92
|
-
return values;
|
|
93
|
-
}
|
|
63
|
+
try {
|
|
64
|
+
if (Array.isArray(list)) {
|
|
65
|
+
const values = list.reduce((total, item, index) => {
|
|
66
|
+
const attrObj = {};
|
|
67
|
+
const key = item.name;
|
|
68
|
+
const prefixs = key.split('.');
|
|
69
|
+
const attrs = formData[key] ? Object.keys(formData[key]) : [];
|
|
70
|
+
attrs.forEach(attr => {
|
|
71
|
+
var _a;
|
|
72
|
+
attrObj[attr] = (_a = formData[key][attr]) === null || _a === void 0 ? void 0 : _a.value;
|
|
73
|
+
});
|
|
74
|
+
let children = [];
|
|
75
|
+
if (dataLevel[key]) {
|
|
76
|
+
children = recursionSort(dataLevel[key], dataLevel, formData);
|
|
77
|
+
}
|
|
78
|
+
const len = prefixs.length - 2;
|
|
79
|
+
if (total[prefixs[len]]) {
|
|
80
|
+
total[prefixs[len]][index] = Object.assign(Object.assign({}, attrObj), children || []);
|
|
81
|
+
} else {
|
|
82
|
+
total[prefixs[len]] = [Object.assign(Object.assign({}, attrObj), children || [])];
|
|
83
|
+
}
|
|
84
|
+
return total;
|
|
85
|
+
}, {});
|
|
86
|
+
return values;
|
|
94
87
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
throw e.message;
|
|
103
|
-
}
|
|
104
|
-
throw e;
|
|
88
|
+
} catch (e) {
|
|
89
|
+
if (typeof e === 'string') {
|
|
90
|
+
console.error(e.toUpperCase());
|
|
91
|
+
throw e.toUpperCase();
|
|
92
|
+
} else if (e instanceof Error) {
|
|
93
|
+
console.error(e.message);
|
|
94
|
+
throw e.message;
|
|
105
95
|
}
|
|
96
|
+
throw e;
|
|
97
|
+
}
|
|
106
98
|
};
|
|
107
99
|
/**
|
|
108
100
|
* 获取form表单的value
|
|
109
101
|
* @param {*} formCurrent
|
|
110
102
|
* @returns
|
|
111
103
|
*/
|
|
112
|
-
export const getFieldsValue =
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return values;
|
|
104
|
+
export const getFieldsValue = formCurrent => {
|
|
105
|
+
try {
|
|
106
|
+
const {
|
|
107
|
+
formData,
|
|
108
|
+
dataLevel
|
|
109
|
+
} = formCurrent;
|
|
110
|
+
let firstKey = '';
|
|
111
|
+
// 这里不直接用Object.keys的原因是Object.keys并不能保证一定是按照属性顺序
|
|
112
|
+
for (const i in dataLevel) {
|
|
113
|
+
if (Object.prototype.hasOwnProperty.call(dataLevel, i)) {
|
|
114
|
+
firstKey = i;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
126
117
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
118
|
+
const recursionStart = dataLevel[firstKey];
|
|
119
|
+
const values = recursionSort(recursionStart, dataLevel, formData);
|
|
120
|
+
return values;
|
|
121
|
+
} catch (e) {
|
|
122
|
+
if (typeof e === 'string') {
|
|
123
|
+
console.error(e.toUpperCase());
|
|
124
|
+
return e.toUpperCase();
|
|
125
|
+
} else if (e instanceof Error) {
|
|
126
|
+
console.error(e.message);
|
|
127
|
+
return e.message;
|
|
137
128
|
}
|
|
129
|
+
return e;
|
|
130
|
+
}
|
|
138
131
|
};
|
|
139
132
|
/**
|
|
140
133
|
* 获取form表单的value
|
|
@@ -142,88 +135,85 @@ export const getFieldsValue = (formCurrent) => {
|
|
|
142
135
|
* @returns
|
|
143
136
|
*/
|
|
144
137
|
export const getFieldValue = (formCurrent, field) => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
return e;
|
|
138
|
+
var _a, _b;
|
|
139
|
+
try {
|
|
140
|
+
const {
|
|
141
|
+
formData
|
|
142
|
+
} = formCurrent;
|
|
143
|
+
return formData && ((_b = (_a = formData === null || formData === void 0 ? void 0 : formData[field[0]]) === null || _a === void 0 ? void 0 : _a[field[1]]) === null || _b === void 0 ? void 0 : _b.value);
|
|
144
|
+
} catch (e) {
|
|
145
|
+
if (typeof e === 'string') {
|
|
146
|
+
return e.toUpperCase();
|
|
147
|
+
} else if (e instanceof Error) {
|
|
148
|
+
return e.message;
|
|
158
149
|
}
|
|
150
|
+
return e;
|
|
151
|
+
}
|
|
159
152
|
};
|
|
160
153
|
/**
|
|
161
154
|
* 提交时候校验的方法
|
|
162
155
|
* @param {*} formCurrent
|
|
163
156
|
* @returns
|
|
164
157
|
*/
|
|
165
|
-
export const validateFields =
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
158
|
+
export const validateFields = formCurrent => {
|
|
159
|
+
return new Promise(resolve => {
|
|
160
|
+
const {
|
|
161
|
+
formData,
|
|
162
|
+
dataLevel
|
|
163
|
+
} = formCurrent;
|
|
164
|
+
let firstKey = '';
|
|
165
|
+
// 这里不直接用Object.keys的原因是Object.keys并不能保证一定是按照属性顺序
|
|
166
|
+
for (const i in dataLevel) {
|
|
167
|
+
if (Object.prototype.hasOwnProperty.call(dataLevel, i)) {
|
|
168
|
+
firstKey = i;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const recursionStart = dataLevel[firstKey];
|
|
173
|
+
const errorList = recursionCheck(recursionStart, dataLevel, formData);
|
|
174
|
+
if (Array.isArray(errorList) && errorList.length) {
|
|
175
|
+
console.error(JSON.stringify(errorList));
|
|
176
|
+
} else {
|
|
177
|
+
resolve(recursionSort(recursionStart, dataLevel, formData));
|
|
178
|
+
}
|
|
179
|
+
});
|
|
185
180
|
};
|
|
186
181
|
/** 获取初始化的值 */
|
|
187
182
|
export const getInitValue = (initialValues, names) => {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
return initialValues;
|
|
183
|
+
let keys = [];
|
|
184
|
+
if (Array.isArray(names)) {
|
|
185
|
+
const [str, ...rest] = names;
|
|
186
|
+
keys = str.split('.').concat(rest);
|
|
187
|
+
}
|
|
188
|
+
if (Array.isArray(keys) && !!keys.length) {
|
|
189
|
+
keys.forEach(i => {
|
|
190
|
+
initialValues = ['', null, undefined].includes(initialValues === null || initialValues === void 0 ? void 0 : initialValues[i]) ? undefined : initialValues === null || initialValues === void 0 ? void 0 : initialValues[i];
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
return initialValues;
|
|
201
194
|
};
|
|
202
195
|
/** 校验表单是否正确的方法 */
|
|
203
196
|
export const handleCheckItem = (value, rules) => {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
return;
|
|
197
|
+
try {
|
|
198
|
+
if (Array.isArray(rules)) {
|
|
199
|
+
rules.forEach(i => {
|
|
200
|
+
// @ts-ignore
|
|
201
|
+
if (i.required && ['', null, undefined].includes(value)) {
|
|
202
|
+
throw new Error((i === null || i === void 0 ? void 0 : i.message) || 'error');
|
|
203
|
+
}
|
|
204
|
+
if (i === null || i === void 0 ? void 0 : i.validator) {
|
|
205
|
+
i.validator(rules, value, function (_errorMsg) {
|
|
206
|
+
throw new Error(_errorMsg);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
});
|
|
219
210
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
211
|
+
return;
|
|
212
|
+
} catch (e) {
|
|
213
|
+
if (typeof e === 'string') {
|
|
214
|
+
return e.toUpperCase();
|
|
215
|
+
} else if (e instanceof Error) {
|
|
216
|
+
return e.message;
|
|
227
217
|
}
|
|
228
|
-
}
|
|
229
|
-
|
|
218
|
+
}
|
|
219
|
+
};
|
|
@@ -13,8 +13,8 @@ import React, { useEffect, useRef, useState } from 'react';
|
|
|
13
13
|
import Form from './index';
|
|
14
14
|
import { Input, InputNumber, Checkbox, Button, Select, Radio, Row, message, Icon, Modal, Drawer, Cascader, DatePicker, TimePicker, TreeSelect, Switch, Upload, } from '../index';
|
|
15
15
|
import moment from 'moment';
|
|
16
|
-
const { TreeNode } = TreeSelect;
|
|
17
16
|
const { Option } = Select;
|
|
17
|
+
const { TreeNode } = TreeSelect;
|
|
18
18
|
const options = [
|
|
19
19
|
{ label: 'Apple', value: 'apple' },
|
|
20
20
|
{ label: 'Pear', value: 'pear' },
|
|
@@ -50,8 +50,8 @@ Basic.args = {
|
|
|
50
50
|
React.createElement(Input, null)),
|
|
51
51
|
React.createElement(Form.Item, { label: "Password", name: "password", rules: [{ required: true, message: 'Please input your password!' }] },
|
|
52
52
|
React.createElement(Input.Password, null)),
|
|
53
|
-
React.createElement(Form.Item, { label: "TreeSelect", name: "treeSelect" },
|
|
54
|
-
React.createElement(TreeSelect, { treeDefaultExpandAll: true,
|
|
53
|
+
React.createElement(Form.Item, { label: "TreeSelect", name: "treeSelect", rules: [{ required: true, message: 'Please select one node' }] },
|
|
54
|
+
React.createElement(TreeSelect, { showSearch: true, treeDefaultExpandAll: true, allowClear: true },
|
|
55
55
|
React.createElement(TreeNode, { value: "parent 1", title: "parent 1", key: "0-1" },
|
|
56
56
|
React.createElement(TreeNode, { value: "parent 1-0", title: "parent 1-0", key: "0-1-1" },
|
|
57
57
|
React.createElement(TreeNode, { value: "leaf1", title: "my leaf", key: "random" }),
|
|
@@ -268,13 +268,14 @@ export const DynamicItemsComplex = DynamicItemsComplexTpl.bind({});
|
|
|
268
268
|
// 弹窗中表单
|
|
269
269
|
const FormInModalTpl = () => {
|
|
270
270
|
const [data, setData] = useState({});
|
|
271
|
+
const [destroyOnClose, setDestroyOnClose] = useState(true);
|
|
271
272
|
const [popupType, setPopupType] = useState('modal');
|
|
272
273
|
const PopupCom = {
|
|
273
274
|
modal: Modal,
|
|
274
275
|
drawer: Drawer,
|
|
275
276
|
}[popupType];
|
|
276
|
-
const [form] = Form.useForm();
|
|
277
277
|
const close = () => setData(null);
|
|
278
|
+
const [form] = Form.useForm();
|
|
278
279
|
return (React.createElement(React.Fragment, null,
|
|
279
280
|
React.createElement(Button, { type: "primary", onClick: () => setData({}), style: { marginRight: 12 } }, "\u65B0\u5EFA"),
|
|
280
281
|
React.createElement(Button, { type: "primary", style: { marginRight: 12, marginBottom: 12 }, onClick: () => setData({
|
|
@@ -286,7 +287,8 @@ const FormInModalTpl = () => {
|
|
|
286
287
|
React.createElement(Radio.Group, { value: popupType, onChange: (evt) => setPopupType(evt.target.value) },
|
|
287
288
|
React.createElement(Radio.Button, { value: "modal" }, "\u5F39\u7A97"),
|
|
288
289
|
React.createElement(Radio.Button, { value: "drawer" }, "\u62BD\u5C49")),
|
|
289
|
-
React.createElement(
|
|
290
|
+
React.createElement(Switch, { onClick: () => setDestroyOnClose(!destroyOnClose), checked: destroyOnClose, checkedChildren: "\u5173\u95ED\u65F6\u9500\u6BC1\u5B50\u5143\u7D20", unCheckedChildren: "\u5173\u95ED\u65F6\u4E0D\u9500\u6BC1\u5B50\u5143\u7D20" }),
|
|
291
|
+
React.createElement(PopupCom, { title: `${(data === null || data === void 0 ? void 0 : data.id) ? '编辑' : '新建'}`, visible: !!data, width: "40%", destroyOnClose: destroyOnClose, onClose: close, onCancel: close, onOk: close },
|
|
290
292
|
React.createElement(Form, { initialValues: data, form: form },
|
|
291
293
|
React.createElement(Form.Item, { name: "name", label: "\u540D\u79F0" },
|
|
292
294
|
React.createElement(Input, null)),
|