@godxjp/ui 20.0.0 → 20.1.0

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 (250) hide show
  1. package/README.md +8 -2
  2. package/dist/app/theme-axes.d.ts +2 -0
  3. package/dist/app/theme-axes.js +45 -0
  4. package/dist/components/charts/chart-cartesian.d.ts +2 -1
  5. package/dist/components/charts/chart-cartesian.js +52 -3
  6. package/dist/components/charts/chart-category-axis.d.ts +55 -0
  7. package/dist/components/charts/chart-category-axis.js +93 -0
  8. package/dist/components/charts/chart-frame.d.ts +10 -1
  9. package/dist/components/charts/chart-frame.js +19 -3
  10. package/dist/components/charts/compact-bar-trend.d.ts +1 -1
  11. package/dist/components/charts/compact-bar-trend.js +2 -0
  12. package/dist/components/charts/pie-chart.d.ts +1 -1
  13. package/dist/components/charts/pie-chart.js +12 -1
  14. package/dist/components/charts/recharts-peer.d.ts +49 -0
  15. package/dist/components/charts/recharts-peer.js +45 -0
  16. package/dist/components/data-display/card.d.ts +12 -1
  17. package/dist/components/data-display/card.js +22 -4
  18. package/dist/components/data-display/code-block.js +6 -2
  19. package/dist/components/data-display/data-table.d.ts +39 -4
  20. package/dist/components/data-display/data-table.js +802 -270
  21. package/dist/components/data-display/descriptions.d.ts +27 -6
  22. package/dist/components/data-display/descriptions.js +58 -17
  23. package/dist/components/data-display/index.d.ts +2 -0
  24. package/dist/components/data-display/index.js +2 -0
  25. package/dist/components/data-display/list-row.d.ts +10 -1
  26. package/dist/components/data-display/list-row.js +7 -1
  27. package/dist/components/data-display/popover.d.ts +2 -2
  28. package/dist/components/data-display/popover.js +61 -11
  29. package/dist/components/data-display/range-timeline.d.ts +38 -0
  30. package/dist/components/data-display/range-timeline.js +161 -0
  31. package/dist/components/data-display/scroll-area.js +13 -2
  32. package/dist/components/data-display/service-launcher-card.js +10 -10
  33. package/dist/components/data-display/table.d.ts +11 -3
  34. package/dist/components/data-display/table.js +48 -18
  35. package/dist/components/data-display/tree-list.js +4 -9
  36. package/dist/components/data-entry/calendar.d.ts +2 -2
  37. package/dist/components/data-entry/calendar.js +12 -1
  38. package/dist/components/data-entry/cascader.d.ts +1 -1
  39. package/dist/components/data-entry/cascader.js +188 -24
  40. package/dist/components/data-entry/color-picker.d.ts +1 -1
  41. package/dist/components/data-entry/color-picker.js +17 -5
  42. package/dist/components/data-entry/control-appearance.d.ts +64 -0
  43. package/dist/components/data-entry/control-appearance.js +39 -0
  44. package/dist/components/data-entry/control-surface.d.ts +61 -0
  45. package/dist/components/data-entry/control-surface.js +39 -0
  46. package/dist/components/data-entry/date-picker.d.ts +1 -1
  47. package/dist/components/data-entry/date-picker.js +344 -113
  48. package/dist/components/data-entry/date-range-picker.d.ts +1 -1
  49. package/dist/components/data-entry/date-range-picker.js +278 -140
  50. package/dist/components/data-entry/form-field.d.ts +1 -1
  51. package/dist/components/data-entry/form-field.js +39 -4
  52. package/dist/components/data-entry/form.d.ts +4 -0
  53. package/dist/components/data-entry/form.js +4 -2
  54. package/dist/components/data-entry/index.d.ts +7 -3
  55. package/dist/components/data-entry/index.js +10 -1
  56. package/dist/components/data-entry/input-otp.d.ts +1 -1
  57. package/dist/components/data-entry/input.d.ts +12 -34
  58. package/dist/components/data-entry/input.js +92 -24
  59. package/dist/components/data-entry/month-picker.d.ts +1 -1
  60. package/dist/components/data-entry/month-picker.js +47 -10
  61. package/dist/components/data-entry/month-range-picker.d.ts +1 -1
  62. package/dist/components/data-entry/month-range-picker.js +51 -11
  63. package/dist/components/data-entry/number-input.d.ts +7 -0
  64. package/dist/components/data-entry/number-input.js +147 -98
  65. package/dist/components/data-entry/password-input.d.ts +1 -1
  66. package/dist/components/data-entry/radio.d.ts +1 -1
  67. package/dist/components/data-entry/radio.js +61 -13
  68. package/dist/components/data-entry/search-input.d.ts +1 -1
  69. package/dist/components/data-entry/search-input.js +16 -2
  70. package/dist/components/data-entry/search-select.d.ts +2 -2
  71. package/dist/components/data-entry/search-select.js +209 -78
  72. package/dist/components/data-entry/select.d.ts +22 -4
  73. package/dist/components/data-entry/select.js +215 -163
  74. package/dist/components/data-entry/slider.d.ts +9 -1
  75. package/dist/components/data-entry/slider.js +87 -9
  76. package/dist/components/data-entry/switch.d.ts +3 -0
  77. package/dist/components/data-entry/switch.js +29 -3
  78. package/dist/components/data-entry/textarea.d.ts +14 -56
  79. package/dist/components/data-entry/textarea.js +80 -33
  80. package/dist/components/data-entry/time-picker.d.ts +2 -2
  81. package/dist/components/data-entry/time-picker.js +333 -109
  82. package/dist/components/data-entry/time-range-picker.d.ts +5 -0
  83. package/dist/components/data-entry/time-range-picker.js +89 -0
  84. package/dist/components/data-entry/transfer.d.ts +1 -1
  85. package/dist/components/data-entry/transfer.js +86 -28
  86. package/dist/components/data-entry/tree-select.d.ts +1 -1
  87. package/dist/components/data-entry/tree-select.js +201 -113
  88. package/dist/components/data-entry/tree-utils.js +7 -14
  89. package/dist/components/data-entry/upload-files.d.ts +2 -0
  90. package/dist/components/data-entry/upload-files.js +31 -0
  91. package/dist/components/data-entry/upload-request.d.ts +4 -0
  92. package/dist/components/data-entry/upload-request.js +53 -0
  93. package/dist/components/data-entry/upload-types.d.ts +28 -0
  94. package/dist/components/data-entry/upload-types.js +2 -0
  95. package/dist/components/data-entry/upload.d.ts +2 -2
  96. package/dist/components/data-entry/upload.js +475 -115
  97. package/dist/components/feedback/dialog.js +16 -19
  98. package/dist/components/general/button.d.ts +1 -1
  99. package/dist/components/general/button.js +5 -1
  100. package/dist/components/general/index.d.ts +1 -0
  101. package/dist/components/general/index.js +2 -0
  102. package/dist/components/general/typography.d.ts +3 -0
  103. package/dist/components/general/typography.js +15 -1
  104. package/dist/components/general/visually-hidden.d.ts +3 -0
  105. package/dist/components/general/visually-hidden.js +9 -0
  106. package/dist/components/layout/app-launcher.d.ts +34 -0
  107. package/dist/components/layout/app-launcher.js +228 -0
  108. package/dist/components/layout/app-shell.d.ts +2 -0
  109. package/dist/components/layout/app-shell.js +20 -7
  110. package/dist/components/layout/breadcrumb.d.ts +14 -2
  111. package/dist/components/layout/breadcrumb.js +46 -4
  112. package/dist/components/layout/flex.d.ts +1 -1
  113. package/dist/components/layout/flex.js +23 -2
  114. package/dist/components/layout/index.d.ts +3 -0
  115. package/dist/components/layout/index.js +5 -1
  116. package/dist/components/layout/org-switcher.js +20 -1
  117. package/dist/components/layout/page-container.d.ts +1 -1
  118. package/dist/components/layout/page-container.js +5 -3
  119. package/dist/components/layout/responsive-grid.d.ts +16 -2
  120. package/dist/components/layout/responsive-grid.js +29 -2
  121. package/dist/components/layout/topbar-item.d.ts +3 -0
  122. package/dist/components/layout/topbar-item.js +18 -3
  123. package/dist/components/layout/topbar.d.ts +1 -1
  124. package/dist/components/layout/topbar.js +27 -6
  125. package/dist/components/navigation/dropdown-menu.d.ts +30 -2
  126. package/dist/components/navigation/dropdown-menu.js +68 -11
  127. package/dist/components/navigation/pagination.d.ts +2 -2
  128. package/dist/components/navigation/pagination.js +155 -83
  129. package/dist/components/navigation/steps.d.ts +2 -2
  130. package/dist/components/navigation/steps.js +29 -4
  131. package/dist/components/navigation/tabs.d.ts +5 -33
  132. package/dist/components/navigation/tabs.js +232 -64
  133. package/dist/components/ui/input-otp.d.ts +26 -28
  134. package/dist/components/ui/input-otp.js +50 -7
  135. package/dist/components/ui/password-input.d.ts +36 -2
  136. package/dist/components/ui/password-input.js +27 -7
  137. package/dist/components/ui/rating.d.ts +25 -0
  138. package/dist/components/ui/rating.js +67 -27
  139. package/dist/components/ui/segmented.d.ts +9 -0
  140. package/dist/components/ui/segmented.js +17 -2
  141. package/dist/components/ui/separator.d.ts +4 -0
  142. package/dist/components/ui/separator.js +13 -0
  143. package/dist/components/ui/tag-input.d.ts +45 -0
  144. package/dist/components/ui/tag-input.js +109 -27
  145. package/dist/form/form-context.d.ts +29 -0
  146. package/dist/form/form-context.js +44 -4
  147. package/dist/form/form-field-array.d.ts +22 -0
  148. package/dist/form/form-field-array.js +50 -0
  149. package/dist/form/form-field-control.d.ts +2 -1
  150. package/dist/form/form-field-control.js +116 -40
  151. package/dist/form/form-root.d.ts +2 -1
  152. package/dist/form/form-root.js +142 -23
  153. package/dist/form/index.d.ts +3 -1
  154. package/dist/form/index.js +12 -1
  155. package/dist/i18n/messages/en.json +56 -5
  156. package/dist/i18n/messages/ja.json +56 -5
  157. package/dist/i18n/messages/vi.json +56 -5
  158. package/dist/inertia/index.d.ts +20 -0
  159. package/dist/inertia/index.js +60 -1
  160. package/dist/lib/control-styles.d.ts +25 -3
  161. package/dist/lib/control-styles.js +9 -3
  162. package/dist/lib/datetime/picker-format.d.ts +8 -0
  163. package/dist/lib/datetime/picker-format.js +54 -0
  164. package/dist/props/components/charts.prop.d.ts +21 -0
  165. package/dist/props/components/data-display.prop.d.ts +55 -4
  166. package/dist/props/components/data-entry.prop.d.ts +687 -43
  167. package/dist/props/components/form.prop.d.ts +142 -4
  168. package/dist/props/components/general.prop.d.ts +17 -1
  169. package/dist/props/components/index.d.ts +2 -2
  170. package/dist/props/components/layout.prop.d.ts +163 -6
  171. package/dist/props/components/navigation.prop.d.ts +113 -3
  172. package/dist/props/registry.d.ts +376 -10
  173. package/dist/props/registry.js +493 -9
  174. package/dist/props/vocabulary/data.prop.d.ts +179 -1
  175. package/dist/props/vocabulary/index.d.ts +4 -4
  176. package/dist/props/vocabulary/interaction.prop.d.ts +51 -2
  177. package/dist/props/vocabulary/navigation.prop.d.ts +40 -0
  178. package/dist/props/vocabulary/shared.prop.d.ts +33 -0
  179. package/dist/styles/badge-layout.css +2 -1
  180. package/dist/styles/card-layout.css +26 -4
  181. package/dist/styles/chart-layout.css +15 -0
  182. package/dist/styles/control.css +515 -14
  183. package/dist/styles/data-display-layout.css +241 -6
  184. package/dist/styles/data-entry-layout.css +13 -0
  185. package/dist/styles/layout.css +221 -4
  186. package/dist/styles/navigation-layout.css +227 -0
  187. package/dist/styles/shell-layout.css +229 -5
  188. package/dist/styles/table-layout.css +95 -6
  189. package/dist/styles/text-layout.css +5 -0
  190. package/dist/tokens/base.css +1 -0
  191. package/dist/tokens/components/badge.css +1 -0
  192. package/dist/tokens/components/chart.css +6 -0
  193. package/dist/tokens/components/control.css +79 -2
  194. package/dist/tokens/components/data-display.css +9 -0
  195. package/dist/tokens/components/descriptions.css +11 -0
  196. package/dist/tokens/components/flex.css +8 -0
  197. package/dist/tokens/components/navigation.css +55 -0
  198. package/dist/tokens/components/shell.css +50 -2
  199. package/dist/tokens/components/table.css +14 -0
  200. package/dist/tokens/semantic/layout.css +9 -0
  201. package/docs/CONSUMER-RULES.md +13 -0
  202. package/docs/DESIGN-AUTHORITY.md +43 -6
  203. package/docs/DEVELOPMENT.md +4 -3
  204. package/docs/FORMS.md +151 -6
  205. package/docs/FRAME-COVERAGE-REPORT.md +29 -16
  206. package/docs/README.md +1 -1
  207. package/docs/STANDARDS-vocabulary-tokens.md +1 -1
  208. package/docs/TESTING.md +15 -6
  209. package/docs/charts/cjk-category-axis.tsx +81 -0
  210. package/docs/data-display/card/index.tsx +22 -0
  211. package/docs/data-display/data-table/examples/antd-parity.tsx +257 -0
  212. package/docs/data-display/data-table/index.tsx +23 -0
  213. package/docs/data-display/descriptions.tsx +41 -0
  214. package/docs/data-display/scroll-area.tsx +31 -25
  215. package/docs/data-display/table.tsx +104 -45
  216. package/docs/data-display/timeline.tsx +41 -0
  217. package/docs/data-entry/date-picker.tsx +85 -0
  218. package/docs/data-entry/date-range-picker.tsx +26 -0
  219. package/docs/data-entry/form-dynamic-fields.tsx +199 -0
  220. package/docs/data-entry/form.tsx +74 -4
  221. package/docs/data-entry/input-otp.tsx +24 -0
  222. package/docs/data-entry/input.tsx +46 -1
  223. package/docs/data-entry/month-range-picker.tsx +1 -1
  224. package/docs/data-entry/select.tsx +27 -0
  225. package/docs/data-entry/switch.tsx +41 -0
  226. package/docs/data-entry/textarea.tsx +38 -0
  227. package/docs/data-entry/time-picker.tsx +85 -1
  228. package/docs/data-entry/time-range-picker.tsx +55 -0
  229. package/docs/data-entry/transfer.tsx +17 -0
  230. package/docs/data-entry/upload.tsx +56 -12
  231. package/docs/feedback/tooltip.tsx +1 -1
  232. package/docs/general/activity.tsx +2 -2
  233. package/docs/general/button/index.tsx +14 -1
  234. package/docs/general/typography.tsx +14 -1
  235. package/docs/layout/app-launcher.tsx +151 -0
  236. package/docs/layout/app-shell.tsx +11 -0
  237. package/docs/layout/flex.tsx +50 -0
  238. package/docs/layout/responsive-grid.tsx +21 -1
  239. package/docs/layout/topbar.tsx +5 -9
  240. package/docs/navigation/app-setting-picker.tsx +11 -0
  241. package/docs/navigation/breadcrumb.tsx +48 -0
  242. package/docs/navigation/dropdown-menu.tsx +21 -0
  243. package/docs/navigation/pagination.tsx +52 -0
  244. package/docs/navigation/steps.tsx +37 -0
  245. package/docs/navigation/tabs.tsx +97 -1
  246. package/docs/query/button-refetch.tsx +1 -0
  247. package/package.json +19 -2
  248. package/scripts/_agent-setup.mjs +19 -2
  249. package/scripts/init-guinea-pig.mjs +26 -4
  250. package/scripts/ui-audit.mjs +243 -30
