@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.
Files changed (147) hide show
  1. package/dist/components/affix/affix.js +20 -16
  2. package/dist/components/alert/alert.js +114 -99
  3. package/dist/components/app/app-modals.js +134 -96
  4. package/dist/components/app/app-notices.js +39 -23
  5. package/dist/components/auto-complete/auto-complete.js +21 -7
  6. package/dist/components/avatar/avatar.js +31 -11
  7. package/dist/components/badge/badge.css +1 -1
  8. package/dist/components/badge/badge.js +72 -257
  9. package/dist/components/border-beam/border-beam.js +21 -17
  10. package/dist/components/breadcrumb/breadcrumb.js +178 -159
  11. package/dist/components/button/button.css +9 -1
  12. package/dist/components/button/button.js +61 -53
  13. package/dist/components/calendar/calendar.js +6 -4
  14. package/dist/components/card/card.js +24 -8
  15. package/dist/components/carousel/carousel.d.ts +1 -1
  16. package/dist/components/carousel/carousel.js +105 -68
  17. package/dist/components/cascader/cascader.js +54 -19
  18. package/dist/components/checkbox/checkbox.css +13 -2
  19. package/dist/components/checkbox/checkbox.d.ts +2 -0
  20. package/dist/components/checkbox/checkbox.js +320 -229
  21. package/dist/components/collapse/collapse-panels.d.ts +1 -1
  22. package/dist/components/collapse/collapse-panels.js +122 -113
  23. package/dist/components/collapse/collapse.js +98 -63
  24. package/dist/components/color-picker/color-picker.js +539 -441
  25. package/dist/components/color-picker/color.js +1 -1
  26. package/dist/components/context-menu/context-menu.d.ts +1 -1
  27. package/dist/components/context-menu/context-menu.js +108 -68
  28. package/dist/components/date-picker/calendar/calendar-grid.js +42 -39
  29. package/dist/components/date-picker/calendar/month-grid.d.ts +8 -1
  30. package/dist/components/date-picker/calendar/month-grid.js +79 -37
  31. package/dist/components/date-picker/calendar/time-panel.d.ts +2 -1
  32. package/dist/components/date-picker/calendar/time-panel.js +94 -89
  33. package/dist/components/date-picker/calendar/year-grid.d.ts +8 -1
  34. package/dist/components/date-picker/calendar/year-grid.js +66 -35
  35. package/dist/components/date-picker/date-picker.css +24 -1
  36. package/dist/components/date-picker/date-picker.js +99 -53
  37. package/dist/components/date-picker/presets.d.ts +2 -1
  38. package/dist/components/date-picker/presets.js +27 -24
  39. package/dist/components/date-picker/range-picker.js +308 -153
  40. package/dist/components/descriptions/descriptions.js +7 -3
  41. package/dist/components/divider/divider.css +1 -1
  42. package/dist/components/divider/divider.js +1 -1
  43. package/dist/components/drawer/drawer.js +201 -369
  44. package/dist/components/dropdown/dropdown.d.ts +1 -1
  45. package/dist/components/dropdown/dropdown.js +183 -279
  46. package/dist/components/empty/empty.js +57 -78
  47. package/dist/components/float-button/float-button.d.ts +1 -0
  48. package/dist/components/float-button/float-button.js +47 -30
  49. package/dist/components/form/field-control.d.ts +4 -2
  50. package/dist/components/form/field-control.js +17 -9
  51. package/dist/components/form/form-context.d.ts +8 -2
  52. package/dist/components/form/form-context.js +2 -1
  53. package/dist/components/form/form-item.js +85 -63
  54. package/dist/components/form/use-form.d.ts +2 -1
  55. package/dist/components/form/use-form.js +2 -1
  56. package/dist/components/form-field/form-field-view.d.ts +3 -1
  57. package/dist/components/form-field/form-field-view.js +194 -141
  58. package/dist/components/form-section/form-section.d.ts +1 -1
  59. package/dist/components/form-section/form-section.js +52 -45
  60. package/dist/components/image/image.js +585 -477
  61. package/dist/components/input/base-input.js +8 -9
  62. package/dist/components/input/input-shared.d.ts +5 -2
  63. package/dist/components/input/input-shared.js +42 -18
  64. package/dist/components/input/input.css +1 -0
  65. package/dist/components/input/otp.js +236 -217
  66. package/dist/components/input/password.js +2 -1
  67. package/dist/components/input/search.js +8 -7
  68. package/dist/components/list/list-pagination.js +41 -36
  69. package/dist/components/list/list.js +141 -125
  70. package/dist/components/listy/listy.js +175 -106
  71. package/dist/components/masonry/masonry.js +108 -85
  72. package/dist/components/mentions/mentions.js +12 -3
  73. package/dist/components/menu/menu-render.d.ts +9 -3
  74. package/dist/components/menu/menu-render.js +99 -36
  75. package/dist/components/modal/confirm-dialog.js +10 -4
  76. package/dist/components/modal/confirm.js +3 -7
  77. package/dist/components/modal/index.js +9 -3
  78. package/dist/components/modal/modal.js +390 -365
  79. package/dist/components/pagination/pagination.js +105 -96
  80. package/dist/components/popconfirm/popconfirm.d.ts +1 -1
  81. package/dist/components/popconfirm/popconfirm.js +219 -168
  82. package/dist/components/popover/popover.js +330 -243
  83. package/dist/components/progress/progress.css +2 -2
  84. package/dist/components/progress/progress.js +232 -458
  85. package/dist/components/qr-code/qr-code.js +72 -66
  86. package/dist/components/radio/radio.css +15 -4
  87. package/dist/components/radio/radio.d.ts +2 -1
  88. package/dist/components/radio/radio.js +260 -198
  89. package/dist/components/rate/rate.js +173 -113
  90. package/dist/components/scroll-area/scroll-area.js +241 -211
  91. package/dist/components/segmented/segmented.js +73 -41
  92. package/dist/components/select/mobile-select.d.ts +2 -1
  93. package/dist/components/select/mobile-select.js +24 -13
  94. package/dist/components/select/select-searchable-list.d.ts +2 -1
  95. package/dist/components/select/select-searchable-list.js +2 -3
  96. package/dist/components/select/select.css +3 -2
  97. package/dist/components/select/select.js +49 -25
  98. package/dist/components/select/use-select-selection.d.ts +1 -1
  99. package/dist/components/select/use-select-selection.js +7 -4
  100. package/dist/components/skeleton/skeleton.js +56 -48
  101. package/dist/components/slider/slider.js +87 -212
  102. package/dist/components/sonner/sonner.js +109 -93
  103. package/dist/components/spinner/spinner.js +147 -138
  104. package/dist/components/splitter/splitter.js +222 -159
  105. package/dist/components/statistic/statistic.js +7 -6
  106. package/dist/components/steps/steps.js +88 -81
  107. package/dist/components/steps/use-display-steps.js +1 -1
  108. package/dist/components/switch/switch.js +89 -89
  109. package/dist/components/table/table-filter.js +66 -56
  110. package/dist/components/table/table-icons.d.ts +2 -1
  111. package/dist/components/table/table-icons.js +11 -9
  112. package/dist/components/table/table-model.js +1 -1
  113. package/dist/components/table/table.js +107 -83
  114. package/dist/components/table/use-table-data.d.ts +6 -3
  115. package/dist/components/table/use-table-data.js +166 -130
  116. package/dist/components/tabs/tabs.css +1 -1
  117. package/dist/components/tabs/tabs.js +236 -179
  118. package/dist/components/tag/tag.d.ts +2 -2
  119. package/dist/components/tag/tag.js +111 -108
  120. package/dist/components/textarea/textarea.js +22 -17
  121. package/dist/components/time-picker/time-picker.js +5 -3
  122. package/dist/components/timeline/timeline.css +6 -1
  123. package/dist/components/timeline/timeline.js +21 -11
  124. package/dist/components/tooltip/tooltip.d.ts +2 -2
  125. package/dist/components/tooltip/tooltip.js +123 -233
  126. package/dist/components/tour/tour.css +4 -0
  127. package/dist/components/tour/tour.js +400 -331
  128. package/dist/components/transfer/transfer-list.js +31 -12
  129. package/dist/components/transfer/transfer-parts.js +1 -1
  130. package/dist/components/transfer/transfer-types.d.ts +1 -0
  131. package/dist/components/transfer/transfer.css +5 -0
  132. package/dist/components/transfer/transfer.js +29 -14
  133. package/dist/components/tree/tree-keyboard.d.ts +1 -1
  134. package/dist/components/tree/tree-keyboard.js +5 -3
  135. package/dist/components/tree/tree.js +74 -59
  136. package/dist/components/tree-select/select-engine.d.ts +3 -2
  137. package/dist/components/tree-select/select-engine.js +18 -16
  138. package/dist/components/tree-select/tree-select.js +21 -5
  139. package/dist/components/upload/upload.css +8 -0
  140. package/dist/components/upload/upload.js +160 -72
  141. package/dist/components/watermark/watermark.js +36 -29
  142. package/dist/number-input/use-number-input.js +129 -90
  143. package/dist/number-input/validate.js +32 -5
  144. package/dist/provider/merge-locale.js +12 -9
  145. package/dist/provider/tao-provider.d.ts +3 -1
  146. package/dist/provider/tao-provider.js +123 -86
  147. 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] !== required || $[1] !== rules) {
14
- t1 = required ?? rules?.some(_temp) ?? false;
15
- $[0] = required;
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 = extra ?? (showAsStatus ? void 0 : message);
20
+ const descriptionSlot = showAsStatus ? void 0 : message;
28
21
  let controlProps = control ?? void 0;
29
- if (controlProps && status && /*#__PURE__*/ isValidElement(content) && "string" != typeof content.type && null == content.props.status && null == content.props.error) controlProps = {
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 && /*#__PURE__*/ isValidElement(content) && ("input" === content.type || "textarea" === content.type) && null == valuePropName && void 0 === controlProps.value) controlProps = {
38
- ...controlProps,
39
- value: ""
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
- const child = /*#__PURE__*/ isValidElement(content) && controlProps ? /*#__PURE__*/ cloneElement(content, controlProps) : content;
43
- return null != name && meta && /*#__PURE__*/ isValidElement(child) ? /*#__PURE__*/ jsx(FieldControl, {
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
- $[3] = className;
71
- $[4] = classNames;
72
- $[5] = extra;
73
- $[6] = help;
74
- $[7] = htmlFor;
75
- $[8] = label;
76
- $[9] = layout;
77
- $[10] = name;
78
- $[11] = noStyle;
79
- $[12] = requiredMark;
80
- $[13] = rules?.length;
81
- $[14] = style;
82
- $[15] = styles;
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] = t2;
86
- } else t2 = $[18];
87
- const renderShell = t2;
110
+ $[18] = t1;
111
+ } else t1 = $[18];
112
+ const renderShell = t1;
88
113
  if (null == name && null == dependencies && null == shouldUpdate) {
89
- const t3 = children;
90
- let t4;
91
- if ($[19] !== renderShell || $[20] !== t3) {
92
- t4 = renderShell(t3, void 0, null);
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] = t3;
95
- $[21] = t4;
96
- } else t4 = $[21];
97
- return t4;
119
+ $[20] = t2;
120
+ $[21] = t3;
121
+ } else t3 = $[21];
122
+ return t3;
98
123
  }
