@godxjp/ui 19.6.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 (326) 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 +14 -3
  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/collapsible.d.ts +23 -4
  20. package/dist/components/data-display/collapsible.js +119 -4
  21. package/dist/components/data-display/data-table.d.ts +39 -4
  22. package/dist/components/data-display/data-table.js +802 -270
  23. package/dist/components/data-display/descriptions.d.ts +27 -6
  24. package/dist/components/data-display/descriptions.js +58 -17
  25. package/dist/components/data-display/index.d.ts +5 -1
  26. package/dist/components/data-display/index.js +4 -0
  27. package/dist/components/data-display/legend.d.ts +15 -0
  28. package/dist/components/data-display/legend.js +11 -0
  29. package/dist/components/data-display/list-row.d.ts +10 -1
  30. package/dist/components/data-display/list-row.js +8 -2
  31. package/dist/components/data-display/popover.d.ts +60 -7
  32. package/dist/components/data-display/popover.js +268 -39
  33. package/dist/components/data-display/progress.d.ts +50 -2
  34. package/dist/components/data-display/progress.js +57 -9
  35. package/dist/components/data-display/range-timeline.d.ts +38 -0
  36. package/dist/components/data-display/range-timeline.js +161 -0
  37. package/dist/components/data-display/scroll-area.js +13 -2
  38. package/dist/components/data-display/service-launcher-card.js +10 -10
  39. package/dist/components/data-display/table.d.ts +11 -3
  40. package/dist/components/data-display/table.js +48 -18
  41. package/dist/components/data-display/tree-list.js +4 -9
  42. package/dist/components/data-entry/calendar.d.ts +2 -2
  43. package/dist/components/data-entry/calendar.js +79 -33
  44. package/dist/components/data-entry/cascader.d.ts +1 -1
  45. package/dist/components/data-entry/cascader.js +188 -24
  46. package/dist/components/data-entry/checkbox.d.ts +19 -6
  47. package/dist/components/data-entry/checkbox.js +55 -16
  48. package/dist/components/data-entry/choice-option.d.ts +1 -1
  49. package/dist/components/data-entry/color-picker.d.ts +1 -1
  50. package/dist/components/data-entry/color-picker.js +17 -5
  51. package/dist/components/data-entry/control-appearance.d.ts +64 -0
  52. package/dist/components/data-entry/control-appearance.js +39 -0
  53. package/dist/components/data-entry/control-surface.d.ts +61 -0
  54. package/dist/components/data-entry/control-surface.js +39 -0
  55. package/dist/components/data-entry/date-picker.d.ts +1 -1
  56. package/dist/components/data-entry/date-picker.js +344 -113
  57. package/dist/components/data-entry/date-range-picker.d.ts +2 -2
  58. package/dist/components/data-entry/date-range-picker.js +278 -140
  59. package/dist/components/data-entry/field.js +0 -1
  60. package/dist/components/data-entry/form-field.d.ts +1 -1
  61. package/dist/components/data-entry/form-field.js +39 -4
  62. package/dist/components/data-entry/form.d.ts +4 -0
  63. package/dist/components/data-entry/form.js +5 -3
  64. package/dist/components/data-entry/index.d.ts +7 -3
  65. package/dist/components/data-entry/index.js +10 -1
  66. package/dist/components/data-entry/input-otp.d.ts +1 -1
  67. package/dist/components/data-entry/input.d.ts +12 -34
  68. package/dist/components/data-entry/input.js +92 -24
  69. package/dist/components/data-entry/label.d.ts +3 -2
  70. package/dist/components/data-entry/label.js +23 -10
  71. package/dist/components/data-entry/month-picker.d.ts +2 -2
  72. package/dist/components/data-entry/month-picker.js +47 -10
  73. package/dist/components/data-entry/month-range-picker.d.ts +2 -2
  74. package/dist/components/data-entry/month-range-picker.js +51 -11
  75. package/dist/components/data-entry/number-input.d.ts +7 -0
  76. package/dist/components/data-entry/number-input.js +147 -98
  77. package/dist/components/data-entry/password-input.d.ts +1 -1
  78. package/dist/components/data-entry/radio.d.ts +1 -1
  79. package/dist/components/data-entry/radio.js +61 -13
  80. package/dist/components/data-entry/search-input.d.ts +1 -1
  81. package/dist/components/data-entry/search-input.js +16 -2
  82. package/dist/components/data-entry/search-select.d.ts +2 -2
  83. package/dist/components/data-entry/search-select.js +209 -78
  84. package/dist/components/data-entry/select.d.ts +22 -4
  85. package/dist/components/data-entry/select.js +215 -163
  86. package/dist/components/data-entry/slider.d.ts +9 -1
  87. package/dist/components/data-entry/slider.js +87 -9
  88. package/dist/components/data-entry/switch.d.ts +3 -0
  89. package/dist/components/data-entry/switch.js +29 -3
  90. package/dist/components/data-entry/textarea.d.ts +14 -56
  91. package/dist/components/data-entry/textarea.js +80 -33
  92. package/dist/components/data-entry/time-picker.d.ts +2 -2
  93. package/dist/components/data-entry/time-picker.js +333 -109
  94. package/dist/components/data-entry/time-range-picker.d.ts +5 -0
  95. package/dist/components/data-entry/time-range-picker.js +89 -0
  96. package/dist/components/data-entry/transfer.d.ts +1 -1
  97. package/dist/components/data-entry/transfer.js +99 -31
  98. package/dist/components/data-entry/tree-select-strategy.d.ts +1 -1
  99. package/dist/components/data-entry/tree-select.d.ts +1 -1
  100. package/dist/components/data-entry/tree-select.js +197 -92
  101. package/dist/components/data-entry/tree-utils.d.ts +1 -1
  102. package/dist/components/data-entry/tree-utils.js +7 -14
  103. package/dist/components/data-entry/upload-files.d.ts +2 -0
  104. package/dist/components/data-entry/upload-files.js +31 -0
  105. package/dist/components/data-entry/upload-request.d.ts +4 -0
  106. package/dist/components/data-entry/upload-request.js +53 -0
  107. package/dist/components/data-entry/upload-types.d.ts +28 -0
  108. package/dist/components/data-entry/upload-types.js +2 -0
  109. package/dist/components/data-entry/upload.d.ts +2 -2
  110. package/dist/components/data-entry/upload.js +482 -117
  111. package/dist/components/feedback/dialog.d.ts +105 -38
  112. package/dist/components/feedback/dialog.js +268 -193
  113. package/dist/components/feedback/overlay-close-focus.d.ts +31 -0
  114. package/dist/components/feedback/overlay-close-focus.js +31 -0
  115. package/dist/components/feedback/overlay-header-tone.d.ts +1 -1
  116. package/dist/components/feedback/sheet.d.ts +53 -11
  117. package/dist/components/feedback/sheet.js +150 -81
  118. package/dist/components/feedback/tooltip.d.ts +51 -7
  119. package/dist/components/feedback/tooltip.js +107 -25
  120. package/dist/components/general/button.d.ts +1 -1
  121. package/dist/components/general/button.js +7 -3
  122. package/dist/components/general/index.d.ts +1 -0
  123. package/dist/components/general/index.js +2 -0
  124. package/dist/components/general/logo.d.ts +17 -0
  125. package/dist/components/general/logo.js +22 -16
  126. package/dist/components/general/typography.d.ts +3 -0
  127. package/dist/components/general/typography.js +15 -1
  128. package/dist/components/general/visually-hidden.d.ts +3 -0
  129. package/dist/components/general/visually-hidden.js +9 -0
  130. package/dist/components/layout/app-launcher.d.ts +34 -0
  131. package/dist/components/layout/app-launcher.js +228 -0
  132. package/dist/components/layout/app-shell.d.ts +3 -1
  133. package/dist/components/layout/app-shell.js +69 -12
  134. package/dist/components/layout/aspect-ratio.js +0 -1
  135. package/dist/components/layout/auth-divider.js +0 -1
  136. package/dist/components/layout/breadcrumb.d.ts +14 -2
  137. package/dist/components/layout/breadcrumb.js +46 -4
  138. package/dist/components/layout/flex.d.ts +1 -1
  139. package/dist/components/layout/flex.js +41 -3
  140. package/dist/components/layout/index.d.ts +3 -0
  141. package/dist/components/layout/index.js +5 -1
  142. package/dist/components/layout/nav-surface.d.ts +26 -0
  143. package/dist/components/layout/nav-surface.js +17 -0
  144. package/dist/components/layout/org-switcher.d.ts +5 -1
  145. package/dist/components/layout/org-switcher.js +25 -4
  146. package/dist/components/layout/page-container.d.ts +1 -1
  147. package/dist/components/layout/page-container.js +5 -3
  148. package/dist/components/layout/responsive-grid.d.ts +16 -2
  149. package/dist/components/layout/responsive-grid.js +29 -2
  150. package/dist/components/layout/separator.js +0 -1
  151. package/dist/components/layout/sidebar.js +4 -1
  152. package/dist/components/layout/split-pane.d.ts +14 -1
  153. package/dist/components/layout/split-pane.js +26 -13
  154. package/dist/components/layout/topbar-item.d.ts +3 -0
  155. package/dist/components/layout/topbar-item.js +19 -5
  156. package/dist/components/layout/topbar.d.ts +1 -1
  157. package/dist/components/layout/topbar.js +27 -6
  158. package/dist/components/navigation/app-setting-picker.js +21 -2
  159. package/dist/components/navigation/app-setting-toggle.d.ts +16 -0
  160. package/dist/components/navigation/app-setting-toggle.js +96 -0
  161. package/dist/components/navigation/dropdown-menu.d.ts +227 -18
  162. package/dist/components/navigation/dropdown-menu.js +402 -118
  163. package/dist/components/navigation/index.d.ts +2 -0
  164. package/dist/components/navigation/index.js +2 -0
  165. package/dist/components/navigation/pagination-utils.d.ts +2 -1
  166. package/dist/components/navigation/pagination.d.ts +2 -2
  167. package/dist/components/navigation/pagination.js +155 -83
  168. package/dist/components/navigation/steps.d.ts +2 -2
  169. package/dist/components/navigation/steps.js +29 -4
  170. package/dist/components/navigation/tabs.d.ts +29 -16
  171. package/dist/components/navigation/tabs.js +374 -144
  172. package/dist/components/ui/accordion.d.ts +50 -5
  173. package/dist/components/ui/accordion.js +239 -33
  174. package/dist/components/ui/aspect-ratio.d.ts +23 -2
  175. package/dist/components/ui/aspect-ratio.js +15 -13
  176. package/dist/components/ui/avatar.d.ts +29 -4
  177. package/dist/components/ui/avatar.js +111 -25
  178. package/dist/components/ui/hover-card.d.ts +42 -4
  179. package/dist/components/ui/hover-card.js +183 -27
  180. package/dist/components/ui/input-otp.d.ts +26 -28
  181. package/dist/components/ui/input-otp.js +50 -7
  182. package/dist/components/ui/label.js +0 -1
  183. package/dist/components/ui/password-input.d.ts +36 -2
  184. package/dist/components/ui/password-input.js +27 -7
  185. package/dist/components/ui/rating.d.ts +25 -0
  186. package/dist/components/ui/rating.js +67 -27
  187. package/dist/components/ui/segmented.d.ts +12 -3
  188. package/dist/components/ui/segmented.js +17 -2
  189. package/dist/components/ui/separator.d.ts +12 -2
  190. package/dist/components/ui/separator.js +30 -9
  191. package/dist/components/ui/tag-input.d.ts +45 -0
  192. package/dist/components/ui/tag-input.js +109 -27
  193. package/dist/components/ui/toggle-group.d.ts +50 -5
  194. package/dist/components/ui/toggle-group.js +79 -20
  195. package/dist/components/ui/toggle.d.ts +31 -5
  196. package/dist/components/ui/toggle.js +42 -3
  197. package/dist/form/form-context.d.ts +29 -0
  198. package/dist/form/form-context.js +44 -4
  199. package/dist/form/form-field-array.d.ts +22 -0
  200. package/dist/form/form-field-array.js +50 -0
  201. package/dist/form/form-field-control.d.ts +2 -1
  202. package/dist/form/form-field-control.js +116 -40
  203. package/dist/form/form-root.d.ts +2 -1
  204. package/dist/form/form-root.js +142 -23
  205. package/dist/form/index.d.ts +3 -1
  206. package/dist/form/index.js +12 -1
  207. package/dist/i18n/messages/en.json +64 -5
  208. package/dist/i18n/messages/ja.json +64 -5
  209. package/dist/i18n/messages/vi.json +64 -5
  210. package/dist/inertia/index.d.ts +20 -0
  211. package/dist/inertia/index.js +60 -1
  212. package/dist/lib/control-styles.d.ts +25 -3
  213. package/dist/lib/control-styles.js +9 -3
  214. package/dist/lib/datetime/picker-format.d.ts +8 -0
  215. package/dist/lib/datetime/picker-format.js +54 -0
  216. package/dist/lib/slot.d.ts +32 -0
  217. package/dist/lib/slot.js +22 -0
  218. package/dist/lib/variants.d.ts +22 -3
  219. package/dist/lib/variants.js +56 -1
  220. package/dist/props/components/app.prop.d.ts +25 -1
  221. package/dist/props/components/charts.prop.d.ts +21 -0
  222. package/dist/props/components/data-display.prop.d.ts +72 -4
  223. package/dist/props/components/data-entry.prop.d.ts +718 -46
  224. package/dist/props/components/form.prop.d.ts +142 -4
  225. package/dist/props/components/general.prop.d.ts +17 -1
  226. package/dist/props/components/index.d.ts +3 -3
  227. package/dist/props/components/layout.prop.d.ts +281 -11
  228. package/dist/props/components/navigation.prop.d.ts +114 -4
  229. package/dist/props/registry.d.ts +397 -11
  230. package/dist/props/registry.js +526 -11
  231. package/dist/props/vocabulary/content.prop.d.ts +1 -1
  232. package/dist/props/vocabulary/data.prop.d.ts +179 -1
  233. package/dist/props/vocabulary/index.d.ts +5 -5
  234. package/dist/props/vocabulary/interaction.prop.d.ts +68 -3
  235. package/dist/props/vocabulary/layout.prop.d.ts +57 -1
  236. package/dist/props/vocabulary/navigation.prop.d.ts +40 -0
  237. package/dist/props/vocabulary/shared.prop.d.ts +33 -0
  238. package/dist/styles/badge-layout.css +2 -1
  239. package/dist/styles/card-layout.css +26 -4
  240. package/dist/styles/chart-layout.css +15 -0
  241. package/dist/styles/control.css +657 -15
  242. package/dist/styles/core.css +5 -2
  243. package/dist/styles/data-display-layout.css +313 -6
  244. package/dist/styles/data-entry-layout.css +13 -0
  245. package/dist/styles/focus-ring.css +4 -0
  246. package/dist/styles/index.css +5 -2
  247. package/dist/styles/layout.css +327 -4
  248. package/dist/styles/navigation-layout.css +227 -0
  249. package/dist/styles/shell-layout.css +369 -13
  250. package/dist/styles/table-layout.css +95 -6
  251. package/dist/styles/text-layout.css +10 -4
  252. package/dist/tokens/base.css +2 -1
  253. package/dist/tokens/components/badge.css +1 -0
  254. package/dist/tokens/components/chart.css +6 -0
  255. package/dist/tokens/components/control.css +79 -2
  256. package/dist/tokens/components/data-display.css +20 -0
  257. package/dist/tokens/components/descriptions.css +11 -0
  258. package/dist/tokens/components/flex.css +8 -0
  259. package/dist/tokens/components/navigation.css +55 -0
  260. package/dist/tokens/components/shell.css +53 -3
  261. package/dist/tokens/components/table.css +14 -0
  262. package/dist/tokens/foundation.css +2 -0
  263. package/dist/tokens/semantic/layout.css +9 -0
  264. package/docs/COMPONENTS.md +9 -3
  265. package/docs/CONSUMER-RULES.md +13 -0
  266. package/docs/DESIGN-AUTHORITY.md +145 -83
  267. package/docs/DEVELOPMENT.md +4 -3
  268. package/docs/FORMS.md +151 -6
  269. package/docs/FRAME-COVERAGE-REPORT.md +32 -17
  270. package/docs/README.md +15 -15
  271. package/docs/STANDARDS-vocabulary-tokens.md +1 -1
  272. package/docs/TESTING.md +15 -6
  273. package/docs/WHAT-BELONGS-HERE.md +179 -0
  274. package/docs/charts/cjk-category-axis.tsx +81 -0
  275. package/docs/data-display/card/index.tsx +22 -0
  276. package/docs/data-display/data-table/examples/antd-parity.tsx +257 -0
  277. package/docs/data-display/data-table/index.tsx +23 -0
  278. package/docs/data-display/descriptions.tsx +41 -0
  279. package/docs/data-display/legend.tsx +145 -0
  280. package/docs/data-display/progress.tsx +32 -0
  281. package/docs/data-display/scroll-area.tsx +31 -25
  282. package/docs/data-display/table.tsx +104 -45
  283. package/docs/data-display/timeline.tsx +41 -0
  284. package/docs/data-entry/date-picker.tsx +85 -0
  285. package/docs/data-entry/date-range-picker.tsx +26 -0
  286. package/docs/data-entry/form-dynamic-fields.tsx +199 -0
  287. package/docs/data-entry/form.tsx +74 -4
  288. package/docs/data-entry/input-otp.tsx +24 -0
  289. package/docs/data-entry/input.tsx +46 -1
  290. package/docs/data-entry/month-range-picker.tsx +1 -1
  291. package/docs/data-entry/segmented.tsx +1 -1
  292. package/docs/data-entry/select.tsx +29 -2
  293. package/docs/data-entry/switch.tsx +41 -0
  294. package/docs/data-entry/textarea.tsx +38 -0
  295. package/docs/data-entry/time-picker.tsx +85 -1
  296. package/docs/data-entry/time-range-picker.tsx +55 -0
  297. package/docs/data-entry/transfer.tsx +17 -0
  298. package/docs/data-entry/upload.tsx +56 -12
  299. package/docs/feedback/sheet.tsx +1 -1
  300. package/docs/feedback/tooltip.tsx +1 -1
  301. package/docs/general/activity.tsx +2 -2
  302. package/docs/general/button/index.tsx +14 -1
  303. package/docs/general/typography.tsx +14 -1
  304. package/docs/layout/app-launcher.tsx +151 -0
  305. package/docs/layout/app-shell-arrangements.tsx +225 -0
  306. package/docs/layout/app-shell.tsx +11 -0
  307. package/docs/layout/aspect-ratio.tsx +1 -1
  308. package/docs/layout/flex.tsx +50 -0
  309. package/docs/layout/responsive-grid.tsx +21 -1
  310. package/docs/layout/topbar.tsx +5 -9
  311. package/docs/navigation/app-setting-picker.tsx +37 -1
  312. package/docs/navigation/app-setting-toggle.tsx +111 -0
  313. package/docs/navigation/breadcrumb.tsx +48 -0
  314. package/docs/navigation/dropdown-menu.tsx +21 -0
  315. package/docs/navigation/pagination.tsx +52 -0
  316. package/docs/navigation/steps.tsx +37 -0
  317. package/docs/navigation/tabs.tsx +97 -1
  318. package/docs/query/button-refetch.tsx +1 -0
  319. package/package.json +28 -8
  320. package/scripts/_agent-setup.mjs +182 -3
  321. package/scripts/consumer-rule.md +98 -0
  322. package/scripts/guinea-pig-skill.md +322 -0
  323. package/scripts/init-guinea-pig.mjs +84 -0
  324. package/scripts/postinstall.mjs +13 -2
  325. package/scripts/ui-audit.mjs +351 -37
  326. /package/dist/tokens/{antd.generated.css → derived.css} +0 -0
