tntd 2.6.8 → 2.6.10
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 +26 -0
- package/es/actions/index.js.map +1 -0
- package/es/actions/index.less +70 -0
- package/es/cascader/index.js +5 -1
- package/es/cascader/index.js.map +1 -1
- package/es/check-card/group.js +197 -0
- package/es/check-card/group.js.map +1 -0
- package/es/check-card/index.js +163 -0
- package/es/check-card/index.js.map +1 -0
- package/es/check-card/index.less +179 -0
- package/es/checkbox/checkbox-group.js +5 -0
- package/es/checkbox/checkbox-group.js.map +1 -0
- package/es/checkbox/index.js +5 -0
- package/es/checkbox/index.js.map +1 -1
- 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/config-provider/DisabledContext.js +12 -0
- package/es/config-provider/DisabledContext.js.map +1 -0
- package/es/config-provider/SizeContext.js +9 -0
- package/es/config-provider/SizeContext.js.map +1 -0
- package/es/config-provider/index.js +4 -0
- package/es/config-provider/index.js.map +1 -1
- package/es/connect/index.js +29 -0
- package/es/connect/index.js.map +1 -0
- package/es/date-picker/index.js +15 -1
- package/es/date-picker/index.js.map +1 -1
- package/es/ellipsis/index.js +1 -1
- package/es/ellipsis/index.js.map +1 -1
- package/es/ellipsis/index.less +1 -1
- package/es/handle/index.js +13 -5
- package/es/handle/index.js.map +1 -1
- package/es/handle/index.less +1 -1
- package/es/index.js +8 -1
- package/es/index.js.map +1 -1
- package/es/index.less +5 -0
- package/es/input/input.js +19 -10
- package/es/input/input.js.map +1 -1
- package/es/input-number/index.js +3 -1
- package/es/input-number/index.js.map +1 -1
- package/es/label/label.js +140 -0
- package/es/label/label.js.map +1 -0
- package/es/label/label.test.js +12 -0
- package/es/label/label.test.js.map +1 -0
- package/es/locale/en_US.js +4 -2
- package/es/locale/en_US.js.map +1 -1
- package/es/locale/zh_CN.js +4 -2
- package/es/locale/zh_CN.js.map +1 -1
- 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/preview-text/index.js +265 -0
- package/es/preview-text/index.js.map +1 -0
- package/es/preview-text/index.less +3 -0
- package/es/query-form/Field/SelectInput.js +7 -5
- package/es/query-form/Field/SelectInput.js.map +1 -1
- package/es/radio/index.js +3 -0
- package/es/radio/index.js.map +1 -1
- package/es/radio/radio-group.js +5 -0
- package/es/radio/radio-group.js.map +1 -0
- package/es/segmented/index.js +67 -0
- package/es/segmented/index.js.map +1 -0
- package/es/segmented/index.less +138 -0
- package/es/select/index.js.map +1 -1
- package/es/select/select.js +25 -3
- package/es/select/select.js.map +1 -1
- package/es/switch/index.js +2 -3
- package/es/switch/index.js.map +1 -1
- package/es/switch/switch.js +10 -0
- package/es/switch/switch.js.map +1 -0
- package/es/table/table.js +10 -4
- package/es/table/table.js.map +1 -1
- package/es/table/total-shower.js +10 -0
- package/es/table/total-shower.js.map +1 -0
- package/es/time-picker/index.js +3 -1
- package/es/time-picker/index.js.map +1 -1
- package/es/title/index.js +9 -11
- package/es/title/index.js.map +1 -1
- package/es/title/index.less +10 -10
- package/es/tntd-form/ErrorList.js +87 -0
- package/es/tntd-form/ErrorList.js.map +1 -0
- package/es/tntd-form/Form.js +122 -0
- package/es/tntd-form/Form.js.map +1 -0
- package/es/tntd-form/FormItem/ItemHolder.js +144 -0
- package/es/tntd-form/FormItem/ItemHolder.js.map +1 -0
- package/es/tntd-form/FormItem/index.js +264 -0
- package/es/tntd-form/FormItem/index.js.map +1 -0
- package/es/tntd-form/FormItemInput.js +79 -0
- package/es/tntd-form/FormItemInput.js.map +1 -0
- package/es/tntd-form/FormItemLabel.js +98 -0
- package/es/tntd-form/FormItemLabel.js.map +1 -0
- package/es/tntd-form/FormList.js +40 -0
- package/es/tntd-form/FormList.js.map +1 -0
- package/es/tntd-form/_util/motion.js +47 -0
- package/es/tntd-form/_util/motion.js.map +1 -0
- package/es/tntd-form/_util/reactNode.js +16 -0
- package/es/tntd-form/_util/reactNode.js.map +1 -0
- package/es/tntd-form/_util/scrollTo.js +35 -0
- package/es/tntd-form/_util/scrollTo.js.map +1 -0
- package/es/tntd-form/_util/type.js +3 -0
- package/es/tntd-form/_util/type.js.map +1 -0
- package/es/tntd-form/_util/warning.js +5 -0
- package/es/tntd-form/_util/warning.js.map +1 -0
- package/es/tntd-form/_util/wave.js +168 -0
- package/es/tntd-form/_util/wave.js.map +1 -0
- package/es/tntd-form/context.js +40 -0
- package/es/tntd-form/context.js.map +1 -0
- package/es/tntd-form/hooks/useDebounce.js +13 -0
- package/es/tntd-form/hooks/useDebounce.js.map +1 -0
- package/es/tntd-form/hooks/useForm.js +40 -0
- package/es/tntd-form/hooks/useForm.js.map +1 -0
- package/es/tntd-form/hooks/useFormInstance.js +8 -0
- package/es/tntd-form/hooks/useFormInstance.js.map +1 -0
- package/es/tntd-form/hooks/useFormItemStatus.js +13 -0
- package/es/tntd-form/hooks/useFormItemStatus.js.map +1 -0
- package/es/tntd-form/hooks/useFrameState.js +37 -0
- package/es/tntd-form/hooks/useFrameState.js.map +1 -0
- package/es/tntd-form/hooks/useItemRef.js +20 -0
- package/es/tntd-form/hooks/useItemRef.js.map +1 -0
- package/es/tntd-form/index.js +17 -1
- package/es/tntd-form/index.js.map +1 -1
- package/es/tntd-form/interface.js +2 -0
- package/es/tntd-form/interface.js.map +1 -0
- package/es/tntd-form/style/components.less +16 -0
- package/es/tntd-form/style/horizontal.less +26 -0
- package/es/tntd-form/style/index.js +5 -0
- package/es/tntd-form/style/index.js.map +1 -0
- package/es/tntd-form/style/index.less +342 -0
- package/es/tntd-form/style/inline.less +40 -0
- package/es/tntd-form/style/mixin.less +90 -0
- package/es/tntd-form/style/rtl.less +204 -0
- package/es/tntd-form/style/status.less +45 -0
- package/es/tntd-form/style/vertical.less +95 -0
- package/es/tntd-form/tntd-form.stories.js +786 -0
- package/es/tntd-form/tntd-form.stories.js.map +1 -0
- package/es/tntd-form/util.js +18 -0
- package/es/tntd-form/util.js.map +1 -0
- package/es/tntd-form/validateMessagesContext.js +5 -0
- package/es/tntd-form/validateMessagesContext.js.map +1 -0
- package/es/tntd-modal/index.js +71 -56
- package/es/tntd-modal/index.js.map +1 -1
- package/es/tntd-modal/index.less +83 -63
- package/es/tree-select/index.js +4 -1
- package/es/tree-select/index.js.map +1 -1
- package/es/upload/index.js +8 -1
- package/es/upload/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 +10 -0
- package/es/utils/simple-template.js.map +1 -0
- package/es/water-mark/index.js +110 -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 +34 -0
- package/lib/actions/index.js.map +1 -0
- package/lib/actions/index.less +70 -0
- package/lib/cascader/index.d.ts +6 -1
- package/lib/cascader/index.d.ts.map +1 -1
- package/lib/cascader/index.js +10 -3
- package/lib/cascader/index.js.map +1 -1
- 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 +236 -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 +178 -0
- package/lib/check-card/index.js.map +1 -0
- package/lib/check-card/index.less +179 -0
- package/lib/checkbox/checkbox-group.d.ts +8 -0
- package/lib/checkbox/checkbox-group.d.ts.map +1 -0
- package/lib/checkbox/checkbox-group.js +13 -0
- package/lib/checkbox/checkbox-group.js.map +1 -0
- package/lib/checkbox/index.d.ts +1 -0
- package/lib/checkbox/index.d.ts.map +1 -1
- package/lib/checkbox/index.js +16 -0
- package/lib/checkbox/index.js.map +1 -1
- 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/config-provider/DisabledContext.d.ts +10 -0
- package/lib/config-provider/DisabledContext.d.ts.map +1 -0
- package/lib/config-provider/DisabledContext.js +22 -0
- package/lib/config-provider/DisabledContext.js.map +1 -0
- package/lib/config-provider/SizeContext.d.ts +10 -0
- package/lib/config-provider/SizeContext.d.ts.map +1 -0
- package/lib/config-provider/SizeContext.js +23 -0
- package/lib/config-provider/SizeContext.js.map +1 -0
- package/lib/config-provider/index.d.ts +1 -0
- package/lib/config-provider/index.d.ts.map +1 -1
- package/lib/config-provider/index.js +15 -0
- package/lib/config-provider/index.js.map +1 -1
- package/lib/connect/index.d.ts +12 -0
- package/lib/connect/index.d.ts.map +1 -0
- package/lib/connect/index.js +50 -0
- package/lib/connect/index.js.map +1 -0
- package/lib/date-picker/index.d.ts +6 -1
- package/lib/date-picker/index.d.ts.map +1 -1
- package/lib/date-picker/index.js +29 -3
- package/lib/date-picker/index.js.map +1 -1
- package/lib/ellipsis/index.js +1 -1
- package/lib/ellipsis/index.js.map +1 -1
- package/lib/ellipsis/index.less +1 -1
- package/lib/handle/index.d.ts.map +1 -1
- package/lib/handle/index.js +13 -4
- 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 +22 -0
- package/lib/index.js.map +1 -1
- package/lib/index.less +5 -0
- package/lib/input/input.d.ts +5 -0
- package/lib/input/input.d.ts.map +1 -1
- package/lib/input/input.js +18 -8
- package/lib/input/input.js.map +1 -1
- package/lib/input-number/index.d.ts +7 -2
- package/lib/input-number/index.d.ts.map +1 -1
- package/lib/input-number/index.js +4 -1
- package/lib/input-number/index.js.map +1 -1
- package/lib/label/label.d.ts +52 -0
- package/lib/label/label.d.ts.map +1 -0
- package/lib/label/label.js +150 -0
- package/lib/label/label.js.map +1 -0
- package/lib/label/label.test.d.ts +2 -0
- package/lib/label/label.test.d.ts.map +1 -0
- package/lib/label/label.test.js +14 -0
- package/lib/label/label.test.js.map +1 -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 +4 -2
- 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 +4 -2
- package/lib/locale/zh_CN.js.map +1 -1
- 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/preview-text/index.d.ts +20 -0
- package/lib/preview-text/index.d.ts.map +1 -0
- package/lib/preview-text/index.js +278 -0
- package/lib/preview-text/index.js.map +1 -0
- package/lib/preview-text/index.less +3 -0
- package/lib/query-form/Field/SelectInput.d.ts.map +1 -1
- package/lib/query-form/Field/SelectInput.js +6 -4
- package/lib/query-form/Field/SelectInput.js.map +1 -1
- package/lib/radio/index.d.ts.map +1 -1
- package/lib/radio/index.js +4 -0
- package/lib/radio/index.js.map +1 -1
- package/lib/radio/radio-group.d.ts +8 -0
- package/lib/radio/radio-group.d.ts.map +1 -0
- package/lib/radio/radio-group.js +13 -0
- package/lib/radio/radio-group.js.map +1 -0
- package/lib/segmented/index.d.ts +23 -0
- package/lib/segmented/index.d.ts.map +1 -0
- package/lib/segmented/index.js +80 -0
- package/lib/segmented/index.js.map +1 -0
- package/lib/segmented/index.less +138 -0
- package/lib/select/index.d.ts +2 -1
- package/lib/select/index.d.ts.map +1 -1
- package/lib/select/index.js.map +1 -1
- package/lib/select/select.d.ts +12 -0
- package/lib/select/select.d.ts.map +1 -1
- package/lib/select/select.js +25 -4
- package/lib/select/select.js.map +1 -1
- package/lib/svg-components/illustration-403.d.ts +1 -1
- package/lib/svg-components/illustration-404.d.ts +1 -1
- package/lib/svg-components/illustration-500.d.ts +1 -1
- package/lib/svg-components/illustration-empty.d.ts +1 -1
- package/lib/svg-components/illustration-failure.d.ts +1 -1
- package/lib/svg-components/illustration-no-access.d.ts +1 -1
- package/lib/svg-components/illustration-no-chart.d.ts +1 -1
- package/lib/svg-components/illustration-no-result.d.ts +1 -1
- package/lib/svg-components/illustration-offline.d.ts +1 -1
- package/lib/svg-components/illustration-success.d.ts +1 -1
- package/lib/switch/index.d.ts +2 -3
- package/lib/switch/index.d.ts.map +1 -1
- package/lib/switch/index.js +1 -2
- package/lib/switch/index.js.map +1 -1
- package/lib/switch/switch.d.ts +10 -0
- package/lib/switch/switch.d.ts.map +1 -0
- package/lib/switch/switch.js +37 -0
- package/lib/switch/switch.js.map +1 -0
- package/lib/table/assets/image-loading-background.d.ts +1 -1
- package/lib/table/assets/image-loading.d.ts +1 -1
- package/lib/table/table.d.ts.map +1 -1
- package/lib/table/table.js +14 -7
- package/lib/table/table.js.map +1 -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 +17 -0
- package/lib/table/total-shower.js.map +1 -0
- package/lib/time-picker/index.d.ts +7 -2
- package/lib/time-picker/index.d.ts.map +1 -1
- package/lib/time-picker/index.js +3 -1
- package/lib/time-picker/index.js.map +1 -1
- package/lib/title/index.d.ts +11 -1
- package/lib/title/index.d.ts.map +1 -1
- package/lib/title/index.js +8 -10
- package/lib/title/index.js.map +1 -1
- package/lib/title/index.less +10 -10
- package/lib/tntd-cascader/AntdCascader/config/utils.d.ts +1 -1
- package/lib/tntd-form/ErrorList.d.ts +13 -0
- package/lib/tntd-form/ErrorList.d.ts.map +1 -0
- package/lib/tntd-form/ErrorList.js +104 -0
- package/lib/tntd-form/ErrorList.js.map +1 -0
- package/lib/tntd-form/Form.d.ts +36 -0
- package/lib/tntd-form/Form.d.ts.map +1 -0
- package/lib/tntd-form/Form.js +160 -0
- package/lib/tntd-form/Form.js.map +1 -0
- package/lib/tntd-form/FormItem/ItemHolder.d.ts +18 -0
- package/lib/tntd-form/FormItem/ItemHolder.d.ts.map +1 -0
- package/lib/tntd-form/FormItem/ItemHolder.js +163 -0
- package/lib/tntd-form/FormItem/ItemHolder.js.map +1 -0
- package/lib/tntd-form/FormItem/index.d.ts +36 -0
- package/lib/tntd-form/FormItem/index.d.ts.map +1 -0
- package/lib/tntd-form/FormItem/index.js +301 -0
- package/lib/tntd-form/FormItem/index.js.map +1 -0
- package/lib/tntd-form/FormItemInput.d.ts +30 -0
- package/lib/tntd-form/FormItemInput.d.ts.map +1 -0
- package/lib/tntd-form/FormItemInput.js +92 -0
- package/lib/tntd-form/FormItemInput.js.map +1 -0
- package/lib/tntd-form/FormItemLabel.d.ts +24 -0
- package/lib/tntd-form/FormItemLabel.d.ts.map +1 -0
- package/lib/tntd-form/FormItemLabel.js +106 -0
- package/lib/tntd-form/FormItemLabel.js.map +1 -0
- package/lib/tntd-form/FormList.d.ts +26 -0
- package/lib/tntd-form/FormList.d.ts.map +1 -0
- package/lib/tntd-form/FormList.js +56 -0
- package/lib/tntd-form/FormList.js.map +1 -0
- package/lib/tntd-form/_util/motion.d.ts +9 -0
- package/lib/tntd-form/_util/motion.d.ts.map +1 -0
- package/lib/tntd-form/_util/motion.js +59 -0
- package/lib/tntd-form/_util/motion.js.map +1 -0
- package/lib/tntd-form/_util/reactNode.d.ts +9 -0
- package/lib/tntd-form/_util/reactNode.d.ts.map +1 -0
- package/lib/tntd-form/_util/reactNode.js +27 -0
- package/lib/tntd-form/_util/reactNode.js.map +1 -0
- package/lib/tntd-form/_util/scrollTo.d.ts +1 -0
- package/lib/tntd-form/_util/scrollTo.d.ts.map +1 -0
- package/lib/tntd-form/_util/scrollTo.js +35 -0
- package/lib/tntd-form/_util/scrollTo.js.map +1 -0
- package/lib/tntd-form/_util/type.d.ts +4 -0
- package/lib/tntd-form/_util/type.d.ts.map +1 -0
- package/lib/tntd-form/_util/type.js +21 -0
- package/lib/tntd-form/_util/type.js.map +1 -0
- package/lib/tntd-form/_util/warning.d.ts +5 -0
- package/lib/tntd-form/_util/warning.d.ts.map +1 -0
- package/lib/tntd-form/_util/warning.js +20 -0
- package/lib/tntd-form/_util/warning.js.map +1 -0
- package/lib/tntd-form/_util/wave.d.ts +1 -0
- package/lib/tntd-form/_util/wave.d.ts.map +1 -0
- package/lib/tntd-form/_util/wave.js +168 -0
- package/lib/tntd-form/_util/wave.js.map +1 -0
- package/lib/tntd-form/context.d.ts +51 -0
- package/lib/tntd-form/context.d.ts.map +1 -0
- package/lib/tntd-form/context.js +54 -0
- package/lib/tntd-form/context.js.map +1 -0
- package/lib/tntd-form/hooks/useDebounce.d.ts +2 -0
- package/lib/tntd-form/hooks/useDebounce.d.ts.map +1 -0
- package/lib/tntd-form/hooks/useDebounce.js +31 -0
- package/lib/tntd-form/hooks/useDebounce.js.map +1 -0
- package/lib/tntd-form/hooks/useForm.d.ts +16 -0
- package/lib/tntd-form/hooks/useForm.d.ts.map +1 -0
- package/lib/tntd-form/hooks/useForm.js +63 -0
- package/lib/tntd-form/hooks/useForm.js.map +1 -0
- package/lib/tntd-form/hooks/useFormInstance.d.ts +3 -0
- package/lib/tntd-form/hooks/useFormInstance.d.ts.map +1 -0
- package/lib/tntd-form/hooks/useFormInstance.js +13 -0
- package/lib/tntd-form/hooks/useFormInstance.js.map +1 -0
- package/lib/tntd-form/hooks/useFormItemStatus.d.ts +7 -0
- package/lib/tntd-form/hooks/useFormItemStatus.d.ts.map +1 -0
- package/lib/tntd-form/hooks/useFormItemStatus.js +20 -0
- package/lib/tntd-form/hooks/useFormItemStatus.js.map +1 -0
- package/lib/tntd-form/hooks/useFrameState.d.ts +4 -0
- package/lib/tntd-form/hooks/useFrameState.d.ts.map +1 -0
- package/lib/tntd-form/hooks/useFrameState.js +55 -0
- package/lib/tntd-form/hooks/useFrameState.js.map +1 -0
- package/lib/tntd-form/hooks/useItemRef.d.ts +4 -0
- package/lib/tntd-form/hooks/useItemRef.d.ts.map +1 -0
- package/lib/tntd-form/hooks/useItemRef.js +28 -0
- package/lib/tntd-form/hooks/useItemRef.js.map +1 -0
- package/lib/tntd-form/index.d.ts +23 -1
- package/lib/tntd-form/index.d.ts.map +1 -1
- package/lib/tntd-form/index.js +24 -8
- package/lib/tntd-form/index.js.map +1 -1
- package/lib/tntd-form/interface.d.ts +4 -0
- package/lib/tntd-form/interface.d.ts.map +1 -0
- package/lib/tntd-form/interface.js +7 -0
- package/lib/tntd-form/interface.js.map +1 -0
- package/lib/tntd-form/style/components.less +16 -0
- package/lib/tntd-form/style/horizontal.less +26 -0
- package/lib/tntd-form/style/index.d.ts +5 -0
- package/lib/tntd-form/style/index.d.ts.map +1 -0
- package/lib/tntd-form/style/index.js +6 -0
- package/lib/tntd-form/style/index.js.map +1 -0
- package/lib/tntd-form/style/index.less +342 -0
- package/lib/tntd-form/style/inline.less +40 -0
- package/lib/tntd-form/style/mixin.less +90 -0
- package/lib/tntd-form/style/rtl.less +204 -0
- package/lib/tntd-form/style/status.less +45 -0
- package/lib/tntd-form/style/vertical.less +95 -0
- package/lib/tntd-form/tntd-form.stories.d.ts +33 -0
- package/lib/tntd-form/tntd-form.stories.d.ts.map +1 -0
- package/lib/tntd-form/tntd-form.stories.js +888 -0
- package/lib/tntd-form/tntd-form.stories.js.map +1 -0
- package/lib/tntd-form/util.d.ts +4 -0
- package/lib/tntd-form/util.d.ts.map +1 -0
- package/lib/tntd-form/util.js +25 -0
- package/lib/tntd-form/util.js.map +1 -0
- package/lib/tntd-form/validateMessagesContext.d.ts +5 -0
- package/lib/tntd-form/validateMessagesContext.d.ts.map +1 -0
- package/lib/tntd-form/validateMessagesContext.js +12 -0
- package/lib/tntd-form/validateMessagesContext.js.map +1 -0
- 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 +76 -61
- 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 -1
- package/lib/tree-select/index.d.ts.map +1 -1
- package/lib/tree-select/index.js +9 -3
- package/lib/tree-select/index.js.map +1 -1
- package/lib/upload/index.d.ts +6 -1
- package/lib/upload/index.d.ts.map +1 -1
- package/lib/upload/index.js +11 -1
- package/lib/upload/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 +12 -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 +19 -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 +142 -0
- package/lib/water-mark/index.js.map +1 -0
- package/package.json +26 -5
- package/themes/default/variables.less +43 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
4
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
5
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
6
|
+
}
|
|
7
|
+
return t;
|
|
8
|
+
};
|
|
9
|
+
import Icon from '../icon';
|
|
10
|
+
import classNames from 'classnames';
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import Col from '../col';
|
|
13
|
+
import Tooltip from '../tooltip';
|
|
14
|
+
import { FormContext } from './context';
|
|
15
|
+
function toTooltipProps(tooltip) {
|
|
16
|
+
if (!tooltip) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
if (typeof tooltip === 'object' && !React.isValidElement(tooltip)) {
|
|
20
|
+
return tooltip;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
title: tooltip
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const FormItemLabel = ({
|
|
27
|
+
prefixCls,
|
|
28
|
+
label,
|
|
29
|
+
htmlFor,
|
|
30
|
+
labelCol,
|
|
31
|
+
labelAlign,
|
|
32
|
+
colon,
|
|
33
|
+
required,
|
|
34
|
+
requiredMark,
|
|
35
|
+
tooltip
|
|
36
|
+
}) => {
|
|
37
|
+
// const [formLocale] = useLocaleReceiver('Form');
|
|
38
|
+
if (!label) return null;
|
|
39
|
+
return React.createElement(FormContext.Consumer, {
|
|
40
|
+
key: "label"
|
|
41
|
+
}, ({
|
|
42
|
+
vertical,
|
|
43
|
+
labelAlign: contextLabelAlign,
|
|
44
|
+
labelCol: contextLabelCol,
|
|
45
|
+
labelWrap,
|
|
46
|
+
colon: contextColon
|
|
47
|
+
}) => {
|
|
48
|
+
const mergedLabelCol = labelCol || contextLabelCol || {};
|
|
49
|
+
const mergedLabelAlign = labelAlign || contextLabelAlign;
|
|
50
|
+
const labelClsBasic = `${prefixCls}-item-label`;
|
|
51
|
+
const labelColClassName = classNames(labelClsBasic, mergedLabelAlign === 'left' && `${labelClsBasic}-left`, mergedLabelCol.className, {
|
|
52
|
+
[`${labelClsBasic}-wrap`]: !!labelWrap
|
|
53
|
+
});
|
|
54
|
+
let labelChildren = label;
|
|
55
|
+
// Keep label is original where there should have no colon
|
|
56
|
+
const computedColon = colon === true || contextColon !== false && colon !== false;
|
|
57
|
+
const haveColon = computedColon && !vertical;
|
|
58
|
+
// Remove duplicated user input colon
|
|
59
|
+
if (haveColon && typeof label === 'string' && label.trim() !== '') {
|
|
60
|
+
labelChildren = label.replace(/[:|:]\s*$/, '');
|
|
61
|
+
}
|
|
62
|
+
// Tooltip
|
|
63
|
+
const tooltipProps = toTooltipProps(tooltip);
|
|
64
|
+
if (tooltipProps) {
|
|
65
|
+
const {
|
|
66
|
+
icon = React.createElement(Icon, {
|
|
67
|
+
type: "question-circle"
|
|
68
|
+
})
|
|
69
|
+
} = tooltipProps,
|
|
70
|
+
restTooltipProps = __rest(tooltipProps, ["icon"]);
|
|
71
|
+
const tooltipNode = React.createElement(Tooltip, Object.assign({}, restTooltipProps), React.cloneElement(icon, {
|
|
72
|
+
className: `${prefixCls}-item-tooltip`,
|
|
73
|
+
title: ''
|
|
74
|
+
}));
|
|
75
|
+
labelChildren = React.createElement(React.Fragment, null, labelChildren, tooltipNode);
|
|
76
|
+
}
|
|
77
|
+
// Add required mark if optional
|
|
78
|
+
if (requiredMark === 'optional' && !required) {
|
|
79
|
+
labelChildren = React.createElement(React.Fragment, null, labelChildren, React.createElement("span", {
|
|
80
|
+
className: `${prefixCls}-item-optional`,
|
|
81
|
+
title: ""
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
const labelClassName = classNames({
|
|
85
|
+
[`${prefixCls}-item-required`]: required,
|
|
86
|
+
[`${prefixCls}-item-required-mark-optional`]: requiredMark === 'optional',
|
|
87
|
+
[`${prefixCls}-item-no-colon`]: !computedColon
|
|
88
|
+
});
|
|
89
|
+
return React.createElement(Col, Object.assign({}, mergedLabelCol, {
|
|
90
|
+
className: labelColClassName
|
|
91
|
+
}), React.createElement("label", {
|
|
92
|
+
htmlFor: htmlFor,
|
|
93
|
+
className: labelClassName,
|
|
94
|
+
title: typeof label === 'string' ? label : ''
|
|
95
|
+
}, labelChildren));
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
export default FormItemLabel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormItemLabel.js","sourceRoot":"","sources":["../../src/tntd-form/FormItemLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,GAAG,MAAM,QAAQ,CAAA;AAIxB,OAAO,OAAO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AAC,GAAG,oBAAK,cAAc,IAAE,SAAS,EAAE,iBAAiB;YACnD,+BACE,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAE5C,aAAa,CACR,CACJ,CACP,CAAA;IACH,CAAC,CACoB,CACxB,CAAA;AACH,CAAC,CAAA;AAED,eAAe,aAAa,CAAA","sourcesContent":["import Icon from '../icon'\nimport classNames from 'classnames'\nimport * as React from 'react'\n// import type { ColProps } from '../grid/col';\n// import Col from '../grid/col';\nimport type { ColProps } from '../col'\nimport Col from '../col'\n// import { useLocaleReceiver } from '../locale-provider/LocaleReceiver';\n// import defaultLocale from '../locale/default';\nimport type { TooltipProps } from '../tooltip'\nimport Tooltip from '../tooltip'\nimport type { FormContextProps } from './context'\nimport { FormContext } from './context'\nimport type { RequiredMark } from './Form'\nimport type { FormLabelAlign } from './interface'\n\nexport type WrapperTooltipProps = TooltipProps & {\n icon?: React.ReactElement\n}\n\nexport type LabelTooltipType = WrapperTooltipProps | React.ReactNode\n\nfunction toTooltipProps(tooltip: LabelTooltipType): WrapperTooltipProps | null {\n if (!tooltip) {\n return null\n }\n\n if (typeof tooltip === 'object' && !React.isValidElement(tooltip)) {\n return tooltip as WrapperTooltipProps\n }\n\n return {\n title: tooltip,\n }\n}\n\nexport interface FormItemLabelProps {\n colon?: boolean\n htmlFor?: string\n label?: React.ReactNode\n labelAlign?: FormLabelAlign\n labelCol?: ColProps\n requiredMark?: RequiredMark\n tooltip?: LabelTooltipType\n}\n\nconst FormItemLabel: React.FC<FormItemLabelProps & { required?: boolean; prefixCls: string }> = ({\n prefixCls,\n label,\n htmlFor,\n labelCol,\n labelAlign,\n colon,\n required,\n requiredMark,\n tooltip,\n}) => {\n // const [formLocale] = useLocaleReceiver('Form');\n\n if (!label) return null\n\n return (\n <FormContext.Consumer key=\"label\">\n {({\n vertical,\n labelAlign: contextLabelAlign,\n labelCol: contextLabelCol,\n labelWrap,\n colon: contextColon,\n }: FormContextProps) => {\n const mergedLabelCol: ColProps = labelCol || contextLabelCol || {}\n\n const mergedLabelAlign: FormLabelAlign | undefined = labelAlign || contextLabelAlign\n\n const labelClsBasic = `${prefixCls}-item-label`\n const labelColClassName = classNames(\n labelClsBasic,\n mergedLabelAlign === 'left' && `${labelClsBasic}-left`,\n mergedLabelCol.className,\n {\n [`${labelClsBasic}-wrap`]: !!labelWrap,\n }\n )\n\n let labelChildren = label\n // Keep label is original where there should have no colon\n const computedColon = colon === true || (contextColon !== false && colon !== false)\n const haveColon = computedColon && !vertical\n // Remove duplicated user input colon\n if (haveColon && typeof label === 'string' && (label as string).trim() !== '') {\n labelChildren = (label as string).replace(/[:|:]\\s*$/, '')\n }\n\n // Tooltip\n const tooltipProps = toTooltipProps(tooltip)\n if (tooltipProps) {\n const { icon = <Icon type=\"question-circle\" />, ...restTooltipProps } = tooltipProps\n const tooltipNode = (\n <Tooltip {...restTooltipProps}>\n {React.cloneElement(icon, { className: `${prefixCls}-item-tooltip`, title: '' })}\n </Tooltip>\n )\n\n labelChildren = (\n <>\n {labelChildren}\n {tooltipNode}\n </>\n )\n }\n\n // Add required mark if optional\n if (requiredMark === 'optional' && !required) {\n labelChildren = (\n <>\n {labelChildren}\n <span className={`${prefixCls}-item-optional`} title=\"\">\n {/* {formLocale?.optional || defaultLocale.Form?.optional} */}\n </span>\n </>\n )\n }\n\n const labelClassName = classNames({\n [`${prefixCls}-item-required`]: required,\n [`${prefixCls}-item-required-mark-optional`]: requiredMark === 'optional',\n [`${prefixCls}-item-no-colon`]: !computedColon,\n })\n\n return (\n <Col {...mergedLabelCol} className={labelColClassName}>\n <label\n htmlFor={htmlFor}\n className={labelClassName}\n title={typeof label === 'string' ? label : ''}\n >\n {labelChildren}\n </label>\n </Col>\n )\n }}\n </FormContext.Consumer>\n )\n}\n\nexport default FormItemLabel\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
4
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
5
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
6
|
+
}
|
|
7
|
+
return t;
|
|
8
|
+
};
|
|
9
|
+
import { List } from 'rc-field-form';
|
|
10
|
+
import * as React from 'react';
|
|
11
|
+
import { ConfigContext } from '../config-provider';
|
|
12
|
+
import warning from './_util/warning';
|
|
13
|
+
import { FormItemPrefixContext } from './context';
|
|
14
|
+
const FormList = _a => {
|
|
15
|
+
var {
|
|
16
|
+
prefixCls: customizePrefixCls,
|
|
17
|
+
children
|
|
18
|
+
} = _a,
|
|
19
|
+
props = __rest(_a, ["prefixCls", "children"]);
|
|
20
|
+
warning(!!props.name, 'Form.List', 'Miss `name` prop.');
|
|
21
|
+
// TODO
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
const {
|
|
24
|
+
getPrefixCls
|
|
25
|
+
} = React.useContext(ConfigContext);
|
|
26
|
+
const prefixCls = getPrefixCls('form', customizePrefixCls);
|
|
27
|
+
const contextValue = React.useMemo(() => ({
|
|
28
|
+
prefixCls,
|
|
29
|
+
status: 'error'
|
|
30
|
+
}), [prefixCls]);
|
|
31
|
+
return React.createElement(List, Object.assign({}, props), (fields, operation, meta) => React.createElement(FormItemPrefixContext.Provider, {
|
|
32
|
+
value: contextValue
|
|
33
|
+
}, children(fields.map(field => Object.assign(Object.assign({}, field), {
|
|
34
|
+
fieldKey: field.key
|
|
35
|
+
})), operation, {
|
|
36
|
+
errors: meta.errors,
|
|
37
|
+
warnings: meta.warnings
|
|
38
|
+
})));
|
|
39
|
+
};
|
|
40
|
+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AM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;KACxB,CACF,CAC8B,CAClC,CACI,CACR,CAAA;AACH,CAAC,CAAA;AAED,eAAe,QAAQ,CAAA","sourcesContent":["import { List } from 'rc-field-form'\nimport type { StoreValue, ValidatorRule } from 'rc-field-form/lib/interface'\nimport * as React from 'react'\nimport { ConfigContext } from '../config-provider'\nimport warning from './_util/warning'\nimport { FormItemPrefixContext } from './context'\n\nexport interface FormListFieldData {\n name: number\n key: number\n /** @deprecated No need anymore Use key instead */\n fieldKey?: number\n}\n\nexport interface FormListOperation {\n add: (defaultValue?: StoreValue, insertIndex?: number) => void\n remove: (index: number | number[]) => void\n move: (from: number, to: number) => void\n}\n\nexport interface FormListProps {\n prefixCls?: string\n name: string | number | (string | number)[]\n rules?: ValidatorRule[]\n initialValue?: any[]\n children: (\n fields: FormListFieldData[],\n operation: FormListOperation,\n meta: { errors: React.ReactNode[]; warnings: React.ReactNode[] }\n ) => React.ReactNode\n}\n\nconst FormList: React.FC<FormListProps> = ({\n prefixCls: customizePrefixCls,\n children,\n ...props\n}) => {\n warning(!!props.name, 'Form.List', 'Miss `name` prop.')\n\n // TODO\n // @ts-ignore\n const { getPrefixCls } = React.useContext(ConfigContext)\n const prefixCls = getPrefixCls('form', customizePrefixCls)\n const contextValue = React.useMemo(\n () => ({\n prefixCls,\n status: 'error' as const,\n }),\n [prefixCls]\n )\n\n return (\n <List {...props}>\n {(fields, operation, meta) => (\n <FormItemPrefixContext.Provider value={contextValue}>\n {children(\n fields.map((field) => ({ ...field, fieldKey: field.key })),\n operation,\n {\n errors: meta.errors,\n warnings: meta.warnings,\n }\n )}\n </FormItemPrefixContext.Provider>\n )}\n </List>\n )\n}\n\nexport default FormList\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { tuple } from './type';
|
|
2
|
+
// ================== Collapse Motion ==================
|
|
3
|
+
const getCollapsedHeight = () => ({
|
|
4
|
+
height: 0,
|
|
5
|
+
opacity: 0
|
|
6
|
+
});
|
|
7
|
+
const getRealHeight = node => {
|
|
8
|
+
const {
|
|
9
|
+
scrollHeight
|
|
10
|
+
} = node;
|
|
11
|
+
return {
|
|
12
|
+
height: scrollHeight,
|
|
13
|
+
opacity: 1
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
const getCurrentHeight = node => ({
|
|
17
|
+
height: node ? node.offsetHeight : 0
|
|
18
|
+
});
|
|
19
|
+
const skipOpacityTransition = (_, event) => (event === null || event === void 0 ? void 0 : event.deadline) === true || event.propertyName === 'height';
|
|
20
|
+
const collapseMotion = {
|
|
21
|
+
motionName: 'ant-motion-collapse',
|
|
22
|
+
onAppearStart: getCollapsedHeight,
|
|
23
|
+
onEnterStart: getCollapsedHeight,
|
|
24
|
+
onAppearActive: getRealHeight,
|
|
25
|
+
onEnterActive: getRealHeight,
|
|
26
|
+
onLeaveStart: getCurrentHeight,
|
|
27
|
+
onLeaveActive: getCollapsedHeight,
|
|
28
|
+
onAppearEnd: skipOpacityTransition,
|
|
29
|
+
onEnterEnd: skipOpacityTransition,
|
|
30
|
+
onLeaveEnd: skipOpacityTransition,
|
|
31
|
+
motionDeadline: 500
|
|
32
|
+
};
|
|
33
|
+
const SelectPlacements = tuple('bottomLeft', 'bottomRight', 'topLeft', 'topRight');
|
|
34
|
+
const getTransitionDirection = placement => {
|
|
35
|
+
if (placement !== undefined && (placement === 'topLeft' || placement === 'topRight')) {
|
|
36
|
+
return `slide-down`;
|
|
37
|
+
}
|
|
38
|
+
return `slide-up`;
|
|
39
|
+
};
|
|
40
|
+
const getTransitionName = (rootPrefixCls, motion, transitionName) => {
|
|
41
|
+
if (transitionName !== undefined) {
|
|
42
|
+
return transitionName;
|
|
43
|
+
}
|
|
44
|
+
return `${rootPrefixCls}-${motion}`;
|
|
45
|
+
};
|
|
46
|
+
export { getTransitionName, getTransitionDirection };
|
|
47
|
+
export default collapseMotion;
|
|
@@ -0,0 +1 @@
|
|
|
1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B,GAAG,CAAC,SAA4C,EAAE,EAAE;IAC9E,IAAI,SAAS,KAAK,SAAS,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,UAAU,CAAC,EAAE;QACpF,OAAO,YAAY,CAAA;KACpB;IACD,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAG,CAAC,aAAqB,EAAE,MAAc,EAAE,cAAuB,EAAE,EAAE;IAC3F,IAAI,cAAc,KAAK,SAAS,EAAE;QAChC,OAAO,cAAc,CAAA;KACtB;IACD,OAAO,GAAG,aAAa,IAAI,MAAM,EAAE,CAAA;AACrC,CAAC,CAAA;AACD,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,CAAA;AACpD,eAAe,cAAc,CAAA","sourcesContent":["import type { CSSMotionProps, MotionEndEventHandler, MotionEventHandler } from 'rc-motion'\nimport type { MotionEvent } from 'rc-motion/lib/interface'\nimport { tuple } from './type'\n\n// ================== Collapse Motion ==================\nconst getCollapsedHeight: MotionEventHandler = () => ({ height: 0, opacity: 0 })\nconst getRealHeight: MotionEventHandler = (node) => {\n const { scrollHeight } = node\n return { height: scrollHeight, opacity: 1 }\n}\nconst getCurrentHeight: MotionEventHandler = (node) => ({ height: node ? node.offsetHeight : 0 })\nconst skipOpacityTransition: MotionEndEventHandler = (_, event: MotionEvent) =>\n event?.deadline === true || (event as TransitionEvent).propertyName === 'height'\n\nconst collapseMotion: CSSMotionProps = {\n motionName: 'ant-motion-collapse',\n onAppearStart: getCollapsedHeight,\n onEnterStart: getCollapsedHeight,\n onAppearActive: getRealHeight,\n onEnterActive: getRealHeight,\n onLeaveStart: getCurrentHeight,\n onLeaveActive: getCollapsedHeight,\n onAppearEnd: skipOpacityTransition,\n onEnterEnd: skipOpacityTransition,\n onLeaveEnd: skipOpacityTransition,\n motionDeadline: 500,\n}\n\nconst SelectPlacements = tuple('bottomLeft', 'bottomRight', 'topLeft', 'topRight')\nexport type SelectCommonPlacement = typeof SelectPlacements[number]\n\nconst getTransitionDirection = (placement: SelectCommonPlacement | undefined) => {\n if (placement !== undefined && (placement === 'topLeft' || placement === 'topRight')) {\n return `slide-down`\n }\n return `slide-up`\n}\n\nconst getTransitionName = (rootPrefixCls: string, motion: string, transitionName?: string) => {\n if (transitionName !== undefined) {\n return transitionName\n }\n return `${rootPrefixCls}-${motion}`\n}\nexport { getTransitionName, getTransitionDirection }\nexport default collapseMotion\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export const {
|
|
3
|
+
isValidElement
|
|
4
|
+
} = React;
|
|
5
|
+
export function isFragment(child) {
|
|
6
|
+
return child && isValidElement(child) && child.type === React.Fragment;
|
|
7
|
+
}
|
|
8
|
+
export function replaceElement(element, replacement, props) {
|
|
9
|
+
if (!isValidElement(element)) {
|
|
10
|
+
return replacement;
|
|
11
|
+
}
|
|
12
|
+
return React.cloneElement(element, typeof props === 'function' ? props(element.props || {}) : props);
|
|
13
|
+
}
|
|
14
|
+
export function cloneElement(element, props) {
|
|
15
|
+
return replaceElement(element, element, props);
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactNode.js","sourceRoot":"","sources":["../../../src/tntd-form/_util/reactNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,KAAK,CAAA;AAEvC,MAAM,UAAU,UAAU,CAAC,KAAU;IACnC,OAAO,KAAK,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,QAAQ,CAAA;AACxE,CAAC;AAMD,MAAM,UAAU,cAAc,CAC5B,OAAwB,EACxB,WAA4B,EAC5B,KAAmB;IAEnB,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;QAC5B,OAAO,WAAW,CAAA;KACnB;IACD,OAAO,KAAK,CAAC,YAAY,CACvB,OAAO,EACP,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CACjE,CAAA;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAwB,EAAE,KAAmB;IACxE,OAAO,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAuB,CAAA;AACtE,CAAC","sourcesContent":["import * as React from 'react'\n\nexport const { isValidElement } = React\n\nexport function isFragment(child: any): boolean {\n return child && isValidElement(child) && child.type === React.Fragment\n}\n\ntype AnyObject = Record<PropertyKey, any>\n\ntype RenderProps = AnyObject | ((originProps: AnyObject) => AnyObject | void)\n\nexport function replaceElement(\n element: React.ReactNode,\n replacement: React.ReactNode,\n props?: RenderProps\n): React.ReactNode {\n if (!isValidElement(element)) {\n return replacement\n }\n return React.cloneElement(\n element,\n typeof props === 'function' ? props(element.props || {}) : props\n )\n}\n\nexport function cloneElement(element: React.ReactNode, props?: RenderProps): React.ReactElement {\n return replaceElement(element, element, props) as React.ReactElement\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// import raf from 'raf';
|
|
4
|
+
// import getScroll from './getScroll';
|
|
5
|
+
// import { easeInOutCubic } from './easings';
|
|
6
|
+
// interface ScrollToOptions {
|
|
7
|
+
// /** Scroll container, default as window */
|
|
8
|
+
// getContainer?: () => HTMLElement | Window;
|
|
9
|
+
// /** Scroll end callback */
|
|
10
|
+
// callback?: () => any;
|
|
11
|
+
// /** Animation duration, default as 450 */
|
|
12
|
+
// duration?: number;
|
|
13
|
+
// }
|
|
14
|
+
// export default function scrollTo(y: number, options: ScrollToOptions = {}) {
|
|
15
|
+
// const { getContainer = () => window, callback, duration = 450 } = options;
|
|
16
|
+
// const container = getContainer();
|
|
17
|
+
// const scrollTop = getScroll(container, true);
|
|
18
|
+
// const startTime = Date.now();
|
|
19
|
+
// const frameFunc = () => {
|
|
20
|
+
// const timestamp = Date.now();
|
|
21
|
+
// const time = timestamp - startTime;
|
|
22
|
+
// const nextScrollTop = easeInOutCubic(time > duration ? duration : time, scrollTop, y, duration);
|
|
23
|
+
// if (container === window) {
|
|
24
|
+
// window.scrollTo(window.pageXOffset, nextScrollTop);
|
|
25
|
+
// } else {
|
|
26
|
+
// (container as HTMLElement).scrollTop = nextScrollTop;
|
|
27
|
+
// }
|
|
28
|
+
// if (time < duration) {
|
|
29
|
+
// raf(frameFunc);
|
|
30
|
+
// } else if (typeof callback === 'function') {
|
|
31
|
+
// callback();
|
|
32
|
+
// }
|
|
33
|
+
// };
|
|
34
|
+
// raf(frameFunc);
|
|
35
|
+
// }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollTo.js","sourceRoot":"","sources":["../../../src/tntd-form/_util/scrollTo.ts"],"names":[],"mappings":";AAAA,yBAAyB;AACzB,uCAAuC;AACvC,8CAA8C;AAE9C,8BAA8B;AAC9B,+CAA+C;AAC/C,+CAA+C;AAC/C,+BAA+B;AAC/B,0BAA0B;AAC1B,8CAA8C;AAC9C,uBAAuB;AACvB,IAAI;AAEJ,+EAA+E;AAC/E,+EAA+E;AAE/E,sCAAsC;AACtC,kDAAkD;AAClD,kCAAkC;AAElC,8BAA8B;AAC9B,oCAAoC;AACpC,0CAA0C;AAC1C,uGAAuG;AACvG,kCAAkC;AAClC,4DAA4D;AAC5D,eAAe;AACf,8DAA8D;AAC9D,QAAQ;AACR,6BAA6B;AAC7B,wBAAwB;AACxB,mDAAmD;AACnD,oBAAoB;AACpB,QAAQ;AACR,OAAO;AACP,oBAAoB;AACpB,IAAI","sourcesContent":["// import raf from 'raf';\n// import getScroll from './getScroll';\n// import { easeInOutCubic } from './easings';\n\n// interface ScrollToOptions {\n// /** Scroll container, default as window */\n// getContainer?: () => HTMLElement | Window;\n// /** Scroll end callback */\n// callback?: () => any;\n// /** Animation duration, default as 450 */\n// duration?: number;\n// }\n\n// export default function scrollTo(y: number, options: ScrollToOptions = {}) {\n// const { getContainer = () => window, callback, duration = 450 } = options;\n\n// const container = getContainer();\n// const scrollTop = getScroll(container, true);\n// const startTime = Date.now();\n\n// const frameFunc = () => {\n// const timestamp = Date.now();\n// const time = timestamp - startTime;\n// const nextScrollTop = easeInOutCubic(time > duration ? duration : time, scrollTop, y, duration);\n// if (container === window) {\n// window.scrollTo(window.pageXOffset, nextScrollTop);\n// } else {\n// (container as HTMLElement).scrollTop = nextScrollTop;\n// }\n// if (time < duration) {\n// raf(frameFunc);\n// } else if (typeof callback === 'function') {\n// callback();\n// }\n// };\n// raf(frameFunc);\n// }\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../../src/tntd-form/_util/type.ts"],"names":[],"mappings":"AACA,qHAAqH;AACrH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAqB,GAAG,IAAO,EAAE,EAAE,CAAC,IAAI,CAAA;AAE7D,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAqB,GAAG,IAAO,EAAE,EAAE,CAAC,IAAI,CAAA","sourcesContent":["export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>\n// https://stackoverflow.com/questions/46176165/ways-to-get-string-literal-type-of-array-values-without-enum-overhead\nexport const tuple = <T extends string[]>(...args: T) => args\n\nexport const tupleNum = <T extends number[]>(...args: T) => args\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warning.js","sourceRoot":"","sources":["../../../src/tntd-form/_util/warning.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,EAAE,WAAW,EAAE,CAAA;AAEtB,eAAe,CAAC,KAAc,EAAE,SAAiB,EAAE,OAAe,EAAQ,EAAE;IAC1E,OAAO,CAAC,KAAK,EAAE,UAAU,SAAS,KAAK,OAAO,EAAE,CAAC,CAAA;AACnD,CAAC,CAAA","sourcesContent":["import warning, { resetWarned } from 'rc-util/lib/warning'\n\nexport { resetWarned }\n\nexport default (valid: boolean, component: string, message: string): void => {\n warning(valid, `[antd: ${component}] ${message}`)\n}\n"]}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// import * as React from 'react'
|
|
4
|
+
// import { findDOMNode } from 'react-dom'
|
|
5
|
+
// import TransitionEvents from 'css-animation/lib/Event'
|
|
6
|
+
// import raf from './raf'
|
|
7
|
+
// import { ConfigConsumer, ConfigConsumerProps, CSPConfig } from '../../config-provider'
|
|
8
|
+
// let styleForPesudo: HTMLStyleElement | null
|
|
9
|
+
// // Where el is the DOM element you'd like to test for visibility
|
|
10
|
+
// function isHidden(element: HTMLElement) {
|
|
11
|
+
// if (process.env.NODE_ENV === 'test') {
|
|
12
|
+
// return false
|
|
13
|
+
// }
|
|
14
|
+
// return !element || element.offsetParent === null
|
|
15
|
+
// }
|
|
16
|
+
// function isNotGrey(color: string) {
|
|
17
|
+
// // eslint-disable-next-line no-useless-escape
|
|
18
|
+
// const match = (color || '').match(/rgba?\((\d*), (\d*), (\d*)(, [\.\d]*)?\)/)
|
|
19
|
+
// if (match && match[1] && match[2] && match[3]) {
|
|
20
|
+
// return !(match[1] === match[2] && match[2] === match[3])
|
|
21
|
+
// }
|
|
22
|
+
// return true
|
|
23
|
+
// }
|
|
24
|
+
// export default class Wave extends React.Component<{ insertExtraNode?: boolean }> {
|
|
25
|
+
// private instance?: {
|
|
26
|
+
// cancel: () => void
|
|
27
|
+
// }
|
|
28
|
+
// private extraNode: HTMLDivElement
|
|
29
|
+
// private clickWaveTimeoutId: number
|
|
30
|
+
// private animationStartId: number
|
|
31
|
+
// private animationStart: boolean = false
|
|
32
|
+
// private destroy: boolean = false
|
|
33
|
+
// private csp?: CSPConfig
|
|
34
|
+
// componentDidMount() {
|
|
35
|
+
// const node = findDOMNode(this) as HTMLElement
|
|
36
|
+
// if (!node || node.nodeType !== 1) {
|
|
37
|
+
// return
|
|
38
|
+
// }
|
|
39
|
+
// this.instance = this.bindAnimationEvent(node)
|
|
40
|
+
// }
|
|
41
|
+
// componentWillUnmount() {
|
|
42
|
+
// if (this.instance) {
|
|
43
|
+
// this.instance.cancel()
|
|
44
|
+
// }
|
|
45
|
+
// if (this.clickWaveTimeoutId) {
|
|
46
|
+
// clearTimeout(this.clickWaveTimeoutId)
|
|
47
|
+
// }
|
|
48
|
+
// this.destroy = true
|
|
49
|
+
// }
|
|
50
|
+
// onClick = (node: HTMLElement, waveColor: string) => {
|
|
51
|
+
// if (!node || isHidden(node) || node.className.indexOf('-leave') >= 0) {
|
|
52
|
+
// return
|
|
53
|
+
// }
|
|
54
|
+
// const { insertExtraNode } = this.props
|
|
55
|
+
// this.extraNode = document.createElement('div')
|
|
56
|
+
// const { extraNode } = this
|
|
57
|
+
// extraNode.className = 'ant-click-animating-node'
|
|
58
|
+
// const attributeName = this.getAttributeName()
|
|
59
|
+
// node.setAttribute(attributeName, 'true')
|
|
60
|
+
// // Not white or transparnt or grey
|
|
61
|
+
// styleForPesudo = styleForPesudo || document.createElement('style')
|
|
62
|
+
// if (
|
|
63
|
+
// waveColor &&
|
|
64
|
+
// waveColor !== '#ffffff' &&
|
|
65
|
+
// waveColor !== 'rgb(255, 255, 255)' &&
|
|
66
|
+
// isNotGrey(waveColor) &&
|
|
67
|
+
// !/rgba\(\d*, \d*, \d*, 0\)/.test(waveColor) && // any transparent rgba color
|
|
68
|
+
// waveColor !== 'transparent'
|
|
69
|
+
// ) {
|
|
70
|
+
// // Add nonce if CSP exist
|
|
71
|
+
// if (this.csp && this.csp.nonce) {
|
|
72
|
+
// styleForPesudo.nonce = this.csp.nonce
|
|
73
|
+
// }
|
|
74
|
+
// extraNode.style.borderColor = waveColor
|
|
75
|
+
// styleForPesudo.innerHTML = `
|
|
76
|
+
// [ant-click-animating-without-extra-node='true']::after, .ant-click-animating-node {
|
|
77
|
+
// --antd-wave-shadow-color: ${waveColor};
|
|
78
|
+
// }`
|
|
79
|
+
// if (!document.body.contains(styleForPesudo)) {
|
|
80
|
+
// document.body.appendChild(styleForPesudo)
|
|
81
|
+
// }
|
|
82
|
+
// }
|
|
83
|
+
// if (insertExtraNode) {
|
|
84
|
+
// node.appendChild(extraNode)
|
|
85
|
+
// }
|
|
86
|
+
// TransitionEvents.addStartEventListener(node, this.onTransitionStart)
|
|
87
|
+
// TransitionEvents.addEndEventListener(node, this.onTransitionEnd)
|
|
88
|
+
// }
|
|
89
|
+
// onTransitionStart = (e: AnimationEvent) => {
|
|
90
|
+
// if (this.destroy) return
|
|
91
|
+
// const node = findDOMNode(this) as HTMLElement
|
|
92
|
+
// if (!e || e.target !== node) {
|
|
93
|
+
// return
|
|
94
|
+
// }
|
|
95
|
+
// if (!this.animationStart) {
|
|
96
|
+
// this.resetEffect(node)
|
|
97
|
+
// }
|
|
98
|
+
// }
|
|
99
|
+
// onTransitionEnd = (e: AnimationEvent) => {
|
|
100
|
+
// if (!e || e.animationName !== 'fadeEffect') {
|
|
101
|
+
// return
|
|
102
|
+
// }
|
|
103
|
+
// this.resetEffect(e.target as HTMLElement)
|
|
104
|
+
// }
|
|
105
|
+
// getAttributeName() {
|
|
106
|
+
// const { insertExtraNode } = this.props
|
|
107
|
+
// return insertExtraNode ? 'ant-click-animating' : 'ant-click-animating-without-extra-node'
|
|
108
|
+
// }
|
|
109
|
+
// bindAnimationEvent = (node: HTMLElement) => {
|
|
110
|
+
// if (
|
|
111
|
+
// !node ||
|
|
112
|
+
// !node.getAttribute ||
|
|
113
|
+
// node.getAttribute('disabled') ||
|
|
114
|
+
// node.className.indexOf('disabled') >= 0
|
|
115
|
+
// ) {
|
|
116
|
+
// return
|
|
117
|
+
// }
|
|
118
|
+
// const onClick = (e: MouseEvent) => {
|
|
119
|
+
// // Fix radio button click twice
|
|
120
|
+
// if ((e.target as HTMLElement).tagName === 'INPUT' || isHidden(e.target as HTMLElement)) {
|
|
121
|
+
// return
|
|
122
|
+
// }
|
|
123
|
+
// this.resetEffect(node)
|
|
124
|
+
// // Get wave color from target
|
|
125
|
+
// const waveColor =
|
|
126
|
+
// getComputedStyle(node).getPropertyValue('border-top-color') || // Firefox Compatible
|
|
127
|
+
// getComputedStyle(node).getPropertyValue('border-color') ||
|
|
128
|
+
// getComputedStyle(node).getPropertyValue('background-color')
|
|
129
|
+
// this.clickWaveTimeoutId = window.setTimeout(() => this.onClick(node, waveColor), 0)
|
|
130
|
+
// raf.cancel(this.animationStartId)
|
|
131
|
+
// this.animationStart = true
|
|
132
|
+
// // Render to trigger transition event cost 3 frames. Let's delay 10 frames to reset this.
|
|
133
|
+
// this.animationStartId = raf(() => {
|
|
134
|
+
// this.animationStart = false
|
|
135
|
+
// }, 10)
|
|
136
|
+
// }
|
|
137
|
+
// node.addEventListener('click', onClick, true)
|
|
138
|
+
// return {
|
|
139
|
+
// cancel: () => {
|
|
140
|
+
// node.removeEventListener('click', onClick, true)
|
|
141
|
+
// },
|
|
142
|
+
// }
|
|
143
|
+
// }
|
|
144
|
+
// resetEffect(node: HTMLElement) {
|
|
145
|
+
// if (!node || node === this.extraNode || !(node instanceof Element)) {
|
|
146
|
+
// return
|
|
147
|
+
// }
|
|
148
|
+
// const { insertExtraNode } = this.props
|
|
149
|
+
// const attributeName = this.getAttributeName()
|
|
150
|
+
// node.setAttribute(attributeName, 'false') // edge has bug on `removeAttribute` #14466
|
|
151
|
+
// if (styleForPesudo) {
|
|
152
|
+
// styleForPesudo.innerHTML = ''
|
|
153
|
+
// }
|
|
154
|
+
// if (insertExtraNode && this.extraNode && node.contains(this.extraNode)) {
|
|
155
|
+
// node.removeChild(this.extraNode)
|
|
156
|
+
// }
|
|
157
|
+
// TransitionEvents.removeStartEventListener(node, this.onTransitionStart)
|
|
158
|
+
// TransitionEvents.removeEndEventListener(node, this.onTransitionEnd)
|
|
159
|
+
// }
|
|
160
|
+
// renderWave = ({ csp }: ConfigConsumerProps) => {
|
|
161
|
+
// const { children } = this.props
|
|
162
|
+
// this.csp = csp
|
|
163
|
+
// return children
|
|
164
|
+
// }
|
|
165
|
+
// render() {
|
|
166
|
+
// return <ConfigConsumer>{this.renderWave}</ConfigConsumer>
|
|
167
|
+
// }
|
|
168
|
+
// }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wave.js","sourceRoot":"","sources":["../../../src/tntd-form/_util/wave.tsx"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,0CAA0C;AAC1C,yDAAyD;AACzD,0BAA0B;AAC1B,yFAAyF;AAEzF,8CAA8C;AAE9C,mEAAmE;AACnE,4CAA4C;AAC5C,2CAA2C;AAC3C,mBAAmB;AACnB,MAAM;AACN,qDAAqD;AACrD,IAAI;AAEJ,sCAAsC;AACtC,kDAAkD;AAClD,kFAAkF;AAClF,qDAAqD;AACrD,+DAA+D;AAC/D,MAAM;AACN,gBAAgB;AAChB,IAAI;AAEJ,qFAAqF;AACrF,yBAAyB;AACzB,yBAAyB;AACzB,MAAM;AAEN,sCAAsC;AAEtC,uCAAuC;AAEvC,qCAAqC;AAErC,4CAA4C;AAE5C,qCAAqC;AAErC,4BAA4B;AAE5B,0BAA0B;AAC1B,oDAAoD;AACpD,0CAA0C;AAC1C,eAAe;AACf,QAAQ;AACR,oDAAoD;AACpD,MAAM;AAEN,6BAA6B;AAC7B,2BAA2B;AAC3B,+BAA+B;AAC/B,QAAQ;AACR,qCAAqC;AACrC,8CAA8C;AAC9C,QAAQ;AAER,0BAA0B;AAC1B,MAAM;AAEN,0DAA0D;AAC1D,8EAA8E;AAC9E,eAAe;AACf,QAAQ;AACR,6CAA6C;AAC7C,qDAAqD;AACrD,iCAAiC;AACjC,uDAAuD;AACvD,oDAAoD;AACpD,+CAA+C;AAC/C,yCAAyC;AACzC,yEAAyE;AACzE,WAAW;AACX,qBAAqB;AACrB,mCAAmC;AACnC,8CAA8C;AAC9C,gCAAgC;AAChC,qFAAqF;AACrF,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AAC9E,0EAA0E;AAC1E,MAAM;AAEN,qDAAqD;AACrD,sCAAsC;AACtC,qBAAqB;AAErB,sBAAsB;AACtB,MAAM;AAEN,eAAe;AACf,gEAAgE;AAChE,MAAM;AACN,IAAI","sourcesContent":["// import * as React from 'react'\n// import { findDOMNode } from 'react-dom'\n// import TransitionEvents from 'css-animation/lib/Event'\n// import raf from './raf'\n// import { ConfigConsumer, ConfigConsumerProps, CSPConfig } from '../../config-provider'\n\n// let styleForPesudo: HTMLStyleElement | null\n\n// // Where el is the DOM element you'd like to test for visibility\n// function isHidden(element: HTMLElement) {\n// if (process.env.NODE_ENV === 'test') {\n// return false\n// }\n// return !element || element.offsetParent === null\n// }\n\n// function isNotGrey(color: string) {\n// // eslint-disable-next-line no-useless-escape\n// const match = (color || '').match(/rgba?\\((\\d*), (\\d*), (\\d*)(, [\\.\\d]*)?\\)/)\n// if (match && match[1] && match[2] && match[3]) {\n// return !(match[1] === match[2] && match[2] === match[3])\n// }\n// return true\n// }\n\n// export default class Wave extends React.Component<{ insertExtraNode?: boolean }> {\n// private instance?: {\n// cancel: () => void\n// }\n\n// private extraNode: HTMLDivElement\n\n// private clickWaveTimeoutId: number\n\n// private animationStartId: number\n\n// private animationStart: boolean = false\n\n// private destroy: boolean = false\n\n// private csp?: CSPConfig\n\n// componentDidMount() {\n// const node = findDOMNode(this) as HTMLElement\n// if (!node || node.nodeType !== 1) {\n// return\n// }\n// this.instance = this.bindAnimationEvent(node)\n// }\n\n// componentWillUnmount() {\n// if (this.instance) {\n// this.instance.cancel()\n// }\n// if (this.clickWaveTimeoutId) {\n// clearTimeout(this.clickWaveTimeoutId)\n// }\n\n// this.destroy = true\n// }\n\n// onClick = (node: HTMLElement, waveColor: string) => {\n// if (!node || isHidden(node) || node.className.indexOf('-leave') >= 0) {\n// return\n// }\n// const { insertExtraNode } = this.props\n// this.extraNode = document.createElement('div')\n// const { extraNode } = this\n// extraNode.className = 'ant-click-animating-node'\n// const attributeName = this.getAttributeName()\n// node.setAttribute(attributeName, 'true')\n// // Not white or transparnt or grey\n// styleForPesudo = styleForPesudo || document.createElement('style')\n// if (\n// waveColor &&\n// waveColor !== '#ffffff' &&\n// waveColor !== 'rgb(255, 255, 255)' &&\n// isNotGrey(waveColor) &&\n// !/rgba\\(\\d*, \\d*, \\d*, 0\\)/.test(waveColor) && // any transparent rgba color\n// waveColor !== 'transparent'\n// ) {\n// // Add nonce if CSP exist\n// if (this.csp && this.csp.nonce) {\n// styleForPesudo.nonce = this.csp.nonce\n// }\n\n// extraNode.style.borderColor = waveColor\n// styleForPesudo.innerHTML = `\n// [ant-click-animating-without-extra-node='true']::after, .ant-click-animating-node {\n// --antd-wave-shadow-color: ${waveColor};\n// }`\n// if (!document.body.contains(styleForPesudo)) {\n// document.body.appendChild(styleForPesudo)\n// }\n// }\n// if (insertExtraNode) {\n// node.appendChild(extraNode)\n// }\n// TransitionEvents.addStartEventListener(node, this.onTransitionStart)\n// TransitionEvents.addEndEventListener(node, this.onTransitionEnd)\n// }\n\n// onTransitionStart = (e: AnimationEvent) => {\n// if (this.destroy) return\n\n// const node = findDOMNode(this) as HTMLElement\n// if (!e || e.target !== node) {\n// return\n// }\n\n// if (!this.animationStart) {\n// this.resetEffect(node)\n// }\n// }\n\n// onTransitionEnd = (e: AnimationEvent) => {\n// if (!e || e.animationName !== 'fadeEffect') {\n// return\n// }\n// this.resetEffect(e.target as HTMLElement)\n// }\n\n// getAttributeName() {\n// const { insertExtraNode } = this.props\n// return insertExtraNode ? 'ant-click-animating' : 'ant-click-animating-without-extra-node'\n// }\n\n// bindAnimationEvent = (node: HTMLElement) => {\n// if (\n// !node ||\n// !node.getAttribute ||\n// node.getAttribute('disabled') ||\n// node.className.indexOf('disabled') >= 0\n// ) {\n// return\n// }\n// const onClick = (e: MouseEvent) => {\n// // Fix radio button click twice\n// if ((e.target as HTMLElement).tagName === 'INPUT' || isHidden(e.target as HTMLElement)) {\n// return\n// }\n// this.resetEffect(node)\n// // Get wave color from target\n// const waveColor =\n// getComputedStyle(node).getPropertyValue('border-top-color') || // Firefox Compatible\n// getComputedStyle(node).getPropertyValue('border-color') ||\n// getComputedStyle(node).getPropertyValue('background-color')\n// this.clickWaveTimeoutId = window.setTimeout(() => this.onClick(node, waveColor), 0)\n\n// raf.cancel(this.animationStartId)\n// this.animationStart = true\n\n// // Render to trigger transition event cost 3 frames. Let's delay 10 frames to reset this.\n// this.animationStartId = raf(() => {\n// this.animationStart = false\n// }, 10)\n// }\n// node.addEventListener('click', onClick, true)\n// return {\n// cancel: () => {\n// node.removeEventListener('click', onClick, true)\n// },\n// }\n// }\n\n// resetEffect(node: HTMLElement) {\n// if (!node || node === this.extraNode || !(node instanceof Element)) {\n// return\n// }\n// const { insertExtraNode } = this.props\n// const attributeName = this.getAttributeName()\n// node.setAttribute(attributeName, 'false') // edge has bug on `removeAttribute` #14466\n\n// if (styleForPesudo) {\n// styleForPesudo.innerHTML = ''\n// }\n\n// if (insertExtraNode && this.extraNode && node.contains(this.extraNode)) {\n// node.removeChild(this.extraNode)\n// }\n// TransitionEvents.removeStartEventListener(node, this.onTransitionStart)\n// TransitionEvents.removeEndEventListener(node, this.onTransitionEnd)\n// }\n\n// renderWave = ({ csp }: ConfigConsumerProps) => {\n// const { children } = this.props\n// this.csp = csp\n\n// return children\n// }\n\n// render() {\n// return <ConfigConsumer>{this.renderWave}</ConfigConsumer>\n// }\n// }\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FormProvider as RcFormProvider } from 'rc-field-form';
|
|
2
|
+
import omit from 'rc-util/lib/omit';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useContext, useMemo } from 'react';
|
|
5
|
+
export const FormContext = React.createContext({
|
|
6
|
+
labelAlign: 'right',
|
|
7
|
+
vertical: false,
|
|
8
|
+
itemRef: () => {}
|
|
9
|
+
});
|
|
10
|
+
export const NoStyleItemContext = React.createContext(null);
|
|
11
|
+
export const FormProvider = props => {
|
|
12
|
+
const providerProps = omit(props, ['prefixCls']);
|
|
13
|
+
return React.createElement(RcFormProvider, Object.assign({}, providerProps));
|
|
14
|
+
};
|
|
15
|
+
export const FormItemPrefixContext = React.createContext({
|
|
16
|
+
prefixCls: ''
|
|
17
|
+
});
|
|
18
|
+
export const FormItemInputContext = React.createContext({});
|
|
19
|
+
export const NoFormStyle = ({
|
|
20
|
+
children,
|
|
21
|
+
status,
|
|
22
|
+
override
|
|
23
|
+
}) => {
|
|
24
|
+
const formItemInputContext = useContext(FormItemInputContext);
|
|
25
|
+
const newFormItemInputContext = useMemo(() => {
|
|
26
|
+
const newContext = Object.assign({}, formItemInputContext);
|
|
27
|
+
if (override) {
|
|
28
|
+
delete newContext.isFormItemInput;
|
|
29
|
+
}
|
|
30
|
+
if (status) {
|
|
31
|
+
delete newContext.status;
|
|
32
|
+
delete newContext.hasFeedback;
|
|
33
|
+
delete newContext.feedbackIcon;
|
|
34
|
+
}
|
|
35
|
+
return newContext;
|
|
36
|
+
}, [status, override, formItemInputContext]);
|
|
37
|
+
return React.createElement(FormItemInputContext.Provider, {
|
|
38
|
+
value: newFormItemInputContext
|
|
39
|
+
}, children);
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/tntd-form/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,cAAc,EAAE,MAAM,eAAe,CAAA;AAG9D,OAAO,IAAI,MAAM,kBAAkB,CAAA;AAEnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAsB3C,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAmB;IAC/D,UAAU,EAAE,OAAO;IACnB,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,CAAC,GAAG,EAAE,GAAE,CAAC,CAAQ;CAC3B,CAAC,CAAA;AAIF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,aAAa,CAA0B,IAAI,CAAC,CAAA;AAOpF,MAAM,CAAC,MAAM,YAAY,GAAgC,CAAC,KAAK,EAAE,EAAE;IACjE,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;IAChD,OAAO,oBAAC,cAAc,oBAAK,aAAa,EAAI,CAAA;AAC9C,CAAC,CAAA;AAQD,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC,aAAa,CAA6B;IACnF,SAAS,EAAE,EAAE;CACd,CAAC,CAAA;AASF,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC,aAAa,CAA6B,EAAE,CAAC,CAAA;AAOvF,MAAM,CAAC,MAAM,WAAW,GAAyB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE;IAClF,MAAM,oBAAoB,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAA;IAE7D,MAAM,uBAAuB,GAAG,OAAO,CAAC,GAAG,EAAE;QAC3C,MAAM,UAAU,qBAAQ,oBAAoB,CAAE,CAAA;QAC9C,IAAI,QAAQ,EAAE;YACZ,OAAO,UAAU,CAAC,eAAe,CAAA;SAClC;QACD,IAAI,MAAM,EAAE;YACV,OAAO,UAAU,CAAC,MAAM,CAAA;YACxB,OAAO,UAAU,CAAC,WAAW,CAAA;YAC7B,OAAO,UAAU,CAAC,YAAY,CAAA;SAC/B;QACD,OAAO,UAAU,CAAA;IACnB,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAA;IAE5C,OAAO,CACL,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,uBAAuB,IAC1D,QAAQ,CACqB,CACjC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { FormProvider as RcFormProvider } from 'rc-field-form'\nimport type { FormProviderProps as RcFormProviderProps } from 'rc-field-form/lib/FormContext'\nimport type { Meta } from 'rc-field-form/lib/interface'\nimport omit from 'rc-util/lib/omit'\nimport type { FC, PropsWithChildren, ReactNode } from 'react'\nimport * as React from 'react'\nimport { useContext, useMemo } from 'react'\nimport type { ColProps } from '../col'\nimport type { FormInstance, RequiredMark } from './Form'\nimport type { ValidateStatus } from './FormItem'\nimport type { FormLabelAlign } from './interface'\n\n/** Form Context. Set top form style and pass to Form Item usage. */\nexport interface FormContextProps {\n vertical: boolean\n name?: string\n colon?: boolean\n labelAlign?: FormLabelAlign\n labelWrap?: boolean\n labelCol?: ColProps\n wrapperCol?: ColProps\n requiredMark?: RequiredMark\n itemRef: (name: (string | number)[]) => (node: React.ReactElement) => void\n form?: FormInstance\n readonly?: boolean\n placeholder?: string | React.ReactNode\n}\n\nexport const FormContext = React.createContext<FormContextProps>({\n labelAlign: 'right',\n vertical: false,\n itemRef: (() => {}) as any,\n})\n\n/** `noStyle` Form Item Context. Used for error collection */\nexport type ReportMetaChange = (meta: Meta, uniqueKeys: React.Key[]) => void\nexport const NoStyleItemContext = React.createContext<ReportMetaChange | null>(null)\n\n/** Form Provider */\nexport interface FormProviderProps extends Omit<RcFormProviderProps, 'validateMessages'> {\n prefixCls?: string\n}\n\nexport const FormProvider: React.FC<FormProviderProps> = (props) => {\n const providerProps = omit(props, ['prefixCls'])\n return <RcFormProvider {...providerProps} />\n}\n\n/** Used for ErrorList only */\nexport interface FormItemPrefixContextProps {\n prefixCls: string\n status?: ValidateStatus\n}\n\nexport const FormItemPrefixContext = React.createContext<FormItemPrefixContextProps>({\n prefixCls: '',\n})\n\nexport interface FormItemStatusContextProps {\n isFormItemInput?: boolean\n status?: ValidateStatus\n hasFeedback?: boolean\n feedbackIcon?: ReactNode\n}\n\nexport const FormItemInputContext = React.createContext<FormItemStatusContextProps>({})\n\nexport type NoFormStyleProps = PropsWithChildren<{\n status?: boolean\n override?: boolean\n}>\n\nexport const NoFormStyle: FC<NoFormStyleProps> = ({ children, status, override }) => {\n const formItemInputContext = useContext(FormItemInputContext)\n\n const newFormItemInputContext = useMemo(() => {\n const newContext = { ...formItemInputContext }\n if (override) {\n delete newContext.isFormItemInput\n }\n if (status) {\n delete newContext.status\n delete newContext.hasFeedback\n delete newContext.feedbackIcon\n }\n return newContext\n }, [status, override, formItemInputContext])\n\n return (\n <FormItemInputContext.Provider value={newFormItemInputContext}>\n {children}\n </FormItemInputContext.Provider>\n )\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export default function useDebounce(value) {
|
|
3
|
+
const [cacheValue, setCacheValue] = React.useState(value);
|
|
4
|
+
React.useEffect(() => {
|
|
5
|
+
const timeout = setTimeout(() => {
|
|
6
|
+
setCacheValue(value);
|
|
7
|
+
}, value.length ? 0 : 10);
|
|
8
|
+
return () => {
|
|
9
|
+
clearTimeout(timeout);
|
|
10
|
+
};
|
|
11
|
+
}, [value]);
|
|
12
|
+
return cacheValue;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebounce.js","sourceRoot":"","sources":["../../../src/tntd-form/hooks/useDebounce.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,MAAM,CAAC,OAAO,UAAU,WAAW,CAAI,KAAU;IAC/C,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IACzD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,OAAO,GAAG,UAAU,CACxB,GAAG,EAAE;YACH,aAAa,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC,EACD,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CACtB,CAAA;QAED,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,OAAO,CAAC,CAAA;QACvB,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAEX,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["import * as React from 'react'\n\nexport default function useDebounce<T>(value: T[]): T[] {\n const [cacheValue, setCacheValue] = React.useState(value)\n React.useEffect(() => {\n const timeout = setTimeout(\n () => {\n setCacheValue(value)\n },\n value.length ? 0 : 10\n )\n\n return () => {\n clearTimeout(timeout)\n }\n }, [value])\n\n return cacheValue\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useForm as useRcForm } from 'rc-field-form';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import scrollIntoView from 'scroll-into-view-if-needed';
|
|
4
|
+
import { getFieldId, toArray } from '../util';
|
|
5
|
+
function toNamePathStr(name) {
|
|
6
|
+
const namePath = toArray(name);
|
|
7
|
+
return namePath.join('_');
|
|
8
|
+
}
|
|
9
|
+
export default function useForm(form) {
|
|
10
|
+
const [rcForm] = useRcForm();
|
|
11
|
+
const itemsRef = React.useRef({});
|
|
12
|
+
const wrapForm = React.useMemo(() => form !== null && form !== void 0 ? form : Object.assign(Object.assign({}, rcForm), {
|
|
13
|
+
__INTERNAL__: {
|
|
14
|
+
itemRef: name => node => {
|
|
15
|
+
const namePathStr = toNamePathStr(name);
|
|
16
|
+
if (node) {
|
|
17
|
+
itemsRef.current[namePathStr] = node;
|
|
18
|
+
} else {
|
|
19
|
+
delete itemsRef.current[namePathStr];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
scrollToField: (name, options = {}) => {
|
|
24
|
+
const namePath = toArray(name);
|
|
25
|
+
const fieldId = getFieldId(namePath, wrapForm.__INTERNAL__.name);
|
|
26
|
+
const node = fieldId ? document.getElementById(fieldId) : null;
|
|
27
|
+
if (node) {
|
|
28
|
+
scrollIntoView(node, Object.assign({
|
|
29
|
+
scrollMode: 'if-needed',
|
|
30
|
+
block: 'nearest'
|
|
31
|
+
}, options));
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
getFieldInstance: name => {
|
|
35
|
+
const namePathStr = toNamePathStr(name);
|
|
36
|
+
return itemsRef.current[namePathStr];
|
|
37
|
+
}
|
|
38
|
+
}), [form, rcForm]);
|
|
39
|
+
return [wrapForm];
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useForm.js","sourceRoot":"","sources":["../../../src/tntd-form/hooks/useForm.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,cAAc,MAAM,4BAA4B,CAAA;AAEvD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAc7C,SAAS,aAAa,CAAC,IAAc;IACnC,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9B,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC3B,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,OAAO,CAAe,IAA2B;IACvE,MAAM,CAAC,MAAM,CAAC,GAAG,SAAS,EAAE,CAAA;IAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAqC,EAAE,CAAC,CAAA;IAErE,MAAM,QAAQ,GAAyB,KAAK,CAAC,OAAO,CAClD,GAAG,EAAE,CACH,IAAI,aAAJ,IAAI,cAAJ,IAAI,mCACC,MAAM,KACT,YAAY,EAAE;YACZ,OAAO,EAAE,CAAC,IAAsB,EAAE,EAAE,CAAC,CAAC,IAAwB,EAAE,EAAE;gBAChE,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC,CAAA;gBACvC,IAAI,IAAI,EAAE;oBACR,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAAA;iBACrC;qBAAM;oBACL,OAAO,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;iBACrC;YACH,CAAC;SACF,EACD,aAAa,EAAE,CAAC,IAAc,EAAE,UAAyB,EAAE,EAAE,EAAE;YAC7D,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;YAC9B,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;YAChE,MAAM,IAAI,GAAuB,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;YAElF,IAAI,IAAI,EAAE;gBACR,cAAc,CAAC,IAAI,kBACjB,UAAU,EAAE,WAAW,EACvB,KAAK,EAAE,SAAS,IACb,OAAO,EACV,CAAA;aACH;QACH,CAAC,EACD,gBAAgB,EAAE,CAAC,IAAc,EAAE,EAAE;YACnC,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC,CAAA;YACvC,OAAO,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;QACtC,CAAC,GACF,EACH,CAAC,IAAI,EAAE,MAAM,CAAC,CACf,CAAA;IAED,OAAO,CAAC,QAAQ,CAAC,CAAA;AACnB,CAAC","sourcesContent":["import type { FormInstance as RcFormInstance } from 'rc-field-form'\nimport { useForm as useRcForm } from 'rc-field-form'\nimport * as React from 'react'\nimport scrollIntoView from 'scroll-into-view-if-needed'\nimport type { InternalNamePath, NamePath, ScrollOptions } from '../interface'\nimport { getFieldId, toArray } from '../util'\n\nexport interface FormInstance<Values = any> extends RcFormInstance<Values> {\n scrollToField: (name: NamePath, options?: ScrollOptions) => void\n /** @internal: This is an internal usage. Do not use in your prod */\n __INTERNAL__: {\n /** No! Do not use this in your code! */\n name?: string\n /** No! Do not use this in your code! */\n itemRef: (name: InternalNamePath) => (node: React.ReactElement) => void\n }\n getFieldInstance: (name: NamePath) => any\n}\n\nfunction toNamePathStr(name: NamePath) {\n const namePath = toArray(name)\n return namePath.join('_')\n}\n\nexport default function useForm<Values = any>(form?: FormInstance<Values>): [FormInstance<Values>] {\n const [rcForm] = useRcForm()\n const itemsRef = React.useRef<Record<string, React.ReactElement>>({})\n\n const wrapForm: FormInstance<Values> = React.useMemo(\n () =>\n form ?? {\n ...rcForm,\n __INTERNAL__: {\n itemRef: (name: InternalNamePath) => (node: React.ReactElement) => {\n const namePathStr = toNamePathStr(name)\n if (node) {\n itemsRef.current[namePathStr] = node\n } else {\n delete itemsRef.current[namePathStr]\n }\n },\n },\n scrollToField: (name: NamePath, options: ScrollOptions = {}) => {\n const namePath = toArray(name)\n const fieldId = getFieldId(namePath, wrapForm.__INTERNAL__.name)\n const node: HTMLElement | null = fieldId ? document.getElementById(fieldId) : null\n\n if (node) {\n scrollIntoView(node, {\n scrollMode: 'if-needed',\n block: 'nearest',\n ...options,\n })\n }\n },\n getFieldInstance: (name: NamePath) => {\n const namePathStr = toNamePathStr(name)\n return itemsRef.current[namePathStr]\n },\n },\n [form, rcForm]\n )\n\n return [wrapForm]\n}\n"]}
|