@nizivo/react 0.0.0-stage → 0.2.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 (461) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +120 -2
  3. package/THIRD_PARTY_NOTICES +68 -0
  4. package/dist/_engines/react-aria/dialog.client.js +126 -0
  5. package/dist/_engines/react-aria/dom-allowlist.js +19 -0
  6. package/dist/_engines/react-aria/dom.js +31 -0
  7. package/dist/_engines/react-aria/drawer.client.js +8 -0
  8. package/dist/_engines/react-aria/file-upload.client.js +50 -0
  9. package/dist/_engines/react-aria/locale.client.js +13 -0
  10. package/dist/_engines/react-aria/menu.client.js +229 -0
  11. package/dist/_engines/react-aria/open-state.client.js +53 -0
  12. package/dist/_engines/react-aria/outside-press.client.js +61 -0
  13. package/dist/_engines/react-aria/overlay.client.js +46 -0
  14. package/dist/_engines/react-aria/popover.client.js +148 -0
  15. package/dist/_engines/react-aria/popup.client.js +153 -0
  16. package/dist/_engines/react-aria/select.client.js +180 -0
  17. package/dist/_engines/react-aria/tabs.client.js +95 -0
  18. package/dist/_engines/react-aria/toast.client.js +38 -0
  19. package/dist/_engines/react-aria/tooltip.client.js +72 -0
  20. package/dist/_internal/cx.js +11 -0
  21. package/dist/_internal/data-status.d.ts +3 -0
  22. package/dist/_internal/data-status.js +13 -0
  23. package/dist/_internal/engine-part.d.ts +1 -0
  24. package/dist/_internal/field.js +20 -0
  25. package/dist/_internal/glyphs.js +87 -0
  26. package/dist/_internal/keys.js +62 -0
  27. package/dist/_internal/modal.client.js +54 -0
  28. package/dist/_internal/nested-focus.js +33 -0
  29. package/dist/_internal/overlay.d.ts +9 -0
  30. package/dist/_virtual/_rolldown/runtime.js +13 -0
  31. package/dist/alert/alert-dismiss.client.d.ts +32 -0
  32. package/dist/alert/alert-dismiss.client.js +38 -0
  33. package/dist/alert/alert.d.ts +28 -0
  34. package/dist/alert/alert.js +44 -0
  35. package/dist/alert/index.d.ts +3 -0
  36. package/dist/alert/index.js +3 -0
  37. package/dist/app-shell/app-shell.d.ts +24 -0
  38. package/dist/app-shell/app-shell.js +56 -0
  39. package/dist/app-shell/index.d.ts +2 -0
  40. package/dist/app-shell/index.js +1 -0
  41. package/dist/augment.d.ts +13 -0
  42. package/dist/augment.js +0 -0
  43. package/dist/avatar/avatar.d.ts +96 -0
  44. package/dist/avatar/avatar.js +94 -0
  45. package/dist/avatar/index.d.ts +2 -0
  46. package/dist/avatar/index.js +1 -0
  47. package/dist/badge/badge.d.ts +19 -0
  48. package/dist/badge/badge.js +22 -0
  49. package/dist/badge/index.d.ts +2 -0
  50. package/dist/badge/index.js +1 -0
  51. package/dist/banner/banner-dismiss.client.d.ts +32 -0
  52. package/dist/banner/banner-dismiss.client.js +38 -0
  53. package/dist/banner/banner.d.ts +34 -0
  54. package/dist/banner/banner.js +47 -0
  55. package/dist/banner/index.d.ts +3 -0
  56. package/dist/banner/index.js +3 -0
  57. package/dist/breadcrumb/breadcrumb.d.ts +46 -0
  58. package/dist/breadcrumb/breadcrumb.js +46 -0
  59. package/dist/breadcrumb/breadcrumb.parts.d.ts +6 -0
  60. package/dist/breadcrumb/breadcrumb.parts.js +9 -0
  61. package/dist/breadcrumb/index.d.ts +3 -0
  62. package/dist/breadcrumb/index.js +3 -0
  63. package/dist/button/button.d.ts +55 -0
  64. package/dist/button/button.js +62 -0
  65. package/dist/button/index.d.ts +2 -0
  66. package/dist/button/index.js +1 -0
  67. package/dist/card/card.d.ts +64 -0
  68. package/dist/card/card.js +62 -0
  69. package/dist/card/card.parts.d.ts +6 -0
  70. package/dist/card/card.parts.js +14 -0
  71. package/dist/card/index.d.ts +3 -0
  72. package/dist/card/index.js +3 -0
  73. package/dist/checkbox/checkbox.client.d.ts +37 -0
  74. package/dist/checkbox/checkbox.client.js +81 -0
  75. package/dist/checkbox/index.d.ts +2 -0
  76. package/dist/checkbox/index.js +1 -0
  77. package/dist/chip-group/chip-group.client.d.ts +88 -0
  78. package/dist/chip-group/chip-group.client.js +157 -0
  79. package/dist/chip-group/index.d.ts +2 -0
  80. package/dist/chip-group/index.js +1 -0
  81. package/dist/choice-card/choice-card.client.d.ts +66 -0
  82. package/dist/choice-card/choice-card.client.js +138 -0
  83. package/dist/choice-card/index.d.ts +2 -0
  84. package/dist/choice-card/index.js +1 -0
  85. package/dist/config/config.client.d.ts +24 -0
  86. package/dist/config/config.client.js +33 -0
  87. package/dist/config/index.d.ts +2 -0
  88. package/dist/config/index.js +1 -0
  89. package/dist/container/container.d.ts +13 -0
  90. package/dist/container/container.js +16 -0
  91. package/dist/container/index.d.ts +2 -0
  92. package/dist/container/index.js +1 -0
  93. package/dist/contracts/details.d.ts +13 -0
  94. package/dist/contracts/details.js +9 -0
  95. package/dist/contracts/index.d.ts +5 -0
  96. package/dist/contracts/index.js +5 -0
  97. package/dist/contracts/merge-props.d.ts +16 -0
  98. package/dist/contracts/merge-props.js +76 -0
  99. package/dist/contracts/render.d.ts +17 -0
  100. package/dist/contracts/render.js +43 -0
  101. package/dist/contracts/state.d.ts +42 -0
  102. package/dist/contracts/state.js +42 -0
  103. package/dist/css/alert.css +2 -0
  104. package/dist/css/app-shell.css +2 -0
  105. package/dist/css/avatar.css +2 -0
  106. package/dist/css/badge.css +2 -0
  107. package/dist/css/banner.css +2 -0
  108. package/dist/css/base.css +2 -0
  109. package/dist/css/breadcrumb.css +2 -0
  110. package/dist/css/button.css +2 -0
  111. package/dist/css/card.css +2 -0
  112. package/dist/css/checkbox.css +2 -0
  113. package/dist/css/chip-group.css +2 -0
  114. package/dist/css/choice-card.css +2 -0
  115. package/dist/css/container.css +2 -0
  116. package/dist/css/delta.css +2 -0
  117. package/dist/css/dialog.css +2 -0
  118. package/dist/css/drawer.css +2 -0
  119. package/dist/css/empty-state.css +2 -0
  120. package/dist/css/field.css +2 -0
  121. package/dist/css/fieldset.css +2 -0
  122. package/dist/css/file-upload.css +2 -0
  123. package/dist/css/form.css +2 -0
  124. package/dist/css/grid.css +2 -0
  125. package/dist/css/heading.css +2 -0
  126. package/dist/css/icon-button.css +2 -0
  127. package/dist/css/image.css +2 -0
  128. package/dist/css/inline-error.css +2 -0
  129. package/dist/css/inline.css +2 -0
  130. package/dist/css/input.css +2 -0
  131. package/dist/css/kbd.css +2 -0
  132. package/dist/css/kpi-tile.css +2 -0
  133. package/dist/css/menu.css +2 -0
  134. package/dist/css/meter.css +2 -0
  135. package/dist/css/metric.css +2 -0
  136. package/dist/css/mobile-tab-bar.css +2 -0
  137. package/dist/css/mobile-top-bar.css +2 -0
  138. package/dist/css/motion.css +2 -0
  139. package/dist/css/native-select.css +2 -0
  140. package/dist/css/nav-item.css +2 -0
  141. package/dist/css/number-value.css +2 -0
  142. package/dist/css/page-header.css +2 -0
  143. package/dist/css/pagination.css +2 -0
  144. package/dist/css/password-input.css +2 -0
  145. package/dist/css/popover.css +2 -0
  146. package/dist/css/progress-bar.css +2 -0
  147. package/dist/css/progress-ring.css +2 -0
  148. package/dist/css/radio-group.css +2 -0
  149. package/dist/css/ranked-list.css +2 -0
  150. package/dist/css/search-field.css +2 -0
  151. package/dist/css/segmented-control.css +2 -0
  152. package/dist/css/select.css +2 -0
  153. package/dist/css/separator.css +2 -0
  154. package/dist/css/sidebar.css +2 -0
  155. package/dist/css/skeleton.css +2 -0
  156. package/dist/css/split.css +2 -0
  157. package/dist/css/stack.css +2 -0
  158. package/dist/css/sticky-bar.css +2 -0
  159. package/dist/css/switch.css +2 -0
  160. package/dist/css/tab-nav.css +2 -0
  161. package/dist/css/table-selection.css +2 -0
  162. package/dist/css/table.css +2 -0
  163. package/dist/css/tabs.css +2 -0
  164. package/dist/css/text.css +2 -0
  165. package/dist/css/textarea.css +2 -0
  166. package/dist/css/toast.css +2 -0
  167. package/dist/css/tooltip.css +2 -0
  168. package/dist/css/top-bar.css +2 -0
  169. package/dist/css/trend-card.css +2 -0
  170. package/dist/delta/delta.d.ts +32 -0
  171. package/dist/delta/delta.js +50 -0
  172. package/dist/delta/index.d.ts +2 -0
  173. package/dist/delta/index.js +1 -0
  174. package/dist/dialog/dialog.client.d.ts +25 -0
  175. package/dist/dialog/dialog.client.js +145 -0
  176. package/dist/dialog/dialog.contract.d.ts +97 -0
  177. package/dist/dialog/dialog.parts.d.ts +6 -0
  178. package/dist/dialog/dialog.parts.js +15 -0
  179. package/dist/dialog/index.d.ts +5 -0
  180. package/dist/dialog/index.js +3 -0
  181. package/dist/drawer/drawer.client.d.ts +25 -0
  182. package/dist/drawer/drawer.client.js +154 -0
  183. package/dist/drawer/drawer.contract.d.ts +98 -0
  184. package/dist/drawer/drawer.parts.d.ts +6 -0
  185. package/dist/drawer/drawer.parts.js +16 -0
  186. package/dist/drawer/index.d.ts +5 -0
  187. package/dist/drawer/index.js +3 -0
  188. package/dist/empty-state/empty-state.d.ts +18 -0
  189. package/dist/empty-state/empty-state.js +32 -0
  190. package/dist/empty-state/index.d.ts +2 -0
  191. package/dist/empty-state/index.js +1 -0
  192. package/dist/field/field-scope.client.d.ts +50 -0
  193. package/dist/field/field-scope.client.js +212 -0
  194. package/dist/field/field-static.d.ts +122 -0
  195. package/dist/field/field-static.js +159 -0
  196. package/dist/field/field.d.ts +5 -0
  197. package/dist/field/field.js +53 -0
  198. package/dist/field/index.d.ts +4 -0
  199. package/dist/field/index.js +4 -0
  200. package/dist/fieldset/fieldset.d.ts +36 -0
  201. package/dist/fieldset/fieldset.js +63 -0
  202. package/dist/fieldset/index.d.ts +2 -0
  203. package/dist/fieldset/index.js +1 -0
  204. package/dist/file-upload/file-upload.client.d.ts +9 -0
  205. package/dist/file-upload/file-upload.client.js +406 -0
  206. package/dist/file-upload/file-upload.contract.d.ts +112 -0
  207. package/dist/file-upload/index.d.ts +3 -0
  208. package/dist/file-upload/index.js +1 -0
  209. package/dist/file-upload/seam.d.ts +1 -0
  210. package/dist/form/form.client.d.ts +38 -0
  211. package/dist/form/form.client.js +127 -0
  212. package/dist/form/form.d.ts +36 -0
  213. package/dist/form/form.js +29 -0
  214. package/dist/form/index.d.ts +4 -0
  215. package/dist/form/index.js +4 -0
  216. package/dist/form/submit-button.client.d.ts +20 -0
  217. package/dist/form/submit-button.client.js +19 -0
  218. package/dist/grid/grid.d.ts +38 -0
  219. package/dist/grid/grid.js +28 -0
  220. package/dist/grid/index.d.ts +2 -0
  221. package/dist/grid/index.js +1 -0
  222. package/dist/heading/heading.d.ts +30 -0
  223. package/dist/heading/heading.js +26 -0
  224. package/dist/heading/index.d.ts +2 -0
  225. package/dist/heading/index.js +1 -0
  226. package/dist/i18n/format-label.d.ts +24 -0
  227. package/dist/i18n/format-label.js +19 -0
  228. package/dist/i18n/index.d.ts +2 -0
  229. package/dist/i18n/index.js +1 -0
  230. package/dist/icon-button/icon-button-static.d.ts +23 -0
  231. package/dist/icon-button/icon-button-static.js +83 -0
  232. package/dist/icon-button/icon-button.client.js +29 -0
  233. package/dist/icon-button/icon-button.contract.d.ts +89 -0
  234. package/dist/icon-button/icon-button.d.ts +5 -0
  235. package/dist/icon-button/icon-button.js +21 -0
  236. package/dist/icon-button/index.d.ts +4 -0
  237. package/dist/icon-button/index.js +3 -0
  238. package/dist/image/image.d.ts +28 -0
  239. package/dist/image/image.js +24 -0
  240. package/dist/image/index.d.ts +2 -0
  241. package/dist/image/index.js +1 -0
  242. package/dist/index.d.ts +174 -0
  243. package/dist/index.js +96 -0
  244. package/dist/inline/index.d.ts +2 -0
  245. package/dist/inline/index.js +1 -0
  246. package/dist/inline/inline.d.ts +16 -0
  247. package/dist/inline/inline.js +14 -0
  248. package/dist/inline-error/index.d.ts +2 -0
  249. package/dist/inline-error/index.js +1 -0
  250. package/dist/inline-error/inline-error.d.ts +17 -0
  251. package/dist/inline-error/inline-error.js +33 -0
  252. package/dist/input/index.d.ts +2 -0
  253. package/dist/input/index.js +1 -0
  254. package/dist/input/input.client.d.ts +39 -0
  255. package/dist/input/input.client.js +82 -0
  256. package/dist/kbd/index.d.ts +2 -0
  257. package/dist/kbd/index.js +1 -0
  258. package/dist/kbd/kbd.d.ts +19 -0
  259. package/dist/kbd/kbd.js +68 -0
  260. package/dist/kpi-tile/index.d.ts +2 -0
  261. package/dist/kpi-tile/index.js +1 -0
  262. package/dist/kpi-tile/kpi-tile.d.ts +30 -0
  263. package/dist/kpi-tile/kpi-tile.js +48 -0
  264. package/dist/locales/en-US.d.ts +77 -0
  265. package/dist/locales/en-US.js +83 -0
  266. package/dist/menu/index.d.ts +5 -0
  267. package/dist/menu/index.js +3 -0
  268. package/dist/menu/menu.client.d.ts +14 -0
  269. package/dist/menu/menu.client.js +152 -0
  270. package/dist/menu/menu.contract.d.ts +152 -0
  271. package/dist/menu/menu.parts.d.ts +6 -0
  272. package/dist/menu/menu.parts.js +17 -0
  273. package/dist/meter/index.d.ts +2 -0
  274. package/dist/meter/index.js +1 -0
  275. package/dist/meter/meter.d.ts +43 -0
  276. package/dist/meter/meter.js +59 -0
  277. package/dist/metric/index.d.ts +2 -0
  278. package/dist/metric/index.js +1 -0
  279. package/dist/metric/metric.d.ts +72 -0
  280. package/dist/metric/metric.js +116 -0
  281. package/dist/mobile-tab-bar/index.d.ts +4 -0
  282. package/dist/mobile-tab-bar/index.js +4 -0
  283. package/dist/mobile-tab-bar/mobile-tab-bar-inset.client.js +38 -0
  284. package/dist/mobile-tab-bar/mobile-tab-bar-more.client.d.ts +26 -0
  285. package/dist/mobile-tab-bar/mobile-tab-bar-more.client.js +60 -0
  286. package/dist/mobile-tab-bar/mobile-tab-bar.d.ts +39 -0
  287. package/dist/mobile-tab-bar/mobile-tab-bar.js +54 -0
  288. package/dist/mobile-tab-bar/mobile-tab-bar.parts.d.ts +6 -0
  289. package/dist/mobile-tab-bar/mobile-tab-bar.parts.js +9 -0
  290. package/dist/mobile-top-bar/index.d.ts +2 -0
  291. package/dist/mobile-top-bar/index.js +1 -0
  292. package/dist/mobile-top-bar/mobile-top-bar.d.ts +17 -0
  293. package/dist/mobile-top-bar/mobile-top-bar.js +31 -0
  294. package/dist/motion/count-up.client.d.ts +39 -0
  295. package/dist/motion/count-up.client.js +109 -0
  296. package/dist/motion/index.d.ts +2 -0
  297. package/dist/motion/index.js +1 -0
  298. package/dist/native-select/index.d.ts +2 -0
  299. package/dist/native-select/index.js +1 -0
  300. package/dist/native-select/native-select.d.ts +43 -0
  301. package/dist/native-select/native-select.js +56 -0
  302. package/dist/nav-item/index.d.ts +2 -0
  303. package/dist/nav-item/index.js +1 -0
  304. package/dist/nav-item/nav-item.d.ts +35 -0
  305. package/dist/nav-item/nav-item.js +50 -0
  306. package/dist/number-value/index.d.ts +2 -0
  307. package/dist/number-value/index.js +1 -0
  308. package/dist/number-value/number-value.d.ts +25 -0
  309. package/dist/number-value/number-value.js +26 -0
  310. package/dist/page-header/index.d.ts +2 -0
  311. package/dist/page-header/index.js +1 -0
  312. package/dist/page-header/page-header.d.ts +19 -0
  313. package/dist/page-header/page-header.js +39 -0
  314. package/dist/pagination/index.d.ts +2 -0
  315. package/dist/pagination/index.js +1 -0
  316. package/dist/pagination/pagination.d.ts +74 -0
  317. package/dist/pagination/pagination.js +136 -0
  318. package/dist/password-input/index.d.ts +2 -0
  319. package/dist/password-input/index.js +1 -0
  320. package/dist/password-input/password-input.client.d.ts +52 -0
  321. package/dist/password-input/password-input.client.js +106 -0
  322. package/dist/popover/index.d.ts +5 -0
  323. package/dist/popover/index.js +3 -0
  324. package/dist/popover/popover.client.d.ts +20 -0
  325. package/dist/popover/popover.client.js +113 -0
  326. package/dist/popover/popover.contract.d.ts +88 -0
  327. package/dist/popover/popover.parts.d.ts +6 -0
  328. package/dist/popover/popover.parts.js +13 -0
  329. package/dist/progress-bar/index.d.ts +2 -0
  330. package/dist/progress-bar/index.js +1 -0
  331. package/dist/progress-bar/progress-bar.d.ts +34 -0
  332. package/dist/progress-bar/progress-bar.js +55 -0
  333. package/dist/progress-ring/index.d.ts +2 -0
  334. package/dist/progress-ring/index.js +1 -0
  335. package/dist/progress-ring/progress-ring.d.ts +38 -0
  336. package/dist/progress-ring/progress-ring.js +67 -0
  337. package/dist/radio-group/index.d.ts +3 -0
  338. package/dist/radio-group/index.js +3 -0
  339. package/dist/radio-group/radio-group.client.d.ts +22 -0
  340. package/dist/radio-group/radio-group.client.js +70 -0
  341. package/dist/radio-group/radio-group.d.ts +28 -0
  342. package/dist/radio-group/radio-group.js +35 -0
  343. package/dist/ranked-list/index.d.ts +3 -0
  344. package/dist/ranked-list/index.js +3 -0
  345. package/dist/ranked-list/ranked-list.d.ts +85 -0
  346. package/dist/ranked-list/ranked-list.js +153 -0
  347. package/dist/ranked-list/ranked-list.parts.d.ts +6 -0
  348. package/dist/ranked-list/ranked-list.parts.js +10 -0
  349. package/dist/search-field/index.d.ts +2 -0
  350. package/dist/search-field/index.js +1 -0
  351. package/dist/search-field/search-field.client.d.ts +55 -0
  352. package/dist/search-field/search-field.client.js +136 -0
  353. package/dist/segmented-control/index.d.ts +3 -0
  354. package/dist/segmented-control/index.js +3 -0
  355. package/dist/segmented-control/segmented-control.client.d.ts +61 -0
  356. package/dist/segmented-control/segmented-control.client.js +156 -0
  357. package/dist/segmented-control/segmented-control.parts.d.ts +6 -0
  358. package/dist/segmented-control/segmented-control.parts.js +9 -0
  359. package/dist/select/index.d.ts +5 -0
  360. package/dist/select/index.js +3 -0
  361. package/dist/select/select.client.d.ts +12 -0
  362. package/dist/select/select.client.js +152 -0
  363. package/dist/select/select.contract.d.ts +119 -0
  364. package/dist/select/select.parts.d.ts +6 -0
  365. package/dist/select/select.parts.js +15 -0
  366. package/dist/separator/index.d.ts +2 -0
  367. package/dist/separator/index.js +1 -0
  368. package/dist/separator/separator.d.ts +26 -0
  369. package/dist/separator/separator.js +23 -0
  370. package/dist/sidebar/index.d.ts +4 -0
  371. package/dist/sidebar/index.js +4 -0
  372. package/dist/sidebar/sidebar-item.client.d.ts +10 -0
  373. package/dist/sidebar/sidebar-item.client.js +55 -0
  374. package/dist/sidebar/sidebar.d.ts +45 -0
  375. package/dist/sidebar/sidebar.js +62 -0
  376. package/dist/sidebar/sidebar.parts.d.ts +6 -0
  377. package/dist/sidebar/sidebar.parts.js +11 -0
  378. package/dist/skeleton/index.d.ts +2 -0
  379. package/dist/skeleton/index.js +1 -0
  380. package/dist/skeleton/skeleton.d.ts +20 -0
  381. package/dist/skeleton/skeleton.js +19 -0
  382. package/dist/split/index.d.ts +3 -0
  383. package/dist/split/index.js +3 -0
  384. package/dist/split/split.d.ts +28 -0
  385. package/dist/split/split.js +33 -0
  386. package/dist/split/split.parts.d.ts +6 -0
  387. package/dist/split/split.parts.js +10 -0
  388. package/dist/stack/index.d.ts +2 -0
  389. package/dist/stack/index.js +1 -0
  390. package/dist/stack/stack.d.ts +17 -0
  391. package/dist/stack/stack.js +14 -0
  392. package/dist/sticky-bar/index.d.ts +2 -0
  393. package/dist/sticky-bar/index.js +1 -0
  394. package/dist/sticky-bar/sticky-bar.d.ts +16 -0
  395. package/dist/sticky-bar/sticky-bar.js +26 -0
  396. package/dist/styles.css +595 -0
  397. package/dist/switch/index.d.ts +2 -0
  398. package/dist/switch/index.js +1 -0
  399. package/dist/switch/switch.client.d.ts +33 -0
  400. package/dist/switch/switch.client.js +63 -0
  401. package/dist/tab-nav/index.d.ts +3 -0
  402. package/dist/tab-nav/index.js +3 -0
  403. package/dist/tab-nav/tab-nav.d.ts +36 -0
  404. package/dist/tab-nav/tab-nav.js +47 -0
  405. package/dist/tab-nav/tab-nav.parts.d.ts +6 -0
  406. package/dist/tab-nav/tab-nav.parts.js +9 -0
  407. package/dist/table/index.d.ts +3 -0
  408. package/dist/table/index.js +3 -0
  409. package/dist/table/table.d.ts +101 -0
  410. package/dist/table/table.js +121 -0
  411. package/dist/table/table.parts.d.ts +6 -0
  412. package/dist/table/table.parts.js +18 -0
  413. package/dist/table-selection/index.d.ts +3 -0
  414. package/dist/table-selection/index.js +3 -0
  415. package/dist/table-selection/table-selection.client.d.ts +14 -0
  416. package/dist/table-selection/table-selection.client.js +84 -0
  417. package/dist/table-selection/table-selection.d.ts +34 -0
  418. package/dist/table-selection/table-selection.js +50 -0
  419. package/dist/tabs/index.d.ts +4 -0
  420. package/dist/tabs/index.js +3 -0
  421. package/dist/tabs/tabs.client.d.ts +8 -0
  422. package/dist/tabs/tabs.client.js +68 -0
  423. package/dist/tabs/tabs.contract.d.ts +89 -0
  424. package/dist/tabs/tabs.parts.d.ts +6 -0
  425. package/dist/tabs/tabs.parts.js +11 -0
  426. package/dist/text/index.d.ts +2 -0
  427. package/dist/text/index.js +1 -0
  428. package/dist/text/text.d.ts +32 -0
  429. package/dist/text/text.js +17 -0
  430. package/dist/textarea/index.d.ts +2 -0
  431. package/dist/textarea/index.js +1 -0
  432. package/dist/textarea/textarea.client.d.ts +18 -0
  433. package/dist/textarea/textarea.client.js +31 -0
  434. package/dist/theme-script/index.d.ts +2 -0
  435. package/dist/theme-script/index.js +1 -0
  436. package/dist/theme-script/theme-script.d.ts +43 -0
  437. package/dist/theme-script/theme-script.js +46 -0
  438. package/dist/toast/index.d.ts +4 -0
  439. package/dist/toast/index.js +3 -0
  440. package/dist/toast/seam.d.ts +2 -0
  441. package/dist/toast/store.d.ts +19 -0
  442. package/dist/toast/store.js +136 -0
  443. package/dist/toast/toast.contract.d.ts +56 -0
  444. package/dist/toast/toaster.client.d.ts +10 -0
  445. package/dist/toast/toaster.client.js +305 -0
  446. package/dist/tooltip/index.d.ts +5 -0
  447. package/dist/tooltip/index.js +3 -0
  448. package/dist/tooltip/tooltip.client.d.ts +12 -0
  449. package/dist/tooltip/tooltip.client.js +51 -0
  450. package/dist/tooltip/tooltip.contract.d.ts +60 -0
  451. package/dist/tooltip/tooltip.parts.d.ts +6 -0
  452. package/dist/tooltip/tooltip.parts.js +10 -0
  453. package/dist/top-bar/index.d.ts +2 -0
  454. package/dist/top-bar/index.js +1 -0
  455. package/dist/top-bar/top-bar.d.ts +17 -0
  456. package/dist/top-bar/top-bar.js +35 -0
  457. package/dist/trend-card/index.d.ts +2 -0
  458. package/dist/trend-card/index.js +1 -0
  459. package/dist/trend-card/trend-card.d.ts +34 -0
  460. package/dist/trend-card/trend-card.js +74 -0
  461. package/package.json +447 -3
