@senvenli/react 0.0.0-stage → 0.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 (636) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -2
  3. package/dist/action/button-group.d.ts +26 -0
  4. package/dist/action/button-group.js +12 -0
  5. package/dist/action/button-group.js.map +1 -0
  6. package/dist/action/button.d.ts +42 -0
  7. package/dist/action/button.js +58 -0
  8. package/dist/action/button.js.map +1 -0
  9. package/dist/action/close-button.d.ts +12 -0
  10. package/dist/action/close-button.js +13 -0
  11. package/dist/action/close-button.js.map +1 -0
  12. package/dist/action/copy-button.d.ts +21 -0
  13. package/dist/action/copy-button.js +38 -0
  14. package/dist/action/copy-button.js.map +1 -0
  15. package/dist/action/fab.d.ts +29 -0
  16. package/dist/action/fab.js +57 -0
  17. package/dist/action/fab.js.map +1 -0
  18. package/dist/action/files.d.ts +70 -0
  19. package/dist/action/files.js +156 -0
  20. package/dist/action/files.js.map +1 -0
  21. package/dist/action/index.d.ts +23 -0
  22. package/dist/action/index.js +16 -0
  23. package/dist/action/index.js.map +1 -0
  24. package/dist/action/language-names.d.ts +19 -0
  25. package/dist/action/language-names.js +79 -0
  26. package/dist/action/language-names.js.map +1 -0
  27. package/dist/action/language-switcher.d.ts +57 -0
  28. package/dist/action/language-switcher.js +53 -0
  29. package/dist/action/language-switcher.js.map +1 -0
  30. package/dist/action/link-button.d.ts +57 -0
  31. package/dist/action/link-button.js +48 -0
  32. package/dist/action/link-button.js.map +1 -0
  33. package/dist/action/link.d.ts +24 -0
  34. package/dist/action/link.js +18 -0
  35. package/dist/action/link.js.map +1 -0
  36. package/dist/action/pressable.d.ts +40 -0
  37. package/dist/action/pressable.js +65 -0
  38. package/dist/action/pressable.js.map +1 -0
  39. package/dist/action/styles.d.ts +60 -0
  40. package/dist/action/styles.js +109 -0
  41. package/dist/action/styles.js.map +1 -0
  42. package/dist/action/theme-script.d.ts +12 -0
  43. package/dist/action/theme-script.js +23 -0
  44. package/dist/action/theme-script.js.map +1 -0
  45. package/dist/action/theme-switcher.d.ts +43 -0
  46. package/dist/action/theme-switcher.js +260 -0
  47. package/dist/action/theme-switcher.js.map +1 -0
  48. package/dist/action/theme-toggle.d.ts +43 -0
  49. package/dist/action/theme-toggle.js +259 -0
  50. package/dist/action/theme-toggle.js.map +1 -0
  51. package/dist/action/toggle.d.ts +44 -0
  52. package/dist/action/toggle.js +28 -0
  53. package/dist/action/toggle.js.map +1 -0
  54. package/dist/action/touch-target.d.ts +9 -0
  55. package/dist/action/touch-target.js +14 -0
  56. package/dist/action/touch-target.js.map +1 -0
  57. package/dist/charts/axis-width.d.ts +186 -0
  58. package/dist/charts/axis-width.js +1262 -0
  59. package/dist/charts/axis-width.js.map +1 -0
  60. package/dist/charts/bar-public.d.ts +16 -0
  61. package/dist/charts/bar-public.js +16 -0
  62. package/dist/charts/bar-public.js.map +1 -0
  63. package/dist/charts/chart-parts.d.ts +136 -0
  64. package/dist/charts/chart-parts.js +160 -0
  65. package/dist/charts/chart-parts.js.map +1 -0
  66. package/dist/charts/core-charts.d.ts +157 -0
  67. package/dist/charts/core-charts.js +505 -0
  68. package/dist/charts/core-charts.js.map +1 -0
  69. package/dist/charts/index.d.ts +12 -0
  70. package/dist/charts/index.js +8 -0
  71. package/dist/charts/index.js.map +1 -0
  72. package/dist/charts/list-charts.d.ts +124 -0
  73. package/dist/charts/list-charts.js +308 -0
  74. package/dist/charts/list-charts.js.map +1 -0
  75. package/dist/charts/more-charts.d.ts +138 -0
  76. package/dist/charts/more-charts.js +284 -0
  77. package/dist/charts/more-charts.js.map +1 -0
  78. package/dist/charts/report-charts.d.ts +138 -0
  79. package/dist/charts/report-charts.js +370 -0
  80. package/dist/charts/report-charts.js.map +1 -0
  81. package/dist/charts/value-tick.d.ts +178 -0
  82. package/dist/charts/value-tick.js +240 -0
  83. package/dist/charts/value-tick.js.map +1 -0
  84. package/dist/collection/data-table-url-hook.d.ts +34 -0
  85. package/dist/collection/data-table-url-hook.js +70 -0
  86. package/dist/collection/data-table-url-hook.js.map +1 -0
  87. package/dist/collection/data-table-url.d.ts +30 -0
  88. package/dist/collection/data-table-url.js +48 -0
  89. package/dist/collection/data-table-url.js.map +1 -0
  90. package/dist/collection/data-table.d.ts +112 -0
  91. package/dist/collection/data-table.js +188 -0
  92. package/dist/collection/data-table.js.map +1 -0
  93. package/dist/collection/grid-list-public.d.ts +18 -0
  94. package/dist/collection/grid-list-public.js +19 -0
  95. package/dist/collection/grid-list-public.js.map +1 -0
  96. package/dist/collection/grid-list.d.ts +73 -0
  97. package/dist/collection/grid-list.js +46 -0
  98. package/dist/collection/grid-list.js.map +1 -0
  99. package/dist/collection/index.d.ts +14 -0
  100. package/dist/collection/index.js +8 -0
  101. package/dist/collection/index.js.map +1 -0
  102. package/dist/collection/list.d.ts +61 -0
  103. package/dist/collection/list.js +38 -0
  104. package/dist/collection/list.js.map +1 -0
  105. package/dist/collection/selection-checkbox.d.ts +5 -0
  106. package/dist/collection/selection-checkbox.js +13 -0
  107. package/dist/collection/selection-checkbox.js.map +1 -0
  108. package/dist/collection/table.d.ts +91 -0
  109. package/dist/collection/table.js +183 -0
  110. package/dist/collection/table.js.map +1 -0
  111. package/dist/collection/tree.d.ts +31 -0
  112. package/dist/collection/tree.js +22 -0
  113. package/dist/collection/tree.js.map +1 -0
  114. package/dist/color/color.d.ts +87 -0
  115. package/dist/color/color.js +200 -0
  116. package/dist/color/color.js.map +1 -0
  117. package/dist/color/contrast.d.ts +34 -0
  118. package/dist/color/contrast.js +44 -0
  119. package/dist/color/contrast.js.map +1 -0
  120. package/dist/color/index.d.ts +4 -0
  121. package/dist/color/index.js +5 -0
  122. package/dist/color/index.js.map +1 -0
  123. package/dist/date/calendar.d.ts +71 -0
  124. package/dist/date/calendar.js +291 -0
  125. package/dist/date/calendar.js.map +1 -0
  126. package/dist/date/fields.d.ts +174 -0
  127. package/dist/date/fields.js +250 -0
  128. package/dist/date/fields.js.map +1 -0
  129. package/dist/date/index.d.ts +7 -0
  130. package/dist/date/index.js +6 -0
  131. package/dist/date/index.js.map +1 -0
  132. package/dist/date/month-grid.d.ts +31 -0
  133. package/dist/date/month-grid.js +115 -0
  134. package/dist/date/month-grid.js.map +1 -0
  135. package/dist/date/pickers.d.ts +118 -0
  136. package/dist/date/pickers.js +176 -0
  137. package/dist/date/pickers.js.map +1 -0
  138. package/dist/date/public.d.ts +25 -0
  139. package/dist/date/public.js +24 -0
  140. package/dist/date/public.js.map +1 -0
  141. package/dist/date/segments.d.ts +153 -0
  142. package/dist/date/segments.js +433 -0
  143. package/dist/date/segments.js.map +1 -0
  144. package/dist/defaults.d.ts +74 -0
  145. package/dist/defaults.js +100 -0
  146. package/dist/defaults.js.map +1 -0
  147. package/dist/density.d.ts +2 -0
  148. package/dist/density.js +2 -0
  149. package/dist/density.js.map +1 -0
  150. package/dist/display/avatar.d.ts +29 -0
  151. package/dist/display/avatar.js +71 -0
  152. package/dist/display/avatar.js.map +1 -0
  153. package/dist/display/badge.d.ts +65 -0
  154. package/dist/display/badge.js +99 -0
  155. package/dist/display/badge.js.map +1 -0
  156. package/dist/display/card.d.ts +72 -0
  157. package/dist/display/card.js +91 -0
  158. package/dist/display/card.js.map +1 -0
  159. package/dist/display/carousel.d.ts +47 -0
  160. package/dist/display/carousel.js +214 -0
  161. package/dist/display/carousel.js.map +1 -0
  162. package/dist/display/description-list.d.ts +25 -0
  163. package/dist/display/description-list.js +36 -0
  164. package/dist/display/description-list.js.map +1 -0
  165. package/dist/display/icon-aliases.d.ts +1 -0
  166. package/dist/display/icon-aliases.js +259 -0
  167. package/dist/display/icon-aliases.js.map +1 -0
  168. package/dist/display/icon-names.d.ts +4 -0
  169. package/dist/display/icon-names.js +2 -0
  170. package/dist/display/icon-names.js.map +1 -0
  171. package/dist/display/icon.d.ts +51 -0
  172. package/dist/display/icon.js +96 -0
  173. package/dist/display/icon.js.map +1 -0
  174. package/dist/display/image-crop.d.ts +106 -0
  175. package/dist/display/image-crop.js +117 -0
  176. package/dist/display/image-crop.js.map +1 -0
  177. package/dist/display/image-cropper.d.ts +68 -0
  178. package/dist/display/image-cropper.js +284 -0
  179. package/dist/display/image-cropper.js.map +1 -0
  180. package/dist/display/image-viewer.d.ts +54 -0
  181. package/dist/display/image-viewer.js +84 -0
  182. package/dist/display/image-viewer.js.map +1 -0
  183. package/dist/display/image.d.ts +26 -0
  184. package/dist/display/image.js +17 -0
  185. package/dist/display/image.js.map +1 -0
  186. package/dist/display/index.d.ts +29 -0
  187. package/dist/display/index.js +16 -0
  188. package/dist/display/index.js.map +1 -0
  189. package/dist/display/iso-chip.d.ts +19 -0
  190. package/dist/display/iso-chip.js +21 -0
  191. package/dist/display/iso-chip.js.map +1 -0
  192. package/dist/display/kbd.d.ts +11 -0
  193. package/dist/display/kbd.js +33 -0
  194. package/dist/display/kbd.js.map +1 -0
  195. package/dist/display/lozenge.d.ts +30 -0
  196. package/dist/display/lozenge.js +55 -0
  197. package/dist/display/lozenge.js.map +1 -0
  198. package/dist/display/scroll-area.d.ts +29 -0
  199. package/dist/display/scroll-area.js +95 -0
  200. package/dist/display/scroll-area.js.map +1 -0
  201. package/dist/display/separator.d.ts +13 -0
  202. package/dist/display/separator.js +24 -0
  203. package/dist/display/separator.js.map +1 -0
  204. package/dist/display/stat.d.ts +35 -0
  205. package/dist/display/stat.js +41 -0
  206. package/dist/display/stat.js.map +1 -0
  207. package/dist/display/timeline.d.ts +44 -0
  208. package/dist/display/timeline.js +111 -0
  209. package/dist/display/timeline.js.map +1 -0
  210. package/dist/display/typography.d.ts +37 -0
  211. package/dist/display/typography.js +53 -0
  212. package/dist/display/typography.js.map +1 -0
  213. package/dist/display/visually-hidden.d.ts +14 -0
  214. package/dist/display/visually-hidden.js +10 -0
  215. package/dist/display/visually-hidden.js.map +1 -0
  216. package/dist/feedback/banner.d.ts +46 -0
  217. package/dist/feedback/banner.js +157 -0
  218. package/dist/feedback/banner.js.map +1 -0
  219. package/dist/feedback/cooldown.d.ts +17 -0
  220. package/dist/feedback/cooldown.js +59 -0
  221. package/dist/feedback/cooldown.js.map +1 -0
  222. package/dist/feedback/empty-state.d.ts +35 -0
  223. package/dist/feedback/empty-state.js +39 -0
  224. package/dist/feedback/empty-state.js.map +1 -0
  225. package/dist/feedback/index.d.ts +12 -0
  226. package/dist/feedback/index.js +11 -0
  227. package/dist/feedback/index.js.map +1 -0
  228. package/dist/feedback/meter.d.ts +33 -0
  229. package/dist/feedback/meter.js +42 -0
  230. package/dist/feedback/meter.js.map +1 -0
  231. package/dist/feedback/motion.d.ts +9 -0
  232. package/dist/feedback/motion.js +57 -0
  233. package/dist/feedback/motion.js.map +1 -0
  234. package/dist/feedback/progress.d.ts +39 -0
  235. package/dist/feedback/progress.js +68 -0
  236. package/dist/feedback/progress.js.map +1 -0
  237. package/dist/feedback/skeleton.d.ts +48 -0
  238. package/dist/feedback/skeleton.js +61 -0
  239. package/dist/feedback/skeleton.js.map +1 -0
  240. package/dist/feedback/spinner.d.ts +19 -0
  241. package/dist/feedback/spinner.js +29 -0
  242. package/dist/feedback/spinner.js.map +1 -0
  243. package/dist/feedback/status-dot.d.ts +23 -0
  244. package/dist/feedback/status-dot.js +37 -0
  245. package/dist/feedback/status-dot.js.map +1 -0
  246. package/dist/form/countries.d.ts +34 -0
  247. package/dist/form/countries.js +273 -0
  248. package/dist/form/countries.js.map +1 -0
  249. package/dist/form/data-attributes.d.ts +11 -0
  250. package/dist/form/data-attributes.js +22 -0
  251. package/dist/form/data-attributes.js.map +1 -0
  252. package/dist/form/field-parts.d.ts +113 -0
  253. package/dist/form/field-parts.js +178 -0
  254. package/dist/form/field-parts.js.map +1 -0
  255. package/dist/form/field.d.ts +36 -0
  256. package/dist/form/field.js +65 -0
  257. package/dist/form/field.js.map +1 -0
  258. package/dist/form/files.d.ts +70 -0
  259. package/dist/form/files.js +156 -0
  260. package/dist/form/files.js.map +1 -0
  261. package/dist/form/form.d.ts +40 -0
  262. package/dist/form/form.js +74 -0
  263. package/dist/form/form.js.map +1 -0
  264. package/dist/form/image-crop.d.ts +106 -0
  265. package/dist/form/image-crop.js +117 -0
  266. package/dist/form/image-crop.js.map +1 -0
  267. package/dist/form/image-cropper.d.ts +68 -0
  268. package/dist/form/image-cropper.js +284 -0
  269. package/dist/form/image-cropper.js.map +1 -0
  270. package/dist/form/index.d.ts +24 -0
  271. package/dist/form/index.js +15 -0
  272. package/dist/form/index.js.map +1 -0
  273. package/dist/form/input-group.d.ts +63 -0
  274. package/dist/form/input-group.js +63 -0
  275. package/dist/form/input-group.js.map +1 -0
  276. package/dist/form/input-otp.d.ts +35 -0
  277. package/dist/form/input-otp.js +83 -0
  278. package/dist/form/input-otp.js.map +1 -0
  279. package/dist/form/input.d.ts +36 -0
  280. package/dist/form/input.js +41 -0
  281. package/dist/form/input.js.map +1 -0
  282. package/dist/form/number-field.d.ts +84 -0
  283. package/dist/form/number-field.js +81 -0
  284. package/dist/form/number-field.js.map +1 -0
  285. package/dist/form/otp-field.d.ts +37 -0
  286. package/dist/form/otp-field.js +116 -0
  287. package/dist/form/otp-field.js.map +1 -0
  288. package/dist/form/password-field.d.ts +61 -0
  289. package/dist/form/password-field.js +61 -0
  290. package/dist/form/password-field.js.map +1 -0
  291. package/dist/form/phone-field.d.ts +104 -0
  292. package/dist/form/phone-field.js +275 -0
  293. package/dist/form/phone-field.js.map +1 -0
  294. package/dist/form/phone-paste.d.ts +24 -0
  295. package/dist/form/phone-paste.js +40 -0
  296. package/dist/form/phone-paste.js.map +1 -0
  297. package/dist/form/phone.d.ts +159 -0
  298. package/dist/form/phone.js +309 -0
  299. package/dist/form/phone.js.map +1 -0
  300. package/dist/form/search-field.d.ts +29 -0
  301. package/dist/form/search-field.js +23 -0
  302. package/dist/form/search-field.js.map +1 -0
  303. package/dist/form/styles.d.ts +31 -0
  304. package/dist/form/styles.js +43 -0
  305. package/dist/form/styles.js.map +1 -0
  306. package/dist/form/text-area.d.ts +70 -0
  307. package/dist/form/text-area.js +93 -0
  308. package/dist/form/text-area.js.map +1 -0
  309. package/dist/form/text-field.d.ts +131 -0
  310. package/dist/form/text-field.js +59 -0
  311. package/dist/form/text-field.js.map +1 -0
  312. package/dist/form/validation.d.ts +145 -0
  313. package/dist/form/validation.js +136 -0
  314. package/dist/form/validation.js.map +1 -0
  315. package/dist/i18n.d.ts +438 -0
  316. package/dist/i18n.js +948 -0
  317. package/dist/i18n.js.map +1 -0
  318. package/dist/index.d.ts +9 -0
  319. package/dist/index.js +7 -0
  320. package/dist/index.js.map +1 -0
  321. package/dist/intl-locale.d.ts +30 -0
  322. package/dist/intl-locale.js +83 -0
  323. package/dist/intl-locale.js.map +1 -0
  324. package/dist/layers.d.ts +32 -0
  325. package/dist/layers.js +33 -0
  326. package/dist/layers.js.map +1 -0
  327. package/dist/layout/auth-form-layout.d.ts +71 -0
  328. package/dist/layout/auth-form-layout.js +61 -0
  329. package/dist/layout/auth-form-layout.js.map +1 -0
  330. package/dist/layout/auth-layout.d.ts +59 -0
  331. package/dist/layout/auth-layout.js +26 -0
  332. package/dist/layout/auth-layout.js.map +1 -0
  333. package/dist/layout/box.d.ts +26 -0
  334. package/dist/layout/box.js +16 -0
  335. package/dist/layout/box.js.map +1 -0
  336. package/dist/layout/grid.d.ts +27 -0
  337. package/dist/layout/grid.js +26 -0
  338. package/dist/layout/grid.js.map +1 -0
  339. package/dist/layout/index.d.ts +16 -0
  340. package/dist/layout/index.js +12 -0
  341. package/dist/layout/index.js.map +1 -0
  342. package/dist/layout/pressable.d.ts +40 -0
  343. package/dist/layout/pressable.js +65 -0
  344. package/dist/layout/pressable.js.map +1 -0
  345. package/dist/layout/reset-sent-card.d.ts +39 -0
  346. package/dist/layout/reset-sent-card.js +22 -0
  347. package/dist/layout/reset-sent-card.js.map +1 -0
  348. package/dist/layout/scroll-area.d.ts +29 -0
  349. package/dist/layout/scroll-area.js +95 -0
  350. package/dist/layout/scroll-area.js.map +1 -0
  351. package/dist/layout/section.d.ts +41 -0
  352. package/dist/layout/section.js +22 -0
  353. package/dist/layout/section.js.map +1 -0
  354. package/dist/layout/split.d.ts +50 -0
  355. package/dist/layout/split.js +35 -0
  356. package/dist/layout/split.js.map +1 -0
  357. package/dist/layout/stack.d.ts +44 -0
  358. package/dist/layout/stack.js +36 -0
  359. package/dist/layout/stack.js.map +1 -0
  360. package/dist/layout/tokens.d.ts +33 -0
  361. package/dist/layout/tokens.js +85 -0
  362. package/dist/layout/tokens.js.map +1 -0
  363. package/dist/layout/toolbar.d.ts +37 -0
  364. package/dist/layout/toolbar.js +334 -0
  365. package/dist/layout/toolbar.js.map +1 -0
  366. package/dist/navigate-context.d.ts +12 -0
  367. package/dist/navigate-context.js +13 -0
  368. package/dist/navigate-context.js.map +1 -0
  369. package/dist/navigation/accordion.d.ts +40 -0
  370. package/dist/navigation/accordion.js +33 -0
  371. package/dist/navigation/accordion.js.map +1 -0
  372. package/dist/navigation/bottom-nav.d.ts +29 -0
  373. package/dist/navigation/bottom-nav.js +48 -0
  374. package/dist/navigation/bottom-nav.js.map +1 -0
  375. package/dist/navigation/brand-link-context.d.ts +8 -0
  376. package/dist/navigation/brand-link-context.js +9 -0
  377. package/dist/navigation/brand-link-context.js.map +1 -0
  378. package/dist/navigation/breadcrumbs.d.ts +36 -0
  379. package/dist/navigation/breadcrumbs.js +51 -0
  380. package/dist/navigation/breadcrumbs.js.map +1 -0
  381. package/dist/navigation/dock.d.ts +27 -0
  382. package/dist/navigation/dock.js +47 -0
  383. package/dist/navigation/dock.js.map +1 -0
  384. package/dist/navigation/footer.d.ts +43 -0
  385. package/dist/navigation/footer.js +43 -0
  386. package/dist/navigation/footer.js.map +1 -0
  387. package/dist/navigation/index.d.ts +22 -0
  388. package/dist/navigation/index.js +17 -0
  389. package/dist/navigation/index.js.map +1 -0
  390. package/dist/navigation/language-names.d.ts +19 -0
  391. package/dist/navigation/language-names.js +79 -0
  392. package/dist/navigation/language-names.js.map +1 -0
  393. package/dist/navigation/language-switcher.d.ts +55 -0
  394. package/dist/navigation/language-switcher.js +53 -0
  395. package/dist/navigation/language-switcher.js.map +1 -0
  396. package/dist/navigation/nav-panel.d.ts +18 -0
  397. package/dist/navigation/nav-panel.js +51 -0
  398. package/dist/navigation/nav-panel.js.map +1 -0
  399. package/dist/navigation/navbar.d.ts +73 -0
  400. package/dist/navigation/navbar.js +64 -0
  401. package/dist/navigation/navbar.js.map +1 -0
  402. package/dist/navigation/page-header.d.ts +37 -0
  403. package/dist/navigation/page-header.js +50 -0
  404. package/dist/navigation/page-header.js.map +1 -0
  405. package/dist/navigation/pagination.d.ts +25 -0
  406. package/dist/navigation/pagination.js +51 -0
  407. package/dist/navigation/pagination.js.map +1 -0
  408. package/dist/navigation/panel-header.d.ts +37 -0
  409. package/dist/navigation/panel-header.js +50 -0
  410. package/dist/navigation/panel-header.js.map +1 -0
  411. package/dist/navigation/sidebar-script.d.ts +12 -0
  412. package/dist/navigation/sidebar-script.js +20 -0
  413. package/dist/navigation/sidebar-script.js.map +1 -0
  414. package/dist/navigation/sidebar.d.ts +149 -0
  415. package/dist/navigation/sidebar.js +332 -0
  416. package/dist/navigation/sidebar.js.map +1 -0
  417. package/dist/navigation/skip-link.d.ts +12 -0
  418. package/dist/navigation/skip-link.js +30 -0
  419. package/dist/navigation/skip-link.js.map +1 -0
  420. package/dist/navigation/stepper.d.ts +50 -0
  421. package/dist/navigation/stepper.js +96 -0
  422. package/dist/navigation/stepper.js.map +1 -0
  423. package/dist/navigation/tabs.d.ts +84 -0
  424. package/dist/navigation/tabs.js +118 -0
  425. package/dist/navigation/tabs.js.map +1 -0
  426. package/dist/navigation/toolbar.d.ts +37 -0
  427. package/dist/navigation/toolbar.js +334 -0
  428. package/dist/navigation/toolbar.js.map +1 -0
  429. package/dist/overlay/alert-dialog.d.ts +63 -0
  430. package/dist/overlay/alert-dialog.js +76 -0
  431. package/dist/overlay/alert-dialog.js.map +1 -0
  432. package/dist/overlay/command-palette.d.ts +53 -0
  433. package/dist/overlay/command-palette.js +130 -0
  434. package/dist/overlay/command-palette.js.map +1 -0
  435. package/dist/overlay/command.d.ts +53 -0
  436. package/dist/overlay/command.js +129 -0
  437. package/dist/overlay/command.js.map +1 -0
  438. package/dist/overlay/context-menu.d.ts +29 -0
  439. package/dist/overlay/context-menu.js +58 -0
  440. package/dist/overlay/context-menu.js.map +1 -0
  441. package/dist/overlay/dialog.d.ts +162 -0
  442. package/dist/overlay/dialog.js +174 -0
  443. package/dist/overlay/dialog.js.map +1 -0
  444. package/dist/overlay/drawer.d.ts +41 -0
  445. package/dist/overlay/drawer.js +114 -0
  446. package/dist/overlay/drawer.js.map +1 -0
  447. package/dist/overlay/floating.d.ts +142 -0
  448. package/dist/overlay/floating.js +226 -0
  449. package/dist/overlay/floating.js.map +1 -0
  450. package/dist/overlay/hover-card.d.ts +19 -0
  451. package/dist/overlay/hover-card.js +31 -0
  452. package/dist/overlay/hover-card.js.map +1 -0
  453. package/dist/overlay/index.d.ts +18 -0
  454. package/dist/overlay/index.js +12 -0
  455. package/dist/overlay/index.js.map +1 -0
  456. package/dist/overlay/overlay-base.d.ts +105 -0
  457. package/dist/overlay/overlay-base.js +250 -0
  458. package/dist/overlay/overlay-base.js.map +1 -0
  459. package/dist/overlay/overlay.d.ts +299 -0
  460. package/dist/overlay/overlay.js +558 -0
  461. package/dist/overlay/overlay.js.map +1 -0
  462. package/dist/overlay/toast.d.ts +58 -0
  463. package/dist/overlay/toast.js +145 -0
  464. package/dist/overlay/toast.js.map +1 -0
  465. package/dist/provider.d.ts +26 -0
  466. package/dist/provider.js +30 -0
  467. package/dist/provider.js.map +1 -0
  468. package/dist/selection/autocomplete.d.ts +54 -0
  469. package/dist/selection/autocomplete.js +122 -0
  470. package/dist/selection/autocomplete.js.map +1 -0
  471. package/dist/selection/checkbox.d.ts +56 -0
  472. package/dist/selection/checkbox.js +49 -0
  473. package/dist/selection/checkbox.js.map +1 -0
  474. package/dist/selection/choice-size.d.ts +26 -0
  475. package/dist/selection/choice-size.js +50 -0
  476. package/dist/selection/choice-size.js.map +1 -0
  477. package/dist/selection/choice-text.d.ts +21 -0
  478. package/dist/selection/choice-text.js +33 -0
  479. package/dist/selection/choice-text.js.map +1 -0
  480. package/dist/selection/combobox.d.ts +173 -0
  481. package/dist/selection/combobox.js +410 -0
  482. package/dist/selection/combobox.js.map +1 -0
  483. package/dist/selection/index.d.ts +20 -0
  484. package/dist/selection/index.js +13 -0
  485. package/dist/selection/index.js.map +1 -0
  486. package/dist/selection/list-box.d.ts +30 -0
  487. package/dist/selection/list-box.js +16 -0
  488. package/dist/selection/list-box.js.map +1 -0
  489. package/dist/selection/listbox.d.ts +44 -0
  490. package/dist/selection/listbox.js +49 -0
  491. package/dist/selection/listbox.js.map +1 -0
  492. package/dist/selection/match.d.ts +20 -0
  493. package/dist/selection/match.js +57 -0
  494. package/dist/selection/match.js.map +1 -0
  495. package/dist/selection/multi-select.d.ts +72 -0
  496. package/dist/selection/multi-select.js +138 -0
  497. package/dist/selection/multi-select.js.map +1 -0
  498. package/dist/selection/radio-card.d.ts +31 -0
  499. package/dist/selection/radio-card.js +29 -0
  500. package/dist/selection/radio-card.js.map +1 -0
  501. package/dist/selection/radio.d.ts +72 -0
  502. package/dist/selection/radio.js +64 -0
  503. package/dist/selection/radio.js.map +1 -0
  504. package/dist/selection/select-public.d.ts +19 -0
  505. package/dist/selection/select-public.js +24 -0
  506. package/dist/selection/select-public.js.map +1 -0
  507. package/dist/selection/select.d.ts +72 -0
  508. package/dist/selection/select.js +69 -0
  509. package/dist/selection/select.js.map +1 -0
  510. package/dist/selection/slider.d.ts +16 -0
  511. package/dist/selection/slider.js +44 -0
  512. package/dist/selection/slider.js.map +1 -0
  513. package/dist/selection/styles.d.ts +26 -0
  514. package/dist/selection/styles.js +78 -0
  515. package/dist/selection/styles.js.map +1 -0
  516. package/dist/selection/switch.d.ts +24 -0
  517. package/dist/selection/switch.js +27 -0
  518. package/dist/selection/switch.js.map +1 -0
  519. package/dist/selection/tag-group.d.ts +38 -0
  520. package/dist/selection/tag-group.js +45 -0
  521. package/dist/selection/tag-group.js.map +1 -0
  522. package/dist/tone.d.ts +6 -0
  523. package/dist/tone.js +2 -0
  524. package/dist/tone.js.map +1 -0
  525. package/dist/utils.d.ts +9 -0
  526. package/dist/utils.js +42 -0
  527. package/dist/utils.js.map +1 -0
  528. package/manifest/component.full.schema.json +391 -0
  529. package/manifest/component.schema.json +279 -0
  530. package/manifests/accordion.json +299 -0
  531. package/manifests/alert-dialog.json +261 -0
  532. package/manifests/area-chart.json +338 -0
  533. package/manifests/autocomplete.json +299 -0
  534. package/manifests/avatar.json +253 -0
  535. package/manifests/badge.json +288 -0
  536. package/manifests/banner.json +185 -0
  537. package/manifests/bar-chart.json +454 -0
  538. package/manifests/bar-list.json +262 -0
  539. package/manifests/bottom-nav.json +139 -0
  540. package/manifests/box.json +3450 -0
  541. package/manifests/breadcrumbs.json +199 -0
  542. package/manifests/button-group.json +2294 -0
  543. package/manifests/button.json +1211 -0
  544. package/manifests/calendar-heatmap.json +218 -0
  545. package/manifests/calendar.json +299 -0
  546. package/manifests/card.json +308 -0
  547. package/manifests/carousel.json +263 -0
  548. package/manifests/chart-parts.json +309 -0
  549. package/manifests/checkbox.json +998 -0
  550. package/manifests/close-button.json +1000 -0
  551. package/manifests/color-field.json +276 -0
  552. package/manifests/color-picker.json +161 -0
  553. package/manifests/color-swatch-picker.json +220 -0
  554. package/manifests/color-swatch.json +140 -0
  555. package/manifests/combobox.json +581 -0
  556. package/manifests/command.json +275 -0
  557. package/manifests/composed-chart.json +287 -0
  558. package/manifests/context-menu.json +148 -0
  559. package/manifests/copy-button.json +192 -0
  560. package/manifests/data-table.json +334 -0
  561. package/manifests/date-field.json +302 -0
  562. package/manifests/date-picker.json +472 -0
  563. package/manifests/description-list.json +201 -0
  564. package/manifests/dialog.json +322 -0
  565. package/manifests/donut-chart.json +264 -0
  566. package/manifests/drawer.json +211 -0
  567. package/manifests/empty-state.json +185 -0
  568. package/manifests/fab.json +172 -0
  569. package/manifests/field.json +209 -0
  570. package/manifests/file-upload.json +791 -0
  571. package/manifests/form.json +829 -0
  572. package/manifests/funnel-chart.json +223 -0
  573. package/manifests/gauge-chart.json +252 -0
  574. package/manifests/grid-list.json +335 -0
  575. package/manifests/grid.json +3482 -0
  576. package/manifests/heading.json +183 -0
  577. package/manifests/heatmap.json +265 -0
  578. package/manifests/hover-card.json +172 -0
  579. package/manifests/icon.json +201 -0
  580. package/manifests/image-cropper.json +295 -0
  581. package/manifests/image-viewer.json +198 -0
  582. package/manifests/image.json +193 -0
  583. package/manifests/index.json +2035 -0
  584. package/manifests/input-group.json +3571 -0
  585. package/manifests/input.json +1557 -0
  586. package/manifests/kbd.json +98 -0
  587. package/manifests/language-switcher.json +274 -0
  588. package/manifests/line-chart.json +342 -0
  589. package/manifests/link.json +867 -0
  590. package/manifests/list-box.json +213 -0
  591. package/manifests/menu.json +453 -0
  592. package/manifests/meter.json +145 -0
  593. package/manifests/navbar.json +281 -0
  594. package/manifests/otp-field.json +1029 -0
  595. package/manifests/page-header.json +164 -0
  596. package/manifests/pagination.json +181 -0
  597. package/manifests/popover.json +205 -0
  598. package/manifests/pressable.json +367 -0
  599. package/manifests/progress.json +282 -0
  600. package/manifests/radar-chart.json +229 -0
  601. package/manifests/radial-chart.json +195 -0
  602. package/manifests/radio.json +975 -0
  603. package/manifests/scatter-chart.json +277 -0
  604. package/manifests/scroll-area.json +127 -0
  605. package/manifests/section.json +169 -0
  606. package/manifests/select.json +474 -0
  607. package/manifests/separator.json +119 -0
  608. package/manifests/sidebar.json +584 -0
  609. package/manifests/skeleton.json +235 -0
  610. package/manifests/skip-link.json +89 -0
  611. package/manifests/slider.json +706 -0
  612. package/manifests/sparkline.json +208 -0
  613. package/manifests/spinner.json +105 -0
  614. package/manifests/split.json +6618 -0
  615. package/manifests/stack.json +3541 -0
  616. package/manifests/stat.json +192 -0
  617. package/manifests/stepper.json +279 -0
  618. package/manifests/switch.json +205 -0
  619. package/manifests/table.json +375 -0
  620. package/manifests/tabs.json +438 -0
  621. package/manifests/tag-group.json +264 -0
  622. package/manifests/text-area.json +1136 -0
  623. package/manifests/text.json +244 -0
  624. package/manifests/theme-switcher.json +152 -0
  625. package/manifests/time-field.json +284 -0
  626. package/manifests/timeline.json +196 -0
  627. package/manifests/toast.json +87 -0
  628. package/manifests/toggle-button.json +1489 -0
  629. package/manifests/toolbar.json +145 -0
  630. package/manifests/tooltip.json +181 -0
  631. package/manifests/tracker.json +192 -0
  632. package/manifests/tree.json +245 -0
  633. package/manifests/visually-hidden.json +114 -0
  634. package/package.json +117 -3
  635. package/styles/base.css +56 -0
  636. package/styles/theme.css +154 -0
