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
|
@@ -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
|
+
};
|
package/es/tntd-modal/index.js
CHANGED
|
@@ -9,31 +9,64 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
+
import { Close, FullScreen as FullScreenIcon, OffScreen } from '@icon-park/react';
|
|
12
13
|
import cn from 'classnames';
|
|
13
14
|
import React, { Fragment, useEffect, useState } from 'react';
|
|
14
|
-
import Modal from '
|
|
15
|
-
import
|
|
15
|
+
import { Modal as AntdModal } from 'antd';
|
|
16
|
+
import { isArray } from 'lodash';
|
|
16
17
|
import './index.less';
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
React.createElement(Icon, { className: "close", type: "close", onClick: onClose }))));
|
|
25
|
-
};
|
|
26
|
-
export default (props) => {
|
|
27
|
-
const { visible, children, logo, title, height = '90vh', width = '85%', className, supportFullscreen, onToggleFullscreen, onCancel } = props, rest = __rest(props, ["visible", "children", "logo", "title", "height", "width", "className", "supportFullscreen", "onToggleFullscreen", "onCancel"]);
|
|
28
|
-
const [fullscreen, setFullscreen] = useState(rest.fullscreen || false);
|
|
18
|
+
export const Modal = (_a) => {
|
|
19
|
+
var { visible, className, title, width, style = {}, children, onCancel, hasFooter = true, footer, config = {
|
|
20
|
+
width: 'auto',
|
|
21
|
+
height: 'auto',
|
|
22
|
+
} } = _a, rest = __rest(_a, ["visible", "className", "title", "width", "style", "children", "onCancel", "hasFooter", "footer", "config"]);
|
|
23
|
+
const [fullscreen, setFullscreen] = useState(false);
|
|
24
|
+
const supportFullscreen = config.fullScreen;
|
|
29
25
|
useEffect(() => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
return () => {
|
|
27
|
+
setFullscreen(false);
|
|
28
|
+
};
|
|
29
|
+
}, [visible]);
|
|
30
|
+
const Title = ({ title, logo, fullscreen, onToggleFullscreen, onClose, }) => {
|
|
31
|
+
return (React.createElement(Fragment, null,
|
|
32
|
+
React.createElement("div", { className: "ant-modal-header-title" },
|
|
33
|
+
logo && logo,
|
|
34
|
+
React.createElement("span", null, title)),
|
|
35
|
+
React.createElement("div", { className: "ant-modal-header-actions" },
|
|
36
|
+
React.createElement("a", { className: "modal-fullscreen-wrap", onClick: onToggleFullscreen }, fullscreen ? React.createElement(OffScreen, null) : React.createElement(FullScreenIcon, null)),
|
|
37
|
+
React.createElement("a", { className: "modal-close-wrap", onClick: onClose },
|
|
38
|
+
React.createElement(Close, { theme: "outline" })))));
|
|
39
|
+
};
|
|
40
|
+
const computeWidth = supportFullscreen
|
|
41
|
+
? fullscreen
|
|
42
|
+
? '100vw'
|
|
43
|
+
: width || config.width
|
|
44
|
+
: width || config.width;
|
|
45
|
+
const computeHeight = supportFullscreen ? (fullscreen ? '100vh' : config.height) : 'inherit';
|
|
46
|
+
style.height = computeHeight;
|
|
47
|
+
if (supportFullscreen && fullscreen) {
|
|
48
|
+
style.top = 0;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
delete style.top;
|
|
52
|
+
}
|
|
53
|
+
const footerConfig = hasFooter
|
|
54
|
+
? (isArray(footer) ? footer.length > 0 : footer)
|
|
55
|
+
? footer
|
|
56
|
+
: undefined
|
|
57
|
+
: null;
|
|
58
|
+
return (React.createElement(AntdModal, Object.assign({ visible: visible, title: supportFullscreen ? (React.createElement(Title, { logo: config.logo, title: title, fullscreen: fullscreen, supportFullscreen: supportFullscreen, onClose: onCancel, onToggleFullscreen: () => {
|
|
33
59
|
setFullscreen(!fullscreen);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
60
|
+
if (!fullscreen) {
|
|
61
|
+
}
|
|
62
|
+
} })) : (title), onCancel: onCancel, centered: supportFullscreen ? true : rest.centered ? true : false, width: computeWidth, style: style, className: cn([
|
|
63
|
+
{
|
|
64
|
+
'support-fullscreen': supportFullscreen,
|
|
65
|
+
fullscreen: fullscreen,
|
|
66
|
+
'no-header': supportFullscreen && !(config.logo || title),
|
|
67
|
+
},
|
|
68
|
+
className,
|
|
69
|
+
]), footer: footer }, rest), children));
|
|
38
70
|
};
|
|
71
|
+
export default Modal;
|
|
39
72
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tntd-modal/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tntd-modal/index.tsx"],"names":[],"mappings":"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","sourcesContent":["import { Close, FullScreen as FullScreenIcon, OffScreen } from '@icon-park/react'\nimport type { ModalProps as AntdModalProps } from 'antd/lib/modal'\nimport cn from 'classnames'\nimport React, { Fragment, useEffect, useState, useRef } from 'react'\nimport { Modal as AntdModal } from 'antd'\nimport { isArray } from 'lodash'\n\nimport './index.less'\n\nexport type ModalProps = AntdModalProps & {\n children?: React.ReactNode\n hasFooter?: boolean\n config?: {\n fullScreen?: boolean\n width?: string | number\n height?: string | number\n logo?: React.ReactNode\n }\n}\n\nexport const Modal = ({\n visible,\n className,\n title,\n width,\n style = {},\n children,\n onCancel,\n hasFooter = true,\n footer,\n config = {\n width: 'auto',\n height: 'auto',\n },\n ...rest\n}: ModalProps) => {\n const [fullscreen, setFullscreen] = useState<boolean>(false)\n const supportFullscreen = config.fullScreen\n\n useEffect(() => {\n return () => {\n setFullscreen(false)\n }\n }, [visible])\n\n const Title = ({\n title,\n logo,\n fullscreen,\n onToggleFullscreen,\n onClose,\n }: // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any) => {\n return (\n <Fragment>\n <div className=\"ant-modal-header-title\">\n {logo && logo}\n <span>{title}</span>\n </div>\n <div className=\"ant-modal-header-actions\">\n <a className=\"modal-fullscreen-wrap\" onClick={onToggleFullscreen}>\n {fullscreen ? <OffScreen /> : <FullScreenIcon />}\n </a>\n <a className=\"modal-close-wrap\" onClick={onClose}>\n <Close theme=\"outline\" />\n </a>\n </div>\n </Fragment>\n )\n }\n\n const computeWidth = supportFullscreen\n ? fullscreen\n ? '100vw'\n : width || config.width\n : width || config.width\n\n const computeHeight = supportFullscreen ? (fullscreen ? '100vh' : config.height) : 'inherit'\n\n style.height = computeHeight\n if (supportFullscreen && fullscreen) {\n style.top = 0\n } else {\n delete style.top\n }\n\n const footerConfig = hasFooter\n ? (isArray(footer) ? footer.length > 0 : footer)\n ? footer\n : undefined\n : null\n\n return (\n <AntdModal\n visible={visible}\n title={\n supportFullscreen ? (\n <Title\n logo={config.logo}\n title={title}\n fullscreen={fullscreen}\n supportFullscreen={supportFullscreen}\n onClose={onCancel}\n onToggleFullscreen={() => {\n setFullscreen(!fullscreen)\n if (!fullscreen) {\n }\n }}\n />\n ) : (\n title\n )\n }\n onCancel={onCancel}\n centered={supportFullscreen ? true : rest.centered ? true : false}\n width={computeWidth}\n style={style}\n className={cn([\n {\n 'support-fullscreen': supportFullscreen,\n fullscreen: fullscreen,\n 'no-header': supportFullscreen && !(config.logo || title),\n },\n className,\n ])}\n footer={footer}\n {...rest}\n >\n {children}\n </AntdModal>\n )\n}\n\nexport default Modal\n"]}
|