@rockshin/tao-ui 0.0.48 → 0.0.51
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/dist/components/affix/affix.js +20 -16
- package/dist/components/alert/alert.js +114 -99
- package/dist/components/app/app-modals.js +134 -96
- package/dist/components/app/app-notices.js +39 -23
- package/dist/components/auto-complete/auto-complete.js +21 -7
- package/dist/components/avatar/avatar.js +31 -11
- package/dist/components/badge/badge.css +1 -1
- package/dist/components/badge/badge.js +72 -257
- package/dist/components/border-beam/border-beam.js +21 -17
- package/dist/components/breadcrumb/breadcrumb.js +178 -159
- package/dist/components/button/button.css +9 -1
- package/dist/components/button/button.js +61 -53
- package/dist/components/calendar/calendar.js +6 -4
- package/dist/components/card/card.js +24 -8
- package/dist/components/carousel/carousel.d.ts +1 -1
- package/dist/components/carousel/carousel.js +105 -68
- package/dist/components/cascader/cascader.js +54 -19
- package/dist/components/checkbox/checkbox.css +13 -2
- package/dist/components/checkbox/checkbox.d.ts +2 -0
- package/dist/components/checkbox/checkbox.js +320 -229
- package/dist/components/collapse/collapse-panels.d.ts +1 -1
- package/dist/components/collapse/collapse-panels.js +122 -113
- package/dist/components/collapse/collapse.js +98 -63
- package/dist/components/color-picker/color-picker.js +539 -441
- package/dist/components/color-picker/color.js +1 -1
- package/dist/components/context-menu/context-menu.d.ts +1 -1
- package/dist/components/context-menu/context-menu.js +108 -68
- package/dist/components/date-picker/calendar/calendar-grid.js +42 -39
- package/dist/components/date-picker/calendar/month-grid.d.ts +8 -1
- package/dist/components/date-picker/calendar/month-grid.js +79 -37
- package/dist/components/date-picker/calendar/time-panel.d.ts +2 -1
- package/dist/components/date-picker/calendar/time-panel.js +94 -89
- package/dist/components/date-picker/calendar/year-grid.d.ts +8 -1
- package/dist/components/date-picker/calendar/year-grid.js +66 -35
- package/dist/components/date-picker/date-picker.css +24 -1
- package/dist/components/date-picker/date-picker.js +99 -53
- package/dist/components/date-picker/presets.d.ts +2 -1
- package/dist/components/date-picker/presets.js +27 -24
- package/dist/components/date-picker/range-picker.js +308 -153
- package/dist/components/descriptions/descriptions.js +7 -3
- package/dist/components/divider/divider.css +1 -1
- package/dist/components/divider/divider.js +1 -1
- package/dist/components/drawer/drawer.js +201 -369
- package/dist/components/dropdown/dropdown.d.ts +1 -1
- package/dist/components/dropdown/dropdown.js +183 -279
- package/dist/components/empty/empty.js +57 -78
- package/dist/components/float-button/float-button.d.ts +1 -0
- package/dist/components/float-button/float-button.js +47 -30
- package/dist/components/form/field-control.d.ts +4 -2
- package/dist/components/form/field-control.js +17 -9
- package/dist/components/form/form-context.d.ts +8 -2
- package/dist/components/form/form-context.js +2 -1
- package/dist/components/form/form-item.js +85 -63
- package/dist/components/form/use-form.d.ts +2 -1
- package/dist/components/form/use-form.js +2 -1
- package/dist/components/form-field/form-field-view.d.ts +3 -1
- package/dist/components/form-field/form-field-view.js +194 -141
- package/dist/components/form-section/form-section.d.ts +1 -1
- package/dist/components/form-section/form-section.js +52 -45
- package/dist/components/image/image.js +585 -477
- package/dist/components/input/base-input.js +8 -9
- package/dist/components/input/input-shared.d.ts +5 -2
- package/dist/components/input/input-shared.js +42 -18
- package/dist/components/input/input.css +1 -0
- package/dist/components/input/otp.js +236 -217
- package/dist/components/input/password.js +2 -1
- package/dist/components/input/search.js +8 -7
- package/dist/components/list/list-pagination.js +41 -36
- package/dist/components/list/list.js +141 -125
- package/dist/components/listy/listy.js +175 -106
- package/dist/components/masonry/masonry.js +108 -85
- package/dist/components/mentions/mentions.js +12 -3
- package/dist/components/menu/menu-render.d.ts +9 -3
- package/dist/components/menu/menu-render.js +99 -36
- package/dist/components/modal/confirm-dialog.js +10 -4
- package/dist/components/modal/confirm.js +3 -7
- package/dist/components/modal/index.js +9 -3
- package/dist/components/modal/modal.js +390 -365
- package/dist/components/pagination/pagination.js +105 -96
- package/dist/components/popconfirm/popconfirm.d.ts +1 -1
- package/dist/components/popconfirm/popconfirm.js +219 -168
- package/dist/components/popover/popover.js +330 -243
- package/dist/components/progress/progress.css +2 -2
- package/dist/components/progress/progress.js +232 -458
- package/dist/components/qr-code/qr-code.js +72 -66
- package/dist/components/radio/radio.css +15 -4
- package/dist/components/radio/radio.d.ts +2 -1
- package/dist/components/radio/radio.js +260 -198
- package/dist/components/rate/rate.js +173 -113
- package/dist/components/scroll-area/scroll-area.js +241 -211
- package/dist/components/segmented/segmented.js +73 -41
- package/dist/components/select/mobile-select.d.ts +2 -1
- package/dist/components/select/mobile-select.js +24 -13
- package/dist/components/select/select-searchable-list.d.ts +2 -1
- package/dist/components/select/select-searchable-list.js +2 -3
- package/dist/components/select/select.css +3 -2
- package/dist/components/select/select.js +49 -25
- package/dist/components/select/use-select-selection.d.ts +1 -1
- package/dist/components/select/use-select-selection.js +7 -4
- package/dist/components/skeleton/skeleton.js +56 -48
- package/dist/components/slider/slider.js +87 -212
- package/dist/components/sonner/sonner.js +109 -93
- package/dist/components/spinner/spinner.js +147 -138
- package/dist/components/splitter/splitter.js +222 -159
- package/dist/components/statistic/statistic.js +7 -6
- package/dist/components/steps/steps.js +88 -81
- package/dist/components/steps/use-display-steps.js +1 -1
- package/dist/components/switch/switch.js +89 -89
- package/dist/components/table/table-filter.js +66 -56
- package/dist/components/table/table-icons.d.ts +2 -1
- package/dist/components/table/table-icons.js +11 -9
- package/dist/components/table/table-model.js +1 -1
- package/dist/components/table/table.js +107 -83
- package/dist/components/table/use-table-data.d.ts +6 -3
- package/dist/components/table/use-table-data.js +166 -130
- package/dist/components/tabs/tabs.css +1 -1
- package/dist/components/tabs/tabs.js +236 -179
- package/dist/components/tag/tag.d.ts +2 -2
- package/dist/components/tag/tag.js +111 -108
- package/dist/components/textarea/textarea.js +22 -17
- package/dist/components/time-picker/time-picker.js +5 -3
- package/dist/components/timeline/timeline.css +6 -1
- package/dist/components/timeline/timeline.js +21 -11
- package/dist/components/tooltip/tooltip.d.ts +2 -2
- package/dist/components/tooltip/tooltip.js +123 -233
- package/dist/components/tour/tour.css +4 -0
- package/dist/components/tour/tour.js +400 -331
- package/dist/components/transfer/transfer-list.js +31 -12
- package/dist/components/transfer/transfer-parts.js +1 -1
- package/dist/components/transfer/transfer-types.d.ts +1 -0
- package/dist/components/transfer/transfer.css +5 -0
- package/dist/components/transfer/transfer.js +29 -14
- package/dist/components/tree/tree-keyboard.d.ts +1 -1
- package/dist/components/tree/tree-keyboard.js +5 -3
- package/dist/components/tree/tree.js +74 -59
- package/dist/components/tree-select/select-engine.d.ts +3 -2
- package/dist/components/tree-select/select-engine.js +18 -16
- package/dist/components/tree-select/tree-select.js +21 -5
- package/dist/components/upload/upload.css +8 -0
- package/dist/components/upload/upload.js +160 -72
- package/dist/components/watermark/watermark.js +36 -29
- package/dist/number-input/use-number-input.js +129 -90
- package/dist/number-input/validate.js +32 -5
- package/dist/provider/merge-locale.js +12 -9
- package/dist/provider/tao-provider.d.ts +3 -1
- package/dist/provider/tao-provider.js +123 -86
- package/package.json +4 -3
|
@@ -1,47 +1,66 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { Field } from "@rc-component/form";
|
|
4
|
-
import { cloneElement, isValidElement } from "react";
|
|
4
|
+
import { Fragment, cloneElement, isValidElement } from "react";
|
|
5
5
|
import { FormFieldView } from "../form-field/form-field-view.js";
|
|
6
|
-
import { useFormLayout } from "./form-context.js";
|
|
7
6
|
import { FieldControl } from "./field-control.js";
|
|
7
|
+
import { useFormLayout } from "./form-context.js";
|
|
8
8
|
function FormItem(t0) {
|
|
9
9
|
const $ = c(42);
|
|
10
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;
|
|
11
11
|
const { layout, form: formInstance } = useFormLayout();
|
|
12
12
|
let t1;
|
|
13
|
-
if ($[0] !==
|
|
14
|
-
t1 =
|
|
15
|
-
|
|
16
|
-
$[1] = rules;
|
|
17
|
-
$[2] = t1;
|
|
18
|
-
} else t1 = $[2];
|
|
19
|
-
const requiredMark = t1;
|
|
20
|
-
let t2;
|
|
21
|
-
if ($[3] !== className || $[4] !== classNames || $[5] !== extra || $[6] !== help || $[7] !== htmlFor || $[8] !== label || $[9] !== layout || $[10] !== name || $[11] !== noStyle || $[12] !== requiredMark || $[13] !== rules?.length || $[14] !== style || $[15] !== styles || $[16] !== validateStatus || $[17] !== valuePropName) {
|
|
22
|
-
t2 = (content, meta, control)=>{
|
|
13
|
+
if ($[0] !== children || $[1] !== className || $[2] !== classNames || $[3] !== extra || $[4] !== formInstance || $[5] !== help || $[6] !== htmlFor || $[7] !== label || $[8] !== layout || $[9] !== name || $[10] !== noStyle || $[11] !== required || $[12] !== rules || $[13] !== style || $[14] !== styles || $[15] !== trigger || $[16] !== validateStatus || $[17] !== valuePropName) {
|
|
14
|
+
t1 = (content, meta, control)=>{
|
|
15
|
+
const requiredMark = required ?? rules?.some((rule)=>"function" == typeof rule ? !!(formInstance && rule(formInstance).required) : !!rule?.required) ?? false;
|
|
23
16
|
const status = validateStatus ?? (meta?.errors.length ? "error" : meta?.warnings.length ? "warning" : void 0);
|
|
24
17
|
const message = help ?? meta?.errors[0] ?? meta?.warnings[0];
|
|
25
18
|
const showAsStatus = null != message && null != status;
|
|
26
19
|
const errorSlot = showAsStatus ? message : void 0;
|
|
27
|
-
const descriptionSlot =
|
|
20
|
+
const descriptionSlot = showAsStatus ? void 0 : message;
|
|
28
21
|
let controlProps = control ?? void 0;
|
|
29
|
-
|
|
22
|
+
const valueProp = valuePropName ?? "value";
|
|
23
|
+
const element = /*#__PURE__*/ isValidElement(content) && content.type !== Fragment ? content : void 0;
|
|
24
|
+
if (status && element && "string" != typeof element.type && null == element.props.status && null == element.props.error) controlProps = {
|
|
30
25
|
...controlProps,
|
|
31
26
|
status
|
|
32
27
|
};
|
|
33
|
-
if (controlProps && "checked" === valuePropName && "checked" in controlProps && void 0 === controlProps.checked) controlProps = {
|
|
28
|
+
if (controlProps && "checked" === valuePropName && "checked" in controlProps && (void 0 === controlProps.checked || null === controlProps.checked && element?.type === "input")) controlProps = {
|
|
34
29
|
...controlProps,
|
|
35
30
|
checked: false
|
|
36
31
|
};
|
|
37
|
-
if (controlProps &&
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
if (controlProps && "value" === valueProp && null == controlProps.value) {
|
|
33
|
+
if (element?.type === "select") controlProps = {
|
|
34
|
+
...controlProps,
|
|
35
|
+
value: element.props.multiple ? [] : ""
|
|
36
|
+
};
|
|
37
|
+
else if (element?.type === "input" || element?.type === "textarea") controlProps = {
|
|
38
|
+
...controlProps,
|
|
39
|
+
value: ""
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (controlProps && element) for (const [prop, handler] of Object.entries(controlProps)){
|
|
43
|
+
const childHandler = element.props[prop];
|
|
44
|
+
if (prop !== valueProp && "function" == typeof handler && "function" == typeof childHandler) controlProps = {
|
|
45
|
+
...controlProps,
|
|
46
|
+
[prop]: "function" == typeof children ? childHandler : (...t2)=>{
|
|
47
|
+
const args = t2;
|
|
48
|
+
handler(...args);
|
|
49
|
+
childHandler(...args);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const collect = control?.onChange;
|
|
54
|
+
const valueChange = (trigger ?? "onChange") === "onChange" && "value" === valueProp && "function" == typeof collect ? {
|
|
55
|
+
onChange: controlProps?.onChange,
|
|
56
|
+
collect: (value)=>collect(value)
|
|
57
|
+
} : null;
|
|
41
58
|
if (noStyle) {
|
|
42
|
-
|
|
43
|
-
|
|
59
|
+
if (!element) return content;
|
|
60
|
+
const child = controlProps ? /*#__PURE__*/ cloneElement(element, controlProps) : element;
|
|
61
|
+
return null != name && meta ? /*#__PURE__*/ jsx(FieldControl, {
|
|
44
62
|
name: meta.name,
|
|
63
|
+
valueChange: valueChange,
|
|
45
64
|
children: child
|
|
46
65
|
}) : child;
|
|
47
66
|
}
|
|
@@ -52,12 +71,15 @@ function FormItem(t0) {
|
|
|
52
71
|
htmlFor: htmlFor,
|
|
53
72
|
required: requiredMark,
|
|
54
73
|
error: errorSlot,
|
|
74
|
+
invalid: "error" === status,
|
|
55
75
|
warning: "warning" === status,
|
|
56
76
|
description: descriptionSlot,
|
|
77
|
+
extra: extra,
|
|
57
78
|
layout: layout,
|
|
58
79
|
controlProps: controlProps,
|
|
59
80
|
renderControl: null != name && meta ? (child_0)=>/*#__PURE__*/ jsx(FieldControl, {
|
|
60
81
|
name: meta.name,
|
|
82
|
+
valueChange: valueChange,
|
|
61
83
|
children: child_0
|
|
62
84
|
}) : void 0,
|
|
63
85
|
className: className,
|
|
@@ -67,39 +89,42 @@ function FormItem(t0) {
|
|
|
67
89
|
children: content
|
|
68
90
|
});
|
|
69
91
|
};
|
|
70
|
-
$[
|
|
71
|
-
$[
|
|
72
|
-
$[
|
|
73
|
-
$[
|
|
74
|
-
$[
|
|
75
|
-
$[
|
|
76
|
-
$[
|
|
77
|
-
$[
|
|
78
|
-
$[
|
|
79
|
-
$[
|
|
80
|
-
$[
|
|
81
|
-
$[
|
|
82
|
-
$[
|
|
92
|
+
$[0] = children;
|
|
93
|
+
$[1] = className;
|
|
94
|
+
$[2] = classNames;
|
|
95
|
+
$[3] = extra;
|
|
96
|
+
$[4] = formInstance;
|
|
97
|
+
$[5] = help;
|
|
98
|
+
$[6] = htmlFor;
|
|
99
|
+
$[7] = label;
|
|
100
|
+
$[8] = layout;
|
|
101
|
+
$[9] = name;
|
|
102
|
+
$[10] = noStyle;
|
|
103
|
+
$[11] = required;
|
|
104
|
+
$[12] = rules;
|
|
105
|
+
$[13] = style;
|
|
106
|
+
$[14] = styles;
|
|
107
|
+
$[15] = trigger;
|
|
83
108
|
$[16] = validateStatus;
|
|
84
109
|
$[17] = valuePropName;
|
|
85
|
-
$[18] =
|
|
86
|
-
} else
|
|
87
|
-
const renderShell =
|
|
110
|
+
$[18] = t1;
|
|
111
|
+
} else t1 = $[18];
|
|
112
|
+
const renderShell = t1;
|
|
88
113
|
if (null == name && null == dependencies && null == shouldUpdate) {
|
|
89
|
-
const
|
|
90
|
-
let
|
|
91
|
-
if ($[19] !== renderShell || $[20] !==
|
|
92
|
-
|
|
114
|
+
const t2 = children;
|
|
115
|
+
let t3;
|
|
116
|
+
if ($[19] !== renderShell || $[20] !== t2) {
|
|
117
|
+
t3 = renderShell(t2, void 0, null);
|
|
93
118
|
$[19] = renderShell;
|
|
94
|
-
$[20] =
|
|
95
|
-
$[21] =
|
|
96
|
-
} else
|
|
97
|
-
return
|
|
119
|
+
$[20] = t2;
|
|
120
|
+
$[21] = t3;
|
|
121
|
+
} else t3 = $[21];
|
|
122
|
+
return t3;
|
|
98
123
|
}
|
|
99
|
-
const
|
|
100
|
-
let
|
|
124
|
+
const t2 = name ?? void 0;
|
|
125
|
+
let t3;
|
|
101
126
|
if ($[22] !== children || $[23] !== formInstance || $[24] !== name || $[25] !== renderShell) {
|
|
102
|
-
|
|
127
|
+
t3 = (control_0, meta_0)=>{
|
|
103
128
|
const content_0 = "function" == typeof children ? children(control_0, meta_0, formInstance) : children;
|
|
104
129
|
return renderShell(content_0, meta_0, null != name ? control_0 : null);
|
|
105
130
|
};
|
|
@@ -107,12 +132,12 @@ function FormItem(t0) {
|
|
|
107
132
|
$[23] = formInstance;
|
|
108
133
|
$[24] = name;
|
|
109
134
|
$[25] = renderShell;
|
|
110
|
-
$[26] =
|
|
111
|
-
} else
|
|
112
|
-
let
|
|
113
|
-
if ($[27] !== dependencies || $[28] !== getValueFromEvent || $[29] !== initialValue || $[30] !== messageVariables || $[31] !== normalize || $[32] !== preserve || $[33] !== rules || $[34] !== shouldUpdate || $[35] !==
|
|
114
|
-
|
|
115
|
-
name:
|
|
135
|
+
$[26] = t3;
|
|
136
|
+
} else t3 = $[26];
|
|
137
|
+
let t4;
|
|
138
|
+
if ($[27] !== dependencies || $[28] !== getValueFromEvent || $[29] !== initialValue || $[30] !== messageVariables || $[31] !== normalize || $[32] !== preserve || $[33] !== rules || $[34] !== shouldUpdate || $[35] !== t2 || $[36] !== t3 || $[37] !== trigger || $[38] !== validateFirst || $[39] !== validateTrigger || $[40] !== valuePropName) {
|
|
139
|
+
t4 = /*#__PURE__*/ jsx(Field, {
|
|
140
|
+
name: t2,
|
|
116
141
|
rules: rules,
|
|
117
142
|
initialValue: initialValue,
|
|
118
143
|
valuePropName: valuePropName,
|
|
@@ -125,7 +150,7 @@ function FormItem(t0) {
|
|
|
125
150
|
preserve: preserve,
|
|
126
151
|
messageVariables: messageVariables,
|
|
127
152
|
validateFirst: validateFirst,
|
|
128
|
-
children:
|
|
153
|
+
children: t3
|
|
129
154
|
});
|
|
130
155
|
$[27] = dependencies;
|
|
131
156
|
$[28] = getValueFromEvent;
|
|
@@ -135,17 +160,14 @@ function FormItem(t0) {
|
|
|
135
160
|
$[32] = preserve;
|
|
136
161
|
$[33] = rules;
|
|
137
162
|
$[34] = shouldUpdate;
|
|
138
|
-
$[35] =
|
|
139
|
-
$[36] =
|
|
163
|
+
$[35] = t2;
|
|
164
|
+
$[36] = t3;
|
|
140
165
|
$[37] = trigger;
|
|
141
166
|
$[38] = validateFirst;
|
|
142
167
|
$[39] = validateTrigger;
|
|
143
168
|
$[40] = valuePropName;
|
|
144
|
-
$[41] =
|
|
145
|
-
} else
|
|
146
|
-
return
|
|
147
|
-
}
|
|
148
|
-
function _temp(rule) {
|
|
149
|
-
return "object" == typeof rule && null != rule && "required" in rule && Boolean(rule.required);
|
|
169
|
+
$[41] = t4;
|
|
170
|
+
} else t4 = $[41];
|
|
171
|
+
return t4;
|
|
150
172
|
}
|
|
151
173
|
export { FormItem };
|
|
@@ -11,6 +11,7 @@ export interface FieldTarget {
|
|
|
11
11
|
id: string;
|
|
12
12
|
instance: unknown;
|
|
13
13
|
}
|
|
14
|
-
export
|
|
14
|
+
export type FieldRegistry = Map<string, Set<FieldTarget>>;
|
|
15
|
+
export declare function getFieldRegistry(form: object): FieldRegistry | undefined;
|
|
15
16
|
export declare function fieldKey(name: unknown): string;
|
|
16
17
|
export declare function useForm<Values = any>(form?: FormInstance<Values>): [FormInstance<Values>];
|
|
@@ -28,7 +28,8 @@ function use_form_useForm(form) {
|
|
|
28
28
|
...rcForm,
|
|
29
29
|
scrollToField (name, t1) {
|
|
30
30
|
const options = void 0 === t1 ? {} : t1;
|
|
31
|
-
const
|
|
31
|
+
const targets = fields.get(fieldKey(name));
|
|
32
|
+
const target = targets && Array.from(targets).at(-1);
|
|
32
33
|
if (!target) return;
|
|
33
34
|
const node = getDOM(target.instance) ?? document.getElementById(target.id);
|
|
34
35
|
if (!node) return;
|
|
@@ -11,9 +11,11 @@ export interface FormFieldViewProps {
|
|
|
11
11
|
htmlFor?: string;
|
|
12
12
|
required?: boolean;
|
|
13
13
|
error?: ReactNode;
|
|
14
|
+
invalid?: boolean;
|
|
14
15
|
/** Render the message slot with warning styling instead of error. */
|
|
15
16
|
warning?: boolean;
|
|
16
17
|
description?: ReactNode;
|
|
18
|
+
extra?: ReactNode;
|
|
17
19
|
layout?: FormFieldLayout;
|
|
18
20
|
/**
|
|
19
21
|
* Extra props cloned onto the single child control (e.g. Form.Item's
|
|
@@ -34,4 +36,4 @@ export interface FormFieldViewProps {
|
|
|
34
36
|
* with the aria wiring (describedby/errormessage/invalid/required) applied
|
|
35
37
|
* to the child control. Not part of the public API.
|
|
36
38
|
*/
|
|
37
|
-
export declare function FormFieldView({ formItem, reserveMessage, label, htmlFor, required, error, warning, description, layout, controlProps, renderControl, children, className, style, classNames, styles, }: FormFieldViewProps): import("react").JSX.Element;
|
|
39
|
+
export declare function FormFieldView({ formItem, reserveMessage, label, htmlFor, required, error, invalid, warning, description, extra, layout, controlProps, renderControl, children, className, style, classNames, styles, }: FormFieldViewProps): import("react").JSX.Element;
|
|
@@ -1,61 +1,109 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
|
-
import { cloneElement, isValidElement, useId } from "react";
|
|
3
|
+
import { Fragment, cloneElement, isValidElement, useId } from "react";
|
|
4
4
|
import { FieldLabelContext } from "../../utils/field-label.js";
|
|
5
5
|
import { cx } from "../../utils/semantic.js";
|
|
6
6
|
import "./form.css";
|
|
7
|
+
const hasContent = (value)=>null != value && '' !== value && 'boolean' != typeof value;
|
|
7
8
|
function FormFieldView(t0) {
|
|
8
|
-
const $ = c(
|
|
9
|
-
const { formItem, reserveMessage, label, htmlFor, required, error, warning, description, layout: t1, controlProps, renderControl, children, className, style, classNames, styles } = t0;
|
|
9
|
+
const $ = c(78);
|
|
10
|
+
const { formItem, reserveMessage, label, htmlFor, required, error, invalid, warning, description, extra, layout: t1, controlProps, renderControl, children, className, style, classNames, styles } = t0;
|
|
10
11
|
const layout = void 0 === t1 ? "vertical" : t1;
|
|
11
12
|
const generatedId = useId();
|
|
12
|
-
const child = /*#__PURE__*/ isValidElement(children) ? children : null;
|
|
13
|
+
const child = /*#__PURE__*/ isValidElement(children) && children.type !== Fragment ? children : null;
|
|
13
14
|
const childId = "string" == typeof child?.props.id ? child.props.id : void 0;
|
|
14
15
|
const controlId = htmlFor ?? childId ?? `${generatedId}-control`;
|
|
15
16
|
const labelId = `${generatedId}-label`;
|
|
16
17
|
const descriptionId = `${generatedId}-description`;
|
|
17
18
|
const errorId = `${generatedId}-error`;
|
|
18
|
-
const
|
|
19
|
-
|
|
19
|
+
const extraId = `${generatedId}-extra`;
|
|
20
|
+
let t2;
|
|
21
|
+
if ($[0] !== label) {
|
|
22
|
+
t2 = hasContent(label);
|
|
23
|
+
$[0] = label;
|
|
24
|
+
$[1] = t2;
|
|
25
|
+
} else t2 = $[1];
|
|
26
|
+
const hasLabel = t2;
|
|
20
27
|
let t3;
|
|
21
|
-
if ($[
|
|
22
|
-
t3 =
|
|
28
|
+
if ($[2] !== error) {
|
|
29
|
+
t3 = hasContent(error);
|
|
30
|
+
$[2] = error;
|
|
31
|
+
$[3] = t3;
|
|
32
|
+
} else t3 = $[3];
|
|
33
|
+
const hasError = t3;
|
|
34
|
+
let t4;
|
|
35
|
+
if ($[4] !== description) {
|
|
36
|
+
t4 = hasContent(description);
|
|
37
|
+
$[4] = description;
|
|
38
|
+
$[5] = t4;
|
|
39
|
+
} else t4 = $[5];
|
|
40
|
+
const hasDescription = t4;
|
|
41
|
+
let t5;
|
|
42
|
+
if ($[6] !== extra) {
|
|
43
|
+
t5 = hasContent(extra);
|
|
44
|
+
$[6] = extra;
|
|
45
|
+
$[7] = t5;
|
|
46
|
+
} else t5 = $[7];
|
|
47
|
+
const hasExtra = t5;
|
|
48
|
+
const childDescribedBy = "string" == typeof child?.props["aria-describedby"] ? child.props["aria-describedby"] : void 0;
|
|
49
|
+
const t6 = hasError ? errorId : hasDescription ? descriptionId : void 0;
|
|
50
|
+
const t7 = hasExtra ? extraId : void 0;
|
|
51
|
+
let t8;
|
|
52
|
+
if ($[8] !== childDescribedBy || $[9] !== t6 || $[10] !== t7) {
|
|
53
|
+
t8 = [
|
|
23
54
|
childDescribedBy,
|
|
24
|
-
|
|
55
|
+
t6,
|
|
56
|
+
t7
|
|
25
57
|
].filter(Boolean);
|
|
26
|
-
$[
|
|
27
|
-
$[
|
|
28
|
-
$[
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
58
|
+
$[8] = childDescribedBy;
|
|
59
|
+
$[9] = t6;
|
|
60
|
+
$[10] = t7;
|
|
61
|
+
$[11] = t8;
|
|
62
|
+
} else t8 = $[11];
|
|
63
|
+
const describedBy = t8.join(" ");
|
|
64
|
+
let t9;
|
|
65
|
+
if ($[12] !== child || $[13] !== children || $[14] !== controlId || $[15] !== controlProps || $[16] !== describedBy || $[17] !== errorId || $[18] !== hasError || $[19] !== hasLabel || $[20] !== invalid || $[21] !== labelId || $[22] !== required || $[23] !== warning) {
|
|
66
|
+
t9 = child ? /*#__PURE__*/ cloneElement(child, {
|
|
34
67
|
...controlProps,
|
|
35
68
|
id: controlId,
|
|
36
|
-
"aria-labelledby": child.props["aria-labelledby"] ?? (
|
|
69
|
+
"aria-labelledby": child.props["aria-labelledby"] ?? (hasLabel && !child.props["aria-label"] ? labelId : void 0),
|
|
37
70
|
"aria-describedby": describedBy || void 0,
|
|
38
|
-
"aria-errormessage":
|
|
39
|
-
"aria-invalid":
|
|
71
|
+
"aria-errormessage": hasError && !warning ? errorId : child.props["aria-errormessage"],
|
|
72
|
+
"aria-invalid": invalid || hasError && !warning ? true : child.props["aria-invalid"],
|
|
40
73
|
"aria-required": required ? true : child.props["aria-required"]
|
|
41
74
|
}) : children;
|
|
42
|
-
$[
|
|
43
|
-
$[
|
|
44
|
-
$[
|
|
45
|
-
$[
|
|
46
|
-
$[
|
|
47
|
-
$[
|
|
48
|
-
$[
|
|
49
|
-
$[
|
|
50
|
-
$[
|
|
51
|
-
$[
|
|
52
|
-
$[
|
|
53
|
-
$[
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
75
|
+
$[12] = child;
|
|
76
|
+
$[13] = children;
|
|
77
|
+
$[14] = controlId;
|
|
78
|
+
$[15] = controlProps;
|
|
79
|
+
$[16] = describedBy;
|
|
80
|
+
$[17] = errorId;
|
|
81
|
+
$[18] = hasError;
|
|
82
|
+
$[19] = hasLabel;
|
|
83
|
+
$[20] = invalid;
|
|
84
|
+
$[21] = labelId;
|
|
85
|
+
$[22] = required;
|
|
86
|
+
$[23] = warning;
|
|
87
|
+
$[24] = t9;
|
|
88
|
+
} else t9 = $[24];
|
|
89
|
+
const control = t9;
|
|
90
|
+
let t10;
|
|
91
|
+
if ($[25] !== classNames?.description || $[26] !== styles?.description) {
|
|
92
|
+
t10 = (id, content)=>/*#__PURE__*/ jsx("p", {
|
|
93
|
+
className: classNames?.description,
|
|
94
|
+
style: styles?.description,
|
|
95
|
+
"data-tao-form-description": "",
|
|
96
|
+
id: id,
|
|
97
|
+
children: content
|
|
98
|
+
});
|
|
99
|
+
$[25] = classNames?.description;
|
|
100
|
+
$[26] = styles?.description;
|
|
101
|
+
$[27] = t10;
|
|
102
|
+
} else t10 = $[27];
|
|
103
|
+
const descriptionMessage = t10;
|
|
104
|
+
let t11;
|
|
105
|
+
if ($[28] !== classNames?.error || $[29] !== description || $[30] !== descriptionId || $[31] !== descriptionMessage || $[32] !== error || $[33] !== errorId || $[34] !== hasDescription || $[35] !== hasError || $[36] !== styles?.error || $[37] !== warning) {
|
|
106
|
+
t11 = hasError ? /*#__PURE__*/ jsx("p", {
|
|
59
107
|
className: classNames?.error,
|
|
60
108
|
style: styles?.error,
|
|
61
109
|
"data-tao-form-error": "",
|
|
@@ -63,51 +111,46 @@ function FormFieldView(t0) {
|
|
|
63
111
|
id: errorId,
|
|
64
112
|
role: "alert",
|
|
65
113
|
children: error
|
|
66
|
-
}) :
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
$[
|
|
74
|
-
$[
|
|
75
|
-
$[
|
|
76
|
-
$[
|
|
77
|
-
$[
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const t8 = styles?.root;
|
|
95
|
-
let t9;
|
|
96
|
-
if ($[28] !== style || $[29] !== t8) {
|
|
97
|
-
t9 = {
|
|
98
|
-
...t8,
|
|
114
|
+
}) : hasDescription ? descriptionMessage(descriptionId, description) : null;
|
|
115
|
+
$[28] = classNames?.error;
|
|
116
|
+
$[29] = description;
|
|
117
|
+
$[30] = descriptionId;
|
|
118
|
+
$[31] = descriptionMessage;
|
|
119
|
+
$[32] = error;
|
|
120
|
+
$[33] = errorId;
|
|
121
|
+
$[34] = hasDescription;
|
|
122
|
+
$[35] = hasError;
|
|
123
|
+
$[36] = styles?.error;
|
|
124
|
+
$[37] = warning;
|
|
125
|
+
$[38] = t11;
|
|
126
|
+
} else t11 = $[38];
|
|
127
|
+
const message = t11;
|
|
128
|
+
const hasMessage = formItem && (reserveMessage || null !== message || hasExtra);
|
|
129
|
+
const t12 = classNames?.root;
|
|
130
|
+
let t13;
|
|
131
|
+
if ($[39] !== className || $[40] !== t12) {
|
|
132
|
+
t13 = cx(t12, className);
|
|
133
|
+
$[39] = className;
|
|
134
|
+
$[40] = t12;
|
|
135
|
+
$[41] = t13;
|
|
136
|
+
} else t13 = $[41];
|
|
137
|
+
const t14 = styles?.root;
|
|
138
|
+
let t15;
|
|
139
|
+
if ($[42] !== style || $[43] !== t14) {
|
|
140
|
+
t15 = {
|
|
141
|
+
...t14,
|
|
99
142
|
...style
|
|
100
143
|
};
|
|
101
|
-
$[
|
|
102
|
-
$[
|
|
103
|
-
$[
|
|
104
|
-
} else
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
let
|
|
109
|
-
if ($[
|
|
110
|
-
|
|
144
|
+
$[42] = style;
|
|
145
|
+
$[43] = t14;
|
|
146
|
+
$[44] = t15;
|
|
147
|
+
} else t15 = $[44];
|
|
148
|
+
const t16 = formItem ? "" : void 0;
|
|
149
|
+
const t17 = hasMessage ? "" : void 0;
|
|
150
|
+
const t18 = "horizontal" === layout ? "horizontal" : void 0;
|
|
151
|
+
let t19;
|
|
152
|
+
if ($[45] !== classNames?.label || $[46] !== controlId || $[47] !== hasLabel || $[48] !== label || $[49] !== labelId || $[50] !== required || $[51] !== styles?.label) {
|
|
153
|
+
t19 = hasLabel && /*#__PURE__*/ jsxs("label", {
|
|
111
154
|
id: labelId,
|
|
112
155
|
htmlFor: controlId,
|
|
113
156
|
className: classNames?.label,
|
|
@@ -122,77 +165,87 @@ function FormFieldView(t0) {
|
|
|
122
165
|
})
|
|
123
166
|
]
|
|
124
167
|
});
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
127
|
-
$[
|
|
128
|
-
$[
|
|
129
|
-
$[
|
|
130
|
-
$[
|
|
131
|
-
$[
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
$[
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
168
|
+
$[45] = classNames?.label;
|
|
169
|
+
$[46] = controlId;
|
|
170
|
+
$[47] = hasLabel;
|
|
171
|
+
$[48] = label;
|
|
172
|
+
$[49] = labelId;
|
|
173
|
+
$[50] = required;
|
|
174
|
+
$[51] = styles?.label;
|
|
175
|
+
$[52] = t19;
|
|
176
|
+
} else t19 = $[52];
|
|
177
|
+
const t20 = hasLabel ? label : void 0;
|
|
178
|
+
let t21;
|
|
179
|
+
if ($[53] !== child || $[54] !== control || $[55] !== renderControl) {
|
|
180
|
+
t21 = renderControl && child && /*#__PURE__*/ isValidElement(control) ? renderControl(control) : control;
|
|
181
|
+
$[53] = child;
|
|
182
|
+
$[54] = control;
|
|
183
|
+
$[55] = renderControl;
|
|
184
|
+
$[56] = t21;
|
|
185
|
+
} else t21 = $[56];
|
|
186
|
+
let t22;
|
|
187
|
+
if ($[57] !== t20 || $[58] !== t21) {
|
|
188
|
+
t22 = /*#__PURE__*/ jsx(FieldLabelContext.Provider, {
|
|
189
|
+
value: t20,
|
|
190
|
+
children: t21
|
|
145
191
|
});
|
|
146
|
-
$[
|
|
147
|
-
$[
|
|
148
|
-
$[
|
|
149
|
-
} else
|
|
150
|
-
let
|
|
151
|
-
if ($[
|
|
152
|
-
|
|
192
|
+
$[57] = t20;
|
|
193
|
+
$[58] = t21;
|
|
194
|
+
$[59] = t22;
|
|
195
|
+
} else t22 = $[59];
|
|
196
|
+
let t23;
|
|
197
|
+
if ($[60] !== descriptionMessage || $[61] !== extra || $[62] !== extraId || $[63] !== hasExtra || $[64] !== hasMessage || $[65] !== message) {
|
|
198
|
+
t23 = hasMessage ? /*#__PURE__*/ jsxs("div", {
|
|
153
199
|
"data-tao-form-message": "",
|
|
154
|
-
children:
|
|
200
|
+
children: [
|
|
201
|
+
message,
|
|
202
|
+
hasExtra && descriptionMessage(extraId, extra)
|
|
203
|
+
]
|
|
155
204
|
}) : message;
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
205
|
+
$[60] = descriptionMessage;
|
|
206
|
+
$[61] = extra;
|
|
207
|
+
$[62] = extraId;
|
|
208
|
+
$[63] = hasExtra;
|
|
209
|
+
$[64] = hasMessage;
|
|
210
|
+
$[65] = message;
|
|
211
|
+
$[66] = t23;
|
|
212
|
+
} else t23 = $[66];
|
|
213
|
+
let t24;
|
|
214
|
+
if ($[67] !== t22 || $[68] !== t23) {
|
|
215
|
+
t24 = /*#__PURE__*/ jsxs("div", {
|
|
163
216
|
"data-tao-form-control": "",
|
|
164
217
|
children: [
|
|
165
|
-
|
|
166
|
-
|
|
218
|
+
t22,
|
|
219
|
+
t23
|
|
167
220
|
]
|
|
168
221
|
});
|
|
169
|
-
$[
|
|
170
|
-
$[
|
|
171
|
-
$[
|
|
172
|
-
} else
|
|
173
|
-
let
|
|
174
|
-
if ($[
|
|
175
|
-
|
|
176
|
-
className:
|
|
177
|
-
style:
|
|
222
|
+
$[67] = t22;
|
|
223
|
+
$[68] = t23;
|
|
224
|
+
$[69] = t24;
|
|
225
|
+
} else t24 = $[69];
|
|
226
|
+
let t25;
|
|
227
|
+
if ($[70] !== t13 || $[71] !== t15 || $[72] !== t16 || $[73] !== t17 || $[74] !== t18 || $[75] !== t19 || $[76] !== t24) {
|
|
228
|
+
t25 = /*#__PURE__*/ jsxs("div", {
|
|
229
|
+
className: t13,
|
|
230
|
+
style: t15,
|
|
178
231
|
"data-tao-form-field": "",
|
|
179
|
-
"data-tao-form-item":
|
|
180
|
-
"data-tao-form-feedback":
|
|
181
|
-
"data-tao-layout":
|
|
232
|
+
"data-tao-form-item": t16,
|
|
233
|
+
"data-tao-form-feedback": t17,
|
|
234
|
+
"data-tao-layout": t18,
|
|
182
235
|
children: [
|
|
183
|
-
|
|
184
|
-
|
|
236
|
+
t19,
|
|
237
|
+
t24
|
|
185
238
|
]
|
|
186
239
|
});
|
|
187
|
-
$[
|
|
188
|
-
$[
|
|
189
|
-
$[
|
|
190
|
-
$[
|
|
191
|
-
$[
|
|
192
|
-
$[
|
|
193
|
-
$[
|
|
194
|
-
$[
|
|
195
|
-
} else
|
|
196
|
-
return
|
|
240
|
+
$[70] = t13;
|
|
241
|
+
$[71] = t15;
|
|
242
|
+
$[72] = t16;
|
|
243
|
+
$[73] = t17;
|
|
244
|
+
$[74] = t18;
|
|
245
|
+
$[75] = t19;
|
|
246
|
+
$[76] = t24;
|
|
247
|
+
$[77] = t25;
|
|
248
|
+
} else t25 = $[77];
|
|
249
|
+
return t25;
|
|
197
250
|
}
|
|
198
251
|
export { FormFieldView };
|