@primecoderin/fast-ui-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 (354) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/LICENSE +21 -0
  3. package/README.md +180 -3
  4. package/dist/_virtual/_rolldown/runtime.js +12 -0
  5. package/dist/charts.d.ts +7 -0
  6. package/dist/charts.js +7 -0
  7. package/dist/components/Avatar/Avatar.d.ts +12 -0
  8. package/dist/components/Avatar/Avatar.js +92 -0
  9. package/dist/components/Button/Button.d.ts +44 -0
  10. package/dist/components/Button/Button.js +221 -0
  11. package/dist/components/Checkbox/CheckboxBox.d.ts +33 -0
  12. package/dist/components/Checkbox/CheckboxBox.js +148 -0
  13. package/dist/components/CodeSnippet/CodeSnippet.d.ts +26 -0
  14. package/dist/components/CodeSnippet/CodeSnippet.js +153 -0
  15. package/dist/components/Collapsible/Collapsible.d.ts +20 -0
  16. package/dist/components/Collapsible/Collapsible.js +97 -0
  17. package/dist/components/Container/Container.d.ts +301 -0
  18. package/dist/components/Container/Container.js +20 -0
  19. package/dist/components/FloatingActionButton/FloatingActionButton.d.ts +22 -0
  20. package/dist/components/FloatingActionButton/FloatingActionButton.js +141 -0
  21. package/dist/components/Grid/Grid.d.ts +311 -0
  22. package/dist/components/Grid/Grid.js +30 -0
  23. package/dist/components/IconTile/IconTile.d.ts +12 -0
  24. package/dist/components/IconTile/IconTile.js +70 -0
  25. package/dist/components/InlineError/InlineError.d.ts +9 -0
  26. package/dist/components/InlineError/InlineError.js +62 -0
  27. package/dist/components/Kbd/Kbd.d.ts +11 -0
  28. package/dist/components/Kbd/Kbd.js +31 -0
  29. package/dist/components/Link/Link.d.ts +18 -0
  30. package/dist/components/Link/Link.js +68 -0
  31. package/dist/components/Menu/ContextMenu.d.ts +18 -0
  32. package/dist/components/Menu/ContextMenu.js +68 -0
  33. package/dist/components/Menu/Menu.d.ts +86 -0
  34. package/dist/components/Menu/Menu.js +394 -0
  35. package/dist/components/OtpInput/OtpInput.d.ts +32 -0
  36. package/dist/components/OtpInput/OtpInput.js +177 -0
  37. package/dist/components/Popover/HoverPopover.d.ts +22 -0
  38. package/dist/components/Popover/HoverPopover.js +74 -0
  39. package/dist/components/Popover/Popover.d.ts +21 -0
  40. package/dist/components/Popover/Popover.js +64 -0
  41. package/dist/components/ProgressBar/ProgressBar.d.ts +17 -0
  42. package/dist/components/ProgressBar/ProgressBar.js +44 -0
  43. package/dist/components/Rating/Rating.d.ts +49 -0
  44. package/dist/components/Rating/Rating.js +241 -0
  45. package/dist/components/ScrollArea/ScrollArea.d.ts +23 -0
  46. package/dist/components/ScrollArea/ScrollArea.js +90 -0
  47. package/dist/components/SegmentedControl/SegmentedControl.d.ts +29 -0
  48. package/dist/components/SegmentedControl/SegmentedControl.js +99 -0
  49. package/dist/components/Separator/Separator.d.ts +9 -0
  50. package/dist/components/Separator/Separator.js +34 -0
  51. package/dist/components/Skeleton/Skeleton.d.ts +31 -0
  52. package/dist/components/Skeleton/Skeleton.js +152 -0
  53. package/dist/components/Slider/Slider.d.ts +54 -0
  54. package/dist/components/Slider/Slider.js +178 -0
  55. package/dist/components/Spinner/Spinner.d.ts +17 -0
  56. package/dist/components/Spinner/Spinner.js +118 -0
  57. package/dist/components/Stack/Stack.d.ts +302 -0
  58. package/dist/components/Stack/Stack.js +14 -0
  59. package/dist/components/StateIcon/StateIcon.d.ts +11 -0
  60. package/dist/components/StateIcon/StateIcon.js +65 -0
  61. package/dist/components/StatusBadge/StatusBadge.d.ts +19 -0
  62. package/dist/components/StatusBadge/StatusBadge.js +82 -0
  63. package/dist/components/Tabs/Tabs.d.ts +28 -0
  64. package/dist/components/Tabs/Tabs.js +109 -0
  65. package/dist/components/Tag/Tag.d.ts +11 -0
  66. package/dist/components/Tag/Tag.js +66 -0
  67. package/dist/components/Toast/AppToaster.d.ts +8 -0
  68. package/dist/components/Toast/AppToaster.js +135 -0
  69. package/dist/components/Toast/toast-manager.d.ts +28 -0
  70. package/dist/components/Toast/toast-manager.js +47 -0
  71. package/dist/components/ToggleButton/ToggleButton.d.ts +26 -0
  72. package/dist/components/ToggleButton/ToggleButton.js +106 -0
  73. package/dist/components/ToggleGroup/ToggleGroup.d.ts +32 -0
  74. package/dist/components/ToggleGroup/ToggleGroup.js +79 -0
  75. package/dist/components/Tooltip/Tooltip.d.ts +16 -0
  76. package/dist/components/Tooltip/Tooltip.js +58 -0
  77. package/dist/components/Tooltip/TooltipGroup.d.ts +22 -0
  78. package/dist/components/Tooltip/TooltipGroup.js +65 -0
  79. package/dist/components/Typography/Typography.d.ts +17 -0
  80. package/dist/components/Typography/Typography.js +100 -0
  81. package/dist/editor-forms.d.ts +1 -0
  82. package/dist/editor-forms.js +1 -0
  83. package/dist/editor.d.ts +1 -0
  84. package/dist/editor.js +1 -0
  85. package/dist/fonts/LICENSE +93 -0
  86. package/dist/fonts/inter-cyrillic-ext-wght-normal.woff2 +0 -0
  87. package/dist/fonts/inter-cyrillic-wght-normal.woff2 +0 -0
  88. package/dist/fonts/inter-greek-ext-wght-normal.woff2 +0 -0
  89. package/dist/fonts/inter-greek-wght-normal.woff2 +0 -0
  90. package/dist/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
  91. package/dist/fonts/inter-latin-wght-normal.woff2 +0 -0
  92. package/dist/fonts/inter-vietnamese-wght-normal.woff2 +0 -0
  93. package/dist/fonts.css +69 -0
  94. package/dist/forms.d.ts +22 -0
  95. package/dist/forms.js +23 -0
  96. package/dist/foundation.css +23 -0
  97. package/dist/global.css +116 -0
  98. package/dist/hooks/useAppToast.d.ts +12 -0
  99. package/dist/hooks/useAppToast.js +29 -0
  100. package/dist/icons/icons.d.ts +43 -0
  101. package/dist/icons/icons.js +44 -0
  102. package/dist/index.d.ts +106 -0
  103. package/dist/index.js +101 -0
  104. package/dist/patterns/Accordion/Accordion.d.ts +35 -0
  105. package/dist/patterns/Accordion/Accordion.js +139 -0
  106. package/dist/patterns/Alert/Alert.d.ts +38 -0
  107. package/dist/patterns/Alert/Alert.js +151 -0
  108. package/dist/patterns/AppShell/AppShell.d.ts +39 -0
  109. package/dist/patterns/AppShell/AppShell.js +218 -0
  110. package/dist/patterns/Breadcrumbs/Breadcrumbs.d.ts +21 -0
  111. package/dist/patterns/Breadcrumbs/Breadcrumbs.js +73 -0
  112. package/dist/patterns/Calendar/Calendar.d.ts +59 -0
  113. package/dist/patterns/Calendar/Calendar.js +283 -0
  114. package/dist/patterns/Calendar/DateRangePicker.d.ts +53 -0
  115. package/dist/patterns/Calendar/DateRangePicker.js +266 -0
  116. package/dist/patterns/Calendar/FormDateRangeField.d.ts +24 -0
  117. package/dist/patterns/Calendar/FormDateRangeField.js +138 -0
  118. package/dist/patterns/Card/Card.d.ts +26 -0
  119. package/dist/patterns/Card/Card.js +125 -0
  120. package/dist/patterns/Carousel/Carousel.d.ts +33 -0
  121. package/dist/patterns/Carousel/Carousel.js +127 -0
  122. package/dist/patterns/Cascader/Cascader.d.ts +53 -0
  123. package/dist/patterns/Cascader/Cascader.js +371 -0
  124. package/dist/patterns/Cascader/FormCascaderField.d.ts +21 -0
  125. package/dist/patterns/Cascader/FormCascaderField.js +130 -0
  126. package/dist/patterns/Charts/AreaChart.d.ts +13 -0
  127. package/dist/patterns/Charts/AreaChart.js +220 -0
  128. package/dist/patterns/Charts/BarChart.d.ts +11 -0
  129. package/dist/patterns/Charts/BarChart.js +220 -0
  130. package/dist/patterns/Charts/DonutChart.d.ts +37 -0
  131. package/dist/patterns/Charts/DonutChart.js +215 -0
  132. package/dist/patterns/Charts/GaugeChart.d.ts +44 -0
  133. package/dist/patterns/Charts/GaugeChart.js +210 -0
  134. package/dist/patterns/Charts/LineChart.d.ts +14 -0
  135. package/dist/patterns/Charts/LineChart.js +222 -0
  136. package/dist/patterns/Charts/Sparkline.d.ts +24 -0
  137. package/dist/patterns/Charts/Sparkline.js +81 -0
  138. package/dist/patterns/Charts/chart-parts.d.ts +139 -0
  139. package/dist/patterns/Charts/chart-parts.js +385 -0
  140. package/dist/patterns/Charts/gauge-math.d.ts +20 -0
  141. package/dist/patterns/Charts/gauge-math.js +21 -0
  142. package/dist/patterns/Charts/sparkline-path.d.ts +11 -0
  143. package/dist/patterns/Charts/sparkline-path.js +24 -0
  144. package/dist/patterns/ColorPicker/ColorPicker.d.ts +50 -0
  145. package/dist/patterns/ColorPicker/ColorPicker.js +590 -0
  146. package/dist/patterns/ColorPicker/FormColorField.d.ts +21 -0
  147. package/dist/patterns/ColorPicker/FormColorField.js +130 -0
  148. package/dist/patterns/ColorPicker/color-value.d.ts +19 -0
  149. package/dist/patterns/ColorPicker/color-value.js +72 -0
  150. package/dist/patterns/Combobox/Autocomplete.d.ts +48 -0
  151. package/dist/patterns/Combobox/Autocomplete.js +158 -0
  152. package/dist/patterns/Combobox/Combobox.d.ts +52 -0
  153. package/dist/patterns/Combobox/Combobox.js +195 -0
  154. package/dist/patterns/Combobox/ComboboxPopup.d.ts +24 -0
  155. package/dist/patterns/Combobox/ComboboxPopup.js +107 -0
  156. package/dist/patterns/Combobox/FormAutocompleteField.d.ts +17 -0
  157. package/dist/patterns/Combobox/FormAutocompleteField.js +119 -0
  158. package/dist/patterns/Combobox/FormComboboxField.d.ts +18 -0
  159. package/dist/patterns/Combobox/FormComboboxField.js +119 -0
  160. package/dist/patterns/Combobox/FormMultiSelectField.d.ts +18 -0
  161. package/dist/patterns/Combobox/FormMultiSelectField.js +119 -0
  162. package/dist/patterns/Combobox/MultiSelect.d.ts +54 -0
  163. package/dist/patterns/Combobox/MultiSelect.js +175 -0
  164. package/dist/patterns/CommandPalette/CommandPalette.d.ts +50 -0
  165. package/dist/patterns/CommandPalette/CommandPalette.js +193 -0
  166. package/dist/patterns/DataTable/DataTable.d.ts +107 -0
  167. package/dist/patterns/DataTable/DataTable.js +364 -0
  168. package/dist/patterns/DateTimePicker/DateTimePanel.d.ts +28 -0
  169. package/dist/patterns/DateTimePicker/DateTimePanel.js +444 -0
  170. package/dist/patterns/DateTimePicker/DateTimePicker.d.ts +75 -0
  171. package/dist/patterns/DateTimePicker/DateTimePicker.js +271 -0
  172. package/dist/patterns/DateTimePicker/FormDateTimeField.d.ts +32 -0
  173. package/dist/patterns/DateTimePicker/FormDateTimeField.js +148 -0
  174. package/dist/patterns/DateTimePicker/TimeSliders.d.ts +14 -0
  175. package/dist/patterns/DateTimePicker/TimeSliders.js +206 -0
  176. package/dist/patterns/DateTimePicker/picker-labels.d.ts +30 -0
  177. package/dist/patterns/DateTimePicker/picker-labels.js +23 -0
  178. package/dist/patterns/DateTimePicker/picker-values.d.ts +98 -0
  179. package/dist/patterns/DateTimePicker/picker-values.js +194 -0
  180. package/dist/patterns/DescriptionList/DescriptionList.d.ts +20 -0
  181. package/dist/patterns/DescriptionList/DescriptionList.js +57 -0
  182. package/dist/patterns/Dialog/Dialog.d.ts +26 -0
  183. package/dist/patterns/Dialog/Dialog.js +212 -0
  184. package/dist/patterns/Drawer/Drawer.d.ts +33 -0
  185. package/dist/patterns/Drawer/Drawer.js +153 -0
  186. package/dist/patterns/EmptyState/EmptyState.d.ts +35 -0
  187. package/dist/patterns/EmptyState/EmptyState.js +44 -0
  188. package/dist/patterns/FileUpload/FileUpload.d.ts +87 -0
  189. package/dist/patterns/FileUpload/FileUpload.js +417 -0
  190. package/dist/patterns/FileUpload/FormFileUploadField.d.ts +19 -0
  191. package/dist/patterns/FileUpload/FormFileUploadField.js +117 -0
  192. package/dist/patterns/FileUpload/add-files.d.ts +26 -0
  193. package/dist/patterns/FileUpload/add-files.js +35 -0
  194. package/dist/patterns/FileUpload/file-size.d.ts +14 -0
  195. package/dist/patterns/FileUpload/file-size.js +44 -0
  196. package/dist/patterns/FormField/CheckboxField.d.ts +26 -0
  197. package/dist/patterns/FormField/CheckboxField.js +97 -0
  198. package/dist/patterns/FormField/FieldFrame.d.ts +85 -0
  199. package/dist/patterns/FormField/FieldFrame.js +257 -0
  200. package/dist/patterns/FormField/FormCheckboxField.d.ts +17 -0
  201. package/dist/patterns/FormField/FormCheckboxField.js +92 -0
  202. package/dist/patterns/FormField/FormRadioGroupField.d.ts +16 -0
  203. package/dist/patterns/FormField/FormRadioGroupField.js +97 -0
  204. package/dist/patterns/FormField/FormRatingField.d.ts +19 -0
  205. package/dist/patterns/FormField/FormRatingField.js +119 -0
  206. package/dist/patterns/FormField/FormSelectField.d.ts +16 -0
  207. package/dist/patterns/FormField/FormSelectField.js +91 -0
  208. package/dist/patterns/FormField/FormSliderField.d.ts +22 -0
  209. package/dist/patterns/FormField/FormSliderField.js +128 -0
  210. package/dist/patterns/FormField/FormSwitchField.d.ts +19 -0
  211. package/dist/patterns/FormField/FormSwitchField.js +88 -0
  212. package/dist/patterns/FormField/FormTextAreaField.d.ts +12 -0
  213. package/dist/patterns/FormField/FormTextAreaField.js +91 -0
  214. package/dist/patterns/FormField/FormTextField.d.ts +23 -0
  215. package/dist/patterns/FormField/FormTextField.js +103 -0
  216. package/dist/patterns/FormField/RadioGroupField.d.ts +38 -0
  217. package/dist/patterns/FormField/RadioGroupField.js +201 -0
  218. package/dist/patterns/FormField/SelectField.d.ts +43 -0
  219. package/dist/patterns/FormField/SelectField.js +211 -0
  220. package/dist/patterns/FormField/SwitchField.d.ts +27 -0
  221. package/dist/patterns/FormField/SwitchField.js +105 -0
  222. package/dist/patterns/FormField/TextAreaField.d.ts +37 -0
  223. package/dist/patterns/FormField/TextAreaField.js +134 -0
  224. package/dist/patterns/FormField/TextField.d.ts +51 -0
  225. package/dist/patterns/FormField/TextField.js +256 -0
  226. package/dist/patterns/FormField/error-message.d.ts +6 -0
  227. package/dist/patterns/FormField/error-message.js +8 -0
  228. package/dist/patterns/FormField/field-styles.d.ts +44 -0
  229. package/dist/patterns/FormField/field-styles.js +89 -0
  230. package/dist/patterns/FormField/field-types.d.ts +4 -0
  231. package/dist/patterns/FormField/use-field-ids.d.ts +18 -0
  232. package/dist/patterns/FormField/use-field-ids.js +53 -0
  233. package/dist/patterns/List/List.d.ts +38 -0
  234. package/dist/patterns/List/List.js +174 -0
  235. package/dist/patterns/MentionsInput/FormMentionsField.d.ts +18 -0
  236. package/dist/patterns/MentionsInput/FormMentionsField.js +124 -0
  237. package/dist/patterns/MentionsInput/MentionsInput.d.ts +57 -0
  238. package/dist/patterns/MentionsInput/MentionsInput.js +133 -0
  239. package/dist/patterns/MentionsInput/mention-text.d.ts +24 -0
  240. package/dist/patterns/MentionsInput/mention-text.js +31 -0
  241. package/dist/patterns/Menubar/Menubar.d.ts +22 -0
  242. package/dist/patterns/Menubar/Menubar.js +79 -0
  243. package/dist/patterns/NavigationMenu/NavigationMenu.d.ts +27 -0
  244. package/dist/patterns/NavigationMenu/NavigationMenu.js +104 -0
  245. package/dist/patterns/NumberField/FormNumberField.d.ts +18 -0
  246. package/dist/patterns/NumberField/FormNumberField.js +119 -0
  247. package/dist/patterns/NumberField/NumberField.d.ts +57 -0
  248. package/dist/patterns/NumberField/NumberField.js +242 -0
  249. package/dist/patterns/Pagination/Pagination.d.ts +31 -0
  250. package/dist/patterns/Pagination/Pagination.js +275 -0
  251. package/dist/patterns/Pagination/page-items.d.ts +18 -0
  252. package/dist/patterns/Pagination/page-items.js +40 -0
  253. package/dist/patterns/PhoneField/FormPhoneField.d.ts +22 -0
  254. package/dist/patterns/PhoneField/FormPhoneField.js +97 -0
  255. package/dist/patterns/PhoneField/PhoneField.d.ts +60 -0
  256. package/dist/patterns/PhoneField/PhoneField.js +448 -0
  257. package/dist/patterns/PhoneField/phone-value.d.ts +26 -0
  258. package/dist/patterns/PhoneField/phone-value.js +38 -0
  259. package/dist/patterns/QRCode/QRCode.d.ts +37 -0
  260. package/dist/patterns/QRCode/QRCode.js +120 -0
  261. package/dist/patterns/QRCode/qr-path.d.ts +7 -0
  262. package/dist/patterns/QRCode/qr-path.js +25 -0
  263. package/dist/patterns/ResizablePanels/ResizablePanels.d.ts +34 -0
  264. package/dist/patterns/ResizablePanels/ResizablePanels.js +175 -0
  265. package/dist/patterns/ResizablePanels/panel-sizes.d.ts +31 -0
  266. package/dist/patterns/ResizablePanels/panel-sizes.js +54 -0
  267. package/dist/patterns/RichTextEditor/FormRichTextField.d.ts +18 -0
  268. package/dist/patterns/RichTextEditor/FormRichTextField.js +118 -0
  269. package/dist/patterns/RichTextEditor/RichTextEditor.d.ts +71 -0
  270. package/dist/patterns/RichTextEditor/RichTextEditor.js +453 -0
  271. package/dist/patterns/SearchInput/SearchInput.d.ts +26 -0
  272. package/dist/patterns/SearchInput/SearchInput.js +98 -0
  273. package/dist/patterns/SideNav/SideNav.d.ts +50 -0
  274. package/dist/patterns/SideNav/SideNav.js +269 -0
  275. package/dist/patterns/Stat/Stat.d.ts +51 -0
  276. package/dist/patterns/Stat/Stat.js +292 -0
  277. package/dist/patterns/Stepper/Stepper.d.ts +35 -0
  278. package/dist/patterns/Stepper/Stepper.js +110 -0
  279. package/dist/patterns/TagGroup/TagGroup.d.ts +44 -0
  280. package/dist/patterns/TagGroup/TagGroup.js +151 -0
  281. package/dist/patterns/TagsInput/FormTagsInputField.d.ts +18 -0
  282. package/dist/patterns/TagsInput/FormTagsInputField.js +124 -0
  283. package/dist/patterns/TagsInput/TagsInput.d.ts +51 -0
  284. package/dist/patterns/TagsInput/TagsInput.js +97 -0
  285. package/dist/patterns/Timeline/Timeline.d.ts +29 -0
  286. package/dist/patterns/Timeline/Timeline.js +85 -0
  287. package/dist/patterns/Toolbar/Toolbar.d.ts +31 -0
  288. package/dist/patterns/Toolbar/Toolbar.js +105 -0
  289. package/dist/patterns/Tour/Tour.d.ts +38 -0
  290. package/dist/patterns/Tour/Tour.js +333 -0
  291. package/dist/patterns/TransferList/FormTransferListField.d.ts +19 -0
  292. package/dist/patterns/TransferList/FormTransferListField.js +117 -0
  293. package/dist/patterns/TransferList/TransferList.d.ts +53 -0
  294. package/dist/patterns/TransferList/TransferList.js +441 -0
  295. package/dist/patterns/TreeSelect/FormTreeSelectField.d.ts +28 -0
  296. package/dist/patterns/TreeSelect/FormTreeSelectField.js +88 -0
  297. package/dist/patterns/TreeSelect/TreeSelect.d.ts +49 -0
  298. package/dist/patterns/TreeSelect/TreeSelect.js +375 -0
  299. package/dist/patterns/TreeView/TreeView.d.ts +40 -0
  300. package/dist/patterns/TreeView/TreeView.js +296 -0
  301. package/dist/provider/DesignSystemProvider.d.ts +54 -0
  302. package/dist/provider/DesignSystemProvider.js +270 -0
  303. package/dist/provider/nonce.d.ts +7 -0
  304. package/dist/provider/nonce.js +13 -0
  305. package/dist/styles.css +2 -0
  306. package/dist/theme/chart-palette.d.ts +51 -0
  307. package/dist/theme/chart-palette.js +112 -0
  308. package/dist/theme/create-theme.d.ts +52 -0
  309. package/dist/theme/create-theme.js +75 -0
  310. package/dist/theme/style-element.d.ts +28 -0
  311. package/dist/theme/style-element.js +79 -0
  312. package/dist/theme/tenant-branding.d.ts +48 -0
  313. package/dist/theme/tenant-branding.js +65 -0
  314. package/dist/theme/theme-switch.d.ts +25 -0
  315. package/dist/theme/theme-switch.js +90 -0
  316. package/dist/theme/token-names.d.ts +3 -0
  317. package/dist/theme/token-names.js +166 -0
  318. package/dist/theme.css +241 -0
  319. package/dist/tokens.css +383 -0
  320. package/dist/types/direction.d.ts +4 -0
  321. package/dist/types/tone.d.ts +7 -0
  322. package/dist/utils/cn.d.ts +7 -0
  323. package/dist/utils/cn.js +50 -0
  324. package/dist/utils/first-field.d.ts +8 -0
  325. package/dist/utils/first-field.js +10 -0
  326. package/dist/utils/layout.d.ts +33 -0
  327. package/dist/utils/layout.js +30 -0
  328. package/dist/utils/popup.d.ts +12 -0
  329. package/dist/utils/popup.js +27 -0
  330. package/docs/accessibility.md +61 -0
  331. package/docs/advanced-components.md +38 -0
  332. package/docs/ai-assistants.md +44 -0
  333. package/docs/architecture.md +65 -0
  334. package/docs/browser-support.md +30 -0
  335. package/docs/charts.md +56 -0
  336. package/docs/components.md +2928 -0
  337. package/docs/conventions.md +19 -0
  338. package/docs/customization.md +79 -0
  339. package/docs/dates-files-data.md +48 -0
  340. package/docs/design-principles.md +50 -0
  341. package/docs/faq.md +68 -0
  342. package/docs/forms.md +114 -0
  343. package/docs/getting-started.md +64 -0
  344. package/docs/icons.md +48 -0
  345. package/docs/internationalization.md +64 -0
  346. package/docs/layout-and-navigation.md +51 -0
  347. package/docs/nextjs.md +69 -0
  348. package/docs/releasing.md +41 -0
  349. package/docs/testing.md +242 -0
  350. package/docs/theming.md +118 -0
  351. package/docs/typescript.md +62 -0
  352. package/llms-full.txt +4574 -0
  353. package/llms.txt +52 -0
  354. package/package.json +166 -6
