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,301 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _rcFieldForm = require("rc-field-form");
|
|
8
|
+
var _useState3 = _interopRequireDefault(require("rc-util/lib/hooks/useState"));
|
|
9
|
+
var _ref2 = require("rc-util/lib/ref");
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _useFormItemStatus = _interopRequireDefault(require("../hooks/useFormItemStatus"));
|
|
12
|
+
var _configProvider = require("../../config-provider");
|
|
13
|
+
var _DisabledContext = _interopRequireDefault(require("../../config-provider/DisabledContext"));
|
|
14
|
+
var _reactNode = require("../_util/reactNode");
|
|
15
|
+
var _type = require("../_util/type");
|
|
16
|
+
var _warning = _interopRequireDefault(require("../_util/warning"));
|
|
17
|
+
var _context = require("../context");
|
|
18
|
+
var _useFrameState3 = _interopRequireDefault(require("../hooks/useFrameState"));
|
|
19
|
+
var _useItemRef = _interopRequireDefault(require("../hooks/useItemRef"));
|
|
20
|
+
var _util = require("../util");
|
|
21
|
+
var _ItemHolder = _interopRequireDefault(require("./ItemHolder"));
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
26
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
27
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
28
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
29
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
30
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
31
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
32
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
33
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
34
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) { ; } } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
35
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
36
|
+
var NAME_SPLIT = '__SPLIT__';
|
|
37
|
+
var ValidateStatuses = (0, _type.tuple)('success', 'warning', 'error', 'validating', '');
|
|
38
|
+
var MemoInput = React.memo(function (_ref) {
|
|
39
|
+
var children = _ref.children;
|
|
40
|
+
return children;
|
|
41
|
+
}, function (prev, next) {
|
|
42
|
+
return prev.value === next.value && prev.update === next.update && prev.childProps.length === next.childProps.length && prev.childProps.every(function (value, index) {
|
|
43
|
+
return value === next.childProps[index];
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
function hasValidName(name) {
|
|
47
|
+
if (name === null) {
|
|
48
|
+
(0, _warning["default"])(false, 'Form.Item', '`null` is passed as `name` property');
|
|
49
|
+
}
|
|
50
|
+
return !(name === undefined || name === null);
|
|
51
|
+
}
|
|
52
|
+
function genEmptyMeta() {
|
|
53
|
+
return {
|
|
54
|
+
errors: [],
|
|
55
|
+
warnings: [],
|
|
56
|
+
touched: false,
|
|
57
|
+
validating: false,
|
|
58
|
+
validated: false,
|
|
59
|
+
name: []
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function InternalFormItem(props) {
|
|
63
|
+
var _a, _b, _c, _d;
|
|
64
|
+
var name = props.name,
|
|
65
|
+
noStyle = props.noStyle,
|
|
66
|
+
dependencies = props.dependencies,
|
|
67
|
+
customizePrefixCls = props.prefixCls,
|
|
68
|
+
shouldUpdate = props.shouldUpdate,
|
|
69
|
+
rules = props.rules,
|
|
70
|
+
children = props.children,
|
|
71
|
+
required = props.required,
|
|
72
|
+
label = props.label,
|
|
73
|
+
messageVariables = props.messageVariables,
|
|
74
|
+
_props$trigger = props.trigger,
|
|
75
|
+
trigger = _props$trigger === void 0 ? 'onChange' : _props$trigger,
|
|
76
|
+
validateTrigger = props.validateTrigger,
|
|
77
|
+
hidden = props.hidden;
|
|
78
|
+
// TODO
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
var _useContext = (0, React.useContext)(_configProvider.ConfigContext),
|
|
81
|
+
getPrefixCls = _useContext.getPrefixCls;
|
|
82
|
+
var _useContext2 = (0, React.useContext)(_context.FormContext),
|
|
83
|
+
formName = _useContext2.name;
|
|
84
|
+
var isRenderProps = typeof children === 'function';
|
|
85
|
+
var notifyParentMetaChange = (0, React.useContext)(_context.NoStyleItemContext);
|
|
86
|
+
var contextDisabled = (0, React.useContext)(_DisabledContext["default"]);
|
|
87
|
+
var _useContext3 = (0, React.useContext)(_context.FormContext),
|
|
88
|
+
contextReadonly = _useContext3.readonly;
|
|
89
|
+
var _useContext4 = (0, React.useContext)(_rcFieldForm.FieldContext),
|
|
90
|
+
contextValidateTrigger = _useContext4.validateTrigger;
|
|
91
|
+
var mergedValidateTrigger = validateTrigger !== undefined ? validateTrigger : contextValidateTrigger;
|
|
92
|
+
var hasName = hasValidName(name);
|
|
93
|
+
var prefixCls = getPrefixCls('form', customizePrefixCls);
|
|
94
|
+
// ========================= MISC =========================
|
|
95
|
+
// Get `noStyle` required info
|
|
96
|
+
var listContext = React.useContext(_rcFieldForm.ListContext);
|
|
97
|
+
var fieldKeyPathRef = React.useRef();
|
|
98
|
+
// ======================== Errors ========================
|
|
99
|
+
// >>>>> Collect sub field errors
|
|
100
|
+
var _useFrameState = (0, _useFrameState3["default"])({}),
|
|
101
|
+
_useFrameState2 = _slicedToArray(_useFrameState, 2),
|
|
102
|
+
subFieldErrors = _useFrameState2[0],
|
|
103
|
+
setSubFieldErrors = _useFrameState2[1];
|
|
104
|
+
// >>>>> Current field errors
|
|
105
|
+
var _useState = (0, _useState3["default"])(function () {
|
|
106
|
+
return genEmptyMeta();
|
|
107
|
+
}),
|
|
108
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
109
|
+
meta = _useState2[0],
|
|
110
|
+
setMeta = _useState2[1];
|
|
111
|
+
var onMetaChange = function onMetaChange(nextMeta) {
|
|
112
|
+
// This keyInfo is not correct when field is removed
|
|
113
|
+
// Since origin keyManager no longer keep the origin key anymore
|
|
114
|
+
// Which means we need cache origin one and reuse when removed
|
|
115
|
+
var keyInfo = listContext === null || listContext === void 0 ? void 0 : listContext.getKey(nextMeta.name);
|
|
116
|
+
// Destroy will reset all the meta
|
|
117
|
+
setMeta(nextMeta.destroy ? genEmptyMeta() : nextMeta, true);
|
|
118
|
+
// Bump to parent since noStyle
|
|
119
|
+
if (noStyle && notifyParentMetaChange) {
|
|
120
|
+
var namePath = nextMeta.name;
|
|
121
|
+
if (!nextMeta.destroy) {
|
|
122
|
+
if (keyInfo !== undefined) {
|
|
123
|
+
var _keyInfo = _slicedToArray(keyInfo, 2),
|
|
124
|
+
fieldKey = _keyInfo[0],
|
|
125
|
+
restPath = _keyInfo[1];
|
|
126
|
+
namePath = [fieldKey].concat(_toConsumableArray(restPath));
|
|
127
|
+
fieldKeyPathRef.current = namePath;
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
// Use origin cache data
|
|
131
|
+
namePath = fieldKeyPathRef.current || namePath;
|
|
132
|
+
}
|
|
133
|
+
notifyParentMetaChange(nextMeta, namePath);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
// >>>>> Collect noStyle Field error to the top FormItem
|
|
137
|
+
var onSubItemMetaChange = function onSubItemMetaChange(subMeta, uniqueKeys) {
|
|
138
|
+
// Only `noStyle` sub item will trigger
|
|
139
|
+
setSubFieldErrors(function (prevSubFieldErrors) {
|
|
140
|
+
var clone = Object.assign({}, prevSubFieldErrors);
|
|
141
|
+
// name: ['user', 1] + key: [4] = ['user', 4]
|
|
142
|
+
var mergedNamePath = [].concat(_toConsumableArray(subMeta.name.slice(0, -1)), _toConsumableArray(uniqueKeys));
|
|
143
|
+
var mergedNameKey = mergedNamePath.join(NAME_SPLIT);
|
|
144
|
+
if (subMeta.destroy) {
|
|
145
|
+
// Remove
|
|
146
|
+
delete clone[mergedNameKey];
|
|
147
|
+
} else {
|
|
148
|
+
// Update
|
|
149
|
+
clone[mergedNameKey] = subMeta;
|
|
150
|
+
}
|
|
151
|
+
return clone;
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
// >>>>> Get merged errors
|
|
155
|
+
var _React$useMemo = React.useMemo(function () {
|
|
156
|
+
var errorList = _toConsumableArray(meta.errors);
|
|
157
|
+
var warningList = _toConsumableArray(meta.warnings);
|
|
158
|
+
Object.values(subFieldErrors).forEach(function (subFieldError) {
|
|
159
|
+
errorList.push.apply(errorList, _toConsumableArray(subFieldError.errors || []));
|
|
160
|
+
warningList.push.apply(warningList, _toConsumableArray(subFieldError.warnings || []));
|
|
161
|
+
});
|
|
162
|
+
return [errorList, warningList];
|
|
163
|
+
}, [subFieldErrors, meta.errors, meta.warnings]),
|
|
164
|
+
_React$useMemo2 = _slicedToArray(_React$useMemo, 2),
|
|
165
|
+
mergedErrors = _React$useMemo2[0],
|
|
166
|
+
mergedWarnings = _React$useMemo2[1];
|
|
167
|
+
// ===================== Children Ref =====================
|
|
168
|
+
var getItemRef = (0, _useItemRef["default"])();
|
|
169
|
+
// ======================== Render ========================
|
|
170
|
+
function renderLayout(baseChildren, fieldId, isRequired) {
|
|
171
|
+
if (noStyle && !hidden) {
|
|
172
|
+
return baseChildren;
|
|
173
|
+
}
|
|
174
|
+
return React.createElement(_ItemHolder["default"], Object.assign({
|
|
175
|
+
key: "row"
|
|
176
|
+
}, props, {
|
|
177
|
+
prefixCls: prefixCls,
|
|
178
|
+
fieldId: fieldId,
|
|
179
|
+
isRequired: isRequired,
|
|
180
|
+
errors: mergedErrors,
|
|
181
|
+
warnings: mergedWarnings,
|
|
182
|
+
meta: meta,
|
|
183
|
+
// TODO
|
|
184
|
+
// @ts-ignore
|
|
185
|
+
onSubItemMetaChange: onSubItemMetaChange
|
|
186
|
+
}), baseChildren);
|
|
187
|
+
}
|
|
188
|
+
if (!hasName && !isRenderProps && !dependencies) {
|
|
189
|
+
if ((0, _reactNode.isValidElement)(children)) {
|
|
190
|
+
return renderLayout((0, _reactNode.cloneElement)(children, Object.assign(Object.assign({}, children.props), {
|
|
191
|
+
disabled: (_b = (_a = children.props) === null || _a === void 0 ? void 0 : _a.disabled) !== null && _b !== void 0 ? _b : contextDisabled,
|
|
192
|
+
readonly: (_d = (_c = children.props) === null || _c === void 0 ? void 0 : _c.readonly) !== null && _d !== void 0 ? _d : contextReadonly
|
|
193
|
+
})));
|
|
194
|
+
}
|
|
195
|
+
return renderLayout(children);
|
|
196
|
+
}
|
|
197
|
+
var variables = {};
|
|
198
|
+
if (typeof label === 'string') {
|
|
199
|
+
variables.label = label;
|
|
200
|
+
} else if (name) {
|
|
201
|
+
variables.label = String(name);
|
|
202
|
+
}
|
|
203
|
+
if (messageVariables) {
|
|
204
|
+
variables = Object.assign(Object.assign({}, variables), messageVariables);
|
|
205
|
+
}
|
|
206
|
+
// >>>>> With Field
|
|
207
|
+
return React.createElement(_rcFieldForm.Field, Object.assign({}, props, {
|
|
208
|
+
messageVariables: variables,
|
|
209
|
+
trigger: trigger,
|
|
210
|
+
validateTrigger: mergedValidateTrigger,
|
|
211
|
+
onMetaChange: onMetaChange
|
|
212
|
+
}), function (control, renderMeta, context) {
|
|
213
|
+
var _a, _b, _c, _d;
|
|
214
|
+
var mergedName = (0, _util.toArray)(name).length && renderMeta ? renderMeta.name : [];
|
|
215
|
+
var fieldId = (0, _util.getFieldId)(mergedName, formName);
|
|
216
|
+
var isRequired = required !== undefined ? required : !!(rules && rules.some(function (rule) {
|
|
217
|
+
if (rule && _typeof(rule) === 'object' && rule.required && !rule.warningOnly) {
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
if (typeof rule === 'function') {
|
|
221
|
+
var ruleEntity = rule(context);
|
|
222
|
+
return ruleEntity && ruleEntity.required && !ruleEntity.warningOnly;
|
|
223
|
+
}
|
|
224
|
+
return false;
|
|
225
|
+
}));
|
|
226
|
+
// ======================= Children =======================
|
|
227
|
+
var mergedControl = Object.assign({}, control);
|
|
228
|
+
var childNode = null;
|
|
229
|
+
(0, _warning["default"])(!(shouldUpdate && dependencies), 'Form.Item', "`shouldUpdate` and `dependencies` shouldn't be used together. See https://u.ant.design/form-deps.");
|
|
230
|
+
if (Array.isArray(children) && hasName) {
|
|
231
|
+
(0, _warning["default"])(false, 'Form.Item', 'A `Form.Item` with a `name` prop must have a single child element. For information on how to render more complex form items, see https://u.ant.design/complex-form-item.');
|
|
232
|
+
childNode = children;
|
|
233
|
+
} else if (isRenderProps && (!(shouldUpdate || dependencies) || hasName)) {
|
|
234
|
+
(0, _warning["default"])(!!(shouldUpdate || dependencies), 'Form.Item', 'A `Form.Item` with a render function must have either `shouldUpdate` or `dependencies`.');
|
|
235
|
+
(0, _warning["default"])(!hasName, 'Form.Item', 'A `Form.Item` with a render function cannot be a field, and thus cannot have a `name` prop.');
|
|
236
|
+
} else if (dependencies && !isRenderProps && !hasName) {
|
|
237
|
+
(0, _warning["default"])(false, 'Form.Item', 'Must set `name` or use a render function when `dependencies` is set.');
|
|
238
|
+
} else if ((0, _reactNode.isValidElement)(children)) {
|
|
239
|
+
(0, _warning["default"])(children.props.defaultValue === undefined, 'Form.Item', '`defaultValue` will not work on controlled Field. You should use `initialValues` of Form instead.');
|
|
240
|
+
var childProps = Object.assign(Object.assign(Object.assign({}, children.props), mergedControl), {
|
|
241
|
+
disabled: (_b = (_a = children.props) === null || _a === void 0 ? void 0 : _a.disabled) !== null && _b !== void 0 ? _b : contextDisabled
|
|
242
|
+
});
|
|
243
|
+
if (contextReadonly !== undefined) {
|
|
244
|
+
childProps.readonly = (_d = (_c = children.props) === null || _c === void 0 ? void 0 : _c.readonly) !== null && _d !== void 0 ? _d : contextReadonly;
|
|
245
|
+
}
|
|
246
|
+
if (!childProps.id) {
|
|
247
|
+
childProps.id = fieldId;
|
|
248
|
+
}
|
|
249
|
+
if (props.help || mergedErrors.length > 0 || mergedWarnings.length > 0 || props.extra) {
|
|
250
|
+
var describedbyArr = [];
|
|
251
|
+
if (props.help || mergedErrors.length > 0) {
|
|
252
|
+
describedbyArr.push("".concat(fieldId, "_help"));
|
|
253
|
+
}
|
|
254
|
+
if (props.extra) {
|
|
255
|
+
describedbyArr.push("".concat(fieldId, "_extra"));
|
|
256
|
+
}
|
|
257
|
+
childProps['aria-describedby'] = describedbyArr.join(' ');
|
|
258
|
+
}
|
|
259
|
+
if (mergedErrors.length > 0) {
|
|
260
|
+
childProps['aria-invalid'] = 'true';
|
|
261
|
+
}
|
|
262
|
+
if (isRequired) {
|
|
263
|
+
childProps['aria-required'] = 'true';
|
|
264
|
+
}
|
|
265
|
+
if ((0, _ref2.supportRef)(children)) {
|
|
266
|
+
childProps.ref = getItemRef(mergedName, children);
|
|
267
|
+
}
|
|
268
|
+
// We should keep user origin event handler
|
|
269
|
+
var triggers = new Set([].concat(_toConsumableArray((0, _util.toArray)(trigger)), _toConsumableArray((0, _util.toArray)(mergedValidateTrigger))));
|
|
270
|
+
triggers.forEach(function (eventName) {
|
|
271
|
+
childProps[eventName] = function () {
|
|
272
|
+
var _a2, _c2;
|
|
273
|
+
var _a, _b, _c;
|
|
274
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
275
|
+
args[_key] = arguments[_key];
|
|
276
|
+
}
|
|
277
|
+
(_a = mergedControl[eventName]) === null || _a === void 0 ? void 0 : (_a2 = _a).call.apply(_a2, [mergedControl].concat(args));
|
|
278
|
+
// @ts-ignore
|
|
279
|
+
(_c = (_b = children === null || children === void 0 ? void 0 : children.props) === null || _b === void 0 ? void 0 : _b[eventName]) === null || _c === void 0 ? void 0 : (_c2 = _c).call.apply(_c2, [_b].concat(args));
|
|
280
|
+
};
|
|
281
|
+
});
|
|
282
|
+
// List of props that need to be watched for changes -> if changes are detected in MemoInput -> rerender
|
|
283
|
+
var watchingChildProps = [childProps['aria-required'], childProps['aria-invalid'], childProps['aria-describedby'], childProps.disabled, childProps.readonly];
|
|
284
|
+
childNode = React.createElement(MemoInput, {
|
|
285
|
+
value: mergedControl[props.valuePropName || 'value'],
|
|
286
|
+
update: children,
|
|
287
|
+
childProps: watchingChildProps
|
|
288
|
+
}, (0, _reactNode.cloneElement)(children, childProps));
|
|
289
|
+
} else if (isRenderProps && (shouldUpdate || dependencies) && !hasName) {
|
|
290
|
+
childNode = children(context);
|
|
291
|
+
} else {
|
|
292
|
+
(0, _warning["default"])(!mergedName.length, 'Form.Item', '`name` is only used for validate React element. If you are using Form.Item as layout display, please remove `name` instead.');
|
|
293
|
+
childNode = children;
|
|
294
|
+
}
|
|
295
|
+
return renderLayout(childNode, fieldId, isRequired);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
var FormItem = InternalFormItem;
|
|
299
|
+
FormItem.useStatus = _useFormItemStatus["default"];
|
|
300
|
+
var _default = FormItem;
|
|
301
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tntd-form/FormItem/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAAgE;AAGhE,0EAAiD;AACjD,yCAA4C;AAC5C,6CAA8B;AAC9B,iCAAkC;AAClC,mFAA0D;AAC1D,2DAAqD;AACrD,4FAAmE;AACnE,kDAAiE;AACjE,wCAAqC;AACrC,+DAAsC;AACtC,wCAA4D;AAG5D,2EAAkD;AAClD,qEAA4C;AAC5C,kCAA6C;AAC7C,8DAAqC;AAErC,MAAM,UAAU,GAAG,WAAW,CAAA;AAO9B,MAAM,gBAAgB,GAAG,IAAA,YAAK,EAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,CAAC,CAAA;AAc/E,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAC1B,CAAC,EAAE,QAAQ,EAAkB,EAAE,EAAE,CAAC,QAAuB,EACzD,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CACb,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK;IACzB,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;IAC3B,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,IAAI,CAAC,UAAU,CAAC,MAAM;IACjD,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KA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":["import type { FormInstance } from 'rc-field-form'\nimport { Field, FieldContext, ListContext } from 'rc-field-form'\nimport type { FieldProps } from 'rc-field-form/lib/Field'\nimport type { Meta, NamePath } from 'rc-field-form/lib/interface'\nimport useState from 'rc-util/lib/hooks/useState'\nimport { supportRef } from 'rc-util/lib/ref'\nimport * as React from 'react'\nimport { useContext } from 'react'\nimport useFormItemStatus from '../hooks/useFormItemStatus'\nimport { ConfigContext } from '../../config-provider'\nimport DisabledContext from '../../config-provider/DisabledContext'\nimport { cloneElement, isValidElement } from '../_util/reactNode'\nimport { tuple } from '../_util/type'\nimport warning from '../_util/warning'\nimport { FormContext, NoStyleItemContext } from '../context'\nimport type { FormItemInputProps } from '../FormItemInput'\nimport type { FormItemLabelProps, LabelTooltipType } from '../FormItemLabel'\nimport useFrameState from '../hooks/useFrameState'\nimport useItemRef from '../hooks/useItemRef'\nimport { getFieldId, toArray } from '../util'\nimport ItemHolder from './ItemHolder'\n\nconst NAME_SPLIT = '__SPLIT__'\n\ninterface FieldError {\n errors: string[]\n warnings: string[]\n}\n\nconst ValidateStatuses = tuple('success', 'warning', 'error', 'validating', '')\nexport type ValidateStatus = typeof ValidateStatuses[number]\n\ntype RenderChildren<Values = any> = (form: FormInstance<Values>) => React.ReactNode\ntype RcFieldProps<Values = any> = Omit<FieldProps<Values>, 'children'>\ntype ChildrenType<Values = any> = RenderChildren<Values> | React.ReactNode\n\ninterface MemoInputProps {\n value: any\n update: any\n children: React.ReactNode\n childProps: any[]\n}\n\nconst MemoInput = React.memo(\n ({ children }: MemoInputProps) => children as JSX.Element,\n (prev, next) =>\n prev.value === next.value &&\n prev.update === next.update &&\n prev.childProps.length === next.childProps.length &&\n prev.childProps.every((value, index) => value === next.childProps[index])\n)\n\nexport interface FormItemProps<Values = any>\n extends FormItemLabelProps,\n FormItemInputProps,\n RcFieldProps<Values> {\n prefixCls?: string\n noStyle?: boolean\n style?: React.CSSProperties\n className?: string\n children?: ChildrenType<Values>\n id?: string\n hasFeedback?: boolean\n validateStatus?: ValidateStatus\n required?: boolean\n hidden?: boolean\n initialValue?: any\n messageVariables?: Record<string, string>\n tooltip?: LabelTooltipType\n /** @deprecated No need anymore */\n fieldKey?: React.Key | React.Key[]\n}\n\nfunction hasValidName(name?: NamePath): boolean {\n if (name === null) {\n warning(false, 'Form.Item', '`null` is passed as `name` property')\n }\n return !(name === undefined || name === null)\n}\n\nfunction genEmptyMeta(): Meta {\n return {\n errors: [],\n warnings: [],\n touched: false,\n validating: false,\n validated: false,\n name: [],\n }\n}\n\nfunction InternalFormItem<Values = any>(props: FormItemProps<Values>): React.ReactElement {\n const {\n name,\n noStyle,\n dependencies,\n prefixCls: customizePrefixCls,\n shouldUpdate,\n rules,\n children,\n required,\n label,\n messageVariables,\n trigger = 'onChange',\n validateTrigger,\n hidden,\n } = props\n // TODO\n // @ts-ignore\n const { getPrefixCls } = useContext(ConfigContext)\n const { name: formName } = useContext(FormContext)\n const isRenderProps = typeof children === 'function'\n const notifyParentMetaChange = useContext(NoStyleItemContext)\n const contextDisabled = useContext(DisabledContext)\n const { readonly: contextReadonly } = useContext(FormContext)\n\n const { validateTrigger: contextValidateTrigger } = useContext(FieldContext)\n const mergedValidateTrigger =\n validateTrigger !== undefined ? validateTrigger : contextValidateTrigger\n\n const hasName = hasValidName(name)\n\n const prefixCls = getPrefixCls('form', customizePrefixCls)\n\n // ========================= MISC =========================\n // Get `noStyle` required info\n const listContext = React.useContext(ListContext)\n const fieldKeyPathRef = React.useRef<React.Key[]>()\n\n // ======================== Errors ========================\n // >>>>> Collect sub field errors\n const [subFieldErrors, setSubFieldErrors] = useFrameState<Record<string, FieldError>>({})\n\n // >>>>> Current field errors\n const [meta, setMeta] = useState<Meta>(() => genEmptyMeta())\n\n const onMetaChange = (nextMeta: Meta & { destroy?: boolean }) => {\n // This keyInfo is not correct when field is removed\n // Since origin keyManager no longer keep the origin key anymore\n // Which means we need cache origin one and reuse when removed\n const keyInfo = listContext?.getKey(nextMeta.name)\n\n // Destroy will reset all the meta\n setMeta(nextMeta.destroy ? genEmptyMeta() : nextMeta, true)\n\n // Bump to parent since noStyle\n if (noStyle && notifyParentMetaChange) {\n let namePath = nextMeta.name\n\n if (!nextMeta.destroy) {\n if (keyInfo !== undefined) {\n const [fieldKey, restPath] = keyInfo\n namePath = [fieldKey, ...restPath]\n fieldKeyPathRef.current = namePath\n }\n } else {\n // Use origin cache data\n namePath = fieldKeyPathRef.current || namePath\n }\n notifyParentMetaChange(nextMeta, namePath)\n }\n }\n\n // >>>>> Collect noStyle Field error to the top FormItem\n const onSubItemMetaChange = (subMeta: Meta & { destroy: boolean }, uniqueKeys: React.Key[]) => {\n // Only `noStyle` sub item will trigger\n setSubFieldErrors((prevSubFieldErrors) => {\n const clone = {\n ...prevSubFieldErrors,\n }\n\n // name: ['user', 1] + key: [4] = ['user', 4]\n const mergedNamePath = [...subMeta.name.slice(0, -1), ...uniqueKeys]\n const mergedNameKey = mergedNamePath.join(NAME_SPLIT)\n\n if (subMeta.destroy) {\n // Remove\n delete clone[mergedNameKey]\n } else {\n // Update\n clone[mergedNameKey] = subMeta\n }\n\n return clone\n })\n }\n\n // >>>>> Get merged errors\n const [mergedErrors, mergedWarnings] = React.useMemo(() => {\n const errorList: string[] = [...meta.errors]\n const warningList: string[] = [...meta.warnings]\n\n Object.values(subFieldErrors).forEach((subFieldError) => {\n errorList.push(...(subFieldError.errors || []))\n warningList.push(...(subFieldError.warnings || []))\n })\n\n return [errorList, warningList]\n }, [subFieldErrors, meta.errors, meta.warnings])\n\n // ===================== Children Ref =====================\n const getItemRef = useItemRef()\n\n // ======================== Render ========================\n function renderLayout(\n baseChildren: React.ReactNode,\n fieldId?: string,\n isRequired?: boolean\n ): React.ReactNode {\n if (noStyle && !hidden) {\n return baseChildren\n }\n\n return (\n <ItemHolder\n key=\"row\"\n {...props}\n prefixCls={prefixCls}\n fieldId={fieldId}\n isRequired={isRequired}\n errors={mergedErrors}\n warnings={mergedWarnings}\n meta={meta}\n // TODO\n // @ts-ignore\n onSubItemMetaChange={onSubItemMetaChange}\n >\n {baseChildren}\n </ItemHolder>\n )\n }\n\n if (!hasName && !isRenderProps && !dependencies) {\n if (isValidElement(children)) {\n return renderLayout(\n cloneElement(children, {\n ...children.props,\n disabled: children.props?.disabled ?? contextDisabled,\n readonly: children.props?.readonly ?? contextReadonly,\n })\n ) as JSX.Element\n }\n return renderLayout(children) as JSX.Element\n }\n\n let variables: Record<string, string> = {}\n if (typeof label === 'string') {\n variables.label = label\n } else if (name) {\n variables.label = String(name)\n }\n if (messageVariables) {\n variables = { ...variables, ...messageVariables }\n }\n\n // >>>>> With Field\n return (\n <Field\n {...props}\n messageVariables={variables}\n trigger={trigger}\n validateTrigger={mergedValidateTrigger}\n onMetaChange={onMetaChange}\n >\n {(control, renderMeta, context) => {\n const mergedName = toArray(name).length && renderMeta ? renderMeta.name : []\n const fieldId = getFieldId(mergedName, formName)\n\n const isRequired =\n required !== undefined\n ? required\n : !!(\n rules &&\n rules.some((rule) => {\n if (rule && typeof rule === 'object' && rule.required && !rule.warningOnly) {\n return true\n }\n if (typeof rule === 'function') {\n const ruleEntity = rule(context)\n return ruleEntity && ruleEntity.required && !ruleEntity.warningOnly\n }\n return false\n })\n )\n\n // ======================= Children =======================\n const mergedControl: typeof control = {\n ...control,\n }\n\n let childNode: React.ReactNode = null\n\n warning(\n !(shouldUpdate && dependencies),\n 'Form.Item',\n \"`shouldUpdate` and `dependencies` shouldn't be used together. See https://u.ant.design/form-deps.\"\n )\n if (Array.isArray(children) && hasName) {\n warning(\n false,\n 'Form.Item',\n 'A `Form.Item` with a `name` prop must have a single child element. For information on how to render more complex form items, see https://u.ant.design/complex-form-item.'\n )\n childNode = children\n } else if (isRenderProps && (!(shouldUpdate || dependencies) || hasName)) {\n warning(\n !!(shouldUpdate || dependencies),\n 'Form.Item',\n 'A `Form.Item` with a render function must have either `shouldUpdate` or `dependencies`.'\n )\n warning(\n !hasName,\n 'Form.Item',\n 'A `Form.Item` with a render function cannot be a field, and thus cannot have a `name` prop.'\n )\n } else if (dependencies && !isRenderProps && !hasName) {\n warning(\n false,\n 'Form.Item',\n 'Must set `name` or use a render function when `dependencies` is set.'\n )\n } else if (isValidElement(children)) {\n warning(\n children.props.defaultValue === undefined,\n 'Form.Item',\n '`defaultValue` will not work on controlled Field. You should use `initialValues` of Form instead.'\n )\n\n const childProps = {\n ...children.props,\n ...mergedControl,\n disabled: children.props?.disabled ?? contextDisabled,\n }\n\n if (contextReadonly !== undefined) {\n childProps.readonly = children.props?.readonly ?? contextReadonly\n }\n\n if (!childProps.id) {\n childProps.id = fieldId\n }\n\n if (props.help || mergedErrors.length > 0 || mergedWarnings.length > 0 || props.extra) {\n const describedbyArr = []\n if (props.help || mergedErrors.length > 0) {\n describedbyArr.push(`${fieldId}_help`)\n }\n if (props.extra) {\n describedbyArr.push(`${fieldId}_extra`)\n }\n childProps['aria-describedby'] = describedbyArr.join(' ')\n }\n\n if (mergedErrors.length > 0) {\n childProps['aria-invalid'] = 'true'\n }\n\n if (isRequired) {\n childProps['aria-required'] = 'true'\n }\n\n if (supportRef(children)) {\n childProps.ref = getItemRef(mergedName, children)\n }\n\n // We should keep user origin event handler\n const triggers = new Set<string>([...toArray(trigger), ...toArray(mergedValidateTrigger)])\n\n triggers.forEach((eventName) => {\n childProps[eventName] = (...args: any[]) => {\n mergedControl[eventName]?.(...args)\n // @ts-ignore\n children?.props?.[eventName]?.(...args)\n }\n })\n\n // List of props that need to be watched for changes -> if changes are detected in MemoInput -> rerender\n const watchingChildProps = [\n childProps['aria-required'],\n childProps['aria-invalid'],\n childProps['aria-describedby'],\n childProps.disabled,\n childProps.readonly,\n ]\n\n childNode = (\n <MemoInput\n value={mergedControl[props.valuePropName || 'value']}\n update={children}\n childProps={watchingChildProps}\n >\n {cloneElement(children, childProps)}\n </MemoInput>\n )\n } else if (isRenderProps && (shouldUpdate || dependencies) && !hasName) {\n childNode = (children as RenderChildren)(context)\n } else {\n warning(\n !mergedName.length,\n 'Form.Item',\n '`name` is only used for validate React element. If you are using Form.Item as layout display, please remove `name` instead.'\n )\n childNode = children as React.ReactNode\n }\n\n return renderLayout(childNode, fieldId, isRequired)\n }}\n </Field>\n )\n}\n\ntype InternalFormItemType = typeof InternalFormItem\n\ntype CompoundedComponent = InternalFormItemType & {\n useStatus: typeof useFormItemStatus\n}\n\nconst FormItem = InternalFormItem as CompoundedComponent\nFormItem.useStatus = useFormItemStatus\n\nexport default FormItem\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ColProps } from '../col';
|
|
3
|
+
import type { ValidateStatus } from './FormItem';
|
|
4
|
+
interface FormItemInputMiscProps {
|
|
5
|
+
prefixCls: string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
errors: React.ReactNode[];
|
|
8
|
+
warnings: React.ReactNode[];
|
|
9
|
+
marginBottom?: number | null;
|
|
10
|
+
onErrorVisibleChanged?: (visible: boolean) => void;
|
|
11
|
+
/** @internal do not use in any of your production. */
|
|
12
|
+
_internalItemRender?: {
|
|
13
|
+
mark: string;
|
|
14
|
+
render: (props: FormItemInputProps & FormItemInputMiscProps, domList: {
|
|
15
|
+
input: JSX.Element;
|
|
16
|
+
errorList: JSX.Element | null;
|
|
17
|
+
extra: JSX.Element | null;
|
|
18
|
+
}) => React.ReactNode;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export interface FormItemInputProps {
|
|
22
|
+
wrapperCol?: ColProps;
|
|
23
|
+
extra?: React.ReactNode;
|
|
24
|
+
status?: ValidateStatus;
|
|
25
|
+
help?: React.ReactNode;
|
|
26
|
+
fieldId?: string;
|
|
27
|
+
}
|
|
28
|
+
declare const FormItemInput: React.FC<FormItemInputProps & FormItemInputMiscProps>;
|
|
29
|
+
export default FormItemInput;
|
|
30
|
+
//# sourceMappingURL=FormItemInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormItemInput.d.ts","sourceRoot":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,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _col = _interopRequireDefault(require("../col"));
|
|
11
|
+
var _context = require("./context");
|
|
12
|
+
var _ErrorList = _interopRequireDefault(require("./ErrorList"));
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
|
+
var FormItemInput = function FormItemInput(props) {
|
|
17
|
+
var prefixCls = props.prefixCls,
|
|
18
|
+
status = props.status,
|
|
19
|
+
wrapperCol = props.wrapperCol,
|
|
20
|
+
children = props.children,
|
|
21
|
+
errors = props.errors,
|
|
22
|
+
warnings = props.warnings,
|
|
23
|
+
formItemRender = props._internalItemRender,
|
|
24
|
+
extra = props.extra,
|
|
25
|
+
help = props.help,
|
|
26
|
+
fieldId = props.fieldId,
|
|
27
|
+
marginBottom = props.marginBottom,
|
|
28
|
+
onErrorVisibleChanged = props.onErrorVisibleChanged;
|
|
29
|
+
var baseClassName = "".concat(prefixCls, "-item");
|
|
30
|
+
var formContext = React.useContext(_context.FormContext);
|
|
31
|
+
var mergedWrapperCol = wrapperCol || formContext.wrapperCol || {};
|
|
32
|
+
var className = (0, _classnames["default"])("".concat(baseClassName, "-control"), mergedWrapperCol.className);
|
|
33
|
+
// Pass to sub FormItem should not with col info
|
|
34
|
+
var subFormContext = React.useMemo(function () {
|
|
35
|
+
return Object.assign({}, formContext);
|
|
36
|
+
}, [formContext]);
|
|
37
|
+
delete subFormContext.labelCol;
|
|
38
|
+
delete subFormContext.wrapperCol;
|
|
39
|
+
var inputDom = React.createElement("div", {
|
|
40
|
+
className: "".concat(baseClassName, "-control-input")
|
|
41
|
+
}, React.createElement("div", {
|
|
42
|
+
className: "".concat(baseClassName, "-control-input-content")
|
|
43
|
+
}, children));
|
|
44
|
+
var formItemContext = React.useMemo(function () {
|
|
45
|
+
return {
|
|
46
|
+
prefixCls: prefixCls,
|
|
47
|
+
status: status
|
|
48
|
+
};
|
|
49
|
+
}, [prefixCls, status]);
|
|
50
|
+
var errorListDom = marginBottom !== null || errors.length || warnings.length ? React.createElement("div", {
|
|
51
|
+
style: {
|
|
52
|
+
display: 'flex',
|
|
53
|
+
flexWrap: 'nowrap'
|
|
54
|
+
}
|
|
55
|
+
}, React.createElement(_context.FormItemPrefixContext.Provider, {
|
|
56
|
+
value: formItemContext
|
|
57
|
+
}, React.createElement(_ErrorList["default"], {
|
|
58
|
+
fieldId: fieldId,
|
|
59
|
+
errors: errors,
|
|
60
|
+
warnings: warnings,
|
|
61
|
+
help: help,
|
|
62
|
+
helpStatus: status,
|
|
63
|
+
className: "".concat(baseClassName, "-explain-connected"),
|
|
64
|
+
onVisibleChanged: onErrorVisibleChanged
|
|
65
|
+
})), !!marginBottom && React.createElement("div", {
|
|
66
|
+
style: {
|
|
67
|
+
width: 0,
|
|
68
|
+
height: marginBottom
|
|
69
|
+
}
|
|
70
|
+
})) : null;
|
|
71
|
+
var extraProps = {};
|
|
72
|
+
if (fieldId) {
|
|
73
|
+
extraProps.id = "".concat(fieldId, "_extra");
|
|
74
|
+
}
|
|
75
|
+
// If extra = 0, && will goes wrong
|
|
76
|
+
// 0&&error -> 0
|
|
77
|
+
var extraDom = extra ? React.createElement("div", Object.assign({}, extraProps, {
|
|
78
|
+
className: "".concat(baseClassName, "-extra")
|
|
79
|
+
}), extra) : null;
|
|
80
|
+
var dom = formItemRender && formItemRender.mark === 'pro_table_render' && formItemRender.render ? formItemRender.render(props, {
|
|
81
|
+
input: inputDom,
|
|
82
|
+
errorList: errorListDom,
|
|
83
|
+
extra: extraDom
|
|
84
|
+
}) : React.createElement(React.Fragment, null, inputDom, errorListDom, extraDom);
|
|
85
|
+
return React.createElement(_context.FormContext.Provider, {
|
|
86
|
+
value: subFormContext
|
|
87
|
+
}, React.createElement(_col["default"], Object.assign({}, mergedWrapperCol, {
|
|
88
|
+
className: className
|
|
89
|
+
}), dom));
|
|
90
|
+
};
|
|
91
|
+
var _default = FormItemInput;
|
|
92
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormItemInput.js","sourceRoot":"","sources":["../../src/tntd-form/FormItemInput.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAmC;AACnC,6CAA8B;AAI9B,iDAAwB;AACxB,uCAA8D;AAC9D,4DAAmC;AAgCn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ACH,CAAC,CAAA;AAED,kBAAe,aAAa,CAAA","sourcesContent":["import 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'\nimport { FormContext, FormItemPrefixContext } from './context'\nimport ErrorList from './ErrorList'\nimport type { ValidateStatus } from './FormItem'\n\ninterface FormItemInputMiscProps {\n prefixCls: string\n children: React.ReactNode\n errors: React.ReactNode[]\n warnings: React.ReactNode[]\n marginBottom?: number | null\n onErrorVisibleChanged?: (visible: boolean) => void\n /** @internal do not use in any of your production. */\n _internalItemRender?: {\n mark: string\n render: (\n props: FormItemInputProps & FormItemInputMiscProps,\n domList: {\n input: JSX.Element\n errorList: JSX.Element | null\n extra: JSX.Element | null\n }\n ) => React.ReactNode\n }\n}\n\nexport interface FormItemInputProps {\n wrapperCol?: ColProps\n extra?: React.ReactNode\n status?: ValidateStatus\n help?: React.ReactNode\n fieldId?: string\n}\n\nconst FormItemInput: React.FC<FormItemInputProps & FormItemInputMiscProps> = (props) => {\n const {\n prefixCls,\n status,\n wrapperCol,\n children,\n errors,\n warnings,\n _internalItemRender: formItemRender,\n extra,\n help,\n fieldId,\n marginBottom,\n onErrorVisibleChanged,\n } = props\n const baseClassName = `${prefixCls}-item`\n\n const formContext = React.useContext(FormContext)\n\n const mergedWrapperCol: ColProps = wrapperCol || formContext.wrapperCol || {}\n\n const className = classNames(`${baseClassName}-control`, mergedWrapperCol.className)\n\n // Pass to sub FormItem should not with col info\n const subFormContext = React.useMemo(() => ({ ...formContext }), [formContext])\n delete subFormContext.labelCol\n delete subFormContext.wrapperCol\n\n const inputDom = (\n <div className={`${baseClassName}-control-input`}>\n <div className={`${baseClassName}-control-input-content`}>{children}</div>\n </div>\n )\n const formItemContext = React.useMemo(() => ({ prefixCls, status }), [prefixCls, status])\n const errorListDom =\n marginBottom !== null || errors.length || warnings.length ? (\n <div style={{ display: 'flex', flexWrap: 'nowrap' }}>\n <FormItemPrefixContext.Provider value={formItemContext}>\n <ErrorList\n fieldId={fieldId}\n errors={errors}\n warnings={warnings}\n help={help}\n helpStatus={status}\n className={`${baseClassName}-explain-connected`}\n onVisibleChanged={onErrorVisibleChanged}\n />\n </FormItemPrefixContext.Provider>\n {!!marginBottom && <div style={{ width: 0, height: marginBottom }} />}\n </div>\n ) : null\n\n const extraProps: { id?: string } = {}\n\n if (fieldId) {\n extraProps.id = `${fieldId}_extra`\n }\n\n // If extra = 0, && will goes wrong\n // 0&&error -> 0\n const extraDom = extra ? (\n <div {...extraProps} className={`${baseClassName}-extra`}>\n {extra}\n </div>\n ) : null\n\n const dom =\n formItemRender && formItemRender.mark === 'pro_table_render' && formItemRender.render ? (\n formItemRender.render(props, { input: inputDom, errorList: errorListDom, extra: extraDom })\n ) : (\n <>\n {inputDom}\n {errorListDom}\n {extraDom}\n </>\n )\n return (\n <FormContext.Provider value={subFormContext}>\n <Col {...mergedWrapperCol} className={className}>\n {dom}\n </Col>\n </FormContext.Provider>\n )\n}\n\nexport default FormItemInput\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ColProps } from '../col';
|
|
3
|
+
import type { TooltipProps } from '../tooltip';
|
|
4
|
+
import type { RequiredMark } from './Form';
|
|
5
|
+
import type { FormLabelAlign } from './interface';
|
|
6
|
+
export declare type WrapperTooltipProps = TooltipProps & {
|
|
7
|
+
icon?: React.ReactElement;
|
|
8
|
+
};
|
|
9
|
+
export declare type LabelTooltipType = WrapperTooltipProps | React.ReactNode;
|
|
10
|
+
export interface FormItemLabelProps {
|
|
11
|
+
colon?: boolean;
|
|
12
|
+
htmlFor?: string;
|
|
13
|
+
label?: React.ReactNode;
|
|
14
|
+
labelAlign?: FormLabelAlign;
|
|
15
|
+
labelCol?: ColProps;
|
|
16
|
+
requiredMark?: RequiredMark;
|
|
17
|
+
tooltip?: LabelTooltipType;
|
|
18
|
+
}
|
|
19
|
+
declare const FormItemLabel: React.FC<FormItemLabelProps & {
|
|
20
|
+
required?: boolean;
|
|
21
|
+
prefixCls: string;
|
|
22
|
+
}>;
|
|
23
|
+
export default FormItemLabel;
|
|
24
|
+
//# sourceMappingURL=FormItemLabel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormItemLabel.d.ts","sourceRoot":"","sources":["../../src/tntd-form/FormItemLabel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAItC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAI9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,oBAAY,mBAAmB,GAAG,YAAY,GAAG;IAC/C,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,CAAA;CAC1B,CAAA;AAED,oBAAY,gBAAgB,GAAG,mBAAmB,GAAG,KAAK,CAAC,SAAS,CAAA;AAgBpE,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACvB,UAAU,CAAC,EAAE,cAAc,CAAA;IAC3B,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,OAAO,CAAC,EAAE,gBAAgB,CAAA;CAC3B;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAiG3F,CAAA;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _icon = _interopRequireDefault(require("../icon"));
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _col = _interopRequireDefault(require("../col"));
|
|
11
|
+
var _tooltip = _interopRequireDefault(require("../tooltip"));
|
|
12
|
+
var _context = require("./context");
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
18
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
19
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
20
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
21
|
+
var t = {};
|
|
22
|
+
for (var p in s) {
|
|
23
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
24
|
+
}
|
|
25
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
26
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
27
|
+
}
|
|
28
|
+
return t;
|
|
29
|
+
};
|
|
30
|
+
function toTooltipProps(tooltip) {
|
|
31
|
+
if (!tooltip) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
if (_typeof(tooltip) === 'object' && !React.isValidElement(tooltip)) {
|
|
35
|
+
return tooltip;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
title: tooltip
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
var FormItemLabel = function FormItemLabel(_ref) {
|
|
42
|
+
var prefixCls = _ref.prefixCls,
|
|
43
|
+
label = _ref.label,
|
|
44
|
+
htmlFor = _ref.htmlFor,
|
|
45
|
+
labelCol = _ref.labelCol,
|
|
46
|
+
labelAlign = _ref.labelAlign,
|
|
47
|
+
colon = _ref.colon,
|
|
48
|
+
required = _ref.required,
|
|
49
|
+
requiredMark = _ref.requiredMark,
|
|
50
|
+
tooltip = _ref.tooltip;
|
|
51
|
+
// const [formLocale] = useLocaleReceiver('Form');
|
|
52
|
+
if (!label) return null;
|
|
53
|
+
return React.createElement(_context.FormContext.Consumer, {
|
|
54
|
+
key: "label"
|
|
55
|
+
}, function (_ref2) {
|
|
56
|
+
var _classNames2;
|
|
57
|
+
var vertical = _ref2.vertical,
|
|
58
|
+
contextLabelAlign = _ref2.labelAlign,
|
|
59
|
+
contextLabelCol = _ref2.labelCol,
|
|
60
|
+
labelWrap = _ref2.labelWrap,
|
|
61
|
+
contextColon = _ref2.colon;
|
|
62
|
+
var mergedLabelCol = labelCol || contextLabelCol || {};
|
|
63
|
+
var mergedLabelAlign = labelAlign || contextLabelAlign;
|
|
64
|
+
var labelClsBasic = "".concat(prefixCls, "-item-label");
|
|
65
|
+
var labelColClassName = (0, _classnames["default"])(labelClsBasic, mergedLabelAlign === 'left' && "".concat(labelClsBasic, "-left"), mergedLabelCol.className, _defineProperty({}, "".concat(labelClsBasic, "-wrap"), !!labelWrap));
|
|
66
|
+
var labelChildren = label;
|
|
67
|
+
// Keep label is original where there should have no colon
|
|
68
|
+
var computedColon = colon === true || contextColon !== false && colon !== false;
|
|
69
|
+
var haveColon = computedColon && !vertical;
|
|
70
|
+
// Remove duplicated user input colon
|
|
71
|
+
if (haveColon && typeof label === 'string' && label.trim() !== '') {
|
|
72
|
+
labelChildren = label.replace(/[:|:]\s*$/, '');
|
|
73
|
+
}
|
|
74
|
+
// Tooltip
|
|
75
|
+
var tooltipProps = toTooltipProps(tooltip);
|
|
76
|
+
if (tooltipProps) {
|
|
77
|
+
var _tooltipProps$icon = tooltipProps.icon,
|
|
78
|
+
icon = _tooltipProps$icon === void 0 ? React.createElement(_icon["default"], {
|
|
79
|
+
type: "question-circle"
|
|
80
|
+
}) : _tooltipProps$icon,
|
|
81
|
+
restTooltipProps = __rest(tooltipProps, ["icon"]);
|
|
82
|
+
var tooltipNode = React.createElement(_tooltip["default"], Object.assign({}, restTooltipProps), React.cloneElement(icon, {
|
|
83
|
+
className: "".concat(prefixCls, "-item-tooltip"),
|
|
84
|
+
title: ''
|
|
85
|
+
}));
|
|
86
|
+
labelChildren = React.createElement(React.Fragment, null, labelChildren, tooltipNode);
|
|
87
|
+
}
|
|
88
|
+
// Add required mark if optional
|
|
89
|
+
if (requiredMark === 'optional' && !required) {
|
|
90
|
+
labelChildren = React.createElement(React.Fragment, null, labelChildren, React.createElement("span", {
|
|
91
|
+
className: "".concat(prefixCls, "-item-optional"),
|
|
92
|
+
title: ""
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
var labelClassName = (0, _classnames["default"])((_classNames2 = {}, _defineProperty(_classNames2, "".concat(prefixCls, "-item-required"), required), _defineProperty(_classNames2, "".concat(prefixCls, "-item-required-mark-optional"), requiredMark === 'optional'), _defineProperty(_classNames2, "".concat(prefixCls, "-item-no-colon"), !computedColon), _classNames2));
|
|
96
|
+
return React.createElement(_col["default"], Object.assign({}, mergedLabelCol, {
|
|
97
|
+
className: labelColClassName
|
|
98
|
+
}), React.createElement("label", {
|
|
99
|
+
htmlFor: htmlFor,
|
|
100
|
+
className: labelClassName,
|
|
101
|
+
title: typeof label === 'string' ? label : ''
|
|
102
|
+
}, labelChildren));
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
var _default = FormItemLabel;
|
|
106
|
+
exports["default"] = _default;
|