@rockshin/tao-ui 0.0.43 → 0.0.45
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/README.md +7 -1
- package/component-manifest.json +10 -3
- package/dist/components/auto-complete/auto-complete.js +12 -3
- package/dist/components/breadcrumb/breadcrumb.css +4 -0
- package/dist/components/breadcrumb/breadcrumb.js +1 -0
- package/dist/components/calendar/calendar.d.ts +1 -0
- package/dist/components/calendar/calendar.js +10 -3
- package/dist/components/card/card-tabs.js +204 -182
- package/dist/components/card/card.js +1 -1
- package/dist/components/carousel/carousel.js +11 -5
- package/dist/components/cascader/cascader.js +16 -4
- package/dist/components/collapse/collapse.css +8 -0
- package/dist/components/context-menu/context-menu.d.ts +2 -1
- package/dist/components/context-menu/context-menu.js +57 -44
- package/dist/components/date-picker/calendar/calendar-grid.js +3 -2
- package/dist/components/date-picker/date-picker.css +4 -0
- package/dist/components/date-picker/date-picker.d.ts +1 -0
- package/dist/components/date-picker/date-picker.js +13 -3
- package/dist/components/date-picker/range-picker.d.ts +1 -0
- package/dist/components/date-picker/range-picker.js +13 -3
- package/dist/components/drawer/drawer.d.ts +2 -1
- package/dist/components/drawer/drawer.js +32 -20
- package/dist/components/dropdown/dropdown.d.ts +1 -0
- package/dist/components/dropdown/dropdown.js +139 -123
- package/dist/components/form/field-control.d.ts +6 -0
- package/dist/components/form/field-control.js +42 -0
- package/dist/components/form/form-context.d.ts +3 -0
- package/dist/components/form/form-item.d.ts +2 -1
- package/dist/components/form/form-item.js +55 -42
- package/dist/components/form/form.d.ts +5 -5
- package/dist/components/form/form.js +86 -68
- package/dist/components/form/index.d.ts +1 -0
- package/dist/components/form/use-form.d.ts +16 -0
- package/dist/components/form/use-form.js +69 -0
- package/dist/components/form-field/form-field-view.d.ts +4 -2
- package/dist/components/form-field/form-field-view.js +42 -35
- package/dist/components/mentions/mentions.js +6 -2
- package/dist/components/modal/modal.d.ts +2 -1
- package/dist/components/modal/modal.js +14 -4
- package/dist/components/pagination/pagination.css +4 -0
- package/dist/components/popover/popover.d.ts +2 -1
- package/dist/components/popover/popover.js +185 -176
- package/dist/components/rate/rate.js +114 -88
- package/dist/components/scroll-area/scroll-area.js +127 -118
- package/dist/components/segmented/segmented.js +52 -29
- package/dist/components/select/mobile-select.d.ts +2 -1
- package/dist/components/select/mobile-select.js +52 -47
- package/dist/components/select/select-types.d.ts +1 -0
- package/dist/components/select/select.js +19 -6
- package/dist/components/slider/slider.js +136 -133
- package/dist/components/splitter/splitter.css +4 -0
- package/dist/components/splitter/splitter.js +5 -3
- package/dist/components/table/table.css +29 -11
- package/dist/components/table/table.js +383 -547
- package/dist/components/tabs/tabs.js +3 -2
- package/dist/components/time-picker/time-picker.js +21 -7
- package/dist/components/tooltip/tooltip.d.ts +2 -1
- package/dist/components/tooltip/tooltip.js +82 -71
- package/dist/components/transfer/transfer-parts.js +12 -2
- package/dist/components/transfer/transfer.js +10 -4
- package/dist/components/tree/tree-keyboard.d.ts +6 -0
- package/dist/components/tree/tree-keyboard.js +27 -0
- package/dist/components/tree/tree.js +14 -3
- package/dist/components/tree-select/select-engine.d.ts +2 -1
- package/dist/components/tree-select/select-engine.js +23 -15
- package/dist/components/tree-select/tree-select.js +20 -10
- package/dist/docs/components/form.doc.js +3 -1
- package/dist/docs/components/tao-provider.doc.js +6 -1
- package/dist/entries/form.d.ts +2 -2
- package/dist/entries/provider.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/provider/tao-provider.d.ts +10 -3
- package/dist/provider/tao-provider.js +198 -88
- package/dist/utils/scroll-left.d.ts +3 -0
- package/dist/utils/scroll-left.js +7 -0
- package/llms.txt +3 -3
- package/package.json +4 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { useRef, useState } from "react";
|
|
4
|
-
import { TaoPortalScope, useTaoConfig } from "../../provider/tao-provider.js";
|
|
4
|
+
import { TaoPortalScope, useTaoConfig, useTaoDirection } from "../../provider/tao-provider.js";
|
|
5
5
|
import { asTriggerChild } from "../../utils/overlay.js";
|
|
6
6
|
import { cx } from "../../utils/semantic.js";
|
|
7
7
|
import { Button } from "../button/button.js";
|
|
@@ -65,93 +65,94 @@ function EllipsisIcon() {
|
|
|
65
65
|
return t0;
|
|
66
66
|
}
|
|
67
67
|
function Dropdown(props) {
|
|
68
|
-
const $ = c(
|
|
69
|
-
const
|
|
70
|
-
|
|
68
|
+
const $ = c(68);
|
|
69
|
+
const [direction, directionRef] = useTaoDirection(props.direction, "self");
|
|
70
|
+
const { menu, children, trigger: t0, placement, open, defaultOpen, onOpenChange, disabled, arrow: t1, className, style, classNames, styles } = props;
|
|
71
|
+
let t2;
|
|
71
72
|
if ($[0] !== t0) {
|
|
72
|
-
|
|
73
|
+
t2 = void 0 === t0 ? [
|
|
73
74
|
"click"
|
|
74
75
|
] : t0;
|
|
75
76
|
$[0] = t0;
|
|
76
|
-
$[1] =
|
|
77
|
-
} else
|
|
78
|
-
const trigger =
|
|
79
|
-
const
|
|
80
|
-
const arrow = void 0 === t2 ? false : t2;
|
|
77
|
+
$[1] = t2;
|
|
78
|
+
} else t2 = $[1];
|
|
79
|
+
const trigger = t2;
|
|
80
|
+
const arrow = void 0 === t1 ? false : t1;
|
|
81
81
|
const { size, disabled: ctxDisabled } = useTaoConfig();
|
|
82
82
|
const resolvedDisabled = disabled ?? ctxDisabled;
|
|
83
|
-
let
|
|
83
|
+
let t3;
|
|
84
84
|
if ($[2] !== trigger) {
|
|
85
|
-
|
|
85
|
+
t3 = trigger.includes("contextMenu");
|
|
86
86
|
$[2] = trigger;
|
|
87
|
-
$[3] =
|
|
88
|
-
} else
|
|
89
|
-
const isContext =
|
|
90
|
-
let
|
|
87
|
+
$[3] = t3;
|
|
88
|
+
} else t3 = $[3];
|
|
89
|
+
const isContext = t3;
|
|
90
|
+
let t4;
|
|
91
91
|
if ($[4] !== isContext || $[5] !== trigger) {
|
|
92
|
-
|
|
92
|
+
t4 = !isContext && trigger.includes("hover");
|
|
93
93
|
$[4] = isContext;
|
|
94
94
|
$[5] = trigger;
|
|
95
|
-
$[6] =
|
|
96
|
-
} else
|
|
97
|
-
const hoverMode =
|
|
95
|
+
$[6] = t4;
|
|
96
|
+
} else t4 = $[6];
|
|
97
|
+
const hoverMode = t4;
|
|
98
98
|
const isOpenControlled = null != open;
|
|
99
99
|
const [openInternal, setOpenInternal] = useState(defaultOpen ?? false);
|
|
100
100
|
const realOpen = isOpenControlled ? open : openInternal;
|
|
101
|
-
let
|
|
101
|
+
let t5;
|
|
102
102
|
if ($[7] !== isOpenControlled || $[8] !== onOpenChange) {
|
|
103
|
-
|
|
103
|
+
t5 = (next)=>{
|
|
104
104
|
if (!isOpenControlled) setOpenInternal(next);
|
|
105
105
|
onOpenChange?.(next);
|
|
106
106
|
};
|
|
107
107
|
$[7] = isOpenControlled;
|
|
108
108
|
$[8] = onOpenChange;
|
|
109
|
-
$[9] =
|
|
110
|
-
} else
|
|
111
|
-
const setOpen =
|
|
109
|
+
$[9] = t5;
|
|
110
|
+
} else t5 = $[9];
|
|
111
|
+
const setOpen = t5;
|
|
112
112
|
const closeTimer = useRef(void 0);
|
|
113
|
-
let
|
|
113
|
+
let t6;
|
|
114
114
|
if ($[10] !== resolvedDisabled || $[11] !== setOpen) {
|
|
115
|
-
|
|
115
|
+
t6 = ()=>{
|
|
116
116
|
clearTimeout(closeTimer.current);
|
|
117
117
|
if (!resolvedDisabled) setOpen(true);
|
|
118
118
|
};
|
|
119
119
|
$[10] = resolvedDisabled;
|
|
120
120
|
$[11] = setOpen;
|
|
121
|
-
$[12] =
|
|
122
|
-
} else
|
|
123
|
-
const openOnHover =
|
|
124
|
-
let
|
|
121
|
+
$[12] = t6;
|
|
122
|
+
} else t6 = $[12];
|
|
123
|
+
const openOnHover = t6;
|
|
124
|
+
let t7;
|
|
125
125
|
if ($[13] !== setOpen) {
|
|
126
|
-
|
|
126
|
+
t7 = ()=>{
|
|
127
127
|
closeTimer.current = setTimeout(()=>setOpen(false), 120);
|
|
128
128
|
};
|
|
129
129
|
$[13] = setOpen;
|
|
130
|
-
$[14] =
|
|
131
|
-
} else
|
|
132
|
-
const closeOnHover =
|
|
133
|
-
let
|
|
130
|
+
$[14] = t7;
|
|
131
|
+
} else t7 = $[14];
|
|
132
|
+
const closeOnHover = t7;
|
|
133
|
+
let t8;
|
|
134
134
|
if ($[15] !== classNames || $[16] !== styles) {
|
|
135
|
-
|
|
135
|
+
t8 = {
|
|
136
136
|
classNames,
|
|
137
137
|
styles
|
|
138
138
|
};
|
|
139
139
|
$[15] = classNames;
|
|
140
140
|
$[16] = styles;
|
|
141
|
-
$[17] =
|
|
142
|
-
} else
|
|
143
|
-
const content = useMenuController(menu, DD,
|
|
144
|
-
let
|
|
141
|
+
$[17] = t8;
|
|
142
|
+
} else t8 = $[17];
|
|
143
|
+
const content = useMenuController(menu, DD, t8);
|
|
144
|
+
let t9;
|
|
145
145
|
if ($[18] !== children) {
|
|
146
|
-
|
|
146
|
+
t9 = asTriggerChild(children);
|
|
147
147
|
$[18] = children;
|
|
148
|
-
$[19] =
|
|
149
|
-
} else
|
|
150
|
-
const triggerChild =
|
|
148
|
+
$[19] = t9;
|
|
149
|
+
} else t9 = $[19];
|
|
150
|
+
const triggerChild = t9;
|
|
151
151
|
if (isContext) {
|
|
152
|
-
let
|
|
153
|
-
if ($[20] !== children || $[21] !== className || $[22] !== classNames || $[23] !== disabled || $[24] !== menu || $[25] !== onOpenChange || $[26] !== open || $[27] !==
|
|
154
|
-
|
|
152
|
+
let t10;
|
|
153
|
+
if ($[20] !== children || $[21] !== className || $[22] !== classNames || $[23] !== disabled || $[24] !== menu || $[25] !== onOpenChange || $[26] !== open || $[27] !== props.direction || $[28] !== style || $[29] !== styles) {
|
|
154
|
+
t10 = /*#__PURE__*/ jsx(ContextMenu, {
|
|
155
|
+
direction: props.direction,
|
|
155
156
|
menu: menu,
|
|
156
157
|
open: open,
|
|
157
158
|
onOpenChange: onOpenChange,
|
|
@@ -169,125 +170,140 @@ function Dropdown(props) {
|
|
|
169
170
|
$[24] = menu;
|
|
170
171
|
$[25] = onOpenChange;
|
|
171
172
|
$[26] = open;
|
|
172
|
-
$[27] =
|
|
173
|
-
$[28] =
|
|
174
|
-
$[29] =
|
|
175
|
-
|
|
176
|
-
|
|
173
|
+
$[27] = props.direction;
|
|
174
|
+
$[28] = style;
|
|
175
|
+
$[29] = styles;
|
|
176
|
+
$[30] = t10;
|
|
177
|
+
} else t10 = $[30];
|
|
178
|
+
return t10;
|
|
177
179
|
}
|
|
180
|
+
const t10 = placement ?? ("rtl" === direction ? "bottomRight" : "bottomLeft");
|
|
178
181
|
let t11;
|
|
179
|
-
if ($[
|
|
180
|
-
t11 = parsePlacement(
|
|
181
|
-
$[
|
|
182
|
-
$[
|
|
183
|
-
} else t11 = $[
|
|
184
|
-
const { side, align } = t11;
|
|
182
|
+
if ($[31] !== t10) {
|
|
183
|
+
t11 = parsePlacement(t10);
|
|
184
|
+
$[31] = t10;
|
|
185
|
+
$[32] = t11;
|
|
186
|
+
} else t11 = $[32];
|
|
187
|
+
const { side, align: physicalAlign } = t11;
|
|
188
|
+
const align = "rtl" === direction && "center" !== physicalAlign ? "start" === physicalAlign ? "end" : "start" : physicalAlign;
|
|
185
189
|
let t12;
|
|
186
|
-
if ($[
|
|
190
|
+
if ($[33] !== closeOnHover || $[34] !== hoverMode || $[35] !== openOnHover) {
|
|
187
191
|
t12 = hoverMode ? {
|
|
188
192
|
onPointerEnter: openOnHover,
|
|
189
193
|
onPointerLeave: closeOnHover
|
|
190
194
|
} : void 0;
|
|
191
|
-
$[
|
|
192
|
-
$[
|
|
193
|
-
$[
|
|
194
|
-
$[
|
|
195
|
-
} else t12 = $[
|
|
195
|
+
$[33] = closeOnHover;
|
|
196
|
+
$[34] = hoverMode;
|
|
197
|
+
$[35] = openOnHover;
|
|
198
|
+
$[36] = t12;
|
|
199
|
+
} else t12 = $[36];
|
|
196
200
|
const hoverProps = t12;
|
|
197
201
|
let t13;
|
|
198
|
-
if ($[
|
|
202
|
+
if ($[37] !== directionRef || $[38] !== hoverProps || $[39] !== resolvedDisabled || $[40] !== triggerChild) {
|
|
199
203
|
t13 = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_dropdown_menu_154a7470.Trigger, {
|
|
204
|
+
ref: directionRef,
|
|
200
205
|
asChild: true,
|
|
201
206
|
disabled: resolvedDisabled,
|
|
202
207
|
"data-tao-dropdown-trigger": "",
|
|
203
208
|
...hoverProps,
|
|
204
209
|
children: triggerChild
|
|
205
210
|
});
|
|
206
|
-
$[
|
|
207
|
-
$[
|
|
208
|
-
$[
|
|
209
|
-
$[
|
|
210
|
-
|
|
211
|
+
$[37] = directionRef;
|
|
212
|
+
$[38] = hoverProps;
|
|
213
|
+
$[39] = resolvedDisabled;
|
|
214
|
+
$[40] = triggerChild;
|
|
215
|
+
$[41] = t13;
|
|
216
|
+
} else t13 = $[41];
|
|
211
217
|
const t14 = classNames?.content;
|
|
212
218
|
let t15;
|
|
213
|
-
if ($[
|
|
219
|
+
if ($[42] !== className || $[43] !== t14) {
|
|
214
220
|
t15 = cx(t14, className);
|
|
215
|
-
$[
|
|
216
|
-
$[
|
|
217
|
-
$[
|
|
218
|
-
} else t15 = $[
|
|
221
|
+
$[42] = className;
|
|
222
|
+
$[43] = t14;
|
|
223
|
+
$[44] = t15;
|
|
224
|
+
} else t15 = $[44];
|
|
219
225
|
const t16 = styles?.content;
|
|
220
226
|
let t17;
|
|
221
|
-
if ($[
|
|
227
|
+
if ($[45] !== style || $[46] !== t16) {
|
|
222
228
|
t17 = {
|
|
223
229
|
...t16,
|
|
224
230
|
...style
|
|
225
231
|
};
|
|
226
|
-
$[
|
|
227
|
-
$[
|
|
228
|
-
$[
|
|
229
|
-
} else t17 = $[
|
|
232
|
+
$[45] = style;
|
|
233
|
+
$[46] = t16;
|
|
234
|
+
$[47] = t17;
|
|
235
|
+
} else t17 = $[47];
|
|
230
236
|
let t18;
|
|
231
|
-
if ($[
|
|
237
|
+
if ($[48] !== arrow) {
|
|
232
238
|
t18 = arrow && /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_dropdown_menu_154a7470.Arrow, {
|
|
233
239
|
asChild: true,
|
|
234
240
|
children: /*#__PURE__*/ jsx("span", {
|
|
235
241
|
"data-tao-dropdown-arrow": ""
|
|
236
242
|
})
|
|
237
243
|
});
|
|
238
|
-
$[
|
|
239
|
-
$[
|
|
240
|
-
} else t18 = $[
|
|
244
|
+
$[48] = arrow;
|
|
245
|
+
$[49] = t18;
|
|
246
|
+
} else t18 = $[49];
|
|
241
247
|
let t19;
|
|
242
|
-
if ($[
|
|
243
|
-
t19 = /*#__PURE__*/
|
|
248
|
+
if ($[50] !== align || $[51] !== content || $[52] !== hoverProps || $[53] !== side || $[54] !== size || $[55] !== t15 || $[56] !== t17 || $[57] !== t18) {
|
|
249
|
+
t19 = /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_dropdown_menu_154a7470.Content, {
|
|
250
|
+
"data-tao-menu-content": "",
|
|
251
|
+
"data-tao-dropdown": "",
|
|
252
|
+
"data-tao-size": size,
|
|
253
|
+
className: t15,
|
|
254
|
+
style: t17,
|
|
255
|
+
side: side,
|
|
256
|
+
align: align,
|
|
257
|
+
sideOffset: 4,
|
|
258
|
+
...hoverProps,
|
|
259
|
+
children: [
|
|
260
|
+
t18,
|
|
261
|
+
content
|
|
262
|
+
]
|
|
263
|
+
});
|
|
264
|
+
$[50] = align;
|
|
265
|
+
$[51] = content;
|
|
266
|
+
$[52] = hoverProps;
|
|
267
|
+
$[53] = side;
|
|
268
|
+
$[54] = size;
|
|
269
|
+
$[55] = t15;
|
|
270
|
+
$[56] = t17;
|
|
271
|
+
$[57] = t18;
|
|
272
|
+
$[58] = t19;
|
|
273
|
+
} else t19 = $[58];
|
|
274
|
+
let t20;
|
|
275
|
+
if ($[59] !== direction || $[60] !== t19) {
|
|
276
|
+
t20 = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_dropdown_menu_154a7470.Portal, {
|
|
244
277
|
children: /*#__PURE__*/ jsx(TaoPortalScope, {
|
|
245
278
|
asChild: true,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
"data-tao-dropdown": "",
|
|
249
|
-
"data-tao-size": size,
|
|
250
|
-
className: t15,
|
|
251
|
-
style: t17,
|
|
252
|
-
side: side,
|
|
253
|
-
align: align,
|
|
254
|
-
sideOffset: 4,
|
|
255
|
-
...hoverProps,
|
|
256
|
-
children: [
|
|
257
|
-
t18,
|
|
258
|
-
content
|
|
259
|
-
]
|
|
260
|
-
})
|
|
279
|
+
direction: direction,
|
|
280
|
+
children: t19
|
|
261
281
|
})
|
|
262
282
|
});
|
|
263
|
-
$[
|
|
264
|
-
$[
|
|
265
|
-
$[
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
$[56] = t19;
|
|
272
|
-
} else t19 = $[56];
|
|
273
|
-
let t20;
|
|
274
|
-
if ($[57] !== realOpen || $[58] !== setOpen || $[59] !== t13 || $[60] !== t19) {
|
|
275
|
-
t20 = /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_dropdown_menu_154a7470.Root, {
|
|
283
|
+
$[59] = direction;
|
|
284
|
+
$[60] = t19;
|
|
285
|
+
$[61] = t20;
|
|
286
|
+
} else t20 = $[61];
|
|
287
|
+
let t21;
|
|
288
|
+
if ($[62] !== direction || $[63] !== realOpen || $[64] !== setOpen || $[65] !== t13 || $[66] !== t20) {
|
|
289
|
+
t21 = /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_dropdown_menu_154a7470.Root, {
|
|
290
|
+
dir: direction,
|
|
276
291
|
open: realOpen,
|
|
277
292
|
onOpenChange: setOpen,
|
|
278
293
|
modal: false,
|
|
279
294
|
children: [
|
|
280
295
|
t13,
|
|
281
|
-
|
|
296
|
+
t20
|
|
282
297
|
]
|
|
283
298
|
});
|
|
284
|
-
$[
|
|
285
|
-
$[
|
|
286
|
-
$[
|
|
287
|
-
$[
|
|
288
|
-
$[
|
|
289
|
-
|
|
290
|
-
|
|
299
|
+
$[62] = direction;
|
|
300
|
+
$[63] = realOpen;
|
|
301
|
+
$[64] = setOpen;
|
|
302
|
+
$[65] = t13;
|
|
303
|
+
$[66] = t20;
|
|
304
|
+
$[67] = t21;
|
|
305
|
+
} else t21 = $[67];
|
|
306
|
+
return t21;
|
|
291
307
|
}
|
|
292
308
|
function DropdownButton(t0) {
|
|
293
309
|
const $ = c(26);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
/** Register the actual control, including noStyle and Form.List fields. */
|
|
3
|
+
export declare function FieldControl({ name, children, }: {
|
|
4
|
+
name: (string | number)[];
|
|
5
|
+
children: ReactElement<Record<string, unknown>>;
|
|
6
|
+
}): ReactElement<Record<string, unknown>, string | import("react").JSXElementConstructor<any>>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getNodeRef, supportNodeRef } from "@rc-component/util/es/ref";
|
|
2
|
+
import useLayoutEffect from "@rc-component/util/es/hooks/useLayoutEffect";
|
|
3
|
+
import { cloneElement, useId, useMemo } from "react";
|
|
4
|
+
import { mergeRefs } from "../../utils/refs.js";
|
|
5
|
+
import { useFormLayout } from "./form-context.js";
|
|
6
|
+
import { fieldKey } from "./use-form.js";
|
|
7
|
+
function FieldControl({ name, children }) {
|
|
8
|
+
const { fields } = useFormLayout();
|
|
9
|
+
const generatedId = useId();
|
|
10
|
+
const id = 'string' == typeof children.props.id ? children.props.id : `${generatedId}-control`;
|
|
11
|
+
const key = fieldKey(name);
|
|
12
|
+
const target = useMemo(()=>({
|
|
13
|
+
id,
|
|
14
|
+
instance: null
|
|
15
|
+
}), [
|
|
16
|
+
id
|
|
17
|
+
]);
|
|
18
|
+
const childRef = getNodeRef(children);
|
|
19
|
+
const ref = useMemo(()=>mergeRefs((instance)=>{
|
|
20
|
+
target.instance = instance;
|
|
21
|
+
}, childRef), [
|
|
22
|
+
target,
|
|
23
|
+
childRef
|
|
24
|
+
]);
|
|
25
|
+
useLayoutEffect(()=>{
|
|
26
|
+
fields?.set(key, target);
|
|
27
|
+
return ()=>{
|
|
28
|
+
fields?.delete(key);
|
|
29
|
+
};
|
|
30
|
+
}, [
|
|
31
|
+
fields,
|
|
32
|
+
key,
|
|
33
|
+
target
|
|
34
|
+
]);
|
|
35
|
+
return /*#__PURE__*/ cloneElement(children, {
|
|
36
|
+
id,
|
|
37
|
+
...supportNodeRef(children) ? {
|
|
38
|
+
ref
|
|
39
|
+
} : {}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export { FieldControl };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { FormFieldLayout } from '../form-field/form-field-view.js';
|
|
2
|
+
import type { FieldTarget, FormInstance } from './use-form.js';
|
|
2
3
|
export interface FormLayoutContextValue {
|
|
3
4
|
layout: FormFieldLayout;
|
|
5
|
+
form?: FormInstance;
|
|
6
|
+
fields?: Map<string, FieldTarget>;
|
|
4
7
|
}
|
|
5
8
|
/** Internal layout channel: Form → Form.Item. */
|
|
6
9
|
export declare const FormLayoutContext: import("react").Context<FormLayoutContextValue>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Meta, type NamePath, type Rule } from '@rc-component/form';
|
|
2
2
|
import { type CSSProperties, type ReactNode } from 'react';
|
|
3
3
|
import type { TaoStatus } from '../../provider/tao-provider.js';
|
|
4
4
|
import type { SemanticClassNames, SemanticStyles } from '../../utils/semantic.js';
|
|
5
|
+
import type { FormInstance } from './use-form.js';
|
|
5
6
|
export type FormItemSemanticPart = 'root' | 'label' | 'error' | 'description';
|
|
6
7
|
export type FormItemValidateStatus = TaoStatus;
|
|
7
8
|
export type FormItemChildren<Values = Record<string, unknown>> = ReactNode | ((control: Record<string, unknown>, meta: Meta, form: FormInstance<Values>) => ReactNode);
|
|
@@ -4,10 +4,11 @@ import { Field } from "@rc-component/form";
|
|
|
4
4
|
import { cloneElement, isValidElement } from "react";
|
|
5
5
|
import { FormFieldView } from "../form-field/form-field-view.js";
|
|
6
6
|
import { useFormLayout } from "./form-context.js";
|
|
7
|
+
import { FieldControl } from "./field-control.js";
|
|
7
8
|
function FormItem(t0) {
|
|
8
|
-
const $ = c(
|
|
9
|
+
const $ = c(41);
|
|
9
10
|
const { name, label, required, rules, help, extra, validateStatus, initialValue, valuePropName, getValueFromEvent, trigger, validateTrigger, noStyle, dependencies, shouldUpdate, normalize, preserve, messageVariables, validateFirst, htmlFor, className, style, classNames, styles, children } = t0;
|
|
10
|
-
const { layout } = useFormLayout();
|
|
11
|
+
const { layout, form: formInstance } = useFormLayout();
|
|
11
12
|
let t1;
|
|
12
13
|
if ($[0] !== required || $[1] !== rules) {
|
|
13
14
|
t1 = required ?? rules?.some(_temp) ?? false;
|
|
@@ -17,7 +18,7 @@ function FormItem(t0) {
|
|
|
17
18
|
} else t1 = $[2];
|
|
18
19
|
const requiredMark = t1;
|
|
19
20
|
let t2;
|
|
20
|
-
if ($[3] !== className || $[4] !== classNames || $[5] !== extra || $[6] !== help || $[7] !== htmlFor || $[8] !== label || $[9] !== layout || $[10] !==
|
|
21
|
+
if ($[3] !== className || $[4] !== classNames || $[5] !== extra || $[6] !== help || $[7] !== htmlFor || $[8] !== label || $[9] !== layout || $[10] !== name || $[11] !== noStyle || $[12] !== requiredMark || $[13] !== style || $[14] !== styles || $[15] !== validateStatus || $[16] !== valuePropName) {
|
|
21
22
|
t2 = (content, meta, control)=>{
|
|
22
23
|
const status = validateStatus ?? (meta?.errors.length ? "error" : meta?.warnings.length ? "warning" : void 0);
|
|
23
24
|
const message = help ?? meta?.errors[0] ?? meta?.warnings[0];
|
|
@@ -37,7 +38,13 @@ function FormItem(t0) {
|
|
|
37
38
|
...controlProps,
|
|
38
39
|
value: ""
|
|
39
40
|
};
|
|
40
|
-
if (noStyle)
|
|
41
|
+
if (noStyle) {
|
|
42
|
+
const child = /*#__PURE__*/ isValidElement(content) && controlProps ? /*#__PURE__*/ cloneElement(content, controlProps) : content;
|
|
43
|
+
return null != name && meta && /*#__PURE__*/ isValidElement(child) ? /*#__PURE__*/ jsx(FieldControl, {
|
|
44
|
+
name: meta.name,
|
|
45
|
+
children: child
|
|
46
|
+
}) : child;
|
|
47
|
+
}
|
|
41
48
|
return /*#__PURE__*/ jsx(FormFieldView, {
|
|
42
49
|
formItem: true,
|
|
43
50
|
label: label,
|
|
@@ -48,6 +55,10 @@ function FormItem(t0) {
|
|
|
48
55
|
description: descriptionSlot,
|
|
49
56
|
layout: layout,
|
|
50
57
|
controlProps: controlProps,
|
|
58
|
+
renderControl: null != name && meta ? (child_0)=>/*#__PURE__*/ jsx(FieldControl, {
|
|
59
|
+
name: meta.name,
|
|
60
|
+
children: child_0
|
|
61
|
+
}) : void 0,
|
|
51
62
|
className: className,
|
|
52
63
|
style: style,
|
|
53
64
|
classNames: classNames,
|
|
@@ -62,40 +73,42 @@ function FormItem(t0) {
|
|
|
62
73
|
$[7] = htmlFor;
|
|
63
74
|
$[8] = label;
|
|
64
75
|
$[9] = layout;
|
|
65
|
-
$[10] =
|
|
66
|
-
$[11] =
|
|
67
|
-
$[12] =
|
|
68
|
-
$[13] =
|
|
69
|
-
$[14] =
|
|
70
|
-
$[15] =
|
|
71
|
-
$[16] =
|
|
72
|
-
|
|
76
|
+
$[10] = name;
|
|
77
|
+
$[11] = noStyle;
|
|
78
|
+
$[12] = requiredMark;
|
|
79
|
+
$[13] = style;
|
|
80
|
+
$[14] = styles;
|
|
81
|
+
$[15] = validateStatus;
|
|
82
|
+
$[16] = valuePropName;
|
|
83
|
+
$[17] = t2;
|
|
84
|
+
} else t2 = $[17];
|
|
73
85
|
const renderShell = t2;
|
|
74
86
|
if (null == name && null == dependencies && null == shouldUpdate) {
|
|
75
87
|
const t3 = children;
|
|
76
88
|
let t4;
|
|
77
|
-
if ($[
|
|
89
|
+
if ($[18] !== renderShell || $[19] !== t3) {
|
|
78
90
|
t4 = renderShell(t3, void 0, null);
|
|
79
|
-
$[
|
|
80
|
-
$[
|
|
81
|
-
$[
|
|
82
|
-
} else t4 = $[
|
|
91
|
+
$[18] = renderShell;
|
|
92
|
+
$[19] = t3;
|
|
93
|
+
$[20] = t4;
|
|
94
|
+
} else t4 = $[20];
|
|
83
95
|
return t4;
|
|
84
96
|
}
|
|
85
97
|
const t3 = name ?? void 0;
|
|
86
98
|
let t4;
|
|
87
|
-
if ($[
|
|
88
|
-
t4 = (control_0, meta_0
|
|
89
|
-
const content_0 = "function" == typeof children ? children(control_0, meta_0,
|
|
99
|
+
if ($[21] !== children || $[22] !== formInstance || $[23] !== name || $[24] !== renderShell) {
|
|
100
|
+
t4 = (control_0, meta_0)=>{
|
|
101
|
+
const content_0 = "function" == typeof children ? children(control_0, meta_0, formInstance) : children;
|
|
90
102
|
return renderShell(content_0, meta_0, null != name ? control_0 : null);
|
|
91
103
|
};
|
|
92
|
-
$[
|
|
93
|
-
$[
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
96
|
-
|
|
104
|
+
$[21] = children;
|
|
105
|
+
$[22] = formInstance;
|
|
106
|
+
$[23] = name;
|
|
107
|
+
$[24] = renderShell;
|
|
108
|
+
$[25] = t4;
|
|
109
|
+
} else t4 = $[25];
|
|
97
110
|
let t5;
|
|
98
|
-
if ($[
|
|
111
|
+
if ($[26] !== dependencies || $[27] !== getValueFromEvent || $[28] !== initialValue || $[29] !== messageVariables || $[30] !== normalize || $[31] !== preserve || $[32] !== rules || $[33] !== shouldUpdate || $[34] !== t3 || $[35] !== t4 || $[36] !== trigger || $[37] !== validateFirst || $[38] !== validateTrigger || $[39] !== valuePropName) {
|
|
99
112
|
t5 = /*#__PURE__*/ jsx(Field, {
|
|
100
113
|
name: t3,
|
|
101
114
|
rules: rules,
|
|
@@ -112,22 +125,22 @@ function FormItem(t0) {
|
|
|
112
125
|
validateFirst: validateFirst,
|
|
113
126
|
children: t4
|
|
114
127
|
});
|
|
115
|
-
$[
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
-
$[
|
|
119
|
-
$[
|
|
120
|
-
$[
|
|
121
|
-
$[
|
|
122
|
-
$[
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
127
|
-
$[
|
|
128
|
-
$[
|
|
129
|
-
$[
|
|
130
|
-
} else t5 = $[
|
|
128
|
+
$[26] = dependencies;
|
|
129
|
+
$[27] = getValueFromEvent;
|
|
130
|
+
$[28] = initialValue;
|
|
131
|
+
$[29] = messageVariables;
|
|
132
|
+
$[30] = normalize;
|
|
133
|
+
$[31] = preserve;
|
|
134
|
+
$[32] = rules;
|
|
135
|
+
$[33] = shouldUpdate;
|
|
136
|
+
$[34] = t3;
|
|
137
|
+
$[35] = t4;
|
|
138
|
+
$[36] = trigger;
|
|
139
|
+
$[37] = validateFirst;
|
|
140
|
+
$[38] = validateTrigger;
|
|
141
|
+
$[39] = valuePropName;
|
|
142
|
+
$[40] = t5;
|
|
143
|
+
} else t5 = $[40];
|
|
131
144
|
return t5;
|
|
132
145
|
}
|
|
133
146
|
function _temp(rule) {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { List, type FormProps as RcFormProps, useWatch } from '@rc-component/form';
|
|
2
2
|
import { type ReactNode } from 'react';
|
|
3
3
|
import { type TaoSize } from '../../provider/tao-provider.js';
|
|
4
4
|
import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic.js';
|
|
5
5
|
import { FormItem, type FormItemProps } from './form-item.js';
|
|
6
|
+
import { type FormInstance, useForm } from './use-form.js';
|
|
6
7
|
import './form.css';
|
|
7
8
|
export type FormSemanticPart = 'root';
|
|
8
|
-
export interface FormProps<Values = Record<string, unknown>> extends Omit<RcFormProps<Values>, 'component'> {
|
|
9
|
+
export interface FormProps<Values = Record<string, unknown>> extends Omit<RcFormProps<Values>, 'component' | 'form'> {
|
|
10
|
+
form?: FormInstance<Values>;
|
|
9
11
|
/** Label/control arrangement inherited by Form.Item. Defaults to 'vertical'. */
|
|
10
12
|
layout?: 'vertical' | 'horizontal';
|
|
11
13
|
/** Cascades a control size to everything inside the form. */
|
|
@@ -17,9 +19,7 @@ export interface FormProps<Values = Record<string, unknown>> extends Omit<RcForm
|
|
|
17
19
|
styles?: SemanticStyles<FormSemanticPart>;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
|
-
* Returns the instance of the enclosing Form
|
|
21
|
-
* InternalFormInstance (a superset of FormInstance), same source antd's
|
|
22
|
-
* useFormInstance reads from.
|
|
22
|
+
* Returns the enhanced instance of the enclosing Form.
|
|
23
23
|
*/
|
|
24
24
|
declare function useFormInstance<Values = Record<string, unknown>>(): FormInstance<Values>;
|
|
25
25
|
export declare const Form: (<Values = Record<string, unknown>>(props: FormProps<Values> & {
|