99
- const t3 = name ?? void 0;
100
- let t4;
124
+ const t2 = name ?? void 0;
125
+ let t3;
101
126
  if ($[22] !== children || $[23] !== formInstance || $[24] !== name || $[25] !== renderShell) {
102
- t4 = (control_0, meta_0)=>{
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] = t4;
111
- } else t4 = $[26];
112
- let t5;
113
- if ($[27] !== dependencies || $[28] !== getValueFromEvent || $[29] !== initialValue || $[30] !== messageVariables || $[31] !== normalize || $[32] !== preserve || $[33] !== rules || $[34] !== shouldUpdate || $[35] !== t3 || $[36] !== t4 || $[37] !== trigger || $[38] !== validateFirst || $[39] !== validateTrigger || $[40] !== valuePropName) {
114
- t5 = /*#__PURE__*/ jsx(Field, {
115
- name: t3,
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: t4
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] = t3;
139
- $[36] = t4;
163
+ $[35] = t2;
164
+ $[36] = t3;
140
165
  $[37] = trigger;
141
166
  $[38] = validateFirst;
142
167
  $[39] = validateTrigger;
143
168
  $[40] = valuePropName;
144
- $[41] = t5;
145
- } else t5 = $[41];
146
- return t5;
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 declare function getFieldRegistry(form: object): Map<string, FieldTarget> | undefined;
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 target = fields.get(fieldKey(name));
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(58);
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 childDescribedBy = "string" == typeof child?.props["aria-describedby"] ? child.props["aria-describedby"] : void 0;
19
- const t2 = error ? errorId : description ? descriptionId : void 0;
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 ($[0] !== childDescribedBy || $[1] !== t2) {
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
- t2
55
+ t6,
56
+ t7
25
57
  ].filter(Boolean);
26
- $[0] = childDescribedBy;
27
- $[1] = t2;
28
- $[2] = t3;
29
- } else t3 = $[2];
30
- const describedBy = t3.join(" ");
31
- let t4;
32
- if ($[3] !== child || $[4] !== children || $[5] !== controlId || $[6] !== controlProps || $[7] !== describedBy || $[8] !== error || $[9] !== errorId || $[10] !== label || $[11] !== labelId || $[12] !== required || $[13] !== warning) {
33
- t4 = child ? /*#__PURE__*/ cloneElement(child, {
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"] ?? (null == label || child.props["aria-label"] ? void 0 : labelId),
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": error && !warning ? errorId : child.props["aria-errormessage"],
39
- "aria-invalid": error && !warning ? true : child.props["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
- $[3] = child;
43
- $[4] = children;
44
- $[5] = controlId;
45
- $[6] = controlProps;
46
- $[7] = describedBy;
47
- $[8] = error;
48
- $[9] = errorId;
49
- $[10] = label;
50
- $[11] = labelId;
51
- $[12] = required;
52
- $[13] = warning;
53
- $[14] = t4;
54
- } else t4 = $[14];
55
- const control = t4;
56
- let t5;
57
- if ($[15] !== classNames?.description || $[16] !== classNames?.error || $[17] !== description || $[18] !== descriptionId || $[19] !== error || $[20] !== errorId || $[21] !== styles?.description || $[22] !== styles?.error || $[23] !== warning) {
58
- t5 = error ? /*#__PURE__*/ jsx("p", {
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
- }) : description ? /*#__PURE__*/ jsx("p", {
67
- className: classNames?.description,
68
- style: styles?.description,
69
- "data-tao-form-description": "",
70
- id: descriptionId,
71
- children: description
72
- }) : null;
73
- $[15] = classNames?.description;
74
- $[16] = classNames?.error;
75
- $[17] = description;
76
- $[18] = descriptionId;
77
- $[19] = error;
78
- $[20] = errorId;
79
- $[21] = styles?.description;
80
- $[22] = styles?.error;
81
- $[23] = warning;
82
- $[24] = t5;
83
- } else t5 = $[24];
84
- const message = t5;
85
- const hasMessage = formItem && (reserveMessage || null !== message);
86
- const t6 = classNames?.root;
87
- let t7;
88
- if ($[25] !== className || $[26] !== t6) {
89
- t7 = cx(t6, className);
90
- $[25] = className;
91
- $[26] = t6;
92
- $[27] = t7;
93
- } else t7 = $[27];
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
- $[28] = style;
102
- $[29] = t8;
103
- $[30] = t9;
104
- } else t9 = $[30];
105
- const t10 = formItem ? "" : void 0;
106
- const t11 = hasMessage ? "" : void 0;
107
- const t12 = "horizontal" === layout ? "horizontal" : void 0;
108
- let t13;
109
- if ($[31] !== classNames?.label || $[32] !== controlId || $[33] !== label || $[34] !== labelId || $[35] !== required || $[36] !== styles?.label) {
110
- t13 = null != label && /*#__PURE__*/ jsxs("label", {
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
- $[31] = classNames?.label;
126
- $[32] = controlId;
127
- $[33] = label;
128
- $[34] = labelId;
129
- $[35] = required;
130
- $[36] = styles?.label;
131
- $[37] = t13;
132
- } else t13 = $[37];
133
- let t14;
134
- if ($[38] !== control || $[39] !== renderControl) {
135
- t14 = renderControl && /*#__PURE__*/ isValidElement(control) ? renderControl(control) : control;
136
- $[38] = control;
137
- $[39] = renderControl;
138
- $[40] = t14;
139
- } else t14 = $[40];
140
- let t15;
141
- if ($[41] !== label || $[42] !== t14) {
142
- t15 = /*#__PURE__*/ jsx(FieldLabelContext.Provider, {
143
- value: label,
144
- children: t14
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
- $[41] = label;
147
- $[42] = t14;
148
- $[43] = t15;
149
- } else t15 = $[43];
150
- let t16;
151
- if ($[44] !== hasMessage || $[45] !== message) {
152
- t16 = hasMessage ? /*#__PURE__*/ jsx("div", {
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: message
200
+ children: [
201
+ message,
202
+ hasExtra && descriptionMessage(extraId, extra)
203
+ ]
155
204
  }) : message;
156
- $[44] = hasMessage;
157
- $[45] = message;
158
- $[46] = t16;
159
- } else t16 = $[46];
160
- let t17;
161
- if ($[47] !== t15 || $[48] !== t16) {
162
- t17 = /*#__PURE__*/ jsxs("div", {
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
- t15,
166
- t16
218
+ t22,
219
+ t23
167
220
  ]
168
221
  });
169
- $[47] = t15;
170
- $[48] = t16;
171
- $[49] = t17;
172
- } else t17 = $[49];
173
- let t18;
174
- if ($[50] !== t10 || $[51] !== t11 || $[52] !== t12 || $[53] !== t13 || $[54] !== t17 || $[55] !== t7 || $[56] !== t9) {
175
- t18 = /*#__PURE__*/ jsxs("div", {
176
- className: t7,
177
- style: t9,
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": t10,
180
- "data-tao-form-feedback": t11,
181
- "data-tao-layout": t12,
232
+ "data-tao-form-item": t16,
233
+ "data-tao-form-feedback": t17,
234
+ "data-tao-layout": t18,
182
235
  children: [
183
- t13,
184
- t17
236
+ t19,
237
+ t24
185
238
  ]
186
239
  });
187
- $[50] = t10;
188
- $[51] = t11;
189
- $[52] = t12;
190
- $[53] = t13;
191
- $[54] = t17;
192
- $[55] = t7;
193
- $[56] = t9;
194
- $[57] = t18;
195
- } else t18 = $[57];
196
- return t18;
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 };