@primecoderin/fast-ui-react 0.0.0-stage → 1.0.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 +106 -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 +40 -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 +4573 -0
  353. package/llms.txt +52 -0
  354. package/package.json +193 -6
@@ -0,0 +1,139 @@
1
+ import { type ReactNode, type RefObject } from "react";
2
+ /** One row of a chart's data: the x value and a number for each series, by key. A `null` is a gap. */
3
+ export type ChartDatum = Readonly<Record<string, string | number | null>>;
4
+ export interface ChartSeries {
5
+ /** The key of the number in each datum. */
6
+ key: string;
7
+ /** The series' name, in the user's language: the legend, the tooltip and the data table say it. */
8
+ label: string;
9
+ /** A CSS colour or variable, e.g. `"var(--fast-tone-success-solid)"`. The chart tokens in order of use if omitted. */
10
+ color?: string | undefined;
11
+ }
12
+ /** What the charts that draw against two axes (line, area, bar) take. */
13
+ export interface CartesianChartProps {
14
+ /** The rows to draw, in x order. With none the chart draws its axes only, and its data table has no rows. */
15
+ data: readonly ChartDatum[];
16
+ /** The key of the x value in each datum: a month, a date, a category. */
17
+ xKey: string;
18
+ /** What the x values are called, for the data table a screen reader reads: "Month". The `xKey` if omitted. */
19
+ xLabel?: string | undefined;
20
+ /** The measures to draw, one line, area or bar group each. Five is the most the colours can tell apart. */
21
+ series: readonly ChartSeries[];
22
+ /** What the chart shows, e.g. "Orders per month". It names the chart and its data table. */
23
+ "aria-label": string;
24
+ /** The height of the plot in pixels. Default 240. The width is the container's. */
25
+ height?: number | undefined;
26
+ /** Writes an x value on the axis, in the tooltip and in the data table. */
27
+ formatX?: ((value: string | number) => string) | undefined;
28
+ /** Writes a number on the value axis, in the tooltip and in the data table: `(n) => `${n} kr``. */
29
+ formatValue?: ((value: number) => string) | undefined;
30
+ /** Leave out the legend under the chart (for one series, whose name the heading says). */
31
+ hideLegend?: boolean | undefined;
32
+ /** Leave out the grid lines. */
33
+ hideGrid?: boolean | undefined;
34
+ /** Extra classes for the chart's box. Merged last. */
35
+ className?: string | undefined;
36
+ }
37
+ /** The colour of the series at `index`: its own, or the chart token for its place (the first five, then round again). */
38
+ export declare const seriesColor: (index: number, color?: string) => string;
39
+ /**
40
+ * The dash pattern of the line of the series at `index`, as an SVG `stroke-dasharray`: none (solid) for the first,
41
+ * then dashes, dots and mixes, round again after five like the colours. A reader who cannot tell the colours apart
42
+ * tells the lines apart by these, and the legend draws the same.
43
+ */
44
+ export declare const seriesDash: (index: number) => string | undefined;
45
+ /** The text style of axis ticks, from the chart tokens: the caption size, in the colour of the axis. */
46
+ export declare const AXIS_TICK: {
47
+ readonly fill: "var(--fast-chart-axis)";
48
+ readonly fontSize: "var(--fast-text-caption)";
49
+ };
50
+ /** The line along the x axis. */
51
+ export declare const AXIS_LINE: {
52
+ readonly stroke: "var(--fast-chart-grid)";
53
+ };
54
+ export declare const GRID_STROKE = "var(--fast-chart-grid)";
55
+ /** The guide that follows the pointer. */
56
+ export declare const CURSOR_STROKE: {
57
+ readonly stroke: "var(--fast-chart-axis)";
58
+ readonly strokeDasharray: "3 3";
59
+ };
60
+ /** Whether the visitor asks for less motion: a chart then draws at once instead of growing. */
61
+ export declare const usePrefersReducedMotion: () => boolean;
62
+ /**
63
+ * A number that goes up when the chart's font changes: a theme with another font family, the switch to right to
64
+ * left (which changes the font), or a web font that finishes loading. Recharts measures the value axis's labels
65
+ * once (`width="auto"`), so a chart uses the number as the `key` of its Recharts chart, which then draws and
66
+ * measures again in the new font.
67
+ *
68
+ * It watches a hidden sample of text in the chart's font (put `probe` on ChartFrame's `fontProbe`): when the
69
+ * sample's width changes, the font has. One observer per chart and no global listeners; nothing runs on the server,
70
+ * and an ordinary redraw does not change the number.
71
+ */
72
+ export declare const useChartFontVersion: () => {
73
+ version: number;
74
+ probe: RefObject<HTMLSpanElement | null>;
75
+ };
76
+ interface LegendItem {
77
+ label: string;
78
+ color: string;
79
+ /** Written after the label, e.g. a donut slice's value. */
80
+ value?: string | undefined;
81
+ /** Draw the swatch as a short line in this dash pattern (`seriesDash`), as the series is drawn. A dot if omitted. */
82
+ line?: {
83
+ dash: string | undefined;
84
+ } | undefined;
85
+ }
86
+ /** The swatches and names under a chart. Decorative: the data table already says all of it to a screen reader. */
87
+ export declare const ChartLegend: ({ items }: {
88
+ items: readonly LegendItem[];
89
+ }) => import("react").JSX.Element;
90
+ interface TooltipRow {
91
+ name?: unknown;
92
+ value?: unknown;
93
+ color?: string | undefined;
94
+ stroke?: string | undefined;
95
+ fill?: string | undefined;
96
+ }
97
+ interface ChartTooltipProps {
98
+ active?: boolean | undefined;
99
+ payload?: readonly TooltipRow[] | undefined;
100
+ label?: unknown;
101
+ /** Writes the heading, the x value. */
102
+ formatLabel?: ((value: string | number) => string) | undefined;
103
+ formatValue?: ((value: number) => string) | undefined;
104
+ }
105
+ /**
106
+ * The box that follows the pointer over a chart: the x value, and a swatch, a name and a value for each series. It
107
+ * sits in the plot, which is always left to right, so it takes the page's direction back for its own text.
108
+ */
109
+ export declare const ChartTooltip: ({ active, payload, label, formatLabel, formatValue }: ChartTooltipProps) => import("react").JSX.Element | null;
110
+ interface ChartFrameProps {
111
+ /** The plot. It is hidden from a screen reader, which reads `table` instead. */
112
+ children: ReactNode;
113
+ height: number;
114
+ legend?: ReactNode | undefined;
115
+ /** The data as a table, visually hidden. */
116
+ table: ReactNode;
117
+ "aria-label": string;
118
+ /** The `probe` of `useChartFontVersion`: a hidden sample of text in the plot's font, which it watches. */
119
+ fontProbe?: RefObject<HTMLSpanElement | null> | undefined;
120
+ className?: string | undefined;
121
+ }
122
+ /**
123
+ * What every chart sits in: the plot at a set height, always left to right (an axis of numbers or dates reads that
124
+ * way in a right-to-left language too), the legend under it, and the data as a table that only a screen reader
125
+ * sees. The drawing is for the eyes; the table carries the same numbers for everyone else.
126
+ */
127
+ export declare const ChartFrame: ({ children, height, legend, table, "aria-label": ariaLabel, fontProbe, className }: ChartFrameProps) => import("react").JSX.Element;
128
+ interface DataTableProps {
129
+ caption: string;
130
+ data: readonly ChartDatum[];
131
+ xKey: string;
132
+ xLabel?: string | undefined;
133
+ series: readonly ChartSeries[];
134
+ formatX?: ((value: string | number) => string) | undefined;
135
+ formatValue?: ((value: number) => string) | undefined;
136
+ }
137
+ /** The chart's data as a table that only a screen reader sees: a row for each x value, a column for each series. */
138
+ export declare const ChartDataTable: ({ caption, data, xKey, xLabel, series, formatX, formatValue }: DataTableProps) => import("react").JSX.Element;
139
+ export {};
@@ -0,0 +1,385 @@
1
+ "use client";
2
+ import { c } from "react/compiler-runtime";
3
+ import { useEffect, useRef, useState, useSyncExternalStore } from "react";
4
+ import { useDirection } from "@base-ui/react/direction-provider";
5
+ import { cn } from "../../utils/cn.js";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ // src/patterns/Charts/chart-parts.tsx
8
+ /** The colour of the series at `index`: its own, or the chart token for its place (the first five, then round again). */
9
+ var seriesColor = (index, color) => color ?? `var(--fast-chart-${String(index % 5 + 1)})`;
10
+ var DASHES = [
11
+ void 0,
12
+ "8 4",
13
+ "2 3",
14
+ "8 3 2 3",
15
+ "8 3 2 3 2 3"
16
+ ];
17
+ /**
18
+ * The dash pattern of the line of the series at `index`, as an SVG `stroke-dasharray`: none (solid) for the first,
19
+ * then dashes, dots and mixes, round again after five like the colours. A reader who cannot tell the colours apart
20
+ * tells the lines apart by these, and the legend draws the same.
21
+ */
22
+ var seriesDash = (index) => DASHES[index % DASHES.length];
23
+ /** The text style of axis ticks, from the chart tokens: the caption size, in the colour of the axis. */
24
+ var AXIS_TICK = {
25
+ fill: "var(--fast-chart-axis)",
26
+ fontSize: "var(--fast-text-caption)"
27
+ };
28
+ /** The line along the x axis. */
29
+ var AXIS_LINE = { stroke: "var(--fast-chart-grid)" };
30
+ var GRID_STROKE = "var(--fast-chart-grid)";
31
+ /** The guide that follows the pointer. */
32
+ var CURSOR_STROKE = {
33
+ stroke: "var(--fast-chart-axis)",
34
+ strokeDasharray: "3 3"
35
+ };
36
+ var REDUCED_MOTION = "(prefers-reduced-motion: reduce)";
37
+ /** Whether the visitor asks for less motion: a chart then draws at once instead of growing. */
38
+ var usePrefersReducedMotion = () => {
39
+ return useSyncExternalStore(_temp, _temp2, _temp3);
40
+ };
41
+ /**
42
+ * A number that goes up when the chart's font changes: a theme with another font family, the switch to right to
43
+ * left (which changes the font), or a web font that finishes loading. Recharts measures the value axis's labels
44
+ * once (`width="auto"`), so a chart uses the number as the `key` of its Recharts chart, which then draws and
45
+ * measures again in the new font.
46
+ *
47
+ * It watches a hidden sample of text in the chart's font (put `probe` on ChartFrame's `fontProbe`): when the
48
+ * sample's width changes, the font has. One observer per chart and no global listeners; nothing runs on the server,
49
+ * and an ordinary redraw does not change the number.
50
+ */
51
+ var useChartFontVersion = () => {
52
+ const $ = c(4);
53
+ const probe = useRef(null);
54
+ const [version, setVersion] = useState(0);
55
+ let t0;
56
+ let t1;
57
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
58
+ t0 = () => {
59
+ const element = probe.current;
60
+ if (!element || typeof ResizeObserver === "undefined") return;
61
+ let width = element.getBoundingClientRect().width;
62
+ const observer = new ResizeObserver(() => {
63
+ const next = element.getBoundingClientRect().width;
64
+ if (next === width) return;
65
+ width = next;
66
+ setVersion(_temp4);
67
+ });
68
+ observer.observe(element);
69
+ return () => {
70
+ observer.disconnect();
71
+ };
72
+ };
73
+ t1 = [];
74
+ $[0] = t0;
75
+ $[1] = t1;
76
+ } else {
77
+ t0 = $[0];
78
+ t1 = $[1];
79
+ }
80
+ useEffect(t0, t1);
81
+ let t2;
82
+ if ($[2] !== version) {
83
+ t2 = {
84
+ version,
85
+ probe
86
+ };
87
+ $[2] = version;
88
+ $[3] = t2;
89
+ } else t2 = $[3];
90
+ return t2;
91
+ };
92
+ var FONT_SAMPLE = "0123456789 AaMmWw.,%";
93
+ /** The swatches and names under a chart. Decorative: the data table already says all of it to a screen reader. */
94
+ var ChartLegend = (t0) => {
95
+ const $ = c(4);
96
+ const { items } = t0;
97
+ let t1;
98
+ if ($[0] !== items) {
99
+ t1 = items.map(_temp5);
100
+ $[0] = items;
101
+ $[1] = t1;
102
+ } else t1 = $[1];
103
+ let t2;
104
+ if ($[2] !== t1) {
105
+ t2 = /* @__PURE__ */ jsx("ul", {
106
+ "aria-hidden": "true",
107
+ className: "m-0 flex list-none flex-wrap gap-x-4 gap-y-1 p-0 text-caption text-fg-secondary",
108
+ children: t1
109
+ });
110
+ $[2] = t1;
111
+ $[3] = t2;
112
+ } else t2 = $[3];
113
+ return t2;
114
+ };
115
+ /**
116
+ * The box that follows the pointer over a chart: the x value, and a swatch, a name and a value for each series. It
117
+ * sits in the plot, which is always left to right, so it takes the page's direction back for its own text.
118
+ */
119
+ var ChartTooltip = (t0) => {
120
+ const $ = c(14);
121
+ const { active, payload, label, formatLabel, formatValue } = t0;
122
+ const direction = useDirection();
123
+ if (!active || !payload || payload.length === 0) return null;
124
+ let t1;
125
+ if ($[0] !== formatLabel || $[1] !== label) {
126
+ t1 = typeof label === "string" || typeof label === "number" ? formatLabel ? formatLabel(label) : String(label) : null;
127
+ $[0] = formatLabel;
128
+ $[1] = label;
129
+ $[2] = t1;
130
+ } else t1 = $[2];
131
+ const heading = t1;
132
+ let t2;
133
+ if ($[3] !== heading) {
134
+ t2 = heading ? /* @__PURE__ */ jsx("p", {
135
+ className: "m-0 mb-1 font-semibold",
136
+ children: heading
137
+ }) : null;
138
+ $[3] = heading;
139
+ $[4] = t2;
140
+ } else t2 = $[4];
141
+ let t3;
142
+ if ($[5] !== formatValue || $[6] !== payload) {
143
+ let t4;
144
+ if ($[8] !== formatValue) {
145
+ t4 = (row, index) => /* @__PURE__ */ jsxs("p", {
146
+ className: "m-0 flex items-center gap-2",
147
+ children: [
148
+ /* @__PURE__ */ jsx("span", {
149
+ className: "size-2 shrink-0 rounded-full",
150
+ style: { backgroundColor: row.color ?? row.stroke ?? row.fill }
151
+ }),
152
+ /* @__PURE__ */ jsx("span", {
153
+ className: "flex-1 text-fg-secondary",
154
+ children: String(row.name)
155
+ }),
156
+ /* @__PURE__ */ jsx("span", {
157
+ className: "font-medium tabular-nums",
158
+ children: typeof row.value === "number" ? formatValue ? formatValue(row.value) : String(row.value) : String(row.value)
159
+ })
160
+ ]
161
+ }, `${String(row.name)}-${String(index)}`);
162
+ $[8] = formatValue;
163
+ $[9] = t4;
164
+ } else t4 = $[9];
165
+ t3 = payload.map(t4);
166
+ $[5] = formatValue;
167
+ $[6] = payload;
168
+ $[7] = t3;
169
+ } else t3 = $[7];
170
+ let t4;
171
+ if ($[10] !== direction || $[11] !== t2 || $[12] !== t3) {
172
+ t4 = /* @__PURE__ */ jsxs("div", {
173
+ dir: direction,
174
+ className: "box-border min-w-32 rounded-md border border-line bg-surface px-3 py-2 text-caption text-fg shadow-md",
175
+ children: [t2, t3]
176
+ });
177
+ $[10] = direction;
178
+ $[11] = t2;
179
+ $[12] = t3;
180
+ $[13] = t4;
181
+ } else t4 = $[13];
182
+ return t4;
183
+ };
184
+ /**
185
+ * What every chart sits in: the plot at a set height, always left to right (an axis of numbers or dates reads that
186
+ * way in a right-to-left language too), the legend under it, and the data as a table that only a screen reader
187
+ * sees. The drawing is for the eyes; the table carries the same numbers for everyone else.
188
+ */
189
+ var ChartFrame = (t0) => {
190
+ const $ = c(16);
191
+ const { children, height, legend, table, "aria-label": ariaLabel, fontProbe, className } = t0;
192
+ let t1;
193
+ if ($[0] !== className) {
194
+ t1 = cn("flex w-full min-w-0 flex-col gap-3", className);
195
+ $[0] = className;
196
+ $[1] = t1;
197
+ } else t1 = $[1];
198
+ let t2;
199
+ if ($[2] !== height) {
200
+ t2 = { height };
201
+ $[2] = height;
202
+ $[3] = t2;
203
+ } else t2 = $[3];
204
+ let t3;
205
+ if ($[4] !== fontProbe) {
206
+ t3 = fontProbe ? /* @__PURE__ */ jsx("span", {
207
+ ref: fontProbe,
208
+ className: "pointer-events-none invisible absolute start-0 top-0 text-caption whitespace-nowrap",
209
+ children: FONT_SAMPLE
210
+ }) : null;
211
+ $[4] = fontProbe;
212
+ $[5] = t3;
213
+ } else t3 = $[5];
214
+ let t4;
215
+ if ($[6] !== children || $[7] !== t2 || $[8] !== t3) {
216
+ t4 = /* @__PURE__ */ jsxs("div", {
217
+ dir: "ltr",
218
+ "aria-hidden": "true",
219
+ className: "relative w-full min-w-0",
220
+ style: t2,
221
+ children: [t3, children]
222
+ });
223
+ $[6] = children;
224
+ $[7] = t2;
225
+ $[8] = t3;
226
+ $[9] = t4;
227
+ } else t4 = $[9];
228
+ let t5;
229
+ if ($[10] !== ariaLabel || $[11] !== legend || $[12] !== t1 || $[13] !== t4 || $[14] !== table) {
230
+ t5 = /* @__PURE__ */ jsxs("div", {
231
+ role: "group",
232
+ "aria-label": ariaLabel,
233
+ className: t1,
234
+ children: [
235
+ t4,
236
+ legend,
237
+ table
238
+ ]
239
+ });
240
+ $[10] = ariaLabel;
241
+ $[11] = legend;
242
+ $[12] = t1;
243
+ $[13] = t4;
244
+ $[14] = table;
245
+ $[15] = t5;
246
+ } else t5 = $[15];
247
+ return t5;
248
+ };
249
+ /** The chart's data as a table that only a screen reader sees: a row for each x value, a column for each series. */
250
+ var ChartDataTable = (t0) => {
251
+ const $ = c(26);
252
+ const { caption, data, xKey, xLabel, series, formatX, formatValue } = t0;
253
+ let t1;
254
+ if ($[0] !== caption) {
255
+ t1 = /* @__PURE__ */ jsx("caption", { children: caption });
256
+ $[0] = caption;
257
+ $[1] = t1;
258
+ } else t1 = $[1];
259
+ const t2 = xLabel ?? xKey;
260
+ let t3;
261
+ if ($[2] !== t2) {
262
+ t3 = /* @__PURE__ */ jsx("th", {
263
+ scope: "col",
264
+ children: t2
265
+ });
266
+ $[2] = t2;
267
+ $[3] = t3;
268
+ } else t3 = $[3];
269
+ let t4;
270
+ if ($[4] !== series) {
271
+ t4 = series.map(_temp6);
272
+ $[4] = series;
273
+ $[5] = t4;
274
+ } else t4 = $[5];
275
+ let t5;
276
+ if ($[6] !== t3 || $[7] !== t4) {
277
+ t5 = /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [t3, t4] }) });
278
+ $[6] = t3;
279
+ $[7] = t4;
280
+ $[8] = t5;
281
+ } else t5 = $[8];
282
+ let t6;
283
+ if ($[9] !== data || $[10] !== formatValue || $[11] !== formatX || $[12] !== series || $[13] !== xKey) {
284
+ let t7;
285
+ if ($[15] !== formatValue || $[16] !== formatX || $[17] !== series || $[18] !== xKey) {
286
+ t7 = (row, index) => {
287
+ const x = row[xKey];
288
+ return /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
289
+ scope: "row",
290
+ children: x === null || x === void 0 ? "" : formatX ? formatX(x) : String(x)
291
+ }), series.map((item_0) => {
292
+ const value = row[item_0.key];
293
+ return /* @__PURE__ */ jsx("td", { children: typeof value === "number" ? formatValue ? formatValue(value) : String(value) : "" }, item_0.key);
294
+ })] }, `${String(x)}-${String(index)}`);
295
+ };
296
+ $[15] = formatValue;
297
+ $[16] = formatX;
298
+ $[17] = series;
299
+ $[18] = xKey;
300
+ $[19] = t7;
301
+ } else t7 = $[19];
302
+ t6 = data.map(t7);
303
+ $[9] = data;
304
+ $[10] = formatValue;
305
+ $[11] = formatX;
306
+ $[12] = series;
307
+ $[13] = xKey;
308
+ $[14] = t6;
309
+ } else t6 = $[14];
310
+ let t7;
311
+ if ($[20] !== t6) {
312
+ t7 = /* @__PURE__ */ jsx("tbody", { children: t6 });
313
+ $[20] = t6;
314
+ $[21] = t7;
315
+ } else t7 = $[21];
316
+ let t8;
317
+ if ($[22] !== t1 || $[23] !== t5 || $[24] !== t7) {
318
+ t8 = /* @__PURE__ */ jsxs("table", {
319
+ className: "sr-only",
320
+ children: [
321
+ t1,
322
+ t5,
323
+ t7
324
+ ]
325
+ });
326
+ $[22] = t1;
327
+ $[23] = t5;
328
+ $[24] = t7;
329
+ $[25] = t8;
330
+ } else t8 = $[25];
331
+ return t8;
332
+ };
333
+ function _temp(onChange) {
334
+ const query = window.matchMedia(REDUCED_MOTION);
335
+ query.addEventListener("change", onChange);
336
+ return () => {
337
+ query.removeEventListener("change", onChange);
338
+ };
339
+ }
340
+ function _temp2() {
341
+ return window.matchMedia(REDUCED_MOTION).matches;
342
+ }
343
+ function _temp3() {
344
+ return false;
345
+ }
346
+ function _temp4(count) {
347
+ return count + 1;
348
+ }
349
+ function _temp5(item) {
350
+ return /* @__PURE__ */ jsxs("li", {
351
+ className: "inline-flex items-center gap-1.5",
352
+ children: [
353
+ item.line ? /* @__PURE__ */ jsx("svg", {
354
+ width: "24",
355
+ height: "8",
356
+ viewBox: "0 0 24 8",
357
+ className: "shrink-0",
358
+ children: /* @__PURE__ */ jsx("line", {
359
+ x1: "0",
360
+ y1: "4",
361
+ x2: "24",
362
+ y2: "4",
363
+ stroke: item.color,
364
+ strokeWidth: 2,
365
+ ...item.line.dash ? { strokeDasharray: item.line.dash } : {}
366
+ })
367
+ }) : /* @__PURE__ */ jsx("span", {
368
+ className: "size-2.5 shrink-0 rounded-full",
369
+ style: { backgroundColor: item.color }
370
+ }),
371
+ /* @__PURE__ */ jsx("span", { children: item.label }),
372
+ item.value ? /* @__PURE__ */ jsx("span", {
373
+ className: "font-medium text-fg",
374
+ children: item.value
375
+ }) : null
376
+ ]
377
+ }, item.label);
378
+ }
379
+ function _temp6(item) {
380
+ return /* @__PURE__ */ jsx("th", {
381
+ scope: "col",
382
+ children: item.label
383
+ }, item.key);
384
+ }
385
+ export { AXIS_LINE, AXIS_TICK, CURSOR_STROKE, ChartDataTable, ChartFrame, ChartLegend, ChartTooltip, GRID_STROKE, seriesColor, seriesDash, useChartFontVersion, usePrefersReducedMotion };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * What a gauge needs to know, as pure functions so they are tested in Node: where a value stands in its range, and
3
+ * which colour band it is in.
4
+ */
5
+ /** A colour for the values up to and including `upTo`, from the bands before it. */
6
+ export interface GaugeBand {
7
+ /** The band covers values up to and including this one. */
8
+ upTo: number;
9
+ /** A CSS colour or variable. */
10
+ color: string;
11
+ }
12
+ /** The value held inside the range. A value that is not a number counts as the minimum. */
13
+ export declare const clampGaugeValue: (value: number, min: number, max: number) => number;
14
+ /** How far along the range the value is, from 0 to 1. An empty range (min equal to max) is 0. */
15
+ export declare const gaugeFraction: (value: number, min: number, max: number) => number;
16
+ /**
17
+ * The colour of the band the value is in: the first whose `upTo` is at least the value, else the last band (a
18
+ * value past every band takes the last colour). `undefined` when there are no bands.
19
+ */
20
+ export declare const gaugeBandColor: (value: number, bands: readonly GaugeBand[]) => string | undefined;
@@ -0,0 +1,21 @@
1
+ // src/patterns/Charts/gauge-math.ts
2
+ /** The value held inside the range. A value that is not a number counts as the minimum. */
3
+ var clampGaugeValue = (value, min, max) => {
4
+ if (!Number.isFinite(value)) return min;
5
+ return Math.min(Math.max(value, min), max);
6
+ };
7
+ /** How far along the range the value is, from 0 to 1. An empty range (min equal to max) is 0. */
8
+ var gaugeFraction = (value, min, max) => {
9
+ if (max <= min) return 0;
10
+ return (clampGaugeValue(value, min, max) - min) / (max - min);
11
+ };
12
+ /**
13
+ * The colour of the band the value is in: the first whose `upTo` is at least the value, else the last band (a
14
+ * value past every band takes the last colour). `undefined` when there are no bands.
15
+ */
16
+ var gaugeBandColor = (value, bands) => {
17
+ if (bands.length === 0) return void 0;
18
+ const sorted = [...bands].sort((a, b) => a.upTo - b.upTo);
19
+ return (sorted.find((band) => value <= band.upTo) ?? sorted[sorted.length - 1])?.color;
20
+ };
21
+ export { clampGaugeValue, gaugeBandColor, gaugeFraction };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The shape of a sparkline, in a 100 by 100 box with the origin at the top left. Pure functions, so they are tested
3
+ * in Node. The values are spread evenly along the width, and the smallest sits on the bottom edge, the largest on
4
+ * the top; a line that never changes runs through the middle.
5
+ */
6
+ /** The points of the line, as [x, y] pairs. Fewer than two values give a flat line across the box. */
7
+ export declare const sparklinePoints: (values: readonly number[]) => [number, number][];
8
+ /** The line as an SVG path: "M0 100 L50 0 L100 50". Empty for no values. */
9
+ export declare const sparklinePath: (values: readonly number[]) => string;
10
+ /** The same line closed down to the bottom edge, to fill under it. Empty for no values. */
11
+ export declare const sparklineAreaPath: (values: readonly number[]) => string;
@@ -0,0 +1,24 @@
1
+ // src/patterns/Charts/sparkline-path.ts
2
+ /**
3
+ * The shape of a sparkline, in a 100 by 100 box with the origin at the top left. Pure functions, so they are tested
4
+ * in Node. The values are spread evenly along the width, and the smallest sits on the bottom edge, the largest on
5
+ * the top; a line that never changes runs through the middle.
6
+ */
7
+ /** The points of the line, as [x, y] pairs. Fewer than two values give a flat line across the box. */
8
+ var sparklinePoints = (values) => {
9
+ const finite = values.filter((value) => Number.isFinite(value));
10
+ if (finite.length === 0) return [];
11
+ if (finite.length === 1) return [[0, 50], [100, 50]];
12
+ const min = Math.min(...finite);
13
+ const span = Math.max(...finite) - min;
14
+ return finite.map((value, index) => [index / (finite.length - 1) * 100, span === 0 ? 50 : 100 - (value - min) / span * 100]);
15
+ };
16
+ var write = (n) => String(Math.round(n * 100) / 100);
17
+ /** The line as an SVG path: "M0 100 L50 0 L100 50". Empty for no values. */
18
+ var sparklinePath = (values) => sparklinePoints(values).map(([x, y], index) => `${index === 0 ? "M" : "L"}${write(x)} ${write(y)}`).join(" ");
19
+ /** The same line closed down to the bottom edge, to fill under it. Empty for no values. */
20
+ var sparklineAreaPath = (values) => {
21
+ const line = sparklinePath(values);
22
+ return line === "" ? "" : `${line} L100 100 L0 100 Z`;
23
+ };
24
+ export { sparklineAreaPath, sparklinePath, sparklinePoints };
@@ -0,0 +1,50 @@
1
+ import { type Ref } from "react";
2
+ import type { FieldSize } from "../FormField/field-types.js";
3
+ /** The texts of the picker. The design system has no i18n, so the caller supplies them. */
4
+ export interface ColorPickerLabels {
5
+ /** Accessible name of the picker and of its panel, e.g. "Choose a colour". */
6
+ choose: string;
7
+ /** Name of the area that sets saturation and brightness, e.g. "Saturation and brightness". */
8
+ area: string;
9
+ /** Reads the area's position for a screen reader, e.g. `(s, v) => `Saturation ${s}%, brightness ${v}%``. */
10
+ areaValue: (saturation: number, brightness: number) => string;
11
+ /** Name of the hue slider, e.g. "Hue". */
12
+ hue: string;
13
+ /** Name of the input for the hex text, e.g. "Hex colour". */
14
+ hex: string;
15
+ }
16
+ export interface ColorPickerProps {
17
+ /** The colour as hex, "#6d28d9"; an empty string for none. */
18
+ value: string;
19
+ /** Called with the new colour as "#rrggbb" in lower case, as the person picks. */
20
+ onValueChange: (value: string) => void;
21
+ labels: ColorPickerLabels;
22
+ /** Colours offered as one-click choices under the picker, as hex. */
23
+ swatches?: readonly string[] | undefined;
24
+ /** Shown on the button while there is no colour. `labels.choose` if omitted. */
25
+ placeholder?: string | undefined;
26
+ disabled?: boolean | undefined;
27
+ /**
28
+ * Draws the red border. A button cannot carry aria-invalid, so the field is announced as invalid through its
29
+ * message, which `aria-describedby` ties to it.
30
+ */
31
+ invalid?: boolean | undefined;
32
+ size?: FieldSize | undefined;
33
+ id?: string | undefined;
34
+ /** What names the picker when there is no visible label. `labels.choose` if omitted. */
35
+ "aria-label"?: string | undefined;
36
+ /** The id of the element that is the picker's label; the chosen colour is added to the name. */
37
+ "aria-labelledby"?: string | undefined;
38
+ /** The ids of the field's message and hint, read after the name. */
39
+ "aria-describedby"?: string | undefined;
40
+ triggerRef?: Ref<HTMLButtonElement> | undefined;
41
+ /** The picker was left: the panel closed, or focus moved off it while closed. */
42
+ onBlur?: (() => void) | undefined;
43
+ }
44
+ /**
45
+ * A colour picker: a button showing the colour that opens a panel with an area for saturation (across) and
46
+ * brightness (up), a hue slider, the hex text and, if given, swatches. The value is hex text. The area is one
47
+ * slider for a screen reader, which reads its position through `labels.areaValue`; the arrow keys move it by 1
48
+ * (10 with Shift). The panel is always left to right, like the colours it shows.
49
+ */
50
+ export declare const ColorPicker: ({ value, onValueChange, labels, swatches, placeholder, disabled, invalid, size, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, triggerRef, onBlur, }: ColorPickerProps) => import("react").JSX.Element;