@techsio/ui-kit 0.56.1 → 0.58.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 (346) hide show
  1. package/README.md +128 -133
  2. package/dist/atoms/action-icon.js +9 -8
  3. package/dist/atoms/button.js +78 -18
  4. package/dist/atoms/checkbox.js +77 -17
  5. package/dist/atoms/hotkeys.js +26 -7
  6. package/dist/atoms/icon.js +5 -5
  7. package/dist/atoms/image.js +107 -2
  8. package/dist/atoms/input.js +57 -9
  9. package/dist/atoms/label.js +13 -4
  10. package/dist/atoms/link-button.js +14 -12
  11. package/dist/atoms/link.js +18 -4
  12. package/dist/atoms/numeric-input.js +293 -76
  13. package/dist/atoms/rating.js +306 -73
  14. package/dist/atoms/skeleton.js +18 -14
  15. package/dist/atoms/status-text.js +31 -18
  16. package/dist/atoms/textarea.js +59 -12
  17. package/dist/atoms/tooltip.js +64 -43
  18. package/dist/hotkeys.js +1 -0
  19. package/dist/internal/choice-control.js +173 -0
  20. package/dist/internal/combobox-query-sync.js +11 -0
  21. package/dist/internal/date-picker-coordinator.js +56 -40
  22. package/dist/internal/date-picker-dom.js +44 -0
  23. package/dist/internal/date-picker-input.js +30 -0
  24. package/dist/internal/described-by.js +23 -18
  25. package/dist/internal/form-control-lifecycle.js +122 -0
  26. package/dist/internal/molecules/command.context.js +1 -0
  27. package/dist/internal/molecules/drawer.context.js +1 -0
  28. package/dist/internal/molecules/vertical-navigation.context.js +1 -0
  29. package/dist/internal/molecules/vertical-navigation.styles.js +9 -2
  30. package/dist/internal/numeric-input-editing.js +87 -0
  31. package/dist/internal/organisms/sidebar.context.js +1 -0
  32. package/dist/internal/organisms/sidebar.focus.js +1 -0
  33. package/dist/internal/overlay-portal.js +72 -0
  34. package/dist/internal/reduced-motion.js +1 -0
  35. package/dist/internal/use-effective-disabled.js +8 -0
  36. package/dist/molecules/accordion.js +44 -30
  37. package/dist/molecules/availability-status.js +1 -0
  38. package/dist/molecules/breadcrumb.js +11 -11
  39. package/dist/molecules/carousel.js +279 -97
  40. package/dist/molecules/cascade-select.js +327 -81
  41. package/dist/molecules/chart.js +276 -38
  42. package/dist/molecules/color-select.js +181 -62
  43. package/dist/molecules/combobox.js +535 -182
  44. package/dist/molecules/command.js +2 -1
  45. package/dist/molecules/date-picker.js +571 -119
  46. package/dist/molecules/dialog.js +81 -47
  47. package/dist/molecules/drawer.js +54 -5
  48. package/dist/molecules/file-upload.js +373 -37
  49. package/dist/molecules/form-checkbox.js +65 -22
  50. package/dist/molecules/form-error-summary.js +29 -5
  51. package/dist/molecules/form-input.js +26 -30
  52. package/dist/molecules/form-numeric-input.js +11 -9
  53. package/dist/molecules/form-textarea.js +26 -23
  54. package/dist/molecules/menu.js +170 -47
  55. package/dist/molecules/pagination.js +100 -28
  56. package/dist/molecules/phone-input.js +172 -37
  57. package/dist/molecules/popover.js +53 -26
  58. package/dist/molecules/price-block.js +1 -0
  59. package/dist/molecules/product-card.js +23 -18
  60. package/dist/molecules/quantity-field.js +4 -2
  61. package/dist/molecules/radio-card.js +102 -30
  62. package/dist/molecules/radio-group.js +108 -31
  63. package/dist/molecules/search-form.js +116 -13
  64. package/dist/molecules/select.js +226 -81
  65. package/dist/molecules/slider.js +141 -30
  66. package/dist/molecules/steps.js +181 -50
  67. package/dist/molecules/switch.js +85 -20
  68. package/dist/molecules/tabs.js +227 -31
  69. package/dist/molecules/toast.js +146 -51
  70. package/dist/molecules/totals-summary.js +2 -1
  71. package/dist/molecules/tour.js +9 -5
  72. package/dist/molecules/tree-view.js +255 -109
  73. package/dist/molecules/vertical-navigation.js +8 -4
  74. package/dist/organisms/data-table.fields.js +25 -5
  75. package/dist/organisms/data-table.helpers.js +6 -2
  76. package/dist/organisms/data-table.js +580 -151
  77. package/dist/organisms/footer.js +18 -11
  78. package/dist/organisms/gallery.js +61 -24
  79. package/dist/organisms/header.js +106 -32
  80. package/dist/organisms/line-item.js +1 -0
  81. package/dist/organisms/sidebar.js +1 -0
  82. package/dist/organisms/table.js +22 -7
  83. package/dist/src/atoms/action-icon.d.ts +10 -10
  84. package/dist/src/atoms/action-icon.d.ts.map +1 -1
  85. package/dist/src/atoms/badge.d.ts +3 -3
  86. package/dist/src/atoms/badge.d.ts.map +1 -1
  87. package/dist/src/atoms/button.d.ts +35 -24
  88. package/dist/src/atoms/button.d.ts.map +1 -1
  89. package/dist/src/atoms/checkbox.d.ts +6 -5
  90. package/dist/src/atoms/checkbox.d.ts.map +1 -1
  91. package/dist/src/atoms/hotkeys.d.ts +3 -2
  92. package/dist/src/atoms/hotkeys.d.ts.map +1 -1
  93. package/dist/src/atoms/icon.d.ts +18 -17
  94. package/dist/src/atoms/icon.d.ts.map +1 -1
  95. package/dist/src/atoms/image.d.ts +14 -6
  96. package/dist/src/atoms/image.d.ts.map +1 -1
  97. package/dist/src/atoms/input.d.ts +23 -14
  98. package/dist/src/atoms/input.d.ts.map +1 -1
  99. package/dist/src/atoms/label.d.ts +4 -4
  100. package/dist/src/atoms/label.d.ts.map +1 -1
  101. package/dist/src/atoms/link-button.d.ts +54 -31
  102. package/dist/src/atoms/link-button.d.ts.map +1 -1
  103. package/dist/src/atoms/link.d.ts +30 -9
  104. package/dist/src/atoms/link.d.ts.map +1 -1
  105. package/dist/src/atoms/numeric-input.d.ts +23 -19
  106. package/dist/src/atoms/numeric-input.d.ts.map +1 -1
  107. package/dist/src/atoms/rating.d.ts +54 -26
  108. package/dist/src/atoms/rating.d.ts.map +1 -1
  109. package/dist/src/atoms/skeleton.d.ts +9 -9
  110. package/dist/src/atoms/skeleton.d.ts.map +1 -1
  111. package/dist/src/atoms/status-text.d.ts +21 -13
  112. package/dist/src/atoms/status-text.d.ts.map +1 -1
  113. package/dist/src/atoms/textarea.d.ts +22 -20
  114. package/dist/src/atoms/textarea.d.ts.map +1 -1
  115. package/dist/src/atoms/tooltip.d.ts +5 -5
  116. package/dist/src/atoms/tooltip.d.ts.map +1 -1
  117. package/dist/src/hotkeys.d.ts +1 -1
  118. package/dist/src/hotkeys.d.ts.map +1 -1
  119. package/dist/src/internal/choice-control.d.ts +18 -0
  120. package/dist/src/internal/choice-control.d.ts.map +1 -0
  121. package/dist/src/internal/combobox-query-sync.d.ts +4 -0
  122. package/dist/src/internal/combobox-query-sync.d.ts.map +1 -0
  123. package/dist/src/internal/date-picker-coordinator.d.ts +7 -1
  124. package/dist/src/internal/date-picker-coordinator.d.ts.map +1 -1
  125. package/dist/src/internal/date-picker-dom.d.ts +10 -0
  126. package/dist/src/internal/date-picker-dom.d.ts.map +1 -0
  127. package/dist/src/internal/date-picker-input.d.ts +7 -0
  128. package/dist/src/internal/date-picker-input.d.ts.map +1 -0
  129. package/dist/src/internal/described-by.d.ts +7 -1
  130. package/dist/src/internal/described-by.d.ts.map +1 -1
  131. package/dist/src/internal/form-control-lifecycle.d.ts +22 -0
  132. package/dist/src/internal/form-control-lifecycle.d.ts.map +1 -0
  133. package/dist/src/internal/molecules/vertical-navigation.context.d.ts +1 -1
  134. package/dist/src/internal/molecules/vertical-navigation.context.d.ts.map +1 -1
  135. package/dist/src/internal/molecules/vertical-navigation.styles.d.ts +21 -0
  136. package/dist/src/internal/molecules/vertical-navigation.styles.d.ts.map +1 -1
  137. package/dist/src/internal/numeric-input-editing.d.ts +13 -0
  138. package/dist/src/internal/numeric-input-editing.d.ts.map +1 -0
  139. package/dist/src/internal/overlay-portal.d.ts +18 -0
  140. package/dist/src/internal/overlay-portal.d.ts.map +1 -0
  141. package/dist/src/internal/use-effective-disabled.d.ts +4 -0
  142. package/dist/src/internal/use-effective-disabled.d.ts.map +1 -0
  143. package/dist/src/molecules/accordion.d.ts +25 -19
  144. package/dist/src/molecules/accordion.d.ts.map +1 -1
  145. package/dist/src/molecules/availability-status.d.ts +4 -1
  146. package/dist/src/molecules/availability-status.d.ts.map +1 -1
  147. package/dist/src/molecules/breadcrumb.d.ts +2 -2
  148. package/dist/src/molecules/breadcrumb.d.ts.map +1 -1
  149. package/dist/src/molecules/carousel.d.ts +51 -52
  150. package/dist/src/molecules/carousel.d.ts.map +1 -1
  151. package/dist/src/molecules/cascade-select.d.ts +23 -8
  152. package/dist/src/molecules/cascade-select.d.ts.map +1 -1
  153. package/dist/src/molecules/chart.d.ts +7 -1
  154. package/dist/src/molecules/chart.d.ts.map +1 -1
  155. package/dist/src/molecules/color-select.d.ts +19 -3
  156. package/dist/src/molecules/color-select.d.ts.map +1 -1
  157. package/dist/src/molecules/combobox.d.ts +23 -5
  158. package/dist/src/molecules/combobox.d.ts.map +1 -1
  159. package/dist/src/molecules/command.d.ts +1 -1
  160. package/dist/src/molecules/date-picker.d.ts +7 -3
  161. package/dist/src/molecules/date-picker.d.ts.map +1 -1
  162. package/dist/src/molecules/dialog.d.ts +7 -3
  163. package/dist/src/molecules/dialog.d.ts.map +1 -1
  164. package/dist/src/molecules/drawer.d.ts +4 -4
  165. package/dist/src/molecules/drawer.d.ts.map +1 -1
  166. package/dist/src/molecules/file-upload.d.ts +11 -6
  167. package/dist/src/molecules/file-upload.d.ts.map +1 -1
  168. package/dist/src/molecules/form-checkbox.d.ts +7 -2
  169. package/dist/src/molecules/form-checkbox.d.ts.map +1 -1
  170. package/dist/src/molecules/form-error-summary.d.ts +4 -3
  171. package/dist/src/molecules/form-error-summary.d.ts.map +1 -1
  172. package/dist/src/molecules/form-input.d.ts +5 -6
  173. package/dist/src/molecules/form-input.d.ts.map +1 -1
  174. package/dist/src/molecules/form-numeric-input.d.ts +5 -5
  175. package/dist/src/molecules/form-numeric-input.d.ts.map +1 -1
  176. package/dist/src/molecules/form-textarea.d.ts +5 -6
  177. package/dist/src/molecules/form-textarea.d.ts.map +1 -1
  178. package/dist/src/molecules/menu.d.ts +17 -3
  179. package/dist/src/molecules/menu.d.ts.map +1 -1
  180. package/dist/src/molecules/pagination.d.ts +1 -1
  181. package/dist/src/molecules/pagination.d.ts.map +1 -1
  182. package/dist/src/molecules/phone-input.d.ts +4 -1
  183. package/dist/src/molecules/phone-input.d.ts.map +1 -1
  184. package/dist/src/molecules/popover.d.ts +7 -1
  185. package/dist/src/molecules/popover.d.ts.map +1 -1
  186. package/dist/src/molecules/price-block.d.ts +1 -1
  187. package/dist/src/molecules/price-block.d.ts.map +1 -1
  188. package/dist/src/molecules/product-card.d.ts +20 -25
  189. package/dist/src/molecules/product-card.d.ts.map +1 -1
  190. package/dist/src/molecules/quantity-field.d.ts +1 -1
  191. package/dist/src/molecules/quantity-field.d.ts.map +1 -1
  192. package/dist/src/molecules/radio-card.d.ts +10 -3
  193. package/dist/src/molecules/radio-card.d.ts.map +1 -1
  194. package/dist/src/molecules/radio-group.d.ts +15 -6
  195. package/dist/src/molecules/radio-group.d.ts.map +1 -1
  196. package/dist/src/molecules/search-form.d.ts +37 -12
  197. package/dist/src/molecules/search-form.d.ts.map +1 -1
  198. package/dist/src/molecules/select.d.ts +34 -29
  199. package/dist/src/molecules/select.d.ts.map +1 -1
  200. package/dist/src/molecules/slider.d.ts +23 -2
  201. package/dist/src/molecules/slider.d.ts.map +1 -1
  202. package/dist/src/molecules/steps.d.ts +30 -10
  203. package/dist/src/molecules/steps.d.ts.map +1 -1
  204. package/dist/src/molecules/switch.d.ts +54 -33
  205. package/dist/src/molecules/switch.d.ts.map +1 -1
  206. package/dist/src/molecules/tabs.d.ts +11 -11
  207. package/dist/src/molecules/tabs.d.ts.map +1 -1
  208. package/dist/src/molecules/toast.d.ts +25 -13
  209. package/dist/src/molecules/toast.d.ts.map +1 -1
  210. package/dist/src/molecules/totals-summary.d.ts +1 -1
  211. package/dist/src/molecules/totals-summary.d.ts.map +1 -1
  212. package/dist/src/molecules/tour.d.ts +1 -1
  213. package/dist/src/molecules/tour.d.ts.map +1 -1
  214. package/dist/src/molecules/tree-view.d.ts +16 -20
  215. package/dist/src/molecules/tree-view.d.ts.map +1 -1
  216. package/dist/src/molecules/vertical-navigation.d.ts +2 -2
  217. package/dist/src/molecules/vertical-navigation.d.ts.map +1 -1
  218. package/dist/src/organisms/data-table.d.ts +24 -3
  219. package/dist/src/organisms/data-table.d.ts.map +1 -1
  220. package/dist/src/organisms/data-table.fields.d.ts +4 -1
  221. package/dist/src/organisms/data-table.fields.d.ts.map +1 -1
  222. package/dist/src/organisms/data-table.helpers.d.ts +5 -12
  223. package/dist/src/organisms/data-table.helpers.d.ts.map +1 -1
  224. package/dist/src/organisms/footer.d.ts +5 -5
  225. package/dist/src/organisms/footer.d.ts.map +1 -1
  226. package/dist/src/organisms/gallery.d.ts +11 -9
  227. package/dist/src/organisms/gallery.d.ts.map +1 -1
  228. package/dist/src/organisms/header.d.ts +24 -22
  229. package/dist/src/organisms/header.d.ts.map +1 -1
  230. package/dist/src/organisms/table.d.ts +14 -14
  231. package/dist/src/organisms/table.d.ts.map +1 -1
  232. package/dist/src/templates/accordion.d.ts +8 -6
  233. package/dist/src/templates/accordion.d.ts.map +1 -1
  234. package/dist/src/templates/breadcrumb.d.ts +1 -1
  235. package/dist/src/templates/breadcrumb.d.ts.map +1 -1
  236. package/dist/src/templates/carousel.d.ts +3 -3
  237. package/dist/src/templates/carousel.d.ts.map +1 -1
  238. package/dist/src/templates/facet-filter-panel.d.ts +9 -3
  239. package/dist/src/templates/facet-filter-panel.d.ts.map +1 -1
  240. package/dist/src/templates/gallery.d.ts +2 -2
  241. package/dist/src/templates/gallery.d.ts.map +1 -1
  242. package/dist/src/templates/numeric-input.d.ts +1 -1
  243. package/dist/src/templates/numeric-input.d.ts.map +1 -1
  244. package/dist/src/templates/popover.d.ts +4 -2
  245. package/dist/src/templates/popover.d.ts.map +1 -1
  246. package/dist/src/templates/product-card.d.ts +12 -4
  247. package/dist/src/templates/product-card.d.ts.map +1 -1
  248. package/dist/src/templates/search-suggestions.d.ts +1 -1
  249. package/dist/src/templates/select.d.ts +7 -2
  250. package/dist/src/templates/select.d.ts.map +1 -1
  251. package/dist/src/templates/tabs.d.ts +8 -7
  252. package/dist/src/templates/tabs.d.ts.map +1 -1
  253. package/dist/src/theme/theme-config.d.ts +9 -16
  254. package/dist/src/theme/theme-config.d.ts.map +1 -1
  255. package/dist/src/theme/theme-provider.d.ts +16 -21
  256. package/dist/src/theme/theme-provider.d.ts.map +1 -1
  257. package/dist/src/theme/theme-toggle.d.ts.map +1 -1
  258. package/dist/src/utils.d.ts.map +1 -1
  259. package/dist/templates/accordion.js +3 -1
  260. package/dist/templates/breadcrumb.js +11 -4
  261. package/dist/templates/carousel.js +3 -6
  262. package/dist/templates/facet-filter-panel.js +121 -52
  263. package/dist/templates/gallery.js +6 -2
  264. package/dist/templates/numeric-input.js +6 -1
  265. package/dist/templates/popover.js +6 -1
  266. package/dist/templates/product-card.js +52 -26
  267. package/dist/templates/select.js +6 -1
  268. package/dist/templates/tabs.js +4 -2
  269. package/dist/theme/theme-config.js +8 -16
  270. package/dist/theme/theme-provider.js +89 -63
  271. package/dist/theme/theme-toggle.js +17 -9
  272. package/dist/utils.js +11 -1
  273. package/package.json +9 -5
  274. package/src/tokens/_base.css +4 -3
  275. package/src/tokens/_business-atoms.css +103 -0
  276. package/src/tokens/_foundation-overrides.css +251 -0
  277. package/src/tokens/_reset.css +10 -10
  278. package/src/tokens/_scheme-scopes.css +4144 -0
  279. package/src/tokens/_semantic.css +1 -23
  280. package/src/tokens/_tokens-base.css +36 -32
  281. package/src/tokens/_typography.css +2 -1
  282. package/src/tokens/components/_form-control.css +149 -6
  283. package/src/tokens/components/_popup-surface.css +15 -29
  284. package/src/tokens/components/atoms/_action-icon.css +49 -0
  285. package/src/tokens/components/atoms/_button.css +67 -0
  286. package/src/tokens/components/atoms/_checkbox.css +47 -4
  287. package/src/tokens/components/atoms/_hotkeys.css +2 -0
  288. package/src/tokens/components/atoms/_icon.css +60 -7
  289. package/src/tokens/components/atoms/_image.css +18 -0
  290. package/src/tokens/components/atoms/_input.css +20 -0
  291. package/src/tokens/components/atoms/_label.css +3 -7
  292. package/src/tokens/components/atoms/_link.css +47 -5
  293. package/src/tokens/components/atoms/_numeric-input.css +111 -2
  294. package/src/tokens/components/atoms/_rating.css +55 -6
  295. package/src/tokens/components/atoms/_skeleton.css +12 -2
  296. package/src/tokens/components/atoms/_status-text.css +35 -5
  297. package/src/tokens/components/atoms/_textarea.css +32 -3
  298. package/src/tokens/components/atoms/_tooltip.css +25 -0
  299. package/src/tokens/components/molecules/_accordion.css +46 -5
  300. package/src/tokens/components/molecules/_breadcrumb.css +15 -4
  301. package/src/tokens/components/molecules/_carousel.css +67 -0
  302. package/src/tokens/components/molecules/_cascade-select.css +104 -0
  303. package/src/tokens/components/molecules/_chart.css +12 -14
  304. package/src/tokens/components/molecules/_color-select.css +21 -0
  305. package/src/tokens/components/molecules/_combobox.css +81 -0
  306. package/src/tokens/components/molecules/_command.css +1 -0
  307. package/src/tokens/components/molecules/_date-picker.css +66 -10
  308. package/src/tokens/components/molecules/_dialog.css +36 -4
  309. package/src/tokens/components/molecules/_drawer.css +39 -3
  310. package/src/tokens/components/molecules/_file-upload.css +16 -1
  311. package/src/tokens/components/molecules/_menu.css +17 -0
  312. package/src/tokens/components/molecules/_pagination.css +19 -0
  313. package/src/tokens/components/molecules/_phone-input.css +20 -5
  314. package/src/tokens/components/molecules/_popover.css +34 -0
  315. package/src/tokens/components/molecules/_product-card.css +49 -0
  316. package/src/tokens/components/molecules/_radio-card.css +35 -0
  317. package/src/tokens/components/molecules/_radio-group.css +8 -0
  318. package/src/tokens/components/molecules/_select.css +33 -0
  319. package/src/tokens/components/molecules/_slider.css +5 -0
  320. package/src/tokens/components/molecules/_steps.css +52 -0
  321. package/src/tokens/components/molecules/_switch.css +59 -10
  322. package/src/tokens/components/molecules/_tabs.css +61 -3
  323. package/src/tokens/components/molecules/_toast.css +60 -0
  324. package/src/tokens/components/molecules/_totals-summary.css +22 -22
  325. package/src/tokens/components/molecules/_tour.css +16 -1
  326. package/src/tokens/components/molecules/_tree-view.css +27 -3
  327. package/src/tokens/components/molecules/_vertical-navigation.css +21 -3
  328. package/src/tokens/components/organisms/_data-table.css +97 -0
  329. package/src/tokens/components/organisms/_footer.css +9 -0
  330. package/src/tokens/components/organisms/_gallery.css +11 -0
  331. package/src/tokens/components/organisms/_header.css +22 -0
  332. package/src/tokens/components/organisms/_sidebar.css +1 -1
  333. package/src/tokens/components/organisms/_table.css +31 -0
  334. package/src/tokens/components/templates/_facet-filter-panel.css +11 -1
  335. package/src/tokens/figma/akros/variables.css +6 -6
  336. package/src/tokens/figma/brand-overrides.css +162 -57
  337. package/src/tokens/figma/business/variables.css +6 -6
  338. package/src/tokens/figma/cyber/variables.css +115 -38
  339. package/src/tokens/figma/cyber-dark/variables.css +115 -38
  340. package/src/tokens/figma/dark/variables.css +4 -4
  341. package/src/tokens/figma/light/variables.css +43 -40
  342. package/src/tokens/figma/{neo → n1}/variables.css +114 -114
  343. package/src/tokens/figma/variables.css +639 -240
  344. package/src/tokens/theme.css +24 -4
  345. package/src/tokens/_colors.css +0 -5
  346. package/src/tokens/figma/neo-dark/variables.css +0 -457
