@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,283 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
4
|
+
import { useDirection } from "@base-ui/react/direction-provider";
|
|
5
|
+
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
6
|
+
import { enUS } from "date-fns/locale/en-US";
|
|
7
|
+
import { Button } from "../../components/Button/Button.js";
|
|
8
|
+
import { cn } from "../../utils/cn.js";
|
|
9
|
+
import { ENGLISH_PICKER_LABELS } from "../DateTimePicker/picker-labels.js";
|
|
10
|
+
import { currentParts, dayLabel, isDayAllowed, monthNames, monthOf, monthTitle, monthWeeks, nearestAllowedDay, readBounds, readPickerValue, shiftDay, shiftDayByMonths, shiftMonth, weekEdge, weekdayNames, yearOf } from "../DateTimePicker/picker-values.js";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
// src/patterns/Calendar/Calendar.tsx
|
|
13
|
+
/** A day: a teal border and wash on hover, solid teal at the ends of the choice, a wash between them, faded when it cannot be picked. */
|
|
14
|
+
var DAY_BUTTON = cn("flex h-8 w-full cursor-pointer items-center justify-center rounded-check border border-transparent text-body-sm font-normal text-fg outline-none transition-colors", "hover:border-primary hover:bg-primary-light focus-visible:ring-2 focus-visible:ring-focus", "aria-disabled:cursor-not-allowed aria-disabled:opacity-25 aria-disabled:hover:border-transparent aria-disabled:hover:bg-transparent", "data-today:font-semibold data-today:text-primary-text", "data-in-range:rounded-none data-in-range:bg-primary-light data-in-range:text-primary-text", "data-selected:bg-primary data-selected:font-normal data-selected:text-on-primary data-selected:hover:border-primary data-selected:hover:bg-primary");
|
|
15
|
+
/** A day, "yyyy-MM-dd", or "" for an empty text, one that cannot be read ("2026-13-01") or a day that does not exist ("2026-02-31"). */
|
|
16
|
+
var dayOrEmpty = (text) => readPickerValue(text, "date")?.day ?? "";
|
|
17
|
+
var subscribeToNothing = () => () => {};
|
|
18
|
+
var readToday = () => currentParts().day;
|
|
19
|
+
var noTodayOnServer = () => null;
|
|
20
|
+
/**
|
|
21
|
+
* A month of days on show, to pick one day or a range: the date picker's calendar, inline. The arrow buttons and
|
|
22
|
+
* Page Up and Page Down change the month, the month's name opens a list of months and years, and the arrow keys
|
|
23
|
+
* move between days (the other way in right to left). A range is two clicks, the start and then the end; a click
|
|
24
|
+
* before the start begins again. The weeks start on the locale's first day of the week.
|
|
25
|
+
*/
|
|
26
|
+
var Calendar = (props) => {
|
|
27
|
+
const $ = c(20);
|
|
28
|
+
const { min, max, labels: t0, locale: t1, defaultMonth, "aria-label": ariaLabel, className } = props;
|
|
29
|
+
const labels = t0 === void 0 ? ENGLISH_PICKER_LABELS : t0;
|
|
30
|
+
const locale = t1 === void 0 ? enUS : t1;
|
|
31
|
+
const direction = useDirection();
|
|
32
|
+
const bounds = readBounds(min, max, "date");
|
|
33
|
+
const range = props.mode === "range" ? {
|
|
34
|
+
start: dayOrEmpty(props.value.start),
|
|
35
|
+
end: dayOrEmpty(props.value.end)
|
|
36
|
+
} : null;
|
|
37
|
+
const single = props.mode === "range" ? "" : dayOrEmpty(props.value);
|
|
38
|
+
const today = useSyncExternalStore(subscribeToNothing, readToday, noTodayOnServer);
|
|
39
|
+
const startDay = (range ? range.start : single) || (defaultMonth ? dayOrEmpty(`${defaultMonth.slice(0, 7)}-01`) : "") || (today ?? "");
|
|
40
|
+
const anchor = startDay === "" ? null : nearestAllowedDay(startDay, bounds);
|
|
41
|
+
const [movedMonth, setViewMonth] = useState(() => anchor === null ? null : monthOf(anchor));
|
|
42
|
+
const [movedDay, setFocusDay] = useState(anchor);
|
|
43
|
+
const viewMonth = movedMonth ?? (anchor === null ? null : monthOf(anchor));
|
|
44
|
+
const focusDay = movedDay ?? anchor;
|
|
45
|
+
const [view, setView] = useState("days");
|
|
46
|
+
const grid = useRef(null);
|
|
47
|
+
const monthList = useRef(null);
|
|
48
|
+
const focusNext = useRef(null);
|
|
49
|
+
let t2;
|
|
50
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
51
|
+
t2 = () => {
|
|
52
|
+
const target = focusNext.current;
|
|
53
|
+
if (target === null) return;
|
|
54
|
+
focusNext.current = null;
|
|
55
|
+
(target === "day" ? grid.current : monthList.current)?.querySelector("[data-focus-target]")?.focus();
|
|
56
|
+
};
|
|
57
|
+
$[0] = t2;
|
|
58
|
+
} else t2 = $[0];
|
|
59
|
+
useEffect(t2);
|
|
60
|
+
if (viewMonth === null || focusDay === null) {
|
|
61
|
+
let t3;
|
|
62
|
+
if ($[1] !== ariaLabel) {
|
|
63
|
+
t3 = ariaLabel ? { "aria-label": ariaLabel } : {};
|
|
64
|
+
$[1] = ariaLabel;
|
|
65
|
+
$[2] = t3;
|
|
66
|
+
} else t3 = $[2];
|
|
67
|
+
let t4;
|
|
68
|
+
if ($[3] !== className) {
|
|
69
|
+
t4 = cn("w-64 text-body-sm text-fg", className);
|
|
70
|
+
$[3] = className;
|
|
71
|
+
$[4] = t4;
|
|
72
|
+
} else t4 = $[4];
|
|
73
|
+
let t5;
|
|
74
|
+
if ($[5] !== t3 || $[6] !== t4) {
|
|
75
|
+
t5 = /* @__PURE__ */ jsx("div", {
|
|
76
|
+
role: "group",
|
|
77
|
+
...t3,
|
|
78
|
+
className: t4
|
|
79
|
+
});
|
|
80
|
+
$[5] = t3;
|
|
81
|
+
$[6] = t4;
|
|
82
|
+
$[7] = t5;
|
|
83
|
+
} else t5 = $[7];
|
|
84
|
+
return t5;
|
|
85
|
+
}
|
|
86
|
+
const pick = (day) => {
|
|
87
|
+
setFocusDay(day);
|
|
88
|
+
if (!isDayAllowed(day, bounds)) return;
|
|
89
|
+
if (props.mode === "range") {
|
|
90
|
+
const { start, end } = range ?? {
|
|
91
|
+
start: "",
|
|
92
|
+
end: ""
|
|
93
|
+
};
|
|
94
|
+
if (start === "" || end !== "" || day < start) props.onValueChange({
|
|
95
|
+
start: day,
|
|
96
|
+
end: ""
|
|
97
|
+
});
|
|
98
|
+
else props.onValueChange({
|
|
99
|
+
start,
|
|
100
|
+
end: day
|
|
101
|
+
});
|
|
102
|
+
} else props.onValueChange(day);
|
|
103
|
+
};
|
|
104
|
+
let t3;
|
|
105
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
106
|
+
t3 = (day_0) => {
|
|
107
|
+
focusNext.current = "day";
|
|
108
|
+
setFocusDay(day_0);
|
|
109
|
+
setViewMonth(monthOf(day_0));
|
|
110
|
+
};
|
|
111
|
+
$[8] = t3;
|
|
112
|
+
} else t3 = $[8];
|
|
113
|
+
const moveFocus = t3;
|
|
114
|
+
let t4;
|
|
115
|
+
if ($[9] !== direction || $[10] !== locale) {
|
|
116
|
+
t4 = (event) => {
|
|
117
|
+
const day_1 = event.target.closest("[data-day]")?.dataset.day;
|
|
118
|
+
if (day_1 === void 0) return;
|
|
119
|
+
const forward = direction === "rtl" ? -1 : 1;
|
|
120
|
+
const jump = event.shiftKey ? 12 : 1;
|
|
121
|
+
const moves = {
|
|
122
|
+
ArrowRight: shiftDay(day_1, forward),
|
|
123
|
+
ArrowLeft: shiftDay(day_1, -forward),
|
|
124
|
+
ArrowDown: shiftDay(day_1, 7),
|
|
125
|
+
ArrowUp: shiftDay(day_1, -7),
|
|
126
|
+
Home: weekEdge(day_1, "start", locale),
|
|
127
|
+
End: weekEdge(day_1, "end", locale),
|
|
128
|
+
PageDown: shiftDayByMonths(day_1, jump),
|
|
129
|
+
PageUp: shiftDayByMonths(day_1, -jump)
|
|
130
|
+
};
|
|
131
|
+
const next = Object.hasOwn(moves, event.key) ? moves[event.key] : void 0;
|
|
132
|
+
if (next === void 0) return;
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
moveFocus(next);
|
|
135
|
+
};
|
|
136
|
+
$[9] = direction;
|
|
137
|
+
$[10] = locale;
|
|
138
|
+
$[11] = t4;
|
|
139
|
+
} else t4 = $[11];
|
|
140
|
+
const onGridKeyDown = t4;
|
|
141
|
+
const focusTarget = monthOf(focusDay) === viewMonth ? focusDay : `${viewMonth}-01`;
|
|
142
|
+
const isChosen = (day_2) => range ? day_2 === range.start || range.end !== "" && day_2 === range.end : day_2 === single;
|
|
143
|
+
const isBetween = (day_3) => range !== null && range.start !== "" && range.end !== "" && day_3 > range.start && day_3 < range.end;
|
|
144
|
+
let t5;
|
|
145
|
+
if ($[12] !== ariaLabel) {
|
|
146
|
+
t5 = ariaLabel ? { "aria-label": ariaLabel } : {};
|
|
147
|
+
$[12] = ariaLabel;
|
|
148
|
+
$[13] = t5;
|
|
149
|
+
} else t5 = $[13];
|
|
150
|
+
let t6;
|
|
151
|
+
if ($[14] !== className) {
|
|
152
|
+
t6 = cn("w-64 text-body-sm text-fg", className);
|
|
153
|
+
$[14] = className;
|
|
154
|
+
$[15] = t6;
|
|
155
|
+
} else t6 = $[15];
|
|
156
|
+
let t7;
|
|
157
|
+
if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
|
|
158
|
+
t7 = /* @__PURE__ */ jsx(ChevronLeft, { className: "rtl:rotate-180" });
|
|
159
|
+
$[16] = t7;
|
|
160
|
+
} else t7 = $[16];
|
|
161
|
+
let t8;
|
|
162
|
+
if ($[17] !== view) {
|
|
163
|
+
t8 = () => {
|
|
164
|
+
focusNext.current = view === "days" ? "month" : "day";
|
|
165
|
+
setView(view === "days" ? "months" : "days");
|
|
166
|
+
};
|
|
167
|
+
$[17] = view;
|
|
168
|
+
$[18] = t8;
|
|
169
|
+
} else t8 = $[18];
|
|
170
|
+
let t9;
|
|
171
|
+
if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
|
|
172
|
+
t9 = /* @__PURE__ */ jsx(ChevronRight, { className: "rtl:rotate-180" });
|
|
173
|
+
$[19] = t9;
|
|
174
|
+
} else t9 = $[19];
|
|
175
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
176
|
+
role: "group",
|
|
177
|
+
...t5,
|
|
178
|
+
className: t6,
|
|
179
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
180
|
+
className: "flex h-10 items-center justify-between px-2",
|
|
181
|
+
children: [
|
|
182
|
+
/* @__PURE__ */ jsx(Button, {
|
|
183
|
+
variant: "subtle",
|
|
184
|
+
size: "small",
|
|
185
|
+
className: "text-fg",
|
|
186
|
+
"aria-label": view === "days" ? labels.previousMonth : labels.previousYear,
|
|
187
|
+
icon: t7,
|
|
188
|
+
onClick: () => {
|
|
189
|
+
setViewMonth(shiftMonth(viewMonth, view === "days" ? -1 : -12));
|
|
190
|
+
}
|
|
191
|
+
}),
|
|
192
|
+
/* @__PURE__ */ jsx("button", {
|
|
193
|
+
type: "button",
|
|
194
|
+
"aria-label": view === "days" ? `${monthTitle(viewMonth, locale)}. ${labels.chooseMonth}` : `${yearOf(viewMonth)}. ${labels.backToCalendar}`,
|
|
195
|
+
className: "cursor-pointer rounded-sm px-2 py-1 text-body-lg font-semibold text-fg outline-none hover:bg-subtle focus-visible:ring-2 focus-visible:ring-focus",
|
|
196
|
+
onClick: t8,
|
|
197
|
+
children: view === "days" ? monthTitle(viewMonth, locale) : yearOf(viewMonth)
|
|
198
|
+
}),
|
|
199
|
+
/* @__PURE__ */ jsx(Button, {
|
|
200
|
+
variant: "subtle",
|
|
201
|
+
size: "small",
|
|
202
|
+
className: "text-fg",
|
|
203
|
+
"aria-label": view === "days" ? labels.nextMonth : labels.nextYear,
|
|
204
|
+
icon: t9,
|
|
205
|
+
onClick: () => {
|
|
206
|
+
setViewMonth(shiftMonth(viewMonth, view === "days" ? 1 : 12));
|
|
207
|
+
}
|
|
208
|
+
})
|
|
209
|
+
]
|
|
210
|
+
}), view === "days" ? /* @__PURE__ */ jsxs("table", {
|
|
211
|
+
ref: grid,
|
|
212
|
+
role: "grid",
|
|
213
|
+
"aria-label": monthTitle(viewMonth, locale),
|
|
214
|
+
className: "mx-1 mb-2 w-[calc(100%-0.5rem)] border-collapse",
|
|
215
|
+
onKeyDown: onGridKeyDown,
|
|
216
|
+
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: weekdayNames(locale).map(_temp) }) }), /* @__PURE__ */ jsx("tbody", { children: monthWeeks(viewMonth, locale).map((week) => /* @__PURE__ */ jsx("tr", { children: week.map((cell) => {
|
|
217
|
+
if (!cell.inMonth) return /* @__PURE__ */ jsx("td", {
|
|
218
|
+
"aria-hidden": "true",
|
|
219
|
+
className: "p-0"
|
|
220
|
+
}, cell.day);
|
|
221
|
+
const chosen = isChosen(cell.day);
|
|
222
|
+
const between = isBetween(cell.day);
|
|
223
|
+
const isTarget = cell.day === focusTarget;
|
|
224
|
+
return /* @__PURE__ */ jsx("td", {
|
|
225
|
+
"aria-selected": chosen || between,
|
|
226
|
+
className: "p-0 text-center",
|
|
227
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
228
|
+
type: "button",
|
|
229
|
+
"aria-label": dayLabel(cell.day, locale),
|
|
230
|
+
"aria-disabled": !isDayAllowed(cell.day, bounds),
|
|
231
|
+
tabIndex: isTarget ? 0 : -1,
|
|
232
|
+
"data-day": cell.day,
|
|
233
|
+
className: DAY_BUTTON,
|
|
234
|
+
...chosen ? { "data-selected": "" } : {},
|
|
235
|
+
...between ? { "data-in-range": "" } : {},
|
|
236
|
+
...cell.day === today ? {
|
|
237
|
+
"data-today": "",
|
|
238
|
+
"aria-current": "date"
|
|
239
|
+
} : {},
|
|
240
|
+
...isTarget ? { "data-focus-target": "" } : {},
|
|
241
|
+
onClick: () => {
|
|
242
|
+
pick(cell.day);
|
|
243
|
+
},
|
|
244
|
+
children: cell.date
|
|
245
|
+
})
|
|
246
|
+
}, cell.day);
|
|
247
|
+
}) }, week[0]?.day)) })]
|
|
248
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
249
|
+
ref: monthList,
|
|
250
|
+
className: "grid grid-cols-3 gap-1 px-3 pt-1 pb-3",
|
|
251
|
+
children: monthNames(locale).map((name_0, index) => {
|
|
252
|
+
const month = shiftMonth(`${yearOf(viewMonth)}-01`, index);
|
|
253
|
+
return /* @__PURE__ */ jsx("button", {
|
|
254
|
+
type: "button",
|
|
255
|
+
"aria-label": name_0.long,
|
|
256
|
+
className: cn(DAY_BUTTON, "h-9"),
|
|
257
|
+
...monthOf(focusDay) === month ? { "data-selected": "" } : {},
|
|
258
|
+
...today !== null && monthOf(today) === month ? {
|
|
259
|
+
"data-today": "",
|
|
260
|
+
"aria-current": "date"
|
|
261
|
+
} : {},
|
|
262
|
+
...month === viewMonth ? { "data-focus-target": "" } : {},
|
|
263
|
+
onClick: () => {
|
|
264
|
+
focusNext.current = "day";
|
|
265
|
+
setViewMonth(month);
|
|
266
|
+
setFocusDay(`${month}-01`);
|
|
267
|
+
setView("days");
|
|
268
|
+
},
|
|
269
|
+
children: name_0.short
|
|
270
|
+
}, month);
|
|
271
|
+
})
|
|
272
|
+
})]
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
function _temp(name) {
|
|
276
|
+
return /* @__PURE__ */ jsx("th", {
|
|
277
|
+
scope: "col",
|
|
278
|
+
abbr: name.long,
|
|
279
|
+
className: "h-8 text-center text-body-sm font-normal text-fg",
|
|
280
|
+
children: name.narrow
|
|
281
|
+
}, name.long);
|
|
282
|
+
}
|
|
283
|
+
export { Calendar };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type ReactNode, type Ref } from "react";
|
|
2
|
+
import type { Locale } from "date-fns";
|
|
3
|
+
import type { FieldSize } from "../FormField/field-types.js";
|
|
4
|
+
import { type CalendarLabels, type DateRangeValue } from "./Calendar.js";
|
|
5
|
+
/** The texts of the field and its calendar, in the user's language. */
|
|
6
|
+
export interface DateRangePickerLabels extends CalendarLabels {
|
|
7
|
+
/** The field's text while it has no range, e.g. "Select dates". */
|
|
8
|
+
select: string;
|
|
9
|
+
/** The panel's name, e.g. "Choose dates". */
|
|
10
|
+
chooseRange: string;
|
|
11
|
+
}
|
|
12
|
+
/** The texts used when a picker is given none. */
|
|
13
|
+
export declare const ENGLISH_RANGE_LABELS: DateRangePickerLabels;
|
|
14
|
+
export interface DateRangePickerProps {
|
|
15
|
+
/** The range: "yyyy-MM-dd" each, `end` empty while only the start is picked. */
|
|
16
|
+
value: DateRangeValue;
|
|
17
|
+
/** Called with the range as the person picks. The panel closes once both ends are picked. */
|
|
18
|
+
onValueChange: (value: DateRangeValue) => void;
|
|
19
|
+
/** The earliest and latest day that can be picked, "yyyy-MM-dd". */
|
|
20
|
+
min?: string | undefined;
|
|
21
|
+
max?: string | undefined;
|
|
22
|
+
/** Shown while there is no range. `labels.select` if omitted. */
|
|
23
|
+
placeholder?: string | undefined;
|
|
24
|
+
/** The texts of the field and its calendar. English if omitted. */
|
|
25
|
+
labels?: DateRangePickerLabels | undefined;
|
|
26
|
+
/** date-fns' locale for the names of months and days and the first day of the week. English, with weeks from Sunday, if omitted. */
|
|
27
|
+
locale?: Locale | undefined;
|
|
28
|
+
disabled?: boolean | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Draws the red border. A button cannot carry aria-invalid, so the field is announced as invalid through its
|
|
31
|
+
* message, which `aria-describedby` ties to it.
|
|
32
|
+
*/
|
|
33
|
+
invalid?: boolean | undefined;
|
|
34
|
+
size?: FieldSize | undefined;
|
|
35
|
+
/** Replaces the calendar glyph at the end of the field. */
|
|
36
|
+
icon?: ReactNode | undefined;
|
|
37
|
+
id?: string | undefined;
|
|
38
|
+
/** What names the field when there is no visible label. */
|
|
39
|
+
"aria-label"?: string | undefined;
|
|
40
|
+
/** The id of the element that is the field's label; the chosen range is added to the name. */
|
|
41
|
+
"aria-labelledby"?: string | undefined;
|
|
42
|
+
/** The ids of the field's message and hint, read after the name. */
|
|
43
|
+
"aria-describedby"?: string | undefined;
|
|
44
|
+
triggerRef?: Ref<HTMLButtonElement> | undefined;
|
|
45
|
+
/** The picker was left: the panel closed, or focus moved off it while closed. */
|
|
46
|
+
onBlur?: (() => void) | undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A field that picks a start and an end day: a button showing the range that opens a calendar, where the first
|
|
50
|
+
* click is the start and the second the end, and the panel closes. The value is two day texts. For one day, see
|
|
51
|
+
* DateTimePicker; for a calendar that is always on show, see Calendar.
|
|
52
|
+
*/
|
|
53
|
+
export declare const DateRangePicker: ({ value, onValueChange, min, max, placeholder, labels, locale, disabled, invalid, size, icon, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, triggerRef, onBlur, }: DateRangePickerProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useId, useRef, useState } from "react";
|
|
4
|
+
import { Popover } from "@base-ui/react/popover";
|
|
5
|
+
import { CalendarDays } from "lucide-react";
|
|
6
|
+
import { enUS } from "date-fns/locale/en-US";
|
|
7
|
+
import { cn } from "../../utils/cn.js";
|
|
8
|
+
import { popup, positioner } from "../../utils/popup.js";
|
|
9
|
+
import { ENGLISH_PICKER_LABELS } from "../DateTimePicker/picker-labels.js";
|
|
10
|
+
import { formatPickerValue } from "../DateTimePicker/picker-values.js";
|
|
11
|
+
import { fieldControl } from "../FormField/field-styles.js";
|
|
12
|
+
import { Calendar as Calendar$1 } from "./Calendar.js";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
// src/patterns/Calendar/DateRangePicker.tsx
|
|
15
|
+
/** The texts used when a picker is given none. */
|
|
16
|
+
var ENGLISH_RANGE_LABELS = {
|
|
17
|
+
...ENGLISH_PICKER_LABELS,
|
|
18
|
+
select: "Select dates",
|
|
19
|
+
chooseRange: "Choose dates"
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A field that picks a start and an end day: a button showing the range that opens a calendar, where the first
|
|
23
|
+
* click is the start and the second the end, and the panel closes. The value is two day texts. For one day, see
|
|
24
|
+
* DateTimePicker; for a calendar that is always on show, see Calendar.
|
|
25
|
+
*/
|
|
26
|
+
var DateRangePicker = (t0) => {
|
|
27
|
+
const $ = c(70);
|
|
28
|
+
const { value, onValueChange, min, max, placeholder, labels: t1, locale: t2, disabled: t3, invalid: t4, size: t5, icon, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, triggerRef, onBlur } = t0;
|
|
29
|
+
const labels = t1 === void 0 ? ENGLISH_RANGE_LABELS : t1;
|
|
30
|
+
const locale = t2 === void 0 ? enUS : t2;
|
|
31
|
+
const disabled = t3 === void 0 ? false : t3;
|
|
32
|
+
const invalid = t4 === void 0 ? false : t4;
|
|
33
|
+
const size = t5 === void 0 ? "medium" : t5;
|
|
34
|
+
const [open, setOpen] = useState(false);
|
|
35
|
+
const popupRef = useRef(null);
|
|
36
|
+
const valueId = useId();
|
|
37
|
+
const isOpen = open && !disabled;
|
|
38
|
+
let t6;
|
|
39
|
+
if ($[0] !== locale) {
|
|
40
|
+
t6 = (day) => formatPickerValue(day, "date", {
|
|
41
|
+
withSeconds: false,
|
|
42
|
+
dayMonth: false,
|
|
43
|
+
locale
|
|
44
|
+
});
|
|
45
|
+
$[0] = locale;
|
|
46
|
+
$[1] = t6;
|
|
47
|
+
} else t6 = $[1];
|
|
48
|
+
const write = t6;
|
|
49
|
+
let t7;
|
|
50
|
+
if ($[2] !== value.start || $[3] !== write) {
|
|
51
|
+
t7 = write(value.start);
|
|
52
|
+
$[2] = value.start;
|
|
53
|
+
$[3] = write;
|
|
54
|
+
$[4] = t7;
|
|
55
|
+
} else t7 = $[4];
|
|
56
|
+
const start = t7;
|
|
57
|
+
let t8;
|
|
58
|
+
if ($[5] !== value.end || $[6] !== write) {
|
|
59
|
+
t8 = write(value.end);
|
|
60
|
+
$[5] = value.end;
|
|
61
|
+
$[6] = write;
|
|
62
|
+
$[7] = t8;
|
|
63
|
+
} else t8 = $[7];
|
|
64
|
+
const end = t8;
|
|
65
|
+
const text = start === "" ? "" : `${start} – ${end === "" ? "…" : end}`;
|
|
66
|
+
const shown = text === "" ? placeholder ?? labels.select : text;
|
|
67
|
+
let t9;
|
|
68
|
+
if ($[8] !== ariaLabel || $[9] !== ariaLabelledBy || $[10] !== labels.chooseRange || $[11] !== shown || $[12] !== valueId) {
|
|
69
|
+
t9 = ariaLabelledBy ? { "aria-labelledby": `${ariaLabelledBy} ${valueId}` } : { "aria-label": `${ariaLabel ?? labels.chooseRange}: ${shown}` };
|
|
70
|
+
$[8] = ariaLabel;
|
|
71
|
+
$[9] = ariaLabelledBy;
|
|
72
|
+
$[10] = labels.chooseRange;
|
|
73
|
+
$[11] = shown;
|
|
74
|
+
$[12] = valueId;
|
|
75
|
+
$[13] = t9;
|
|
76
|
+
} else t9 = $[13];
|
|
77
|
+
const nameProps = t9;
|
|
78
|
+
let t10;
|
|
79
|
+
if ($[14] !== onBlur) {
|
|
80
|
+
t10 = (next) => {
|
|
81
|
+
setOpen(next);
|
|
82
|
+
if (!next) onBlur?.();
|
|
83
|
+
};
|
|
84
|
+
$[14] = onBlur;
|
|
85
|
+
$[15] = t10;
|
|
86
|
+
} else t10 = $[15];
|
|
87
|
+
let t11;
|
|
88
|
+
if ($[16] !== id) {
|
|
89
|
+
t11 = id ? { id } : {};
|
|
90
|
+
$[16] = id;
|
|
91
|
+
$[17] = t11;
|
|
92
|
+
} else t11 = $[17];
|
|
93
|
+
let t12;
|
|
94
|
+
if ($[18] !== ariaDescribedBy) {
|
|
95
|
+
t12 = ariaDescribedBy ? { "aria-describedby": ariaDescribedBy } : {};
|
|
96
|
+
$[18] = ariaDescribedBy;
|
|
97
|
+
$[19] = t12;
|
|
98
|
+
} else t12 = $[19];
|
|
99
|
+
let t13;
|
|
100
|
+
if ($[20] !== size) {
|
|
101
|
+
t13 = cn(fieldControl({ size }), "cursor-pointer justify-between data-popup-open:border-primary-active");
|
|
102
|
+
$[20] = size;
|
|
103
|
+
$[21] = t13;
|
|
104
|
+
} else t13 = $[21];
|
|
105
|
+
const t14 = invalid || void 0;
|
|
106
|
+
const t15 = disabled || void 0;
|
|
107
|
+
let t16;
|
|
108
|
+
if ($[22] !== isOpen || $[23] !== onBlur) {
|
|
109
|
+
t16 = () => {
|
|
110
|
+
if (!isOpen) onBlur?.();
|
|
111
|
+
};
|
|
112
|
+
$[22] = isOpen;
|
|
113
|
+
$[23] = onBlur;
|
|
114
|
+
$[24] = t16;
|
|
115
|
+
} else t16 = $[24];
|
|
116
|
+
const t17 = text === "" && "text-fg-tertiary";
|
|
117
|
+
let t18;
|
|
118
|
+
if ($[25] !== t17) {
|
|
119
|
+
t18 = cn("min-w-0 flex-1 truncate text-start", t17);
|
|
120
|
+
$[25] = t17;
|
|
121
|
+
$[26] = t18;
|
|
122
|
+
} else t18 = $[26];
|
|
123
|
+
let t19;
|
|
124
|
+
if ($[27] !== shown || $[28] !== text) {
|
|
125
|
+
t19 = text === "" ? shown : /* @__PURE__ */ jsx("bdi", {
|
|
126
|
+
dir: "ltr",
|
|
127
|
+
children: text
|
|
128
|
+
});
|
|
129
|
+
$[27] = shown;
|
|
130
|
+
$[28] = text;
|
|
131
|
+
$[29] = t19;
|
|
132
|
+
} else t19 = $[29];
|
|
133
|
+
let t20;
|
|
134
|
+
if ($[30] !== t18 || $[31] !== t19 || $[32] !== valueId) {
|
|
135
|
+
t20 = /* @__PURE__ */ jsx("span", {
|
|
136
|
+
id: valueId,
|
|
137
|
+
className: t18,
|
|
138
|
+
children: t19
|
|
139
|
+
});
|
|
140
|
+
$[30] = t18;
|
|
141
|
+
$[31] = t19;
|
|
142
|
+
$[32] = valueId;
|
|
143
|
+
$[33] = t20;
|
|
144
|
+
} else t20 = $[33];
|
|
145
|
+
let t21;
|
|
146
|
+
if ($[34] !== icon) {
|
|
147
|
+
t21 = icon ?? /* @__PURE__ */ jsx(CalendarDays, {});
|
|
148
|
+
$[34] = icon;
|
|
149
|
+
$[35] = t21;
|
|
150
|
+
} else t21 = $[35];
|
|
151
|
+
let t22;
|
|
152
|
+
if ($[36] !== t21) {
|
|
153
|
+
t22 = /* @__PURE__ */ jsx("span", {
|
|
154
|
+
className: "flex shrink-0 text-fg-tertiary [&_svg]:size-4",
|
|
155
|
+
"aria-hidden": "true",
|
|
156
|
+
children: t21
|
|
157
|
+
});
|
|
158
|
+
$[36] = t21;
|
|
159
|
+
$[37] = t22;
|
|
160
|
+
} else t22 = $[37];
|
|
161
|
+
let t23;
|
|
162
|
+
if ($[38] !== disabled || $[39] !== nameProps || $[40] !== t11 || $[41] !== t12 || $[42] !== t13 || $[43] !== t14 || $[44] !== t15 || $[45] !== t16 || $[46] !== t20 || $[47] !== t22 || $[48] !== triggerRef) {
|
|
163
|
+
t23 = /* @__PURE__ */ jsxs(Popover.Trigger, {
|
|
164
|
+
ref: triggerRef,
|
|
165
|
+
...t11,
|
|
166
|
+
disabled,
|
|
167
|
+
...nameProps,
|
|
168
|
+
...t12,
|
|
169
|
+
className: t13,
|
|
170
|
+
"data-invalid": t14,
|
|
171
|
+
"data-disabled": t15,
|
|
172
|
+
onBlur: t16,
|
|
173
|
+
children: [t20, t22]
|
|
174
|
+
});
|
|
175
|
+
$[38] = disabled;
|
|
176
|
+
$[39] = nameProps;
|
|
177
|
+
$[40] = t11;
|
|
178
|
+
$[41] = t12;
|
|
179
|
+
$[42] = t13;
|
|
180
|
+
$[43] = t14;
|
|
181
|
+
$[44] = t15;
|
|
182
|
+
$[45] = t16;
|
|
183
|
+
$[46] = t20;
|
|
184
|
+
$[47] = t22;
|
|
185
|
+
$[48] = triggerRef;
|
|
186
|
+
$[49] = t23;
|
|
187
|
+
} else t23 = $[49];
|
|
188
|
+
const t24 = labels.chooseRange;
|
|
189
|
+
let t25;
|
|
190
|
+
let t26;
|
|
191
|
+
if ($[50] === Symbol.for("react.memo_cache_sentinel")) {
|
|
192
|
+
t25 = () => popupRef.current?.querySelector("[data-focus-target]") ?? true;
|
|
193
|
+
t26 = cn(popup, "overflow-x-hidden p-0");
|
|
194
|
+
$[50] = t25;
|
|
195
|
+
$[51] = t26;
|
|
196
|
+
} else {
|
|
197
|
+
t25 = $[50];
|
|
198
|
+
t26 = $[51];
|
|
199
|
+
}
|
|
200
|
+
let t27;
|
|
201
|
+
if ($[52] !== onBlur || $[53] !== onValueChange) {
|
|
202
|
+
t27 = (next_0) => {
|
|
203
|
+
onValueChange(next_0);
|
|
204
|
+
if (next_0.end !== "") {
|
|
205
|
+
setOpen(false);
|
|
206
|
+
onBlur?.();
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
$[52] = onBlur;
|
|
210
|
+
$[53] = onValueChange;
|
|
211
|
+
$[54] = t27;
|
|
212
|
+
} else t27 = $[54];
|
|
213
|
+
let t28;
|
|
214
|
+
if ($[55] !== labels || $[56] !== locale || $[57] !== max || $[58] !== min || $[59] !== t27 || $[60] !== value) {
|
|
215
|
+
t28 = /* @__PURE__ */ jsx(Calendar$1, {
|
|
216
|
+
mode: "range",
|
|
217
|
+
value,
|
|
218
|
+
labels,
|
|
219
|
+
locale,
|
|
220
|
+
min,
|
|
221
|
+
max,
|
|
222
|
+
onValueChange: t27
|
|
223
|
+
});
|
|
224
|
+
$[55] = labels;
|
|
225
|
+
$[56] = locale;
|
|
226
|
+
$[57] = max;
|
|
227
|
+
$[58] = min;
|
|
228
|
+
$[59] = t27;
|
|
229
|
+
$[60] = value;
|
|
230
|
+
$[61] = t28;
|
|
231
|
+
} else t28 = $[61];
|
|
232
|
+
let t29;
|
|
233
|
+
if ($[62] !== labels.chooseRange || $[63] !== t28) {
|
|
234
|
+
t29 = /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(Popover.Positioner, {
|
|
235
|
+
className: positioner,
|
|
236
|
+
align: "start",
|
|
237
|
+
sideOffset: 4,
|
|
238
|
+
collisionPadding: 8,
|
|
239
|
+
children: /* @__PURE__ */ jsx(Popover.Popup, {
|
|
240
|
+
ref: popupRef,
|
|
241
|
+
"aria-label": t24,
|
|
242
|
+
initialFocus: t25,
|
|
243
|
+
className: t26,
|
|
244
|
+
children: t28
|
|
245
|
+
})
|
|
246
|
+
}) });
|
|
247
|
+
$[62] = labels.chooseRange;
|
|
248
|
+
$[63] = t28;
|
|
249
|
+
$[64] = t29;
|
|
250
|
+
} else t29 = $[64];
|
|
251
|
+
let t30;
|
|
252
|
+
if ($[65] !== isOpen || $[66] !== t10 || $[67] !== t23 || $[68] !== t29) {
|
|
253
|
+
t30 = /* @__PURE__ */ jsxs(Popover.Root, {
|
|
254
|
+
open: isOpen,
|
|
255
|
+
onOpenChange: t10,
|
|
256
|
+
children: [t23, t29]
|
|
257
|
+
});
|
|
258
|
+
$[65] = isOpen;
|
|
259
|
+
$[66] = t10;
|
|
260
|
+
$[67] = t23;
|
|
261
|
+
$[68] = t29;
|
|
262
|
+
$[69] = t30;
|
|
263
|
+
} else t30 = $[69];
|
|
264
|
+
return t30;
|
|
265
|
+
};
|
|
266
|
+
export { DateRangePicker, ENGLISH_RANGE_LABELS };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Control, type ControllerProps, type FieldPath, type FieldValues } from "react-hook-form";
|
|
2
|
+
import type { FieldOrientation } from "../FormField/field-types.js";
|
|
3
|
+
import { type DateRangePickerProps } from "./DateRangePicker.js";
|
|
4
|
+
export type { DateRangePickerLabels } from "./DateRangePicker.js";
|
|
5
|
+
export interface FormDateRangeFieldProps<TValues extends FieldValues> extends Omit<DateRangePickerProps, "value" | "onValueChange" | "onBlur" | "invalid" | "triggerRef" | "id" | "aria-label" | "aria-labelledby" | "aria-describedby"> {
|
|
6
|
+
control: Control<TValues>;
|
|
7
|
+
name: FieldPath<TValues>;
|
|
8
|
+
label: string;
|
|
9
|
+
hint?: string | undefined;
|
|
10
|
+
required?: boolean | undefined;
|
|
11
|
+
/** Label above the control (default) or in a column beside it. */
|
|
12
|
+
orientation?: FieldOrientation | undefined;
|
|
13
|
+
/** Keep the label for assistive technology only. */
|
|
14
|
+
hideLabel?: boolean | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* react-hook-form validation rules, for forms that do not use a schema resolver. The value is an object that is
|
|
17
|
+
* never empty, so `required` does not apply: use `validate`, e.g. `(range) => range.end !== "" || "Pick both days"`.
|
|
18
|
+
*/
|
|
19
|
+
rules?: ControllerProps<TValues, FieldPath<TValues>>["rules"] | undefined;
|
|
20
|
+
/** Turns a stored schema message (an i18n key) into display text. */
|
|
21
|
+
formatError?: ((message: string) => string) | undefined;
|
|
22
|
+
}
|
|
23
|
+
/** A DateRangePicker in a field, bound to a react-hook-form field holding `{ start, end }`, "yyyy-MM-dd" each. */
|
|
24
|
+
export declare const FormDateRangeField: <TValues extends FieldValues>({ control, name, label, hint, required, orientation, hideLabel, rules, formatError, disabled, size, ...pickerProps }: FormDateRangeFieldProps<TValues>) => import("react").JSX.Element;
|