@rockshin/tao-ui 0.0.46 → 0.0.48

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 CHANGED
@@ -55,7 +55,7 @@ Automated regression checks cover DOM semantics and keyboard interactions in Rea
55
55
 
56
56
  ### Responsive controls and language
57
57
 
58
- Select, DatePicker and RangePicker adapt to the viewport. Select keeps its current editing surface while open, supports `maxTagCount="responsive"`, and shares selection limits, controlled search and tag creation across desktop and mobile. Coarse pointers receive larger targets for basic controls.
58
+ Select, Cascader, DatePicker and RangePicker adapt to the viewport. Select keeps its current editing surface while open, supports `maxTagCount="responsive"`, and shares selection limits, controlled search and tag creation across desktop and mobile. Cascader uses a bottom drawer on phones, with immediate single selection and Done/cancel for multiple selection. Coarse pointers receive larger targets for basic controls.
59
59
 
60
60
  ```tsx
61
61
  import { TaoProvider, zhCN } from '@rockshin/tao-ui/provider';
@@ -142,7 +142,7 @@ Import types from the root or `@rockshin/tao-ui/util`. Compound APIs share their
142
142
 
143
143
  Responsive helpers: `useBreakpoint`, `useIsMobile`, plus breakpoint-map props on
144
144
  `Stack` (`direction`/`gap`/`align`), `Modal` (`width`), and `Table` (column
145
- `responsive`). `Select` / `DatePicker` / `RangePicker` render as bottom drawers
145
+ `responsive`). `Select` / `Cascader` / `DatePicker` / `RangePicker` render as bottom drawers
146
146
  on phones automatically.
147
147
 
148
148
  Headless utilities: `useNumberInput` / `NumberInput`, and the `cx` semantic-class helper.
@@ -1,3 +1,41 @@
1
+ [data-tao-cascader] [class$="-clear"] {
2
+ background: none;
3
+ width: 16px;
4
+ height: 16px;
5
+ }
6
+
7
+ [data-tao-cascader]:has( > [class*="-suffix"]) > [class$="-clear"] {
8
+ inset-inline-end: 8px;
9
+ position: absolute;
10
+ top: 50%;
11
+ transform: translateY(-50%);
12
+ }
13
+
14
+ [data-tao-cascader]:has( > [class$="-clear"]) > [class*="-suffix"] {
15
+ visibility: hidden;
16
+ }
17
+
18
+ @media (hover: hover) and (pointer: fine) {
19
+ [data-tao-cascader]:not(:hover):not(:has([class$="-clear"]:focus-visible)) > [class*="-suffix"] {
20
+ visibility: visible;
21
+ }
22
+ }
23
+
24
+ @media (pointer: coarse) {
25
+ [data-tao-cascader]:has( > [class*="-suffix"]):has( > [class$="-clear"]) {
26
+ padding-inline-end: 52px;
27
+ }
28
+
29
+ [data-tao-cascader] > [class$="-clear"] {
30
+ width: 44px;
31
+ height: 44px;
32
+ }
33
+
34
+ [data-tao-cascader]:has( > [class$="-clear"]) > [class*="-suffix"] {
35
+ display: none;
36
+ }
37
+ }
38
+
1
39
  [data-tao-cascader-popup] {
2
40
  color: var(--tao-color-text);
3
41
  font: var(--tao-font-size-base) / var(--tao-line-height) var(--tao-font-family);
@@ -69,12 +107,72 @@
69
107
  min-width: 0;
70
108
  }
71
109
 
110
+ [data-tao-cascader-popup] [class$="-menu-item-expand-icon"] {
111
+ justify-content: center;
112
+ align-items: center;
113
+ display: flex;
114
+ }
115
+
72
116
  [data-tao-cascader-expand] {
73
117
  align-items: center;
74
118
  display: inline-flex;
75
119
  transform: rotate(-90deg);
76
120
  }
77
121
 
122
+ [data-tao-drawer]:has([data-tao-cascader-mobile]) [data-tao-drawer-body] {
123
+ flex-direction: column;
124
+ min-height: 0;
125
+ padding: 0;
126
+ display: flex;
127
+ overflow: hidden;
128
+ }
129
+
130
+ [data-tao-cascader-mobile] {
131
+ flex: 1;
132
+ min-height: 0;
133
+ display: flex;
134
+ }
135
+
136
+ [data-tao-cascader-mobile-container] {
137
+ border: 0;
138
+ flex: 1;
139
+ min-width: 0;
140
+ min-height: 0;
141
+ margin: 0;
142
+ padding: 0;
143
+ display: flex;
144
+ overflow: hidden;
145
+ }
146
+
147
+ [data-tao-cascader-mobile] [class$="-menus"] {
148
+ flex: 1;
149
+ min-height: 0;
150
+ }
151
+
152
+ [data-tao-cascader-mobile] [class$="-menu"] {
153
+ overscroll-behavior: contain;
154
+ max-width: none;
155
+ height: auto;
156
+ }
157
+
158
+ [data-tao-cascader-mobile] li[class*="-menu-item"] {
159
+ min-height: 44px;
160
+ }
161
+
162
+ [data-tao-cascader-search] {
163
+ width: 100%;
164
+ min-height: 44px;
165
+ padding: var(--tao-padding-xs) var(--tao-padding);
166
+ border: 0;
167
+ border-block-end: var(--tao-line-width) solid
168
+ var(--tao-color-border-secondary);
169
+ color: var(--tao-color-text);
170
+ font: inherit;
171
+ background: none;
172
+ flex: none;
173
+ font-size: 16px;
174
+ }
175
+
78
176
  [data-tao-cascader-popup]:dir(rtl) [data-tao-cascader-expand] {
79
177
  transform: rotate(90deg);
80
178
  }
@@ -15,6 +15,10 @@ export type CascaderSemanticType = {
15
15
  };
16
16
  export interface CascaderProps<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType, Multiple extends boolean = boolean> extends Omit<RcCascaderProps<OptionType, ValueField, Multiple>, 'checkable' | 'classNames' | 'styles' | 'popupRender'> {
17
17
  multiple?: Multiple;
18
+ /** Use a bottom drawer. Automatically enabled below 576px. */
19
+ mobile?: boolean;
20
+ /** Drawer title; defaults to the field label, then localized selection text. */
21
+ mobileTitle?: ReactNode;
18
22
  size?: TaoSize | 'middle';
19
23
  variant?: SelectEngineVariant;
20
24
  status?: TaoStatus;
@@ -1,7 +1,8 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
3
  import cascader, { Panel } from "@rc-component/cascader";
4
- import { forwardRef, useMemo } from "react";
4
+ import { forwardRef, useMemo, useRef, useState } from "react";
5
+ import { createPortal } from "react-dom";
5
6
  import { useTaoDirection, useTaoInternalConfig } from "../../provider/tao-provider.js";
6
7
  import { mergeRefs } from "../../utils/refs.js";
7
8
  import { cx } from "../../utils/semantic.js";
@@ -10,8 +11,19 @@ import { Spinner } from "../spinner/spinner.js";
10
11
  import { SelectEnginePopup, selectAllowClear } from "../tree-select/select-engine.js";
11
12
  import "../tree-select/select-engine.css";
12
13
  import "./cascader.css";
14
+ import { useBreakpoint } from "../../utils/breakpoint.js";
15
+ import { useMobileTitle } from "../../utils/field-label.js";
13
16
  import { interopDefault } from "../../utils/interop-default.js";
17
+ import { Button } from "../button/button.js";
18
+ import { Drawer } from "../drawer/drawer.js";
14
19
  const RcCascaderComponent = /*#__PURE__*/ interopDefault(cascader);
20
+ const NAVIGATION_KEYS = {
21
+ ArrowLeft: 37,
22
+ ArrowUp: 38,
23
+ ArrowRight: 39,
24
+ ArrowDown: 40,
25
+ Enter: 13
26
+ };
15
27
  function ExpandIcon() {
16
28
  const $ = c(1);
17
29
  let t0;
@@ -26,7 +38,7 @@ function ExpandIcon() {
26
38
  }
27
39
  function InternalCascader(props, ref) {
28
40
  const config = useTaoInternalConfig();
29
- const { size: sizeProp = config.size, disabled = config.disabled, variant = false === props.bordered ? 'borderless' : config.variant, status, prefixCls = 'tao-select-engine', className, rootClassName, style, classNames, styles, multiple, suffix, suffixIcon, showArrow = true, allowClear = true, clearIcon, removeIcon = /*#__PURE__*/ jsx(CloseIcon, {
41
+ const { size: sizeProp = config.size, disabled = config.disabled, variant = false === props.bordered ? 'borderless' : config.variant, status, prefixCls = 'tao-select-engine', className, rootClassName, style, classNames, styles, multiple, mobile, mobileTitle, open: openProp, defaultOpen = false, value: valueProp, defaultValue, onChange, showSearch, searchValue: searchValueProp, onSearch, suffix, suffixIcon, showArrow = true, allowClear = true, clearIcon, removeIcon = /*#__PURE__*/ jsx(CloseIcon, {
30
42
  small: true
31
43
  }), expandIcon = /*#__PURE__*/ jsx(ExpandIcon, {}), loadingIcon = /*#__PURE__*/ jsx(Spinner, {
32
44
  size: "small"
@@ -45,69 +57,202 @@ function InternalCascader(props, ref) {
45
57
  props: resolvedProps
46
58
  }) : styles;
47
59
  const renderPopup = popupRender ?? dropdownRender;
60
+ const screens = useBreakpoint();
61
+ const requestedMobile = mobile ?? screens.xs;
62
+ const [internalOpen, setInternalOpen] = useState(defaultOpen);
63
+ const open = openProp ?? internalOpen;
64
+ const [mobilePresentation, setMobilePresentation] = useState(requestedMobile);
65
+ if ((!open || void 0 === mobilePresentation) && mobilePresentation !== requestedMobile) setMobilePresentation(requestedMobile);
66
+ const isMobile = (open ? mobilePresentation : requestedMobile) ?? false;
67
+ const title = useMobileTitle(mobileTitle, config.locale.select);
68
+ const triggerRef = useRef(null);
48
69
  const [direction, directionRef] = useTaoDirection(props.direction);
49
- const mergedRef = useMemo(()=>mergeRefs(ref, (node)=>directionRef(node?.nativeElement ?? null)), [
70
+ const mergedRef = useMemo(()=>mergeRefs(triggerRef, ref, (node)=>directionRef(node?.nativeElement ?? null)), [
50
71
  ref,
51
72
  directionRef
52
73
  ]);
53
- return /*#__PURE__*/ jsx(RcCascaderComponent, {
54
- ...rest,
55
- ref: mergedRef,
56
- direction: direction,
57
- dir: direction,
58
- prefixCls: prefixCls,
59
- popupPrefixCls: "tao-cascader",
60
- "data-tao-cascader": "",
61
- "data-tao-select-engine": "",
62
- "data-tao-control": "",
63
- "data-tao-size": size,
64
- "data-tao-variant": variant,
65
- "data-disabled": disabled || void 0,
66
- "data-tao-error": 'error' === status || void 0,
67
- "data-tao-warning": 'warning' === status || void 0,
68
- disabled: disabled,
69
- className: cx(className, rootClassName, classes?.root),
70
- style: {
71
- ...semanticStyles?.root,
72
- ...style
73
- },
74
- classNames: classes,
75
- styles: semanticStyles,
76
- checkable: multiple,
77
- expandIcon: expandIcon,
78
- loadingIcon: loadingIcon,
79
- suffix: void 0 !== suffix ? suffix : void 0 !== suffixIcon ? suffixIcon : showArrow ? /*#__PURE__*/ jsx(ChevronDownIcon, {}) : null,
80
- allowClear: selectAllowClear(allowClear, clearIcon, config.locale.clear),
81
- removeIcon: removeIcon,
82
- notFoundContent: notFoundContent,
83
- popupAlign: {
84
- overflow: {
85
- adjustX: true,
86
- adjustY: true,
87
- shiftX: 8
88
- },
89
- ...props.popupAlign
90
- },
91
- popupClassName: cx(popupClassName ?? dropdownClassName, rootClassName, classes?.popup?.root),
92
- popupStyle: {
93
- ...config.tokenStyle,
94
- position: 'absolute',
95
- maxWidth: 'calc(100vw - 16px)',
96
- zIndex: 'var(--tao-z-index-popup)',
97
- ...dropdownStyle,
98
- ...popupStyle,
99
- ...semanticStyles?.popup?.root
100
- },
101
- popupRender: (menu)=>/*#__PURE__*/ jsx(SelectEnginePopup, {
74
+ const [internalValue, setInternalValue] = useState(defaultValue);
75
+ const value = void 0 !== valueProp ? valueProp : internalValue;
76
+ const [draft, setDraft] = useState();
77
+ const [previousOpen, setPreviousOpen] = useState(open);
78
+ if (previousOpen !== open) {
79
+ setPreviousOpen(open);
80
+ setDraft(void 0);
81
+ }
82
+ const [mobileContainer, setMobileContainer] = useState(null);
83
+ const [internalSearch, setInternalSearch] = useState('');
84
+ const searchConfig = 'object' == typeof showSearch ? showSearch : {};
85
+ const searchValue = searchConfig.searchValue ?? searchValueProp ?? internalSearch;
86
+ const changeSearch = (next)=>{
87
+ setInternalSearch(next);
88
+ (searchConfig.onSearch ?? onSearch)?.(next);
89
+ };
90
+ const changeOpen = (next_0)=>{
91
+ setInternalOpen(next_0);
92
+ setDraft(void 0);
93
+ if (!next_0 && isMobile) {
94
+ if (searchValue) changeSearch('');
95
+ triggerRef.current?.focus();
96
+ }
97
+ (onOpenChange ?? onPopupVisibleChange ?? onDropdownVisibleChange)?.(next_0);
98
+ };
99
+ const commit = (...args)=>{
100
+ setInternalValue(args[0]);
101
+ onChange?.(...args);
102
+ };
103
+ const changeValue = (...args_0)=>{
104
+ if (isMobile && open && multiple) return void setDraft(args_0);
105
+ commit(...args_0);
106
+ if (isMobile && open) {
107
+ const selected = args_0[1];
108
+ const last = selected?.at(-1);
109
+ const children = last?.[props.fieldNames?.children ?? 'children'];
110
+ if (!last || (last.isLeaf ?? !children?.length)) changeOpen(false);
111
+ }
112
+ };
113
+ const navigateMobile = (event)=>{
114
+ if (event.nativeEvent.isComposing || 229 === event.keyCode) return;
115
+ if (searchValue && ('ArrowLeft' === event.key || 'ArrowRight' === event.key)) return;
116
+ const keyCode = NAVIGATION_KEYS[event.key];
117
+ if (!keyCode) return;
118
+ event.preventDefault();
119
+ triggerRef.current?.nativeElement.querySelector('input')?.dispatchEvent(new KeyboardEvent('keydown', {
120
+ key: event.key,
121
+ keyCode,
122
+ which: keyCode,
123
+ bubbles: true
124
+ }));
125
+ };
126
+ return /*#__PURE__*/ jsxs(Fragment, {
127
+ children: [
128
+ /*#__PURE__*/ jsx(RcCascaderComponent, {
129
+ ...rest,
130
+ ref: mergedRef,
102
131
  direction: direction,
103
- size: size,
104
- children: /*#__PURE__*/ jsx("div", {
105
- "data-tao-cascader-popup": "",
106
- children: renderPopup ? renderPopup(menu) : menu
107
- })
132
+ dir: direction,
133
+ open: open,
134
+ value: (isMobile && open && multiple && draft ? draft[0] : value) ?? [],
135
+ onChange: changeValue,
136
+ showSearch: isMobile && showSearch ? {
137
+ ...searchConfig,
138
+ searchValue,
139
+ onSearch: changeSearch
140
+ } : showSearch,
141
+ searchValue: isMobile ? searchValue : searchValueProp,
142
+ onSearch: isMobile ? changeSearch : onSearch,
143
+ expandTrigger: isMobile ? 'click' : props.expandTrigger,
144
+ prefixCls: prefixCls,
145
+ popupPrefixCls: "tao-cascader",
146
+ "data-tao-cascader": "",
147
+ "data-tao-select-engine": "",
148
+ "data-tao-control": "",
149
+ "data-tao-size": size,
150
+ "data-tao-variant": variant,
151
+ "data-disabled": disabled || void 0,
152
+ "data-tao-error": 'error' === status || void 0,
153
+ "data-tao-warning": 'warning' === status || void 0,
154
+ disabled: disabled,
155
+ className: cx(className, rootClassName, classes?.root),
156
+ style: {
157
+ ...semanticStyles?.root,
158
+ ...style
159
+ },
160
+ classNames: classes,
161
+ styles: semanticStyles,
162
+ checkable: multiple,
163
+ expandIcon: expandIcon,
164
+ loadingIcon: loadingIcon,
165
+ suffix: void 0 !== suffix ? suffix : void 0 !== suffixIcon ? suffixIcon : showArrow ? /*#__PURE__*/ jsx(ChevronDownIcon, {}) : null,
166
+ allowClear: selectAllowClear(allowClear, clearIcon, config.locale.clear),
167
+ removeIcon: removeIcon,
168
+ notFoundContent: notFoundContent,
169
+ popupAlign: {
170
+ overflow: {
171
+ adjustX: true,
172
+ adjustY: true,
173
+ shiftX: 8
174
+ },
175
+ ...props.popupAlign
176
+ },
177
+ popupClassName: cx(popupClassName ?? dropdownClassName, rootClassName, classes?.popup?.root),
178
+ popupStyle: {
179
+ ...config.tokenStyle,
180
+ position: 'absolute',
181
+ maxWidth: 'calc(100vw - 16px)',
182
+ zIndex: 'var(--tao-z-index-popup)',
183
+ ...dropdownStyle,
184
+ ...popupStyle,
185
+ ...semanticStyles?.popup?.root,
186
+ ...isMobile ? {
187
+ display: 'contents'
188
+ } : {}
189
+ },
190
+ popupRender: (menu)=>{
191
+ if (isMobile) return mobileContainer ? /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx("div", {
192
+ "data-tao-cascader-popup": "",
193
+ "data-tao-cascader-mobile": "",
194
+ children: renderPopup ? renderPopup(menu) : menu
195
+ }), mobileContainer) : /*#__PURE__*/ jsx(Fragment, {});
196
+ return /*#__PURE__*/ jsx(SelectEnginePopup, {
197
+ direction: direction,
198
+ size: size,
199
+ children: /*#__PURE__*/ jsx("div", {
200
+ "data-tao-cascader-popup": "",
201
+ children: renderPopup ? renderPopup(menu) : menu
202
+ })
203
+ });
204
+ },
205
+ popupMenuColumnStyle: popupMenuColumnStyle ?? dropdownMenuColumnStyle,
206
+ onPopupVisibleChange: (next_1)=>{
207
+ if (!isMobile || next_1) changeOpen(next_1);
208
+ }
108
209
  }),
109
- popupMenuColumnStyle: popupMenuColumnStyle ?? dropdownMenuColumnStyle,
110
- onPopupVisibleChange: onOpenChange ?? onPopupVisibleChange ?? onDropdownVisibleChange
210
+ isMobile && /*#__PURE__*/ jsxs(Drawer, {
211
+ open: open && !disabled,
212
+ onClose: ()=>changeOpen(false),
213
+ placement: "bottom",
214
+ title: title,
215
+ height: "70vh",
216
+ classNames: {
217
+ root: classes?.popup?.root
218
+ },
219
+ styles: {
220
+ root: semanticStyles?.popup?.root
221
+ },
222
+ footer: multiple ? /*#__PURE__*/ jsx(Button, {
223
+ size: "large",
224
+ style: {
225
+ width: '100%'
226
+ },
227
+ disabled: disabled,
228
+ onClick: ()=>{
229
+ if (draft) commit(...draft);
230
+ changeOpen(false);
231
+ },
232
+ children: config.locale.done
233
+ }) : void 0,
234
+ children: [
235
+ showSearch && /*#__PURE__*/ jsx("input", {
236
+ "data-tao-cascader-search": "",
237
+ type: "search",
238
+ "aria-label": config.locale.searchOptions,
239
+ placeholder: config.locale.searchPlaceholder,
240
+ value: searchValue,
241
+ disabled: disabled,
242
+ onChange: (event_0)=>changeSearch(event_0.target.value),
243
+ onKeyDown: navigateMobile
244
+ }),
245
+ /*#__PURE__*/ jsx("fieldset", {
246
+ "data-tao-cascader-mobile-container": "",
247
+ dir: direction,
248
+ ref: setMobileContainer,
249
+ "aria-label": config.locale.select,
250
+ tabIndex: showSearch ? -1 : 0,
251
+ onKeyDown: navigateMobile
252
+ })
253
+ ]
254
+ })
255
+ ]
111
256
  });
112
257
  }
113
258
  function CascaderPanel(props) {
@@ -6,7 +6,7 @@ import { FormFieldView } from "../form-field/form-field-view.js";
6
6
  import { useFormLayout } from "./form-context.js";
7
7
  import { FieldControl } from "./field-control.js";
8
8
  function FormItem(t0) {
9
- const $ = c(41);
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;
@@ -18,7 +18,7 @@ function FormItem(t0) {
18
18
  } else t1 = $[2];
19
19
  const requiredMark = t1;
20
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] !== style || $[14] !== styles || $[15] !== validateStatus || $[16] !== valuePropName) {
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
22
  t2 = (content, meta, control)=>{
23
23
  const status = validateStatus ?? (meta?.errors.length ? "error" : meta?.warnings.length ? "warning" : void 0);
24
24
  const message = help ?? meta?.errors[0] ?? meta?.warnings[0];
@@ -47,6 +47,7 @@ function FormItem(t0) {
47
47
  }
48
48
  return /*#__PURE__*/ jsx(FormFieldView, {
49
49
  formItem: true,
50
+ reserveMessage: Boolean(rules?.length) || null != help || null != extra || null != validateStatus,
50
51
  label: label,
51
52
  htmlFor: htmlFor,
52
53
  required: requiredMark,
@@ -76,39 +77,40 @@ function FormItem(t0) {
76
77
  $[10] = name;
77
78
  $[11] = noStyle;
78
79
  $[12] = requiredMark;
79
- $[13] = style;
80
- $[14] = styles;
81
- $[15] = validateStatus;
82
- $[16] = valuePropName;
83
- $[17] = t2;
84
- } else t2 = $[17];
80
+ $[13] = rules?.length;
81
+ $[14] = style;
82
+ $[15] = styles;
83
+ $[16] = validateStatus;
84
+ $[17] = valuePropName;
85
+ $[18] = t2;
86
+ } else t2 = $[18];
85
87
  const renderShell = t2;
86
88
  if (null == name && null == dependencies && null == shouldUpdate) {
87
89
  const t3 = children;
88
90
  let t4;
89
- if ($[18] !== renderShell || $[19] !== t3) {
91
+ if ($[19] !== renderShell || $[20] !== t3) {
90
92
  t4 = renderShell(t3, void 0, null);
91
- $[18] = renderShell;
92
- $[19] = t3;
93
- $[20] = t4;
94
- } else t4 = $[20];
93
+ $[19] = renderShell;
94
+ $[20] = t3;
95
+ $[21] = t4;
96
+ } else t4 = $[21];
95
97
  return t4;
96
98
  }
97
99
  const t3 = name ?? void 0;
98
100
  let t4;
99
- if ($[21] !== children || $[22] !== formInstance || $[23] !== name || $[24] !== renderShell) {
101
+ if ($[22] !== children || $[23] !== formInstance || $[24] !== name || $[25] !== renderShell) {
100
102
  t4 = (control_0, meta_0)=>{
101
103
  const content_0 = "function" == typeof children ? children(control_0, meta_0, formInstance) : children;
102
104
  return renderShell(content_0, meta_0, null != name ? control_0 : null);
103
105
  };
104
- $[21] = children;
105
- $[22] = formInstance;
106
- $[23] = name;
107
- $[24] = renderShell;
108
- $[25] = t4;
109
- } else t4 = $[25];
106
+ $[22] = children;
107
+ $[23] = formInstance;
108
+ $[24] = name;
109
+ $[25] = renderShell;
110
+ $[26] = t4;
111
+ } else t4 = $[26];
110
112
  let t5;
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) {
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) {
112
114
  t5 = /*#__PURE__*/ jsx(Field, {
113
115
  name: t3,
114
116
  rules: rules,
@@ -125,22 +127,22 @@ function FormItem(t0) {
125
127
  validateFirst: validateFirst,
126
128
  children: t4
127
129
  });
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];
130
+ $[27] = dependencies;
131
+ $[28] = getValueFromEvent;
132
+ $[29] = initialValue;
133
+ $[30] = messageVariables;
134
+ $[31] = normalize;
135
+ $[32] = preserve;
136
+ $[33] = rules;
137
+ $[34] = shouldUpdate;
138
+ $[35] = t3;
139
+ $[36] = t4;
140
+ $[37] = trigger;
141
+ $[38] = validateFirst;
142
+ $[39] = validateTrigger;
143
+ $[40] = valuePropName;
144
+ $[41] = t5;
145
+ } else t5 = $[41];
144
146
  return t5;
145
147
  }
146
148
  function _temp(rule) {
@@ -2,14 +2,19 @@
2
2
  margin-block-end: var(--tao-form-field-item-gap, var(--tao-padding-md));
3
3
  }
4
4
 
5
+ [data-tao-form] > [data-tao-form-item][data-tao-form-feedback] {
6
+ margin-block-end: var(--tao-form-field-item-gap, var(--tao-size-unit));
7
+ }
8
+
5
9
  [data-tao-form-message] {
6
10
  min-block-size: 1lh;
7
11
  font-size: var(--tao-form-field-error-font-size, var(--tao-font-size-xs));
8
- line-height: var(--tao-line-height-sm);
9
12
  margin-block-start: var(--tao-padding-xxs);
13
+ line-height: max(18px, 1.25em);
10
14
  }
11
15
 
12
16
  [data-tao-form-message] > [data-tao-form-error], [data-tao-form-message] > [data-tao-form-description] {
17
+ line-height: inherit;
13
18
  margin-block: 0;
14
19
  }
15
20
 
@@ -1,9 +1,12 @@
1
1
  import { type CSSProperties, type ReactElement, type ReactNode } from 'react';
2
2
  import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic.js';
3
+ import './form.css';
3
4
  export type FormFieldLayout = 'vertical' | 'horizontal';
4
5
  export interface FormFieldViewProps {
5
6
  /** Identifies Form.Item without changing standalone FormField spacing. */
6
7
  formItem?: boolean;
8
+ /** Keep one feedback line for validation or explicitly controlled messages. */
9
+ reserveMessage?: boolean;
7
10
  label?: ReactNode;
8
11
  htmlFor?: string;
9
12
  required?: boolean;
@@ -31,4 +34,4 @@ export interface FormFieldViewProps {
31
34
  * with the aria wiring (describedby/errormessage/invalid/required) applied
32
35
  * to the child control. Not part of the public API.
33
36
  */
34
- export declare function FormFieldView({ formItem, label, htmlFor, required, error, warning, description, layout, controlProps, renderControl, children, className, style, classNames, styles, }: FormFieldViewProps): import("react").JSX.Element;
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;
@@ -3,9 +3,10 @@ import { c } from "react-compiler-runtime";
3
3
  import { cloneElement, isValidElement, useId } from "react";
4
4
  import { FieldLabelContext } from "../../utils/field-label.js";
5
5
  import { cx } from "../../utils/semantic.js";
6
+ import "./form.css";
6
7
  function FormFieldView(t0) {
7
- const $ = c(57);
8
- const { formItem, label, htmlFor, required, error, warning, description, layout: t1, controlProps, renderControl, children, className, style, classNames, styles } = 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
10
  const layout = void 0 === t1 ? "vertical" : t1;
10
11
  const generatedId = useId();
11
12
  const child = /*#__PURE__*/ isValidElement(children) ? children : null;
@@ -81,6 +82,7 @@ function FormFieldView(t0) {
81
82
  $[24] = t5;
82
83
  } else t5 = $[24];
83
84
  const message = t5;
85
+ const hasMessage = formItem && (reserveMessage || null !== message);
84
86
  const t6 = classNames?.root;
85
87
  let t7;
86
88
  if ($[25] !== className || $[26] !== t6) {
@@ -101,10 +103,11 @@ function FormFieldView(t0) {
101
103
  $[30] = t9;
102
104
  } else t9 = $[30];
103
105
  const t10 = formItem ? "" : void 0;
104
- const t11 = "horizontal" === layout ? "horizontal" : void 0;
105
- let t12;
106
+ const t11 = hasMessage ? "" : void 0;
107
+ const t12 = "horizontal" === layout ? "horizontal" : void 0;
108
+ let t13;
106
109
  if ($[31] !== classNames?.label || $[32] !== controlId || $[33] !== label || $[34] !== labelId || $[35] !== required || $[36] !== styles?.label) {
107
- t12 = null != label && /*#__PURE__*/ jsxs("label", {
110
+ t13 = null != label && /*#__PURE__*/ jsxs("label", {
108
111
  id: labelId,
109
112
  htmlFor: controlId,
110
113
  className: classNames?.label,
@@ -125,69 +128,71 @@ function FormFieldView(t0) {
125
128
  $[34] = labelId;
126
129
  $[35] = required;
127
130
  $[36] = styles?.label;
128
- $[37] = t12;
129
- } else t12 = $[37];
130
- let t13;
131
+ $[37] = t13;
132
+ } else t13 = $[37];
133
+ let t14;
131
134
  if ($[38] !== control || $[39] !== renderControl) {
132
- t13 = renderControl && /*#__PURE__*/ isValidElement(control) ? renderControl(control) : control;
135
+ t14 = renderControl && /*#__PURE__*/ isValidElement(control) ? renderControl(control) : control;
133
136
  $[38] = control;
134
137
  $[39] = renderControl;
135
- $[40] = t13;
136
- } else t13 = $[40];
137
- let t14;
138
- if ($[41] !== label || $[42] !== t13) {
139
- t14 = /*#__PURE__*/ jsx(FieldLabelContext.Provider, {
138
+ $[40] = t14;
139
+ } else t14 = $[40];
140
+ let t15;
141
+ if ($[41] !== label || $[42] !== t14) {
142
+ t15 = /*#__PURE__*/ jsx(FieldLabelContext.Provider, {
140
143
  value: label,
141
- children: t13
144
+ children: t14
142
145
  });
143
146
  $[41] = label;
144
- $[42] = t13;
145
- $[43] = t14;
146
- } else t14 = $[43];
147
- let t15;
148
- if ($[44] !== formItem || $[45] !== message) {
149
- t15 = formItem ? /*#__PURE__*/ jsx("div", {
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", {
150
153
  "data-tao-form-message": "",
151
154
  children: message
152
155
  }) : message;
153
- $[44] = formItem;
156
+ $[44] = hasMessage;
154
157
  $[45] = message;
155
- $[46] = t15;
156
- } else t15 = $[46];
157
- let t16;
158
- if ($[47] !== t14 || $[48] !== t15) {
159
- t16 = /*#__PURE__*/ jsxs("div", {
158
+ $[46] = t16;
159
+ } else t16 = $[46];
160
+ let t17;
161
+ if ($[47] !== t15 || $[48] !== t16) {
162
+ t17 = /*#__PURE__*/ jsxs("div", {
160
163
  "data-tao-form-control": "",
161
164
  children: [
162
- t14,
163
- t15
165
+ t15,
166
+ t16
164
167
  ]
165
168
  });
166
- $[47] = t14;
167
- $[48] = t15;
168
- $[49] = t16;
169
- } else t16 = $[49];
170
- let t17;
171
- if ($[50] !== t10 || $[51] !== t11 || $[52] !== t12 || $[53] !== t16 || $[54] !== t7 || $[55] !== t9) {
172
- t17 = /*#__PURE__*/ jsxs("div", {
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", {
173
176
  className: t7,
174
177
  style: t9,
175
178
  "data-tao-form-field": "",
176
179
  "data-tao-form-item": t10,
177
- "data-tao-layout": t11,
180
+ "data-tao-form-feedback": t11,
181
+ "data-tao-layout": t12,
178
182
  children: [
179
- t12,
180
- t16
183
+ t13,
184
+ t17
181
185
  ]
182
186
  });
183
187
  $[50] = t10;
184
188
  $[51] = t11;
185
189
  $[52] = t12;
186
- $[53] = t16;
187
- $[54] = t7;
188
- $[55] = t9;
189
- $[56] = t17;
190
- } else t17 = $[56];
191
- return t17;
190
+ $[53] = t13;
191
+ $[54] = t17;
192
+ $[55] = t7;
193
+ $[56] = t9;
194
+ $[57] = t18;
195
+ } else t18 = $[57];
196
+ return t18;
192
197
  }
193
198
  export { FormFieldView };
@@ -1,6 +1,5 @@
1
1
  import type { CSSProperties, ReactNode } from 'react';
2
2
  import type { SemanticClassNames, SemanticStyles } from '../../utils/semantic.js';
3
- import './form.css';
4
3
  export type FormFieldSemanticPart = 'root' | 'label' | 'error' | 'description';
5
4
  export interface FormFieldProps {
6
5
  label: string;
@@ -1,7 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
3
  import { FormFieldView } from "./form-field-view.js";
4
- import "./form.css";
5
4
  function FormField(t0) {
6
5
  const $ = c(11);
7
6
  const { label, htmlFor, required, error, description, children, className, style, classNames, styles } = t0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rockshin/tao-ui",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "type": "module",
5
5
  "description": "A modern React component library with semantic DOM customization and OKLCH-based theming.",
6
6
  "keywords": [