@primecoderin/fast-ui-react 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +106 -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 +40 -0
- package/docs/testing.md +242 -0
- package/docs/theming.md +118 -0
- package/docs/typescript.md +62 -0
- package/llms-full.txt +4573 -0
- package/llms.txt +52 -0
- package/package.json +193 -6
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Combobox } from "@base-ui/react/combobox";
|
|
4
|
+
import { Check, X } from "lucide-react";
|
|
5
|
+
import { cn } from "../../utils/cn.js";
|
|
6
|
+
import { indicator, item } from "../../utils/popup.js";
|
|
7
|
+
import { fieldChip, fieldChipRemove, fieldChipsBox, fieldControl, fieldInput } from "../FormField/field-styles.js";
|
|
8
|
+
import { ComboboxPopup } from "./ComboboxPopup.js";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
// src/patterns/Combobox/MultiSelect.tsx
|
|
11
|
+
/**
|
|
12
|
+
* A select for several options. The chosen ones are chips in the box, each with a button that removes it, and
|
|
13
|
+
* the box grows onto more lines as chips are added. Typing filters the list, the arrow keys and Enter add an
|
|
14
|
+
* option and the list stays open for the next; Backspace in the empty input removes the last chip.
|
|
15
|
+
*/
|
|
16
|
+
var MultiSelect = (t0) => {
|
|
17
|
+
const $ = c(42);
|
|
18
|
+
const { options, value, onValueChange, labels, placeholder, disabled: t1, invalid: t2, required: t3, size: t4, contentBefore, name, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, onBlur, inputRef } = t0;
|
|
19
|
+
const disabled = t1 === void 0 ? false : t1;
|
|
20
|
+
const invalid = t2 === void 0 ? false : t2;
|
|
21
|
+
const required = t3 === void 0 ? false : t3;
|
|
22
|
+
const size = t4 === void 0 ? "medium" : t4;
|
|
23
|
+
let t5;
|
|
24
|
+
if ($[0] !== options || $[1] !== value) {
|
|
25
|
+
let t6;
|
|
26
|
+
if ($[3] !== options) {
|
|
27
|
+
t6 = (chosen) => options.filter((option) => option.value === chosen);
|
|
28
|
+
$[3] = options;
|
|
29
|
+
$[4] = t6;
|
|
30
|
+
} else t6 = $[4];
|
|
31
|
+
t5 = value.flatMap(t6);
|
|
32
|
+
$[0] = options;
|
|
33
|
+
$[1] = value;
|
|
34
|
+
$[2] = t5;
|
|
35
|
+
} else t5 = $[2];
|
|
36
|
+
let t6;
|
|
37
|
+
if ($[5] !== onValueChange) {
|
|
38
|
+
t6 = (next) => {
|
|
39
|
+
onValueChange(next.map(_temp));
|
|
40
|
+
};
|
|
41
|
+
$[5] = onValueChange;
|
|
42
|
+
$[6] = t6;
|
|
43
|
+
} else t6 = $[6];
|
|
44
|
+
let t7;
|
|
45
|
+
if ($[7] !== name) {
|
|
46
|
+
t7 = name ? { name } : {};
|
|
47
|
+
$[7] = name;
|
|
48
|
+
$[8] = t7;
|
|
49
|
+
} else t7 = $[8];
|
|
50
|
+
let t8;
|
|
51
|
+
if ($[9] !== size) {
|
|
52
|
+
t8 = cn(fieldControl({ size }), fieldChipsBox);
|
|
53
|
+
$[9] = size;
|
|
54
|
+
$[10] = t8;
|
|
55
|
+
} else t8 = $[10];
|
|
56
|
+
const t9 = invalid || void 0;
|
|
57
|
+
const t10 = disabled || void 0;
|
|
58
|
+
let t11;
|
|
59
|
+
if ($[11] !== ariaLabel || $[12] !== ariaLabelledBy || $[13] !== id || $[14] !== inputRef || $[15] !== invalid || $[16] !== labels || $[17] !== onBlur || $[18] !== placeholder || $[19] !== required) {
|
|
60
|
+
t11 = /* @__PURE__ */ jsx(Combobox.Value, { children: (chosen_0) => /* @__PURE__ */ jsxs(Fragment, { children: [chosen_0.map((option_2) => /* @__PURE__ */ jsxs(Combobox.Chip, {
|
|
61
|
+
"aria-label": option_2.label,
|
|
62
|
+
className: fieldChip,
|
|
63
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
64
|
+
className: "min-w-0 truncate",
|
|
65
|
+
children: option_2.label
|
|
66
|
+
}), /* @__PURE__ */ jsx(Combobox.ChipRemove, {
|
|
67
|
+
"aria-label": labels.remove(option_2.label),
|
|
68
|
+
className: fieldChipRemove,
|
|
69
|
+
children: /* @__PURE__ */ jsx(X, { "aria-hidden": "true" })
|
|
70
|
+
})]
|
|
71
|
+
}, option_2.value)), /* @__PURE__ */ jsx(Combobox.Input, {
|
|
72
|
+
ref: inputRef,
|
|
73
|
+
...id ? { id } : {},
|
|
74
|
+
...ariaLabel ? { "aria-label": ariaLabel } : {},
|
|
75
|
+
...ariaLabelledBy ? { "aria-labelledby": ariaLabelledBy } : {},
|
|
76
|
+
...invalid ? { "aria-invalid": true } : {},
|
|
77
|
+
"aria-required": required || void 0,
|
|
78
|
+
className: cn(fieldInput, "min-w-20 flex-1 self-auto"),
|
|
79
|
+
placeholder: chosen_0.length === 0 ? placeholder : void 0,
|
|
80
|
+
onBlur
|
|
81
|
+
})] }) });
|
|
82
|
+
$[11] = ariaLabel;
|
|
83
|
+
$[12] = ariaLabelledBy;
|
|
84
|
+
$[13] = id;
|
|
85
|
+
$[14] = inputRef;
|
|
86
|
+
$[15] = invalid;
|
|
87
|
+
$[16] = labels;
|
|
88
|
+
$[17] = onBlur;
|
|
89
|
+
$[18] = placeholder;
|
|
90
|
+
$[19] = required;
|
|
91
|
+
$[20] = t11;
|
|
92
|
+
} else t11 = $[20];
|
|
93
|
+
let t12;
|
|
94
|
+
if ($[21] !== contentBefore || $[22] !== t10 || $[23] !== t11 || $[24] !== t8 || $[25] !== t9) {
|
|
95
|
+
t12 = /* @__PURE__ */ jsxs(Combobox.Chips, {
|
|
96
|
+
className: t8,
|
|
97
|
+
"data-invalid": t9,
|
|
98
|
+
"data-disabled": t10,
|
|
99
|
+
children: [contentBefore, t11]
|
|
100
|
+
});
|
|
101
|
+
$[21] = contentBefore;
|
|
102
|
+
$[22] = t10;
|
|
103
|
+
$[23] = t11;
|
|
104
|
+
$[24] = t8;
|
|
105
|
+
$[25] = t9;
|
|
106
|
+
$[26] = t12;
|
|
107
|
+
} else t12 = $[26];
|
|
108
|
+
let t13;
|
|
109
|
+
if ($[27] !== ariaLabel || $[28] !== ariaLabelledBy) {
|
|
110
|
+
t13 = {
|
|
111
|
+
"aria-label": ariaLabel,
|
|
112
|
+
"aria-labelledby": ariaLabelledBy
|
|
113
|
+
};
|
|
114
|
+
$[27] = ariaLabel;
|
|
115
|
+
$[28] = ariaLabelledBy;
|
|
116
|
+
$[29] = t13;
|
|
117
|
+
} else t13 = $[29];
|
|
118
|
+
let t14;
|
|
119
|
+
if ($[30] !== labels.noMatches || $[31] !== labels.results || $[32] !== t13) {
|
|
120
|
+
t14 = /* @__PURE__ */ jsx(ComboboxPopup, {
|
|
121
|
+
noMatchesLabel: labels.noMatches,
|
|
122
|
+
resultsLabel: labels.results,
|
|
123
|
+
naming: t13,
|
|
124
|
+
children: _temp4
|
|
125
|
+
});
|
|
126
|
+
$[30] = labels.noMatches;
|
|
127
|
+
$[31] = labels.results;
|
|
128
|
+
$[32] = t13;
|
|
129
|
+
$[33] = t14;
|
|
130
|
+
} else t14 = $[33];
|
|
131
|
+
let t15;
|
|
132
|
+
if ($[34] !== disabled || $[35] !== options || $[36] !== t12 || $[37] !== t14 || $[38] !== t5 || $[39] !== t6 || $[40] !== t7) {
|
|
133
|
+
t15 = /* @__PURE__ */ jsxs(Combobox.Root, {
|
|
134
|
+
multiple: true,
|
|
135
|
+
items: options,
|
|
136
|
+
value: t5,
|
|
137
|
+
onValueChange: t6,
|
|
138
|
+
itemToStringLabel: _temp2,
|
|
139
|
+
isItemEqualToValue: _temp3,
|
|
140
|
+
...t7,
|
|
141
|
+
disabled,
|
|
142
|
+
children: [t12, t14]
|
|
143
|
+
});
|
|
144
|
+
$[34] = disabled;
|
|
145
|
+
$[35] = options;
|
|
146
|
+
$[36] = t12;
|
|
147
|
+
$[37] = t14;
|
|
148
|
+
$[38] = t5;
|
|
149
|
+
$[39] = t6;
|
|
150
|
+
$[40] = t7;
|
|
151
|
+
$[41] = t15;
|
|
152
|
+
} else t15 = $[41];
|
|
153
|
+
return t15;
|
|
154
|
+
};
|
|
155
|
+
function _temp(option_0) {
|
|
156
|
+
return option_0.value;
|
|
157
|
+
}
|
|
158
|
+
function _temp2(option_1) {
|
|
159
|
+
return option_1.label;
|
|
160
|
+
}
|
|
161
|
+
function _temp3(a, b) {
|
|
162
|
+
return a.value === b.value;
|
|
163
|
+
}
|
|
164
|
+
function _temp4(option_3) {
|
|
165
|
+
return /* @__PURE__ */ jsxs(Combobox.Item, {
|
|
166
|
+
value: option_3,
|
|
167
|
+
disabled: option_3.disabled,
|
|
168
|
+
className: item,
|
|
169
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
170
|
+
className: indicator,
|
|
171
|
+
children: /* @__PURE__ */ jsx(Combobox.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { "aria-hidden": "true" }) })
|
|
172
|
+
}), option_3.label]
|
|
173
|
+
}, option_3.value);
|
|
174
|
+
}
|
|
175
|
+
export { MultiSelect };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface CommandItem {
|
|
3
|
+
/** Identifies the command in its group. Any text: the palette does not use it in an element's id. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** The command's name, in the user's language. Typing finds it. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** A glyph before the label. */
|
|
8
|
+
icon?: ReactNode | undefined;
|
|
9
|
+
/** The keys that do it without the palette, written at the end of the row: "Ctrl+N". For reminding only. */
|
|
10
|
+
shortcut?: string | undefined;
|
|
11
|
+
/** Other words that find the command: "preferences" for "Settings". */
|
|
12
|
+
keywords?: readonly string[] | undefined;
|
|
13
|
+
/** Runs the command. The palette closes first. */
|
|
14
|
+
onSelect: () => void;
|
|
15
|
+
/** Listed but cannot run: the arrow keys pass over it. */
|
|
16
|
+
disabled?: boolean | undefined;
|
|
17
|
+
}
|
|
18
|
+
export interface CommandGroup {
|
|
19
|
+
/** Identifies the group. */
|
|
20
|
+
id: string;
|
|
21
|
+
/** A small heading over the group's commands. */
|
|
22
|
+
label?: string | undefined;
|
|
23
|
+
/** The group's commands, in order. A command may be in more than one group. */
|
|
24
|
+
items: readonly CommandItem[];
|
|
25
|
+
}
|
|
26
|
+
/** The texts of the palette. The design system has no i18n, so the caller supplies them. */
|
|
27
|
+
export interface CommandPaletteLabels {
|
|
28
|
+
/** The palette's accessible name, e.g. "Command palette". */
|
|
29
|
+
title: string;
|
|
30
|
+
/** The search field's placeholder and accessible name, e.g. "Type a command or search". */
|
|
31
|
+
placeholder: string;
|
|
32
|
+
/** Shown when nothing matches, e.g. "No results". */
|
|
33
|
+
noResults: string;
|
|
34
|
+
}
|
|
35
|
+
export interface CommandPaletteProps {
|
|
36
|
+
/** Whether the palette is open. Each opening starts with an empty search. */
|
|
37
|
+
open: boolean;
|
|
38
|
+
/** Called with `false` when the palette closes: Escape, a click outside, or a command run. */
|
|
39
|
+
onOpenChange: (open: boolean) => void;
|
|
40
|
+
/** The commands, in groups, in the order they are listed. */
|
|
41
|
+
groups: readonly CommandGroup[];
|
|
42
|
+
/** The palette's name, the search field's placeholder and the no-results text. */
|
|
43
|
+
labels: CommandPaletteLabels;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A search box over a list of commands, opened over the page: type to narrow the list, the arrow keys move through
|
|
47
|
+
* it, Enter runs the command and Escape closes. The app opens it, usually from a shortcut such as Ctrl or Cmd and
|
|
48
|
+
* K, and says what each command does. To a screen reader it is a dialog holding a combobox whose list is announced.
|
|
49
|
+
*/
|
|
50
|
+
export declare const CommandPalette: ({ open, onOpenChange, groups, labels }: CommandPaletteProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useId, useState } from "react";
|
|
4
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
5
|
+
import { Search } from "lucide-react";
|
|
6
|
+
import { cn } from "../../utils/cn.js";
|
|
7
|
+
import { item } from "../../utils/popup.js";
|
|
8
|
+
import { Kbd } from "../../components/Kbd/Kbd.js";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
// src/patterns/CommandPalette/CommandPalette.tsx
|
|
11
|
+
/** The commands that match the typed text: every word of it is found in the label or the keywords. */
|
|
12
|
+
var matches = (item, query) => {
|
|
13
|
+
const words = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
14
|
+
if (words.length === 0) return true;
|
|
15
|
+
const haystack = [item.label, ...item.keywords ?? []].join(" ").toLowerCase();
|
|
16
|
+
return words.every((word) => haystack.includes(word));
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A search box over a list of commands, opened over the page: type to narrow the list, the arrow keys move through
|
|
20
|
+
* it, Enter runs the command and Escape closes. The app opens it, usually from a shortcut such as Ctrl or Cmd and
|
|
21
|
+
* K, and says what each command does. To a screen reader it is a dialog holding a combobox whose list is announced.
|
|
22
|
+
*/
|
|
23
|
+
var CommandPalette = (t0) => {
|
|
24
|
+
const $ = c(11);
|
|
25
|
+
const { open, onOpenChange, groups, labels } = t0;
|
|
26
|
+
let t1;
|
|
27
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
28
|
+
t1 = /* @__PURE__ */ jsx(Dialog.Backdrop, { className: "fixed inset-0 z-1100 bg-scrim backdrop-blur-[2px] transition-opacity duration-150 ease-standard data-ending-style:opacity-0 data-starting-style:opacity-0" });
|
|
29
|
+
$[0] = t1;
|
|
30
|
+
} else t1 = $[0];
|
|
31
|
+
let t2;
|
|
32
|
+
if ($[1] !== onOpenChange) {
|
|
33
|
+
t2 = () => {
|
|
34
|
+
onOpenChange(false);
|
|
35
|
+
};
|
|
36
|
+
$[1] = onOpenChange;
|
|
37
|
+
$[2] = t2;
|
|
38
|
+
} else t2 = $[2];
|
|
39
|
+
let t3;
|
|
40
|
+
if ($[3] !== groups || $[4] !== labels || $[5] !== t2) {
|
|
41
|
+
t3 = /* @__PURE__ */ jsxs(Dialog.Portal, { children: [t1, /* @__PURE__ */ jsx(PaletteBody, {
|
|
42
|
+
groups,
|
|
43
|
+
labels,
|
|
44
|
+
onClose: t2
|
|
45
|
+
})] });
|
|
46
|
+
$[3] = groups;
|
|
47
|
+
$[4] = labels;
|
|
48
|
+
$[5] = t2;
|
|
49
|
+
$[6] = t3;
|
|
50
|
+
} else t3 = $[6];
|
|
51
|
+
let t4;
|
|
52
|
+
if ($[7] !== onOpenChange || $[8] !== open || $[9] !== t3) {
|
|
53
|
+
t4 = /* @__PURE__ */ jsx(Dialog.Root, {
|
|
54
|
+
open,
|
|
55
|
+
onOpenChange,
|
|
56
|
+
children: t3
|
|
57
|
+
});
|
|
58
|
+
$[7] = onOpenChange;
|
|
59
|
+
$[8] = open;
|
|
60
|
+
$[9] = t3;
|
|
61
|
+
$[10] = t4;
|
|
62
|
+
} else t4 = $[10];
|
|
63
|
+
return t4;
|
|
64
|
+
};
|
|
65
|
+
var PaletteBody = ({ groups, labels, onClose }) => {
|
|
66
|
+
const listId = useId();
|
|
67
|
+
const [query, setQuery] = useState("");
|
|
68
|
+
const [active, setActive] = useState(0);
|
|
69
|
+
let count = 0;
|
|
70
|
+
const shown = groups.map((group, groupIndex) => ({
|
|
71
|
+
group,
|
|
72
|
+
groupIndex,
|
|
73
|
+
entries: group.items.filter((item) => matches(item, query)).map((item_0) => ({
|
|
74
|
+
item: item_0,
|
|
75
|
+
index: count++
|
|
76
|
+
}))
|
|
77
|
+
})).filter(({ entries }) => entries.length > 0);
|
|
78
|
+
const flat = shown.flatMap(({ entries: entries_0 }) => entries_0);
|
|
79
|
+
const enabled = flat.filter(({ item: item_1 }) => !item_1.disabled);
|
|
80
|
+
const current = enabled[Math.min(active, Math.max(enabled.length - 1, 0))];
|
|
81
|
+
const optionId = (index) => `${listId}-option-${String(index)}`;
|
|
82
|
+
const empty = flat.length === 0;
|
|
83
|
+
const run = (item_2) => {
|
|
84
|
+
if (item_2.disabled) return;
|
|
85
|
+
onClose();
|
|
86
|
+
item_2.onSelect();
|
|
87
|
+
};
|
|
88
|
+
const move = (to) => {
|
|
89
|
+
if (enabled.length === 0) return;
|
|
90
|
+
setActive((to + enabled.length) % enabled.length);
|
|
91
|
+
};
|
|
92
|
+
return /* @__PURE__ */ jsxs(Dialog.Popup, {
|
|
93
|
+
"aria-label": labels.title,
|
|
94
|
+
className: cn("fixed inset-x-0 top-[12vh] z-1100 mx-auto flex max-h-[min(30rem,76vh)] w-[min(36rem,92vw)] flex-col overflow-hidden rounded-lg border border-line bg-surface text-fg shadow-modal outline-none", "transition-[opacity,scale] duration-150 ease-standard data-ending-style:scale-98 data-ending-style:opacity-0 data-starting-style:scale-98 data-starting-style:opacity-0"),
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ jsx(Dialog.Title, {
|
|
97
|
+
className: "sr-only",
|
|
98
|
+
children: labels.title
|
|
99
|
+
}),
|
|
100
|
+
/* @__PURE__ */ jsxs("div", {
|
|
101
|
+
className: "flex items-center gap-2.5 border-b border-line px-4",
|
|
102
|
+
children: [/* @__PURE__ */ jsx(Search, {
|
|
103
|
+
"aria-hidden": "true",
|
|
104
|
+
className: "size-4.5 shrink-0 text-fg-tertiary"
|
|
105
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
106
|
+
type: "text",
|
|
107
|
+
role: "combobox",
|
|
108
|
+
"aria-expanded": !empty,
|
|
109
|
+
"aria-controls": listId,
|
|
110
|
+
"aria-autocomplete": "list",
|
|
111
|
+
"aria-label": labels.placeholder,
|
|
112
|
+
...current ? { "aria-activedescendant": optionId(current.index) } : {},
|
|
113
|
+
autoComplete: "off",
|
|
114
|
+
spellCheck: false,
|
|
115
|
+
placeholder: labels.placeholder,
|
|
116
|
+
value: query,
|
|
117
|
+
className: "m-0 h-12 min-w-0 flex-1 border-0 bg-transparent p-0 text-body text-fg outline-none placeholder:text-fg-tertiary",
|
|
118
|
+
onChange: (event) => {
|
|
119
|
+
setQuery(event.target.value);
|
|
120
|
+
setActive(0);
|
|
121
|
+
},
|
|
122
|
+
onKeyDown: (event_0) => {
|
|
123
|
+
const at = current ? enabled.indexOf(current) : 0;
|
|
124
|
+
if (event_0.key === "ArrowDown") move(at + 1);
|
|
125
|
+
else if (event_0.key === "ArrowUp") move(at - 1);
|
|
126
|
+
else if (event_0.key === "Home") move(0);
|
|
127
|
+
else if (event_0.key === "End") move(enabled.length - 1);
|
|
128
|
+
else if (event_0.key === "Enter") {
|
|
129
|
+
if (current) run(current.item);
|
|
130
|
+
} else return;
|
|
131
|
+
event_0.preventDefault();
|
|
132
|
+
}
|
|
133
|
+
})]
|
|
134
|
+
}),
|
|
135
|
+
/* @__PURE__ */ jsx("div", {
|
|
136
|
+
id: listId,
|
|
137
|
+
role: "listbox",
|
|
138
|
+
"aria-label": labels.title,
|
|
139
|
+
hidden: empty,
|
|
140
|
+
className: "min-h-0 flex-1 overflow-y-auto p-1.5",
|
|
141
|
+
children: shown.map(({ group: group_0, groupIndex: groupIndex_0, entries: entries_1 }) => {
|
|
142
|
+
const headingId = `${listId}-group-${String(groupIndex_0)}`;
|
|
143
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
144
|
+
role: "group",
|
|
145
|
+
...group_0.label ? { "aria-labelledby": headingId } : {},
|
|
146
|
+
children: [group_0.label ? /* @__PURE__ */ jsx("p", {
|
|
147
|
+
id: headingId,
|
|
148
|
+
"aria-hidden": "true",
|
|
149
|
+
className: "m-0 px-2.5 pt-2 pb-1 text-caption font-semibold text-fg-secondary",
|
|
150
|
+
children: group_0.label
|
|
151
|
+
}) : null, entries_1.map((entry) => {
|
|
152
|
+
const { item: item_3 } = entry;
|
|
153
|
+
const isCurrent = entry === current;
|
|
154
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
155
|
+
id: optionId(entry.index),
|
|
156
|
+
role: "option",
|
|
157
|
+
"aria-selected": isCurrent,
|
|
158
|
+
"aria-disabled": item_3.disabled || void 0,
|
|
159
|
+
className: cn(item, "cursor-pointer", item_3.disabled && "cursor-not-allowed"),
|
|
160
|
+
...isCurrent ? { "data-highlighted": "" } : {},
|
|
161
|
+
...item_3.disabled ? { "data-disabled": "" } : {},
|
|
162
|
+
onMouseMove: () => {
|
|
163
|
+
const at_0 = enabled.indexOf(entry);
|
|
164
|
+
if (at_0 !== -1 && !isCurrent) setActive(at_0);
|
|
165
|
+
},
|
|
166
|
+
onClick: () => {
|
|
167
|
+
run(item_3);
|
|
168
|
+
},
|
|
169
|
+
children: [
|
|
170
|
+
item_3.icon ? /* @__PURE__ */ jsx("span", {
|
|
171
|
+
className: "inline-flex shrink-0 [&_svg]:size-4",
|
|
172
|
+
children: item_3.icon
|
|
173
|
+
}) : null,
|
|
174
|
+
/* @__PURE__ */ jsx("span", {
|
|
175
|
+
className: "min-w-0 flex-1 truncate",
|
|
176
|
+
children: item_3.label
|
|
177
|
+
}),
|
|
178
|
+
item_3.shortcut ? /* @__PURE__ */ jsx(Kbd, { children: item_3.shortcut }) : null
|
|
179
|
+
]
|
|
180
|
+
}, `${item_3.id}-${String(entry.index)}`);
|
|
181
|
+
})]
|
|
182
|
+
}, `${group_0.id}-${String(groupIndex_0)}`);
|
|
183
|
+
})
|
|
184
|
+
}),
|
|
185
|
+
/* @__PURE__ */ jsx("p", {
|
|
186
|
+
role: "status",
|
|
187
|
+
className: cn("m-0 text-center text-body-sm text-fg-secondary", empty ? "px-3 py-6" : "sr-only"),
|
|
188
|
+
children: empty ? labels.noResults : ""
|
|
189
|
+
})
|
|
190
|
+
]
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
export { CommandPalette };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
type RowId = string | number;
|
|
3
|
+
type SortDirection = "ascending" | "descending";
|
|
4
|
+
type CellAlign = "start" | "center" | "end";
|
|
5
|
+
export interface DataTableColumn<TRow> {
|
|
6
|
+
/** Identifies the column: its key, and what `sort` and `onSortChange` name. Unique among the columns. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** The column's title in the header, in the user's language. */
|
|
9
|
+
header: string;
|
|
10
|
+
/** What the column shows for a row: text, a number, a badge, a link. */
|
|
11
|
+
cell: (row: TRow) => ReactNode;
|
|
12
|
+
/** Makes the header a button that calls `onSortChange` with this column's id. */
|
|
13
|
+
sortable?: boolean | undefined;
|
|
14
|
+
/** Where the column's content sits in its cell. Numbers read best at the end. */
|
|
15
|
+
align?: CellAlign | undefined;
|
|
16
|
+
/** A share of the table's width, e.g. "23%", for a layout that should not shift with the data. */
|
|
17
|
+
width?: string | undefined;
|
|
18
|
+
/** Extra classes for the column's body cells, e.g. `max-w-90 truncate` for a long description. */
|
|
19
|
+
cellClassName?: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
export interface DataTableSort {
|
|
22
|
+
/** The `id` of the column the rows are sorted by. */
|
|
23
|
+
columnId: string;
|
|
24
|
+
/** Which way: `ascending` or `descending`. */
|
|
25
|
+
direction: SortDirection;
|
|
26
|
+
}
|
|
27
|
+
export interface DataTableSelection<TRow> {
|
|
28
|
+
/** The ids (`getRowId`) of the selected rows. */
|
|
29
|
+
selectedIds: ReadonlySet<RowId>;
|
|
30
|
+
/** Called with the ids of the selected rows when a box is ticked or cleared. */
|
|
31
|
+
onSelectionChange: (selectedIds: ReadonlySet<RowId>) => void;
|
|
32
|
+
/** Accessible names. The design system has no i18n, so the caller supplies them. */
|
|
33
|
+
labels: {
|
|
34
|
+
/** The header's box, e.g. "Select all projects". */
|
|
35
|
+
selectAll: string;
|
|
36
|
+
/** A row's box, e.g. `(row) => `Select ${row.name}``. */
|
|
37
|
+
selectRow: (row: TRow) => string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Rows that open a panel under themselves, as Figma's charge-card rows do. Each row gets a disclosure button at the
|
|
42
|
+
* start of its first cell (a screen reader hears its name and whether it is open), and a click elsewhere in the row
|
|
43
|
+
* opens or closes it too.
|
|
44
|
+
*/
|
|
45
|
+
export interface DataTableExpansion<TRow> {
|
|
46
|
+
/** Whether the row's panel is open. The caller keeps which rows are. */
|
|
47
|
+
isExpanded: (row: TRow) => boolean;
|
|
48
|
+
/** Called with the row and whether its panel should now be open, from its button or a click on the row. */
|
|
49
|
+
onExpandedChange: (row: TRow, expanded: boolean) => void;
|
|
50
|
+
/**
|
|
51
|
+
* The accessible name of the row's disclosure button: what it opens, e.g. `(row) => `Details of ${row.name}``.
|
|
52
|
+
* The button itself says whether it is open.
|
|
53
|
+
*/
|
|
54
|
+
toggleLabel: (row: TRow) => string;
|
|
55
|
+
/** The panel, drawn in a full-width cell under the row while it is expanded. */
|
|
56
|
+
render: (row: TRow) => ReactNode;
|
|
57
|
+
}
|
|
58
|
+
export interface DataTableProps<TRow> {
|
|
59
|
+
/** The columns, in order from the start edge. */
|
|
60
|
+
columns: readonly DataTableColumn<TRow>[];
|
|
61
|
+
/** The rows to show, in the order to show them: sorting and paging are the caller's. */
|
|
62
|
+
rows: readonly TRow[];
|
|
63
|
+
/** A row's id, unique among the rows: the React key, and what `selection` holds. */
|
|
64
|
+
getRowId: (row: TRow) => RowId;
|
|
65
|
+
/**
|
|
66
|
+
* Makes rows clickable and keyboard-activatable (Enter or Space): each row becomes a Tab stop. A screen reader
|
|
67
|
+
* hears a row there, not a button, so this is a convenience: give the same action a real control in a cell too,
|
|
68
|
+
* such as a link to the row's page. To open a panel under the row, use `expansion`, which draws its own button.
|
|
69
|
+
*/
|
|
70
|
+
onRowActivate?: ((row: TRow) => void) | undefined;
|
|
71
|
+
/** Accessible name of the table. */
|
|
72
|
+
"aria-label": string;
|
|
73
|
+
/** The column the rows are sorted by, shown on its header. Sorting itself is the caller's. */
|
|
74
|
+
sort?: DataTableSort | undefined;
|
|
75
|
+
/** Called with a sortable column's id when its header is pressed; the caller sorts and sets `sort`. */
|
|
76
|
+
onSortChange?: ((columnId: string) => void) | undefined;
|
|
77
|
+
/** Adds a checkbox column. Selected ids may include rows on other pages. */
|
|
78
|
+
selection?: DataTableSelection<TRow> | undefined;
|
|
79
|
+
/** Lets rows expand inline, each with a disclosure button. The caller owns which rows are open. */
|
|
80
|
+
expansion?: DataTableExpansion<TRow> | undefined;
|
|
81
|
+
/** Shows placeholder rows in place of `rows`. */
|
|
82
|
+
isLoading?: boolean | undefined;
|
|
83
|
+
/** How many placeholder rows to show while loading. */
|
|
84
|
+
loadingRows?: number | undefined;
|
|
85
|
+
/** Shown under the header when there are no rows. */
|
|
86
|
+
emptyState?: ReactNode | undefined;
|
|
87
|
+
/** Keep the header in view while the rows scroll inside a bounded container. */
|
|
88
|
+
stickyHeader?: boolean | undefined;
|
|
89
|
+
/** Extra classes for a row's `tr`, e.g. a tint for the rows of one kind. Merged last, so it can override the defaults. */
|
|
90
|
+
rowClassName?: ((row: TRow) => string | undefined) | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* For a windowed list: `rows` is only the part in view, and these are the heights, in
|
|
93
|
+
* pixels, of the rows left out above and below it. They are drawn as empty rows, so
|
|
94
|
+
* the scroll bar is as long as the whole list would be.
|
|
95
|
+
*/
|
|
96
|
+
virtualPadding?: {
|
|
97
|
+
top: number;
|
|
98
|
+
bottom: number;
|
|
99
|
+
} | undefined;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* An edge-to-edge table. When rows are activatable, a
|
|
103
|
+
* click is ignored while the user has text selected, so copying a cell's text
|
|
104
|
+
* does not navigate away.
|
|
105
|
+
*/
|
|
106
|
+
export declare const DataTable: <TRow>({ columns, rows, getRowId, onRowActivate, "aria-label": ariaLabel, sort, onSortChange, selection, expansion, isLoading, loadingRows, emptyState, stickyHeader, rowClassName, virtualPadding, }: DataTableProps<TRow>) => import("react").JSX.Element;
|
|
107
|
+
export {};
|