@@ -0,0 +1,97 @@
1
+ "use client";
2
+ import { c } from "react/compiler-runtime";
3
+ import { Controller } from "react-hook-form";
4
+ import { toErrorText } from "../FormField/error-message.js";
5
+ import { PhoneField } from "./PhoneField.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/patterns/PhoneField/FormPhoneField.tsx
8
+ /**
9
+ * A PhoneField bound to a react-hook-form string field holding the number in E.164:
10
+ * the calling code and the digits with nothing between, e.g. "+12025550123"
11
+ * (`joinPhone` and `splitPhone` convert it). A searchable calling-code picker and a digits-only
12
+ * number share one box. The box is always left to right: numbers read that way
13
+ * in a right-to-left language too.
14
+ */
15
+ var FormPhoneField = (t0) => {
16
+ const $ = c(22);
17
+ let control;
18
+ let formatError;
19
+ let name;
20
+ let phoneProps;
21
+ let rules;
22
+ let t1;
23
+ let t2;
24
+ let t3;
25
+ if ($[0] !== t0) {
26
+ ({control, name, rules, formatError, maxDigits: t1, disabled: t2, size: t3, ...phoneProps} = t0);
27
+ $[0] = t0;
28
+ $[1] = control;
29
+ $[2] = formatError;
30
+ $[3] = name;
31
+ $[4] = phoneProps;
32
+ $[5] = rules;
33
+ $[6] = t1;
34
+ $[7] = t2;
35
+ $[8] = t3;
36
+ } else {
37
+ control = $[1];
38
+ formatError = $[2];
39
+ name = $[3];
40
+ phoneProps = $[4];
41
+ rules = $[5];
42
+ t1 = $[6];
43
+ t2 = $[7];
44
+ t3 = $[8];
45
+ }
46
+ const maxDigits = t1 === void 0 ? 13 : t1;
47
+ const disabled = t2 === void 0 ? false : t2;
48
+ const size = t3 === void 0 ? "medium" : t3;
49
+ let t4;
50
+ if ($[9] !== rules) {
51
+ t4 = rules ? { rules } : {};
52
+ $[9] = rules;
53
+ $[10] = t4;
54
+ } else t4 = $[10];
55
+ let t5;
56
+ if ($[11] !== disabled || $[12] !== formatError || $[13] !== maxDigits || $[14] !== phoneProps || $[15] !== size) {
57
+ t5 = (t6) => {
58
+ const { field, fieldState } = t6;
59
+ const errorMessage = toErrorText(fieldState.error?.message, formatError);
60
+ return /* @__PURE__ */ jsx(PhoneField, {
61
+ ...phoneProps,
62
+ maxDigits,
63
+ disabled,
64
+ size,
65
+ name: field.name,
66
+ inputRef: field.ref,
67
+ value: typeof field.value === "string" ? field.value : "",
68
+ onValueChange: field.onChange,
69
+ onBlur: field.onBlur,
70
+ invalid: fieldState.invalid,
71
+ ...errorMessage === void 0 ? {} : { errorMessage }
72
+ });
73
+ };
74
+ $[11] = disabled;
75
+ $[12] = formatError;
76
+ $[13] = maxDigits;
77
+ $[14] = phoneProps;
78
+ $[15] = size;
79
+ $[16] = t5;
80
+ } else t5 = $[16];
81
+ let t6;
82
+ if ($[17] !== control || $[18] !== name || $[19] !== t4 || $[20] !== t5) {
83
+ t6 = /* @__PURE__ */ jsx(Controller, {
84
+ control,
85
+ name,
86
+ ...t4,
87
+ render: t5
88
+ });
89
+ $[17] = control;
90
+ $[18] = name;
91
+ $[19] = t4;
92
+ $[20] = t5;
93
+ $[21] = t6;
94
+ } else t6 = $[21];
95
+ return t6;
96
+ };
97
+ export { FormPhoneField };
@@ -0,0 +1,60 @@
1
+ import { type Ref } from "react";
2
+ import type { FieldOrientation, FieldSize } from "../FormField/field-types.js";
3
+ /** A choice in the calling-code list. Several countries share a code, so `code` tells them apart. */
4
+ export interface PhoneCountry {
5
+ /** A unique key, e.g. the ISO country code "GB". */
6
+ code: string;
7
+ /** With the plus sign, e.g. "+44". */
8
+ dialCode: string;
9
+ /** The country's name, as shown. */
10
+ label: string;
11
+ /** Lower-case text the search also matches, e.g. the name in another language. */
12
+ searchText?: string | undefined;
13
+ }
14
+ /** The texts of the field. The design system has no i18n, so the caller supplies them. */
15
+ export interface PhoneFieldLabels {
16
+ /** Accessible name of the calling-code input. */
17
+ countryCode: string;
18
+ /** Shown when the typed text matches no country. */
19
+ noMatches: string;
20
+ }
21
+ export interface PhoneFieldProps {
22
+ label: string;
23
+ /**
24
+ * The number in E.164: the calling code and the digits with nothing between, e.g. "+12025550123"
25
+ * (`joinPhone` and `splitPhone` convert it). An empty string for none.
26
+ */
27
+ value: string;
28
+ /** Called with the new number in E.164, or "" when the digits are cleared. */
29
+ onValueChange: (value: string) => void;
30
+ countries: readonly PhoneCountry[];
31
+ /** The calling code shown while no number has been entered. */
32
+ defaultDialCode: string;
33
+ labels: PhoneFieldLabels;
34
+ /** The field's name in a submitted form. */
35
+ name?: string | undefined;
36
+ placeholder?: string | undefined;
37
+ /** The most digits the number takes. */
38
+ maxDigits?: number | undefined;
39
+ hint?: string | undefined;
40
+ /** The validation message, in the user's language: shown in red under the field, which it marks invalid. */
41
+ errorMessage?: string | undefined;
42
+ /** Marks the field invalid without a message to show. */
43
+ invalid?: boolean | undefined;
44
+ required?: boolean | undefined;
45
+ disabled?: boolean | undefined;
46
+ size?: FieldSize | undefined;
47
+ orientation?: FieldOrientation | undefined;
48
+ /** The calling code or the number was left. */
49
+ onBlur?: (() => void) | undefined;
50
+ /** The number's `<input>`, e.g. for a form library to focus the first invalid field. */
51
+ inputRef?: Ref<HTMLInputElement> | undefined;
52
+ }
53
+ /**
54
+ * A phone number: a searchable calling-code picker and a digits-only number in one box, holding the number in
55
+ * E.164. The box is always left to right: numbers read that way in a right-to-left language too. A number pasted
56
+ * with its calling code ("+44 7700 900123") sets the code as well as the digits. It is controlled: it shows `value`
57
+ * and reports each change through `onValueChange`; clearing the digits keeps the calling code shown. Bound to
58
+ * react-hook-form, it is FormPhoneField.
59
+ */
60
+ export declare const PhoneField: ({ label, value, onValueChange, countries, defaultDialCode, labels, name, placeholder, hint, errorMessage, required, orientation, onBlur, inputRef, invalid, maxDigits, disabled, size, }: PhoneFieldProps) => import("react").JSX.Element;
@@ -0,0 +1,448 @@
1
+ "use client";
2
+ import { c } from "react/compiler-runtime";
3
+ import { forwardRef, useId, useState } from "react";
4
+ import { Combobox } from "@base-ui/react/combobox";
5
+ import { Field } from "@base-ui/react/field";
6
+ import { Check, ChevronDown } from "lucide-react";
7
+ import { cn } from "../../utils/cn.js";
8
+ import { indicator, item, popup, positioner } from "../../utils/popup.js";
9
+ import { FieldFrame } from "../FormField/FieldFrame.js";
10
+ import { fieldControl, fieldInput } from "../FormField/field-styles.js";
11
+ import { joinPhone, readInternationalPhone, splitPhone } from "./phone-value.js";
12
+ import { jsx, jsxs } from "react/jsx-runtime";
13
+ // src/patterns/PhoneField/PhoneField.tsx
14
+ /**
15
+ * A phone number: a searchable calling-code picker and a digits-only number in one box, holding the number in
16
+ * E.164. The box is always left to right: numbers read that way in a right-to-left language too. A number pasted
17
+ * with its calling code ("+44 7700 900123") sets the code as well as the digits. It is controlled: it shows `value`
18
+ * and reports each change through `onValueChange`; clearing the digits keeps the calling code shown. Bound to
19
+ * react-hook-form, it is FormPhoneField.
20
+ */
21
+ var PhoneField = (t0) => {
22
+ const $ = c(39);
23
+ const { label, value, onValueChange, countries, defaultDialCode, labels, name, placeholder, hint, errorMessage, required, orientation, onBlur, inputRef, invalid: t1, maxDigits: t2, disabled: t3, size: t4 } = t0;
24
+ const invalid = t1 === void 0 ? false : t1;
25
+ const maxDigits = t2 === void 0 ? 13 : t2;
26
+ const disabled = t3 === void 0 ? false : t3;
27
+ const size = t4 === void 0 ? "medium" : t4;
28
+ const isInvalid = invalid || errorMessage !== void 0;
29
+ let t5;
30
+ if ($[0] !== name) {
31
+ t5 = name ? { name } : {};
32
+ $[0] = name;
33
+ $[1] = t5;
34
+ } else t5 = $[1];
35
+ let t6;
36
+ if ($[2] !== hint) {
37
+ t6 = hint ? { hint } : {};
38
+ $[2] = hint;
39
+ $[3] = t6;
40
+ } else t6 = $[3];
41
+ let t7;
42
+ if ($[4] !== required) {
43
+ t7 = required ? { required } : {};
44
+ $[4] = required;
45
+ $[5] = t7;
46
+ } else t7 = $[5];
47
+ let t8;
48
+ if ($[6] !== orientation) {
49
+ t8 = orientation ? { orientation } : {};
50
+ $[6] = orientation;
51
+ $[7] = t8;
52
+ } else t8 = $[7];
53
+ let t9;
54
+ if ($[8] !== errorMessage) {
55
+ t9 = errorMessage === void 0 ? {} : { errorMessage };
56
+ $[8] = errorMessage;
57
+ $[9] = t9;
58
+ } else t9 = $[9];
59
+ let t10;
60
+ if ($[10] !== onBlur) {
61
+ t10 = onBlur ? { onBlur } : {};
62
+ $[10] = onBlur;
63
+ $[11] = t10;
64
+ } else t10 = $[11];
65
+ const t11 = required ?? false;
66
+ let t12;
67
+ if ($[12] !== placeholder) {
68
+ t12 = placeholder ? { placeholder } : {};
69
+ $[12] = placeholder;
70
+ $[13] = t12;
71
+ } else t12 = $[13];
72
+ let t13;
73
+ if ($[14] !== countries || $[15] !== defaultDialCode || $[16] !== disabled || $[17] !== inputRef || $[18] !== isInvalid || $[19] !== labels || $[20] !== maxDigits || $[21] !== onValueChange || $[22] !== size || $[23] !== t10 || $[24] !== t11 || $[25] !== t12 || $[26] !== value) {
74
+ t13 = /* @__PURE__ */ jsx(PhoneControl, {
75
+ ref: inputRef,
76
+ value,
77
+ onChange: onValueChange,
78
+ ...t10,
79
+ invalid: isInvalid,
80
+ required: t11,
81
+ disabled,
82
+ countries,
83
+ defaultDialCode,
84
+ labels,
85
+ maxDigits,
86
+ size,
87
+ ...t12
88
+ });
89
+ $[14] = countries;
90
+ $[15] = defaultDialCode;
91
+ $[16] = disabled;
92
+ $[17] = inputRef;
93
+ $[18] = isInvalid;
94
+ $[19] = labels;
95
+ $[20] = maxDigits;
96
+ $[21] = onValueChange;
97
+ $[22] = size;
98
+ $[23] = t10;
99
+ $[24] = t11;
100
+ $[25] = t12;
101
+ $[26] = value;
102
+ $[27] = t13;
103
+ } else t13 = $[27];
104
+ let t14;
105
+ if ($[28] !== disabled || $[29] !== isInvalid || $[30] !== label || $[31] !== size || $[32] !== t13 || $[33] !== t5 || $[34] !== t6 || $[35] !== t7 || $[36] !== t8 || $[37] !== t9) {
106
+ t14 = /* @__PURE__ */ jsx(FieldFrame, {
107
+ label,
108
+ disabled,
109
+ invalid: isInvalid,
110
+ size,
111
+ ...t5,
112
+ ...t6,
113
+ ...t7,
114
+ ...t8,
115
+ ...t9,
116
+ children: t13
117
+ });
118
+ $[28] = disabled;
119
+ $[29] = isInvalid;
120
+ $[30] = label;
121
+ $[31] = size;
122
+ $[32] = t13;
123
+ $[33] = t5;
124
+ $[34] = t6;
125
+ $[35] = t7;
126
+ $[36] = t8;
127
+ $[37] = t9;
128
+ $[38] = t14;
129
+ } else t14 = $[38];
130
+ return t14;
131
+ };
132
+ var PhoneControl = forwardRef((t0, ref) => {
133
+ const $ = c(75);
134
+ const { value, onChange, onBlur, invalid, required, disabled, countries, defaultDialCode, labels, maxDigits, size, placeholder } = t0;
135
+ const [typed, setTyped] = useState(null);
136
+ const [pickedCode, setPickedCode] = useState(null);
137
+ const countryCodeLabelId = useId();
138
+ let t1;
139
+ if ($[0] !== countries || $[1] !== value) {
140
+ t1 = splitPhone(value, countries.map(_temp));
141
+ $[0] = countries;
142
+ $[1] = value;
143
+ $[2] = t1;
144
+ } else t1 = $[2];
145
+ const { dialCode: valueDialCode, digits } = t1;
146
+ let t2;
147
+ if ($[3] !== countries || $[4] !== pickedCode) {
148
+ let t3;
149
+ if ($[6] !== pickedCode) {
150
+ t3 = (country_0) => country_0.code === pickedCode;
151
+ $[6] = pickedCode;
152
+ $[7] = t3;
153
+ } else t3 = $[7];
154
+ t2 = countries.find(t3);
155
+ $[3] = countries;
156
+ $[4] = pickedCode;
157
+ $[5] = t2;
158
+ } else t2 = $[5];
159
+ const dialCode = valueDialCode || t2?.dialCode || defaultDialCode;
160
+ let t3;
161
+ if ($[8] !== countries || $[9] !== dialCode || $[10] !== pickedCode) {
162
+ t3 = countries.find((country_2) => country_2.code === pickedCode && country_2.dialCode === dialCode) ?? countries.find((country_1) => country_1.dialCode === dialCode) ?? null;
163
+ $[8] = countries;
164
+ $[9] = dialCode;
165
+ $[10] = pickedCode;
166
+ $[11] = t3;
167
+ } else t3 = $[11];
168
+ const selected = t3;
169
+ const t4 = typed ?? "";
170
+ let t5;
171
+ if ($[12] !== countries || $[13] !== t4) {
172
+ const query = t4.trim().toLowerCase();
173
+ const codeQuery = query.replace(/^\+/, "");
174
+ t5 = query ? countries.filter((country_3) => country_3.label.toLowerCase().includes(query) || country_3.searchText?.includes(query) === true || country_3.dialCode.replace("+", "").startsWith(codeQuery)) : countries;
175
+ $[12] = countries;
176
+ $[13] = t4;
177
+ $[14] = t5;
178
+ } else t5 = $[14];
179
+ const visible = t5;
180
+ let t6;
181
+ if ($[15] !== size) {
182
+ t6 = cn(fieldControl({ size }), "gap-0 ps-0");
183
+ $[15] = size;
184
+ $[16] = t6;
185
+ } else t6 = $[16];
186
+ const t7 = invalid || void 0;
187
+ const t8 = disabled || void 0;
188
+ let t9;
189
+ if ($[17] !== countryCodeLabelId || $[18] !== labels.countryCode) {
190
+ t9 = /* @__PURE__ */ jsx("span", {
191
+ id: countryCodeLabelId,
192
+ hidden: true,
193
+ children: labels.countryCode
194
+ });
195
+ $[17] = countryCodeLabelId;
196
+ $[18] = labels.countryCode;
197
+ $[19] = t9;
198
+ } else t9 = $[19];
199
+ let t10;
200
+ if ($[20] !== digits || $[21] !== onChange) {
201
+ t10 = (next) => {
202
+ if (!next) return;
203
+ setPickedCode(next.code);
204
+ if (digits) onChange(joinPhone(next.dialCode, digits));
205
+ };
206
+ $[20] = digits;
207
+ $[21] = onChange;
208
+ $[22] = t10;
209
+ } else t10 = $[22];
210
+ const t11 = typed ?? dialCode;
211
+ let t12;
212
+ let t13;
213
+ if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
214
+ t12 = (next_0, details) => {
215
+ if (details.reason === "input-change") setTyped(next_0);
216
+ };
217
+ t13 = (open) => {
218
+ if (!open) setTyped(null);
219
+ };
220
+ $[23] = t12;
221
+ $[24] = t13;
222
+ } else {
223
+ t12 = $[23];
224
+ t13 = $[24];
225
+ }
226
+ let t14;
227
+ if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
228
+ t14 = cn(fieldInput, "text-body-sm font-medium");
229
+ $[25] = t14;
230
+ } else t14 = $[25];
231
+ let t15;
232
+ if ($[26] !== countryCodeLabelId || $[27] !== onBlur) {
233
+ t15 = /* @__PURE__ */ jsx(Combobox.Input, {
234
+ "aria-labelledby": countryCodeLabelId,
235
+ className: t14,
236
+ autoComplete: "off",
237
+ onFocus: _temp4,
238
+ onBlur
239
+ });
240
+ $[26] = countryCodeLabelId;
241
+ $[27] = onBlur;
242
+ $[28] = t15;
243
+ } else t15 = $[28];
244
+ let t16;
245
+ if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
246
+ t16 = /* @__PURE__ */ jsx(Combobox.Trigger, {
247
+ className: "inline-flex w-4 shrink-0 cursor-pointer items-center justify-center self-stretch border-0 bg-transparent p-0 text-fg-secondary outline-none disabled:cursor-not-allowed [&_svg]:size-3.5",
248
+ "aria-hidden": "true",
249
+ "aria-labelledby": void 0,
250
+ tabIndex: -1,
251
+ children: /* @__PURE__ */ jsx(ChevronDown, {})
252
+ });
253
+ $[29] = t16;
254
+ } else t16 = $[29];
255
+ let t17;
256
+ if ($[30] !== t15) {
257
+ t17 = /* @__PURE__ */ jsxs(Combobox.InputGroup, {
258
+ className: "flex w-27 shrink-0 items-center gap-1 self-stretch border-e border-line ps-3 pe-1.5",
259
+ children: [t15, t16]
260
+ });
261
+ $[30] = t15;
262
+ $[31] = t17;
263
+ } else t17 = $[31];
264
+ let t18;
265
+ if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
266
+ t18 = cn(popup, "w-72 max-w-(--available-width) max-h-[min(20rem,var(--available-height))]");
267
+ $[32] = t18;
268
+ } else t18 = $[32];
269
+ let t19;
270
+ if ($[33] !== labels.noMatches) {
271
+ t19 = /* @__PURE__ */ jsx(Combobox.Empty, {
272
+ className: "px-2 py-1.5 text-body-sm text-fg-secondary empty:hidden",
273
+ children: labels.noMatches
274
+ });
275
+ $[33] = labels.noMatches;
276
+ $[34] = t19;
277
+ } else t19 = $[34];
278
+ let t20;
279
+ if ($[35] !== countryCodeLabelId) {
280
+ t20 = /* @__PURE__ */ jsx(Combobox.List, {
281
+ "aria-labelledby": countryCodeLabelId,
282
+ children: _temp5
283
+ });
284
+ $[35] = countryCodeLabelId;
285
+ $[36] = t20;
286
+ } else t20 = $[36];
287
+ let t21;
288
+ if ($[37] !== t19 || $[38] !== t20) {
289
+ t21 = /* @__PURE__ */ jsx(Combobox.Portal, { children: /* @__PURE__ */ jsx(Combobox.Positioner, {
290
+ className: positioner,
291
+ sideOffset: 6,
292
+ align: "start",
293
+ children: /* @__PURE__ */ jsxs(Combobox.Popup, {
294
+ className: t18,
295
+ children: [t19, t20]
296
+ })
297
+ }) });
298
+ $[37] = t19;
299
+ $[38] = t20;
300
+ $[39] = t21;
301
+ } else t21 = $[39];
302
+ let t22;
303
+ if ($[40] !== disabled || $[41] !== selected || $[42] !== t10 || $[43] !== t11 || $[44] !== t17 || $[45] !== t21 || $[46] !== visible) {
304
+ t22 = /* @__PURE__ */ jsxs(Combobox.Root, {
305
+ items: visible,
306
+ filter: null,
307
+ value: selected,
308
+ onValueChange: t10,
309
+ inputValue: t11,
310
+ onInputValueChange: t12,
311
+ onOpenChange: t13,
312
+ itemToStringLabel: _temp2,
313
+ isItemEqualToValue: _temp3,
314
+ disabled,
315
+ children: [t17, t21]
316
+ });
317
+ $[40] = disabled;
318
+ $[41] = selected;
319
+ $[42] = t10;
320
+ $[43] = t11;
321
+ $[44] = t17;
322
+ $[45] = t21;
323
+ $[46] = visible;
324
+ $[47] = t22;
325
+ } else t22 = $[47];
326
+ let t23;
327
+ if ($[48] === Symbol.for("react.memo_cache_sentinel")) {
328
+ t23 = cn(fieldInput, "ps-3");
329
+ $[48] = t23;
330
+ } else t23 = $[48];
331
+ const t24 = required || void 0;
332
+ let t25;
333
+ if ($[49] !== dialCode || $[50] !== maxDigits || $[51] !== onChange || $[52] !== selected?.code) {
334
+ t25 = (next_1) => {
335
+ const onlyDigits = next_1.replace(/\D/g, "").slice(0, maxDigits);
336
+ if (!onlyDigits) setPickedCode(selected?.code ?? null);
337
+ onChange(onlyDigits ? joinPhone(dialCode, onlyDigits) : "");
338
+ };
339
+ $[49] = dialCode;
340
+ $[50] = maxDigits;
341
+ $[51] = onChange;
342
+ $[52] = selected?.code;
343
+ $[53] = t25;
344
+ } else t25 = $[53];
345
+ let t26;
346
+ if ($[54] !== countries || $[55] !== maxDigits || $[56] !== onChange || $[57] !== selected?.code) {
347
+ t26 = (event_0) => {
348
+ const pasted = readInternationalPhone(event_0.clipboardData.getData("text/plain"), countries.map(_temp6));
349
+ if (!pasted) return;
350
+ event_0.preventDefault();
351
+ const country_7 = countries.find((option_0) => option_0.code === selected?.code && option_0.dialCode === pasted.dialCode) ?? countries.find((option) => option.dialCode === pasted.dialCode);
352
+ setPickedCode(country_7?.code ?? null);
353
+ const pastedDigits = pasted.digits.slice(0, maxDigits);
354
+ onChange(pastedDigits ? joinPhone(pasted.dialCode, pastedDigits) : "");
355
+ };
356
+ $[54] = countries;
357
+ $[55] = maxDigits;
358
+ $[56] = onChange;
359
+ $[57] = selected?.code;
360
+ $[58] = t26;
361
+ } else t26 = $[58];
362
+ let t27;
363
+ if ($[59] !== digits || $[60] !== disabled || $[61] !== onBlur || $[62] !== placeholder || $[63] !== ref || $[64] !== t24 || $[65] !== t25 || $[66] !== t26) {
364
+ t27 = /* @__PURE__ */ jsx(Field.Control, {
365
+ ref,
366
+ className: t23,
367
+ type: "text",
368
+ inputMode: "numeric",
369
+ autoComplete: "tel-national",
370
+ placeholder,
371
+ disabled,
372
+ "aria-required": t24,
373
+ value: digits,
374
+ onValueChange: t25,
375
+ onPaste: t26,
376
+ onBlur
377
+ });
378
+ $[59] = digits;
379
+ $[60] = disabled;
380
+ $[61] = onBlur;
381
+ $[62] = placeholder;
382
+ $[63] = ref;
383
+ $[64] = t24;
384
+ $[65] = t25;
385
+ $[66] = t26;
386
+ $[67] = t27;
387
+ } else t27 = $[67];
388
+ let t28;
389
+ if ($[68] !== t22 || $[69] !== t27 || $[70] !== t6 || $[71] !== t7 || $[72] !== t8 || $[73] !== t9) {
390
+ t28 = /* @__PURE__ */ jsxs("div", {
391
+ dir: "ltr",
392
+ className: t6,
393
+ "data-invalid": t7,
394
+ "data-disabled": t8,
395
+ children: [
396
+ t9,
397
+ t22,
398
+ t27
399
+ ]
400
+ });
401
+ $[68] = t22;
402
+ $[69] = t27;
403
+ $[70] = t6;
404
+ $[71] = t7;
405
+ $[72] = t8;
406
+ $[73] = t9;
407
+ $[74] = t28;
408
+ } else t28 = $[74];
409
+ return t28;
410
+ });
411
+ PhoneControl.displayName = "PhoneControl";
412
+ function _temp(country) {
413
+ return country.dialCode;
414
+ }
415
+ function _temp2(country_4) {
416
+ return country_4.dialCode;
417
+ }
418
+ function _temp3(a, b) {
419
+ return a.code === b.code;
420
+ }
421
+ function _temp4(event) {
422
+ event.currentTarget.select();
423
+ }
424
+ function _temp5(country_5) {
425
+ return /* @__PURE__ */ jsxs(Combobox.Item, {
426
+ value: country_5,
427
+ className: cn(item, "gap-2"),
428
+ children: [
429
+ /* @__PURE__ */ jsx("span", {
430
+ className: indicator,
431
+ children: /* @__PURE__ */ jsx(Combobox.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { "aria-hidden": "true" }) })
432
+ }),
433
+ /* @__PURE__ */ jsx("span", {
434
+ dir: "ltr",
435
+ className: "w-12 shrink-0 text-fg-secondary tabular-nums",
436
+ children: country_5.dialCode
437
+ }),
438
+ /* @__PURE__ */ jsx("span", {
439
+ className: "min-w-0 truncate",
440
+ children: country_5.label
441
+ })
442
+ ]
443
+ }, country_5.code);
444
+ }
445
+ function _temp6(country_6) {
446
+ return country_6.dialCode;
447
+ }
448
+ export { PhoneField };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * A phone number as the form and the backend hold it: E.164, the calling code and the digits with nothing
3
+ * between them, e.g. "+972541234567". An empty string is "no number". FormPhoneField reads and writes this
4
+ * format, and nothing else does the splitting.
5
+ */
6
+ /** Joins a calling code ("+972") and the digits ("541234567") into E.164: "+972541234567". */
7
+ export declare const joinPhone: (dialCode: string, digits: string) => string;
8
+ /**
9
+ * Splits an E.164 number into its calling code and digits. E.164 has no separator, so the code is the longest
10
+ * of `dialCodes` (with their plus sign, e.g. "+1", "+972") that the number starts with. Spaces, hyphens and
11
+ * brackets are ignored, so "+972-54-123 4567" reads too. A number that starts with none of them has no code
12
+ * and all its digits.
13
+ */
14
+ export declare const splitPhone: (value: string, dialCodes: readonly string[]) => {
15
+ dialCode: string;
16
+ digits: string;
17
+ };
18
+ /**
19
+ * Reads text pasted into a phone number's digits. Text that starts with a plus sign and one of `dialCodes`
20
+ * ("+44 7700 900123") is a whole international number: its calling code and its digits. Anything else (digits
21
+ * alone, or a code that is not offered) gives null, and is the number's digits for the code already chosen.
22
+ */
23
+ export declare const readInternationalPhone: (text: string, dialCodes: readonly string[]) => {
24
+ dialCode: string;
25
+ digits: string;
26
+ } | null;
@@ -0,0 +1,38 @@
1
+ // src/patterns/PhoneField/phone-value.ts
2
+ /**
3
+ * A phone number as the form and the backend hold it: E.164, the calling code and the digits with nothing
4
+ * between them, e.g. "+972541234567". An empty string is "no number". FormPhoneField reads and writes this
5
+ * format, and nothing else does the splitting.
6
+ */
7
+ /** Joins a calling code ("+972") and the digits ("541234567") into E.164: "+972541234567". */
8
+ var joinPhone = (dialCode, digits) => `${dialCode.trim()}${digits.trim()}`;
9
+ /**
10
+ * Splits an E.164 number into its calling code and digits. E.164 has no separator, so the code is the longest
11
+ * of `dialCodes` (with their plus sign, e.g. "+1", "+972") that the number starts with. Spaces, hyphens and
12
+ * brackets are ignored, so "+972-54-123 4567" reads too. A number that starts with none of them has no code
13
+ * and all its digits.
14
+ */
15
+ var splitPhone = (value, dialCodes) => {
16
+ const compact = value.replace(/[\s\-().]/g, "");
17
+ if (compact === "") return {
18
+ dialCode: "",
19
+ digits: ""
20
+ };
21
+ const dialCode = dialCodes.filter((code) => code !== "" && compact.startsWith(code)).reduce((longest, code) => code.length > longest.length ? code : longest, "");
22
+ return {
23
+ dialCode,
24
+ digits: compact.slice(dialCode.length).replace(/\D/g, "")
25
+ };
26
+ };
27
+ /**
28
+ * Reads text pasted into a phone number's digits. Text that starts with a plus sign and one of `dialCodes`
29
+ * ("+44 7700 900123") is a whole international number: its calling code and its digits. Anything else (digits
30
+ * alone, or a code that is not offered) gives null, and is the number's digits for the code already chosen.
31
+ */
32
+ var readInternationalPhone = (text, dialCodes) => {
33
+ const trimmed = text.trim();
34
+ if (!trimmed.startsWith("+")) return null;
35
+ const parts = splitPhone(trimmed, dialCodes);
36
+ return parts.dialCode === "" ? null : parts;
37
+ };
38
+ export { joinPhone, readInternationalPhone, splitPhone };