@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,271 @@
|
|
|
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, Clock } 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 { fieldControl } from "../FormField/field-styles.js";
|
|
10
|
+
import { DateTimePanel } from "./DateTimePanel.js";
|
|
11
|
+
import { ENGLISH_PICKER_LABELS } from "./picker-labels.js";
|
|
12
|
+
import { formatPickerValue, readBounds } from "./picker-values.js";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
// src/patterns/DateTimePicker/DateTimePicker.tsx
|
|
15
|
+
/**
|
|
16
|
+
* A date and time picker: a read-only field with a calendar glyph that
|
|
17
|
+
* opens a panel with the month, the days, the time sliders and Today or Now, Clear and Done.
|
|
18
|
+
* It is a button, so the value is picked and never typed, and it holds its value as the plain
|
|
19
|
+
* text a native `<input type="date">` holds (see `value`), so a form's schema and the code
|
|
20
|
+
* that turns the text into a request need nothing picker-specific. For a field with a label
|
|
21
|
+
* bound to react-hook-form use FormDateTimeField.
|
|
22
|
+
*/
|
|
23
|
+
var DateTimePicker = (t0) => {
|
|
24
|
+
const $ = c(77);
|
|
25
|
+
const { value, onValueChange: onChange, mode: t1, showSeconds: t2, min, max, defaultTime, clearable: t3, showNow: t4, display: t5, placeholder, labels: t6, locale: t7, disabled: t8, invalid: t9, size: t10, icon, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, triggerRef, onBlur } = t0;
|
|
26
|
+
const mode = t1 === void 0 ? "date" : t1;
|
|
27
|
+
const showSeconds = t2 === void 0 ? false : t2;
|
|
28
|
+
const clearable = t3 === void 0 ? false : t3;
|
|
29
|
+
const showNow = t4 === void 0 ? true : t4;
|
|
30
|
+
const display = t5 === void 0 ? "full" : t5;
|
|
31
|
+
const labels = t6 === void 0 ? ENGLISH_PICKER_LABELS : t6;
|
|
32
|
+
const locale = t7 === void 0 ? enUS : t7;
|
|
33
|
+
const disabled = t8 === void 0 ? false : t8;
|
|
34
|
+
const invalid = t9 === void 0 ? false : t9;
|
|
35
|
+
const size = t10 === void 0 ? "medium" : t10;
|
|
36
|
+
const [open, setOpen] = useState(false);
|
|
37
|
+
const popupRef = useRef(null);
|
|
38
|
+
const valueId = useId();
|
|
39
|
+
const isOpen = open && !disabled;
|
|
40
|
+
const withSeconds = showSeconds && mode !== "date";
|
|
41
|
+
const t11 = display === "dayMonth";
|
|
42
|
+
let t12;
|
|
43
|
+
if ($[0] !== locale || $[1] !== mode || $[2] !== t11 || $[3] !== value || $[4] !== withSeconds) {
|
|
44
|
+
t12 = formatPickerValue(value, mode, {
|
|
45
|
+
withSeconds,
|
|
46
|
+
dayMonth: t11,
|
|
47
|
+
locale
|
|
48
|
+
});
|
|
49
|
+
$[0] = locale;
|
|
50
|
+
$[1] = mode;
|
|
51
|
+
$[2] = t11;
|
|
52
|
+
$[3] = value;
|
|
53
|
+
$[4] = withSeconds;
|
|
54
|
+
$[5] = t12;
|
|
55
|
+
} else t12 = $[5];
|
|
56
|
+
const text = t12;
|
|
57
|
+
const shown = text === "" ? placeholder ?? labels.select : text;
|
|
58
|
+
const panelLabel = mode === "date" ? labels.chooseDate : mode === "time" ? labels.chooseTime : labels.chooseDateTime;
|
|
59
|
+
let t13;
|
|
60
|
+
if ($[6] !== ariaLabel || $[7] !== ariaLabelledBy || $[8] !== panelLabel || $[9] !== shown || $[10] !== valueId) {
|
|
61
|
+
t13 = ariaLabelledBy ? { "aria-labelledby": `${ariaLabelledBy} ${valueId}` } : { "aria-label": `${ariaLabel ?? panelLabel}: ${shown}` };
|
|
62
|
+
$[6] = ariaLabel;
|
|
63
|
+
$[7] = ariaLabelledBy;
|
|
64
|
+
$[8] = panelLabel;
|
|
65
|
+
$[9] = shown;
|
|
66
|
+
$[10] = valueId;
|
|
67
|
+
$[11] = t13;
|
|
68
|
+
} else t13 = $[11];
|
|
69
|
+
const nameProps = t13;
|
|
70
|
+
let t14;
|
|
71
|
+
if ($[12] !== onBlur) {
|
|
72
|
+
t14 = (next) => {
|
|
73
|
+
setOpen(next);
|
|
74
|
+
if (!next) onBlur?.();
|
|
75
|
+
};
|
|
76
|
+
$[12] = onBlur;
|
|
77
|
+
$[13] = t14;
|
|
78
|
+
} else t14 = $[13];
|
|
79
|
+
let t15;
|
|
80
|
+
if ($[14] !== id) {
|
|
81
|
+
t15 = id ? { id } : {};
|
|
82
|
+
$[14] = id;
|
|
83
|
+
$[15] = t15;
|
|
84
|
+
} else t15 = $[15];
|
|
85
|
+
let t16;
|
|
86
|
+
if ($[16] !== ariaDescribedBy) {
|
|
87
|
+
t16 = ariaDescribedBy ? { "aria-describedby": ariaDescribedBy } : {};
|
|
88
|
+
$[16] = ariaDescribedBy;
|
|
89
|
+
$[17] = t16;
|
|
90
|
+
} else t16 = $[17];
|
|
91
|
+
let t17;
|
|
92
|
+
if ($[18] !== size) {
|
|
93
|
+
t17 = cn(fieldControl({ size }), "cursor-pointer justify-between data-popup-open:border-primary-active");
|
|
94
|
+
$[18] = size;
|
|
95
|
+
$[19] = t17;
|
|
96
|
+
} else t17 = $[19];
|
|
97
|
+
const t18 = invalid || void 0;
|
|
98
|
+
const t19 = disabled || void 0;
|
|
99
|
+
let t20;
|
|
100
|
+
if ($[20] !== isOpen || $[21] !== onBlur) {
|
|
101
|
+
t20 = () => {
|
|
102
|
+
if (!isOpen) onBlur?.();
|
|
103
|
+
};
|
|
104
|
+
$[20] = isOpen;
|
|
105
|
+
$[21] = onBlur;
|
|
106
|
+
$[22] = t20;
|
|
107
|
+
} else t20 = $[22];
|
|
108
|
+
const t21 = text === "" && "text-fg-tertiary";
|
|
109
|
+
let t22;
|
|
110
|
+
if ($[23] !== t21) {
|
|
111
|
+
t22 = cn("min-w-0 flex-1 truncate text-start", t21);
|
|
112
|
+
$[23] = t21;
|
|
113
|
+
$[24] = t22;
|
|
114
|
+
} else t22 = $[24];
|
|
115
|
+
let t23;
|
|
116
|
+
if ($[25] !== shown || $[26] !== text) {
|
|
117
|
+
t23 = text === "" ? shown : /* @__PURE__ */ jsx("bdi", {
|
|
118
|
+
dir: "ltr",
|
|
119
|
+
children: text
|
|
120
|
+
});
|
|
121
|
+
$[25] = shown;
|
|
122
|
+
$[26] = text;
|
|
123
|
+
$[27] = t23;
|
|
124
|
+
} else t23 = $[27];
|
|
125
|
+
let t24;
|
|
126
|
+
if ($[28] !== t22 || $[29] !== t23 || $[30] !== valueId) {
|
|
127
|
+
t24 = /* @__PURE__ */ jsx("span", {
|
|
128
|
+
id: valueId,
|
|
129
|
+
className: t22,
|
|
130
|
+
children: t23
|
|
131
|
+
});
|
|
132
|
+
$[28] = t22;
|
|
133
|
+
$[29] = t23;
|
|
134
|
+
$[30] = valueId;
|
|
135
|
+
$[31] = t24;
|
|
136
|
+
} else t24 = $[31];
|
|
137
|
+
let t25;
|
|
138
|
+
if ($[32] !== icon || $[33] !== mode) {
|
|
139
|
+
t25 = icon ?? (mode === "time" ? /* @__PURE__ */ jsx(Clock, {}) : /* @__PURE__ */ jsx(CalendarDays, {}));
|
|
140
|
+
$[32] = icon;
|
|
141
|
+
$[33] = mode;
|
|
142
|
+
$[34] = t25;
|
|
143
|
+
} else t25 = $[34];
|
|
144
|
+
let t26;
|
|
145
|
+
if ($[35] !== t25) {
|
|
146
|
+
t26 = /* @__PURE__ */ jsx("span", {
|
|
147
|
+
className: "flex shrink-0 text-fg-tertiary [&_svg]:size-4",
|
|
148
|
+
"aria-hidden": "true",
|
|
149
|
+
children: t25
|
|
150
|
+
});
|
|
151
|
+
$[35] = t25;
|
|
152
|
+
$[36] = t26;
|
|
153
|
+
} else t26 = $[36];
|
|
154
|
+
let t27;
|
|
155
|
+
if ($[37] !== disabled || $[38] !== nameProps || $[39] !== t15 || $[40] !== t16 || $[41] !== t17 || $[42] !== t18 || $[43] !== t19 || $[44] !== t20 || $[45] !== t24 || $[46] !== t26 || $[47] !== triggerRef) {
|
|
156
|
+
t27 = /* @__PURE__ */ jsxs(Popover.Trigger, {
|
|
157
|
+
ref: triggerRef,
|
|
158
|
+
...t15,
|
|
159
|
+
disabled,
|
|
160
|
+
...nameProps,
|
|
161
|
+
...t16,
|
|
162
|
+
className: t17,
|
|
163
|
+
"data-invalid": t18,
|
|
164
|
+
"data-disabled": t19,
|
|
165
|
+
onBlur: t20,
|
|
166
|
+
children: [t24, t26]
|
|
167
|
+
});
|
|
168
|
+
$[37] = disabled;
|
|
169
|
+
$[38] = nameProps;
|
|
170
|
+
$[39] = t15;
|
|
171
|
+
$[40] = t16;
|
|
172
|
+
$[41] = t17;
|
|
173
|
+
$[42] = t18;
|
|
174
|
+
$[43] = t19;
|
|
175
|
+
$[44] = t20;
|
|
176
|
+
$[45] = t24;
|
|
177
|
+
$[46] = t26;
|
|
178
|
+
$[47] = triggerRef;
|
|
179
|
+
$[48] = t27;
|
|
180
|
+
} else t27 = $[48];
|
|
181
|
+
let t28;
|
|
182
|
+
let t29;
|
|
183
|
+
if ($[49] === Symbol.for("react.memo_cache_sentinel")) {
|
|
184
|
+
t28 = () => popupRef.current?.querySelector("[data-initial-focus]") ?? true;
|
|
185
|
+
t29 = cn(popup, "overflow-x-hidden p-0");
|
|
186
|
+
$[49] = t28;
|
|
187
|
+
$[50] = t29;
|
|
188
|
+
} else {
|
|
189
|
+
t28 = $[49];
|
|
190
|
+
t29 = $[50];
|
|
191
|
+
}
|
|
192
|
+
let t30;
|
|
193
|
+
if ($[51] !== max || $[52] !== min || $[53] !== mode) {
|
|
194
|
+
t30 = readBounds(min, max, mode);
|
|
195
|
+
$[51] = max;
|
|
196
|
+
$[52] = min;
|
|
197
|
+
$[53] = mode;
|
|
198
|
+
$[54] = t30;
|
|
199
|
+
} else t30 = $[54];
|
|
200
|
+
let t31;
|
|
201
|
+
if ($[55] !== onBlur) {
|
|
202
|
+
t31 = () => {
|
|
203
|
+
setOpen(false);
|
|
204
|
+
onBlur?.();
|
|
205
|
+
};
|
|
206
|
+
$[55] = onBlur;
|
|
207
|
+
$[56] = t31;
|
|
208
|
+
} else t31 = $[56];
|
|
209
|
+
let t32;
|
|
210
|
+
if ($[57] !== clearable || $[58] !== defaultTime || $[59] !== labels || $[60] !== locale || $[61] !== mode || $[62] !== onChange || $[63] !== showNow || $[64] !== t30 || $[65] !== t31 || $[66] !== value || $[67] !== withSeconds) {
|
|
211
|
+
t32 = /* @__PURE__ */ jsx(DateTimePanel, {
|
|
212
|
+
value,
|
|
213
|
+
kind: mode,
|
|
214
|
+
withSeconds,
|
|
215
|
+
bounds: t30,
|
|
216
|
+
labels,
|
|
217
|
+
locale,
|
|
218
|
+
defaultTime,
|
|
219
|
+
clearable,
|
|
220
|
+
showNow,
|
|
221
|
+
onChange,
|
|
222
|
+
onDone: t31
|
|
223
|
+
});
|
|
224
|
+
$[57] = clearable;
|
|
225
|
+
$[58] = defaultTime;
|
|
226
|
+
$[59] = labels;
|
|
227
|
+
$[60] = locale;
|
|
228
|
+
$[61] = mode;
|
|
229
|
+
$[62] = onChange;
|
|
230
|
+
$[63] = showNow;
|
|
231
|
+
$[64] = t30;
|
|
232
|
+
$[65] = t31;
|
|
233
|
+
$[66] = value;
|
|
234
|
+
$[67] = withSeconds;
|
|
235
|
+
$[68] = t32;
|
|
236
|
+
} else t32 = $[68];
|
|
237
|
+
let t33;
|
|
238
|
+
if ($[69] !== panelLabel || $[70] !== t32) {
|
|
239
|
+
t33 = /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(Popover.Positioner, {
|
|
240
|
+
className: positioner,
|
|
241
|
+
align: "start",
|
|
242
|
+
sideOffset: 4,
|
|
243
|
+
collisionPadding: 8,
|
|
244
|
+
children: /* @__PURE__ */ jsx(Popover.Popup, {
|
|
245
|
+
ref: popupRef,
|
|
246
|
+
"aria-label": panelLabel,
|
|
247
|
+
initialFocus: t28,
|
|
248
|
+
className: t29,
|
|
249
|
+
children: t32
|
|
250
|
+
})
|
|
251
|
+
}) });
|
|
252
|
+
$[69] = panelLabel;
|
|
253
|
+
$[70] = t32;
|
|
254
|
+
$[71] = t33;
|
|
255
|
+
} else t33 = $[71];
|
|
256
|
+
let t34;
|
|
257
|
+
if ($[72] !== isOpen || $[73] !== t14 || $[74] !== t27 || $[75] !== t33) {
|
|
258
|
+
t34 = /* @__PURE__ */ jsxs(Popover.Root, {
|
|
259
|
+
open: isOpen,
|
|
260
|
+
onOpenChange: t14,
|
|
261
|
+
children: [t27, t33]
|
|
262
|
+
});
|
|
263
|
+
$[72] = isOpen;
|
|
264
|
+
$[73] = t14;
|
|
265
|
+
$[74] = t27;
|
|
266
|
+
$[75] = t33;
|
|
267
|
+
$[76] = t34;
|
|
268
|
+
} else t34 = $[76];
|
|
269
|
+
return t34;
|
|
270
|
+
};
|
|
271
|
+
export { DateTimePicker };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Control, type ControllerProps, type FieldPath, type FieldValues } from "react-hook-form";
|
|
2
|
+
import type { FieldOrientation, FieldSize } from "../FormField/field-types.js";
|
|
3
|
+
import { type DateTimePickerProps } from "./DateTimePicker.js";
|
|
4
|
+
export interface FormDateTimeFieldProps<TValues extends FieldValues> extends Pick<DateTimePickerProps, "mode" | "showSeconds" | "min" | "max" | "defaultTime" | "showNow" | "display" | "placeholder" | "labels" | "locale" | "icon" | "id"> {
|
|
5
|
+
control: Control<TValues>;
|
|
6
|
+
name: FieldPath<TValues>;
|
|
7
|
+
label: string;
|
|
8
|
+
hint?: string | undefined;
|
|
9
|
+
required?: boolean | undefined;
|
|
10
|
+
disabled?: boolean | undefined;
|
|
11
|
+
/** "small" is the compact density. */
|
|
12
|
+
size?: FieldSize | undefined;
|
|
13
|
+
/** Label above the control (default) or in a column beside it. */
|
|
14
|
+
orientation?: FieldOrientation | undefined;
|
|
15
|
+
/** Keep the label for assistive technology only, e.g. a time in a table row. */
|
|
16
|
+
hideLabel?: boolean | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Offer Clear. By default a field that is not `required` can be cleared and one that is cannot.
|
|
19
|
+
*/
|
|
20
|
+
clearable?: boolean | undefined;
|
|
21
|
+
/** react-hook-form validation rules, for forms that do not use a schema resolver. */
|
|
22
|
+
rules?: ControllerProps<TValues, FieldPath<TValues>>["rules"] | undefined;
|
|
23
|
+
/** Turns a stored schema message (such as a translation key) into display text. */
|
|
24
|
+
formatError?: ((message: string) => string) | undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A date, a date and time or a time, picked from a panel and bound to react-hook-form: the field
|
|
28
|
+
* value is the text a native input holds ("2026-10-24", "2026-10-24T14:05", "14:05"), so it takes
|
|
29
|
+
* the place of `FormTextField type="date"` (or "time") with the schema and the request code
|
|
30
|
+
* unchanged. See DateTimePicker for what the panel offers.
|
|
31
|
+
*/
|
|
32
|
+
export declare const FormDateTimeField: <TValues extends FieldValues>({ control, name, label, hint, required, disabled, size, orientation, hideLabel, clearable, rules, formatError, ...pickerProps }: FormDateTimeFieldProps<TValues>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { Controller } from "react-hook-form";
|
|
5
|
+
import { toErrorText } from "../FormField/error-message.js";
|
|
6
|
+
import { FieldFrame } from "../FormField/FieldFrame.js";
|
|
7
|
+
import { DateTimePicker } from "./DateTimePicker.js";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
// src/patterns/DateTimePicker/FormDateTimeField.tsx
|
|
10
|
+
/**
|
|
11
|
+
* A date, a date and time or a time, picked from a panel and bound to react-hook-form: the field
|
|
12
|
+
* value is the text a native input holds ("2026-10-24", "2026-10-24T14:05", "14:05"), so it takes
|
|
13
|
+
* the place of `FormTextField type="date"` (or "time") with the schema and the request code
|
|
14
|
+
* unchanged. See DateTimePicker for what the panel offers.
|
|
15
|
+
*/
|
|
16
|
+
var FormDateTimeField = (t0) => {
|
|
17
|
+
const $ = c(35);
|
|
18
|
+
let clearable;
|
|
19
|
+
let control;
|
|
20
|
+
let formatError;
|
|
21
|
+
let hint;
|
|
22
|
+
let label;
|
|
23
|
+
let name;
|
|
24
|
+
let orientation;
|
|
25
|
+
let pickerProps;
|
|
26
|
+
let required;
|
|
27
|
+
let rules;
|
|
28
|
+
let t1;
|
|
29
|
+
let t2;
|
|
30
|
+
let t3;
|
|
31
|
+
if ($[0] !== t0) {
|
|
32
|
+
({control, name, label, hint, required, disabled: t1, size: t2, orientation, hideLabel: t3, clearable, rules, formatError, ...pickerProps} = t0);
|
|
33
|
+
$[0] = t0;
|
|
34
|
+
$[1] = clearable;
|
|
35
|
+
$[2] = control;
|
|
36
|
+
$[3] = formatError;
|
|
37
|
+
$[4] = hint;
|
|
38
|
+
$[5] = label;
|
|
39
|
+
$[6] = name;
|
|
40
|
+
$[7] = orientation;
|
|
41
|
+
$[8] = pickerProps;
|
|
42
|
+
$[9] = required;
|
|
43
|
+
$[10] = rules;
|
|
44
|
+
$[11] = t1;
|
|
45
|
+
$[12] = t2;
|
|
46
|
+
$[13] = t3;
|
|
47
|
+
} else {
|
|
48
|
+
clearable = $[1];
|
|
49
|
+
control = $[2];
|
|
50
|
+
formatError = $[3];
|
|
51
|
+
hint = $[4];
|
|
52
|
+
label = $[5];
|
|
53
|
+
name = $[6];
|
|
54
|
+
orientation = $[7];
|
|
55
|
+
pickerProps = $[8];
|
|
56
|
+
required = $[9];
|
|
57
|
+
rules = $[10];
|
|
58
|
+
t1 = $[11];
|
|
59
|
+
t2 = $[12];
|
|
60
|
+
t3 = $[13];
|
|
61
|
+
}
|
|
62
|
+
const disabled = t1 === void 0 ? false : t1;
|
|
63
|
+
const size = t2 === void 0 ? "medium" : t2;
|
|
64
|
+
const hideLabel = t3 === void 0 ? false : t3;
|
|
65
|
+
const labelId = useId();
|
|
66
|
+
const errorId = useId();
|
|
67
|
+
const hintId = useId();
|
|
68
|
+
let t4;
|
|
69
|
+
if ($[14] !== rules) {
|
|
70
|
+
t4 = rules ? { rules } : {};
|
|
71
|
+
$[14] = rules;
|
|
72
|
+
$[15] = t4;
|
|
73
|
+
} else t4 = $[15];
|
|
74
|
+
let t5;
|
|
75
|
+
if ($[16] !== clearable || $[17] !== disabled || $[18] !== errorId || $[19] !== formatError || $[20] !== hideLabel || $[21] !== hint || $[22] !== hintId || $[23] !== label || $[24] !== labelId || $[25] !== orientation || $[26] !== pickerProps || $[27] !== required || $[28] !== size) {
|
|
76
|
+
t5 = (t6) => {
|
|
77
|
+
const { field, fieldState } = t6;
|
|
78
|
+
const errorMessage = toErrorText(fieldState.error?.message, formatError);
|
|
79
|
+
const describedBy = [errorMessage === void 0 ? null : errorId, hint ? hintId : null].filter(_temp).join(" ");
|
|
80
|
+
return /* @__PURE__ */ jsx(FieldFrame, {
|
|
81
|
+
name: field.name,
|
|
82
|
+
label,
|
|
83
|
+
hideLabel,
|
|
84
|
+
disabled,
|
|
85
|
+
invalid: fieldState.invalid,
|
|
86
|
+
touched: fieldState.isTouched,
|
|
87
|
+
dirty: fieldState.isDirty,
|
|
88
|
+
size,
|
|
89
|
+
triggerLabel: true,
|
|
90
|
+
labelId,
|
|
91
|
+
messageIds: {
|
|
92
|
+
error: errorId,
|
|
93
|
+
hint: hintId
|
|
94
|
+
},
|
|
95
|
+
...hint ? { hint } : {},
|
|
96
|
+
...required ? { required } : {},
|
|
97
|
+
...orientation ? { orientation } : {},
|
|
98
|
+
...errorMessage === void 0 ? {} : { errorMessage },
|
|
99
|
+
children: /* @__PURE__ */ jsx(DateTimePicker, {
|
|
100
|
+
...pickerProps,
|
|
101
|
+
value: typeof field.value === "string" ? field.value : "",
|
|
102
|
+
onValueChange: field.onChange,
|
|
103
|
+
onBlur: field.onBlur,
|
|
104
|
+
triggerRef: field.ref,
|
|
105
|
+
"aria-labelledby": labelId,
|
|
106
|
+
...describedBy ? { "aria-describedby": describedBy } : {},
|
|
107
|
+
invalid: fieldState.invalid,
|
|
108
|
+
disabled,
|
|
109
|
+
size,
|
|
110
|
+
clearable: clearable ?? !required
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
$[16] = clearable;
|
|
115
|
+
$[17] = disabled;
|
|
116
|
+
$[18] = errorId;
|
|
117
|
+
$[19] = formatError;
|
|
118
|
+
$[20] = hideLabel;
|
|
119
|
+
$[21] = hint;
|
|
120
|
+
$[22] = hintId;
|
|
121
|
+
$[23] = label;
|
|
122
|
+
$[24] = labelId;
|
|
123
|
+
$[25] = orientation;
|
|
124
|
+
$[26] = pickerProps;
|
|
125
|
+
$[27] = required;
|
|
126
|
+
$[28] = size;
|
|
127
|
+
$[29] = t5;
|
|
128
|
+
} else t5 = $[29];
|
|
129
|
+
let t6;
|
|
130
|
+
if ($[30] !== control || $[31] !== name || $[32] !== t4 || $[33] !== t5) {
|
|
131
|
+
t6 = /* @__PURE__ */ jsx(Controller, {
|
|
132
|
+
control,
|
|
133
|
+
name,
|
|
134
|
+
...t4,
|
|
135
|
+
render: t5
|
|
136
|
+
});
|
|
137
|
+
$[30] = control;
|
|
138
|
+
$[31] = name;
|
|
139
|
+
$[32] = t4;
|
|
140
|
+
$[33] = t5;
|
|
141
|
+
$[34] = t6;
|
|
142
|
+
} else t6 = $[34];
|
|
143
|
+
return t6;
|
|
144
|
+
};
|
|
145
|
+
function _temp(id) {
|
|
146
|
+
return id !== null;
|
|
147
|
+
}
|
|
148
|
+
export { FormDateTimeField };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DateTimePickerLabels } from "./picker-labels.js";
|
|
2
|
+
interface TimeSlidersProps {
|
|
3
|
+
/** "HH:mm:ss" */
|
|
4
|
+
time: string;
|
|
5
|
+
withSeconds: boolean;
|
|
6
|
+
labels: DateTimePickerLabels;
|
|
7
|
+
/** No time can be set yet: a date and time with no day chosen. */
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
/** Mark the first slider as where focus goes when the panel opens (a panel that is only a time). */
|
|
10
|
+
focusFirst: boolean;
|
|
11
|
+
onChange: (time: string) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const TimeSliders: ({ time, withSeconds, labels, disabled, focusFirst, onChange }: TimeSlidersProps) => import("react").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { clockOf, timeOf } from "./picker-values.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/patterns/DateTimePicker/TimeSliders.tsx
|
|
7
|
+
/**
|
|
8
|
+
* The time controls: a readout of the time and a slider each for the hour, the
|
|
9
|
+
* minute and (when the picker has them) the second. A range input is a native control, so
|
|
10
|
+
* arrow keys step it by one and Home and End jump to its ends. The track is a pill and the thumb has the theme's
|
|
11
|
+
* smallest radius, so a theme's radii reach them.
|
|
12
|
+
*/
|
|
13
|
+
var SLIDER = cn("h-2.5 w-full cursor-pointer appearance-none rounded-pill bg-muted opacity-70 outline-none transition-opacity", "hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-focus disabled:cursor-not-allowed disabled:opacity-40", "[&::-webkit-slider-thumb]:h-5 [&::-webkit-slider-thumb]:w-3.75 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-check [&::-webkit-slider-thumb]:bg-primary", "[&::-moz-range-thumb]:h-5 [&::-moz-range-thumb]:w-3.75 [&::-moz-range-thumb]:rounded-check [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:bg-primary");
|
|
14
|
+
var SliderRow = (t0) => {
|
|
15
|
+
const $ = c(16);
|
|
16
|
+
const { label, max, value, disabled, initialFocus: t1, onChange } = t0;
|
|
17
|
+
const initialFocus = t1 === void 0 ? false : t1;
|
|
18
|
+
let t2;
|
|
19
|
+
if ($[0] !== label) {
|
|
20
|
+
t2 = /* @__PURE__ */ jsx("span", { children: label });
|
|
21
|
+
$[0] = label;
|
|
22
|
+
$[1] = t2;
|
|
23
|
+
} else t2 = $[1];
|
|
24
|
+
let t3;
|
|
25
|
+
if ($[2] !== initialFocus) {
|
|
26
|
+
t3 = initialFocus ? { "data-initial-focus": "" } : {};
|
|
27
|
+
$[2] = initialFocus;
|
|
28
|
+
$[3] = t3;
|
|
29
|
+
} else t3 = $[3];
|
|
30
|
+
let t4;
|
|
31
|
+
if ($[4] !== onChange) {
|
|
32
|
+
t4 = (event) => {
|
|
33
|
+
onChange(event.currentTarget.valueAsNumber);
|
|
34
|
+
};
|
|
35
|
+
$[4] = onChange;
|
|
36
|
+
$[5] = t4;
|
|
37
|
+
} else t4 = $[5];
|
|
38
|
+
let t5;
|
|
39
|
+
if ($[6] !== disabled || $[7] !== label || $[8] !== max || $[9] !== t3 || $[10] !== t4 || $[11] !== value) {
|
|
40
|
+
t5 = /* @__PURE__ */ jsx("input", {
|
|
41
|
+
type: "range",
|
|
42
|
+
min: 0,
|
|
43
|
+
max,
|
|
44
|
+
step: 1,
|
|
45
|
+
value,
|
|
46
|
+
disabled,
|
|
47
|
+
"aria-label": label,
|
|
48
|
+
className: SLIDER,
|
|
49
|
+
...t3,
|
|
50
|
+
onChange: t4
|
|
51
|
+
});
|
|
52
|
+
$[6] = disabled;
|
|
53
|
+
$[7] = label;
|
|
54
|
+
$[8] = max;
|
|
55
|
+
$[9] = t3;
|
|
56
|
+
$[10] = t4;
|
|
57
|
+
$[11] = value;
|
|
58
|
+
$[12] = t5;
|
|
59
|
+
} else t5 = $[12];
|
|
60
|
+
let t6;
|
|
61
|
+
if ($[13] !== t2 || $[14] !== t5) {
|
|
62
|
+
t6 = /* @__PURE__ */ jsxs("label", {
|
|
63
|
+
className: "grid grid-cols-[3.5rem_minmax(0,1fr)] items-center gap-3 py-1.5 text-body-sm text-fg",
|
|
64
|
+
children: [t2, t5]
|
|
65
|
+
});
|
|
66
|
+
$[13] = t2;
|
|
67
|
+
$[14] = t5;
|
|
68
|
+
$[15] = t6;
|
|
69
|
+
} else t6 = $[15];
|
|
70
|
+
return t6;
|
|
71
|
+
};
|
|
72
|
+
var TimeSliders = (t0) => {
|
|
73
|
+
const $ = c(44);
|
|
74
|
+
const { time, withSeconds, labels, disabled, focusFirst, onChange } = t0;
|
|
75
|
+
let t1;
|
|
76
|
+
if ($[0] !== time) {
|
|
77
|
+
t1 = clockOf(time);
|
|
78
|
+
$[0] = time;
|
|
79
|
+
$[1] = t1;
|
|
80
|
+
} else t1 = $[1];
|
|
81
|
+
const { hour, minute, second } = t1;
|
|
82
|
+
let t2;
|
|
83
|
+
if ($[2] !== labels.time) {
|
|
84
|
+
t2 = /* @__PURE__ */ jsx("span", { children: labels.time });
|
|
85
|
+
$[2] = labels.time;
|
|
86
|
+
$[3] = t2;
|
|
87
|
+
} else t2 = $[3];
|
|
88
|
+
let t3;
|
|
89
|
+
if ($[4] !== time || $[5] !== withSeconds) {
|
|
90
|
+
t3 = withSeconds ? time : time.slice(0, 5);
|
|
91
|
+
$[4] = time;
|
|
92
|
+
$[5] = withSeconds;
|
|
93
|
+
$[6] = t3;
|
|
94
|
+
} else t3 = $[6];
|
|
95
|
+
let t4;
|
|
96
|
+
if ($[7] !== t3) {
|
|
97
|
+
t4 = /* @__PURE__ */ jsx("span", {
|
|
98
|
+
dir: "ltr",
|
|
99
|
+
className: "font-medium tabular-nums",
|
|
100
|
+
children: t3
|
|
101
|
+
});
|
|
102
|
+
$[7] = t3;
|
|
103
|
+
$[8] = t4;
|
|
104
|
+
} else t4 = $[8];
|
|
105
|
+
let t5;
|
|
106
|
+
if ($[9] !== t2 || $[10] !== t4) {
|
|
107
|
+
t5 = /* @__PURE__ */ jsxs("div", {
|
|
108
|
+
className: "flex items-center justify-between py-1 text-body-sm text-fg",
|
|
109
|
+
children: [t2, t4]
|
|
110
|
+
});
|
|
111
|
+
$[9] = t2;
|
|
112
|
+
$[10] = t4;
|
|
113
|
+
$[11] = t5;
|
|
114
|
+
} else t5 = $[11];
|
|
115
|
+
let t6;
|
|
116
|
+
if ($[12] !== minute || $[13] !== onChange || $[14] !== second) {
|
|
117
|
+
t6 = (next) => {
|
|
118
|
+
onChange(timeOf(next, minute, second));
|
|
119
|
+
};
|
|
120
|
+
$[12] = minute;
|
|
121
|
+
$[13] = onChange;
|
|
122
|
+
$[14] = second;
|
|
123
|
+
$[15] = t6;
|
|
124
|
+
} else t6 = $[15];
|
|
125
|
+
let t7;
|
|
126
|
+
if ($[16] !== disabled || $[17] !== focusFirst || $[18] !== hour || $[19] !== labels.hour || $[20] !== t6) {
|
|
127
|
+
t7 = /* @__PURE__ */ jsx(SliderRow, {
|
|
128
|
+
label: labels.hour,
|
|
129
|
+
max: 23,
|
|
130
|
+
value: hour,
|
|
131
|
+
disabled,
|
|
132
|
+
initialFocus: focusFirst,
|
|
133
|
+
onChange: t6
|
|
134
|
+
});
|
|
135
|
+
$[16] = disabled;
|
|
136
|
+
$[17] = focusFirst;
|
|
137
|
+
$[18] = hour;
|
|
138
|
+
$[19] = labels.hour;
|
|
139
|
+
$[20] = t6;
|
|
140
|
+
$[21] = t7;
|
|
141
|
+
} else t7 = $[21];
|
|
142
|
+
let t8;
|
|
143
|
+
if ($[22] !== hour || $[23] !== onChange || $[24] !== second) {
|
|
144
|
+
t8 = (next_0) => {
|
|
145
|
+
onChange(timeOf(hour, next_0, second));
|
|
146
|
+
};
|
|
147
|
+
$[22] = hour;
|
|
148
|
+
$[23] = onChange;
|
|
149
|
+
$[24] = second;
|
|
150
|
+
$[25] = t8;
|
|
151
|
+
} else t8 = $[25];
|
|
152
|
+
let t9;
|
|
153
|
+
if ($[26] !== disabled || $[27] !== labels.minute || $[28] !== minute || $[29] !== t8) {
|
|
154
|
+
t9 = /* @__PURE__ */ jsx(SliderRow, {
|
|
155
|
+
label: labels.minute,
|
|
156
|
+
max: 59,
|
|
157
|
+
value: minute,
|
|
158
|
+
disabled,
|
|
159
|
+
onChange: t8
|
|
160
|
+
});
|
|
161
|
+
$[26] = disabled;
|
|
162
|
+
$[27] = labels.minute;
|
|
163
|
+
$[28] = minute;
|
|
164
|
+
$[29] = t8;
|
|
165
|
+
$[30] = t9;
|
|
166
|
+
} else t9 = $[30];
|
|
167
|
+
let t10;
|
|
168
|
+
if ($[31] !== disabled || $[32] !== hour || $[33] !== labels.second || $[34] !== minute || $[35] !== onChange || $[36] !== second || $[37] !== withSeconds) {
|
|
169
|
+
t10 = withSeconds ? /* @__PURE__ */ jsx(SliderRow, {
|
|
170
|
+
label: labels.second,
|
|
171
|
+
max: 59,
|
|
172
|
+
value: second,
|
|
173
|
+
disabled,
|
|
174
|
+
onChange: (next_1) => {
|
|
175
|
+
onChange(timeOf(hour, minute, next_1));
|
|
176
|
+
}
|
|
177
|
+
}) : null;
|
|
178
|
+
$[31] = disabled;
|
|
179
|
+
$[32] = hour;
|
|
180
|
+
$[33] = labels.second;
|
|
181
|
+
$[34] = minute;
|
|
182
|
+
$[35] = onChange;
|
|
183
|
+
$[36] = second;
|
|
184
|
+
$[37] = withSeconds;
|
|
185
|
+
$[38] = t10;
|
|
186
|
+
} else t10 = $[38];
|
|
187
|
+
let t11;
|
|
188
|
+
if ($[39] !== t10 || $[40] !== t5 || $[41] !== t7 || $[42] !== t9) {
|
|
189
|
+
t11 = /* @__PURE__ */ jsxs("div", {
|
|
190
|
+
className: "px-3 pb-1 pt-2",
|
|
191
|
+
children: [
|
|
192
|
+
t5,
|
|
193
|
+
t7,
|
|
194
|
+
t9,
|
|
195
|
+
t10
|
|
196
|
+
]
|
|
197
|
+
});
|
|
198
|
+
$[39] = t10;
|
|
199
|
+
$[40] = t5;
|
|
200
|
+
$[41] = t7;
|
|
201
|
+
$[42] = t9;
|
|
202
|
+
$[43] = t11;
|
|
203
|
+
} else t11 = $[43];
|
|
204
|
+
return t11;
|
|
205
|
+
};
|
|
206
|
+
export { TimeSliders };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Every text the date and time picker shows or announces, in the user's language. */
|
|
2
|
+
export interface DateTimePickerLabels {
|
|
3
|
+
/** The field's text while it has no value. */
|
|
4
|
+
select: string;
|
|
5
|
+
today: string;
|
|
6
|
+
now: string;
|
|
7
|
+
clear: string;
|
|
8
|
+
done: string;
|
|
9
|
+
/** The heading of the time sliders. */
|
|
10
|
+
time: string;
|
|
11
|
+
hour: string;
|
|
12
|
+
minute: string;
|
|
13
|
+
second: string;
|
|
14
|
+
previousMonth: string;
|
|
15
|
+
nextMonth: string;
|
|
16
|
+
previousYear: string;
|
|
17
|
+
nextYear: string;
|
|
18
|
+
/** Names the button that shows the month and opens the list of months and years. */
|
|
19
|
+
chooseMonth: string;
|
|
20
|
+
/** Names the button that shows the year and returns to the days. */
|
|
21
|
+
backToCalendar: string;
|
|
22
|
+
/** The panel's name for a date picker. */
|
|
23
|
+
chooseDate: string;
|
|
24
|
+
/** The panel's name for a date and time picker. */
|
|
25
|
+
chooseDateTime: string;
|
|
26
|
+
/** The panel's name for a time picker. */
|
|
27
|
+
chooseTime: string;
|
|
28
|
+
}
|
|
29
|
+
/** The texts used when a picker is given none. */
|
|
30
|
+
export declare const ENGLISH_PICKER_LABELS: DateTimePickerLabels;
|