@@ -0,0 +1,93 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { Label as AriaLabel, TextArea as AriaTextArea, TextField as AriaTextField, useLocale, } from "react-aria-components";
5
+ import { cn } from "../utils.js";
6
+ import { limitExceededLabel, overLimitLabel } from "../i18n.js";
7
+ import { FieldDescription, FieldError, FieldLabel } from "./field-parts.js";
8
+ import { InputGroup } from "./input-group.js";
9
+ import { ComponentDefaultsProvider, splitRadius } from "../defaults.js";
10
+ import { FIELD_STACK, INPUT } from "./styles.js";
11
+ import { useFieldValidation } from "./validation.js";
12
+ import { splitDataAttributes } from "./data-attributes.js";
13
+ /** The field is 72px minimum, grows with the content up to 240px, then scrolls (design). */
14
+ export const TEXTAREA_MIN_HEIGHT = 72;
15
+ export const TEXTAREA_MAX_HEIGHT = 240;
16
+ /** The frame's block padding (`py-ds-100` × 2); the textarea itself gets the rest. */
17
+ const FRAME_PADDING = 16;
18
+ /** Grows the textarea to its content between the design's minimum and maximum height. */
19
+ function measure(node) {
20
+ node.style.height = "auto";
21
+ const min = TEXTAREA_MIN_HEIGHT - FRAME_PADDING;
22
+ const max = TEXTAREA_MAX_HEIGHT - FRAME_PADDING;
23
+ node.style.height = `${Math.min(Math.max(node.scrollHeight, min), max)}px`;
24
+ node.style.overflowY = node.scrollHeight > max ? "auto" : "hidden";
25
+ }
26
+ /** Re-measures on every value change and whenever the width changes (wrapping, fonts, layout). */
27
+ function useAutoGrow(ref, value) {
28
+ React.useLayoutEffect(() => {
29
+ if (ref.current)
30
+ measure(ref.current);
31
+ }, [ref, value]);
32
+ React.useEffect(() => {
33
+ const node = ref.current;
34
+ if (!node || typeof ResizeObserver === "undefined")
35
+ return;
36
+ let width = node.clientWidth;
37
+ const observer = new ResizeObserver(() => {
38
+ if (node.clientWidth !== width) {
39
+ width = node.clientWidth;
40
+ measure(node);
41
+ }
42
+ });
43
+ observer.observe(node);
44
+ return () => observer.disconnect();
45
+ }, [ref]);
46
+ }
47
+ /** Multi-line text: notes, damage reports, messages. */
48
+ const TextAreaField = React.forwardRef(function TextAreaField({ label, isLabelHidden, description, errorMessage, isOptional, placeholder, maxLength, showCounter = true, value, defaultValue, onChange, validate, onBlur, requiredValidation, ...rest }, forwardedRef) {
49
+ const { locale } = useLocale();
50
+ const local = React.useRef(null);
51
+ const ref = React.useCallback((node) => {
52
+ local.current = node;
53
+ if (typeof forwardedRef === "function")
54
+ forwardedRef(node);
55
+ else if (forwardedRef)
56
+ forwardedRef.current = node;
57
+ }, [forwardedRef]);
58
+ const [uncontrolled, setUncontrolled] = React.useState(defaultValue ?? "");
59
+ const text = value ?? uncontrolled;
60
+ useAutoGrow(local, text);
61
+ const over = maxLength !== undefined ? text.length - maxLength : 0;
62
+ const limitCheck = React.useCallback((current) => {
63
+ if (maxLength !== undefined && current.length > maxLength)
64
+ return overLimitLabel(locale, current.length - maxLength);
65
+ return validate?.(current);
66
+ }, [locale, maxLength, validate]);
67
+ const timing = useFieldValidation({
68
+ validate: limitCheck,
69
+ value: value,
70
+ initialValue: value ?? defaultValue ?? "",
71
+ isRequired: rest.isRequired,
72
+ requiredValidation,
73
+ onBlur: onBlur,
74
+ onChange,
75
+ validationBehavior: rest.validationBehavior,
76
+ });
77
+ const counterId = React.useId();
78
+ const counted = maxLength !== undefined && showCounter;
79
+ const { wrapperProps, controlData } = splitDataAttributes(rest);
80
+ return (_jsx(AriaTextField, { ...wrapperProps, value: text, onChange: (next) => {
81
+ if (value === undefined)
82
+ setUncontrolled(next);
83
+ timing.onChange?.(next);
84
+ }, validationBehavior: timing.validationBehavior, validate: timing.validate, onBlur: timing.onBlur, "aria-describedby": [rest["aria-describedby"], counted ? counterId : undefined].filter(Boolean).join(" ") || undefined, "data-slot": "text-area", className: FIELD_STACK, children: ({ isInvalid, isDisabled }) => (_jsxs(_Fragment, { children: [isLabelHidden ? (_jsx(AriaLabel, { "data-slot": "field-label", className: "sr-only", children: label })) : (_jsx(FieldLabel, { isRequired: rest.isRequired, isOptional: isOptional, children: label })), _jsx(InputGroup, { multiline: true, isDisabled: isDisabled, isInvalid: isInvalid, children: _jsx(AriaTextArea, { ...controlData, ref: ref, placeholder: placeholder, "data-slot": "text-area-input", className: cn(INPUT, "text-body resize-none"), style: { minHeight: TEXTAREA_MIN_HEIGHT - FRAME_PADDING } }) }), (description || counted) && (_jsxs("div", { className: "flex items-start justify-between gap-ds-200", children: [description ? _jsx(FieldDescription, { children: description }) : _jsx("span", {}), counted && (_jsxs("span", { id: counterId, "data-slot": "text-area-counter",
85
+ // "89 / 500" in every locale: on an RTL page the bidi algorithm would show "500 / 89".
86
+ dir: "ltr", className: cn("shrink-0 text-body-small tabular-nums", over > 0 ? "text-ds-text-danger" : "text-ds-text-subtlest"), children: [new Intl.NumberFormat(locale).format(text.length), " / ", new Intl.NumberFormat(locale).format(maxLength)] }))] })), maxLength !== undefined && (_jsx("span", { "aria-live": "polite", "data-slot": "text-area-limit-status", className: "sr-only", children: over > 0 ? limitExceededLabel(locale) : "" })), _jsx(FieldError, { children: over > 0 ? undefined : errorMessage })] })) }));
87
+ });
88
+ /** Several lines of text, with a label, description, error and an optional character count. */
89
+ export const TextArea = React.forwardRef(function TextArea(allProps, ref) {
90
+ const [radius, props] = splitRadius(allProps);
91
+ return (_jsx(ComponentDefaultsProvider, { value: { radius }, children: _jsx(TextAreaField, { ...props, ref: ref }) }));
92
+ });
93
+ //# sourceMappingURL=text-area.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-area.js","sourceRoot":"","sources":["../../src/form/text-area.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,KAAK,IAAI,SAAS,EAClB,QAAQ,IAAI,YAAY,EACxB,SAAS,IAAI,aAAa,EAC1B,SAAS,GAEV,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAmB,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAA2B,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,4FAA4F;AAC5F,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AACtC,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC,sFAAsF;AACtF,MAAM,aAAa,GAAG,EAAE,CAAC;AAiCzB,yFAAyF;AACzF,SAAS,OAAO,CAAC,IAAyB;IACxC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IAC3B,MAAM,GAAG,GAAG,mBAAmB,GAAG,aAAa,CAAC;IAChD,MAAM,GAAG,GAAG,mBAAmB,GAAG,aAAa,CAAC;IAChD,IAAI,CAAC,KAAK,CAA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U,cAAE,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,GAAc,IAC7D,CACJ,GACa,CACjB,CAAC;AACJ,CAAC,CAAC,CAAC;AAIH,+FAA+F;AAC/F,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAqC,SAAS,QAAQ,CAAC,QAAQ,EAAE,GAAG;IAC1G,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9C,OAAO,CACL,KAAC,yBAAyB,IAAC,KAAK,EAAE,EAAE,MAAM,EAAE,YAC1C,KAAC,aAAa,OAAK,KAAK,EAAE,GAAG,EAAE,GAAG,GAAI,GACZ,CAC7B,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport {\n Label as AriaLabel,\n TextArea as AriaTextArea,\n TextField as AriaTextField,\n useLocale,\n type TextFieldProps as AriaTextFieldProps,\n} from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { limitExceededLabel, overLimitLabel } from \"../i18n\";\nimport { FieldDescription, FieldError, FieldLabel } from \"./field-parts\";\nimport { InputGroup } from \"./input-group\";\nimport { ComponentDefaultsProvider, splitRadius, type WithRadius } from \"../defaults\";\nimport { FIELD_STACK, INPUT } from \"./styles\";\nimport { useFieldValidation, type RequiredValidation } from \"./validation\";\nimport { splitDataAttributes } from \"./data-attributes\";\n\n/** The field is 72px minimum, grows with the content up to 240px, then scrolls (design). */\nexport const TEXTAREA_MIN_HEIGHT = 72;\nexport const TEXTAREA_MAX_HEIGHT = 240;\n/** The frame's block padding (`py-ds-100` × 2); the textarea itself gets the rest. */\nconst FRAME_PADDING = 16;\n\ntype TextAreaFieldProps = Omit<AriaTextFieldProps, \"className\" | \"style\" | \"children\" | \"maxLength\"> & {\n label: React.ReactNode;\n /**\n * Keeps the label for screen readers only: it still names the field, but takes no\n * space. For a field whose purpose the surface already shows, such as a chat reply box under its\n * conversation. A visible label stays the default.\n */\n isLabelHidden?: boolean;\n description?: React.ReactNode;\n errorMessage?: React.ReactNode;\n isOptional?: boolean;\n placeholder?: string;\n /**\n * Shows the counter. The user may type or paste past it; the field turns\n * invalid and blocks on submit, so pasted text is never cut silently.\n */\n maxLength?: number;\n /**\n * Shows the \"89 / 500\" count under the field; `true` by default whenever `maxLength`\n * is set. `false` hides only the visible count: the limit still marks the field invalid past\n * `maxLength`, and screen readers still hear when it is exceeded.\n */\n showCounter?: boolean;\n /**\n * Who says an empty required field is missing: `field` (default) or `app`. With `app` a DS\n * Form's `onSubmit` runs with the field empty, and the app's own error must clear on change. See\n * {@link RequiredValidation} for the whole contract.\n */\n requiredValidation?: RequiredValidation;\n};\n\n/** Grows the textarea to its content between the design's minimum and maximum height. */\nfunction measure(node: HTMLTextAreaElement) {\n node.style.height = \"auto\";\n const min = TEXTAREA_MIN_HEIGHT - FRAME_PADDING;\n const max = TEXTAREA_MAX_HEIGHT - FRAME_PADDING;\n node.style.height = `${Math.min(Math.max(node.scrollHeight, min), max)}px`;\n node.style.overflowY = node.scrollHeight > max ? \"auto\" : \"hidden\";\n}\n\n/** Re-measures on every value change and whenever the width changes (wrapping, fonts, layout). */\nfunction useAutoGrow(ref: React.RefObject<HTMLTextAreaElement | null>, value: string) {\n React.useLayoutEffect(() => {\n if (ref.current) measure(ref.current);\n }, [ref, value]);\n React.useEffect(() => {\n const node = ref.current;\n if (!node || typeof ResizeObserver === \"undefined\") return;\n let width = node.clientWidth;\n const observer = new ResizeObserver(() => {\n if (node.clientWidth !== width) {\n width = node.clientWidth;\n measure(node);\n }\n });\n observer.observe(node);\n return () => observer.disconnect();\n }, [ref]);\n}\n\n/** Multi-line text: notes, damage reports, messages. */\nconst TextAreaField = React.forwardRef<HTMLTextAreaElement, TextAreaFieldProps>(function TextAreaField(\n { label, isLabelHidden, description, errorMessage, isOptional, placeholder, maxLength, showCounter = true, value, defaultValue, onChange, validate, onBlur, requiredValidation, ...rest },\n forwardedRef,\n) {\n const { locale } = useLocale();\n const local = React.useRef<HTMLTextAreaElement | null>(null);\n const ref = React.useCallback(\n (node: HTMLTextAreaElement | null) => {\n local.current = node;\n if (typeof forwardedRef === \"function\") forwardedRef(node);\n else if (forwardedRef) forwardedRef.current = node;\n },\n [forwardedRef],\n );\n const [uncontrolled, setUncontrolled] = React.useState(defaultValue ?? \"\");\n const text = value ?? uncontrolled;\n useAutoGrow(local, text);\n\n const over = maxLength !== undefined ? text.length - maxLength : 0;\n const limitCheck = React.useCallback(\n (current: string) => {\n if (maxLength !== undefined && current.length > maxLength) return overLimitLabel(locale, current.length - maxLength);\n return validate?.(current);\n },\n [locale, maxLength, validate],\n );\n const timing = useFieldValidation<string>({\n validate: limitCheck,\n value: value,\n initialValue: value ?? defaultValue ?? \"\",\n isRequired: rest.isRequired,\n requiredValidation,\n onBlur: onBlur as ((event: React.FocusEvent) => void) | undefined,\n onChange,\n validationBehavior: rest.validationBehavior,\n });\n const counterId = React.useId();\n const counted = maxLength !== undefined && showCounter;\n const { wrapperProps, controlData } = splitDataAttributes(rest);\n\n return (\n <AriaTextField\n {...wrapperProps}\n value={text}\n onChange={(next) => {\n if (value === undefined) setUncontrolled(next);\n timing.onChange?.(next);\n }}\n validationBehavior={timing.validationBehavior}\n validate={timing.validate}\n onBlur={timing.onBlur}\n aria-describedby={[rest[\"aria-describedby\"], counted ? counterId : undefined].filter(Boolean).join(\" \") || undefined}\n data-slot=\"text-area\"\n className={FIELD_STACK}\n >\n {({ isInvalid, isDisabled }) => (\n <>\n {isLabelHidden ? (\n <AriaLabel data-slot=\"field-label\" className=\"sr-only\">\n {label}\n </AriaLabel>\n ) : (\n <FieldLabel isRequired={rest.isRequired} isOptional={isOptional}>\n {label}\n </FieldLabel>\n )}\n <InputGroup multiline isDisabled={isDisabled} isInvalid={isInvalid}>\n <AriaTextArea\n {...controlData}\n ref={ref}\n placeholder={placeholder}\n data-slot=\"text-area-input\"\n className={cn(INPUT, \"text-body resize-none\")}\n style={{ minHeight: TEXTAREA_MIN_HEIGHT - FRAME_PADDING }}\n />\n </InputGroup>\n {(description || counted) && (\n <div className=\"flex items-start justify-between gap-ds-200\">\n {description ? <FieldDescription>{description}</FieldDescription> : <span />}\n {counted && (\n <span\n id={counterId}\n data-slot=\"text-area-counter\"\n // \"89 / 500\" in every locale: on an RTL page the bidi algorithm would show \"500 / 89\".\n dir=\"ltr\"\n className={cn(\"shrink-0 text-body-small tabular-nums\", over > 0 ? \"text-ds-text-danger\" : \"text-ds-text-subtlest\")}\n >\n {new Intl.NumberFormat(locale).format(text.length)} / {new Intl.NumberFormat(locale).format(maxLength)}\n </span>\n )}\n </div>\n )}\n {maxLength !== undefined && (\n <span aria-live=\"polite\" data-slot=\"text-area-limit-status\" className=\"sr-only\">\n {over > 0 ? limitExceededLabel(locale) : \"\"}\n </span>\n )}\n <FieldError>{over > 0 ? undefined : errorMessage}</FieldError>\n </>\n )}\n </AriaTextField>\n );\n});\n\nexport type TextAreaProps = TextAreaFieldProps & WithRadius;\n\n/** Several lines of text, with a label, description, error and an optional character count. */\nexport const TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(function TextArea(allProps, ref) {\n const [radius, props] = splitRadius(allProps);\n return (\n <ComponentDefaultsProvider value={{ radius }}>\n <TextAreaField {...props} ref={ref} />\n </ComponentDefaultsProvider>\n );\n});\n"]}
@@ -0,0 +1,131 @@
1
+ import * as React from "react";
2
+ import { type TextFieldProps as AriaTextFieldProps } from "react-aria-components";
3
+ import { type FieldSize } from "./styles.js";
4
+ import { type RequiredValidation } from "./validation.js";
5
+ export type TextFieldProps = Omit<AriaTextFieldProps, "className" | "style" | "children"> & {
6
+ /** Always given; the label sits above the field, never inside it. */
7
+ label: React.ReactNode;
8
+ description?: React.ReactNode;
9
+ /** What happened and what to do ("Enter a valid email: name@example.com"). */
10
+ errorMessage?: React.ReactNode;
11
+ /** Shows "(optional)" when most of the form is required. */
12
+ isOptional?: boolean;
13
+ /**
14
+ * Who says an empty required field is missing: `field` (default) or `app`. With `app` a DS
15
+ * Form's `onSubmit` runs with the field empty, and the app's own error must clear on change. See
16
+ * {@link RequiredValidation} for the whole contract.
17
+ */
18
+ requiredValidation?: RequiredValidation;
19
+ placeholder?: string;
20
+ /** Before the value, inside the frame: text, a unit or currency ("€", "https://"), or `<Icon name="search" />`. */
21
+ leading?: React.ReactNode;
22
+ /** After the value, inside the frame: a unit ("kg"), a domain, an icon. */
23
+ trailing?: React.ReactNode;
24
+ /** Extra controls at the end of the frame (`InputAction`). */
25
+ actions?: React.ReactNode;
26
+ size?: FieldSize;
27
+ /** `code` for codes, references and IDs; `numeric` for money, distance and counts. */
28
+ variant?: "text" | "code" | "numeric";
29
+ /**
30
+ * `uppercase` shows the value in capitals (a code: "ab 123" reads "AB 123"); display only
31
+ *. The input's value, `onChange` and the submitted form value stay exactly as
32
+ * typed; the caret and selection follow the text as drawn. Capitals follow the page's language, as CSS
33
+ * `text-transform` does (`lang="tr"`: "i" shows as "İ"), the same as `toLocaleUpperCase` in that locale. The
34
+ * placeholder keeps its own case. Normalise the stored value in the app if it must be capitals.
35
+ */
36
+ displayCase?: "uppercase";
37
+ /**
38
+ * Mobile keyboards' capitalization: `none` for e-mail and codes, `characters` for codes, `words` for names.
39
+ * React Aria's TextField forwards it to the input (useTextField reads it); its types leave it out, so it is declared here.
40
+ */
41
+ autoCapitalize?: React.InputHTMLAttributes<HTMLInputElement>["autoCapitalize"];
42
+ /**
43
+ * Set by a form row that owns the error text (the shared `Field` hands its control `aria-invalid`): the field
44
+ * shows its invalid state as with `isInvalid`, and without an `errorMessage` of its own draws no error row,
45
+ * so the row's message is the only one. It marks the input for assistive tech and draws it
46
+ * invalid only: unlike `isInvalid` it never becomes the input's native validity, so it never blocks a form's
47
+ * submit, and the field's own validation runs as without it.
48
+ */
49
+ "aria-invalid"?: boolean | "true" | "false";
50
+ /** Bounds and step for `type="number"`; prefer NumberField for money and counts that need formatting. */
51
+ min?: number | string;
52
+ max?: number | string;
53
+ step?: number | string;
54
+ /**
55
+ * `ltr` keeps the frame, addons and value, left to right on an RTL page: phone numbers, IBANs and
56
+ * card numbers read LTR in every locale ("ME +382 67 412 908", never "908 412 67 ME +382"). The
57
+ * label, help text and error still follow the page. On by default for `type` `url`, `email` and `tel`
58
+ * (the placeholder then aligns LTR too); `inherit` turns that off and follows the page. Pass `ltr` for a
59
+ * domain with URL addons: "https://shop.example.com", never "com. shop.example //:https".
60
+ */
61
+ valueDir?: "ltr" | "inherit";
62
+ };
63
+ /** Type per appearance: `code` is the design's code style (Geist 13/20, tabular figures). */
64
+ export declare const APPEARANCE: {
65
+ readonly text: "text-body";
66
+ readonly code: "font-ds-mono text-code";
67
+ readonly numeric: "text-body tabular-nums";
68
+ };
69
+ /**
70
+ * One line of text with a visible label, optional help text and an inline
71
+ * error. React Aria wires label, description and error to the input and
72
+ * sets `aria-invalid`; errors show on blur and on submit (the Form default).
73
+ */
74
+ export declare const TextField: React.ForwardRefExoticComponent<Omit<AriaTextFieldProps, "children" | "style" | "className"> & {
75
+ /** Always given; the label sits above the field, never inside it. */
76
+ label: React.ReactNode;
77
+ description?: React.ReactNode;
78
+ /** What happened and what to do ("Enter a valid email: name@example.com"). */
79
+ errorMessage?: React.ReactNode;
80
+ /** Shows "(optional)" when most of the form is required. */
81
+ isOptional?: boolean;
82
+ /**
83
+ * Who says an empty required field is missing: `field` (default) or `app`. With `app` a DS
84
+ * Form's `onSubmit` runs with the field empty, and the app's own error must clear on change. See
85
+ * {@link RequiredValidation} for the whole contract.
86
+ */
87
+ requiredValidation?: RequiredValidation;
88
+ placeholder?: string;
89
+ /** Before the value, inside the frame: text, a unit or currency ("€", "https://"), or `<Icon name="search" />`. */
90
+ leading?: React.ReactNode;
91
+ /** After the value, inside the frame: a unit ("kg"), a domain, an icon. */
92
+ trailing?: React.ReactNode;
93
+ /** Extra controls at the end of the frame (`InputAction`). */
94
+ actions?: React.ReactNode;
95
+ size?: FieldSize;
96
+ /** `code` for codes, references and IDs; `numeric` for money, distance and counts. */
97
+ variant?: "text" | "code" | "numeric";
98
+ /**
99
+ * `uppercase` shows the value in capitals (a code: "ab 123" reads "AB 123"); display only
100
+ *. The input's value, `onChange` and the submitted form value stay exactly as
101
+ * typed; the caret and selection follow the text as drawn. Capitals follow the page's language, as CSS
102
+ * `text-transform` does (`lang="tr"`: "i" shows as "İ"), the same as `toLocaleUpperCase` in that locale. The
103
+ * placeholder keeps its own case. Normalise the stored value in the app if it must be capitals.
104
+ */
105
+ displayCase?: "uppercase";
106
+ /**
107
+ * Mobile keyboards' capitalization: `none` for e-mail and codes, `characters` for codes, `words` for names.
108
+ * React Aria's TextField forwards it to the input (useTextField reads it); its types leave it out, so it is declared here.
109
+ */
110
+ autoCapitalize?: React.InputHTMLAttributes<HTMLInputElement>["autoCapitalize"];
111
+ /**
112
+ * Set by a form row that owns the error text (the shared `Field` hands its control `aria-invalid`): the field
113
+ * shows its invalid state as with `isInvalid`, and without an `errorMessage` of its own draws no error row,
114
+ * so the row's message is the only one. It marks the input for assistive tech and draws it
115
+ * invalid only: unlike `isInvalid` it never becomes the input's native validity, so it never blocks a form's
116
+ * submit, and the field's own validation runs as without it.
117
+ */
118
+ "aria-invalid"?: boolean | "true" | "false";
119
+ /** Bounds and step for `type="number"`; prefer NumberField for money and counts that need formatting. */
120
+ min?: number | string;
121
+ max?: number | string;
122
+ step?: number | string;
123
+ /**
124
+ * `ltr` keeps the frame, addons and value, left to right on an RTL page: phone numbers, IBANs and
125
+ * card numbers read LTR in every locale ("ME +382 67 412 908", never "908 412 67 ME +382"). The
126
+ * label, help text and error still follow the page. On by default for `type` `url`, `email` and `tel`
127
+ * (the placeholder then aligns LTR too); `inherit` turns that off and follows the page. Pass `ltr` for a
128
+ * domain with URL addons: "https://shop.example.com", never "com. shop.example //:https".
129
+ */
130
+ valueDir?: "ltr" | "inherit";
131
+ } & React.RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,59 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { Input, TextField as AriaTextField } from "react-aria-components";
5
+ import { isIconElement } from "../display/icon.js";
6
+ import { cn } from "../utils.js";
7
+ import { useFieldSize } from "../defaults.js";
8
+ import { ControlFieldError, FieldDescription, FieldLabel, forwardedInvalid, useErrorRowLink } from "./field-parts.js";
9
+ import { InputAddon, InputGroup } from "./input-group.js";
10
+ import { FIELD_ICON, FIELD_STACK, INPUT } from "./styles.js";
11
+ import { useFieldValidation } from "./validation.js";
12
+ import { splitDataAttributes } from "./data-attributes.js";
13
+ /**
14
+ * An `<Icon>` sits in the field as a subtle mark with the same slot as
15
+ * SearchField's icon; text and other nodes become an addon. Pass the
16
+ * `<Icon>` element itself (a wrapper component would read as an addon).
17
+ */
18
+ function Affix({ value, position }) {
19
+ if (isIconElement(value)) {
20
+ return React.cloneElement(value, {
21
+ "data-slot": "field-icon",
22
+ color: value.props.color ?? "subtle",
23
+ });
24
+ }
25
+ return _jsx(InputAddon, { position: position, children: value });
26
+ }
27
+ /** Values that read left to right in every locale. */
28
+ const LTR_TYPES = new Set(["url", "email", "tel"]);
29
+ /** Type per appearance: `code` is the design's code style (Geist 13/20, tabular figures). */
30
+ export const APPEARANCE = {
31
+ text: "text-body",
32
+ code: "font-ds-mono text-code",
33
+ numeric: "text-body tabular-nums",
34
+ };
35
+ /** Capitals on the drawn value only; the placeholder keeps its case. */
36
+ const DISPLAY_UPPERCASE = "uppercase placeholder:normal-case";
37
+ /**
38
+ * One line of text with a visible label, optional help text and an inline
39
+ * error. React Aria wires label, description and error to the input and
40
+ * sets `aria-invalid`; errors show on blur and on submit (the Form default).
41
+ */
42
+ export const TextField = React.forwardRef(function TextField({ label, description, errorMessage, isOptional, placeholder, leading: prefix, trailing: suffix, actions, size: fieldSize, variant: appearance = "text", displayCase, min, max, step, valueDir, validate, onBlur, onChange, "aria-invalid": ariaInvalid, requiredValidation, ...rest }, ref) {
43
+ const size = useFieldSize(fieldSize);
44
+ const timing = useFieldValidation({
45
+ validate,
46
+ value: rest.value,
47
+ initialValue: rest.value ?? rest.defaultValue ?? "",
48
+ isRequired: rest.isRequired,
49
+ requiredValidation,
50
+ onBlur: onBlur,
51
+ onChange,
52
+ validationBehavior: rest.validationBehavior,
53
+ });
54
+ const forwarded = forwardedInvalid(ariaInvalid, rest.render);
55
+ const { wrapperProps, controlData } = splitDataAttributes(rest);
56
+ const errorRowLink = useErrorRowLink(forwarded.invalid, errorMessage);
57
+ return (_jsx(AriaTextField, { ...wrapperProps, ...forwarded.fieldProps, ...errorRowLink, validationBehavior: timing.validationBehavior, validate: timing.validate, onBlur: timing.onBlur, onChange: timing.onChange, "data-slot": "text-field", className: FIELD_STACK, children: ({ isInvalid, isDisabled }) => (_jsxs(_Fragment, { children: [_jsx(FieldLabel, { isRequired: rest.isRequired, isOptional: isOptional, children: label }), _jsxs(InputGroup, { size: size, isDisabled: isDisabled, isInvalid: isInvalid || forwarded.invalid, dir: valueDir === "inherit" ? undefined : (valueDir ?? (LTR_TYPES.has(rest.type ?? "") ? "ltr" : undefined)), children: [prefix !== undefined && _jsx(Affix, { value: prefix, position: "start" }), _jsx(Input, { ...controlData, ref: ref, ...(forwarded.invalid ? { "aria-invalid": true } : null), placeholder: placeholder, min: min, max: max, step: step, "data-slot": "text-field-input", className: cn(INPUT, APPEARANCE[appearance], displayCase === "uppercase" && DISPLAY_UPPERCASE) }), suffix !== undefined && _jsx(Affix, { value: suffix, position: "end" }), actions] }), description && _jsx(FieldDescription, { children: description }), _jsx(ControlFieldError, { forwardedInvalid: forwarded.invalid, children: errorMessage })] })) }));
58
+ });
59
+ //# sourceMappingURL=text-field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-field.js","sourceRoot":"","sources":["../../src/form/text-field.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAA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AW,GAAoB,EAClE,KAAC,iBAAiB,IAAC,gBAAgB,EAAE,SAAS,CAAC,OAAO,YAAG,YAAY,GAAqB,IACzF,CACJ,GACa,CACjB,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Input, TextField as AriaTextField, type TextFieldProps as AriaTextFieldProps } from \"react-aria-components\";\nimport { isIconElement } from \"../display/icon\";\n\nimport { cn } from \"../utils\";\nimport { useFieldSize } from \"../defaults\";\nimport { ControlFieldError, FieldDescription, FieldLabel, forwardedInvalid, useErrorRowLink } from \"./field-parts\";\nimport { InputAddon, InputGroup } from \"./input-group\";\nimport { FIELD_ICON, FIELD_STACK, INPUT, type FieldSize } from \"./styles\";\nimport { useFieldValidation, type RequiredValidation } from \"./validation\";\nimport { splitDataAttributes } from \"./data-attributes\";\n\nexport type TextFieldProps = Omit<AriaTextFieldProps, \"className\" | \"style\" | \"children\"> & {\n /** Always given; the label sits above the field, never inside it. */\n label: React.ReactNode;\n description?: React.ReactNode;\n /** What happened and what to do (\"Enter a valid email: name@example.com\"). */\n errorMessage?: React.ReactNode;\n /** Shows \"(optional)\" when most of the form is required. */\n isOptional?: boolean;\n /**\n * Who says an empty required field is missing: `field` (default) or `app`. With `app` a DS\n * Form's `onSubmit` runs with the field empty, and the app's own error must clear on change. See\n * {@link RequiredValidation} for the whole contract.\n */\n requiredValidation?: RequiredValidation;\n placeholder?: string;\n /** Before the value, inside the frame: text, a unit or currency (\"€\", \"https://\"), or `<Icon name=\"search\" />`. */\n leading?: React.ReactNode;\n /** After the value, inside the frame: a unit (\"kg\"), a domain, an icon. */\n trailing?: React.ReactNode;\n /** Extra controls at the end of the frame (`InputAction`). */\n actions?: React.ReactNode;\n size?: FieldSize;\n /** `code` for codes, references and IDs; `numeric` for money, distance and counts. */\n variant?: \"text\" | \"code\" | \"numeric\";\n /**\n * `uppercase` shows the value in capitals (a code: \"ab 123\" reads \"AB 123\"); display only\n *. The input's value, `onChange` and the submitted form value stay exactly as\n * typed; the caret and selection follow the text as drawn. Capitals follow the page's language, as CSS\n * `text-transform` does (`lang=\"tr\"`: \"i\" shows as \"İ\"), the same as `toLocaleUpperCase` in that locale. The\n * placeholder keeps its own case. Normalise the stored value in the app if it must be capitals.\n */\n displayCase?: \"uppercase\";\n /**\n * Mobile keyboards' capitalization: `none` for e-mail and codes, `characters` for codes, `words` for names.\n * React Aria's TextField forwards it to the input (useTextField reads it); its types leave it out, so it is declared here.\n */\n autoCapitalize?: React.InputHTMLAttributes<HTMLInputElement>[\"autoCapitalize\"];\n /**\n * Set by a form row that owns the error text (the shared `Field` hands its control `aria-invalid`): the field\n * shows its invalid state as with `isInvalid`, and without an `errorMessage` of its own draws no error row,\n * so the row's message is the only one. It marks the input for assistive tech and draws it\n * invalid only: unlike `isInvalid` it never becomes the input's native validity, so it never blocks a form's\n * submit, and the field's own validation runs as without it.\n */\n \"aria-invalid\"?: boolean | \"true\" | \"false\";\n /** Bounds and step for `type=\"number\"`; prefer NumberField for money and counts that need formatting. */\n min?: number | string;\n max?: number | string;\n step?: number | string;\n /**\n * `ltr` keeps the frame, addons and value, left to right on an RTL page: phone numbers, IBANs and\n * card numbers read LTR in every locale (\"ME +382 67 412 908\", never \"908 412 67 ME +382\"). The\n * label, help text and error still follow the page. On by default for `type` `url`, `email` and `tel`\n * (the placeholder then aligns LTR too); `inherit` turns that off and follows the page. Pass `ltr` for a\n * domain with URL addons: \"https://shop.example.com\", never \"com. shop.example //:https\".\n */\n valueDir?: \"ltr\" | \"inherit\";\n};\n\n/**\n * An `<Icon>` sits in the field as a subtle mark with the same slot as\n * SearchField's icon; text and other nodes become an addon. Pass the\n * `<Icon>` element itself (a wrapper component would read as an addon).\n */\nfunction Affix({ value, position }: { value: React.ReactNode; position: \"start\" | \"end\" }) {\n if (isIconElement(value)) {\n return React.cloneElement(value as React.ReactElement<Record<string, unknown>>, {\n \"data-slot\": \"field-icon\",\n color: value.props.color ?? \"subtle\",\n });\n }\n return <InputAddon position={position}>{value}</InputAddon>;\n}\n\n/** Values that read left to right in every locale. */\nconst LTR_TYPES = new Set([\"url\", \"email\", \"tel\"]);\n\n/** Type per appearance: `code` is the design's code style (Geist 13/20, tabular figures). */\nexport const APPEARANCE = {\n text: \"text-body\",\n code: \"font-ds-mono text-code\",\n numeric: \"text-body tabular-nums\",\n} as const;\n\n/** Capitals on the drawn value only; the placeholder keeps its case. */\nconst DISPLAY_UPPERCASE = \"uppercase placeholder:normal-case\";\n\n/**\n * One line of text with a visible label, optional help text and an inline\n * error. React Aria wires label, description and error to the input and\n * sets `aria-invalid`; errors show on blur and on submit (the Form default).\n */\nexport const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(function TextField(\n {\n label, description, errorMessage, isOptional, placeholder, leading: prefix, trailing: suffix, actions, size: fieldSize, variant: appearance = \"text\", displayCase,\n min, max, step, valueDir, validate, onBlur, onChange, \"aria-invalid\": ariaInvalid, requiredValidation, ...rest\n },\n ref,\n) {\n const size = useFieldSize(fieldSize);\n const timing = useFieldValidation({\n validate,\n value: rest.value,\n initialValue: rest.value ?? rest.defaultValue ?? \"\",\n isRequired: rest.isRequired,\n requiredValidation,\n onBlur: onBlur as ((event: React.FocusEvent) => void) | undefined,\n onChange,\n validationBehavior: rest.validationBehavior,\n });\n const forwarded = forwardedInvalid(ariaInvalid, rest.render);\n const { wrapperProps, controlData } = splitDataAttributes(rest);\n const errorRowLink = useErrorRowLink(forwarded.invalid, errorMessage);\n return (\n <AriaTextField {...wrapperProps} {...forwarded.fieldProps} {...errorRowLink} validationBehavior={timing.validationBehavior}\n validate={timing.validate} onBlur={timing.onBlur} onChange={timing.onChange} data-slot=\"text-field\" className={FIELD_STACK}>\n {({ isInvalid, isDisabled }) => (\n <>\n <FieldLabel isRequired={rest.isRequired} isOptional={isOptional}>\n {label}\n </FieldLabel>\n <InputGroup size={size} isDisabled={isDisabled} isInvalid={isInvalid || forwarded.invalid} dir={valueDir === \"inherit\" ? undefined : (valueDir ?? (LTR_TYPES.has(rest.type ?? \"\") ? \"ltr\" : undefined))}>\n {prefix !== undefined && <Affix value={prefix} position=\"start\" />}\n <Input\n {...controlData}\n ref={ref}\n {...(forwarded.invalid ? { \"aria-invalid\": true } : null)}\n placeholder={placeholder}\n min={min}\n max={max}\n step={step}\n data-slot=\"text-field-input\"\n className={cn(INPUT, APPEARANCE[appearance], displayCase === \"uppercase\" && DISPLAY_UPPERCASE)}\n />\n {suffix !== undefined && <Affix value={suffix} position=\"end\" />}\n {actions}\n </InputGroup>\n {description && <FieldDescription>{description}</FieldDescription>}\n <ControlFieldError forwardedInvalid={forwarded.invalid}>{errorMessage}</ControlFieldError>\n </>\n )}\n </AriaTextField>\n );\n});\n"]}
@@ -0,0 +1,145 @@
1
+ import * as React from "react";
2
+ /**
3
+ * Form-wide state the fields read: `submitted` turns on every field's errors
4
+ * at the first submit; `resetCount` changes on form reset so fields forget
5
+ * what they showed; `inForm` is true only inside a DS Form (PhoneField's required check).
6
+ */
7
+ export declare const FormSubmittedContext: React.Context<{
8
+ submitted: boolean;
9
+ resetCount: number;
10
+ inForm: boolean;
11
+ }>;
12
+ type ValidationResult = string | string[] | true | null | undefined;
13
+ type Validate<T> = ((value: T) => ValidationResult) | undefined;
14
+ /**
15
+ * Who says an empty required field is missing: the `requiredValidation` prop of TextField,
16
+ * PasswordField, TextArea, NumberField, OtpField, DateField, TimeField, DatePicker and DateRangePicker, and since
17
+ * of Select, MultiSelect, ComboBox, Autocomplete, RadioGroup, Checkbox, CheckboxGroup,
18
+ * ColorField and PhoneField (empty there: no chosen item, no tag, nothing checked; see {@link useRequiredChoice}).
19
+ *
20
+ * - `field` (default): the field itself, with "Fill in this field." on blur and on a DS Form submit, which it
21
+ * then blocks.
22
+ * - `app`: `isRequired` only marks the field (the label's `*`, `aria-required`); an empty value is never the
23
+ * field's error, on blur or on submit. A DS Form's `onSubmit` therefore runs with the field empty: the app
24
+ * checks it there and shows its own error through `isInvalid` and `errorMessage`.
25
+ *
26
+ * The app's error must clear as soon as the value changes: a DS Form never calls `onSubmit` while any field
27
+ * is `aria-invalid` (form.tsx), so an error left on after the user filled the field blocks every later submit.
28
+ *
29
+ * The app's own `isInvalid`, with either value, overrides the field's required check (React Aria's controlled
30
+ * `isInvalid`), on every field listed here and with either `requiredValidation`:
31
+ * - `isInvalid` with an `errorMessage`: the app's message is the one shown, never "Fill in this field.";
32
+ * - `isInvalid={false}`: the field is valid however empty it is, and does not block a DS Form's submit. On the text,
33
+ * number and date fields it also overrides `validate`, `maxLength` and the impossible date; PhoneField's own
34
+ * length check still shows. So when there is no error, pass `isInvalid={undefined}` (or leave it out) to keep the
35
+ * field's checks; pass `false` only when the app owns the field's validity.
36
+ * PhoneField also counts an `errorMessage` passed without `isInvalid` as the app's error (its own contract: the
37
+ * message makes it invalid); on the other fields such a message shows only when the field is invalid, and the
38
+ * field's own message wins.
39
+ *
40
+ * A required field that is empty and disabled is still empty: with `field` it blocks a DS Form's submit like any
41
+ * other, and since a disabled control cannot take focus the form moves focus nowhere for it (TextField's behaviour
42
+ * since, the selection fields' since). Drop `isRequired` while the field is disabled, fill
43
+ * it, or use `app`.
44
+ *
45
+ * `validate`, TextArea's `maxLength` and the date fields' impossible-date message keep their timing (blur and
46
+ * submit) with either value. With `validationBehavior="native"` the browser owns required and this has no effect,
47
+ * except on PhoneField, which never uses native validity: inside any DS Form (`aria` or `native`) it runs the DS
48
+ * check, and outside a DS Form it shows nothing for an empty value.
49
+ */
50
+ export type RequiredValidation = "field" | "app";
51
+ type Options<T> = {
52
+ validate: Validate<T>;
53
+ /** The field's starting value (`value ?? defaultValue`), so a blur on an untouched field is judged correctly. */
54
+ initialValue?: T;
55
+ /** The controlled value, when the field is controlled. */
56
+ value?: T;
57
+ isRequired?: boolean;
58
+ /** `app`: `isRequired` only marks the field; the empty value is never this hook's error. */
59
+ requiredValidation?: RequiredValidation;
60
+ onBlur?: (event: React.FocusEvent) => void;
61
+ onChange?: (value: T) => void;
62
+ validationBehavior?: "aria" | "native";
63
+ };
64
+ /**
65
+ * The design's timing (Form README): errors appear on blur and on submit, never
66
+ * while typing. Once a blur has shown an error, the message stays current
67
+ * while the user edits and disappears the moment the value is valid; after
68
+ * that, a new error waits for the next blur. After the first submit every
69
+ * field shows its current error live (the user asked to submit).
70
+ *
71
+ * `isRequired` is checked here too: React Aria's `aria` behaviour only sets
72
+ * `aria-required`, so an empty required field would otherwise never be
73
+ * invalid and never block submit. With `requiredValidation: "app"` it is not: the field stays marked
74
+ * required (the label's `*` and React Aria's `aria-required`, both from `isRequired`), but an empty value is
75
+ * never an error here, on blur or on submit; the app validates and passes `isInvalid` / `errorMessage`.
76
+ *
77
+ * With `validationBehavior="native"` the browser owns the timing, so the
78
+ * field's `validate` is passed through untouched.
79
+ */
80
+ export declare function useFieldValidation<T>({ validate, initialValue, value: controlled, isRequired, requiredValidation, onBlur, onChange, validationBehavior, }: Options<T>): {
81
+ validationBehavior: "native";
82
+ validate: Validate<T>;
83
+ onBlur: ((event: React.FocusEvent) => void) | undefined;
84
+ onChange: ((value: T) => void) | undefined;
85
+ } | {
86
+ validationBehavior: "aria";
87
+ validate: (value: T) => string | string[] | null;
88
+ onChange: (value: T) => void;
89
+ onBlur: (event: React.FocusEvent) => void;
90
+ };
91
+ type RequiredChoiceOptions = {
92
+ /** Whether the field holds a value: a chosen key, a tag, a checked box, a typed text or number. */
93
+ filled: boolean;
94
+ isRequired?: boolean;
95
+ requiredValidation?: RequiredValidation;
96
+ /**
97
+ * The caller's own `isInvalid`. Set (`true` or `false`), it owns the field's validity and the required check
98
+ * stays out, as React Aria's controlled `isInvalid` does on TextField; unset, it is `undefined` here too.
99
+ */
100
+ isInvalid?: boolean;
101
+ /** The caller's own `errorMessage`: shown with its `isInvalid`, and whenever the field has no required error. */
102
+ errorMessage?: React.ReactNode;
103
+ /**
104
+ * The field's own `validationBehavior`, when it has one (PhoneField passes `aria` inside a DS Form and `native`
105
+ * outside one). Unset, the surrounding form's, else React Aria's default (`native`).
106
+ */
107
+ validationBehavior?: "aria" | "native";
108
+ onBlur?: (event: React.FocusEvent) => void;
109
+ };
110
+ /**
111
+ * "Required" for the fields React Aria never finds empty under `aria` validation: Select,
112
+ * MultiSelect, ComboBox, Autocomplete, RadioGroup, Checkbox, CheckboxGroup, ColorField and
113
+ * PhoneField. React Aria's `aria` behaviour has no required check of its own (the browser's `valueMissing` is
114
+ * read only under `native`), and it never runs `validate` on an empty selection (a null key, no keys), so an
115
+ * empty required field of these was never invalid: a DS Form called `onSubmit` with it empty, showed nothing and
116
+ * focused nothing. The text, number and date fields have their check in {@link useFieldValidation}; these get the
117
+ * same one, with the same timing and the same `requiredValidation` opt-out:
118
+ *
119
+ * - an empty required field shows "Fill in this field." after a blur that leaves it empty, and from a DS Form's
120
+ * first submit on, which it then blocks (the form focuses the first invalid field, in document order);
121
+ * - a value clears the message at once; after a blur-shown error is cleared, a new one waits for the next blur;
122
+ * - a form reset hides it again;
123
+ * - `requiredValidation="app"`: `isRequired` only marks the field (the label's `*`, `aria-required`).
124
+ *
125
+ * The field is then marked invalid through React Aria's controlled `isInvalid` (its `data-invalid`, the input's
126
+ * `aria-invalid`), with the message as its error. The caller's own `isInvalid`, `true` or `false`, overrides the
127
+ * check, as on TextField (see {@link RequiredValidation}): `true` with its `errorMessage` shows the app's message,
128
+ * never the DS one, and `false` keeps the field valid. Without a required error the caller's `isInvalid` and
129
+ * `errorMessage` pass through unchanged, so a form's server errors (`validationErrors`) still show. Under `native`
130
+ * validation the browser owns required (React Aria's hidden select or input carries `required`) and nothing here
131
+ * applies.
132
+ */
133
+ export declare function useRequiredChoice({ filled, isRequired, requiredValidation, isInvalid, errorMessage, validationBehavior, onBlur, }: RequiredChoiceOptions): {
134
+ isInvalid: boolean | undefined;
135
+ errorMessage: React.ReactNode;
136
+ onBlur: ((event: React.FocusEvent) => void) | ((event: React.FocusEvent) => void) | undefined;
137
+ /**
138
+ * Whether this hook's required message can appear on the field: `isRequired`, `aria` validation (a DS Form's, or
139
+ * the field's own), `requiredValidation` not `app`, and no `isInvalid` from the app. A field whose error sits in an
140
+ * always-mounted live region (a lone Checkbox) keeps that region mounted, empty, while this is true,
141
+ * so the message appears inside the same node and is announced.
142
+ */
143
+ checksRequired: boolean;
144
+ };
145
+ export {};
@@ -0,0 +1,136 @@
1
+ "use client";
2
+ import * as React from "react";
3
+ import { FormContext, useLocale } from "react-aria-components";
4
+ import { requiredLabel } from "../i18n.js";
5
+ /**
6
+ * Form-wide state the fields read: `submitted` turns on every field's errors
7
+ * at the first submit; `resetCount` changes on form reset so fields forget
8
+ * what they showed; `inForm` is true only inside a DS Form (PhoneField's required check).
9
+ */
10
+ export const FormSubmittedContext = React.createContext({ submitted: false, resetCount: 0, inForm: false });
11
+ const isEmptyValue = (value) => value === undefined || value === null || (typeof value === "number" && Number.isNaN(value)) ||
12
+ (typeof value === "string" && value.trim() === "");
13
+ function firstError(result) {
14
+ if (result === true || result === null || result === undefined)
15
+ return null;
16
+ if (Array.isArray(result))
17
+ return result.length ? result : null;
18
+ return result || null;
19
+ }
20
+ /**
21
+ * The design's timing (Form README): errors appear on blur and on submit, never
22
+ * while typing. Once a blur has shown an error, the message stays current
23
+ * while the user edits and disappears the moment the value is valid; after
24
+ * that, a new error waits for the next blur. After the first submit every
25
+ * field shows its current error live (the user asked to submit).
26
+ *
27
+ * `isRequired` is checked here too: React Aria's `aria` behaviour only sets
28
+ * `aria-required`, so an empty required field would otherwise never be
29
+ * invalid and never block submit. With `requiredValidation: "app"` it is not: the field stays marked
30
+ * required (the label's `*` and React Aria's `aria-required`, both from `isRequired`), but an empty value is
31
+ * never an error here, on blur or on submit; the app validates and passes `isInvalid` / `errorMessage`.
32
+ *
33
+ * With `validationBehavior="native"` the browser owns the timing, so the
34
+ * field's `validate` is passed through untouched.
35
+ */
36
+ export function useFieldValidation({ validate, initialValue, value: controlled, isRequired, requiredValidation = "field", onBlur, onChange, validationBehavior, }) {
37
+ const { locale } = useLocale();
38
+ const { submitted, resetCount } = React.useContext(FormSubmittedContext);
39
+ const form = React.useContext(FormContext);
40
+ const behavior = validationBehavior ?? form?.validationBehavior ?? "aria";
41
+ // True from a blur that found an error until the value is valid again.
42
+ const [showing, setShowing] = React.useState(false);
43
+ // React's "adjust state on a prop change" pattern, so a discarded render cannot lose a reset.
44
+ const [seenReset, setSeenReset] = React.useState(resetCount);
45
+ if (seenReset !== resetCount) {
46
+ setSeenReset(resetCount);
47
+ setShowing(false);
48
+ }
49
+ const latest = React.useRef(initialValue);
50
+ // A reset puts the field back to its initial value; the next blur judges that, not the last typed one.
51
+ const resetFor = React.useRef(resetCount);
52
+ if (resetFor.current !== resetCount) {
53
+ resetFor.current = resetCount;
54
+ latest.current = initialValue;
55
+ }
56
+ if (controlled !== undefined)
57
+ latest.current = controlled;
58
+ const check = React.useCallback((value) => {
59
+ if (isRequired && requiredValidation !== "app" && isEmptyValue(value))
60
+ return requiredLabel(locale);
61
+ return firstError(validate?.(value));
62
+ }, [isRequired, requiredValidation, locale, validate]);
63
+ if (behavior === "native") {
64
+ return { validationBehavior: behavior, validate, onBlur, onChange: onChange ? (value) => onChange(value) : undefined };
65
+ }
66
+ return {
67
+ validationBehavior: behavior,
68
+ validate: (value) => {
69
+ const error = check(value);
70
+ return error && (submitted || showing) ? error : null;
71
+ },
72
+ onChange: (value) => {
73
+ latest.current = value;
74
+ if (showing && !check(value))
75
+ setShowing(false);
76
+ onChange?.(value);
77
+ },
78
+ onBlur: (event) => {
79
+ // Only a blur that leaves an error turns errors on; a valid blur keeps them hidden while typing.
80
+ setShowing(Boolean(check(latest.current)));
81
+ onBlur?.(event);
82
+ },
83
+ };
84
+ }
85
+ /**
86
+ * "Required" for the fields React Aria never finds empty under `aria` validation: Select,
87
+ * MultiSelect, ComboBox, Autocomplete, RadioGroup, Checkbox, CheckboxGroup, ColorField and
88
+ * PhoneField. React Aria's `aria` behaviour has no required check of its own (the browser's `valueMissing` is
89
+ * read only under `native`), and it never runs `validate` on an empty selection (a null key, no keys), so an
90
+ * empty required field of these was never invalid: a DS Form called `onSubmit` with it empty, showed nothing and
91
+ * focused nothing. The text, number and date fields have their check in {@link useFieldValidation}; these get the
92
+ * same one, with the same timing and the same `requiredValidation` opt-out:
93
+ *
94
+ * - an empty required field shows "Fill in this field." after a blur that leaves it empty, and from a DS Form's
95
+ * first submit on, which it then blocks (the form focuses the first invalid field, in document order);
96
+ * - a value clears the message at once; after a blur-shown error is cleared, a new one waits for the next blur;
97
+ * - a form reset hides it again;
98
+ * - `requiredValidation="app"`: `isRequired` only marks the field (the label's `*`, `aria-required`).
99
+ *
100
+ * The field is then marked invalid through React Aria's controlled `isInvalid` (its `data-invalid`, the input's
101
+ * `aria-invalid`), with the message as its error. The caller's own `isInvalid`, `true` or `false`, overrides the
102
+ * check, as on TextField (see {@link RequiredValidation}): `true` with its `errorMessage` shows the app's message,
103
+ * never the DS one, and `false` keeps the field valid. Without a required error the caller's `isInvalid` and
104
+ * `errorMessage` pass through unchanged, so a form's server errors (`validationErrors`) still show. Under `native`
105
+ * validation the browser owns required (React Aria's hidden select or input carries `required`) and nothing here
106
+ * applies.
107
+ */
108
+ export function useRequiredChoice({ filled, isRequired, requiredValidation, isInvalid, errorMessage, validationBehavior, onBlur, }) {
109
+ const form = React.useContext(FormContext);
110
+ const behavior = validationBehavior ?? form?.validationBehavior ?? "native";
111
+ const value = filled ? true : null;
112
+ const timing = useFieldValidation({ validate: undefined, value, initialValue: value, isRequired, requiredValidation, onBlur, validationBehavior: behavior });
113
+ // A change of value is the field's onChange for the timing: a value clears a blur-shown error.
114
+ const [seen, setSeen] = React.useState(filled);
115
+ if (seen !== filled) {
116
+ setSeen(filled);
117
+ timing.onChange?.(value);
118
+ }
119
+ // The app's controlled `isInvalid` owns validity, as React Aria's does on TextField: no DS required error then.
120
+ const appOwns = isInvalid !== undefined;
121
+ const error = behavior === "aria" && !appOwns ? (timing.validate?.(value) ?? null) : null;
122
+ const message = typeof error === "string" ? error : Array.isArray(error) ? error.join(" ") : null;
123
+ return {
124
+ isInvalid: message ? true : isInvalid,
125
+ errorMessage: message ?? errorMessage,
126
+ onBlur: timing.onBlur,
127
+ /**
128
+ * Whether this hook's required message can appear on the field: `isRequired`, `aria` validation (a DS Form's, or
129
+ * the field's own), `requiredValidation` not `app`, and no `isInvalid` from the app. A field whose error sits in an
130
+ * always-mounted live region (a lone Checkbox) keeps that region mounted, empty, while this is true,
131
+ * so the message appears inside the same node and is announced.
132
+ */
133
+ checksRequired: behavior === "aria" && !appOwns && Boolean(isRequired) && requiredValidation !== "app",
134
+ };
135
+ }
136
+ //# sourceMappingURL=validation.js.map