@unicom-cloud/ui 0.8.96 → 0.8.98
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/Affix.js +1 -1
- package/Carousel.js +1 -1
- package/LiquidFill.js +4 -0
- package/OverflowEllipsis.js +1 -1
- package/PageHeader.js +1 -1
- package/QrCode.js +57 -0
- package/Tour.js +63 -0
- package/Trigger.js +1 -1
- package/_virtual/_commonjsHelpers.js +6 -0
- package/_virtual/index.js +7 -0
- package/_virtual/index2.js +4 -0
- package/affix/index.js +70 -72
- package/alert/index.js +56 -56
- package/anchor/Anchor.js +55 -55
- package/anchor/Link.js +34 -34
- package/anchor/util.js +5 -5
- package/auto-complete/index.js +116 -122
- package/avatar/Avatar.js +33 -33
- package/avatar/Group.js +26 -26
- package/back-top/index.js +58 -61
- package/badge/index.js +46 -46
- package/breadcrumb/Item.js +42 -43
- package/breadcrumb/index.js +47 -47
- package/button/Group.js +6 -6
- package/button/index.js +91 -91
- package/calendar/Month.js +75 -75
- package/calendar/Year.js +35 -35
- package/calendar/header/index.js +25 -25
- package/calendar/index.js +103 -103
- package/card/Grid.js +8 -8
- package/card/Meta.js +16 -16
- package/card/index.js +49 -49
- package/carousel/Arrow.js +19 -19
- package/carousel/Indicator.js +26 -26
- package/carousel/index.js +108 -108
- package/cascader/Cascader.js +178 -191
- package/cascader/base/node.js +133 -136
- package/cascader/base/store.js +82 -85
- package/cascader/panel/List.js +125 -129
- package/cascader/panel/Search.js +79 -81
- package/cascader/util.js +13 -13
- package/checkbox/Checkbox.js +94 -96
- package/checkbox/Group.js +54 -56
- package/checkbox/GroupBlock.js +28 -29
- package/collapse/Collapse.js +45 -45
- package/collapse/Item.js +53 -55
- package/color-picker/ControlBar.js +43 -43
- package/color-picker/InputAlpha.js +12 -12
- package/color-picker/InputHex.js +30 -31
- package/color-picker/InputRgb.js +24 -24
- package/color-picker/Palette.js +18 -18
- package/color-picker/Panel.js +122 -125
- package/color-picker/hooks/useColorPicker.js +85 -88
- package/color-picker/hooks/useControlBlock.js +38 -40
- package/color-picker/index.js +47 -47
- package/comment/index.js +29 -29
- package/components/common/higher-order/with-speech-synthesis/index.js +37 -40
- package/components/common/hooks/useId.js +8 -8
- package/components/common/hooks/useInView.js +16 -16
- package/components/common/hooks/useIntersectionObserver.js +1 -1
- package/components/common/hooks/useKeyboardEvent.js +9 -10
- package/components/common/hooks/useOverflowHidden.js +1 -4
- package/components/common/hooks/usePersistCallback.js +7 -7
- package/components/common/hooks/useStateCallback.js +9 -10
- package/components/common/hooks/useWindowSize.js +8 -8
- package/components/common/space/index.js +9 -7
- package/components/common/utils/convertToDurationBasedOnTimeUnits.js +6 -0
- package/components/common/utils/dom.js +27 -29
- package/components/common/utils/findScrollParent.js +17 -0
- package/components/common/utils/intersectionObserver.js +21 -0
- package/components/common/utils/is.js +99 -109
- package/components/common/utils/mutationObserver.js +19 -0
- package/components/common/utils/reactDOM.js +34 -34
- package/components/common/utils/resizeObserver.js +21 -0
- package/copy/index.js +38 -40
- package/date-picker/Picker.js +290 -295
- package/date-picker/RangePicker.js +367 -372
- package/date-picker/index.js +33 -35
- package/date-picker/panel/Body.js +46 -47
- package/date-picker/panel/Header.js +33 -33
- package/date-picker/panel/Shortcut.js +31 -31
- package/date-picker/panel/date/index.js +85 -85
- package/date-picker/panel/month/index.js +59 -59
- package/date-picker/panel/quarter/index.js +67 -70
- package/date-picker/panel/range/index.js +101 -101
- package/date-picker/panel/year/index.js +39 -39
- package/date-picker/util.js +17 -18
- package/descriptions/index.js +62 -62
- package/details/index.js +53 -55
- package/development/index.js +9 -9
- package/dist/tinycolor/chunk/BOzCVdr0.js +1 -1
- package/dist/validate/src/index.js +5 -5
- package/dist/validate/src/util.js +1 -1
- package/divider/index.js +21 -21
- package/draggable/Item.js +35 -35
- package/draggable/index.js +22 -22
- package/drawer/Drawer.js +142 -147
- package/dropdown/Button.js +48 -48
- package/dropdown/index.js +88 -92
- package/empty/index.js +16 -16
- package/form/Control.js +211 -225
- package/form/Form.js +109 -113
- package/form/FormItem.js +118 -120
- package/form/FormList.js +60 -66
- package/form/FormProvider.js +31 -34
- package/form/hook/useContext.js +17 -19
- package/form/hook/useState.js +22 -23
- package/form/hook/useWatch.js +26 -27
- package/form/promisify.js +14 -18
- package/form/store.js +304 -316
- package/form/util.js +14 -15
- package/grid/Col.js +64 -64
- package/grid/Grid.js +51 -51
- package/grid/GridItem.js +48 -48
- package/grid/Row.js +39 -39
- package/hooks/useVerificationCode.js +41 -43
- package/hooks/useWatermark.js +89 -92
- package/icon/index.js +23 -24
- package/icon-hover/index.js +16 -16
- package/icons/file.js +11 -11
- package/image/Image.js +140 -141
- package/image/ImagePreview.js +252 -255
- package/image/ImagePreviewArrow.js +25 -25
- package/image/ImagePreviewGroup.js +62 -62
- package/image/util/getScale.js +25 -28
- package/index.js +684 -675
- package/input/Button.js +48 -50
- package/input/Group.js +9 -9
- package/input/Input.js +145 -154
- package/input/InputElement.js +108 -115
- package/input/Password.js +38 -38
- package/input/Search.js +51 -55
- package/input/Textarea.js +80 -81
- package/input/useComposition.js +23 -23
- package/input-number/decimal.js +59 -62
- package/input-number/index.js +139 -141
- package/input-tag/InputTag.js +222 -230
- package/layout/Content.js +6 -6
- package/layout/Footer.js +8 -8
- package/layout/Header.js +7 -7
- package/layout/Sider.js +88 -90
- package/layout/index.js +30 -30
- package/link/index.js +45 -46
- package/liquid-fill/LiquidFill.js +226 -0
- package/liquid-fill/LiquidFill2.js +3 -0
- package/liquid-fill/index.js +4 -0
- package/list/Item.js +28 -28
- package/list/Meta.js +12 -12
- package/list/index.js +146 -148
- package/mentions/index.js +75 -76
- package/menu/Item.js +58 -58
- package/menu/Menu.js +125 -127
- package/menu/OverflowWrap.js +39 -40
- package/menu/sub-menu/Inline.js +45 -45
- package/menu/util.js +26 -28
- package/message/index.js +96 -99
- package/message/useMessage.js +26 -27
- package/modal/Confirm.js +47 -49
- package/modal/Modal.js +250 -257
- package/modal/use-modal/Hook.js +26 -28
- package/modal/use-modal/index.js +46 -49
- package/notice/index.js +89 -90
- package/notification/index.js +60 -65
- package/notification/withNotification.js +35 -35
- package/overflow-ellipsis/OverflowItem.js +19 -20
- package/overflow-ellipsis/index.js +45 -46
- package/package.json +1 -1
- package/page-header/index.js +45 -45
- package/pagination/PageItem.js +87 -91
- package/pagination/PageJumper.js +40 -41
- package/pagination/PageOption.js +31 -35
- package/pagination/Pagination.js +162 -163
- package/picker/Input.js +90 -96
- package/picker/InputRange.js +115 -122
- package/popconfirm/index.js +98 -100
- package/popover/index.js +28 -28
- package/portal/Portal.js +10 -11
- package/progress/index.js +36 -36
- package/qr-code/index.js +99 -0
- package/qr-code/interface.js +1 -0
- package/radio/Group.js +48 -48
- package/radio/GroupBlock.js +32 -33
- package/radio/Radio.js +62 -64
- package/rate/index.js +88 -88
- package/resize-box/ResizeTrigger.js +39 -39
- package/resize-box/Split.js +92 -96
- package/resize-box/SplitGroup.js +116 -122
- package/resize-box/index.js +112 -115
- package/result/index.js +44 -44
- package/select/Option.js +53 -56
- package/select/Select.js +365 -381
- package/select/util.js +95 -99
- package/select-view/Core.js +159 -160
- package/skeleton/index.js +23 -23
- package/slider/Button.js +84 -92
- package/slider/Input.js +47 -49
- package/slider/Tick.js +28 -31
- package/slider/index.js +107 -107
- package/space/index.js +26 -26
- package/space-/index.js +51 -51
- package/spin/DotLoading.js +8 -8
- package/spin/index.js +47 -47
- package/statistic/Countdown.js +37 -37
- package/statistic/index.js +58 -58
- package/steps/Step.js +42 -42
- package/steps/index.js +54 -54
- package/style.css +1 -1
- package/switch/index.js +77 -78
- package/table/ColGroup.js +36 -37
- package/table/Table.js +447 -450
- package/table/hook/useExpand.js +24 -24
- package/table/hook/useRowSelection.js +62 -62
- package/table/summary/Row.js +16 -17
- package/table/tbody/Td.js +119 -118
- package/table/tbody/Tr.js +119 -121
- package/table/tbody/index.js +62 -63
- package/table/th-resizable/index.js +30 -30
- package/table/thead/Column.js +148 -148
- package/table/thead/index.js +87 -88
- package/tabs/Tab.js +55 -55
- package/tabs/TabContent.js +8 -8
- package/tabs/TabPane.js +15 -15
- package/tabs/hook/useHeaderScroll.js +36 -36
- package/tabs/tab-header/TabInk.js +31 -33
- package/tabs/tab-header/TabNavIcon.js +34 -35
- package/tabs/tab-header/index.js +192 -195
- package/tag/index.js +94 -97
- package/time-picker/Picker.js +167 -172
- package/time-picker/RangePicker.js +28 -28
- package/time-picker/TimePicker.js +146 -146
- package/timeline/Item.js +46 -46
- package/timeline/Timeline.js +52 -52
- package/tooltip/index.js +89 -95
- package/tour/index.js +289 -0
- package/transfer/Item.js +54 -54
- package/transfer/List.js +134 -136
- package/transfer/index.js +91 -91
- package/tree/Animation.js +49 -52
- package/tree/Node.js +114 -122
- package/tree/NodeList.js +51 -51
- package/tree/Tree.js +386 -393
- package/tree-select/List.js +71 -72
- package/tree-select/Select.js +135 -143
- package/tree-select/hook/useKeyCache.js +39 -39
- package/tree-select/hook/useStateValue.js +12 -12
- package/trigger/getPopupStyle.js +60 -61
- package/trigger/index.js +337 -346
- package/types/common/space/interface.d.ts +1 -1
- package/types/common/utils/convertToDurationBasedOnTimeUnits.d.ts +3 -0
- package/types/common/utils/findScrollParent.d.ts +2 -0
- package/types/common/utils/index.d.ts +5 -0
- package/types/common/utils/intersectionObserver.d.ts +2 -0
- package/types/common/utils/mutationObserver.d.ts +2 -0
- package/types/common/utils/resizeObserver.d.ts +2 -0
- package/types/pc/config-provider/interface.d.ts +6 -0
- package/types/pc/index.d.ts +3 -0
- package/types/pc/liquid-fill/LiquidFill.d.ts +115 -0
- package/types/pc/liquid-fill/LiquidFill2.d.ts +1 -0
- package/types/pc/liquid-fill/index.d.ts +2 -0
- package/types/pc/qr-code/index.d.ts +34 -0
- package/types/pc/qr-code/interface.d.ts +39 -0
- package/types/pc/table/interface.d.ts +2 -2
- package/types/pc/tour/index.d.ts +42 -0
- package/types/pc/utils/convertToDurationBasedOnTimeUnits.d.ts +3 -0
- package/types/pc/utils/findScrollParent.d.ts +2 -0
- package/types/pc/utils/index.d.ts +5 -0
- package/types/pc/utils/intersectionObserver.d.ts +2 -0
- package/types/pc/utils/mutationObserver.d.ts +2 -0
- package/types/pc/utils/names.d.ts +18 -0
- package/types/pc/utils/resizeObserver.d.ts +2 -0
- package/typography/Base.js +79 -81
- package/typography/EditContent.js +30 -33
- package/typography/Ellipsis.js +77 -73
- package/typography/Operations.js +50 -52
- package/typography/Paragraph.js +7 -7
- package/typography/Typography.js +7 -7
- package/typography/useEllipsis.js +105 -106
- package/upload/TriggerNode.js +69 -76
- package/upload/Upload.js +84 -87
- package/upload/Uploader.js +115 -118
- package/upload/list/PictureItem.js +61 -71
- package/upload/list/TextItem.js +61 -67
- package/upload/list/UploadProgress.js +42 -49
- package/upload/list/index.js +48 -49
- package/upload/request_.js +37 -38
- package/upload/util.js +39 -39
- package/utils/convertToDurationBasedOnTimeUnits.js +6 -0
- package/utils/findScrollParent.js +4 -0
- package/utils/index.js +281 -278
- package/utils/intersectionObserver.js +4 -0
- package/utils/mutationObserver.js +4 -0
- package/utils/names.js +12 -0
- package/utils/resizeObserver.js +4 -0
- package/verification-code/VerificationCode.js +50 -51
- package/version/index.js +1 -1
- package/virtual-list/VirtualList.js +243 -244
- package/virtual-list/util/item.js +3 -4
- package/watermark/Watermark.js +27 -31
- package/components/common/utils/resizeObserverEffect.js +0 -23
- package/types/common/utils/resizeObserverEffect.d.ts +0 -2
- package/types/pc/utils/resizeObserverEffect.d.ts +0 -2
- package/utils/resizeObserverEffect.js +0 -4
package/form/Form.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { forwardRef as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { omit as
|
|
11
|
-
import { FormProviderContext as
|
|
12
|
-
import
|
|
13
|
-
import { ID_SUFFIX as
|
|
14
|
-
import
|
|
15
|
-
function
|
|
16
|
-
const
|
|
17
|
-
return
|
|
2
|
+
import q from "../dist/scroll-into-view-if-needed/src/index.js";
|
|
3
|
+
import D from "lodash/isPlainObject";
|
|
4
|
+
import j from "lodash/merge";
|
|
5
|
+
import { forwardRef as k, useContext as h, useRef as O, useEffect as A, useImperativeHandle as _ } from "react";
|
|
6
|
+
import H from "../config-provider/ConfigProvider.js";
|
|
7
|
+
import U from "../components/common/hooks/useCreate.js";
|
|
8
|
+
import W from "../components/common/hooks/useMergeProps.js";
|
|
9
|
+
import X from "@unicom-cloud/utils/class-name";
|
|
10
|
+
import { omit as B } from "../components/common/utils/omit.js";
|
|
11
|
+
import { FormProviderContext as G, FormContext as J } from "./context.js";
|
|
12
|
+
import K from "./hook/useForm.js";
|
|
13
|
+
import { ID_SUFFIX as L } from "./util.js";
|
|
14
|
+
import Q from "../config-provider/context.js";
|
|
15
|
+
function u(i, c) {
|
|
16
|
+
const t = c.replace(/[[.]/g, "_").replace(/\]/g, "");
|
|
17
|
+
return i ? `${i}-${t}` : `${t}`;
|
|
18
18
|
}
|
|
19
|
-
const
|
|
19
|
+
const Y = {
|
|
20
20
|
layout: "horizontal",
|
|
21
21
|
labelCol: { span: 5, offset: 0 },
|
|
22
22
|
labelAlign: "right",
|
|
@@ -24,106 +24,102 @@ const re = {
|
|
|
24
24
|
requiredSymbol: !0,
|
|
25
25
|
wrapper: "form",
|
|
26
26
|
validateTrigger: "onChange"
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
(h = n.componentConfig) == null ? void 0 : h.Form
|
|
27
|
+
}, Z = (i, c) => {
|
|
28
|
+
const t = h(Q), s = h(G), p = O(null), [n] = K(
|
|
29
|
+
i.form
|
|
30
|
+
), o = W(
|
|
31
|
+
i,
|
|
32
|
+
Y,
|
|
33
|
+
t.componentConfig?.Form
|
|
35
34
|
), {
|
|
36
|
-
layout:
|
|
37
|
-
labelCol:
|
|
38
|
-
wrapperCol:
|
|
39
|
-
wrapper:
|
|
40
|
-
id:
|
|
41
|
-
requiredSymbol:
|
|
42
|
-
labelAlign:
|
|
43
|
-
disabled:
|
|
44
|
-
colon:
|
|
45
|
-
className:
|
|
46
|
-
validateTrigger:
|
|
47
|
-
prefixCls:
|
|
48
|
-
validateMessages:
|
|
49
|
-
...
|
|
50
|
-
} =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}),
|
|
54
|
-
let
|
|
55
|
-
return
|
|
56
|
-
}, [
|
|
57
|
-
const
|
|
58
|
-
if (!
|
|
35
|
+
layout: f,
|
|
36
|
+
labelCol: S,
|
|
37
|
+
wrapperCol: x,
|
|
38
|
+
wrapper: P,
|
|
39
|
+
id: g,
|
|
40
|
+
requiredSymbol: $,
|
|
41
|
+
labelAlign: v,
|
|
42
|
+
disabled: y,
|
|
43
|
+
colon: V,
|
|
44
|
+
className: R,
|
|
45
|
+
validateTrigger: w,
|
|
46
|
+
prefixCls: I,
|
|
47
|
+
validateMessages: M,
|
|
48
|
+
...N
|
|
49
|
+
} = o, l = I || t.getPrefixCls?.("form"), z = t.rtl, C = "size" in o ? o.size : t.size, F = n.getInnerMethods(!0);
|
|
50
|
+
U(() => {
|
|
51
|
+
F.innerSetInitialValues(o.initialValues);
|
|
52
|
+
}), A(() => {
|
|
53
|
+
let e;
|
|
54
|
+
return s.register && (e = s.register(o.id, n)), e;
|
|
55
|
+
}, [o.id, n]), n.scrollToField = (e, r) => {
|
|
56
|
+
const a = p.current, b = o.id;
|
|
57
|
+
if (!a)
|
|
59
58
|
return;
|
|
60
|
-
let
|
|
61
|
-
`#${
|
|
59
|
+
let m = a.querySelector(
|
|
60
|
+
`#${u(b, e)}`
|
|
62
61
|
);
|
|
63
|
-
|
|
64
|
-
`#${
|
|
65
|
-
)),
|
|
62
|
+
m || (m = a.querySelector(
|
|
63
|
+
`#${u(b, e)}${L}`
|
|
64
|
+
)), m && q(m, {
|
|
66
65
|
behavior: "smooth",
|
|
67
66
|
block: "nearest",
|
|
68
67
|
scrollMode: "if-needed",
|
|
69
|
-
...
|
|
68
|
+
...r
|
|
70
69
|
});
|
|
71
|
-
},
|
|
72
|
-
onValuesChange: (
|
|
73
|
-
|
|
74
|
-
(r = e.onValuesChange) == null || r.call(e, o, s), (i = t.onFormValuesChange) == null || i.call(t, e.id, o);
|
|
70
|
+
}, F.innerSetCallbacks({
|
|
71
|
+
onValuesChange: (e, r) => {
|
|
72
|
+
o.onValuesChange?.(e, r), s.onFormValuesChange?.(o.id, e);
|
|
75
73
|
},
|
|
76
|
-
onChange:
|
|
77
|
-
onValidateFail: (
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
Object.keys(
|
|
83
|
-
|
|
74
|
+
onChange: o.onChange,
|
|
75
|
+
onValidateFail: (e) => {
|
|
76
|
+
const r = o.scrollToFirstError;
|
|
77
|
+
if (r) {
|
|
78
|
+
const a = D(r) ? r : {};
|
|
79
|
+
n.scrollToField(
|
|
80
|
+
Object.keys(e)[0],
|
|
81
|
+
a
|
|
84
82
|
);
|
|
85
83
|
}
|
|
86
84
|
},
|
|
87
|
-
onSubmitFailed:
|
|
88
|
-
onSubmit: (
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return (i = t.onFormSubmit) == null || i.call(t, e.id, o), s;
|
|
85
|
+
onSubmitFailed: o.onSubmitFailed,
|
|
86
|
+
onSubmit: (e) => {
|
|
87
|
+
const r = o.onSubmit?.(e);
|
|
88
|
+
return s.onFormSubmit?.(o.id, e), r;
|
|
92
89
|
},
|
|
93
|
-
onReset: (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return (i = t == null ? void 0 : t.onFormReset) == null || i.call(t, e.id, o), s;
|
|
90
|
+
onReset: (e) => {
|
|
91
|
+
const r = o.onReset?.(e);
|
|
92
|
+
return s?.onFormReset?.(o.id, e), r;
|
|
97
93
|
}
|
|
98
94
|
});
|
|
99
|
-
const
|
|
100
|
-
requiredSymbol:
|
|
101
|
-
labelAlign:
|
|
102
|
-
disabled:
|
|
103
|
-
colon:
|
|
104
|
-
labelCol:
|
|
105
|
-
wrapperCol:
|
|
106
|
-
layout:
|
|
107
|
-
store:
|
|
108
|
-
prefixCls:
|
|
109
|
-
validateTrigger:
|
|
110
|
-
validateMessages:
|
|
95
|
+
const T = {
|
|
96
|
+
requiredSymbol: $,
|
|
97
|
+
labelAlign: v,
|
|
98
|
+
disabled: y,
|
|
99
|
+
colon: V,
|
|
100
|
+
labelCol: S,
|
|
101
|
+
wrapperCol: x,
|
|
102
|
+
layout: f,
|
|
103
|
+
store: n,
|
|
104
|
+
prefixCls: l,
|
|
105
|
+
validateTrigger: w,
|
|
106
|
+
validateMessages: j(
|
|
111
107
|
{},
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
t.locale?.Form?.validateMessages,
|
|
109
|
+
M
|
|
114
110
|
),
|
|
115
|
-
getFormElementId: (
|
|
116
|
-
},
|
|
117
|
-
return
|
|
118
|
-
...
|
|
111
|
+
getFormElementId: (e) => u(g, e)
|
|
112
|
+
}, E = J;
|
|
113
|
+
return _(c, () => ({
|
|
114
|
+
...n,
|
|
119
115
|
getRootDOMNode() {
|
|
120
116
|
return p.current;
|
|
121
117
|
}
|
|
122
|
-
})), /* @__PURE__ */ d(
|
|
123
|
-
|
|
118
|
+
})), /* @__PURE__ */ d(H, { ...t, childrenName: "Form", size: C, children: /* @__PURE__ */ d(E.Provider, { value: T, children: /* @__PURE__ */ d(
|
|
119
|
+
P,
|
|
124
120
|
{
|
|
125
121
|
ref: p,
|
|
126
|
-
...
|
|
122
|
+
...B(N, [
|
|
127
123
|
"form",
|
|
128
124
|
"size",
|
|
129
125
|
"initialValues",
|
|
@@ -135,27 +131,27 @@ const re = {
|
|
|
135
131
|
"onSubmitFailed",
|
|
136
132
|
"onReset"
|
|
137
133
|
]),
|
|
138
|
-
...
|
|
139
|
-
className:
|
|
140
|
-
|
|
141
|
-
`${
|
|
142
|
-
`${
|
|
143
|
-
{ [`${
|
|
144
|
-
|
|
134
|
+
...o.wrapperProps,
|
|
135
|
+
className: X(
|
|
136
|
+
l,
|
|
137
|
+
`${l}-${f}`,
|
|
138
|
+
`${l}-size-${C}`,
|
|
139
|
+
{ [`${l}-rtl`]: z },
|
|
140
|
+
R
|
|
145
141
|
),
|
|
146
|
-
style:
|
|
147
|
-
onSubmit: (
|
|
148
|
-
|
|
142
|
+
style: o.style,
|
|
143
|
+
onSubmit: (e) => {
|
|
144
|
+
e.preventDefault(), e.stopPropagation(), n.submit();
|
|
149
145
|
},
|
|
150
|
-
onReset: (
|
|
151
|
-
|
|
146
|
+
onReset: (e) => {
|
|
147
|
+
e.preventDefault(), e.stopPropagation(), n.resetFields();
|
|
152
148
|
},
|
|
153
|
-
id:
|
|
154
|
-
children:
|
|
149
|
+
id: g,
|
|
150
|
+
children: o.children
|
|
155
151
|
}
|
|
156
152
|
) }) });
|
|
157
|
-
},
|
|
158
|
-
|
|
153
|
+
}, ee = k(Z);
|
|
154
|
+
ee.displayName = "Form";
|
|
159
155
|
export {
|
|
160
|
-
|
|
156
|
+
ee as default
|
|
161
157
|
};
|
package/form/FormItem.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { jsx as i, jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import { jsx as i, jsxs as E, Fragment as ie } from "react/jsx-runtime";
|
|
2
|
+
import V, { forwardRef as ae, useContext as F, useState as O, useRef as me, useEffect as de, useMemo as U, createElement as _, cloneElement as z } from "react";
|
|
3
|
+
import ce from "lodash/isArray";
|
|
4
|
+
import pe from "lodash/isFunction";
|
|
5
|
+
import h from "lodash/isPlainObject";
|
|
6
|
+
import y from "lodash/isUndefined";
|
|
7
7
|
import "../config-provider/ConfigProvider.js";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { PqbCSSTransition as
|
|
11
|
-
import
|
|
12
|
-
import { omit as
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import { FormItemContext as
|
|
16
|
-
import { VALIDATE_STATUS as
|
|
17
|
-
import { formatValidateMsg as
|
|
18
|
-
import
|
|
19
|
-
const
|
|
20
|
-
prefixCls:
|
|
21
|
-
help:
|
|
8
|
+
import K from "../grid/index.js";
|
|
9
|
+
import ue from "../components/common/hooks/useMergeProps.js";
|
|
10
|
+
import { PqbCSSTransition as fe } from "../components/common/utils/PqbCSSTransition.js";
|
|
11
|
+
import C from "@unicom-cloud/utils/class-name";
|
|
12
|
+
import { omit as be } from "../components/common/utils/omit.js";
|
|
13
|
+
import $ from "./Control.js";
|
|
14
|
+
import ge from "./FormLabel.js";
|
|
15
|
+
import { FormItemContext as H, FormListContext as he, FormContext as W } from "./context.js";
|
|
16
|
+
import { VALIDATE_STATUS as k } from "./interface.js";
|
|
17
|
+
import { formatValidateMsg as Ce } from "./util.js";
|
|
18
|
+
import ye from "../config-provider/context.js";
|
|
19
|
+
const xe = K.Row, G = K.Col, ve = ({
|
|
20
|
+
prefixCls: f,
|
|
21
|
+
help: b,
|
|
22
22
|
errors: e,
|
|
23
|
-
warnings:
|
|
23
|
+
warnings: I
|
|
24
24
|
}) => {
|
|
25
|
-
const
|
|
25
|
+
const g = e.map((p, d) => {
|
|
26
26
|
if (p)
|
|
27
27
|
return /* @__PURE__ */ i("div", { role: "alert", children: p.message }, d);
|
|
28
28
|
}), c = [];
|
|
29
|
-
|
|
29
|
+
I.map((p, d) => {
|
|
30
30
|
c.push(
|
|
31
|
-
/* @__PURE__ */ i("div", { role: "alert", className: `${
|
|
31
|
+
/* @__PURE__ */ i("div", { role: "alert", className: `${f}-message-help-warning`, children: p }, d)
|
|
32
32
|
);
|
|
33
33
|
});
|
|
34
|
-
const
|
|
34
|
+
const x = !y(b) || !!c.length, u = x || !!g.length;
|
|
35
35
|
return u && /* @__PURE__ */ i(
|
|
36
|
-
|
|
36
|
+
fe,
|
|
37
37
|
{
|
|
38
38
|
in: u,
|
|
39
39
|
appear: !0,
|
|
@@ -43,111 +43,109 @@ const Ne = Y.Row, X = Y.Col, Se = ({
|
|
|
43
43
|
children: /* @__PURE__ */ i(
|
|
44
44
|
"div",
|
|
45
45
|
{
|
|
46
|
-
className:
|
|
47
|
-
[`${
|
|
46
|
+
className: C(`${f}-message`, {
|
|
47
|
+
[`${f}-message-help`]: x
|
|
48
48
|
}),
|
|
49
|
-
children:
|
|
50
|
-
|
|
49
|
+
children: y(b) ? /* @__PURE__ */ E(ie, { children: [
|
|
50
|
+
g.length > 0 && g,
|
|
51
51
|
c.length > 0 && c
|
|
52
|
-
] }) :
|
|
52
|
+
] }) : b
|
|
53
53
|
}
|
|
54
54
|
)
|
|
55
55
|
}
|
|
56
56
|
);
|
|
57
|
-
},
|
|
57
|
+
}, we = {
|
|
58
58
|
trigger: "onChange",
|
|
59
59
|
triggerPropName: "value"
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (x.current)
|
|
60
|
+
}, Fe = (f, b) => {
|
|
61
|
+
const e = ue(f, we), { getPrefixCls: I, prefixCls: g } = F(ye), c = F(H), x = F(he), [u, p] = O(null), [d, T] = O(null), r = F(W), l = r.prefixCls || I?.("form"), q = e.layout || r.layout, B = e.labelAlign || r.labelAlign, N = me(!1), J = (n, t = {}) => {
|
|
62
|
+
if (N.current)
|
|
64
63
|
return;
|
|
65
|
-
const { errors:
|
|
66
|
-
p((
|
|
67
|
-
const
|
|
68
|
-
return
|
|
69
|
-
}),
|
|
70
|
-
const
|
|
71
|
-
return
|
|
64
|
+
const { errors: m, warnings: s } = t || {};
|
|
65
|
+
p((o) => {
|
|
66
|
+
const a = { ...o || {} };
|
|
67
|
+
return m ? a[n] = m : delete a[n], a;
|
|
68
|
+
}), T((o) => {
|
|
69
|
+
const a = { ...o || {} };
|
|
70
|
+
return s && s.length ? a[n] = s : delete a[n], a;
|
|
72
71
|
});
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
}, Q = h(e.noStyle) && e.noStyle.showErrorTip && c.updateFormItem ? c.updateFormItem : J;
|
|
73
|
+
de(() => (N.current = !1, () => {
|
|
74
|
+
N.current = !0, p(null), T(null);
|
|
76
75
|
}), []);
|
|
77
|
-
const
|
|
76
|
+
const X = {
|
|
78
77
|
...r,
|
|
79
|
-
validateMessages: r.validateMessages &&
|
|
78
|
+
validateMessages: r.validateMessages && Ce(r.validateMessages, {
|
|
80
79
|
label: e.label
|
|
81
80
|
}),
|
|
82
81
|
prefixCls: l,
|
|
83
|
-
updateFormItem:
|
|
82
|
+
updateFormItem: Q,
|
|
84
83
|
disabled: "disabled" in e ? e.disabled : r.disabled
|
|
85
|
-
}, { label:
|
|
86
|
-
[`${l}-label-item-left`]:
|
|
87
|
-
}),
|
|
88
|
-
if (
|
|
89
|
-
return
|
|
90
|
-
if (
|
|
91
|
-
return
|
|
92
|
-
if (
|
|
93
|
-
return
|
|
94
|
-
}, [u, d,
|
|
84
|
+
}, { label: A, extra: D, className: Y, style: Z, validateStatus: v, hidden: ee, ...re } = e, te = C(`${l}-label-item`, {
|
|
85
|
+
[`${l}-label-item-left`]: B === "left"
|
|
86
|
+
}), L = u ? Object.values(u) : [], S = d ? Object.values(d).reduce((n, t) => n.concat(t), []) : [], w = U(() => {
|
|
87
|
+
if (v)
|
|
88
|
+
return v;
|
|
89
|
+
if (L.length)
|
|
90
|
+
return k.error;
|
|
91
|
+
if (S.length)
|
|
92
|
+
return k.warning;
|
|
93
|
+
}, [u, d, v]), M = U(() => !y(e.help) || S.length > 0, [e.help, d]), oe = C(
|
|
95
94
|
`${l}-item`,
|
|
96
95
|
{
|
|
97
|
-
[`${l}-item-error`]:
|
|
98
|
-
[`${l}-item-status-${
|
|
99
|
-
[`${l}-item-has-help`]:
|
|
100
|
-
[`${l}-item-hidden`]:
|
|
101
|
-
[`${l}-item-has-feedback`]:
|
|
96
|
+
[`${l}-item-error`]: M || !v && w === k.error,
|
|
97
|
+
[`${l}-item-status-${w}`]: w,
|
|
98
|
+
[`${l}-item-has-help`]: M,
|
|
99
|
+
[`${l}-item-hidden`]: ee,
|
|
100
|
+
[`${l}-item-has-feedback`]: w && e.hasFeedback
|
|
102
101
|
},
|
|
103
|
-
`${l}-layout-${
|
|
104
|
-
|
|
105
|
-
),
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
S,
|
|
102
|
+
`${l}-layout-${q}`,
|
|
103
|
+
Y
|
|
104
|
+
), j = () => {
|
|
105
|
+
const { field: n, children: t } = e, m = "disabled" in e ? e.disabled : r.disabled;
|
|
106
|
+
if (pe(t)) {
|
|
107
|
+
const { key: s, ...o } = e ?? {};
|
|
108
|
+
return /* @__PURE__ */ _(
|
|
109
|
+
$,
|
|
112
110
|
{
|
|
113
|
-
disabled:
|
|
114
|
-
...
|
|
115
|
-
key: n ||
|
|
116
|
-
_key: n ||
|
|
111
|
+
disabled: m,
|
|
112
|
+
...o,
|
|
113
|
+
key: n || s,
|
|
114
|
+
_key: n || s
|
|
117
115
|
},
|
|
118
|
-
(...
|
|
119
|
-
...
|
|
116
|
+
(...a) => t(
|
|
117
|
+
...a
|
|
120
118
|
)
|
|
121
119
|
);
|
|
122
120
|
}
|
|
123
|
-
if (
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
return
|
|
121
|
+
if (ce(t)) {
|
|
122
|
+
const s = V.Children.map(t, (o, a) => {
|
|
123
|
+
const R = h(o) && o.key || a, ne = h(o) && "disabled" in o.props, se = !y(m) && !ne ? { key: R, disabled: m } : { key: R };
|
|
124
|
+
return h(o) ? z(o, se) : o;
|
|
127
125
|
});
|
|
128
|
-
return /* @__PURE__ */ i(
|
|
126
|
+
return /* @__PURE__ */ i($, { ...e, field: void 0, children: s });
|
|
129
127
|
}
|
|
130
|
-
if (
|
|
128
|
+
if (V.Children.count(t) == 1) {
|
|
131
129
|
if (n) {
|
|
132
|
-
const
|
|
133
|
-
return /* @__PURE__ */
|
|
130
|
+
const s = x?.getItemKey?.(n) || n;
|
|
131
|
+
return /* @__PURE__ */ _($, { disabled: m, ...e, key: s, _key: s }, t);
|
|
134
132
|
}
|
|
135
|
-
if (
|
|
136
|
-
if (
|
|
133
|
+
if (h(t)) {
|
|
134
|
+
if (t.type?.isFormControl)
|
|
137
135
|
return t;
|
|
138
|
-
const
|
|
139
|
-
return /* @__PURE__ */ i(
|
|
136
|
+
const o = !("disabled" in t.props) && !y(m) ? { disabled: m } : null;
|
|
137
|
+
return /* @__PURE__ */ i($, { ...e, field: void 0, children: o ? z(t, o) : t });
|
|
140
138
|
}
|
|
141
139
|
}
|
|
142
140
|
return t;
|
|
143
|
-
},
|
|
141
|
+
}, le = H, P = {
|
|
144
142
|
...r
|
|
145
143
|
};
|
|
146
|
-
return e.noStyle || (
|
|
147
|
-
|
|
144
|
+
return e.noStyle || (P.wrapperCol = void 0, P.labelCol = void 0), /* @__PURE__ */ i(W.Provider, { value: P, children: /* @__PURE__ */ i(le.Provider, { value: X, children: e.noStyle ? j() : /* @__PURE__ */ E(
|
|
145
|
+
xe,
|
|
148
146
|
{
|
|
149
|
-
ref:
|
|
150
|
-
...
|
|
147
|
+
ref: b,
|
|
148
|
+
...be(re, [
|
|
151
149
|
"tooltip",
|
|
152
150
|
"children",
|
|
153
151
|
"prefixCls",
|
|
@@ -177,29 +175,29 @@ const Ne = Y.Row, X = Y.Col, Se = ({
|
|
|
177
175
|
"requiredSymbol",
|
|
178
176
|
"isFormList"
|
|
179
177
|
]),
|
|
180
|
-
className:
|
|
181
|
-
div:
|
|
182
|
-
style:
|
|
178
|
+
className: oe,
|
|
179
|
+
div: q !== "horizontal",
|
|
180
|
+
style: Z,
|
|
183
181
|
children: [
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
A ? /* @__PURE__ */ i(
|
|
183
|
+
G,
|
|
186
184
|
{
|
|
187
185
|
...e.labelCol || r.labelCol,
|
|
188
|
-
className:
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
186
|
+
className: C(
|
|
187
|
+
te,
|
|
188
|
+
e.labelCol?.className,
|
|
189
|
+
r.labelCol?.className,
|
|
192
190
|
{
|
|
193
191
|
[`${l}-label-item-flex`]: !e.labelCol && !r.labelCol
|
|
194
192
|
}
|
|
195
193
|
),
|
|
196
194
|
children: /* @__PURE__ */ i(
|
|
197
|
-
|
|
195
|
+
ge,
|
|
198
196
|
{
|
|
199
197
|
tooltip: e.tooltip,
|
|
200
|
-
htmlFor: e.field &&
|
|
201
|
-
label:
|
|
202
|
-
prefix:
|
|
198
|
+
htmlFor: e.field && r?.getFormElementId?.(e.field),
|
|
199
|
+
label: A,
|
|
200
|
+
prefix: g,
|
|
203
201
|
requiredSymbol: "requiredSymbol" in e ? e.requiredSymbol : r.requiredSymbol,
|
|
204
202
|
required: e.required,
|
|
205
203
|
rules: e.rules,
|
|
@@ -208,33 +206,33 @@ const Ne = Y.Row, X = Y.Col, Se = ({
|
|
|
208
206
|
)
|
|
209
207
|
}
|
|
210
208
|
) : null,
|
|
211
|
-
/* @__PURE__ */
|
|
212
|
-
|
|
209
|
+
/* @__PURE__ */ E(
|
|
210
|
+
G,
|
|
213
211
|
{
|
|
214
|
-
className:
|
|
212
|
+
className: C(`${l}-item-wrapper`, {
|
|
215
213
|
[`${l}-item-wrapper-flex`]: !e.wrapperCol && !r.wrapperCol
|
|
216
214
|
}),
|
|
217
215
|
...e.wrapperCol || r.wrapperCol,
|
|
218
216
|
children: [
|
|
219
|
-
|
|
217
|
+
j(),
|
|
220
218
|
/* @__PURE__ */ i(
|
|
221
|
-
|
|
219
|
+
ve,
|
|
222
220
|
{
|
|
223
221
|
prefixCls: l,
|
|
224
222
|
help: e.help,
|
|
225
|
-
errors:
|
|
226
|
-
warnings:
|
|
223
|
+
errors: L,
|
|
224
|
+
warnings: S
|
|
227
225
|
}
|
|
228
226
|
),
|
|
229
|
-
|
|
227
|
+
D && /* @__PURE__ */ i("div", { className: `${l}-extra`, children: D })
|
|
230
228
|
]
|
|
231
229
|
}
|
|
232
230
|
)
|
|
233
231
|
]
|
|
234
232
|
}
|
|
235
233
|
) }) });
|
|
236
|
-
},
|
|
237
|
-
|
|
234
|
+
}, $e = ae(Fe);
|
|
235
|
+
$e.displayName = "FormItem";
|
|
238
236
|
export {
|
|
239
|
-
|
|
237
|
+
$e as default
|
|
240
238
|
};
|