@@ -3,26 +3,35 @@ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { useTranslation } from "../../i18n/use-translation.js";
5
5
  import { cn } from "../../lib/utils.js";
6
- import { resolveFieldA11y } from "../../lib/field-a11y.js";
6
+ import { resolveFieldA11y, useFieldIdentity } from "../../lib/field-a11y.js";
7
7
  import { controlIconClass } from "../../lib/control-styles.js";
8
8
  import { Input } from "./input.js";
9
9
  const HEX_PATTERN = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
10
+ const NATIVE_COLOR_FALLBACK = "#000000";
10
11
  function normalizeHex(value) {
11
12
  if (!value.startsWith("#")) return `#${value}`;
12
13
  return value;
13
14
  }
14
15
  function ColorPicker({
15
- value = "#2563eb",
16
+ value: valueProp,
17
+ defaultValue,
16
18
  onValueChange,
17
19
  disabled,
20
+ name,
18
21
  className,
19
22
  id,
20
23
  showHexInput = true,
21
24
  ...ariaProps
22
25
  }) {
23
26
  const { t } = useTranslation();
27
+ const isControlled = valueProp !== void 0;
28
+ const [internalValue, setInternalValue] = React.useState(defaultValue ?? "");
29
+ const value = isControlled ? valueProp : internalValue;
24
30
  const [draft, setDraft] = React.useState(null);
25
31
  const display = draft ?? value;
32
+ const swatchValue = HEX_PATTERN.test(display) ? display : HEX_PATTERN.test(value) ? value : NATIVE_COLOR_FALLBACK;
33
+ const identity = useFieldIdentity({ id, name, "data-field": ariaProps["data-field"] });
34
+ const resolvedName = name ?? identity.name;
26
35
  const swatchA11y = resolveFieldA11y(ariaProps, t("dataEntry.colorPicker.ariaLabel"));
27
36
  const commit = (next) => {
28
37
  const normalized = normalizeHex(next);
@@ -31,6 +40,7 @@ function ColorPicker({
31
40
  return;
32
41
  }
33
42
  setDraft(null);
43
+ if (!isControlled) setInternalValue(normalized);
34
44
  onValueChange?.(normalized);
35
45
  };
36
46
  return /* @__PURE__ */ jsxs("div", { className: cn("ui-color-picker", className), children: [
@@ -39,7 +49,7 @@ function ColorPicker({
39
49
  "div",
40
50
  {
41
51
  className: "ui-color-picker-preview",
42
- style: { backgroundColor: HEX_PATTERN.test(display) ? display : value },
52
+ style: { backgroundColor: swatchValue },
43
53
  "aria-hidden": "true"
44
54
  }
45
55
  ),
@@ -48,10 +58,11 @@ function ColorPicker({
48
58
  {
49
59
  id,
50
60
  type: "color",
51
- value: HEX_PATTERN.test(display) ? display : value,
61
+ value: swatchValue,
52
62
  disabled,
53
63
  onChange: (event) => commit(event.target.value),
54
64
  className: "ui-color-picker-input",
65
+ "data-field": ariaProps["data-field"] ?? identity["data-field"],
55
66
  ...swatchA11y
56
67
  }
57
68
  )
@@ -71,7 +82,8 @@ function ColorPicker({
71
82
  className: "ui-color-picker-hex",
72
83
  spellCheck: false
73
84
  }
74
- )
85
+ ),
86
+ resolvedName ? /* @__PURE__ */ jsx("input", { type: "hidden", name: resolvedName, value, readOnly: true }) : null
75
87
  ] });
76
88
  }
77
89
  export {
@@ -0,0 +1,64 @@
1
+ import type * as React from "react";
2
+ import type { ControlStatusProp, ControlVariantProp } from "../../props/vocabulary/index.js";
3
+ import type { ControlCountProp } from "../../props/components/data-entry.prop.js";
4
+ /**
5
+ * The two appearance axes Ant Design puts on every text field — `status` and `variant` — resolved
6
+ * once, here, so Input / Textarea / NumberInput / PasswordInput / SearchInput cannot drift into
7
+ * three different spellings of "this field is wrong".
8
+ *
9
+ * WHY A HELPER AND NOT A CLASS PER COMPONENT. `status` has a SECOND half that is not paint:
10
+ * `error` must also report `aria-invalid`, or the red boundary is a lie to a screen reader. That
11
+ * pairing is the thing worth keeping in one place; the CSS is the easy half.
12
+ */
13
+ export type ControlAppearanceInput = {
14
+ status?: ControlStatusProp;
15
+ variant?: ControlVariantProp;
16
+ "aria-invalid"?: React.AriaAttributes["aria-invalid"];
17
+ };
18
+ export type ControlAppearanceAttributes = {
19
+ "data-status"?: ControlStatusProp;
20
+ "data-variant"?: ControlVariantProp;
21
+ "aria-invalid"?: React.AriaAttributes["aria-invalid"];
22
+ };
23
+ /**
24
+ * `status="error"` REPORTS `aria-invalid` — unless the caller (or FormField, which injects it)
25
+ * already said something, in which case the explicit value wins and nothing is overwritten.
26
+ * `status="warning"` deliberately reports nothing: a warning is not a validity failure, and
27
+ * antd does not announce one either (es/_util/statusUtils.js only reaches for the class name).
28
+ */
29
+ export declare function controlAppearanceAttributes({ status, variant, "aria-invalid": ariaInvalid, }: ControlAppearanceInput): ControlAppearanceAttributes;
30
+ /**
31
+ * The chrome utilities a variant carries, kept in the COMPONENT rather than in `control.css`.
32
+ *
33
+ * A Tailwind utility lives in `@layer utilities`, which outranks `@layer components` no matter
34
+ * how specific the component rule is — so `bg-background` baked unconditionally into the class
35
+ * list would silently defeat `filled` and `borderless` and no gate would notice. The outlined
36
+ * field therefore keeps exactly the utilities it always had, and the other two simply do not
37
+ * receive them; their surface comes from `.ui-control--filled` / `.ui-control--borderless`.
38
+ */
39
+ export declare const CONTROL_VARIANT_CHROME_CLASS: Record<ControlVariantProp, string>;
40
+ /**
41
+ * The status BOUNDARY, for the same cascade-layer reason — and this one was measured the hard way.
42
+ *
43
+ * `.ui-control[data-status="warning"] { border-color: … }` in `@layer components` renders exactly
44
+ * nothing: `border-input` is a utility, utilities are a later layer, and a later layer wins over
45
+ * any specificity. In Chromium the warned field measured `rgb(144 135 127)` — the resting border —
46
+ * with the component rule in place and no error anywhere. Painting it from a utility instead puts
47
+ * the two declarations in the SAME layer, where `data-[status=…]` (0,2,0) genuinely outranks
48
+ * `border-input` (0,1,0). It is also the mechanism the library already used for the invalid state
49
+ * (`aria-invalid:border-destructive`), so the two states now paint the same way.
50
+ *
51
+ * The `--focus-*` reassignments stay in `control.css`: those are custom properties, and no utility
52
+ * competes for them.
53
+ */
54
+ export declare const CONTROL_STATUS_CHROME_CLASS = "data-[status=error]:border-destructive data-[status=warning]:border-warning";
55
+ /** Default `count.strategy` — code points, so a surrogate pair counts once. */
56
+ export declare function countCodePoints(value: string): number;
57
+ export type ResolvedControlCount = {
58
+ count: number;
59
+ max?: number;
60
+ exceeded: boolean;
61
+ content: React.ReactNode;
62
+ };
63
+ /** `null` when the counter is switched off (no `count`, or `count.show === false`). */
64
+ export declare function resolveControlCount(config: ControlCountProp | undefined, value: string): ResolvedControlCount | null;
@@ -0,0 +1,39 @@
1
+ function controlAppearanceAttributes({
2
+ status,
3
+ variant,
4
+ "aria-invalid": ariaInvalid
5
+ }) {
6
+ return {
7
+ "data-status": status,
8
+ "data-variant": variant,
9
+ "aria-invalid": ariaInvalid ?? (status === "error" ? true : void 0)
10
+ };
11
+ }
12
+ const CONTROL_VARIANT_CHROME_CLASS = {
13
+ outlined: "border-input bg-background",
14
+ filled: "ui-control--filled",
15
+ borderless: "ui-control--borderless"
16
+ };
17
+ const CONTROL_STATUS_CHROME_CLASS = "data-[status=error]:border-destructive data-[status=warning]:border-warning";
18
+ function countCodePoints(value) {
19
+ return [...value].length;
20
+ }
21
+ function resolveControlCount(config, value) {
22
+ if (!config || config.show === false) return null;
23
+ const strategy = config.strategy ?? countCodePoints;
24
+ const count = strategy(value);
25
+ const max = config.max;
26
+ return {
27
+ count,
28
+ max,
29
+ exceeded: max != null && count > max,
30
+ content: config.formatter ? config.formatter({ value, count, max }) : max == null ? String(count) : `${count} / ${max}`
31
+ };
32
+ }
33
+ export {
34
+ CONTROL_STATUS_CHROME_CLASS,
35
+ CONTROL_VARIANT_CHROME_CLASS,
36
+ controlAppearanceAttributes,
37
+ countCodePoints,
38
+ resolveControlCount
39
+ };
@@ -0,0 +1,61 @@
1
+ import type * as React from "react";
2
+ import type { AllowClearProp, ControlStatusProp, ControlVariantProp, MaxTagPlaceholderProp, SizeProp } from "../../props/vocabulary/index.js";
3
+ /**
4
+ * The DOM attributes that put a control on the `variant` × `status` × `size` matrix owned by
5
+ * `.ui-control-surface` in `src/styles/control.css`.
6
+ *
7
+ * Written once, here, rather than five times: every member of the select family (Select,
8
+ * SearchSelect, Cascader, TreeSelect, TagInput) states the antd surface contract the same way, and
9
+ * a per-component copy is how the five drift apart. Each default (`outlined`, `md`) emits NO
10
+ * attribute at all, so a control that says nothing keeps the exact DOM it had.
11
+ */
12
+ export declare function controlSurfaceAttrs(props: {
13
+ variant?: ControlVariantProp;
14
+ status?: ControlStatusProp;
15
+ size?: SizeProp;
16
+ }): {
17
+ "data-variant"?: ControlVariantProp;
18
+ "data-status"?: ControlStatusProp;
19
+ "data-size"?: SizeProp;
20
+ };
21
+ /**
22
+ * `status="error"` must also reach assistive tech, so it folds into `aria-invalid`.
23
+ *
24
+ * antd's own `status="error"` is a pure recolour — a state announced by hue alone, which WCAG 2.2
25
+ * SC 1.4.1 does not accept. An `aria-invalid` arriving from `FormField` always wins: the field's
26
+ * validation state is the authority, and a `status` prop must never be able to talk it down.
27
+ */
28
+ export declare function resolveAriaInvalid<T extends React.AriaAttributes["aria-invalid"]>(ariaInvalid: T, status: ControlStatusProp | undefined): T | true | undefined;
29
+ /** The normalised clear affordance: whether to offer it, with what icon, under what label. */
30
+ export type ResolvedAllowClear = {
31
+ enabled: boolean;
32
+ clearIcon?: React.ReactNode;
33
+ label?: string;
34
+ };
35
+ /**
36
+ * Reconcile antd's `allowClear` with this library's own `clearable`.
37
+ *
38
+ * `allowClear` wins when present because it is the more specific statement — the object form
39
+ * carries an icon and a label that `clearable` has no way to express. `clearable` remains the
40
+ * name every existing call site uses, and keeps its `true` default.
41
+ */
42
+ export declare function resolveAllowClear(allowClear: AllowClearProp | undefined, clearable: boolean | undefined, fallbackLabel?: string): ResolvedAllowClear;
43
+ /**
44
+ * Apply antd's `maxTagCount` / `maxTagPlaceholder` to a list of selected values.
45
+ *
46
+ * Returns the values that stay visible plus the overflow node, so the three call sites (Cascader,
47
+ * TreeSelect, TagInput) agree on what "+2" means. `maxTagCount` is only honoured when it is a
48
+ * non-negative number — `undefined` shows everything, which is the antd default.
49
+ *
50
+ * `overflow` is `undefined` when the consumer supplied no `maxTagPlaceholder`: the fallback wording
51
+ * is a COUNT, and a count has to go through `t()` + `Intl.PluralRules` at the call site rather than
52
+ * be concatenated here.
53
+ */
54
+ export declare function applyMaxTagCount<T extends {
55
+ value: string;
56
+ label: React.ReactNode;
57
+ }>(items: T[], maxTagCount: number | undefined, maxTagPlaceholder: MaxTagPlaceholderProp | undefined): {
58
+ visible: T[];
59
+ omitted: T[];
60
+ overflow: React.ReactNode | undefined;
61
+ };
@@ -0,0 +1,39 @@
1
+ function controlSurfaceAttrs(props) {
2
+ return {
3
+ "data-variant": props.variant && props.variant !== "outlined" ? props.variant : void 0,
4
+ "data-status": props.status,
5
+ "data-size": props.size && props.size !== "md" ? props.size : void 0
6
+ };
7
+ }
8
+ function resolveAriaInvalid(ariaInvalid, status) {
9
+ if (ariaInvalid !== void 0) return ariaInvalid;
10
+ return status === "error" ? true : void 0;
11
+ }
12
+ function resolveAllowClear(allowClear, clearable, fallbackLabel) {
13
+ if (allowClear !== void 0) {
14
+ if (typeof allowClear === "boolean") {
15
+ return { enabled: allowClear, label: fallbackLabel };
16
+ }
17
+ return {
18
+ enabled: true,
19
+ clearIcon: allowClear.clearIcon,
20
+ label: allowClear.label ?? fallbackLabel
21
+ };
22
+ }
23
+ return { enabled: clearable !== false, label: fallbackLabel };
24
+ }
25
+ function applyMaxTagCount(items, maxTagCount, maxTagPlaceholder) {
26
+ if (maxTagCount === void 0 || maxTagCount < 0 || items.length <= maxTagCount) {
27
+ return { visible: items, omitted: [], overflow: void 0 };
28
+ }
29
+ const visible = items.slice(0, maxTagCount);
30
+ const omitted = items.slice(maxTagCount);
31
+ const overflow = typeof maxTagPlaceholder === "function" ? maxTagPlaceholder(omitted.map(({ value, label }) => ({ value, label }))) : maxTagPlaceholder;
32
+ return { visible, omitted, overflow };
33
+ }
34
+ export {
35
+ applyMaxTagCount,
36
+ controlSurfaceAttrs,
37
+ resolveAllowClear,
38
+ resolveAriaInvalid
39
+ };
@@ -6,4 +6,4 @@ export type { DatePickerProp, DatePickerProp as DatePickerProps, } from "../../p
6
6
  * `yyyy-MM-dd` string (the international standard): it is form-submittable (give it a `name`),
7
7
  * screen-reader friendly, and e2e-testable by simply filling the input.
8
8
  */
9
- export declare function DatePicker({ value: valueProp, defaultValue, onValueChange, placeholder, disabled, className, id, name, locale: localeProp, showToday, showClose, fromDate, toDate, allowClear, ...ariaProps }: DatePickerProp): React.JSX.Element;
9
+ export declare function DatePicker(props: DatePickerProp): React.JSX.Element;