@@ -0,0 +1,32 @@
1
+ import { cx } from "../_internal/cx.js";
2
+ import { renderElement } from "../contracts/render.js";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ //#region src/empty-state/empty-state.tsx
5
+ /** Figma: "A render, a headline, one action. No paragraphs." */
6
+ function EmptyState({ title, level = 2, media, actions, render, className, ...rest }) {
7
+ const Title = `h${level}`;
8
+ return renderElement("div", render, {}, {
9
+ "data-slot": "empty-state",
10
+ ...rest,
11
+ className: cx("nz-empty-state", className),
12
+ children: /* @__PURE__ */ jsxs(Fragment, { children: [
13
+ media != null && /* @__PURE__ */ jsx("div", {
14
+ className: "nz-empty-state-media",
15
+ "data-slot": "empty-state-media",
16
+ children: media
17
+ }),
18
+ /* @__PURE__ */ jsx(Title, {
19
+ className: "nz-empty-state-title",
20
+ "data-slot": "empty-state-title",
21
+ children: title
22
+ }),
23
+ actions != null && /* @__PURE__ */ jsx("div", {
24
+ className: "nz-empty-state-actions",
25
+ "data-slot": "empty-state-actions",
26
+ children: actions
27
+ })
28
+ ] })
29
+ });
30
+ }
31
+ //#endregion
32
+ export { EmptyState };
@@ -0,0 +1,2 @@
1
+ import { EmptyState, EmptyStateProps, EmptyStateTitleLevel } from "./empty-state.js";
2
+ export { EmptyState, type EmptyStateProps, type EmptyStateTitleLevel };
@@ -0,0 +1 @@
1
+ export { EmptyState } from "./empty-state.js";
@@ -0,0 +1,50 @@
1
+ import { FieldControlProps } from "./field-static.js";
2
+ import { FocusEvent, ReactElement, ReactNode, SyntheticEvent } from "react";
3
+ //#region src/field/field-scope.client.d.ts
4
+ /** A native element that takes part in constraint validation. */
5
+ export type FieldValidatable = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
6
+ /** What a control passes in: its own props, which win over the Field's (FIELD-CONTRACT.md). */
7
+ export interface FieldControlOptions {
8
+ id?: string | undefined;
9
+ name?: string | undefined;
10
+ required?: boolean | undefined;
11
+ disabled?: boolean | undefined;
12
+ readOnly?: boolean | undefined;
13
+ invalid?: boolean | undefined;
14
+ /** Joined after the Field's description and error ids, for example a text affix or a count. */
15
+ "aria-describedby"?: string | undefined;
16
+ /**
17
+ * `'focus'`: a click on the Field label focuses the control and does nothing else. For button
18
+ * controls (Select, third-party pickers): a `<label for>` a button presses it, which would open its
19
+ * popup. Omitted, the label keeps the browser's behaviour.
20
+ */
21
+ labelBehavior?: "focus" | undefined;
22
+ }
23
+ /** `controlProps`: the attributes plus the Field's validation handlers, inside a Field. */
24
+ export type FieldControlElementProps = FieldControlProps & {
25
+ onInvalid?: ((event: SyntheticEvent<FieldValidatable>) => void) | undefined;
26
+ onInput?: ((event: SyntheticEvent<FieldValidatable>) => void) | undefined;
27
+ onBlur?: ((event: FocusEvent<FieldValidatable>) => void) | undefined;
28
+ };
29
+ export interface FieldControl {
30
+ /** A Field is around the control. */
31
+ inField: boolean;
32
+ id: string | undefined;
33
+ /** The Field label's id, for a control named by `aria-labelledby` (button or group controls). */
34
+ labelledBy: string | undefined;
35
+ describedBy: string | undefined;
36
+ name: string | undefined;
37
+ required: boolean;
38
+ disabled: boolean;
39
+ readOnly: boolean;
40
+ /** An error message is presented (`data-invalid` semantics, §8.3). */
41
+ invalid: boolean;
42
+ /** Spread on the native element, merged with the consumer's props through `mergeProps`. */
43
+ controlProps: FieldControlElementProps;
44
+ }
45
+ /**
46
+ * Field wiring for a control (FIELD-CONTRACT.md). The control's own props win; `aria-describedby`
47
+ * is joined. With no Field around the control, everything comes from `options`.
48
+ */
49
+ export declare function useFieldControl(options?: FieldControlOptions): FieldControl;
50
+ //#endregion
@@ -0,0 +1,212 @@
1
+ "use client";
2
+ import { renderElement } from "../contracts/render.js";
3
+ import { joinIds, presented } from "../_internal/field.js";
4
+ import { describedBy, fieldControlProps, fieldRootProps, fieldState } from "./field-static.js";
5
+ import { createContext, use, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
6
+ import { jsx } from "react/jsx-runtime";
7
+ //#region src/field/field-scope.client.tsx
8
+ const FieldContext = createContext(null);
9
+ /**
10
+ * Internal: what `Form` (form/form.client.tsx) provides, its presented errors by Field `name` (one
11
+ * message each). It lives here, not in the form folder, so the Field's module graph gains no client
12
+ * module; the form leaf imports it.
13
+ */
14
+ const FormScope = createContext(null);
15
+ /** Internal: rendered only by `Field`. Every prop is serialisable. */
16
+ function FieldScope({ anatomy, name, messages, children }) {
17
+ const [native, setNative] = useState(null);
18
+ const [toFocus, setToFocus] = useState(null);
19
+ const { ids, label, description, required, disabled, readOnly, validateOn } = anatomy;
20
+ const formError = name === void 0 ? void 0 : use(FormScope)?.get(name);
21
+ const error = presented(anatomy.error) ? anatomy.error : formError ?? native;
22
+ const invalid = presented(error);
23
+ const region = useRef(null);
24
+ const [said, say] = useState("");
25
+ const last = useRef(null);
26
+ const asked = useRef(false);
27
+ const handlers = useMemo(() => {
28
+ const current = (element) => element.validity.valid ? null : messageOf(element, messages);
29
+ return {
30
+ onInvalid(event) {
31
+ event.preventDefault();
32
+ const element = event.currentTarget;
33
+ const first = element.form === null || firstInvalid(element.form) === element;
34
+ if (first) arm(region, asked, last);
35
+ setNative(messageOf(element, messages));
36
+ if (first && element.form !== null) setToFocus({ element });
37
+ },
38
+ onInput(event) {
39
+ asked.current = false;
40
+ const next = current(event.currentTarget);
41
+ setNative((shown) => shown === null ? null : next);
42
+ },
43
+ ...validateOn === "blur" && { onBlur(event) {
44
+ setNative(current(event.currentTarget));
45
+ } }
46
+ };
47
+ }, [messages, validateOn]);
48
+ const [labelFocus, setLabelFocus] = useState(false);
49
+ useLayoutEffect(() => {
50
+ const text = invalid && region.current?.previousSibling?.lastChild?.textContent || "";
51
+ if (text !== last.current) {
52
+ last.current = text;
53
+ say(asked.current && text !== "" && inside(region.current) ? text : "");
54
+ if (text !== "") asked.current = false;
55
+ }
56
+ }, [
57
+ error,
58
+ invalid,
59
+ toFocus
60
+ ]);
61
+ useLayoutEffect(() => {
62
+ const element = toFocus?.element;
63
+ if (element?.form != null && firstInvalid(element.form) === element) element.focus();
64
+ }, [toFocus]);
65
+ useEffect(() => {
66
+ const doc = region.current?.ownerDocument;
67
+ const onSubmit = () => arm(region, asked);
68
+ doc?.addEventListener("submit", onSubmit, true);
69
+ return () => doc?.removeEventListener("submit", onSubmit, true);
70
+ }, []);
71
+ useEffect(() => {
72
+ if (said === "") return void 0;
73
+ const timer = setTimeout(say, 7e3, "");
74
+ return () => clearTimeout(timer);
75
+ }, [said]);
76
+ const scope = useMemo(() => ({
77
+ id: ids.control,
78
+ labelledBy: presented(label) ? ids.label : void 0,
79
+ describedBy: describedBy(ids, description, invalid),
80
+ name,
81
+ required,
82
+ disabled,
83
+ readOnly,
84
+ invalid,
85
+ handlers,
86
+ setLabelFocus
87
+ }), [
88
+ ids,
89
+ label,
90
+ description,
91
+ invalid,
92
+ name,
93
+ required,
94
+ disabled,
95
+ readOnly,
96
+ handlers
97
+ ]);
98
+ const field = {
99
+ ...anatomy,
100
+ error,
101
+ onLabelClick: labelFocus ? focusControl : void 0,
102
+ announcer: /* @__PURE__ */ jsx("span", {
103
+ ref: region,
104
+ className: "nz-visually-hidden",
105
+ "aria-live": "polite",
106
+ "aria-atomic": "true",
107
+ children: said
108
+ }),
109
+ children
110
+ };
111
+ return /* @__PURE__ */ jsx(FieldContext, {
112
+ value: scope,
113
+ children: renderElement("div", anatomy.render, fieldState(field), fieldRootProps(field))
114
+ });
115
+ }
116
+ /**
117
+ * Field wiring for a control (FIELD-CONTRACT.md). The control's own props win; `aria-describedby`
118
+ * is joined. With no Field around the control, everything comes from `options`.
119
+ */
120
+ function useFieldControl(options = {}) {
121
+ const scope = use(FieldContext);
122
+ const id = options.id ?? scope?.id;
123
+ const name = options.name ?? scope?.name;
124
+ const required = options.required ?? scope?.required ?? false;
125
+ const disabled = options.disabled ?? scope?.disabled ?? false;
126
+ const readOnly = options.readOnly ?? scope?.readOnly ?? false;
127
+ const invalid = options.invalid ?? scope?.invalid ?? false;
128
+ const described = joinIds(scope?.describedBy, options["aria-describedby"]);
129
+ const setLabelFocus = options.labelBehavior === "focus" ? scope?.setLabelFocus : void 0;
130
+ useEffect(() => {
131
+ if (setLabelFocus === void 0) return void 0;
132
+ setLabelFocus(true);
133
+ return () => setLabelFocus(false);
134
+ }, [setLabelFocus]);
135
+ return {
136
+ inField: scope !== null,
137
+ id,
138
+ labelledBy: scope?.labelledBy,
139
+ describedBy: described,
140
+ name,
141
+ required,
142
+ disabled,
143
+ readOnly,
144
+ invalid,
145
+ controlProps: {
146
+ ...fieldControlProps({
147
+ id,
148
+ name,
149
+ required,
150
+ disabled,
151
+ readOnly,
152
+ invalid,
153
+ describedBy: described
154
+ }),
155
+ ...scope?.handlers
156
+ }
157
+ };
158
+ }
159
+ /**
160
+ * `labelBehavior: 'focus'`: a `<label for>` a button presses it, which would open its popup. Cancel
161
+ * that and focus the control, with the ring showing where focus went, as React Aria's own Select
162
+ * label does. A disabled control takes no focus.
163
+ */
164
+ function focusControl(event) {
165
+ event.preventDefault();
166
+ event.currentTarget.control?.focus({ focusVisible: true });
167
+ }
168
+ const VALIDITY_KEYS = [
169
+ "valueMissing",
170
+ "typeMismatch",
171
+ "patternMismatch",
172
+ "tooLong",
173
+ "tooShort",
174
+ "rangeUnderflow",
175
+ "rangeOverflow",
176
+ "stepMismatch",
177
+ "badInput",
178
+ "customError"
179
+ ];
180
+ /** The Field's message for the first failing validity flag, else the browser's own text. */
181
+ function messageOf(element, messages) {
182
+ const key = VALIDITY_KEYS.find((flag) => element.validity[flag]);
183
+ return (key === void 0 ? void 0 : messages?.[key]) ?? element.validationMessage;
184
+ }
185
+ /**
186
+ * The form's first control that fails validation, in tree order. Not `querySelector(':invalid')`:
187
+ * `fieldset:invalid` matches the ancestor first.
188
+ */
189
+ function firstInvalid(form) {
190
+ for (const element of form.elements) if (isValidatable(element) && element.willValidate && !element.validity.valid) return element;
191
+ }
192
+ /**
193
+ * A validation request: with focus in the Field, the next error text that commits is spoken. With
194
+ * `last` (native validation, which answers in the same commit) the current text also counts as not
195
+ * yet seen. A submit passes none: its reply comes later, and the re-renders before it (a pending
196
+ * state, an `error` node rebuilt) keep the old text, which must not count as new.
197
+ */
198
+ function arm(region, asked, last) {
199
+ if (inside(region.current)) {
200
+ asked.current = true;
201
+ if (last) last.current = null;
202
+ }
203
+ }
204
+ /** Focus is in the Field root that holds the announcer (a group control's radios included). */
205
+ function inside(region) {
206
+ return region?.parentNode?.contains(region.ownerDocument.activeElement) === true;
207
+ }
208
+ function isValidatable(element) {
209
+ return "validity" in element && "willValidate" in element;
210
+ }
211
+ //#endregion
212
+ export { FieldScope, FormScope, useFieldControl };
@@ -0,0 +1,122 @@
1
+ import { RenderProp } from "../contracts/render.js";
2
+ import { ComponentPropsWithRef, ReactElement, ReactNode } from "react";
3
+ //#region src/field/field-static.d.ts
4
+ /** When native validation messages are presented. */
5
+ export type FieldValidateOn = "submit" | "blur";
6
+ /** The `ValidityState` flags a `messages` entry can replace. */
7
+ export type FieldValidityKey = "valueMissing" | "typeMismatch" | "patternMismatch" | "tooLong" | "tooShort" | "rangeUnderflow" | "rangeOverflow" | "stepMismatch" | "badInput" | "customError";
8
+ /** Ids a Field generates; each one given here replaces the generated one (Conform, tests). */
9
+ export interface FieldIds {
10
+ control?: string | undefined;
11
+ label?: string | undefined;
12
+ description?: string | undefined;
13
+ error?: string | undefined;
14
+ }
15
+ export interface FieldState {
16
+ /** An error message is presented. */
17
+ invalid: boolean;
18
+ disabled: boolean;
19
+ required: boolean;
20
+ readOnly: boolean;
21
+ }
22
+ /**
23
+ * Attributes for the native element of a control: what a function child receives, and the base of
24
+ * `useFieldControl().controlProps`. Serialisable; flags are `true` or `undefined`, never `false`.
25
+ */
26
+ export type FieldControlProps = {
27
+ id?: string | undefined;
28
+ name?: string | undefined;
29
+ required?: boolean | undefined;
30
+ disabled?: boolean | undefined;
31
+ readOnly?: boolean | undefined;
32
+ "aria-describedby"?: string | undefined;
33
+ "aria-invalid"?: boolean | undefined;
34
+ };
35
+ export interface FieldProps extends Omit<ComponentPropsWithRef<"div">, "children"> {
36
+ /** The visible name, a `<label for>` the control. */
37
+ label?: ReactNode;
38
+ /** Help text under the control, joined to its `aria-describedby`. */
39
+ description?: ReactNode;
40
+ /**
41
+ * The error message, rendered through InlineError with an icon (never colour alone). Its presence
42
+ * is what "invalid" means (§8.3): `aria-invalid` on the control and `data-invalid` on the Field.
43
+ * It is not a live region; around a client control, the Field's one announcer speaks a new error
44
+ * while focus is already in the Field (§16.5's one exception, FIELD-CONTRACT.md). `null`, `false`
45
+ * and `''` present no error.
46
+ */
47
+ error?: ReactNode;
48
+ /** Replaces the internal error mark (`circle-x`). Decorative. */
49
+ errorIcon?: ReactNode;
50
+ /**
51
+ * The control is a group of native controls under one root (SegmentedControl, a third-party
52
+ * picker), not one labelable element: the label then has no `for`, and names the group through
53
+ * the `aria-labelledby` the control puts on its root (FIELD-CONTRACT.md). @default false
54
+ */
55
+ group?: boolean;
56
+ /** Passed to the control. */
57
+ name?: string;
58
+ /** The control is required: native `required`, and an `aria-hidden` mark after the label. @default false */
59
+ required?: boolean;
60
+ /** @default false */
61
+ disabled?: boolean;
62
+ /** @default false */
63
+ readOnly?: boolean;
64
+ ids?: FieldIds;
65
+ /** Messages for native validation, by validity flag, instead of the browser's own text. */
66
+ messages?: Partial<Record<FieldValidityKey, string>>;
67
+ /** Native messages appear on submit, or also when the control loses focus. @default 'submit' */
68
+ validateOn?: FieldValidateOn;
69
+ /** Composition of the root `<div>`. */
70
+ render?: RenderProp<FieldState>;
71
+ /**
72
+ * The control. A function receives ready-made control attributes and renders with no client code
73
+ * at all (zero-JS mode, for Server-Component forms and plain elements); its second argument,
74
+ * `field`, carries the ids for anything else, as on `FieldStatic`. A NativeSelect placed directly
75
+ * inside is wired the same way, with no function. Client controls (Input, Checkbox, …) read the
76
+ * wiring through `useFieldControl`.
77
+ */
78
+ children?: ReactNode | ((control: FieldControlProps, field: FieldStaticWiring) => ReactNode);
79
+ }
80
+ /**
81
+ * What a FieldStatic function child receives as its second argument: the wiring FieldStatic does
82
+ * not do for you, since it provides no context. Use it for a control that is not one labelable
83
+ * element (`aria-labelledby` on a group root or a button) or to point other elements at the parts.
84
+ */
85
+ export interface FieldStaticWiring extends FieldState {
86
+ /** Every id the Field renders, generated or taken from `ids`. */
87
+ ids: {
88
+ control: string;
89
+ label: string;
90
+ description: string;
91
+ error: string;
92
+ };
93
+ /** The label's id while a label renders, for `aria-labelledby`; `undefined` without a label. */
94
+ labelledBy: string | undefined;
95
+ /** The description and error ids that render, in that order; the control's `aria-describedby`. */
96
+ describedBy: string | undefined;
97
+ }
98
+ export interface FieldStaticProps extends Omit<FieldProps, "children" | "messages" | "validateOn"> {
99
+ /**
100
+ * Not on FieldStatic: nothing intercepts native validation, so the browser shows its own bubble.
101
+ * For inline native messages use `Field`.
102
+ */
103
+ messages?: never;
104
+ /** Not on FieldStatic: see `messages`. */
105
+ validateOn?: never;
106
+ /**
107
+ * The control, always a function: FieldStatic provides no context, so a Nizivo client control
108
+ * placed directly inside (`<Input />`) would not be wired, and that is a type error here (use
109
+ * `Field`). Spread `control` on the element that holds the value (`<input {...control} />`,
110
+ * `<NativeSelect {...control}>`); `field` carries the ids for anything else.
111
+ */
112
+ children: (control: FieldControlProps, field: FieldStaticWiring) => ReactNode;
113
+ }
114
+ /**
115
+ * The Field anatomy with no client code: label, control, description and error, the same HTML and
116
+ * ids as `Field` with a function child (M31). Server-safe, and its module imports no client leaf,
117
+ * so a page that renders only FieldStatic ships no Field JavaScript in any bundler. It provides no
118
+ * context and no announcer, and native validation shows the browser's own bubble; the function
119
+ * child wires the control (FIELD-CONTRACT.md "FieldStatic").
120
+ */
121
+ export declare function FieldStatic({ label, description, error, errorIcon, group, name, required, disabled, readOnly, ids, render, children, messages: _messages, validateOn: _validateOn, ...root }: FieldStaticProps): ReactElement;
122
+ //#endregion
@@ -0,0 +1,159 @@
1
+ import { cx } from "../_internal/cx.js";
2
+ import { renderElement } from "../contracts/render.js";
3
+ import { CircleXGlyph } from "../_internal/glyphs.js";
4
+ import { stateAttrs } from "../contracts/state.js";
5
+ import { joinIds, presented } from "../_internal/field.js";
6
+ import { InlineError } from "../inline-error/inline-error.js";
7
+ import { useId } from "react";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ //#region src/field/field-static.tsx
10
+ /**
11
+ * The Field anatomy with no client code: label, control, description and error, the same HTML and
12
+ * ids as `Field` with a function child (M31). Server-safe, and its module imports no client leaf,
13
+ * so a page that renders only FieldStatic ships no Field JavaScript in any bundler. It provides no
14
+ * context and no announcer, and native validation shows the browser's own bubble; the function
15
+ * child wires the control (FIELD-CONTRACT.md "FieldStatic").
16
+ */
17
+ function FieldStatic({ label, description, error, errorIcon, group = false, name, required = false, disabled = false, readOnly = false, ids, render, children, messages: _messages, validateOn: _validateOn, ...root }) {
18
+ const anatomy = {
19
+ ids: resolveIds(useId(), ids, void 0),
20
+ label,
21
+ group,
22
+ description,
23
+ error,
24
+ errorIcon,
25
+ required,
26
+ disabled,
27
+ readOnly,
28
+ render,
29
+ root
30
+ };
31
+ if (typeof children !== "function") throw new TypeError("FieldStatic: children must be a function; put an element in a Field");
32
+ return staticField(anatomy, name, children);
33
+ }
34
+ /** The ids of one Field: a directly placed control's own id, else `ids`, else generated. */
35
+ function resolveIds(base, ids, ownId) {
36
+ return {
37
+ control: ownId ?? ids?.control ?? `${base}-control`,
38
+ label: ids?.label ?? `${base}-label`,
39
+ description: ids?.description ?? `${base}-description`,
40
+ error: ids?.error ?? `${base}-error`
41
+ };
42
+ }
43
+ /**
44
+ * The zero-JS render, shared by FieldStatic and Field's function child: the control attributes and
45
+ * the wiring go to `control`, and the anatomy renders around what it returns, with no
46
+ * `data-validate-on` and no announcer.
47
+ */
48
+ function staticField(anatomy, name, control) {
49
+ const { ids, label, description, required, disabled, readOnly } = anatomy;
50
+ const invalid = presented(anatomy.error);
51
+ const described = describedBy(ids, description, invalid);
52
+ const attributes = fieldControlProps({
53
+ id: ids.control,
54
+ name,
55
+ required,
56
+ disabled,
57
+ readOnly,
58
+ invalid,
59
+ describedBy: described
60
+ });
61
+ const wiring = {
62
+ ids,
63
+ labelledBy: presented(label) ? ids.label : void 0,
64
+ describedBy: described,
65
+ invalid,
66
+ required,
67
+ disabled,
68
+ readOnly
69
+ };
70
+ const field = {
71
+ ...anatomy,
72
+ validateOn: void 0,
73
+ children: control(attributes, wiring)
74
+ };
75
+ return renderElement("div", anatomy.render, fieldState(field), {
76
+ ...fieldRootProps(field),
77
+ "data-slot": "field",
78
+ className: cx("nz-field", anatomy.root.className)
79
+ });
80
+ }
81
+ /** The state a Field's `render` function receives. */
82
+ function fieldState(anatomy) {
83
+ const { required, disabled, readOnly } = anatomy;
84
+ return {
85
+ invalid: presented(anatomy.error),
86
+ disabled,
87
+ required,
88
+ readOnly
89
+ };
90
+ }
91
+ /**
92
+ * The root props of the one DOM shape of a Field: label, control, description, error (§10.6).
93
+ * Every path renders it: FieldStatic and Field's function child (zero JS) and FieldScope (with its
94
+ * native message and announcer).
95
+ */
96
+ function fieldRootProps(anatomy) {
97
+ const { ids, label, description, error, required, disabled, readOnly, validateOn } = anatomy;
98
+ const invalid = presented(error);
99
+ return {
100
+ "data-slot": "field",
101
+ ...stateAttrs({
102
+ invalid,
103
+ disabled,
104
+ required,
105
+ readOnly
106
+ }),
107
+ "data-validate-on": validateOn,
108
+ ...anatomy.root,
109
+ className: cx("nz-field", anatomy.root.className),
110
+ children: /* @__PURE__ */ jsxs(Fragment, { children: [
111
+ presented(label) && /* @__PURE__ */ jsxs("label", {
112
+ className: "nz-field-label",
113
+ "data-slot": "field-label",
114
+ id: ids.label,
115
+ htmlFor: anatomy.group ? void 0 : ids.control,
116
+ onClick: anatomy.onLabelClick,
117
+ children: [label, required && /* @__PURE__ */ jsx("span", {
118
+ className: "nz-field-required",
119
+ "data-slot": "field-required",
120
+ "aria-hidden": "true",
121
+ children: "*"
122
+ })]
123
+ }),
124
+ anatomy.children,
125
+ presented(description) && /* @__PURE__ */ jsx("div", {
126
+ className: "nz-field-description",
127
+ "data-slot": "field-description",
128
+ id: ids.description,
129
+ children: description
130
+ }),
131
+ invalid && /* @__PURE__ */ jsx(InlineError, {
132
+ className: "nz-field-error",
133
+ "data-slot": "field-error",
134
+ id: ids.error,
135
+ icon: anatomy.errorIcon ?? /* @__PURE__ */ jsx(CircleXGlyph, {}),
136
+ children: error
137
+ }),
138
+ anatomy.announcer
139
+ ] })
140
+ };
141
+ }
142
+ /** `aria-describedby` of the control: description, then error (§16.1). */
143
+ function describedBy(ids, description, invalid) {
144
+ return joinIds(presented(description) && ids.description, invalid && ids.error);
145
+ }
146
+ /** Control attributes; `false` flags and unknown values are left out, never set to `undefined`. */
147
+ function fieldControlProps(state) {
148
+ return {
149
+ ...state.id !== void 0 && { id: state.id },
150
+ ...state.name !== void 0 && { name: state.name },
151
+ ...state.required && { required: true },
152
+ ...state.disabled && { disabled: true },
153
+ ...state.readOnly && { readOnly: true },
154
+ ...state.describedBy !== void 0 && { "aria-describedby": state.describedBy },
155
+ ...state.invalid && { "aria-invalid": true }
156
+ };
157
+ }
158
+ //#endregion
159
+ export { FieldStatic, describedBy, fieldControlProps, fieldRootProps, fieldState, resolveIds, staticField };
@@ -0,0 +1,5 @@
1
+ import { FieldControlProps, FieldIds, FieldProps, FieldState, FieldValidateOn, FieldValidityKey } from "./field-static.js";
2
+ import { ReactElement } from "react";
3
+ //#region src/field/field.d.ts
4
+ export declare function Field({ label, description, error, errorIcon, group, name, required, disabled, readOnly, ids, messages, validateOn, render, children, ...root }: FieldProps): ReactElement;
5
+ //#endregion
@@ -0,0 +1,53 @@
1
+ import { FIELD_CONTROL, joinIds } from "../_internal/field.js";
2
+ import { resolveIds, staticField } from "./field-static.js";
3
+ import { FieldScope } from "./field-scope.client.js";
4
+ import { cloneElement, isValidElement, useId } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+ //#region src/field/field.tsx
7
+ function Field({ label, description, error, errorIcon, group = false, name, required = false, disabled = false, readOnly = false, ids, messages, validateOn = "submit", render, children, ...root }) {
8
+ const base = useId();
9
+ const wired = staticControl(children) ? children : void 0;
10
+ const ownId = wired?.props["id"];
11
+ const anatomy = {
12
+ ids: resolveIds(base, ids, typeof ownId === "string" ? ownId : void 0),
13
+ label,
14
+ group,
15
+ description,
16
+ error,
17
+ errorIcon,
18
+ required,
19
+ disabled,
20
+ readOnly,
21
+ render,
22
+ root
23
+ };
24
+ if (typeof children === "function") return staticField(anatomy, name, children);
25
+ if (wired !== void 0) return staticField(anatomy, name, (control) => cloneElement(wired, fill(control, wired.props)));
26
+ return /* @__PURE__ */ jsx(FieldScope, {
27
+ anatomy: {
28
+ ...anatomy,
29
+ validateOn
30
+ },
31
+ name,
32
+ messages,
33
+ children
34
+ });
35
+ }
36
+ /** A server-safe control (NativeSelect) that takes the zero-JS wiring as plain props. */
37
+ function staticControl(children) {
38
+ return isValidElement(children) && typeof children.type === "function" && Object.hasOwn(children.type, FIELD_CONTROL);
39
+ }
40
+ /**
41
+ * The Field's attributes a directly placed control did not set itself: the control's own props win
42
+ * (an explicit `false` included), and `aria-describedby` is joined after the Field's ids.
43
+ */
44
+ function fill(control, own) {
45
+ const out = {};
46
+ for (const [key, value] of Object.entries(control)) if (own[key] === void 0) out[key] = value;
47
+ const ownDescribedBy = own["aria-describedby"];
48
+ const described = joinIds(control["aria-describedby"], typeof ownDescribedBy === "string" ? ownDescribedBy : void 0);
49
+ if (described !== void 0) out["aria-describedby"] = described;
50
+ return out;
51
+ }
52
+ //#endregion
53
+ export { Field };
@@ -0,0 +1,4 @@
1
+ import { FieldControlProps, FieldIds, FieldProps, FieldState, FieldStatic, FieldStaticProps, FieldStaticWiring, FieldValidateOn, FieldValidityKey } from "./field-static.js";
2
+ import { Field } from "./field.js";
3
+ import { FieldControl, FieldControlElementProps, FieldControlOptions, FieldValidatable, useFieldControl } from "./field-scope.client.js";
4
+ export { Field, type FieldControl, type FieldControlElementProps, type FieldControlOptions, type FieldControlProps, type FieldIds, type FieldProps, type FieldState, FieldStatic, type FieldStaticProps, type FieldStaticWiring, type FieldValidatable, type FieldValidateOn, type FieldValidityKey, useFieldControl };
@@ -0,0 +1,4 @@
1
+ import { FieldStatic } from "./field-static.js";
2
+ import { useFieldControl } from "./field-scope.client.js";
3
+ import { Field } from "./field.js";
4
+ export { Field, FieldStatic, useFieldControl };