@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
package/docs/nextjs.md ADDED
@@ -0,0 +1,69 @@
1
+ # Next.js
2
+
3
+ The package works in the App Router and the Pages Router, with Turbopack or webpack. Every component module is
4
+ marked `"use client"`, so a Server Component imports components directly; the pure helpers (`createTheme`,
5
+ `cn`, `FAST_ICONS`, `TOKEN_NAMES`) are not, so a Server Component can call them too:
6
+
7
+ ```tsx
8
+ // app/layout.tsx: a Server Component
9
+ import type { ReactNode } from "react";
10
+ import "@primecoderin/fast-ui-react/styles.css";
11
+ import { createTheme, DesignSystemProvider } from "@primecoderin/fast-ui-react";
12
+
13
+ const theme = createTheme({ branding: { primary: "#6d28d9", onPrimary: "#fff" } });
14
+
15
+ export default function RootLayout({ children }: { children: ReactNode }) {
16
+ return (
17
+ <html lang="en" dir="ltr">
18
+ <body>
19
+ <DesignSystemProvider themeMode="light" direction="ltr" theme={theme}>
20
+ {children}
21
+ </DesignSystemProvider>
22
+ </body>
23
+ </html>
24
+ );
25
+ }
26
+ ```
27
+
28
+ - **Event handlers stay on the client.** A component that passes `onValueChange` or `onClick` is rendered from a
29
+ Client Component file, as in any Next.js app; a Server Component can render one that takes only data.
30
+ - **Put `dir` on `<html>` in the layout** as well as on the provider, so the server's HTML is already right to
31
+ left. Without the steps below, the provider sets `data-theme` and the theme's `<style>` when the page hydrates,
32
+ so until then the page shows the default light theme and colours.
33
+
34
+ ## No flash of the wrong theme
35
+
36
+ The server knows the user's choice if the app keeps it in a cookie. Render it on `<html>`, and render the theme's
37
+ stylesheet in `<head>` under the id the provider uses; the provider then finds both already right and changes
38
+ nothing when it hydrates:
39
+
40
+ ```tsx
41
+ // app/layout.tsx
42
+ import type { ReactNode } from "react";
43
+ import { cookies } from "next/headers";
44
+ import { createTheme, DesignSystemProvider, THEME_STYLE_ID } from "@primecoderin/fast-ui-react";
45
+
46
+ export default async function RootLayout({ children }: { children: ReactNode }) {
47
+ const mode = (await cookies()).get("theme")?.value === "dark" ? "dark" : "light";
48
+ const theme = createTheme(await loadTenantTheme()); // the app's own loader: the tenant's ThemeDefinition
49
+ return (
50
+ <html lang="en" dir="ltr" data-theme={mode}>
51
+ <head>
52
+ <style id={THEME_STYLE_ID} dangerouslySetInnerHTML={{ __html: theme.css }} />
53
+ </head>
54
+ <body>
55
+ <DesignSystemProvider themeMode={mode} direction="ltr" theme={theme}>
56
+ {children}
57
+ </DesignSystemProvider>
58
+ </body>
59
+ </html>
60
+ );
61
+ }
62
+ ```
63
+
64
+ `theme.css` is safe to write into the page: `createTheme` keeps only known token names and drops any value that
65
+ could leave its declaration (see [Theme, branding and tokens](theming.md)). Under a nonce-based
66
+ Content-Security-Policy, give the `<style>` the same `nonce` as the provider. For `themeMode="system"`, the server
67
+ cannot know the system's setting; a small inline script in `<head>` (with the nonce) can set `data-theme` from
68
+ `matchMedia("(prefers-color-scheme: dark)")` before the first paint.
69
+ - **In the Pages Router**, import the stylesheet and wrap the app in the provider in `pages/_app.tsx`.
@@ -0,0 +1,41 @@
1
+ # Releasing
2
+
3
+ For maintainers. Releases follow [semantic versioning](https://semver.org) because every consuming app upgrades on
4
+ its own schedule: a token or prop that is renamed without a major version breaks them. While the version is below
5
+ 1.0.0, a minor version may include breaking changes, and the changelog says so.
6
+
7
+ ## What counts as which
8
+
9
+ | Change | Version |
10
+ | --- | --- |
11
+ | A fix that changes no export, prop or token | patch |
12
+ | A new component, prop, token or entry | minor |
13
+ | A removed or renamed export, prop or token; a changed default; a raised peer dependency range | major (minor before 1.0.0) |
14
+
15
+ ## Steps
16
+
17
+ 1. **Update `CHANGELOG.md`.** Move the items under "Unreleased" into a heading for the new version and date, in
18
+ the [Keep a Changelog](https://keepachangelog.com) groups (Added, Changed, Deprecated, Removed, Fixed,
19
+ Security). Start each breaking change with "**Breaking:**" and say what to do instead.
20
+ 2. **Bump the version in both packages.** Update `version` in `package.json` and `mcp/package.json` to the same
21
+ version (for example `npm version minor --no-git-tag-version` and the same in `mcp/package.json`): the MCP server's
22
+ catalogue is generated from this package.
23
+ 3. **Regenerate docs and lockfile.** Run `npm run docs` so `docs/components.md`, `llms.txt` and `llms-full.txt` carry
24
+ the new version, and run `npm install --package-lock-only` if dependencies changed.
25
+ 4. **Check everything.** Run `npm run typecheck`, then `npm test` (unit tests, every story light, dark and right to
26
+ left, and SSR + hydration).
27
+ 5. **Check what will ship.** Run `npm run build`, then `npm pack --dry-run` and `npm pack --dry-run -w mcp` to verify
28
+ the files (`dist/`, `docs/`, `CHANGELOG.md`, `LICENSE`, `llms.txt`, `llms-full.txt`, `package.json`, `README.md`
29
+ for the main package; `dist/` and `catalog.json` for the MCP server). Both `package.json` files set
30
+ `"publishConfig": { "access": "public" }`.
31
+ 6. **Commit and tag.** Commit the version bump, changelog and regenerated docs on `master`, then create an annotated
32
+ tag `v<version>` (e.g. `git tag -a v0.2.0 -m "v0.2.0"`).
33
+ 7. **Publish.** Push the commit and tag (`git push origin master --follow-tags`). Pushing a `v*` tag triggers
34
+ `.github/workflows/release.yml`, which verifies the tag matches both `package.json` versions, runs checks and
35
+ publishes both `@primecoderin/fast-ui-react` and `@primecoderin/fast-ui-react-mcp` with npm provenance. To publish manually instead,
36
+ run `npm publish` and `npm publish -w mcp` (each package's `prepack` builds it first). For a private feed, set
37
+ `"publishConfig": { "registry": "https://<your-feed-address>/" }`.
38
+ 8. **Release notes.** Create the GitHub Release for the tag from the changelog entry.
39
+
40
+ Deprecate rather than delete: mark an export `@deprecated` in its doc comment for one minor version before a major
41
+ removes it.
@@ -0,0 +1,242 @@
1
+ <!-- Generated by scripts/generate-docs.mjs (npm run docs) from stories/testing.mdx. Do not edit by hand. -->
2
+
3
+ # Testing with Playwright
4
+
5
+ Every component gives its elements a role, an accessible name and a state, the same information a screen
6
+ reader uses. A test can find an element the way a person does: a button by its text, a field by its label, a
7
+ dialog by its title. Locators written this way keep working when the styling or the markup changes. The
8
+ components render no test ids.
9
+
10
+ The examples below run against this Storybook, and the names in them are each story's sample data. Open the
11
+ story, try the locator, then use the same pattern with the application's own labels.
12
+
13
+ ## Choosing a locator
14
+
15
+ Use the first of these that fits:
16
+
17
+ - **`getByRole(role, { name })`** for anything a person operates: buttons, links, fields, tabs, menu items,
18
+ options, dialogs and table rows. The name is the visible text, or the label of a control that shows only an
19
+ icon.
20
+ - **`getByLabel(text)`** for form fields.
21
+ - **`getByText(text)`** for content that has no role: badges, tags, metric and status cards.
22
+
23
+ When the same name appears more than once, chain from a container: a dialog, a table row, a list item.
24
+
25
+ A name matches as a substring unless the locator passes `exact: true`: `name: "Active"` also finds "Inactive",
26
+ and `name: "Page 1"` also finds "Page 13".
27
+
28
+ Avoid CSS classes, which change with the design, and element ids such as `base-ui-_r_3_`, which are generated
29
+ on every render. The `data-*` state attributes (`data-checked`, `data-disabled`) are for styling: assert a
30
+ state through its ARIA attribute instead (see **States**).
31
+
32
+ ## Buttons and links
33
+
34
+ ```ts
35
+ page.getByRole("button", { name: "Save changes" });
36
+ // A button that shows only an icon is named by its label.
37
+ page.getByRole("button", { name: "Show password" });
38
+ // A clickable card is one button named by all of its text: match part of it.
39
+ page.getByRole("button", { name: /Website redesign/ });
40
+ page.getByRole("link", { name: "Projects" });
41
+ ```
42
+
43
+ ## Form fields
44
+
45
+ ```ts
46
+ await page.getByLabel("Project name").fill("Website redesign");
47
+ await page.getByLabel("Notes").fill("Ship before the review.");
48
+
49
+ // A select: open it, then choose. The list opens at the end of the page, outside the field.
50
+ await page.getByRole("combobox", { name: "Priority" }).click();
51
+ await page.getByRole("option", { name: "High" }).click();
52
+ await expect(page.getByRole("combobox", { name: "Priority" })).toHaveText("High");
53
+
54
+ // A searchable list: type to filter, then choose.
55
+ await page.getByRole("combobox", { name: "Organization" }).fill("Glob");
56
+ await page.getByRole("option", { name: "Globex Labs" }).click();
57
+
58
+ // A phone number: the calling code and the number are two controls, each with its own name.
59
+ await page.getByLabel("Country calling code").click();
60
+ await page.getByRole("option", { name: "+44 United Kingdom" }).click();
61
+ await page.getByLabel("Phone").fill("2071234567");
62
+
63
+ await page.getByRole("checkbox", { name: "Send me a daily summary" }).check();
64
+ await page.getByRole("switch", { name: "Email notifications" }).uncheck();
65
+ await page.getByRole("radio", { name: "Next day" }).check();
66
+ ```
67
+
68
+ A required field shows an asterisk after its label. The asterisk is part of the label's text but not of the
69
+ field's name, so `getByLabel("Phone", { exact: true })` finds nothing when the field is required. Use
70
+ `getByLabel("Phone")` or `getByRole("textbox", { name: "Phone", exact: true })`.
71
+
72
+ ### Validation messages
73
+
74
+ ```ts
75
+ // The message is an alert, and it is the field's description.
76
+ await expect(page.getByRole("alert")).toHaveText("Project name is required");
77
+ await expect(page.getByLabel("Project name")).toHaveAttribute("aria-invalid", "true");
78
+ await expect(page.getByLabel("Project name")).toHaveAccessibleDescription("Project name is required");
79
+ ```
80
+
81
+ ## Tabs, segmented controls and menus
82
+
83
+ ```ts
84
+ await page.getByRole("tab", { name: "Activity" }).click();
85
+ await expect(page.getByRole("tab", { name: "Activity" })).toHaveAttribute("aria-selected", "true");
86
+
87
+ // A segmented control is a radio group.
88
+ await page
89
+ .getByRole("radiogroup", { name: "Filter by status" })
90
+ .getByRole("radio", { name: "Active", exact: true })
91
+ .check();
92
+
93
+ // A menu opens from its button, and its entries are menu items.
94
+ await page.getByRole("button", { name: "Row actions" }).click();
95
+ await page.getByRole("menuitem", { name: "Edit" }).click();
96
+
97
+ // A choice of one inside a menu is a set of menu item radios.
98
+ await page.getByRole("button", { name: "Sort: Name" }).click();
99
+ await page.getByRole("menuitemradio", { name: "Date created" }).click();
100
+ ```
101
+
102
+ ## Dialogs, drawers and popovers
103
+
104
+ ```ts
105
+ await page.getByRole("button", { name: "New project" }).click();
106
+ const dialog = page.getByRole("dialog", { name: "New project" });
107
+ await dialog.getByLabel("Project name").fill("Website redesign");
108
+ await dialog.getByRole("combobox", { name: "Team" }).click();
109
+ // The list opens outside the dialog, so the option is found from the page.
110
+ await page.getByRole("option", { name: "Design" }).click();
111
+ await page.keyboard.press("Escape");
112
+ await expect(dialog).toBeHidden();
113
+
114
+ // A confirmation (a Dialog with modalType="alert") is an alert dialog.
115
+ page.getByRole("alertdialog", { name: "Delete project?" });
116
+ // A drawer is a dialog named by its title, even when the title is not drawn.
117
+ page.getByRole("dialog", { name: "Filters" });
118
+ // A popover is a dialog too. A hover popover opens while the pointer rests on its trigger.
119
+ await page.getByRole("button", { name: "3 reviewers" }).hover();
120
+ await expect(page.getByRole("dialog", { name: "Reviewers" })).toBeVisible();
121
+ ```
122
+
123
+ ## Notifications
124
+
125
+ ```ts
126
+ const notifications = page.getByRole("region", { name: "Notifications" });
127
+
128
+ // A notification is a dialog named by its title, and its message is its text.
129
+ const saved = notifications.getByRole("dialog", { name: "Success" });
130
+ await expect(saved).toContainText("Your changes were saved.");
131
+
132
+ // The dismiss button shows while the pointer is on the notification.
133
+ await saved.hover();
134
+ await saved.getByRole("button", { name: "Dismiss notification" }).click();
135
+
136
+ // An error stays out of the accessibility tree until it has focus, and its message is announced as an alert.
137
+ await expect(page.getByRole("alert").filter({ hasText: "The server did not respond." })).toHaveCount(1);
138
+ notifications.getByRole("alertdialog", { name: "Unable to complete", includeHidden: true });
139
+ ```
140
+
141
+ A notification closes itself after five seconds, and the timer pauses while the pointer is over the
142
+ notifications. Assert right after the action that raises it, or hover the notifications first.
143
+
144
+ ## Tables and pagination
145
+
146
+ ```ts
147
+ // A table card's scrolling area is a region named after its table.
148
+ const projects = page.getByRole("region", { name: "Projects" });
149
+ await expect(projects.getByRole("table")).toBeVisible();
150
+
151
+ // A row is named by the text of its cells: match a value only that row has.
152
+ const row = page.getByRole("row", { name: /PRJ-102/ });
153
+ await expect(row).toContainText("In progress");
154
+ await expect(row.getByRole("cell", { name: "Mobile app" })).toBeVisible();
155
+
156
+ const pager = page.getByRole("navigation", { name: "Pagination" });
157
+ await pager.getByRole("button", { name: "Page 2", exact: true }).click();
158
+ await expect(pager.getByRole("button", { name: "Page 2", exact: true })).toHaveAttribute("aria-current", "page");
159
+ await pager.getByRole("button", { name: "Next" }).click();
160
+ await page.getByRole("combobox", { name: "Rows per page" }).selectOption("50");
161
+ ```
162
+
163
+ In the application's data tables, column headers are `columnheader`s. A sortable column's header holds a button
164
+ with the column's name and carries `aria-sort`. A selectable row has a checkbox named after that row, and a
165
+ selected row has `aria-selected="true"`. A long table can render only the rows in view: scroll, filter or page
166
+ before locating a row further down.
167
+
168
+ ## Content without a role, messages and loading
169
+
170
+ ```ts
171
+ // Badges, tags, metric and status cards are text: find them inside the row, list item or card they belong to.
172
+ await expect(page.getByRole("row", { name: /PRJ-103/ })).toContainText("Failed");
173
+ const processing = page
174
+ .getByRole("list", { name: "Order summary" })
175
+ .getByRole("listitem")
176
+ .filter({ hasText: "Processing" });
177
+ await expect(processing).toContainText("37");
178
+
179
+ // An error message is an alert, and other notices are status messages.
180
+ page.getByRole("alert").filter({ hasText: "Payment method declined" });
181
+ page.getByRole("status").filter({ hasText: "Changes saved" });
182
+ page.getByRole("alert").getByRole("button", { name: "Try again" });
183
+
184
+ // Loading: a spinner is a status holding its label as text, a skeleton is a busy progress bar, and a busy
185
+ // button is disabled.
186
+ page.getByRole("status").filter({ hasText: "Loading results" });
187
+ page.getByRole("progressbar", { name: "Loading rows" });
188
+ await expect(page.getByRole("button", { name: "Saving" })).toBeDisabled();
189
+
190
+ // A tooltip has no role: hover its control, then find its text.
191
+ await page.getByRole("button", { name: "Edit" }).hover();
192
+ await expect(page.getByText("Edit", { exact: true })).toBeVisible();
193
+ ```
194
+
195
+ ## States
196
+
197
+ Assert a state through the attribute that assistive technology reads:
198
+
199
+ - **Disabled**: `toBeDisabled()`. It covers both the native `disabled` attribute and `aria-disabled="true"`,
200
+ which tabs, menu items, a busy button and a button that stays focusable while disabled use.
201
+ - **Checked**: `toBeChecked()` and `not.toBeChecked()` for checkboxes, switches, radios and menu item radios. A
202
+ partly selected checkbox has `aria-checked="mixed"`.
203
+ - **Selected**: a tab or a table row has `aria-selected="true"`.
204
+ - **Open**: the control that opened a list, menu or popover has `aria-expanded="true"`.
205
+ - **Invalid and required**: `aria-invalid="true"`, with the message as the field's accessible description;
206
+ `aria-required="true"`.
207
+ - **Loading**: `aria-busy="true"` on a busy button, a skeleton or a loading table.
208
+ - **Current page**: `aria-current="page"`.
209
+ - **Sorted column**: `aria-sort="ascending"` or `aria-sort="descending"`.
210
+
211
+ ## Things to know
212
+
213
+ - **Names follow the interface language.** Every label and name is translated, so run tests in one language.
214
+ - **Popups open at the end of the page**, outside the element that opens them. Locate options, menu items and
215
+ popovers from `page`, not from the field or the dialog.
216
+ - **An open list adds two hidden "Dismiss" buttons** for screen-reader users. Scope any locator for a button
217
+ named "Dismiss" to its container.
218
+ - **Animations**: dialogs, panels and popups fade and slide, and Playwright waits for them. After closing one,
219
+ assert `toBeHidden()`.
220
+ - **Right to left** changes the layout, not the roles.
221
+ - **Test ids**: the components render none, and most do not pass one through. When role, label and text cannot
222
+ single out an element, ask for a test id on it.
223
+
224
+ ## Unit tests with Testing Library
225
+
226
+ The same queries work in Testing Library: `screen.getByRole("button", { name: "Save changes" })`. Render the
227
+ component inside `DesignSystemProvider`, as the app does, so it gets the direction, the tooltip delay and the
228
+ toaster:
229
+
230
+ ```tsx
231
+ render(
232
+ <DesignSystemProvider themeMode="light" direction="ltr">
233
+ <SaveBar />
234
+ </DesignSystemProvider>,
235
+ );
236
+ ```
237
+
238
+ - **Use `themeMode="light"` or `"dark"`.** `"system"` reads `window.matchMedia`, which jsdom does not have; stub it
239
+ if a test needs the system setting.
240
+ - **jsdom is not a browser.** The package's own tests run every story in Chromium (Vitest browser mode), not in
241
+ jsdom. Components that measure or position (charts, scroll areas, popups, resizable panels) need `ResizeObserver`
242
+ and layout, which jsdom lacks; test those in a browser runner (Vitest browser mode or Playwright component tests).
@@ -0,0 +1,118 @@
1
+ # Theme, branding and tokens
2
+
3
+ `DesignSystemProvider` takes these props:
4
+
5
+ | Prop | Type | What it does |
6
+ | --- | --- | --- |
7
+ | `themeMode` | `"light"` \| `"dark"` \| `"system"` | The colour theme. `"system"` follows the operating system's setting and changes with it. The app keeps a user's own choice; the provider stores nothing. |
8
+ | `direction` | `"ltr"` \| `"rtl"` | The text direction (`dir` on `<html>`). |
9
+ | `theme` | `Theme` | A theme made with `createTheme` (below): the primary colour and any other design token. |
10
+ | `branding` | `TenantBranding` | Only the primary colour, with the shades derived from it. `createTheme`'s `branding` is the same object; use one of the two. |
11
+ | `toastLabels` | `ToastLabelsInput` | The toasts' titles and dismiss text, in the user's language. Any left out are in English. |
12
+ | `nonce` | `string` | The page's Content-Security-Policy nonce (below). |
13
+
14
+ **`createTheme`** sets the primary colour and any design token, for both themes or for one. Make the theme
15
+ once, at module level, and pass it to the provider:
16
+
17
+ ```tsx
18
+ import { createTheme, DesignSystemProvider } from "@primecoderin/fast-ui-react";
19
+
20
+ const theme = createTheme({
21
+ branding: { primary: "#6d28d9", onPrimary: "#fff" }, // the primary colour; its shades are derived
22
+ tokens: { "font-family": "Georgia, serif" }, // both themes
23
+ light: { surface: "#faf8ff" }, // the light theme only
24
+ dark: { surface: "#17122b" }, // the dark theme only
25
+ });
26
+
27
+ export const App = () => (
28
+ <DesignSystemProvider themeMode="system" direction="ltr" theme={theme}>
29
+ {/* ... */}
30
+ </DesignSystemProvider>
31
+ );
32
+ ```
33
+
34
+ - **Token names** are the `--fast-*` variables in the package's `dist/tokens.css` without the prefix: colours
35
+ (`surface`, `fg-secondary`, `tone-error-solid`), the font (`font-family`), radii (`radius-md`), shadows
36
+ (`shadow-card`) and the type scale (`text-body`, `text-body-line-height`, `text-h1-font-weight`). They are typed, so the editor completes them and a typo does not compile; `TOKEN_NAMES`
37
+ lists them at run time. Storybook's Colors page shows the colour tokens.
38
+ - **What is left out.** A name that is not a token, or a value that could leave its declaration (it holds `;`,
39
+ a brace, a comment, `url()` or `image()`, or an unclosed quote or bracket), is dropped, and the rest of the
40
+ theme still applies. `theme.ignored` lists what was dropped, such as `"light.surfce"`, so data that arrives at run time can be checked.
41
+ - **What follows the primary.** The ramp of fills, hovers, links and focus, and also selected rows, row hover and the
42
+ info card. The success, warning, error and info tones stay as they are, so a red or green brand never looks like
43
+ an error or a success.
44
+ - **On unmount** the provider puts back the `dir` and `data-theme` the page had before it.
45
+ - **Which wins.** `light` and `dark` beat `tokens`, and the theme beats `branding`: set a token in one place.
46
+ A theme also beats the stylesheet's right-to-left rule, so a `font-family` in `tokens`, `light` or `dark`
47
+ replaces the Arial the design system uses on right-to-left pages: give a font that covers the page's script, or
48
+ keep Arial after it in the list (`"Georgia, Arial, serif"`).
49
+ - **Another font is the app's to load.** The package ships Inter only; an app that sets another `font-family`
50
+ loads that font itself (a `<link>`, its own `@font-face`, or a Fontsource package).
51
+ - **White label.** A tenant's look is one `createTheme` call: the primary colour, any other colour, the font,
52
+ the corner radii, the shadows and the type scale, made from data fetched for the tenant at run time.
53
+
54
+ ## Changing it at run time
55
+
56
+ Everything the provider takes can change while the app runs, with no reload and no rebuild:
57
+
58
+ ```tsx
59
+ const theme = useMemo(
60
+ () => createTheme({ branding: { primary }, tokens: { "font-family": font } }),
61
+ [primary, font],
62
+ );
63
+
64
+ <DesignSystemProvider themeMode={mode} direction={direction} theme={theme}>
65
+ ```
66
+
67
+ - **Colours and font.** Pass a new `theme` (or `branding`): a colour the user picked, a font, the tenant fetched
68
+ after sign-in. The provider rewrites its one `<style>` element in place. The variables live on `<html>`, so every
69
+ component, popups in `<body>` included, takes the new values at once, and the charts measure their axes again
70
+ for a new font. The provider compares the CSS text, so a theme rebuilt with the same values costs nothing.
71
+ - **Light and dark.** Change `themeMode`; the switch cross-fades where the browser supports view transitions and
72
+ the visitor has not asked for reduced motion.
73
+ - **Direction.** Change `direction`; see [Internationalization](internationalization.md).
74
+
75
+ ## Several tenants
76
+
77
+ One provider sets the page's look, so a page shows one tenant at a time: a multi-tenant app builds the theme from
78
+ the signed-in tenant's data. That data is checked (unknown token names and unsafe values are dropped and listed in
79
+ `theme.ignored`), but not judged:
80
+
81
+ - **Contrast is the tenant's.** `onPrimary`, the text on the primary fill, is not derived from the primary colour:
82
+ it stays the default dark text unless given, so a dark primary needs `onPrimary: "#fff"`. Nothing checks that a
83
+ tenant's colours are readable.
84
+ - **Not every value is a token.** Colours, the font, the type scale, radii, shadows and the layout sizes are; the
85
+ spacing scale, the focus ring's width and the animation timings are not.
86
+
87
+ ## A Content-Security-Policy nonce
88
+
89
+ A policy that allows inline styles only by nonce (`style-src 'nonce-…'`, without `'unsafe-inline'`) blocks every
90
+ `<style>` element that has no nonce. Pass the page's nonce to the provider, at run time, from wherever the
91
+ server puts it:
92
+
93
+ ```tsx
94
+ <DesignSystemProvider themeMode="light" direction="ltr" theme={theme} nonce={nonce}>
95
+ ```
96
+
97
+ The nonce goes on every `<style>` and `<script>` the design system adds: Base UI's own, and the provider's
98
+ (the theme, the branding, and the instant theme switch). `applyTheme`, `applyTenantBranding`,
99
+ `applyThemeMode` and `applyThemePreference` take it too, for an app that calls them without the provider.
100
+
101
+ ## An app that runs its own Tailwind 4
102
+
103
+ An app that writes its own classes with the design system's tokens (`bg-primary`, `text-fg-secondary`,
104
+ `rounded-tile`) imports the foundation instead of the ready-made stylesheet, and tells Tailwind to scan the
105
+ package for the classes the components use:
106
+
107
+ ```css
108
+ @layer theme, base, components, utilities;
109
+
110
+ @import "tailwindcss/theme.css" layer(theme);
111
+ @import "tailwindcss/utilities.css" layer(utilities) source("../");
112
+ @import "@primecoderin/fast-ui-react/foundation.css";
113
+ @source "../node_modules/@primecoderin/fast-ui-react/dist";
114
+ ```
115
+
116
+ The foundation empties Tailwind's own colour, type, radius and shadow scales, so `bg-red-500` or `text-lg`
117
+ generate nothing: only the design system's tokens exist. It brings the font too (`fonts.css`, the same Inter files
118
+ as the ready-made stylesheet), which the app's bundler copies from the package like any other asset.
@@ -0,0 +1,62 @@
1
+ # TypeScript
2
+
3
+ The package ships its own declarations (`dist/**/*.d.ts`) and needs no `@types` package.
4
+
5
+ ## Prop types
6
+
7
+ Each component exports its props type under the name `<Component>Props`, together with the unions its props use
8
+ (`ButtonVariant`, `AlertTone` ...):
9
+
10
+ ```ts
11
+ import type { ButtonProps, ButtonVariant } from "@primecoderin/fast-ui-react";
12
+
13
+ const variant: ButtonVariant = "primary";
14
+ const props: ButtonProps = { variant, children: "Save" };
15
+ ```
16
+
17
+ A component that renders an element accepts that element's attributes (a `Button` takes everything a `<button>`
18
+ does), minus the few the design system owns. The [component reference](components.md) lists what each takes.
19
+
20
+ To get the props of a component without importing its type, use React's helper:
21
+ `type Props = React.ComponentProps<typeof Button>`.
22
+
23
+ ## Strictness
24
+
25
+ Optional props are declared `| undefined`, so the types work with `exactOptionalPropertyTypes: true`: passing
26
+ `undefined` to an optional prop is allowed. A unit test (`tests/unit/optional-props.test.ts`) checks every optional
27
+ property in the source, so a new prop cannot forget it.
28
+
29
+ ## Form fields
30
+
31
+ The react-hook-form fields are generic over the form's values, so `name` is checked against them:
32
+
33
+ ```tsx
34
+ import { useForm } from "react-hook-form";
35
+ import { FormTextField } from "@primecoderin/fast-ui-react/forms";
36
+
37
+ interface Values {
38
+ email: string;
39
+ }
40
+
41
+ export function EmailForm() {
42
+ const { control } = useForm<Values>();
43
+ return <FormTextField control={control} name="email" label="Email" />; // name: "email" only
44
+ }
45
+ ```
46
+
47
+ The types are `Form<Field>FieldProps<Values>`. The plain fields (`TextField` ...) need no generics:
48
+ `value` and `onValueChange` carry the type.
49
+
50
+ ## Theme and tokens
51
+
52
+ - `TokenName` is the union of every token's name (generated from `tokens.css`), and `TokenValues` the object of
53
+ values `createTheme` takes, so a misspelled token is a type error.
54
+ - `DesignSystemProviderProps` types the provider's props; `ThemePreference` (`"light" | "dark" | "system"`) its
55
+ `themeMode`, `TextDirection` its `direction`, `TenantBranding` its `branding` and `Theme` (made by `createTheme` from a
56
+ `ThemeDefinition`) its `theme`. `ThemeMode` is the resolved `"light" | "dark"`.
57
+
58
+ ## Entries and module settings
59
+
60
+ The package is ESM only and has five entries (see [Getting started](getting-started.md)). Use
61
+ `"moduleResolution": "bundler"` (or `"node16"` / `"nodenext"`), which resolve the `exports` map; the old `"node"`
62
+ (node10) setting does not.