@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.
- package/CHANGELOG.md +90 -0
- package/LICENSE +21 -0
- package/README.md +180 -3
- package/dist/_virtual/_rolldown/runtime.js +12 -0
- package/dist/charts.d.ts +7 -0
- package/dist/charts.js +7 -0
- package/dist/components/Avatar/Avatar.d.ts +12 -0
- package/dist/components/Avatar/Avatar.js +92 -0
- package/dist/components/Button/Button.d.ts +44 -0
- package/dist/components/Button/Button.js +221 -0
- package/dist/components/Checkbox/CheckboxBox.d.ts +33 -0
- package/dist/components/Checkbox/CheckboxBox.js +148 -0
- package/dist/components/CodeSnippet/CodeSnippet.d.ts +26 -0
- package/dist/components/CodeSnippet/CodeSnippet.js +153 -0
- package/dist/components/Collapsible/Collapsible.d.ts +20 -0
- package/dist/components/Collapsible/Collapsible.js +97 -0
- package/dist/components/Container/Container.d.ts +301 -0
- package/dist/components/Container/Container.js +20 -0
- package/dist/components/FloatingActionButton/FloatingActionButton.d.ts +22 -0
- package/dist/components/FloatingActionButton/FloatingActionButton.js +141 -0
- package/dist/components/Grid/Grid.d.ts +311 -0
- package/dist/components/Grid/Grid.js +30 -0
- package/dist/components/IconTile/IconTile.d.ts +12 -0
- package/dist/components/IconTile/IconTile.js +70 -0
- package/dist/components/InlineError/InlineError.d.ts +9 -0
- package/dist/components/InlineError/InlineError.js +62 -0
- package/dist/components/Kbd/Kbd.d.ts +11 -0
- package/dist/components/Kbd/Kbd.js +31 -0
- package/dist/components/Link/Link.d.ts +18 -0
- package/dist/components/Link/Link.js +68 -0
- package/dist/components/Menu/ContextMenu.d.ts +18 -0
- package/dist/components/Menu/ContextMenu.js +68 -0
- package/dist/components/Menu/Menu.d.ts +86 -0
- package/dist/components/Menu/Menu.js +394 -0
- package/dist/components/OtpInput/OtpInput.d.ts +32 -0
- package/dist/components/OtpInput/OtpInput.js +177 -0
- package/dist/components/Popover/HoverPopover.d.ts +22 -0
- package/dist/components/Popover/HoverPopover.js +74 -0
- package/dist/components/Popover/Popover.d.ts +21 -0
- package/dist/components/Popover/Popover.js +64 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +17 -0
- package/dist/components/ProgressBar/ProgressBar.js +44 -0
- package/dist/components/Rating/Rating.d.ts +49 -0
- package/dist/components/Rating/Rating.js +241 -0
- package/dist/components/ScrollArea/ScrollArea.d.ts +23 -0
- package/dist/components/ScrollArea/ScrollArea.js +90 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +29 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +99 -0
- package/dist/components/Separator/Separator.d.ts +9 -0
- package/dist/components/Separator/Separator.js +34 -0
- package/dist/components/Skeleton/Skeleton.d.ts +31 -0
- package/dist/components/Skeleton/Skeleton.js +152 -0
- package/dist/components/Slider/Slider.d.ts +54 -0
- package/dist/components/Slider/Slider.js +178 -0
- package/dist/components/Spinner/Spinner.d.ts +17 -0
- package/dist/components/Spinner/Spinner.js +118 -0
- package/dist/components/Stack/Stack.d.ts +302 -0
- package/dist/components/Stack/Stack.js +14 -0
- package/dist/components/StateIcon/StateIcon.d.ts +11 -0
- package/dist/components/StateIcon/StateIcon.js +65 -0
- package/dist/components/StatusBadge/StatusBadge.d.ts +19 -0
- package/dist/components/StatusBadge/StatusBadge.js +82 -0
- package/dist/components/Tabs/Tabs.d.ts +28 -0
- package/dist/components/Tabs/Tabs.js +109 -0
- package/dist/components/Tag/Tag.d.ts +11 -0
- package/dist/components/Tag/Tag.js +66 -0
- package/dist/components/Toast/AppToaster.d.ts +8 -0
- package/dist/components/Toast/AppToaster.js +135 -0
- package/dist/components/Toast/toast-manager.d.ts +28 -0
- package/dist/components/Toast/toast-manager.js +47 -0
- package/dist/components/ToggleButton/ToggleButton.d.ts +26 -0
- package/dist/components/ToggleButton/ToggleButton.js +106 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +32 -0
- package/dist/components/ToggleGroup/ToggleGroup.js +79 -0
- package/dist/components/Tooltip/Tooltip.d.ts +16 -0
- package/dist/components/Tooltip/Tooltip.js +58 -0
- package/dist/components/Tooltip/TooltipGroup.d.ts +22 -0
- package/dist/components/Tooltip/TooltipGroup.js +65 -0
- package/dist/components/Typography/Typography.d.ts +17 -0
- package/dist/components/Typography/Typography.js +100 -0
- package/dist/editor-forms.d.ts +1 -0
- package/dist/editor-forms.js +1 -0
- package/dist/editor.d.ts +1 -0
- package/dist/editor.js +1 -0
- package/dist/fonts/LICENSE +93 -0
- package/dist/fonts/inter-cyrillic-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-vietnamese-wght-normal.woff2 +0 -0
- package/dist/fonts.css +69 -0
- package/dist/forms.d.ts +22 -0
- package/dist/forms.js +23 -0
- package/dist/foundation.css +23 -0
- package/dist/global.css +116 -0
- package/dist/hooks/useAppToast.d.ts +12 -0
- package/dist/hooks/useAppToast.js +29 -0
- package/dist/icons/icons.d.ts +43 -0
- package/dist/icons/icons.js +44 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.js +101 -0
- package/dist/patterns/Accordion/Accordion.d.ts +35 -0
- package/dist/patterns/Accordion/Accordion.js +139 -0
- package/dist/patterns/Alert/Alert.d.ts +38 -0
- package/dist/patterns/Alert/Alert.js +151 -0
- package/dist/patterns/AppShell/AppShell.d.ts +39 -0
- package/dist/patterns/AppShell/AppShell.js +218 -0
- package/dist/patterns/Breadcrumbs/Breadcrumbs.d.ts +21 -0
- package/dist/patterns/Breadcrumbs/Breadcrumbs.js +73 -0
- package/dist/patterns/Calendar/Calendar.d.ts +59 -0
- package/dist/patterns/Calendar/Calendar.js +283 -0
- package/dist/patterns/Calendar/DateRangePicker.d.ts +53 -0
- package/dist/patterns/Calendar/DateRangePicker.js +266 -0
- package/dist/patterns/Calendar/FormDateRangeField.d.ts +24 -0
- package/dist/patterns/Calendar/FormDateRangeField.js +138 -0
- package/dist/patterns/Card/Card.d.ts +26 -0
- package/dist/patterns/Card/Card.js +125 -0
- package/dist/patterns/Carousel/Carousel.d.ts +33 -0
- package/dist/patterns/Carousel/Carousel.js +127 -0
- package/dist/patterns/Cascader/Cascader.d.ts +53 -0
- package/dist/patterns/Cascader/Cascader.js +371 -0
- package/dist/patterns/Cascader/FormCascaderField.d.ts +21 -0
- package/dist/patterns/Cascader/FormCascaderField.js +130 -0
- package/dist/patterns/Charts/AreaChart.d.ts +13 -0
- package/dist/patterns/Charts/AreaChart.js +220 -0
- package/dist/patterns/Charts/BarChart.d.ts +11 -0
- package/dist/patterns/Charts/BarChart.js +220 -0
- package/dist/patterns/Charts/DonutChart.d.ts +37 -0
- package/dist/patterns/Charts/DonutChart.js +215 -0
- package/dist/patterns/Charts/GaugeChart.d.ts +44 -0
- package/dist/patterns/Charts/GaugeChart.js +210 -0
- package/dist/patterns/Charts/LineChart.d.ts +14 -0
- package/dist/patterns/Charts/LineChart.js +222 -0
- package/dist/patterns/Charts/Sparkline.d.ts +24 -0
- package/dist/patterns/Charts/Sparkline.js +81 -0
- package/dist/patterns/Charts/chart-parts.d.ts +139 -0
- package/dist/patterns/Charts/chart-parts.js +385 -0
- package/dist/patterns/Charts/gauge-math.d.ts +20 -0
- package/dist/patterns/Charts/gauge-math.js +21 -0
- package/dist/patterns/Charts/sparkline-path.d.ts +11 -0
- package/dist/patterns/Charts/sparkline-path.js +24 -0
- package/dist/patterns/ColorPicker/ColorPicker.d.ts +50 -0
- package/dist/patterns/ColorPicker/ColorPicker.js +590 -0
- package/dist/patterns/ColorPicker/FormColorField.d.ts +21 -0
- package/dist/patterns/ColorPicker/FormColorField.js +130 -0
- package/dist/patterns/ColorPicker/color-value.d.ts +19 -0
- package/dist/patterns/ColorPicker/color-value.js +72 -0
- package/dist/patterns/Combobox/Autocomplete.d.ts +48 -0
- package/dist/patterns/Combobox/Autocomplete.js +158 -0
- package/dist/patterns/Combobox/Combobox.d.ts +52 -0
- package/dist/patterns/Combobox/Combobox.js +195 -0
- package/dist/patterns/Combobox/ComboboxPopup.d.ts +24 -0
- package/dist/patterns/Combobox/ComboboxPopup.js +107 -0
- package/dist/patterns/Combobox/FormAutocompleteField.d.ts +17 -0
- package/dist/patterns/Combobox/FormAutocompleteField.js +119 -0
- package/dist/patterns/Combobox/FormComboboxField.d.ts +18 -0
- package/dist/patterns/Combobox/FormComboboxField.js +119 -0
- package/dist/patterns/Combobox/FormMultiSelectField.d.ts +18 -0
- package/dist/patterns/Combobox/FormMultiSelectField.js +119 -0
- package/dist/patterns/Combobox/MultiSelect.d.ts +54 -0
- package/dist/patterns/Combobox/MultiSelect.js +175 -0
- package/dist/patterns/CommandPalette/CommandPalette.d.ts +50 -0
- package/dist/patterns/CommandPalette/CommandPalette.js +193 -0
- package/dist/patterns/DataTable/DataTable.d.ts +107 -0
- package/dist/patterns/DataTable/DataTable.js +364 -0
- package/dist/patterns/DateTimePicker/DateTimePanel.d.ts +28 -0
- package/dist/patterns/DateTimePicker/DateTimePanel.js +444 -0
- package/dist/patterns/DateTimePicker/DateTimePicker.d.ts +75 -0
- package/dist/patterns/DateTimePicker/DateTimePicker.js +271 -0
- package/dist/patterns/DateTimePicker/FormDateTimeField.d.ts +32 -0
- package/dist/patterns/DateTimePicker/FormDateTimeField.js +148 -0
- package/dist/patterns/DateTimePicker/TimeSliders.d.ts +14 -0
- package/dist/patterns/DateTimePicker/TimeSliders.js +206 -0
- package/dist/patterns/DateTimePicker/picker-labels.d.ts +30 -0
- package/dist/patterns/DateTimePicker/picker-labels.js +23 -0
- package/dist/patterns/DateTimePicker/picker-values.d.ts +98 -0
- package/dist/patterns/DateTimePicker/picker-values.js +194 -0
- package/dist/patterns/DescriptionList/DescriptionList.d.ts +20 -0
- package/dist/patterns/DescriptionList/DescriptionList.js +57 -0
- package/dist/patterns/Dialog/Dialog.d.ts +26 -0
- package/dist/patterns/Dialog/Dialog.js +212 -0
- package/dist/patterns/Drawer/Drawer.d.ts +33 -0
- package/dist/patterns/Drawer/Drawer.js +153 -0
- package/dist/patterns/EmptyState/EmptyState.d.ts +35 -0
- package/dist/patterns/EmptyState/EmptyState.js +44 -0
- package/dist/patterns/FileUpload/FileUpload.d.ts +87 -0
- package/dist/patterns/FileUpload/FileUpload.js +417 -0
- package/dist/patterns/FileUpload/FormFileUploadField.d.ts +19 -0
- package/dist/patterns/FileUpload/FormFileUploadField.js +117 -0
- package/dist/patterns/FileUpload/add-files.d.ts +26 -0
- package/dist/patterns/FileUpload/add-files.js +35 -0
- package/dist/patterns/FileUpload/file-size.d.ts +14 -0
- package/dist/patterns/FileUpload/file-size.js +44 -0
- package/dist/patterns/FormField/CheckboxField.d.ts +26 -0
- package/dist/patterns/FormField/CheckboxField.js +97 -0
- package/dist/patterns/FormField/FieldFrame.d.ts +85 -0
- package/dist/patterns/FormField/FieldFrame.js +257 -0
- package/dist/patterns/FormField/FormCheckboxField.d.ts +17 -0
- package/dist/patterns/FormField/FormCheckboxField.js +92 -0
- package/dist/patterns/FormField/FormRadioGroupField.d.ts +16 -0
- package/dist/patterns/FormField/FormRadioGroupField.js +97 -0
- package/dist/patterns/FormField/FormRatingField.d.ts +19 -0
- package/dist/patterns/FormField/FormRatingField.js +119 -0
- package/dist/patterns/FormField/FormSelectField.d.ts +16 -0
- package/dist/patterns/FormField/FormSelectField.js +91 -0
- package/dist/patterns/FormField/FormSliderField.d.ts +22 -0
- package/dist/patterns/FormField/FormSliderField.js +128 -0
- package/dist/patterns/FormField/FormSwitchField.d.ts +19 -0
- package/dist/patterns/FormField/FormSwitchField.js +88 -0
- package/dist/patterns/FormField/FormTextAreaField.d.ts +12 -0
- package/dist/patterns/FormField/FormTextAreaField.js +91 -0
- package/dist/patterns/FormField/FormTextField.d.ts +23 -0
- package/dist/patterns/FormField/FormTextField.js +103 -0
- package/dist/patterns/FormField/RadioGroupField.d.ts +38 -0
- package/dist/patterns/FormField/RadioGroupField.js +201 -0
- package/dist/patterns/FormField/SelectField.d.ts +43 -0
- package/dist/patterns/FormField/SelectField.js +211 -0
- package/dist/patterns/FormField/SwitchField.d.ts +27 -0
- package/dist/patterns/FormField/SwitchField.js +105 -0
- package/dist/patterns/FormField/TextAreaField.d.ts +37 -0
- package/dist/patterns/FormField/TextAreaField.js +134 -0
- package/dist/patterns/FormField/TextField.d.ts +51 -0
- package/dist/patterns/FormField/TextField.js +256 -0
- package/dist/patterns/FormField/error-message.d.ts +6 -0
- package/dist/patterns/FormField/error-message.js +8 -0
- package/dist/patterns/FormField/field-styles.d.ts +44 -0
- package/dist/patterns/FormField/field-styles.js +89 -0
- package/dist/patterns/FormField/field-types.d.ts +4 -0
- package/dist/patterns/FormField/use-field-ids.d.ts +18 -0
- package/dist/patterns/FormField/use-field-ids.js +53 -0
- package/dist/patterns/List/List.d.ts +38 -0
- package/dist/patterns/List/List.js +174 -0
- package/dist/patterns/MentionsInput/FormMentionsField.d.ts +18 -0
- package/dist/patterns/MentionsInput/FormMentionsField.js +124 -0
- package/dist/patterns/MentionsInput/MentionsInput.d.ts +57 -0
- package/dist/patterns/MentionsInput/MentionsInput.js +133 -0
- package/dist/patterns/MentionsInput/mention-text.d.ts +24 -0
- package/dist/patterns/MentionsInput/mention-text.js +31 -0
- package/dist/patterns/Menubar/Menubar.d.ts +22 -0
- package/dist/patterns/Menubar/Menubar.js +79 -0
- package/dist/patterns/NavigationMenu/NavigationMenu.d.ts +27 -0
- package/dist/patterns/NavigationMenu/NavigationMenu.js +104 -0
- package/dist/patterns/NumberField/FormNumberField.d.ts +18 -0
- package/dist/patterns/NumberField/FormNumberField.js +119 -0
- package/dist/patterns/NumberField/NumberField.d.ts +57 -0
- package/dist/patterns/NumberField/NumberField.js +242 -0
- package/dist/patterns/Pagination/Pagination.d.ts +31 -0
- package/dist/patterns/Pagination/Pagination.js +275 -0
- package/dist/patterns/Pagination/page-items.d.ts +18 -0
- package/dist/patterns/Pagination/page-items.js +40 -0
- package/dist/patterns/PhoneField/FormPhoneField.d.ts +22 -0
- package/dist/patterns/PhoneField/FormPhoneField.js +97 -0
- package/dist/patterns/PhoneField/PhoneField.d.ts +60 -0
- package/dist/patterns/PhoneField/PhoneField.js +448 -0
- package/dist/patterns/PhoneField/phone-value.d.ts +26 -0
- package/dist/patterns/PhoneField/phone-value.js +38 -0
- package/dist/patterns/QRCode/QRCode.d.ts +37 -0
- package/dist/patterns/QRCode/QRCode.js +120 -0
- package/dist/patterns/QRCode/qr-path.d.ts +7 -0
- package/dist/patterns/QRCode/qr-path.js +25 -0
- package/dist/patterns/ResizablePanels/ResizablePanels.d.ts +34 -0
- package/dist/patterns/ResizablePanels/ResizablePanels.js +175 -0
- package/dist/patterns/ResizablePanels/panel-sizes.d.ts +31 -0
- package/dist/patterns/ResizablePanels/panel-sizes.js +54 -0
- package/dist/patterns/RichTextEditor/FormRichTextField.d.ts +18 -0
- package/dist/patterns/RichTextEditor/FormRichTextField.js +118 -0
- package/dist/patterns/RichTextEditor/RichTextEditor.d.ts +71 -0
- package/dist/patterns/RichTextEditor/RichTextEditor.js +453 -0
- package/dist/patterns/SearchInput/SearchInput.d.ts +26 -0
- package/dist/patterns/SearchInput/SearchInput.js +98 -0
- package/dist/patterns/SideNav/SideNav.d.ts +50 -0
- package/dist/patterns/SideNav/SideNav.js +269 -0
- package/dist/patterns/Stat/Stat.d.ts +51 -0
- package/dist/patterns/Stat/Stat.js +292 -0
- package/dist/patterns/Stepper/Stepper.d.ts +35 -0
- package/dist/patterns/Stepper/Stepper.js +110 -0
- package/dist/patterns/TagGroup/TagGroup.d.ts +44 -0
- package/dist/patterns/TagGroup/TagGroup.js +151 -0
- package/dist/patterns/TagsInput/FormTagsInputField.d.ts +18 -0
- package/dist/patterns/TagsInput/FormTagsInputField.js +124 -0
- package/dist/patterns/TagsInput/TagsInput.d.ts +51 -0
- package/dist/patterns/TagsInput/TagsInput.js +97 -0
- package/dist/patterns/Timeline/Timeline.d.ts +29 -0
- package/dist/patterns/Timeline/Timeline.js +85 -0
- package/dist/patterns/Toolbar/Toolbar.d.ts +31 -0
- package/dist/patterns/Toolbar/Toolbar.js +105 -0
- package/dist/patterns/Tour/Tour.d.ts +38 -0
- package/dist/patterns/Tour/Tour.js +333 -0
- package/dist/patterns/TransferList/FormTransferListField.d.ts +19 -0
- package/dist/patterns/TransferList/FormTransferListField.js +117 -0
- package/dist/patterns/TransferList/TransferList.d.ts +53 -0
- package/dist/patterns/TransferList/TransferList.js +441 -0
- package/dist/patterns/TreeSelect/FormTreeSelectField.d.ts +28 -0
- package/dist/patterns/TreeSelect/FormTreeSelectField.js +88 -0
- package/dist/patterns/TreeSelect/TreeSelect.d.ts +49 -0
- package/dist/patterns/TreeSelect/TreeSelect.js +375 -0
- package/dist/patterns/TreeView/TreeView.d.ts +40 -0
- package/dist/patterns/TreeView/TreeView.js +296 -0
- package/dist/provider/DesignSystemProvider.d.ts +54 -0
- package/dist/provider/DesignSystemProvider.js +270 -0
- package/dist/provider/nonce.d.ts +7 -0
- package/dist/provider/nonce.js +13 -0
- package/dist/styles.css +2 -0
- package/dist/theme/chart-palette.d.ts +51 -0
- package/dist/theme/chart-palette.js +112 -0
- package/dist/theme/create-theme.d.ts +52 -0
- package/dist/theme/create-theme.js +75 -0
- package/dist/theme/style-element.d.ts +28 -0
- package/dist/theme/style-element.js +79 -0
- package/dist/theme/tenant-branding.d.ts +48 -0
- package/dist/theme/tenant-branding.js +65 -0
- package/dist/theme/theme-switch.d.ts +25 -0
- package/dist/theme/theme-switch.js +90 -0
- package/dist/theme/token-names.d.ts +3 -0
- package/dist/theme/token-names.js +166 -0
- package/dist/theme.css +241 -0
- package/dist/tokens.css +383 -0
- package/dist/types/direction.d.ts +4 -0
- package/dist/types/tone.d.ts +7 -0
- package/dist/utils/cn.d.ts +7 -0
- package/dist/utils/cn.js +50 -0
- package/dist/utils/first-field.d.ts +8 -0
- package/dist/utils/first-field.js +10 -0
- package/dist/utils/layout.d.ts +33 -0
- package/dist/utils/layout.js +30 -0
- package/dist/utils/popup.d.ts +12 -0
- package/dist/utils/popup.js +27 -0
- package/docs/accessibility.md +61 -0
- package/docs/advanced-components.md +38 -0
- package/docs/ai-assistants.md +44 -0
- package/docs/architecture.md +65 -0
- package/docs/browser-support.md +30 -0
- package/docs/charts.md +56 -0
- package/docs/components.md +2928 -0
- package/docs/conventions.md +19 -0
- package/docs/customization.md +79 -0
- package/docs/dates-files-data.md +48 -0
- package/docs/design-principles.md +50 -0
- package/docs/faq.md +68 -0
- package/docs/forms.md +114 -0
- package/docs/getting-started.md +64 -0
- package/docs/icons.md +48 -0
- package/docs/internationalization.md +64 -0
- package/docs/layout-and-navigation.md +51 -0
- package/docs/nextjs.md +69 -0
- package/docs/releasing.md +41 -0
- package/docs/testing.md +242 -0
- package/docs/theming.md +118 -0
- package/docs/typescript.md +62 -0
- package/llms-full.txt +4574 -0
- package/llms.txt +52 -0
- package/package.json +166 -6
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Prop conventions
|
|
2
|
+
|
|
3
|
+
Every component follows the same few rules, so one you have not used yet works like the ones you have:
|
|
4
|
+
|
|
5
|
+
| What | Props | Examples |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| A value the user picks | `value` + `onValueChange` | `Tabs`, `SegmentedControl`, `TextField`, `SelectField`, `RadioGroupField`, `PhoneField`, `Combobox`, `MultiSelect`, `Slider`, `NumberField`, `Rating`, `ColorPicker`, `DateTimePicker`, `SearchInput`, `TreeSelect`, `MenuRadioGroup`, `OtpInput` |
|
|
8
|
+
| On or off | `checked` + `onCheckedChange` | `CheckboxBox`, `CheckboxField`, `SwitchField`, `FormCheckboxField`, `FormSwitchField` |
|
|
9
|
+
| Pressed or not | `pressed` + `onPressedChange` (a group: `value` + `onValueChange`, an array) | `ToggleButton`, `ToggleGroup` |
|
|
10
|
+
| A popup's state | `open` + `onOpenChange` | `Dialog`, `Drawer` |
|
|
11
|
+
| The accessible name, where there is no visible label | `aria-label` | `Tabs`, `SegmentedControl`, `DataTable`, `Popover`, `StatGroup` |
|
|
12
|
+
| Text the user reads | a prop (`label`, `labels`, `title`), never built in | every component |
|
|
13
|
+
|
|
14
|
+
**Controlled or not.** A component with a `value` (or `checked`, `open`) is controlled: you hold the state and update it
|
|
15
|
+
in the handler. Where a component can also keep its own state, it takes a `defaultValue` (or `defaultOpen`) instead:
|
|
16
|
+
`Accordion` and `Collapsible` do; the form fields are always controlled. Check a component's props in the
|
|
17
|
+
[component reference](components.md). A controlled field works with any form library.
|
|
18
|
+
|
|
19
|
+
A handler receives the new value itself (`onValueChange("active")`), not an event.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Styling and customization
|
|
2
|
+
|
|
3
|
+
From the broadest change to the narrowest: the theme, a token in one place, a class on one element, a wrapper.
|
|
4
|
+
|
|
5
|
+
## 1. The theme: every component at once
|
|
6
|
+
|
|
7
|
+
`createTheme` sets the primary colour, the font, the radii or any other token for the whole app or for one tenant.
|
|
8
|
+
This is the way to apply a brand; it needs no CSS. See [Theme, branding and tokens](theming.md).
|
|
9
|
+
|
|
10
|
+
## 2. A token: one value, wherever it is used
|
|
11
|
+
|
|
12
|
+
Every colour, size and radius is a CSS variable (`--fast-primary`, `--fast-surface` ...) that the components read
|
|
13
|
+
through Tailwind utilities (`bg-primary`, `text-fg-secondary`, `border-line`). Change a variable on an element and
|
|
14
|
+
what reads that variable inside it follows:
|
|
15
|
+
|
|
16
|
+
```css
|
|
17
|
+
.billing-section {
|
|
18
|
+
--fast-primary: #6d28d9;
|
|
19
|
+
--fast-primary-hover: #5b21b6;
|
|
20
|
+
--fast-primary-active: #4c1d95;
|
|
21
|
+
--fast-primary-text: #5b21b6;
|
|
22
|
+
--fast-focus: #6d28d9;
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Two limits apply to a variable set on an element rather than through `createTheme`:
|
|
27
|
+
|
|
28
|
+
- **Each shade is its own variable.** `--fast-primary` is only the fill: hover, pressed, light, pale, text and the
|
|
29
|
+
focus ring are separate tokens, so set each one the section uses (the list above covers buttons and links).
|
|
30
|
+
Tokens derived from others at the root (`selected`, `surface-hover`, the shadows, `chart-1`) keep the page's value.
|
|
31
|
+
`createTheme`'s `branding` derives the whole ramp from one colour, but for the whole page.
|
|
32
|
+
- **Popups are outside the element.** Menus, dialogs, popovers, tooltips and toasts render at the end of `<body>`,
|
|
33
|
+
so they keep the page's values.
|
|
34
|
+
|
|
35
|
+
The variables, their groups and the utilities that read them are listed in `llms-full.txt` (see
|
|
36
|
+
[AI coding assistants](ai-assistants.md)) and in the package's `dist/tokens.css`.
|
|
37
|
+
|
|
38
|
+
## 3. A class on one element
|
|
39
|
+
|
|
40
|
+
A component that draws a single surface (`Button`, `Card`, `Avatar`, `Stat` ...) accepts `className` and merges it
|
|
41
|
+
last, with `cn()` (clsx and tailwind-merge), so your class wins over the component's own:
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
<Button variant="primary" className="w-full">Save</Button>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
- **Use the design system's utilities.** Tailwind's own palette, type, radius and shadow scales are switched off, so
|
|
48
|
+
`bg-red-500` or `text-lg` produces nothing; use `bg-error-tint`, `text-body-sm` and the other token names.
|
|
49
|
+
- **An app that imports `styles.css` has no Tailwind of its own.** A utility the components do not already use is
|
|
50
|
+
not in the stylesheet. Write the CSS yourself, or run Tailwind 4 in the app with `foundation.css`
|
|
51
|
+
(see [Theme, branding and tokens](theming.md#an-app-that-runs-its-own-tailwind-4)).
|
|
52
|
+
- **Compositions take no `className`.** A component that owns its layout (form fields, dialogs, menus, the date
|
|
53
|
+
picker) does not expose its inner parts: wrap it and place the wrapper.
|
|
54
|
+
- A component's props table in the [component reference](components.md) says whether it takes `className`, `style`
|
|
55
|
+
and the attributes of the element it renders.
|
|
56
|
+
|
|
57
|
+
## 4. Variants
|
|
58
|
+
|
|
59
|
+
Variants are props (`variant`, `size`, `tone`), defined with [CVA](https://cva.style). The values are in the props
|
|
60
|
+
table and in the component's stories. A variant that does not exist is a type error, not a silent fallback.
|
|
61
|
+
|
|
62
|
+
## 5. State
|
|
63
|
+
|
|
64
|
+
Components mark their state with data attributes: `data-checked`, `data-disabled`, `data-highlighted`,
|
|
65
|
+
`data-popup-open`, `data-invalid`, `data-starting-style`, `data-ending-style`. A wrapper's CSS can target them,
|
|
66
|
+
and Tailwind reads them as variants (`data-checked:bg-primary`). Do not use them in tests: assert a state through
|
|
67
|
+
its ARIA attribute (see [Testing](testing.md)).
|
|
68
|
+
|
|
69
|
+
## 6. Composing
|
|
70
|
+
|
|
71
|
+
- **Wrap, do not fork.** A `PrimaryButton` that fixes two props and passes the rest is a three-line component.
|
|
72
|
+
- **Build your own with the same parts.** `cn()` and the tokens are exported; a custom component that uses them looks
|
|
73
|
+
and themes like the rest. A component that needs the app's translations, routing or data belongs in the app.
|
|
74
|
+
- **Icons.** The icons are [lucide](https://lucide.dev); pass any React element as an `icon` prop.
|
|
75
|
+
|
|
76
|
+
## Animation
|
|
77
|
+
|
|
78
|
+
Components animate with CSS transitions and Base UI's `data-starting-style` / `data-ending-style` states. All motion
|
|
79
|
+
stops for a visitor who asks for reduced motion, through one rule in the stylesheet.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Dates, files and data
|
|
2
|
+
|
|
3
|
+
| For | Use |
|
|
4
|
+
| --- | --- |
|
|
5
|
+
| A month of days always on show, to pick a day or a range | `Calendar` (`mode="range"` for a range) |
|
|
6
|
+
| A start and an end day in one field | `DateRangePicker` |
|
|
7
|
+
| Choosing files, by button or by drop | `FileUpload` (`accept`, `maxSize`, `maxFiles`, progress and errors by file) |
|
|
8
|
+
| Rows of text with an avatar and actions, optionally chosen | `List` |
|
|
9
|
+
| A hierarchy that opens and closes, with the full keyboard | `TreeView` |
|
|
10
|
+
| One record's details as term and value pairs | `DescriptionList` |
|
|
11
|
+
| Events in order, joined by a line | `Timeline` |
|
|
12
|
+
| Slides that scroll and snap | `Carousel` |
|
|
13
|
+
| A keyboard key, code or a command | `Kbd`, `CodeSnippet` (a copy button) |
|
|
14
|
+
|
|
15
|
+
`Calendar` and `DateRangePicker` hold days as text, `"2026-10-24"`, like `DateTimePicker`, with no time zone. A day's
|
|
16
|
+
button is named with its weekday and its number, "Saturday 24 October 2026", so the name contains what the button
|
|
17
|
+
shows. The weeks start on the locale's first day of the week (Monday for `de` or `enGB`); without a `locale`, Sunday,
|
|
18
|
+
and Home and End follow it. A day that cannot be read or does not exist (`"2026-02-31"`) is treated as no day. Today is
|
|
19
|
+
read only in the browser: rendered on a server with nothing picked and no `defaultMonth`, a calendar shows its month
|
|
20
|
+
once hydrated.
|
|
21
|
+
|
|
22
|
+
`FileUpload` never sends a file: the app does that, and reports how far it got through `statuses` (a `Map` from a
|
|
23
|
+
`File` to `{ progress, error }`). What it refuses (a type not in `accept`, a file over `maxSize`, one past
|
|
24
|
+
`maxFiles`) is reported through `onReject` with the reason, so the app words the message in its own language.
|
|
25
|
+
With `name`, the files are also kept in a hidden file input, so a form the browser submits sends them. Without
|
|
26
|
+
`multiple`, of several files dropped together the first is kept and the rest are reported as `count`.
|
|
27
|
+
`formatFileSize(bytes, locale)` writes a size for the user's locale and is exported for the app's own use.
|
|
28
|
+
|
|
29
|
+
## The date and time picker
|
|
30
|
+
|
|
31
|
+
`DateTimePicker` and `FormDateTimeField` (from `@primecoderin/fast-ui-react/forms`) pick a date, a date and time, or a time.
|
|
32
|
+
The value is the text a native input holds (`"2026-10-24"`, `"2026-10-24T14:05"`, `"14:05"`), with no time
|
|
33
|
+
zone. Like every component, the picker holds no text of its own: `labels` carries each text it shows and
|
|
34
|
+
announces, and `locale` is a date-fns locale for the names of months and days. Both default to English. An app
|
|
35
|
+
in another language passes its own:
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { he } from "date-fns/locale/he";
|
|
39
|
+
import type { DateTimePickerLabels } from "@primecoderin/fast-ui-react";
|
|
40
|
+
import { FormDateTimeField } from "@primecoderin/fast-ui-react/forms";
|
|
41
|
+
|
|
42
|
+
const labels: DateTimePickerLabels = { select: "בחר", today: "היום" /* ...every key */ };
|
|
43
|
+
|
|
44
|
+
<FormDateTimeField control={control} name="startDate" label="Start date" labels={labels} locale={he} />;
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`date-fns` is a dependency of the package. An app that imports a locale (`date-fns/locale/he`) lists `date-fns`
|
|
48
|
+
in its own `package.json` too, so the import does not depend on how the package manager lays out `node_modules`.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<!-- Generated by scripts/generate-docs.mjs (npm run docs) from stories/introduction.mdx. Do not edit by hand. -->
|
|
2
|
+
|
|
3
|
+
# Design principles
|
|
4
|
+
|
|
5
|
+
The components and design tokens that interfaces are built from: colour, type, spacing, radius, shadows
|
|
6
|
+
and icons, and the controls and patterns made of them. Every example here uses sample data.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Built on
|
|
10
|
+
|
|
11
|
+
**Base UI** provides the accessible, unstyled behaviour; **Tailwind CSS 4** does all the styling;
|
|
12
|
+
**CVA** (class-variance-authority) defines the variants; **`cn()`** (clsx with tailwind-merge) merges class
|
|
13
|
+
names; the icons are **lucide**.
|
|
14
|
+
|
|
15
|
+
## Principles
|
|
16
|
+
|
|
17
|
+
- **Tokens, never colour values.** Colours are utilities such as `bg-primary`, `text-fg-secondary`,
|
|
18
|
+
`border-line` and the tone roles (`bg-success-tint`, `text-error-text`). Tailwind's own palette, type,
|
|
19
|
+
radius and shadow scales are switched off, so `bg-red-500` or `text-lg` produces nothing.
|
|
20
|
+
- **Canonical Tailwind classes.** `w-4`, not `w-[16px]`; `bg-(--x)`, not `bg-[--x]`.
|
|
21
|
+
- **Variants with CVA, merging with `cn()`.** A component that draws one surface takes `className` and
|
|
22
|
+
merges it last, so the caller can place it or override a default. Compositions that own their layout
|
|
23
|
+
(form fields, dialogs, menus) take none: wrap them to place them.
|
|
24
|
+
- **State is styled with data attributes**: `data-checked:`, `data-disabled:`, `data-highlighted:`,
|
|
25
|
+
`data-popup-open:`, `data-invalid:`, `data-starting-style:`, `data-ending-style:`.
|
|
26
|
+
- **Presentation only.** Components hold no copy of their own: every text a user reads arrives through props
|
|
27
|
+
(labels, `PaginationLabels`, `ToastLabels`, `PhoneFieldLabels`), so the caller translates it.
|
|
28
|
+
- **Form fields are controlled, and bind to react-hook-form on request.** A plain field (`TextField`,
|
|
29
|
+
`SelectField`, ...) takes `value` and `onValueChange` and the validation message as `errorMessage`, so it works
|
|
30
|
+
with any form library or none. Its `Form*` twin in `/forms` takes the form's `control` and a field `name`; the
|
|
31
|
+
caller's `formatError` turns a stored validation message into the text shown.
|
|
32
|
+
|
|
33
|
+
## Accessibility
|
|
34
|
+
|
|
35
|
+
- Text meets WCAG AA contrast (4.5:1, large text 3:1) in both themes. Where the brand teal is too pale for
|
|
36
|
+
text, its darker `-text` shade is used, and text on the teal fill is dark.
|
|
37
|
+
- Every control works from the keyboard: Tab and Shift+Tab move between controls, Enter or Space activates,
|
|
38
|
+
the arrow keys move inside menus, lists, tabs and radio groups, and Escape closes a popup and returns
|
|
39
|
+
focus to what opened it.
|
|
40
|
+
- The focus ring (`ring-focus`) shows for keyboard focus only.
|
|
41
|
+
- Dialogs and panels keep focus inside while open and start in their first field.
|
|
42
|
+
- Labels, hints and error messages are tied to their control, and errors are announced as they appear.
|
|
43
|
+
- A control with no visible text needs an accessible name (`aria-label`), and decorative icons are hidden
|
|
44
|
+
from assistive technology.
|
|
45
|
+
|
|
46
|
+
## Responsive behaviour
|
|
47
|
+
|
|
48
|
+
Layouts change at Tailwind's `sm` breakpoint (640px), and the app shell's navigation at `md` (768px). Below `sm`, a `StatGroup` stacks its stats, and dialogs and drawers
|
|
49
|
+
take the width of the screen less a small margin. Right to left mirrors every layout through logical
|
|
50
|
+
utilities (`ps-*`, `ms-*`, `inset-s-*`, `text-start`); `rtl:` is only for a glyph or a slide that must flip.
|
package/docs/faq.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Troubleshooting and FAQ
|
|
2
|
+
|
|
3
|
+
## The components have no styles
|
|
4
|
+
|
|
5
|
+
Import the stylesheet once, at the app's entry: `import "@primecoderin/fast-ui-react/styles.css";`. An app that runs its
|
|
6
|
+
own Tailwind 4 imports `foundation.css` instead and lets its Tailwind scan the package: see
|
|
7
|
+
[Theme, branding and tokens](theming.md#an-app-that-runs-its-own-tailwind-4).
|
|
8
|
+
|
|
9
|
+
## `bg-red-500` or `text-lg` produces nothing
|
|
10
|
+
|
|
11
|
+
Intended. The package switches Tailwind's own palette, type, radius and shadow scales off in favour of the design
|
|
12
|
+
tokens (`bg-primary`, `text-fg-secondary`, `border-line`). An app that imports `styles.css` has no Tailwind of
|
|
13
|
+
its own; the utilities that exist are the ones the components use. Add the app's own CSS or run Tailwind 4 yourself
|
|
14
|
+
(see above).
|
|
15
|
+
|
|
16
|
+
## "You're importing a component that needs `useState`" (Next.js)
|
|
17
|
+
|
|
18
|
+
The component modules start with `"use client"`, so a Server Component can import them as it imports any Client
|
|
19
|
+
Component. If the message names the app's own file, that file uses a hook or an event handler and needs
|
|
20
|
+
`"use client"` itself. See [Next.js](nextjs.md).
|
|
21
|
+
|
|
22
|
+
## "Cannot find module `react-hook-form`" (or `recharts`, `@tiptap/react`)
|
|
23
|
+
|
|
24
|
+
Each belongs to an entry of its own and is an optional peer dependency. Install what the entry needs:
|
|
25
|
+
`@primecoderin/fast-ui-react/forms` needs `react-hook-form`, `/charts` needs `recharts`, `/editor` the four TipTap
|
|
26
|
+
packages. The table is in [Getting started](getting-started.md).
|
|
27
|
+
|
|
28
|
+
## The font is not Inter, or the page has no font
|
|
29
|
+
|
|
30
|
+
Check that `styles.css` is imported and that a Content-Security-Policy allows `font-src 'self'`. If the app sets
|
|
31
|
+
another font with `createTheme`, Inter is not downloaded at all. See [Theme, branding and tokens](theming.md).
|
|
32
|
+
|
|
33
|
+
## Inline styles are blocked by my Content-Security-Policy
|
|
34
|
+
|
|
35
|
+
`DesignSystemProvider` takes a `nonce` for the `<style>` element it writes. See the CSP section of
|
|
36
|
+
[Theme, branding and tokens](theming.md#a-content-security-policy-nonce).
|
|
37
|
+
|
|
38
|
+
## Can I use it without a provider?
|
|
39
|
+
|
|
40
|
+
Render `DesignSystemProvider` once at the root: it sets the theme and direction on `<html>`, applies branding and
|
|
41
|
+
hosts the toaster and tooltip delay. Components outside it lose that, and `toast` has nowhere to show.
|
|
42
|
+
|
|
43
|
+
## Can I use my own brand colour?
|
|
44
|
+
|
|
45
|
+
Yes: `createTheme` and tenant branding; see [Theme, branding and tokens](theming.md).
|
|
46
|
+
|
|
47
|
+
## Does it work with TypeScript's `exactOptionalPropertyTypes`?
|
|
48
|
+
|
|
49
|
+
Yes. Optional props are declared `| undefined`, so passing `undefined` is allowed under that option (a unit test
|
|
50
|
+
checks every optional property in the source).
|
|
51
|
+
|
|
52
|
+
## Which React versions?
|
|
53
|
+
|
|
54
|
+
React 19 only. The build uses the React Compiler, which imports `react/compiler-runtime`.
|
|
55
|
+
|
|
56
|
+
## Can I use it with Vue, Svelte or Angular?
|
|
57
|
+
|
|
58
|
+
No. It is a React library.
|
|
59
|
+
|
|
60
|
+
## A test cannot find a component
|
|
61
|
+
|
|
62
|
+
Components expose accessible roles and names, so query by role and name rather than by class. The
|
|
63
|
+
[testing guide](testing.md) shows each component's selectors with Playwright examples.
|
|
64
|
+
|
|
65
|
+
## Where do I report a bug or ask for a component?
|
|
66
|
+
|
|
67
|
+
Open an issue (templates for both are provided). For a component, say what the other libraries call it and what it
|
|
68
|
+
must do; see also the [roadmap](https://github.com/primecoderIN/fast-ui-react/blob/master/ROADMAP.md) for what is planned.
|
package/docs/forms.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Forms
|
|
2
|
+
|
|
3
|
+
Every form field comes in two forms. The **plain field** is in the main entry and works with any form library or
|
|
4
|
+
none: it is controlled, taking `value` and `onValueChange` (`checked` and `onCheckedChange` for a checkbox or
|
|
5
|
+
switch), and the validation message as `errorMessage`. The **bound field** is in the `/forms` entry and takes a
|
|
6
|
+
react-hook-form `control` and a `name` instead; it renders the plain field. An app that does not use
|
|
7
|
+
react-hook-form never loads it.
|
|
8
|
+
|
|
9
|
+
| Plain field (main entry) | Bound to react-hook-form (`/forms`) |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| `TextField` | `FormTextField` |
|
|
12
|
+
| `TextAreaField` | `FormTextAreaField` |
|
|
13
|
+
| `SelectField` | `FormSelectField` |
|
|
14
|
+
| `CheckboxField` | `FormCheckboxField` |
|
|
15
|
+
| `SwitchField` | `FormSwitchField` |
|
|
16
|
+
| `RadioGroupField` | `FormRadioGroupField` |
|
|
17
|
+
| `PhoneField` | `FormPhoneField` |
|
|
18
|
+
| `DateTimePicker` | `FormDateTimeField` |
|
|
19
|
+
| `TreeSelect` | `FormTreeSelectField` |
|
|
20
|
+
|
|
21
|
+
These inputs are **bare controls**, like `DateTimePicker` and `TreeSelect`: the box alone, without a label,
|
|
22
|
+
hint or message. Each has a bound field in `/forms` that adds them.
|
|
23
|
+
|
|
24
|
+
| Bare control (main entry) | Bound to react-hook-form (`/forms`) | The value |
|
|
25
|
+
| --- | --- | --- |
|
|
26
|
+
| `Combobox` | `FormComboboxField` | the chosen option's `value`, or `""` |
|
|
27
|
+
| `Autocomplete` | `FormAutocompleteField` | the text |
|
|
28
|
+
| `MultiSelect` | `FormMultiSelectField` | an array of the chosen options' `value`s |
|
|
29
|
+
| `TagsInput` | `FormTagsInputField` | an array of the tags |
|
|
30
|
+
| `NumberField` | `FormNumberField` | a number, or `null` while empty |
|
|
31
|
+
| `Slider` | `FormSliderField` | a number, or an array of numbers for a range |
|
|
32
|
+
| `Rating` | `FormRatingField` | a number from 0 (none) to the number of stars |
|
|
33
|
+
| `ColorPicker` | `FormColorField` | the colour as `"#rrggbb"`, or `""` |
|
|
34
|
+
| `DateRangePicker` | `FormDateRangeField` | `{ start, end }`, `"yyyy-MM-dd"` each |
|
|
35
|
+
| `FileUpload` | `FormFileUploadField` | an array of `File`s |
|
|
36
|
+
| `TransferList` | `FormTransferListField` | an array of the chosen items' `id`s |
|
|
37
|
+
| `Cascader` | `FormCascaderField` | the path: an array of the `value` of each step |
|
|
38
|
+
| `MentionsInput` | `FormMentionsField` | the text, with each mention written into it |
|
|
39
|
+
| `RichTextEditor` (`/editor`) | `FormRichTextField` (`/editor-forms`) | the text as HTML |
|
|
40
|
+
| `ToggleButton`, `ToggleGroup` | none | pressed or not; an array of the pressed items' `value`s |
|
|
41
|
+
|
|
42
|
+
Without react-hook-form, put a bare control in `FieldFrame` for its label, message and hint, and give the control
|
|
43
|
+
the label's id so it is named by it:
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import { useId, useState } from "react";
|
|
47
|
+
import { Combobox, FieldFrame } from "@primecoderin/fast-ui-react";
|
|
48
|
+
|
|
49
|
+
export function TeamField({ teams }: { teams: { value: string; label: string }[] }) {
|
|
50
|
+
const labelId = useId();
|
|
51
|
+
const [team, setTeam] = useState("");
|
|
52
|
+
return (
|
|
53
|
+
<FieldFrame label="Team" labelId={labelId} invalid={false}>
|
|
54
|
+
<Combobox
|
|
55
|
+
aria-labelledby={labelId}
|
|
56
|
+
options={teams}
|
|
57
|
+
value={team}
|
|
58
|
+
onValueChange={setTeam}
|
|
59
|
+
noMatchesLabel="No team matches"
|
|
60
|
+
/>
|
|
61
|
+
</FieldFrame>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
With state of your own, or any other form library:
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import { useState } from "react";
|
|
70
|
+
import { Button, SelectField, TextField } from "@primecoderin/fast-ui-react";
|
|
71
|
+
|
|
72
|
+
export function MemberForm({ roles, save }: { roles: { value: string; label: string }[]; save: () => void }) {
|
|
73
|
+
const [name, setName] = useState("");
|
|
74
|
+
const [role, setRole] = useState("");
|
|
75
|
+
return (
|
|
76
|
+
<form onSubmit={save}>
|
|
77
|
+
<TextField label="Name" value={name} onValueChange={setName} errorMessage={name === "" ? "Enter a name" : undefined} />
|
|
78
|
+
<SelectField label="Role" value={role} onValueChange={setRole} options={roles} />
|
|
79
|
+
<Button type="submit" variant="primary">Save</Button>
|
|
80
|
+
</form>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
With react-hook-form:
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { useForm } from "react-hook-form";
|
|
89
|
+
import { Button } from "@primecoderin/fast-ui-react";
|
|
90
|
+
import { FormTextField, FormSelectField } from "@primecoderin/fast-ui-react/forms";
|
|
91
|
+
|
|
92
|
+
export function MemberForm({ roles, save }: { roles: { value: string; label: string }[]; save: (values: { name: string; role: string }) => void }) {
|
|
93
|
+
const { control, handleSubmit } = useForm({ defaultValues: { name: "", role: "" } });
|
|
94
|
+
return (
|
|
95
|
+
<form onSubmit={handleSubmit(save)}>
|
|
96
|
+
<FormTextField control={control} name="name" label="Name" rules={{ required: "Enter a name" }} />
|
|
97
|
+
<FormSelectField control={control} name="role" label="Role" options={roles} rules={{ required: "Choose a role" }} />
|
|
98
|
+
<Button type="submit" variant="primary">Save</Button>
|
|
99
|
+
</form>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The bound fields take the plain field's props, except the ones react-hook-form supplies (`value`, `onValueChange`,
|
|
105
|
+
`errorMessage`, `invalid`, `onBlur`, `inputRef`, and `name`, which is typed to the form's field names), and add
|
|
106
|
+
`rules` (react-hook-form's validation rules, on every bound field) and `formatError`, which turns a stored validation message into display text. A
|
|
107
|
+
plain field takes the text as it is: `errorMessage` is already in the user's language. `inputRef` and `onBlur`
|
|
108
|
+
are for a form library that focuses the first invalid field and tracks which fields were left.
|
|
109
|
+
|
|
110
|
+
A `Slider` cannot be named by `<label htmlFor>`: Base UI puts the `id` on a part that is not the range input, so
|
|
111
|
+
give it `aria-labelledby` (a `FieldFrame` label id) or `aria-label`.
|
|
112
|
+
|
|
113
|
+
The pieces to build a field of your own (`FieldFrame`, `fieldControl`, `fieldInput`, `toErrorText`) stay in the
|
|
114
|
+
main entry.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Getting started
|
|
2
|
+
|
|
3
|
+
```bash
|
|
4
|
+
npm install @primecoderin/fast-ui-react
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
The package needs React 19 in the app (`react` and `react-dom`, which a React app already has). Everything else,
|
|
8
|
+
Base UI included, comes with it. Three features live in their own entries, so an app that does not use them never
|
|
9
|
+
installs, downloads or bundles what they need:
|
|
10
|
+
|
|
11
|
+
| You use | Import from | Also install |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| Components, patterns, theming | `@primecoderin/fast-ui-react` | nothing |
|
|
14
|
+
| Form fields bound to react-hook-form ([Forms](forms.md)) | `@primecoderin/fast-ui-react/forms` | `react-hook-form` 7.91 or later 7.x |
|
|
15
|
+
| Charts ([Charts](charts.md)) | `@primecoderin/fast-ui-react/charts` | `recharts` 3.11 or later 3.x |
|
|
16
|
+
| The rich text editor ([Advanced components](advanced-components.md#rich-text)) | `@primecoderin/fast-ui-react/editor` | `@tiptap/core @tiptap/pm @tiptap/react @tiptap/starter-kit`, 3.35 or later 3.x |
|
|
17
|
+
| The rich text editor as a form field | `@primecoderin/fast-ui-react/editor-forms` | the TipTap packages and `react-hook-form` |
|
|
18
|
+
|
|
19
|
+
These are optional peer dependencies with those ranges (`peerDependencies` in `package.json`): an app on Recharts 2
|
|
20
|
+
or TipTap 2 gets a peer-dependency warning from npm and must upgrade to use that entry.
|
|
21
|
+
|
|
22
|
+
**1. Import the stylesheet once**, at the app's entry. It carries the font, the tokens, the base rules and every
|
|
23
|
+
Tailwind class the components use, so the app needs no Tailwind and no font of its own:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import "@primecoderin/fast-ui-react/styles.css";
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The font is Inter, served from the package's own files (`dist/fonts/`): no `<link>` to add and no request to
|
|
30
|
+
another site, so a Content-Security-Policy of `font-src 'self'` allows it. One variable file per character set
|
|
31
|
+
covers every weight, and a browser downloads only the files whose characters a page shows (47 KB for English), and
|
|
32
|
+
none if the app sets another font with `createTheme`. A right-to-left page uses Arial instead, since Inter has no
|
|
33
|
+
Hebrew or Arabic. The font's licence (SIL Open Font License) ships next to it.
|
|
34
|
+
|
|
35
|
+
**2. Wrap the app in the provider.** It sets `data-theme` and `dir` on `<html>`, applies tenant branding, and
|
|
36
|
+
hosts the toaster and the shared tooltip delay.
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { Button, DesignSystemProvider } from "@primecoderin/fast-ui-react";
|
|
40
|
+
|
|
41
|
+
export const App = () => (
|
|
42
|
+
<DesignSystemProvider themeMode="light" direction="ltr">
|
|
43
|
+
<Button variant="primary">Save</Button>
|
|
44
|
+
</DesignSystemProvider>
|
|
45
|
+
);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Vite and other frameworks
|
|
49
|
+
|
|
50
|
+
- **Vite** needs no plugin and no configuration: the same three steps. The package's own Storybook runs on Vite.
|
|
51
|
+
- **Next.js** has [its own page](nextjs.md).
|
|
52
|
+
- **React Router, Remix, TanStack Start, Astro and others** are not tested yet. The package is ESM, ships plain CSS
|
|
53
|
+
and starts its components with `"use client"`, so any React 19 app whose bundler imports a `.css` file should work.
|
|
54
|
+
Please report a problem with the framework and its version.
|
|
55
|
+
|
|
56
|
+
## Next steps
|
|
57
|
+
|
|
58
|
+
- **Your brand and fonts:** [Theme, branding and tokens](theming.md).
|
|
59
|
+
- **Next.js:** [Next.js](nextjs.md) (Server Components, `"use client"`, App Router and Pages Router).
|
|
60
|
+
- **Forms:** [Forms](forms.md), plain fields and react-hook-form fields.
|
|
61
|
+
- **Styling one component:** [Styling and customization](customization.md); types: [TypeScript](typescript.md).
|
|
62
|
+
- **Every component, with its props:** [Components](components.md).
|
|
63
|
+
- **Right to left, translation, accessibility:** [Internationalization](internationalization.md), [Accessibility](accessibility.md).
|
|
64
|
+
- **Something not working:** [Troubleshooting and FAQ](faq.md).
|
package/docs/icons.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Icons
|
|
2
|
+
|
|
3
|
+
The icons are [lucide](https://lucide.dev), through `lucide-react`, which is a dependency of the package: an app that
|
|
4
|
+
imports icons from it shares the copy.
|
|
5
|
+
|
|
6
|
+
## Passing an icon to a component
|
|
7
|
+
|
|
8
|
+
Components that take an icon (`Button`, `MenuItem`, `IconTile`, `Stat`, `EmptyState`, `Dialog`, `Drawer`, `ToggleButton` ...) take a React element in
|
|
9
|
+
an `icon` prop, and size it by font size:
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { Plus } from "lucide-react";
|
|
13
|
+
import { Button } from "@primecoderin/fast-ui-react";
|
|
14
|
+
|
|
15
|
+
<Button icon={<Plus />}>Add</Button>;
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- **Icons are decorative.** The component hides them from assistive technology. A control that shows only an icon
|
|
19
|
+
needs an `aria-label`: `<Button variant="icon" icon={<Plus />} aria-label="Add" />`.
|
|
20
|
+
- **Colour follows the text** (`currentColor`), so an icon takes the control's colour in every theme and state.
|
|
21
|
+
- Any React element works, so a different icon library or an inline SVG does too.
|
|
22
|
+
|
|
23
|
+
## One icon for each thing
|
|
24
|
+
|
|
25
|
+
`FAST_ICONS` names one icon for each thing an interface shows (`search`, `filter`, `add`, `edit`, `delete`, `download`,
|
|
26
|
+
`calendar`, `settings`, `check`, `warning`, `error`, `info` ...), so the same thing has the same icon on every
|
|
27
|
+
screen. Take an icon from it before picking one; `FastIconName` is the union of the names:
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { FAST_ICONS, type FastIconName } from "@primecoderin/fast-ui-react";
|
|
31
|
+
|
|
32
|
+
const SearchIcon = FAST_ICONS.search;
|
|
33
|
+
const name: FastIconName = "search";
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`FAST_ICONS` covers three general groups: common navigation (`dashboard`, `home`, `analytics`, `billing`, `users`,
|
|
37
|
+
`settings` ...), actions (`search`, `filter`, `add`, `edit`, `delete`, `download`, `calendar`, `arrow`) and status
|
|
38
|
+
(`bolt`, `check`, `close`, `warning`, `error`, `info`). Import directly from `lucide-react` for anything else.
|
|
39
|
+
|
|
40
|
+
## Right to left
|
|
41
|
+
|
|
42
|
+
lucide's icons do not mirror. An icon that means a direction (`arrow`, a chevron that means "next") must flip in a
|
|
43
|
+
right-to-left layout: add `rtl:rotate-180`, as the calendar's arrows do. See [Internationalization](internationalization.md).
|
|
44
|
+
|
|
45
|
+
## Size
|
|
46
|
+
|
|
47
|
+
An icon is sized by the font size of the component it sits in, so it scales with the type. To size one yourself,
|
|
48
|
+
give it a Tailwind size utility the stylesheet has (`size-4` is 16px; see [Styling and customization](customization.md)).
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Internationalization
|
|
2
|
+
|
|
3
|
+
The package holds no text of its own, so it works in any language the app can translate, and it lays out
|
|
4
|
+
right to left as it does left to right.
|
|
5
|
+
|
|
6
|
+
## Text
|
|
7
|
+
|
|
8
|
+
Every string a user reads arrives through props: `label`, `hint`, `errorMessage`, and `labels` objects for
|
|
9
|
+
components with several strings (`PaginationLabels`, `ToastLabels`, `PhoneFieldLabels`, `DateTimePickerLabels`,
|
|
10
|
+
`DateRangePickerLabels`, `RichTextEditorLabels`, and so on). Pass the app's translations from whichever library it
|
|
11
|
+
uses (react-intl, i18next, Lingui, next-intl); the package has no dependency on any of them.
|
|
12
|
+
|
|
13
|
+
A few components export English defaults for their `labels` so a demo works at once: `ENGLISH_PICKER_LABELS`,
|
|
14
|
+
`ENGLISH_RANGE_LABELS`, `ENGLISH_TOAST_LABELS`. They are English only and meant to be replaced; an app that ships
|
|
15
|
+
in other languages passes its own.
|
|
16
|
+
|
|
17
|
+
Validation messages follow the same rule: a plain field takes `errorMessage`, and a react-hook-form field stores a
|
|
18
|
+
message key and shows what the app's `formatError` returns (see [Forms](forms.md)).
|
|
19
|
+
|
|
20
|
+
## Right to left
|
|
21
|
+
|
|
22
|
+
`DesignSystemProvider` sets `dir` and `data-theme` on `<html>`:
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
<DesignSystemProvider themeMode="light" direction="rtl">
|
|
26
|
+
{children}
|
|
27
|
+
</DesignSystemProvider>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
- **Switching at run time.** Pass a new `direction` (from the app's state or its locale) and the provider updates
|
|
31
|
+
`dir` on `<html>` straight away: the layout mirrors, the arrow keys reverse and the right-to-left font applies, with
|
|
32
|
+
no reload. On unmount it puts back the `dir` the page had before.
|
|
33
|
+
- **A region in the other direction** (a right-to-left quote in a left-to-right page): put `dir` on that region's
|
|
34
|
+
element yourself and wrap it in a second `DesignSystemProvider` with the same `direction`. The inner provider only
|
|
35
|
+
tells Base UI's behaviour (arrow keys, popup placement) the direction; the outer one keeps the theme and `<html>`.
|
|
36
|
+
|
|
37
|
+
- Layouts use logical properties (`ps-*`, `pe-*`, `ms-*`, `inset-s-*`, `text-start`), so they mirror without
|
|
38
|
+
`rtl:` overrides. `rtl:` appears only for a glyph or a slide that must flip.
|
|
39
|
+
- Arrow keys follow the reading direction: in a right-to-left layout, ArrowRight moves to the previous item.
|
|
40
|
+
- Icons that point somewhere (the calendar's previous and next arrows, for one) flip with `rtl:rotate-180`. Charts do not: an axis of numbers or dates reads left
|
|
41
|
+
to right in a right-to-left language too.
|
|
42
|
+
- Every story is tested in both directions, so a component that breaks when mirrored fails the build. The
|
|
43
|
+
toolbar's **Direction** switch shows it in Storybook.
|
|
44
|
+
|
|
45
|
+
## Numbers, dates and calendars
|
|
46
|
+
|
|
47
|
+
- `NumberField` takes `locale` and `format` (any `Intl.NumberFormat` options).
|
|
48
|
+
- File sizes format through `Intl.NumberFormat`.
|
|
49
|
+
- The calendars, date and date-time pickers take a date-fns `locale` for the names of months and days and the first day of the week: import it
|
|
50
|
+
from `date-fns/locale/<code>` (for example `he` or `ar-SA`) and pass it. `date-fns` is a dependency of the
|
|
51
|
+
package; an app that already uses it shares the copy. Dates are always written day first and times in 24 hours,
|
|
52
|
+
whatever the locale. See [Dates, files and data](dates-files-data.md).
|
|
53
|
+
|
|
54
|
+
## Fonts
|
|
55
|
+
|
|
56
|
+
Inter, the default font, covers Latin, Cyrillic, Greek and Vietnamese, but not Hebrew or Arabic, so a right-to-left
|
|
57
|
+
page (any language) switches to Arial. For Arabic, Persian or Urdu, CJK or Indic scripts, set a font made for the
|
|
58
|
+
script with `createTheme` (see [Theme, branding and tokens](theming.md)) and keep a fallback after it. A font set
|
|
59
|
+
that way applies in both directions; switch it with the language if the two need different fonts.
|
|
60
|
+
|
|
61
|
+
## Not covered
|
|
62
|
+
|
|
63
|
+
Month and day names follow `locale`, but the date and time order do not. There is no built-in translation catalogue, pluralization or message formatting, and no automatic locale
|
|
64
|
+
detection: the app decides the language and direction and passes both in.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Layout and navigation
|
|
2
|
+
|
|
3
|
+
An app that imports `styles.css` has no Tailwind of its own, so the package lays pages out too:
|
|
4
|
+
|
|
5
|
+
| For | Use |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| Children in a row or a column, with a gap | `Stack` (`direction`, `gap`, `align`, `justify`, `wrap`) |
|
|
8
|
+
| Equal columns, or as many as fit | `Grid` (`columns`, or `minColumnWidth` for cards that wrap by themselves) |
|
|
9
|
+
| A page's content, centred and no wider than a limit | `Container` (`size`: `narrow`, `default`, `wide`, `full`) |
|
|
10
|
+
| A rule between groups | `Separator` |
|
|
11
|
+
| Text that goes somewhere | `Link` (`render` takes the app's router link) |
|
|
12
|
+
| The path to the current page | `Breadcrumbs` |
|
|
13
|
+
| Sections that open and close | `Accordion` (several), `Collapsible` (one) |
|
|
14
|
+
| A scrolling region with slim scrollbars | `ScrollArea` |
|
|
15
|
+
| A row of controls that is one Tab stop | `Toolbar`, `ToolbarButton`, `ToolbarSeparator` |
|
|
16
|
+
| Menus | `Menu`, `ContextMenu` (a right click), `Menubar` and `MenubarMenu`; items: `MenuItem`, `MenuCheckboxItem`, `MenuRadioItem`, `MenuLinkItem`, `MenuSubmenu`, `MenuGroup`, `MenuSeparator` |
|
|
17
|
+
| The top navigation of a site | `NavigationMenu` |
|
|
18
|
+
| The navigation down the side of an app | `SideNav` (sections, groups, a collapsed form of icons) |
|
|
19
|
+
| The frame of an app | `AppShell` (a sticky header, the navigation beside the page, the page as `<main>`) |
|
|
20
|
+
| The steps of a process | `Stepper` |
|
|
21
|
+
|
|
22
|
+
`Stack`, `Grid` and `Container` take a gap in steps of 4px (`gap={4}` is 16px) rather than a class, so they work
|
|
23
|
+
with the ready-made stylesheet. A link in any of the navigation components takes `href`, or `render` for the app's
|
|
24
|
+
router link: `render={<RouterLink to="/orders" />}`; the component keeps its look and the router keeps the
|
|
25
|
+
navigation.
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { useState } from "react";
|
|
29
|
+
import { AppShell, Container, SideNav, Stack, type SideNavProps } from "@primecoderin/fast-ui-react";
|
|
30
|
+
|
|
31
|
+
export function Layout({ sections }: { sections: SideNavProps["sections"] }) {
|
|
32
|
+
const [navOpen, setNavOpen] = useState(false);
|
|
33
|
+
return (
|
|
34
|
+
<AppShell
|
|
35
|
+
labels={{ navigation: "Main navigation", openNavigation: "Open menu", closeNavigation: "Close menu", skipToContent: "Skip to content" }}
|
|
36
|
+
navOpen={navOpen}
|
|
37
|
+
onNavOpenChange={setNavOpen}
|
|
38
|
+
header={<strong>Acme</strong>}
|
|
39
|
+
nav={<SideNav aria-label="Main" current="orders" onNavigate={() => setNavOpen(false)} sections={sections} />}
|
|
40
|
+
>
|
|
41
|
+
<Container>
|
|
42
|
+
<Stack gap={6}>{/* the page */}</Stack>
|
|
43
|
+
</Container>
|
|
44
|
+
</AppShell>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
From the `md` breakpoint (768px) the navigation is a column beside the page, `--fast-size-sidenav` wide; below it
|
|
50
|
+
the navigation is a drawer that the header's menu button opens. The layout sizes are tokens: `size-header`,
|
|
51
|
+
`size-sidenav`, `size-sidenav-collapsed`, `container-max` and `z-sticky`, which `createTheme` can change.
|