@@ -1,5 +1,4 @@
1
1
  import * as React from "react";
2
- import * as TogglePrimitive from "@radix-ui/react-toggle";
3
2
  import { type VariantProps } from "class-variance-authority";
4
3
  declare const toggleVariants: (props?: ({
5
4
  variant?: "default" | "outline" | null | undefined;
@@ -29,6 +28,19 @@ type ToggleCountFields = {
29
28
  */
30
29
  countLabel?: string;
31
30
  };
31
+ /**
32
+ * The repo's two-state vocabulary, kept VERBATIM from the Radix era. React Aria spells the same
33
+ * four things `isSelected` / `defaultSelected` / `onChange` / `isDisabled`; the translation lives
34
+ * inside this file so no consumer ever has to learn RAC's names.
35
+ */
36
+ type TogglePressedFields = {
37
+ /** Controlled pressed state — RAC `isSelected`. */
38
+ pressed?: boolean;
39
+ /** Uncontrolled initial pressed state — RAC `defaultSelected`. */
40
+ defaultPressed?: boolean;
41
+ /** Fired with the NEW pressed state — RAC `onChange`. */
42
+ onPressedChange?: (pressed: boolean) => void;
43
+ };
32
44
  /** Counter pill shared by `Toggle` and `ToggleGroupItem`. ACCESSIBLE NAME. */
33
45
  declare function useCounterPill({ count, overflowCount, showZero, countLabel, ariaLabel, }: ToggleCountFields & {
34
46
  ariaLabel?: string;
@@ -39,11 +51,25 @@ declare function useCounterPill({ count, overflowCount, showZero, countLabel, ar
39
51
  pill: React.JSX.Element;
40
52
  resolvedAriaLabel: string | undefined;
41
53
  };
42
- export type ToggleProp = React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants> & ToggleCountFields;
54
+ /**
55
+ * RAC's `filterDOMProps` forwards only `id`, `data-*`, the four labelling `aria-*` and the global
56
+ * mouse/pointer events; `title`, `tabIndex` and the rarer DOM props are dropped silently, and
57
+ * Radix forwarded ALL of them. `render` is RAC's own escape hatch: the raw props go on first, RAC's
58
+ * merged ones second so its `type`/`disabled`/`aria-pressed`/handlers always win.
59
+ *
60
+ * Two exceptions, both of which Radix owned: `tabIndex` stays the caller's, and so does `id` —
61
+ * inside a ToggleButtonGroup RAC spends `id` as the selection KEY and blanks the DOM attribute,
62
+ * which would otherwise silently drop the id off every grouped item.
63
+ */
64
+ declare function restoreDomProps<P extends {
65
+ id?: string;
66
+ tabIndex?: number;
67
+ }>(raw: P, domProps: React.JSX.IntrinsicElements["button"]): React.JSX.Element;
68
+ export type ToggleProp = React.ComponentPropsWithoutRef<"button"> & TogglePressedFields & VariantProps<typeof toggleVariants> & ToggleCountFields;
43
69
  export type ToggleProps = ToggleProp;
44
- export declare const Toggle: React.ForwardRefExoticComponent<Omit<TogglePrimitive.ToggleProps & React.RefAttributes<HTMLButtonElement>, "ref"> & VariantProps<(props?: ({
70
+ export declare const Toggle: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & TogglePressedFields & VariantProps<(props?: ({
45
71
  variant?: "default" | "outline" | null | undefined;
46
72
  size?: "lg" | "md" | "sm" | null | undefined;
47
73
  } & import("class-variance-authority/types").ClassProp) | undefined) => string> & ToggleCountFields & React.RefAttributes<HTMLButtonElement>>;
48
- export { toggleVariants, useCounterPill };
49
- export type { ToggleCountFields };
74
+ export { toggleVariants, useCounterPill, restoreDomProps };
75
+ export type { ToggleCountFields, TogglePressedFields };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
- import * as TogglePrimitive from "@radix-ui/react-toggle";
4
+ import { ToggleButton } from "react-aria-components";
5
5
  import { cva } from "class-variance-authority";
6
6
  import { cn } from "../../lib/utils.js";
7
7
  import { useTranslation } from "../../i18n/use-translation.js";
@@ -48,6 +48,30 @@ function useCounterPill({
48
48
  resolvedAriaLabel: ariaLabel == null ? ariaLabel : `${ariaLabel}, ${spoken}`
49
49
  };
50
50
  }
51
+ function usePressedState({ pressed, defaultPressed, onPressedChange }) {
52
+ const [uncontrolled, setUncontrolled] = React.useState(defaultPressed ?? false);
53
+ const isPressed = pressed ?? uncontrolled;
54
+ return {
55
+ isPressed,
56
+ onSelectionChange: (next) => {
57
+ if (pressed == null) {
58
+ setUncontrolled(next);
59
+ }
60
+ onPressedChange?.(next);
61
+ }
62
+ };
63
+ }
64
+ function restoreDomProps(raw, domProps) {
65
+ return /* @__PURE__ */ jsx(
66
+ "button",
67
+ {
68
+ ...raw,
69
+ ...domProps,
70
+ id: raw.id ?? domProps.id,
71
+ tabIndex: raw.tabIndex ?? domProps.tabIndex
72
+ }
73
+ );
74
+ }
51
75
  const Toggle = React.forwardRef(
52
76
  ({
53
77
  className,
@@ -59,6 +83,10 @@ const Toggle = React.forwardRef(
59
83
  countLabel,
60
84
  children,
61
85
  "aria-label": ariaLabel,
86
+ pressed,
87
+ defaultPressed,
88
+ onPressedChange,
89
+ disabled,
62
90
  ...props
63
91
  }, ref) => {
64
92
  const { pill, resolvedAriaLabel } = useCounterPill({
@@ -68,14 +96,24 @@ const Toggle = React.forwardRef(
68
96
  countLabel,
69
97
  ariaLabel
70
98
  });
99
+ const { isPressed, onSelectionChange } = usePressedState({
100
+ pressed,
101
+ defaultPressed,
102
+ onPressedChange
103
+ });
71
104
  return /* @__PURE__ */ jsxs(
72
- TogglePrimitive.Root,
105
+ ToggleButton,
73
106
  {
74
107
  ref,
75
108
  "data-slot": "toggle",
109
+ "data-state": isPressed ? "on" : "off",
76
110
  "aria-label": resolvedAriaLabel,
77
111
  className: cn(toggleVariants({ variant, size }), className),
78
112
  ...props,
113
+ isSelected: isPressed,
114
+ onChange: onSelectionChange,
115
+ isDisabled: disabled,
116
+ render: (domProps) => restoreDomProps(props, domProps),
79
117
  children: [
80
118
  children,
81
119
  pill
@@ -84,9 +122,10 @@ const Toggle = React.forwardRef(
84
122
  );
85
123
  }
86
124
  );
87
- Toggle.displayName = TogglePrimitive.Root.displayName;
125
+ Toggle.displayName = "Toggle";
88
126
  export {
89
127
  Toggle,
128
+ restoreDomProps,
90
129
  toggleVariants,
91
130
  useCounterPill
92
131
  };
@@ -1,3 +1,4 @@
1
+ import { type Control, type FieldPath, type FieldValues, type UseFormReturn } from "react-hook-form";
1
2
  import type { FormStateAdapter } from "../props/components/form.prop.js";
2
3
  /**
3
4
  * Context carrying a framework-agnostic {@link FormStateAdapter}. `FormRoot` provides it on the
@@ -7,11 +8,39 @@ import type { FormStateAdapter } from "../props/components/form.prop.js";
7
8
  export declare const FormAdapterContext: import("react").Context<FormStateAdapter | null>;
8
9
  /** Read the active form-state adapter, or `null` when `FormRoot` runs the react-hook-form path. */
9
10
  export declare function useFormAdapter(): FormStateAdapter | null;
11
+ /** Form-wide options shared by BOTH paths — currently the antd-style form-level `disabled`. */
12
+ export interface FormOptionsContextValue {
13
+ disabled: boolean;
14
+ submitting?: boolean;
15
+ }
16
+ /** Defaults to enabled so a `FormField`/`FormFieldControl` outside a `FormRoot` keeps working. */
17
+ export declare const FormOptionsContext: import("react").Context<FormOptionsContextValue>;
18
+ /**
19
+ * Whether the surrounding `FormRoot` disables its fields (`FormRoot disabled`). Read it for the
20
+ * action buttons, which are NOT fields and so are never disabled automatically.
21
+ */
22
+ export declare function useFormDisabled(): boolean;
10
23
  /**
11
24
  * Whether the surrounding `FormRoot` is currently submitting — works for BOTH paths: the adapter's
12
25
  * `isSubmitting` (e.g. Inertia's `processing`) or react-hook-form's `formState.isSubmitting`.
13
26
  */
14
27
  export declare function useFormSubmitting(): boolean;
28
+ /**
29
+ * The react-hook-form instance of the surrounding `FormRoot` (antd `Form.useFormInstance`) — for
30
+ * `setValue`/`trigger`/`getValues` deep inside a form without prop-drilling `form`. Throws on the
31
+ * adapter path, which has no RHF instance; use {@link useFormAdapter} there.
32
+ */
33
+ export declare function useFormInstance<TFieldValues extends FieldValues = FieldValues>(): UseFormReturn<TFieldValues>;
34
+ export declare function getFallbackFormControl(): Control<FieldValues>;
35
+ /**
36
+ * Subscribe to a field's value (antd `Form.useWatch`) — the "show this section only when `plan`
37
+ * is `enterprise`" case, WITHOUT re-rendering the whole form. Omit `name` for every value.
38
+ * Works on both paths: react-hook-form's `useWatch`, or the adapter's `getValue`/`getValues`.
39
+ *
40
+ * Returns `unknown` — the same contract as `FormFieldControl`'s render-prop `value`. Narrow at the
41
+ * call site (`String(v ?? "")`, a Zod parse, a type guard).
42
+ */
43
+ export declare function useFormWatch<TFieldValues extends FieldValues = FieldValues>(name?: FieldPath<TFieldValues>): unknown;
15
44
  /**
16
45
  * Normalise a control's change payload to a bare value. The `FormFieldControl` render-prop spreads
17
46
  * `onChange` onto a control that may call it with a DOM `ChangeEvent` (native `<Input>`) OR a raw
@@ -1,15 +1,50 @@
1
1
  "use client";
2
2
  import { createContext, useContext } from "react";
3
- import { useFormContext } from "react-hook-form";
3
+ import {
4
+ createFormControl,
5
+ useFormContext,
6
+ useWatch
7
+ } from "react-hook-form";
4
8
  const FormAdapterContext = createContext(null);
5
9
  function useFormAdapter() {
6
10
  return useContext(FormAdapterContext);
7
11
  }
12
+ const FormOptionsContext = createContext({ disabled: false });
13
+ function useFormDisabled() {
14
+ return useContext(FormOptionsContext).disabled;
15
+ }
8
16
  function useFormSubmitting() {
17
+ const { submitting } = useContext(FormOptionsContext);
18
+ const adapter = useContext(FormAdapterContext);
19
+ const rhf = useFormContext();
20
+ if (adapter) return Boolean(submitting || adapter.isSubmitting);
21
+ return Boolean(submitting || rhf?.formState?.isSubmitting);
22
+ }
23
+ function useFormInstance() {
24
+ const rhf = useFormContext();
25
+ if (!rhf) {
26
+ throw new Error(
27
+ "useFormInstance must be rendered inside <FormRoot form={\u2026}> (react-hook-form path). On the adapter path use useFormAdapter()."
28
+ );
29
+ }
30
+ return rhf;
31
+ }
32
+ let fallbackControl;
33
+ function getFallbackFormControl() {
34
+ fallbackControl ??= createFormControl().control;
35
+ return fallbackControl;
36
+ }
37
+ function useFormWatch(name) {
9
38
  const adapter = useContext(FormAdapterContext);
10
39
  const rhf = useFormContext();
11
- if (adapter) return adapter.isSubmitting;
12
- return rhf?.formState?.isSubmitting ?? false;
40
+ const control = rhf?.control ?? getFallbackFormControl();
41
+ const watched = useWatch({
42
+ control,
43
+ name,
44
+ disabled: !rhf
45
+ });
46
+ if (adapter) return name === void 0 ? adapter.getValues?.() : adapter.getValue(name);
47
+ return watched;
13
48
  }
14
49
  function extractControlValue(arg) {
15
50
  if (arg && typeof arg === "object" && "target" in arg) {
@@ -23,7 +58,12 @@ function extractControlValue(arg) {
23
58
  }
24
59
  export {
25
60
  FormAdapterContext,
61
+ FormOptionsContext,
26
62
  extractControlValue,
63
+ getFallbackFormControl,
27
64
  useFormAdapter,
28
- useFormSubmitting
65
+ useFormDisabled,
66
+ useFormInstance,
67
+ useFormSubmitting,
68
+ useFormWatch
29
69
  };
@@ -0,0 +1,22 @@
1
+ import * as React from "react";
2
+ import { type FieldArrayPath, type FieldValues } from "react-hook-form";
3
+ import type { FormFieldArrayProp } from "../props/components/form.prop.js";
4
+ export type { FormFieldArrayProp } from "../props/components/form.prop.js";
5
+ /**
6
+ * FormFieldArray — repeating fields (antd `Form.List`) on react-hook-form's `useFieldArray`, so
7
+ * rows keep their identity across insert/remove/move instead of being re-keyed by index.
8
+ *
9
+ * Each row hands back its dotted path prefix; build the child field name from it, which is what
10
+ * makes nested validation messages land on the right row:
11
+ *
12
+ * ```tsx
13
+ * <FormFieldArray<Values, "contacts"> name="contacts">
14
+ * {({ fields, append, remove }) => (…
15
+ * <FormFieldControl name={`${row.name}.email`} label={t("contact.email")}>…
16
+ * )}
17
+ * </FormFieldArray>
18
+ * ```
19
+ *
20
+ * react-hook-form path only — a server-driven `adapter` owns its own collection state.
21
+ */
22
+ export declare function FormFieldArray<TFieldValues extends FieldValues, TName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>>({ name, children }: FormFieldArrayProp<TFieldValues, TName>): React.JSX.Element;
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ import { Fragment, jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import {
5
+ get,
6
+ useFieldArray,
7
+ useFormContext,
8
+ useFormState
9
+ } from "react-hook-form";
10
+ import { getFallbackFormControl, useFormDisabled } from "./form-context.js";
11
+ function arrayErrorMessage(errors, name) {
12
+ const entry = get(errors, name);
13
+ const message = entry?.root?.message ?? entry?.message;
14
+ return typeof message === "string" && message ? message : void 0;
15
+ }
16
+ function FormFieldArray({ name, children }) {
17
+ const rhf = useFormContext();
18
+ const control = rhf?.control ?? getFallbackFormControl();
19
+ const { fields, append, prepend, insert, remove, move, swap, replace } = useFieldArray({ control, name });
20
+ const { errors } = useFormState({ control, name });
21
+ const disabled = useFormDisabled();
22
+ const rows = React.useMemo(
23
+ () => fields.map((row, index) => ({
24
+ key: row.id,
25
+ name: `${String(name)}.${index}`,
26
+ index
27
+ })),
28
+ [fields, name]
29
+ );
30
+ if (!rhf) {
31
+ throw new Error(
32
+ "FormFieldArray must be rendered inside <FormRoot form={\u2026}> (react-hook-form path)."
33
+ );
34
+ }
35
+ return /* @__PURE__ */ jsx(Fragment, { children: children({
36
+ fields: rows,
37
+ append,
38
+ prepend,
39
+ insert,
40
+ remove,
41
+ move,
42
+ swap,
43
+ replace,
44
+ error: arrayErrorMessage(errors, String(name)),
45
+ disabled
46
+ }) });
47
+ }
48
+ export {
49
+ FormFieldArray
50
+ };
@@ -1,4 +1,5 @@
1
+ import * as React from "react";
1
2
  import { type FieldValues } from "react-hook-form";
2
3
  import type { FormFieldControlProp } from "../props/components/form.prop.js";
3
4
  export type { FormFieldControlProp } from "../props/components/form.prop.js";
4
- export declare function FormFieldControl<TFieldValues extends FieldValues>({ name, label, required, helper, className, children, }: FormFieldControlProp<TFieldValues>): import("react").JSX.Element;
5
+ export declare function FormFieldControl<TFieldValues extends FieldValues>({ name, id, field: fieldKey, labelAddon, layout, labelWidth, controlWidth, colSpan, label, required, helper, disabled, dependencies, getValueFromEvent, normalize, help, validateStatus, hasFeedback, feedback, preserve, className, children, }: FormFieldControlProp<TFieldValues>): React.JSX.Element;
@@ -1,70 +1,146 @@
1
1
  "use client";
2
- import { jsx } from "react/jsx-runtime";
3
- import { Controller, useFormContext } from "react-hook-form";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import {
5
+ Controller,
6
+ useFormContext,
7
+ useFormState,
8
+ useWatch
9
+ } from "react-hook-form";
4
10
  import { FormField } from "../components/data-entry/form-field.js";
5
- import { extractControlValue, useFormAdapter } from "./form-context.js";
11
+ import { extractControlValue, useFormAdapter, useFormDisabled } from "./form-context.js";
6
12
  const noopRef = () => {
7
13
  };
14
+ function bindField(field) {
15
+ return { ...field, onValueChange: field.onChange };
16
+ }
17
+ function FieldDependencies({
18
+ control,
19
+ name,
20
+ dependencies,
21
+ trigger
22
+ }) {
23
+ const values = useWatch({ control, name: dependencies });
24
+ const { isSubmitted } = useFormState({ control });
25
+ const signature = JSON.stringify(values ?? null);
26
+ React.useEffect(() => {
27
+ if (!isSubmitted) return;
28
+ void trigger(name);
29
+ }, [signature, isSubmitted, name, trigger]);
30
+ return null;
31
+ }
8
32
  function FormFieldControl({
9
33
  name,
34
+ id,
35
+ field: fieldKey,
36
+ labelAddon,
37
+ layout,
38
+ labelWidth,
39
+ controlWidth,
40
+ colSpan,
10
41
  label,
11
42
  required,
12
43
  helper,
44
+ disabled,
45
+ dependencies,
46
+ getValueFromEvent,
47
+ normalize,
48
+ help,
49
+ validateStatus,
50
+ hasFeedback,
51
+ feedback,
52
+ preserve,
13
53
  className,
14
54
  children
15
55
  }) {
56
+ const autoId = React.useId();
57
+ const resolvedId = id ?? `${autoId}-${String(name)}`;
58
+ const presentation = { field: fieldKey, labelAddon, layout, labelWidth, controlWidth, colSpan };
16
59
  const adapter = useFormAdapter();
17
60
  const rhf = useFormContext();
61
+ const formDisabled = useFormDisabled();
62
+ const isDisabled = disabled ?? formDisabled;
63
+ const disabledProp = isDisabled ? { disabled: true } : disabled === false ? { disabled: false } : void 0;
64
+ const readValue = (args, previousValue) => {
65
+ const raw = getValueFromEvent ? getValueFromEvent(...args) : extractControlValue(args[0]);
66
+ return normalize ? normalize(raw, previousValue) : raw;
67
+ };
18
68
  if (adapter) {
19
69
  const fieldName = String(name);
20
70
  return /* @__PURE__ */ jsx(
21
71
  FormField,
22
72
  {
23
- id: fieldName,
73
+ ...presentation,
74
+ id: resolvedId,
24
75
  name: fieldName,
25
76
  label,
26
77
  required,
27
78
  helper,
28
- error: adapter.getError(fieldName),
79
+ error: help ?? adapter.getError(fieldName),
80
+ validateStatus,
81
+ hasFeedback,
82
+ feedback,
29
83
  className,
30
- children: children({
31
- id: fieldName,
32
- name: fieldName,
33
- value: adapter.getValue(fieldName),
34
- onChange: (...args) => adapter.setValue(fieldName, extractControlValue(args[0])),
35
- onBlur: () => adapter.onBlur?.(fieldName),
36
- ref: noopRef
37
- })
84
+ children: children(
85
+ bindField({
86
+ id: resolvedId,
87
+ name: fieldName,
88
+ value: adapter.getValue(fieldName),
89
+ onChange: (...args) => adapter.setValue(fieldName, readValue(args, adapter.getValue(fieldName))),
90
+ onBlur: () => adapter.onBlur?.(fieldName),
91
+ ref: noopRef,
92
+ ...disabledProp
93
+ })
94
+ )
38
95
  }
39
96
  );
40
97
  }
41
- return /* @__PURE__ */ jsx(
42
- Controller,
43
- {
44
- name,
45
- control: rhf.control,
46
- render: ({ field, fieldState }) => /* @__PURE__ */ jsx(
47
- FormField,
48
- {
49
- id: String(name),
50
- name: String(name),
51
- label,
52
- required,
53
- helper,
54
- error: fieldState.error?.message,
55
- className,
56
- children: children({
57
- id: String(name),
58
- name: field.name,
59
- value: field.value,
60
- onChange: field.onChange,
61
- onBlur: field.onBlur,
62
- ref: field.ref
63
- })
64
- }
65
- )
66
- }
67
- );
98
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
99
+ dependencies?.length ? /* @__PURE__ */ jsx(
100
+ FieldDependencies,
101
+ {
102
+ control: rhf.control,
103
+ name,
104
+ dependencies,
105
+ trigger: rhf.trigger
106
+ }
107
+ ) : null,
108
+ /* @__PURE__ */ jsx(
109
+ Controller,
110
+ {
111
+ name,
112
+ control: rhf.control,
113
+ shouldUnregister: preserve === false,
114
+ render: ({ field, fieldState }) => /* @__PURE__ */ jsx(
115
+ FormField,
116
+ {
117
+ ...presentation,
118
+ id: resolvedId,
119
+ name: String(name),
120
+ label,
121
+ required,
122
+ helper,
123
+ error: help ?? fieldState.error?.message,
124
+ validateStatus,
125
+ hasFeedback,
126
+ feedback,
127
+ className,
128
+ children: children(
129
+ bindField({
130
+ id: resolvedId,
131
+ name: field.name,
132
+ value: field.value,
133
+ onChange: (...args) => field.onChange(readValue(args, field.value)),
134
+ onBlur: field.onBlur,
135
+ ref: field.ref,
136
+ ...disabledProp
137
+ })
138
+ )
139
+ }
140
+ )
141
+ }
142
+ )
143
+ ] });
68
144
  }
69
145
  export {
70
146
  FormFieldControl
@@ -1,3 +1,4 @@
1
+ import * as React from "react";
1
2
  import { type FieldValues } from "react-hook-form";
2
3
  import type { FormRootProp } from "../props/components/form.prop.js";
3
4
  export type { FormRootProp } from "../props/components/form.prop.js";
@@ -6,4 +7,4 @@ export type { FormRootProp } from "../props/components/form.prop.js";
6
7
  * validation) OR `adapter` (a framework-agnostic {@link FormStateAdapter} for a server-driven form
7
8
  * library — Inertia's `useForm` via `@godxjp/ui/inertia`, formik, TanStack Form).
8
9
  */
9
- export declare function FormRoot<TFieldValues extends FieldValues>({ form, adapter, onSubmit, children, className, id, }: FormRootProp<TFieldValues>): import("react").JSX.Element;
10
+ export declare function FormRoot<TFieldValues extends FieldValues>({ form, adapter, onSubmit, onSubmitFailed, onSubmitError, onReset, scrollToFirstError, disabled, layout, labelWidth, controlWidth, labelAlign, collapseBelow, density, columns, requiredMark, errors, children, className, id, }: FormRootProp<TFieldValues>): React.JSX.Element;