@@ -1,8 +1,11 @@
1
+ "use client";
1
2
  import { jsx } from "react/jsx-runtime";
3
+ import { useId, useLayoutEffect, useMemo, useRef } from "react";
4
+ import { subscribeOwnerFormReset, syncReactFormControl } from "../internal/form-control-lifecycle.js";
2
5
  import { tv } from "../utils.js";
3
6
  const textareaVariants = tv({
4
7
  base: [
5
- "block w-full",
8
+ "form-control-readonly textarea-readonly form-control-disabled block w-full",
6
9
  "font-normal",
7
10
  "bg-textarea-bg",
8
11
  "text-textarea-fg",
@@ -16,7 +19,8 @@ const textareaVariants = tv({
16
19
  "focus-visible:outline-(style:--default-ring-style) focus-visible:outline-(length:--default-ring-width)",
17
20
  "focus-visible:outline-textarea-ring",
18
21
  "focus-visible:outline-offset-(length:--default-ring-offset)",
19
- "disabled:pointer-events-none disabled:border-textarea-border-disabled disabled:bg-textarea-bg-disabled disabled:text-textarea-fg-disabled",
22
+ "disabled:cursor-not-allowed disabled:border-textarea-border-disabled disabled:bg-textarea-bg-disabled disabled:text-textarea-fg-disabled",
23
+ "disabled:resize-none",
20
24
  "user-invalid:border-(length:--border-width-validation)",
21
25
  "user-invalid:border-textarea-border-danger-base",
22
26
  "user-invalid:hover:border-textarea-border-danger-hover",
@@ -52,9 +56,9 @@ const textareaVariants = tv({
52
56
  ]
53
57
  },
54
58
  size: {
55
- sm: "rounded-textarea-sm p-textarea-sm text-textarea-sm",
56
- md: "rounded-textarea-md p-textarea-md text-textarea-md",
57
- lg: "p-textarea-lg text-textarea-lg"
59
+ sm: "rounded-textarea-sm p-textarea-sm px-textarea-inline-sm text-textarea-sm",
60
+ md: "rounded-textarea-md p-textarea-md px-textarea-inline-md text-textarea-md",
61
+ lg: "rounded-(--radius-textarea-surface-lg) p-textarea-lg px-textarea-inline-lg text-textarea-lg"
58
62
  },
59
63
  resize: {
60
64
  none: "resize-none",
@@ -63,28 +67,71 @@ const textareaVariants = tv({
63
67
  both: "resize",
64
68
  auto: "field-sizing-content resize-none"
65
69
  },
66
- readonly: {
67
- true: "cursor-default border-textarea-border-disabled bg-textarea-bg-disabled"
70
+ readOnly: {
71
+ true: ""
68
72
  }
69
73
  },
74
+ compoundVariants: [
75
+ {
76
+ variant: "default",
77
+ readOnly: true,
78
+ class: [
79
+ "hover:border-textarea-border-readonly-hover",
80
+ "focus:border-textarea-border-readonly-focus"
81
+ ]
82
+ }
83
+ ],
70
84
  defaultVariants: {
71
85
  size: "md",
72
86
  resize: "y",
73
87
  variant: "default"
74
88
  }
89
+ }, {
90
+ twMergeConfig: {
91
+ theme: {
92
+ radius: [
93
+ "textarea",
94
+ "textarea-sm",
95
+ "textarea-md"
96
+ ]
97
+ }
98
+ }
75
99
  });
76
- function Textarea({ size, resize, variant, readonly, className, ref, ...props }) {
100
+ function Textarea({ size, resize, variant, readonly, readOnly = readonly, id, className, ref, ...props }) {
101
+ const generatedId = useId();
102
+ const currentValue = useRef(props.value);
103
+ useLayoutEffect(()=>{
104
+ currentValue.current = props.value;
105
+ });
106
+ const textareaRef = useMemo(()=>(textarea)=>{
107
+ const stopReset = textarea ? subscribeOwnerFormReset(textarea, ()=>{
108
+ syncReactFormControl(textarea, null == currentValue.current ? textarea.value : String(currentValue.current));
109
+ }) : void 0;
110
+ const cleanup = "function" == typeof ref ? ref(textarea) : void 0;
111
+ if (ref && "function" != typeof ref) ref.current = textarea;
112
+ return ()=>{
113
+ stopReset?.();
114
+ if ("function" == typeof cleanup) cleanup();
115
+ else if ("function" == typeof ref) ref(null);
116
+ else if (ref) ref.current = null;
117
+ };
118
+ }, [
119
+ ref
120
+ ]);
77
121
  return /*#__PURE__*/ jsx("textarea", {
78
122
  className: textareaVariants({
79
123
  size,
80
124
  resize,
81
125
  variant,
82
- readonly,
126
+ readOnly: Boolean(readOnly),
83
127
  className
84
128
  }),
85
- readOnly: readonly,
86
- ref: ref,
87
- ...props
129
+ "data-readonly": readOnly ? "" : void 0,
130
+ id: id || generatedId,
131
+ readOnly: readOnly,
132
+ ref: textareaRef,
133
+ ...props,
134
+ "aria-invalid": "error" === variant ? true : props["aria-invalid"]
88
135
  });
89
136
  }
90
137
  Textarea.displayName = "Textarea";
@@ -1,21 +1,27 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { Portal, normalizeProps, useMachine } from "@zag-js/react";
3
- import { Children, Fragment as external_react_Fragment, cloneElement, isValidElement, useId } from "react";
4
- import { tv } from "tailwind-variants";
5
- import * as __rspack_external__zag_js_tooltip_cb65b1a2 from "@zag-js/tooltip";
3
+ import { normalizeProps, useMachine } from "@zag-js/react";
4
+ import { connect, machine, splitProps } from "@zag-js/tooltip";
5
+ import { Children, Fragment as external_react_Fragment, cloneElement, isValidElement, useEffect, useId } from "react";
6
+ import { joinDescribedBy } from "../internal/described-by.js";
7
+ import { OverlayPortal } from "../internal/overlay-portal.js";
8
+ import { tv } from "../utils.js";
6
9
  const tooltipVariants = tv({
7
10
  slots: {
8
11
  trigger: [
9
12
  "inline-flex"
10
13
  ],
11
14
  content: [
12
- "[--arrow-size:var(--tooltip-arrow-size)]",
13
- "[--arrow-background:var(--tooltip-arrow-background)]",
15
+ "tooltip-surface",
16
+ "popup-layer",
17
+ "text-tooltip-fg",
18
+ "shadow-tooltip-surface",
14
19
  "bg-tooltip-bg",
15
20
  "rounded-tooltip"
16
21
  ],
17
22
  positioner: [
18
- "relative"
23
+ "relative",
24
+ "popup-layer"
19
25
  ],
20
26
  arrow: ""
21
27
  },
@@ -48,50 +54,61 @@ function describeTooltipChildren(children, describedBy) {
48
54
  return Children.map(children, (child)=>{
49
55
  if (!/*#__PURE__*/ isValidElement(child)) return child;
50
56
  if (child.type === external_react_Fragment) return /*#__PURE__*/ cloneElement(child, {}, describeTooltipChildren(child.props.children, describedBy));
51
- const ids = [
52
- child.props["aria-describedby"],
53
- describedBy
54
- ].flatMap((value)=>value?.split(/\s+/).filter(Boolean) ?? []);
55
57
  const props = {
56
- "aria-describedby": [
57
- ...new Set(ids)
58
- ].join(" ") || void 0
58
+ "aria-describedby": joinDescribedBy(child.props["aria-describedby"], describedBy)
59
59
  };
60
60
  return "string" == typeof child.type && void 0 !== child.props.children ? /*#__PURE__*/ cloneElement(child, props, describeTooltipChildren(child.props.children, describedBy)) : /*#__PURE__*/ cloneElement(child, props);
61
61
  });
62
62
  }
63
- function Tooltip({ content, children, className, ref, size, variant, id: MRAId, dir = "ltr", openDelay = 200, closeDelay = 200, interactive = true, defaultOpen, open, onOpenChange, disabled, closeOnEscape = true, closeOnPointerDown, closeOnScroll, closeOnClick, placement, offset = {
64
- mainAxis: 16,
65
- crossAxis: 0
66
- }, gutter, flip, sameWidth, boundary, listeners, strategy }) {
63
+ function Tooltip({ content, children, className, ref, size, variant, ...props }) {
67
64
  const generatedId = useId();
68
- const id = MRAId || generatedId;
69
- const service = useMachine(__rspack_external__zag_js_tooltip_cb65b1a2.machine, {
70
- id,
71
- dir,
72
- open,
73
- defaultOpen,
74
- disabled,
75
- openDelay,
76
- closeDelay,
77
- interactive,
78
- closeOnPointerDown,
79
- closeOnEscape,
80
- closeOnScroll,
81
- closeOnClick,
82
- onOpenChange,
65
+ const [machineProps, positioningProps] = splitProps(props);
66
+ const service = useMachine(machine, {
67
+ openDelay: 200,
68
+ closeDelay: 200,
69
+ interactive: true,
70
+ ...machineProps,
71
+ id: machineProps.id ?? generatedId,
72
+ closeOnEscape: false,
83
73
  positioning: {
84
- placement,
85
- offset,
86
- gutter,
87
- flip,
88
- sameWidth,
89
- boundary,
90
- listeners,
91
- strategy
74
+ offset: {
75
+ mainAxis: 16,
76
+ crossAxis: 0
77
+ },
78
+ ...positioningProps,
79
+ ...machineProps.positioning
92
80
  }
93
81
  });
94
- const api = __rspack_external__zag_js_tooltip_cb65b1a2.connect(service, normalizeProps);
82
+ const api = connect(service, normalizeProps);
83
+ useEffect(()=>{
84
+ if (!api.open || false === machineProps.closeOnEscape) return;
85
+ const root = machineProps.getRootNode?.() ?? document;
86
+ const doc = 9 === root.nodeType ? root : root.ownerDocument;
87
+ const lookupRoot = 11 === root.nodeType ? root : doc;
88
+ const eventTarget = doc?.defaultView ?? root;
89
+ const onEscape = (event)=>{
90
+ if ("Escape" !== event.key || event.isComposing || event.defaultPrevented) return;
91
+ const triggerProps = api.getTriggerProps();
92
+ const contentId = triggerProps["aria-describedby"];
93
+ const contentElement = contentId ? lookupRoot?.getElementById(contentId) : null;
94
+ if (contentElement?.closest('[aria-hidden="true"], [inert]')) return;
95
+ const triggerElement = triggerProps.id ? lookupRoot?.getElementById(triggerProps.id) : null;
96
+ const focusedElement = event.composedPath().find((node)=>node instanceof (doc?.defaultView?.HTMLElement ?? HTMLElement));
97
+ const focusedLayer = focusedElement?.closest('[data-scope][data-part="content"][style*="--layer-index"]');
98
+ if (focusedLayer && !focusedLayer.contains(triggerElement ?? null) && !focusedLayer.contains(contentElement ?? null)) return;
99
+ event.preventDefault();
100
+ event.stopImmediatePropagation();
101
+ api.setOpen(false);
102
+ };
103
+ eventTarget.addEventListener("keydown", onEscape, true);
104
+ return ()=>eventTarget.removeEventListener("keydown", onEscape, true);
105
+ }, [
106
+ api.open,
107
+ api.setOpen,
108
+ api.getTriggerProps,
109
+ machineProps.closeOnEscape,
110
+ machineProps.getRootNode
111
+ ]);
95
112
  const triggerProps = api.getTriggerProps();
96
113
  const { trigger, positioner, content: contentSlot, arrow } = tooltipVariants({
97
114
  variant,
@@ -105,15 +122,19 @@ function Tooltip({ content, children, className, ref, size, variant, id: MRAId,
105
122
  ref: ref,
106
123
  children: describeTooltipChildren(children, triggerProps["aria-describedby"])
107
124
  }),
108
- /*#__PURE__*/ jsx(Portal, {
125
+ /*#__PURE__*/ jsx(OverlayPortal, {
126
+ getRootNode: machineProps.getRootNode,
109
127
  children: api.open && /*#__PURE__*/ jsx("div", {
110
128
  ...api.getPositionerProps(),
111
129
  className: positioner(),
112
130
  children: /*#__PURE__*/ jsxs("div", {
113
131
  ...api.getContentProps(),
132
+ "aria-label": machineProps["aria-label"],
114
133
  className: contentSlot({
115
134
  className
116
135
  }),
136
+ id: triggerProps["aria-describedby"],
137
+ role: "tooltip",
117
138
  children: [
118
139
  /*#__PURE__*/ jsx("div", {
119
140
  ...api.getArrowProps(),
package/dist/hotkeys.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { createHotkeyStore, formatHotkey } from "@zag-js/hotkeys";
2
3
  import { useEffect, useId, useLayoutEffect, useMemo, useRef, useSyncExternalStore } from "react";
3
4
  function useHotkey({ store, id, ...command }) {
@@ -0,0 +1,173 @@
1
+ "use client";
2
+ "use client";
3
+ import { useLayoutEffect, useMemo, useRef } from "react";
4
+ import { isEffectivelyDisabled, subscribeEffectiveDisabled, subscribeOwnerFormReset, syncReactFormControl } from "./form-control-lifecycle.js";
5
+ function getControlledChoiceInputProps(props, checked, indeterminate) {
6
+ const { defaultChecked: _defaultChecked, ...inputProps } = props;
7
+ return {
8
+ ...inputProps,
9
+ checked,
10
+ onChange (event) {
11
+ if (void 0 !== indeterminate) event.currentTarget.indeterminate = indeterminate;
12
+ props.onChange?.(event);
13
+ }
14
+ };
15
+ }
16
+ function useChoiceInputRef(ref, indeterminate) {
17
+ const inputRef = useRef(null);
18
+ const mixedRef = useRef(indeterminate);
19
+ useLayoutEffect(()=>{
20
+ mixedRef.current = indeterminate;
21
+ if (inputRef.current && void 0 !== indeterminate) inputRef.current.indeterminate = indeterminate;
22
+ }, [
23
+ indeterminate
24
+ ]);
25
+ return useMemo(()=>(node)=>{
26
+ inputRef.current = node;
27
+ if (node && void 0 !== mixedRef.current) node.indeterminate = mixedRef.current;
28
+ const cleanup = "function" == typeof ref ? ref(node) : void 0;
29
+ if (ref && "function" != typeof ref) ref.current = node;
30
+ return ()=>{
31
+ inputRef.current = null;
32
+ if ("function" == typeof cleanup) cleanup();
33
+ else if ("function" == typeof ref) ref(null);
34
+ else if (ref) ref.current = null;
35
+ };
36
+ }, [
37
+ ref
38
+ ]);
39
+ }
40
+ const eventHandlerPattern = /^on[A-Z]/;
41
+ function mergeChoiceInputProps(consumer, machine) {
42
+ const merged = {
43
+ ...machine,
44
+ ...consumer
45
+ };
46
+ for (const key of Object.keys(machine)){
47
+ if (!eventHandlerPattern.test(key)) continue;
48
+ const name = key;
49
+ const machineHandler = machine[name];
50
+ const consumerHandler = consumer[name];
51
+ if ("function" == typeof machineHandler && "ref" !== key) Object.assign(merged, {
52
+ [key]: (event)=>{
53
+ if ("function" == typeof consumerHandler) consumerHandler(event);
54
+ if (!event.defaultPrevented) machineHandler(event);
55
+ }
56
+ });
57
+ }
58
+ return merged;
59
+ }
60
+ function handleChoiceArrowKey(event) {
61
+ if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
62
+ const input = event.currentTarget;
63
+ const root = input.closest('[data-part="root"]');
64
+ if (!root) return;
65
+ const rtl = "rtl" === root.dir;
66
+ const direction = {
67
+ ArrowDown: 1,
68
+ ArrowUp: -1,
69
+ ArrowRight: rtl ? -1 : 1,
70
+ ArrowLeft: rtl ? 1 : -1
71
+ }[event.key];
72
+ if (!direction) return;
73
+ const inputs = Array.from(root.querySelectorAll('input[type="radio"]')).filter((node)=>!isEffectivelyDisabled(node));
74
+ const index = inputs.indexOf(input);
75
+ if (index < 0 || !inputs.length) return;
76
+ event.preventDefault();
77
+ const next = inputs[(index + direction + inputs.length) % inputs.length];
78
+ next?.focus();
79
+ next?.click();
80
+ }
81
+ const silentResets = new WeakSet();
82
+ function runSilentChoiceReset(context, update) {
83
+ const alreadyResetting = silentResets.has(context);
84
+ silentResets.add(context);
85
+ try {
86
+ update();
87
+ } finally{
88
+ if (!alreadyResetting) silentResets.delete(context);
89
+ }
90
+ }
91
+ function isSilentChoiceReset(context) {
92
+ return silentResets.has(context);
93
+ }
94
+ function trackChoiceFormControl(root, onReset, onDisabled) {
95
+ if (!root) return;
96
+ let input = null;
97
+ let stopReset = ()=>void 0;
98
+ const update = ()=>{
99
+ onDisabled(isEffectivelyDisabled(root));
100
+ const next = root.querySelector("input");
101
+ if (next !== input) {
102
+ stopReset();
103
+ input = next;
104
+ stopReset = input ? subscribeOwnerFormReset(input, ()=>{
105
+ onReset();
106
+ for (const nativeInput of root.querySelectorAll("input"))syncReactFormControl(nativeInput, "checkbox" === nativeInput.type || "radio" === nativeInput.type ? nativeInput.checked : nativeInput.value);
107
+ }) : ()=>void 0;
108
+ }
109
+ };
110
+ update();
111
+ const stopDisabled = subscribeEffectiveDisabled(root, update);
112
+ return ()=>{
113
+ stopDisabled();
114
+ stopReset();
115
+ };
116
+ }
117
+ function useChoiceFocusRecovery(selector = 'input[type="radio"]') {
118
+ const rootRef = useRef(null);
119
+ useLayoutEffect(()=>{
120
+ const root = rootRef.current;
121
+ if (!root) return;
122
+ const doc = root.ownerDocument;
123
+ let focused = null;
124
+ let previous = [];
125
+ const inputs = ()=>Array.from(root.querySelectorAll(selector));
126
+ const isEnabled = (input)=>!input.matches(":disabled, [aria-disabled=true], [data-disabled]:not([data-disabled=false])");
127
+ const recordFocus = ()=>{
128
+ const current = inputs();
129
+ focused = current.find((input)=>input === doc.activeElement) ?? null;
130
+ previous = current;
131
+ };
132
+ recordFocus();
133
+ doc.addEventListener("focusin", recordFocus);
134
+ const observer = new MutationObserver(()=>{
135
+ if (!focused) return;
136
+ if (focused.isConnected && isEnabled(focused)) {
137
+ previous = inputs();
138
+ return;
139
+ }
140
+ if (doc.activeElement !== doc.body && doc.activeElement !== focused) {
141
+ focused = null;
142
+ return;
143
+ }
144
+ const current = inputs();
145
+ const enabled = current.filter(isEnabled);
146
+ const index = previous.indexOf(focused);
147
+ const next = previous.slice(index + 1).find((input)=>enabled.includes(input)) ?? previous.slice(0, index).reverse().find((input)=>enabled.includes(input)) ?? enabled[Math.min(index, enabled.length - 1)];
148
+ focused = null;
149
+ const target = next ?? root;
150
+ target.focus({
151
+ preventScroll: true
152
+ });
153
+ });
154
+ observer.observe(root, {
155
+ childList: true,
156
+ subtree: true,
157
+ attributes: true,
158
+ attributeFilter: [
159
+ "disabled",
160
+ "aria-disabled",
161
+ "data-disabled"
162
+ ]
163
+ });
164
+ return ()=>{
165
+ doc.removeEventListener("focusin", recordFocus);
166
+ observer.disconnect();
167
+ };
168
+ }, [
169
+ selector
170
+ ]);
171
+ return rootRef;
172
+ }
173
+ export { getControlledChoiceInputProps, handleChoiceArrowKey, isSilentChoiceReset, mergeChoiceInputProps, runSilentChoiceReset, trackChoiceFormControl, useChoiceFocusRecovery, useChoiceInputRef };
@@ -0,0 +1,11 @@
1
+ function queueComboboxQuery(pending, edit, inputValue) {
2
+ return edit === inputValue ? [] : [
3
+ ...pending,
4
+ edit
5
+ ];
6
+ }
7
+ function acknowledgeComboboxQuery(pending, inputValue) {
8
+ const index = pending.lastIndexOf(inputValue);
9
+ return -1 === index ? null : pending.slice(index + 1);
10
+ }
11
+ export { acknowledgeComboboxQuery, queueComboboxQuery };
@@ -1,4 +1,4 @@
1
- import { Time, toCalendarDateTime } from "@internationalized/date";
1
+ import { Time, toCalendarDate, toCalendarDateTime } from "@internationalized/date";
2
2
  function createDatePickerCoordinatorState() {
3
3
  return {
4
4
  draft: null
@@ -18,42 +18,44 @@ function datePickerCoordinatorReducer(state, action) {
18
18
  timeParts: null === action.value ? void 0 : state.draft.timeParts
19
19
  }
20
20
  };
21
- if ("edit-time" === action.type && state.draft?.candidate) {
22
- const index = action.index ?? 0;
23
- const hourCycle = action.hourCycle ?? 24;
24
- const timeParts = {
25
- ...getDatePickerDraftTimeParts(state, hourCycle, index),
26
- [action.part]: action.value
27
- };
28
- const requiredParts = getRequiredTimeParts(action.granularity, hourCycle);
29
- const isComplete = requiredParts.every((part)=>"number" == typeof timeParts[part]);
30
- let candidate = state.draft.candidate;
31
- const endpoint = getCandidateAt(candidate, index);
32
- if (isComplete && endpoint) {
33
- const time = {
34
- hour: 12 === hourCycle ? (timeParts.hour ?? 12) % 12 + (timeParts.dayPeriod ?? 0) : timeParts.hour ?? 0,
35
- minute: timeParts.minute ?? 0,
36
- second: timeParts.second ?? 0
37
- };
38
- const timedEndpoint = isTimedDateValue(endpoint) ? endpoint.set(time) : toCalendarDateTime(endpoint, new Time(time.hour, time.minute, time.second));
39
- candidate = setCandidateAt(candidate, index, timedEndpoint);
40
- }
41
- return {
42
- draft: {
43
- ...state.draft,
44
- candidate,
45
- timeGranularity: action.granularity,
46
- timeHourCycle: hourCycle,
47
- timeParts: {
48
- ...state.draft.timeParts,
49
- [index]: timeParts
50
- }
51
- }
52
- };
53
- }
21
+ if ("edit-time" === action.type && state.draft?.candidate) return editDatePickerDraftTime(state, action);
54
22
  if ("discard" === action.type) return createDatePickerCoordinatorState();
55
23
  return state;
56
24
  }
25
+ function editDatePickerDraftTime(state, action) {
26
+ if (!state.draft?.candidate) return state;
27
+ const index = action.index ?? 0;
28
+ const hourCycle = action.hourCycle ?? 24;
29
+ const timeParts = {
30
+ ...getDatePickerDraftTimeParts(state, hourCycle, index),
31
+ [action.part]: action.value
32
+ };
33
+ const requiredParts = getRequiredTimeParts(action.granularity, hourCycle);
34
+ const isComplete = requiredParts.every((part)=>"number" == typeof timeParts[part]);
35
+ let candidate = state.draft.candidate;
36
+ const endpoint = getCandidateAt(candidate, index);
37
+ if (isComplete && endpoint) {
38
+ const time = {
39
+ hour: 12 === hourCycle ? (timeParts.hour ?? 12) % 12 + (timeParts.dayPeriod ?? 0) : timeParts.hour ?? 0,
40
+ minute: timeParts.minute ?? 0,
41
+ second: timeParts.second ?? 0
42
+ };
43
+ const timedEndpoint = isTimedDateValue(endpoint) ? endpoint.set(time) : toCalendarDateTime(endpoint, new Time(time.hour, time.minute, time.second));
44
+ candidate = setCandidateAt(candidate, index, timedEndpoint);
45
+ }
46
+ return {
47
+ draft: {
48
+ ...state.draft,
49
+ candidate,
50
+ timeGranularity: action.granularity,
51
+ timeHourCycle: hourCycle,
52
+ timeParts: {
53
+ ...state.draft.timeParts,
54
+ [index]: timeParts
55
+ }
56
+ }
57
+ };
58
+ }
57
59
  function getCandidateAt(candidate, index) {
58
60
  if (isCandidateArray(candidate)) return candidate[index];
59
61
  return 0 === index ? candidate : void 0;
@@ -84,10 +86,16 @@ function isDatePickerDraftDirty(state) {
84
86
  if (!state.draft) return false;
85
87
  return !dateValuesEqual(state.draft.baseline, state.draft.candidate) || areDraftTimePartsDirty(state.draft);
86
88
  }
87
- function canConfirmDatePickerDraft(state, isTimeUnavailable) {
89
+ function canConfirmDatePickerDraft(state, isTimeUnavailable, min, max, isDateUnavailable) {
88
90
  if (!isDatePickerDraftDirty(state)) return false;
89
91
  const candidate = state.draft?.candidate;
90
92
  if (null === candidate) return true;
93
+ if (!isDatePickerCandidateAllowed(candidate ?? null, {
94
+ min,
95
+ max,
96
+ isTimeUnavailable,
97
+ isDateUnavailable
98
+ })) return false;
91
99
  const values = candidateValues(candidate);
92
100
  if (isCandidateArray(candidate) && 2 !== values.length) return false;
93
101
  const [startValue, endValue] = values;
@@ -97,11 +105,11 @@ function canConfirmDatePickerDraft(state, isTimeUnavailable) {
97
105
  const firstTimedValue = timedValues[0];
98
106
  const secondTimedValue = timedValues[1];
99
107
  if (firstTimedValue && secondTimedValue && "timeZone" in firstTimedValue !== "timeZone" in secondTimedValue) return false;
100
- return timedValues.every((value, index)=>{
108
+ return timedValues.every((_value, index)=>{
101
109
  if (index > 1) return false;
102
110
  const candidateIndex = 0 === index ? 0 : 1;
103
111
  if (state.draft?.timeGranularity && !getRequiredTimeParts(state.draft.timeGranularity, state.draft.timeHourCycle).every((part)=>"number" == typeof getDatePickerDraftTimeParts(state, state.draft?.timeHourCycle, candidateIndex)[part])) return false;
104
- return !(isTimeUnavailable?.(value, candidateIndex) ?? false);
112
+ return true;
105
113
  });
106
114
  }
107
115
  function isTimedDateValue(value) {
@@ -110,7 +118,7 @@ function isTimedDateValue(value) {
110
118
  function getDatePickerDraftTimeParts(state, hourCycle = 24, index = 0) {
111
119
  const candidate = getCandidateAt(state.draft?.candidate, index);
112
120
  const candidateParts = isTimedDateValue(candidate) ? {
113
- dayPeriod: 12 === hourCycle ? candidate.hour >= 12 ? 12 : 0 : void 0,
121
+ dayPeriod: 12 === hourCycle ? 12 * Number(candidate.hour >= 12) : void 0,
114
122
  hour: 12 === hourCycle ? candidate.hour % 12 || 12 : candidate.hour,
115
123
  minute: candidate.minute,
116
124
  second: candidate.second
@@ -155,7 +163,7 @@ function areDraftTimePartsDirty(draft) {
155
163
  if (!timeParts) return false;
156
164
  const baseline = getCandidateAt(draft.baseline, index);
157
165
  const baselineParts = isTimedDateValue(baseline) ? {
158
- dayPeriod: 12 === draft.timeHourCycle ? baseline.hour >= 12 ? 12 : 0 : void 0,
166
+ dayPeriod: 12 === draft.timeHourCycle ? 12 * Number(baseline.hour >= 12) : void 0,
159
167
  hour: 12 === draft.timeHourCycle ? baseline.hour % 12 || 12 : baseline.hour,
160
168
  minute: baseline.minute,
161
169
  second: baseline.second
@@ -163,4 +171,12 @@ function areDraftTimePartsDirty(draft) {
163
171
  return parts.some((part)=>Object.hasOwn(timeParts, part) && baselineParts[part] !== timeParts[part]);
164
172
  });
165
173
  }
166
- export { canConfirmDatePickerDraft, createDatePickerCoordinatorState, datePickerCoordinatorReducer, getDatePickerDraftTimeParts, isDatePickerDraftDirty, isTimedDateValue };
174
+ function isDatePickerCandidateAllowed(candidate, constraints = {}) {
175
+ const values = candidateValues(candidate);
176
+ if (isCandidateArray(candidate) && (2 !== values.length || !values[0] || !values[1] || values[0].compare(values[1]) > 0)) return false;
177
+ return values.every((value, index)=>{
178
+ const compare = (bound)=>isTimedDateValue(bound) ? value.compare(bound) : toCalendarDate(value).compare(toCalendarDate(bound));
179
+ return !(constraints.min && compare(constraints.min) < 0 || constraints.max && compare(constraints.max) > 0 || constraints.isDateUnavailable?.(value) || isTimedDateValue(value) && constraints.isTimeUnavailable?.(value, 0 === index ? 0 : 1));
180
+ });
181
+ }
182
+ export { canConfirmDatePickerDraft, createDatePickerCoordinatorState, datePickerCoordinatorReducer, getDatePickerDraftTimeParts, isDatePickerCandidateAllowed, isDatePickerDraftDirty, isTimedDateValue };
@@ -0,0 +1,44 @@
1
+ import { DateFormatter, toCalendarDate, toTimeZone } from "@internationalized/date";
2
+ function composeDatePickerRefs(...refs) {
3
+ return (value)=>{
4
+ const cleanups = refs.map((ref)=>{
5
+ if ("function" == typeof ref) {
6
+ const cleanup = ref(value);
7
+ return "function" == typeof cleanup ? cleanup : ()=>ref(null);
8
+ }
9
+ if (ref) ref.current = value;
10
+ return ()=>{
11
+ if (ref) ref.current = null;
12
+ };
13
+ });
14
+ return ()=>{
15
+ for (const cleanup of cleanups)cleanup();
16
+ };
17
+ };
18
+ }
19
+ function normalizeDatePickerTimeZone(value, timeZone) {
20
+ return "timeZone" in value ? toTimeZone(value, timeZone) : value;
21
+ }
22
+ function getDatePickerCalendarDate(value, timeZone) {
23
+ return toCalendarDate(normalizeDatePickerTimeZone(value, timeZone));
24
+ }
25
+ function formatDatePickerCalendar(value, locale, timeZone, options) {
26
+ return new DateFormatter(locale, {
27
+ ...options,
28
+ calendar: value.calendar.identifier,
29
+ timeZone
30
+ }).format(value.toDate(timeZone));
31
+ }
32
+ function normalizeDatePickerDigits(text, locale) {
33
+ const formatter = new Intl.NumberFormat(locale, {
34
+ useGrouping: false
35
+ });
36
+ const digits = Array.from({
37
+ length: 10
38
+ }, (_, number)=>formatter.format(number));
39
+ return Array.from(text, (character)=>{
40
+ const index = digits.indexOf(character);
41
+ return index < 0 ? character : String(index);
42
+ }).join("");
43
+ }
44
+ export { composeDatePickerRefs, formatDatePickerCalendar, getDatePickerCalendarDate, normalizeDatePickerDigits, normalizeDatePickerTimeZone };