@epilot/spark-ui 0.31.1 → 0.32.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/dist/button-B_RNHEc7.d.ts +52 -0
- package/dist/button-DBcEcIMk.d.cts +52 -0
- package/dist/cn-DzRH6EW_.d.cts +4 -0
- package/dist/cn-DzRH6EW_.d.ts +4 -0
- package/dist/components/accordion.cjs +1 -1
- package/dist/components/accordion.js +1 -1
- package/dist/components/alert-dialog.cjs +1 -1
- package/dist/components/alert-dialog.d.cts +1 -1
- package/dist/components/alert-dialog.d.ts +1 -1
- package/dist/components/alert-dialog.js +1 -1
- package/dist/components/attachment.cjs +2 -2
- package/dist/components/attachment.d.cts +3 -3
- package/dist/components/attachment.d.ts +3 -3
- package/dist/components/attachment.js +2 -2
- package/dist/components/autocomplete.cjs +9 -7
- package/dist/components/autocomplete.cjs.map +1 -1
- package/dist/components/autocomplete.d.cts +4 -10
- package/dist/components/autocomplete.d.ts +4 -10
- package/dist/components/autocomplete.js +9 -7
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/avatar.js +1 -1
- package/dist/components/badge.cjs +1 -1
- package/dist/components/badge.js +2 -2
- package/dist/components/banner.cjs +1 -1
- package/dist/components/banner.js +1 -1
- package/dist/components/bar-chart.cjs +1 -1
- package/dist/components/bar-chart.js +2 -2
- package/dist/components/box.cjs +2 -2
- package/dist/components/box.cjs.map +1 -1
- package/dist/components/box.js +3 -3
- package/dist/components/box.js.map +1 -1
- package/dist/components/breadcrumbs.cjs +1 -1
- package/dist/components/breadcrumbs.js +1 -1
- package/dist/components/bubble.cjs +2 -2
- package/dist/components/bubble.d.cts +2 -2
- package/dist/components/bubble.d.ts +2 -2
- package/dist/components/bubble.js +2 -2
- package/dist/components/button-group.cjs +1 -1
- package/dist/components/button-group.js +2 -2
- package/dist/components/button.cjs +13 -30
- package/dist/components/button.cjs.map +1 -1
- package/dist/components/button.d.cts +3 -36
- package/dist/components/button.d.ts +3 -36
- package/dist/components/button.js +14 -31
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar.cjs +32 -4
- package/dist/components/calendar.cjs.map +1 -1
- package/dist/components/calendar.d.cts +2 -2
- package/dist/components/calendar.d.ts +2 -2
- package/dist/components/calendar.js +34 -6
- package/dist/components/calendar.js.map +1 -1
- package/dist/components/callout.cjs +1 -1
- package/dist/components/callout.d.cts +1 -1
- package/dist/components/callout.d.ts +1 -1
- package/dist/components/callout.js +1 -1
- package/dist/components/card.cjs +6 -5
- package/dist/components/card.cjs.map +1 -1
- package/dist/components/card.d.cts +9 -8
- package/dist/components/card.d.ts +9 -8
- package/dist/components/card.js +7 -6
- package/dist/components/card.js.map +1 -1
- package/dist/components/checkbox-card.cjs +157 -65
- package/dist/components/checkbox-card.cjs.map +1 -1
- package/dist/components/checkbox-card.d.cts +38 -18
- package/dist/components/checkbox-card.d.ts +38 -18
- package/dist/components/checkbox-card.js +155 -66
- package/dist/components/checkbox-card.js.map +1 -1
- package/dist/components/checkbox-group.cjs +1 -1
- package/dist/components/checkbox-group.js +2 -2
- package/dist/components/checkbox.cjs +5 -18
- package/dist/components/checkbox.cjs.map +1 -1
- package/dist/components/checkbox.js +7 -20
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/combobox.cjs +2 -1
- package/dist/components/combobox.cjs.map +1 -1
- package/dist/components/combobox.js +2 -1
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/dialog.cjs +1 -1
- package/dist/components/dialog.js +1 -1
- package/dist/components/drawer.cjs +1 -1
- package/dist/components/drawer.js +1 -1
- package/dist/components/dropdown-menu.cjs +1 -1
- package/dist/components/dropdown-menu.js +1 -1
- package/dist/components/dropzone.cjs +224 -0
- package/dist/components/dropzone.cjs.map +1 -0
- package/dist/components/dropzone.d.cts +66 -0
- package/dist/components/dropzone.d.ts +66 -0
- package/dist/components/dropzone.js +215 -0
- package/dist/components/dropzone.js.map +1 -0
- package/dist/components/empty-state.cjs +1 -1
- package/dist/components/empty-state.d.cts +1 -1
- package/dist/components/empty-state.d.ts +1 -1
- package/dist/components/empty-state.js +1 -1
- package/dist/components/entity-card.cjs +1 -1
- package/dist/components/entity-card.js +1 -1
- package/dist/components/field.cjs +69 -11
- package/dist/components/field.cjs.map +1 -1
- package/dist/components/field.d.cts +16 -3
- package/dist/components/field.d.ts +16 -3
- package/dist/components/field.js +68 -11
- package/dist/components/field.js.map +1 -1
- package/dist/components/hero-metric.cjs +1 -1
- package/dist/components/hero-metric.js +1 -1
- package/dist/components/icon.js +1 -1
- package/dist/components/image-carousel.cjs +183 -0
- package/dist/components/image-carousel.cjs.map +1 -0
- package/dist/components/image-carousel.d.cts +54 -0
- package/dist/components/image-carousel.d.ts +54 -0
- package/dist/components/image-carousel.js +174 -0
- package/dist/components/image-carousel.js.map +1 -0
- package/dist/components/info-block.cjs +1 -1
- package/dist/components/info-block.d.cts +1 -1
- package/dist/components/info-block.d.ts +1 -1
- package/dist/components/info-block.js +1 -1
- package/dist/components/input-date-time.cjs +16 -202
- package/dist/components/input-date-time.cjs.map +1 -1
- package/dist/components/input-date-time.d.cts +14 -31
- package/dist/components/input-date-time.d.ts +14 -31
- package/dist/components/input-date-time.js +15 -202
- package/dist/components/input-date-time.js.map +1 -1
- package/dist/components/input-date.cjs +14 -146
- package/dist/components/input-date.cjs.map +1 -1
- package/dist/components/input-date.d.cts +11 -19
- package/dist/components/input-date.d.ts +11 -19
- package/dist/components/input-date.js +13 -146
- package/dist/components/input-date.js.map +1 -1
- package/dist/components/input-group.cjs +4 -3
- package/dist/components/input-group.cjs.map +1 -1
- package/dist/components/input-group.d.cts +2 -30
- package/dist/components/input-group.d.ts +2 -30
- package/dist/components/input-group.js +3 -2
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input-otp.cjs +3 -3
- package/dist/components/input-otp.cjs.map +1 -1
- package/dist/components/input-otp.js +3 -3
- package/dist/components/input-otp.js.map +1 -1
- package/dist/components/input.cjs +4 -2
- package/dist/components/input.cjs.map +1 -1
- package/dist/components/input.d.cts +2 -12
- package/dist/components/input.d.ts +2 -12
- package/dist/components/input.js +4 -2
- package/dist/components/input.js.map +1 -1
- package/dist/components/line-chart.cjs +2 -2
- package/dist/components/line-chart.js +3 -3
- package/dist/components/list.cjs +2 -2
- package/dist/components/list.js +2 -2
- package/dist/components/marker.cjs +2 -2
- package/dist/components/marker.d.cts +1 -1
- package/dist/components/marker.d.ts +1 -1
- package/dist/components/marker.js +2 -2
- package/dist/components/message-scroller.cjs +1 -1
- package/dist/components/message-scroller.d.cts +1 -1
- package/dist/components/message-scroller.d.ts +1 -1
- package/dist/components/message-scroller.js +2 -2
- package/dist/components/page-header.cjs +1 -1
- package/dist/components/page-header.d.cts +2 -2
- package/dist/components/page-header.d.ts +2 -2
- package/dist/components/page-header.js +1 -1
- package/dist/components/pagination.cjs +124 -0
- package/dist/components/pagination.cjs.map +1 -0
- package/dist/components/pagination.d.cts +42 -0
- package/dist/components/pagination.d.ts +42 -0
- package/dist/components/pagination.js +115 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/period-tabs.cjs +1 -1
- package/dist/components/period-tabs.d.cts +1 -1
- package/dist/components/period-tabs.d.ts +1 -1
- package/dist/components/period-tabs.js +1 -1
- package/dist/components/pill.cjs +43 -24
- package/dist/components/pill.cjs.map +1 -1
- package/dist/components/pill.d.cts +13 -3
- package/dist/components/pill.d.ts +13 -3
- package/dist/components/pill.js +44 -26
- package/dist/components/pill.js.map +1 -1
- package/dist/components/popover.cjs +1 -1
- package/dist/components/popover.d.cts +2 -29
- package/dist/components/popover.d.ts +2 -29
- package/dist/components/popover.js +1 -1
- package/dist/components/power-history-chart.cjs +2 -2
- package/dist/components/power-history-chart.js +3 -3
- package/dist/components/power-network.cjs +1 -1
- package/dist/components/power-network.js +2 -2
- package/dist/components/progress.cjs +126 -13
- package/dist/components/progress.cjs.map +1 -1
- package/dist/components/progress.d.cts +19 -10
- package/dist/components/progress.d.ts +19 -10
- package/dist/components/progress.js +126 -15
- package/dist/components/progress.js.map +1 -1
- package/dist/components/radio-card-group.cjs +137 -70
- package/dist/components/radio-card-group.cjs.map +1 -1
- package/dist/components/radio-card-group.d.cts +37 -15
- package/dist/components/radio-card-group.d.ts +37 -15
- package/dist/components/radio-card-group.js +135 -71
- package/dist/components/radio-card-group.js.map +1 -1
- package/dist/components/radio.cjs +1 -1
- package/dist/components/radio.js +2 -2
- package/dist/components/schedule-list.cjs +1 -1
- package/dist/components/schedule-list.js +1 -1
- package/dist/components/select.cjs +11 -4
- package/dist/components/select.cjs.map +1 -1
- package/dist/components/select.d.cts +1 -0
- package/dist/components/select.d.ts +1 -0
- package/dist/components/select.js +11 -4
- package/dist/components/select.js.map +1 -1
- package/dist/components/separator.cjs +1 -1
- package/dist/components/separator.js +1 -1
- package/dist/components/sheet.cjs +1 -1
- package/dist/components/sheet.js +1 -1
- package/dist/components/skeleton.cjs +1 -1
- package/dist/components/skeleton.js +1 -1
- package/dist/components/solar-forecast-chart.js +1 -1
- package/dist/components/spark-home.js +1 -1
- package/dist/components/step-indicator.cjs +128 -0
- package/dist/components/step-indicator.cjs.map +1 -0
- package/dist/components/step-indicator.d.cts +25 -0
- package/dist/components/step-indicator.d.ts +25 -0
- package/dist/components/step-indicator.js +124 -0
- package/dist/components/step-indicator.js.map +1 -0
- package/dist/components/stepper.cjs +3 -2
- package/dist/components/stepper.cjs.map +1 -1
- package/dist/components/stepper.d.cts +1 -2
- package/dist/components/stepper.d.ts +1 -2
- package/dist/components/stepper.js +3 -2
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/switch-group.cjs +1 -1
- package/dist/components/switch-group.js +2 -2
- package/dist/components/switch.js +1 -1
- package/dist/components/table.cjs +1 -1
- package/dist/components/table.js +1 -1
- package/dist/components/tabs.cjs +3 -3
- package/dist/components/tabs.cjs.map +1 -1
- package/dist/components/tabs.js +2 -2
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/textarea.cjs +8 -2
- package/dist/components/textarea.cjs.map +1 -1
- package/dist/components/textarea.js +8 -2
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/theme.cjs +1 -1
- package/dist/components/theme.js +2 -2
- package/dist/components/time-picker.cjs +3 -38
- package/dist/components/time-picker.cjs.map +1 -1
- package/dist/components/time-picker.js +1 -36
- package/dist/components/time-picker.js.map +1 -1
- package/dist/components/toast.cjs +1 -1
- package/dist/components/toast.js +1 -1
- package/dist/components/toggle-group.js +1 -1
- package/dist/components/toggle.d.cts +1 -1
- package/dist/components/toggle.d.ts +1 -1
- package/dist/components/toggle.js +1 -1
- package/dist/components/tooltip.cjs +3 -2
- package/dist/components/tooltip.cjs.map +1 -1
- package/dist/components/tooltip.d.cts +3 -2
- package/dist/components/tooltip.d.ts +3 -2
- package/dist/components/tooltip.js +3 -2
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/trace.cjs +1 -1
- package/dist/components/trace.js +1 -1
- package/dist/hooks/use-isomorphic-layout-effect.cjs +9 -0
- package/dist/hooks/use-isomorphic-layout-effect.cjs.map +1 -0
- package/dist/hooks/use-isomorphic-layout-effect.d.cts +9 -0
- package/dist/hooks/use-isomorphic-layout-effect.d.ts +9 -0
- package/dist/hooks/use-isomorphic-layout-effect.js +8 -0
- package/dist/hooks/use-isomorphic-layout-effect.js.map +1 -0
- package/dist/input-BZFPU-j4.d.cts +14 -0
- package/dist/input-group-5lh67qyY.d.cts +32 -0
- package/dist/input-group-Bc9_sPPN.d.ts +32 -0
- package/dist/input-zB3zmz9J.d.ts +14 -0
- package/dist/lib/accent-theme.cjs +46 -22
- package/dist/lib/accent-theme.cjs.map +1 -1
- package/dist/lib/accent-theme.js +26 -1
- package/dist/lib/accent-theme.js.map +1 -1
- package/dist/lib/calendar-field.cjs +11 -0
- package/dist/lib/calendar-field.cjs.map +1 -0
- package/dist/lib/calendar-field.d.cts +18 -0
- package/dist/lib/calendar-field.d.ts +18 -0
- package/dist/lib/calendar-field.js +8 -0
- package/dist/lib/calendar-field.js.map +1 -0
- package/dist/lib/calendar-lists.cjs +86 -97
- package/dist/lib/calendar-lists.cjs.map +1 -1
- package/dist/lib/calendar-lists.d.cts +30 -2
- package/dist/lib/calendar-lists.d.ts +30 -2
- package/dist/lib/calendar-lists.js +85 -97
- package/dist/lib/calendar-lists.js.map +1 -1
- package/dist/lib/card-control.cjs +18 -0
- package/dist/lib/card-control.cjs.map +1 -0
- package/dist/lib/card-control.d.cts +10 -0
- package/dist/lib/card-control.d.ts +10 -0
- package/dist/lib/card-control.js +17 -0
- package/dist/lib/card-control.js.map +1 -0
- package/dist/lib/checkbox-box.cjs +30 -0
- package/dist/lib/checkbox-box.cjs.map +1 -0
- package/dist/lib/checkbox-box.d.cts +13 -0
- package/dist/lib/checkbox-box.d.ts +13 -0
- package/dist/lib/checkbox-box.js +27 -0
- package/dist/lib/checkbox-box.js.map +1 -0
- package/dist/lib/container-chrome.cjs +8 -1
- package/dist/lib/container-chrome.cjs.map +1 -1
- package/dist/lib/container-chrome.d.cts +4 -2
- package/dist/lib/container-chrome.d.ts +4 -2
- package/dist/lib/container-chrome.js +8 -2
- package/dist/lib/container-chrome.js.map +1 -1
- package/dist/lib/date-field-input.cjs +121 -0
- package/dist/lib/date-field-input.cjs.map +1 -0
- package/dist/lib/date-field-input.d.cts +14 -0
- package/dist/lib/date-field-input.d.ts +14 -0
- package/dist/lib/date-field-input.js +118 -0
- package/dist/lib/date-field-input.js.map +1 -0
- package/dist/lib/date-field-time-list.cjs +81 -0
- package/dist/lib/date-field-time-list.cjs.map +1 -0
- package/dist/lib/date-field-time-list.d.cts +18 -0
- package/dist/lib/date-field-time-list.d.ts +18 -0
- package/dist/lib/date-field-time-list.js +77 -0
- package/dist/lib/date-field-time-list.js.map +1 -0
- package/dist/lib/date-field.cjs +183 -0
- package/dist/lib/date-field.cjs.map +1 -0
- package/dist/lib/date-field.d.cts +76 -0
- package/dist/lib/date-field.d.ts +76 -0
- package/dist/lib/date-field.js +177 -0
- package/dist/lib/date-field.js.map +1 -0
- package/dist/lib/date-time-mask.cjs +148 -102
- package/dist/lib/date-time-mask.cjs.map +1 -1
- package/dist/lib/date-time-mask.d.cts +21 -3
- package/dist/lib/date-time-mask.d.ts +21 -3
- package/dist/lib/date-time-mask.js +142 -103
- package/dist/lib/date-time-mask.js.map +1 -1
- package/dist/lib/generate-radix-colors.cjs +64 -5
- package/dist/lib/generate-radix-colors.cjs.map +1 -1
- package/dist/lib/generate-radix-colors.js +61 -1
- package/dist/lib/generate-radix-colors.js.map +1 -1
- package/dist/lib/input-box-variants.cjs +3 -3
- package/dist/lib/input-box-variants.cjs.map +1 -1
- package/dist/lib/input-box-variants.d.cts +1 -1
- package/dist/lib/input-box-variants.d.ts +1 -1
- package/dist/lib/input-box-variants.js +3 -3
- package/dist/lib/input-box-variants.js.map +1 -1
- package/dist/lib/mask-hint.cjs +15 -0
- package/dist/lib/mask-hint.cjs.map +1 -0
- package/dist/lib/mask-hint.d.cts +10 -0
- package/dist/lib/mask-hint.d.ts +10 -0
- package/dist/lib/mask-hint.js +14 -0
- package/dist/lib/mask-hint.js.map +1 -0
- package/dist/lib/option-list.cjs +71 -0
- package/dist/lib/option-list.cjs.map +1 -0
- package/dist/lib/option-list.d.cts +4 -0
- package/dist/lib/option-list.d.ts +4 -0
- package/dist/lib/option-list.js +67 -0
- package/dist/lib/option-list.js.map +1 -0
- package/dist/lib/time-grid.cjs +34 -0
- package/dist/lib/time-grid.cjs.map +1 -0
- package/dist/lib/time-grid.d.cts +9 -0
- package/dist/lib/time-grid.d.ts +9 -0
- package/dist/lib/time-grid.js +31 -0
- package/dist/lib/time-grid.js.map +1 -0
- package/dist/lib/toggle-group-context.d.cts +1 -1
- package/dist/lib/toggle-group-context.d.ts +1 -1
- package/dist/option-list-CxhR_DGq.d.cts +34 -0
- package/dist/option-list-CxhR_DGq.d.ts +34 -0
- package/dist/popover-DmcqNOkO.d.cts +31 -0
- package/dist/popover-DmcqNOkO.d.ts +31 -0
- package/dist/styles/spark-default.css +21 -0
- package/dist/styles/theme.css +2 -1
- package/dist/utils/cn.d.cts +1 -1
- package/dist/utils/cn.d.ts +1 -1
- package/package.json +3 -3
- package/dist/calendar-lists-CTby2kR5.d.cts +0 -27
- package/dist/calendar-lists-DoloqsCN.d.ts +0 -27
- package/dist/lib/calendar-day-button.cjs +0 -23
- package/dist/lib/calendar-day-button.cjs.map +0 -1
- package/dist/lib/calendar-day-button.d.cts +0 -14
- package/dist/lib/calendar-day-button.d.ts +0 -14
- package/dist/lib/calendar-day-button.js +0 -20
- package/dist/lib/calendar-day-button.js.map +0 -1
- package/dist/lib/input-date-parts.cjs +0 -155
- package/dist/lib/input-date-parts.cjs.map +0 -1
- package/dist/lib/input-date-parts.d.cts +0 -53
- package/dist/lib/input-date-parts.d.ts +0 -53
- package/dist/lib/input-date-parts.js +0 -148
- package/dist/lib/input-date-parts.js.map +0 -1
- package/dist/lib/scroll-within.cjs +0 -27
- package/dist/lib/scroll-within.cjs.map +0 -1
- package/dist/lib/scroll-within.d.cts +0 -14
- package/dist/lib/scroll-within.d.ts +0 -14
- package/dist/lib/scroll-within.js +0 -25
- package/dist/lib/scroll-within.js.map +0 -1
|
@@ -1,38 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { DateFieldContent, DateFieldDetails, DateFieldRootProps, DateFieldTrigger, DateFieldTriggerProps } from "../lib/date-field.cjs";
|
|
4
|
+
import { DateFieldInputProps } from "../lib/date-field-input.cjs";
|
|
5
|
+
import { DateFieldTimeList, DateFieldTimeListProps } from "../lib/date-field-time-list.cjs";
|
|
5
6
|
import { DateTimeStatus, dateTimeStatus, formatDateTime, parseDateTime } from "../lib/date-time-mask.cjs";
|
|
6
|
-
import * as React$1 from "react";
|
|
7
7
|
|
|
8
8
|
//#region src/components/input-date-time.d.ts
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
defaultOpen?: boolean; /** `HH:MM` a day picked from the calendar gets while no time is set. */
|
|
20
|
-
defaultTime?: string;
|
|
21
|
-
defaultValue?: string; /** The day a time picked before any date applies to; today by default. */
|
|
22
|
-
getDefaultDate?: () => Date; /** The date, with its time when `withTime`; undefined until complete. */
|
|
23
|
-
onDateChange?: (date: Date | undefined) => void;
|
|
24
|
-
onOpenChange?: (open: boolean) => void;
|
|
25
|
-
onValueChange?: (value: string) => void;
|
|
26
|
-
open?: boolean;
|
|
27
|
-
pickerOnly?: boolean; /** Read out politely when a key the field ignores is typed, e.g. "Only numbers are allowed". */
|
|
28
|
-
rejectedKeyMessage?: string;
|
|
29
|
-
separator?: string; /** Names the time list. */
|
|
30
|
-
timeLabel?: string; /** Minutes between the times offered; 30 by default, 5 at least. */
|
|
31
|
-
timeStep?: number;
|
|
32
|
-
value?: string; /** Adds `, HH:MM` to the field and a time list beside the calendar. */
|
|
33
|
-
withTime?: boolean;
|
|
34
|
-
};
|
|
35
|
-
declare const InputDateTime: React$1.ForwardRefExoticComponent<Omit<InputDateTimeProps, "ref"> & React$1.RefAttributes<HTMLInputElement>>;
|
|
9
|
+
type InputDateTimeProps = DateFieldRootProps;
|
|
10
|
+
type InputDateTimeInputProps = DateFieldInputProps;
|
|
11
|
+
type InputDateTimeTriggerProps = DateFieldTriggerProps;
|
|
12
|
+
type InputDateTimeContentProps = React.ComponentProps<typeof DateFieldContent>;
|
|
13
|
+
type InputDateTimeTimeListProps = DateFieldTimeListProps;
|
|
14
|
+
declare function InputDateTime(props: InputDateTimeProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
declare const InputDateTimeInput: import("react").ForwardRefExoticComponent<Omit<DateFieldInputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
16
|
+
declare const InputDateTimeTrigger: typeof DateFieldTrigger;
|
|
17
|
+
declare const InputDateTimeContent: typeof DateFieldContent;
|
|
18
|
+
declare const InputDateTimeTimeList: typeof DateFieldTimeList;
|
|
36
19
|
//#endregion
|
|
37
|
-
export { type DateTimeStatus, InputDateTime, InputDateTimeProps, dateTimeStatus, formatDateTime, parseDateTime };
|
|
20
|
+
export { type DateTimeStatus, InputDateTime, InputDateTimeContent, InputDateTimeContentProps, type DateFieldDetails as InputDateTimeDetails, InputDateTimeInput, InputDateTimeInputProps, InputDateTimeProps, InputDateTimeTimeList, InputDateTimeTimeListProps, InputDateTimeTrigger, InputDateTimeTriggerProps, dateTimeStatus, formatDateTime, parseDateTime };
|
|
38
21
|
//# sourceMappingURL=input-date-time.d.cts.map
|
|
@@ -1,38 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { DateFieldContent, DateFieldDetails, DateFieldRootProps, DateFieldTrigger, DateFieldTriggerProps } from "../lib/date-field.js";
|
|
4
|
+
import { DateFieldInputProps } from "../lib/date-field-input.js";
|
|
5
|
+
import { DateFieldTimeList, DateFieldTimeListProps } from "../lib/date-field-time-list.js";
|
|
5
6
|
import { DateTimeStatus, dateTimeStatus, formatDateTime, parseDateTime } from "../lib/date-time-mask.js";
|
|
6
|
-
import * as React$1 from "react";
|
|
7
7
|
|
|
8
8
|
//#region src/components/input-date-time.d.ts
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
defaultOpen?: boolean; /** `HH:MM` a day picked from the calendar gets while no time is set. */
|
|
20
|
-
defaultTime?: string;
|
|
21
|
-
defaultValue?: string; /** The day a time picked before any date applies to; today by default. */
|
|
22
|
-
getDefaultDate?: () => Date; /** The date, with its time when `withTime`; undefined until complete. */
|
|
23
|
-
onDateChange?: (date: Date | undefined) => void;
|
|
24
|
-
onOpenChange?: (open: boolean) => void;
|
|
25
|
-
onValueChange?: (value: string) => void;
|
|
26
|
-
open?: boolean;
|
|
27
|
-
pickerOnly?: boolean; /** Read out politely when a key the field ignores is typed, e.g. "Only numbers are allowed". */
|
|
28
|
-
rejectedKeyMessage?: string;
|
|
29
|
-
separator?: string; /** Names the time list. */
|
|
30
|
-
timeLabel?: string; /** Minutes between the times offered; 30 by default, 5 at least. */
|
|
31
|
-
timeStep?: number;
|
|
32
|
-
value?: string; /** Adds `, HH:MM` to the field and a time list beside the calendar. */
|
|
33
|
-
withTime?: boolean;
|
|
34
|
-
};
|
|
35
|
-
declare const InputDateTime: React$1.ForwardRefExoticComponent<Omit<InputDateTimeProps, "ref"> & React$1.RefAttributes<HTMLInputElement>>;
|
|
9
|
+
type InputDateTimeProps = DateFieldRootProps;
|
|
10
|
+
type InputDateTimeInputProps = DateFieldInputProps;
|
|
11
|
+
type InputDateTimeTriggerProps = DateFieldTriggerProps;
|
|
12
|
+
type InputDateTimeContentProps = React.ComponentProps<typeof DateFieldContent>;
|
|
13
|
+
type InputDateTimeTimeListProps = DateFieldTimeListProps;
|
|
14
|
+
declare function InputDateTime(props: InputDateTimeProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
declare const InputDateTimeInput: import("react").ForwardRefExoticComponent<Omit<DateFieldInputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
16
|
+
declare const InputDateTimeTrigger: typeof DateFieldTrigger;
|
|
17
|
+
declare const InputDateTimeContent: typeof DateFieldContent;
|
|
18
|
+
declare const InputDateTimeTimeList: typeof DateFieldTimeList;
|
|
36
19
|
//#endregion
|
|
37
|
-
export { type DateTimeStatus, InputDateTime, InputDateTimeProps, dateTimeStatus, formatDateTime, parseDateTime };
|
|
20
|
+
export { type DateTimeStatus, InputDateTime, InputDateTimeContent, InputDateTimeContentProps, type DateFieldDetails as InputDateTimeDetails, InputDateTimeInput, InputDateTimeInputProps, InputDateTimeProps, InputDateTimeTimeList, InputDateTimeTimeListProps, InputDateTimeTrigger, InputDateTimeTriggerProps, dateTimeStatus, formatDateTime, parseDateTime };
|
|
38
21
|
//# sourceMappingURL=input-date-time.d.ts.map
|
|
@@ -1,210 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { InputGroup, InputGroupAddon, InputGroupInput } from "./input-group.js";
|
|
9
|
-
import { Calendar } from "./calendar.js";
|
|
10
|
-
import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
11
|
-
import * as React$1 from "react";
|
|
12
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { CalendarMonth } from "@epilot/spark-icons";
|
|
3
|
+
import { dateTimeStatus, formatDateTime, parseDateTime } from "../lib/date-time-mask.js";
|
|
4
|
+
import { DateFieldContent, DateFieldRoot, DateFieldTrigger } from "../lib/date-field.js";
|
|
5
|
+
import { DateFieldInput } from "../lib/date-field-input.js";
|
|
6
|
+
import { DateFieldTimeList } from "../lib/date-field-time-list.js";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
14
8
|
//#region src/components/input-date-time.tsx
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
onChange?.(next);
|
|
21
|
-
}, [isControlled, onChange])];
|
|
22
|
-
}
|
|
23
|
-
const today = () => /* @__PURE__ */ new Date();
|
|
24
|
-
const placeholderOf = (separator, withTime) => `DD${separator}MM${separator}YYYY${withTime ? ", HH:MM" : ""}`;
|
|
25
|
-
/** The field text, the popup and the month shown, and how a pick becomes text. */
|
|
26
|
-
function useInputDateTimeState({ calendarMonth, defaultOpen = false, defaultValue = "", getDefaultDate, onDateChange, onOpenChange, onValueChange, open: openProp, separator, value, withTime }) {
|
|
27
|
-
const [text, setText] = useControllableState({
|
|
28
|
-
defaultProp: defaultValue,
|
|
29
|
-
onChange: onValueChange,
|
|
30
|
-
prop: value
|
|
31
|
-
});
|
|
32
|
-
const [open, setOpenState] = useControllableState({
|
|
33
|
-
defaultProp: defaultOpen,
|
|
34
|
-
onChange: onOpenChange,
|
|
35
|
-
prop: openProp
|
|
9
|
+
function InputDateTime(props) {
|
|
10
|
+
return /* @__PURE__ */ jsx(DateFieldRoot, {
|
|
11
|
+
...props,
|
|
12
|
+
slot: "input-date-time",
|
|
13
|
+
withTime: true
|
|
36
14
|
});
|
|
37
|
-
const selected = parseDatePart(text);
|
|
38
|
-
const parsed = parseDateTime(text, withTime);
|
|
39
|
-
const selectedTime = withTime && parsed ? formatTime(parsed) : void 0;
|
|
40
|
-
const [month, setMonth] = React$1.useState(() => selected ?? calendarMonth);
|
|
41
|
-
const setOpen = React$1.useCallback((next) => {
|
|
42
|
-
if (next && calendarMonth === void 0) setMonth(parseDatePart(text) ?? getDefaultDate());
|
|
43
|
-
setOpenState(next);
|
|
44
|
-
}, [
|
|
45
|
-
calendarMonth,
|
|
46
|
-
getDefaultDate,
|
|
47
|
-
setOpenState,
|
|
48
|
-
text
|
|
49
|
-
]);
|
|
50
|
-
const commit = React$1.useCallback((next) => {
|
|
51
|
-
if (next === text) return;
|
|
52
|
-
setText(next);
|
|
53
|
-
onDateChange?.(parseDateTime(next, withTime));
|
|
54
|
-
}, [
|
|
55
|
-
onDateChange,
|
|
56
|
-
setText,
|
|
57
|
-
text,
|
|
58
|
-
withTime
|
|
59
|
-
]);
|
|
60
|
-
const commitDate = (day, time = "00:00") => {
|
|
61
|
-
const next = new Date(day);
|
|
62
|
-
const [hours = 0, minutes = 0] = time.split(":").map(Number);
|
|
63
|
-
next.setHours(hours, minutes, 0, 0);
|
|
64
|
-
commit(formatDateTime(next, separator, withTime));
|
|
65
|
-
};
|
|
66
|
-
return {
|
|
67
|
-
commit,
|
|
68
|
-
commitDate,
|
|
69
|
-
month,
|
|
70
|
-
open,
|
|
71
|
-
selected,
|
|
72
|
-
selectedTime,
|
|
73
|
-
setMonth,
|
|
74
|
-
setOpen,
|
|
75
|
-
text
|
|
76
|
-
};
|
|
77
15
|
}
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
calendarMonth: calendarProps?.month,
|
|
83
|
-
defaultOpen,
|
|
84
|
-
defaultValue,
|
|
85
|
-
getDefaultDate,
|
|
86
|
-
onDateChange,
|
|
87
|
-
onOpenChange,
|
|
88
|
-
onValueChange,
|
|
89
|
-
open: openProp,
|
|
90
|
-
separator,
|
|
91
|
-
value: valueProp,
|
|
92
|
-
withTime
|
|
93
|
-
});
|
|
94
|
-
const setInputRef = React$1.useCallback((node) => {
|
|
95
|
-
inputRef.current = node;
|
|
96
|
-
if (typeof ref === "function") ref(node);
|
|
97
|
-
else if (ref) ref.current = node;
|
|
98
|
-
}, [ref]);
|
|
99
|
-
const times = React$1.useMemo(() => withTime ? timesOf(timeStep, selectedTime) : [], [
|
|
100
|
-
selectedTime,
|
|
101
|
-
timeStep,
|
|
102
|
-
withTime
|
|
103
|
-
]);
|
|
104
|
-
const handlers = useMaskHandlers({
|
|
105
|
-
commit,
|
|
106
|
-
inputRef,
|
|
107
|
-
onKeyDown,
|
|
108
|
-
onOpen: () => setOpen(true),
|
|
109
|
-
onPaste,
|
|
110
|
-
onRejectedKey: () => {
|
|
111
|
-
if (rejectedKeyMessage) announce(rejectedKeyMessage);
|
|
112
|
-
},
|
|
113
|
-
pickerOnly,
|
|
114
|
-
separator,
|
|
115
|
-
withTime
|
|
116
|
-
});
|
|
117
|
-
return /* @__PURE__ */ jsxs(Popover, {
|
|
118
|
-
onOpenChange: setOpen,
|
|
119
|
-
open,
|
|
120
|
-
children: [
|
|
121
|
-
/* @__PURE__ */ jsx(PopoverAnchor, {
|
|
122
|
-
render: /* @__PURE__ */ jsx("div", { className: "min-w-0" }),
|
|
123
|
-
children: /* @__PURE__ */ jsxs(InputGroup, {
|
|
124
|
-
className,
|
|
125
|
-
children: [/* @__PURE__ */ jsx(InputGroupInput, {
|
|
126
|
-
autoComplete: "off",
|
|
127
|
-
...props,
|
|
128
|
-
className: cn(pickerOnly && "cursor-pointer"),
|
|
129
|
-
disabled,
|
|
130
|
-
id,
|
|
131
|
-
inputMode: pickerOnly ? void 0 : "numeric",
|
|
132
|
-
onChange: () => {},
|
|
133
|
-
onClick: (event) => {
|
|
134
|
-
props.onClick?.(event);
|
|
135
|
-
if (pickerOnly && !disabled && !event.defaultPrevented) setOpen(true);
|
|
136
|
-
},
|
|
137
|
-
...handlers,
|
|
138
|
-
placeholder: placeholder ?? placeholderOf(separator, withTime),
|
|
139
|
-
readOnly: pickerOnly,
|
|
140
|
-
ref: setInputRef,
|
|
141
|
-
spellCheck: false,
|
|
142
|
-
value: text
|
|
143
|
-
}), /* @__PURE__ */ jsx(InputGroupAddon, {
|
|
144
|
-
align: "inline-end",
|
|
145
|
-
children: /* @__PURE__ */ jsx(PopoverTrigger, { render: /* @__PURE__ */ jsx(Button, {
|
|
146
|
-
"aria-label": calendarLabel,
|
|
147
|
-
color: "neutral",
|
|
148
|
-
disabled,
|
|
149
|
-
size: "icon-small",
|
|
150
|
-
styleVariant: "ghost",
|
|
151
|
-
children: /* @__PURE__ */ jsx(CalendarMonth, {})
|
|
152
|
-
}) })
|
|
153
|
-
})]
|
|
154
|
-
})
|
|
155
|
-
}),
|
|
156
|
-
status,
|
|
157
|
-
/* @__PURE__ */ jsx(PopoverContent, {
|
|
158
|
-
align: "start",
|
|
159
|
-
"aria-label": calendarLabel,
|
|
160
|
-
className: "w-auto p-0",
|
|
161
|
-
collisionAvoidance: {
|
|
162
|
-
side: "flip",
|
|
163
|
-
fallbackAxisSide: "none"
|
|
164
|
-
},
|
|
165
|
-
container,
|
|
166
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
167
|
-
className: "flex max-sm:flex-col has-[[data-slot=calendar-list]]:[&>[data-slot=input-date-times]]:hidden",
|
|
168
|
-
children: [/* @__PURE__ */ jsx(Calendar, {
|
|
169
|
-
autoFocus: true,
|
|
170
|
-
...calendarProps,
|
|
171
|
-
components: {
|
|
172
|
-
DayButton: ScrollFreeDayButton,
|
|
173
|
-
...calendarProps?.components
|
|
174
|
-
},
|
|
175
|
-
mode: "single",
|
|
176
|
-
month: calendarProps?.month ?? month,
|
|
177
|
-
onMonthChange: (next) => {
|
|
178
|
-
calendarProps?.onMonthChange?.(next);
|
|
179
|
-
if (calendarProps?.month === void 0) setMonth(next);
|
|
180
|
-
},
|
|
181
|
-
onSelect: (next) => {
|
|
182
|
-
if (!withTime) {
|
|
183
|
-
commit(next ? formatDateTime(next, separator) : "");
|
|
184
|
-
setOpen(false);
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
if (next) commitDate(next, selectedTime ?? defaultTime);
|
|
188
|
-
},
|
|
189
|
-
selected
|
|
190
|
-
}), withTime && /* @__PURE__ */ jsx(TimeList, {
|
|
191
|
-
defaultTime,
|
|
192
|
-
label: timeLabel,
|
|
193
|
-
onPick: (time) => {
|
|
194
|
-
commitDate(selected ?? getDefaultDate(), time);
|
|
195
|
-
setOpen(false);
|
|
196
|
-
inputRef.current?.focus({ preventScroll: true });
|
|
197
|
-
},
|
|
198
|
-
open,
|
|
199
|
-
selectedTime,
|
|
200
|
-
times
|
|
201
|
-
})]
|
|
202
|
-
})
|
|
203
|
-
})
|
|
204
|
-
]
|
|
205
|
-
});
|
|
206
|
-
});
|
|
16
|
+
const InputDateTimeInput = DateFieldInput;
|
|
17
|
+
const InputDateTimeTrigger = DateFieldTrigger;
|
|
18
|
+
const InputDateTimeContent = DateFieldContent;
|
|
19
|
+
const InputDateTimeTimeList = DateFieldTimeList;
|
|
207
20
|
//#endregion
|
|
208
|
-
export { InputDateTime, dateTimeStatus, formatDateTime, parseDateTime };
|
|
21
|
+
export { InputDateTime, InputDateTimeContent, InputDateTimeInput, InputDateTimeTimeList, InputDateTimeTrigger, dateTimeStatus, formatDateTime, parseDateTime };
|
|
209
22
|
|
|
210
23
|
//# sourceMappingURL=input-date-time.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-date-time.js","names":["React"],"sources":["../../src/components/input-date-time.tsx"],"sourcesContent":["'use client'\n\nimport { CalendarMonth } from '@epilot/spark-icons'\nimport * as React from 'react'\nimport { ScrollFreeDayButton } from '../lib/calendar-day-button'\nimport {\n formatDateTime,\n formatTime,\n parseDatePart,\n parseDateTime,\n} from '../lib/date-time-mask'\nimport {\n TimeList,\n timesOf,\n useAnnouncement,\n useMaskHandlers,\n} from '../lib/input-date-parts'\nimport { cn } from '../utils/cn'\nimport { Button } from './button'\nimport { Calendar, type CalendarProps } from './calendar'\nimport { InputGroup, InputGroupAddon, InputGroupInput } from './input-group'\nimport {\n Popover,\n PopoverAnchor,\n PopoverContent,\n PopoverTrigger,\n} from './popover'\n\nfunction useControllableState<T>({\n defaultProp,\n onChange,\n prop,\n}: {\n defaultProp: T\n onChange?: (value: T) => void\n prop?: T\n}) {\n const [uncontrolled, setUncontrolled] = React.useState(defaultProp)\n const isControlled = prop !== undefined\n const value = isControlled ? prop : uncontrolled\n\n const setValue = React.useCallback(\n (next: T) => {\n if (!isControlled) setUncontrolled(next)\n onChange?.(next)\n },\n [isControlled, onChange],\n )\n\n return [value, setValue] as const\n}\n\nconst today = () => new Date()\n\nconst placeholderOf = (separator: string, withTime: boolean) =>\n `DD${separator}MM${separator}YYYY${withTime ? ', HH:MM' : ''}`\n\n/** The field text, the popup and the month shown, and how a pick becomes text. */\nfunction useInputDateTimeState({\n calendarMonth,\n defaultOpen = false,\n defaultValue = '',\n getDefaultDate,\n onDateChange,\n onOpenChange,\n onValueChange,\n open: openProp,\n separator,\n value,\n withTime,\n}: {\n calendarMonth?: Date\n defaultOpen?: boolean\n defaultValue?: string\n getDefaultDate: () => Date\n onDateChange?: (date: Date | undefined) => void\n onOpenChange?: (open: boolean) => void\n onValueChange?: (value: string) => void\n open?: boolean\n separator: string\n value?: string\n withTime: boolean\n}) {\n const [text, setText] = useControllableState({\n defaultProp: defaultValue,\n onChange: onValueChange,\n prop: value,\n })\n const [open, setOpenState] = useControllableState({\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n prop: openProp,\n })\n // the day stays picked while its time is still being typed\n const selected = parseDatePart(text)\n const parsed = parseDateTime(text, withTime)\n const selectedTime = withTime && parsed ? formatTime(parsed) : undefined\n const [month, setMonth] = React.useState<Date | undefined>(\n () => selected ?? calendarMonth,\n )\n const setOpen = React.useCallback(\n (next: boolean) => {\n if (next && calendarMonth === undefined) {\n setMonth(parseDatePart(text) ?? getDefaultDate())\n }\n setOpenState(next)\n },\n [calendarMonth, getDefaultDate, setOpenState, text],\n )\n const commit = React.useCallback(\n (next: string) => {\n if (next === text) return\n setText(next)\n onDateChange?.(parseDateTime(next, withTime))\n },\n [onDateChange, setText, text, withTime],\n )\n const commitDate = (day: Date, time = '00:00') => {\n const next = new Date(day)\n const [hours = 0, minutes = 0] = time.split(':').map(Number)\n next.setHours(hours, minutes, 0, 0)\n commit(formatDateTime(next, separator, withTime))\n }\n return {\n commit,\n commitDate,\n month,\n open,\n selected,\n selectedTime,\n setMonth,\n setOpen,\n text,\n }\n}\n\n/**\n * A date, or a date and a time (`withTime`), in one field with a calendar popup.\n * Input Date's journey-grade sibling: the chosen day takes focus on open, Backspace\n * after a separator deletes the digit before it, pastes go through the mask, and\n * ignored keys can be read out.\n */\nexport type InputDateTimeProps = Omit<\n React.ComponentProps<'input'>,\n 'children' | 'defaultValue' | 'onChange' | 'readOnly' | 'type' | 'value'\n> & {\n calendarLabel: string\n calendarProps?: Omit<CalendarProps, 'mode' | 'onSelect' | 'selected'>\n /** Element the calendar popup mounts into, e.g. the drawer it sits in. */\n container?: React.ComponentProps<typeof PopoverContent>['container']\n defaultOpen?: boolean\n /** `HH:MM` a day picked from the calendar gets while no time is set. */\n defaultTime?: string\n defaultValue?: string\n /** The day a time picked before any date applies to; today by default. */\n getDefaultDate?: () => Date\n /** The date, with its time when `withTime`; undefined until complete. */\n onDateChange?: (date: Date | undefined) => void\n onOpenChange?: (open: boolean) => void\n onValueChange?: (value: string) => void\n open?: boolean\n pickerOnly?: boolean\n /** Read out politely when a key the field ignores is typed, e.g. \"Only numbers are allowed\". */\n rejectedKeyMessage?: string\n separator?: string\n /** Names the time list. */\n timeLabel?: string\n /** Minutes between the times offered; 30 by default, 5 at least. */\n timeStep?: number\n value?: string\n /** Adds `, HH:MM` to the field and a time list beside the calendar. */\n withTime?: boolean\n}\n\nconst InputDateTime = React.forwardRef<HTMLInputElement, InputDateTimeProps>(\n function InputDateTime(\n {\n calendarLabel,\n calendarProps,\n className,\n container,\n defaultOpen,\n defaultTime = '08:00',\n defaultValue,\n disabled,\n getDefaultDate = today,\n id,\n onDateChange,\n onKeyDown,\n onOpenChange,\n onPaste,\n onValueChange,\n open: openProp,\n pickerOnly = false,\n placeholder,\n rejectedKeyMessage,\n separator = '.',\n timeLabel,\n timeStep = 30,\n value: valueProp,\n withTime = false,\n ...props\n },\n ref,\n ) {\n const inputRef = React.useRef<HTMLInputElement>(null)\n const [status, announce] = useAnnouncement()\n const {\n commit,\n commitDate,\n month,\n open,\n selected,\n selectedTime,\n setMonth,\n setOpen,\n text,\n } = useInputDateTimeState({\n calendarMonth: calendarProps?.month,\n defaultOpen,\n defaultValue,\n getDefaultDate,\n onDateChange,\n onOpenChange,\n onValueChange,\n open: openProp,\n separator,\n value: valueProp,\n withTime,\n })\n\n const setInputRef = React.useCallback(\n (node: HTMLInputElement | null) => {\n inputRef.current = node\n if (typeof ref === 'function') ref(node)\n else if (ref) ref.current = node\n },\n [ref],\n )\n\n const times = React.useMemo(\n () => (withTime ? timesOf(timeStep, selectedTime) : []),\n [selectedTime, timeStep, withTime],\n )\n\n const handlers = useMaskHandlers({\n commit,\n inputRef,\n onKeyDown,\n onOpen: () => setOpen(true),\n onPaste,\n onRejectedKey: () => {\n if (rejectedKeyMessage) announce(rejectedKeyMessage)\n },\n pickerOnly,\n separator,\n withTime,\n })\n\n return (\n <Popover onOpenChange={setOpen} open={open}>\n {/* a plain element anchors the popup: InputGroup drops its ref on React 18 */}\n <PopoverAnchor render={<div className=\"min-w-0\" />}>\n <InputGroup className={className}>\n <InputGroupInput\n autoComplete=\"off\"\n {...props}\n className={cn(pickerOnly && 'cursor-pointer')}\n disabled={disabled}\n id={id}\n inputMode={pickerOnly ? undefined : 'numeric'}\n onChange={() => {}}\n onClick={(event) => {\n props.onClick?.(event)\n // picker-only: the value opens the calendar instead of taking a caret\n if (pickerOnly && !disabled && !event.defaultPrevented)\n setOpen(true)\n }}\n {...handlers}\n placeholder={placeholder ?? placeholderOf(separator, withTime)}\n readOnly={pickerOnly}\n ref={setInputRef}\n spellCheck={false}\n value={text}\n />\n <InputGroupAddon align=\"inline-end\">\n <PopoverTrigger\n render={\n <Button\n aria-label={calendarLabel}\n color=\"neutral\"\n disabled={disabled}\n size=\"icon-small\"\n styleVariant=\"ghost\"\n >\n <CalendarMonth />\n </Button>\n }\n />\n </InputGroupAddon>\n </InputGroup>\n </PopoverAnchor>\n {status}\n <PopoverContent\n align=\"start\"\n aria-label={calendarLabel}\n className=\"w-auto p-0\"\n collisionAvoidance={{ side: 'flip', fallbackAxisSide: 'none' }}\n container={container}\n >\n {/* a month or year list replaces the days, and the times step aside for it */}\n <div className=\"flex max-sm:flex-col has-[[data-slot=calendar-list]]:[&>[data-slot=input-date-times]]:hidden\">\n <Calendar\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- DayPicker prop: the picked day takes focus when the popup opens\n autoFocus\n {...calendarProps}\n // the picked day takes focus on open without scrolling the page\n components={{\n DayButton: ScrollFreeDayButton,\n ...calendarProps?.components,\n }}\n mode=\"single\"\n month={calendarProps?.month ?? month}\n onMonthChange={(next) => {\n calendarProps?.onMonthChange?.(next)\n if (calendarProps?.month === undefined) setMonth(next)\n }}\n onSelect={(next) => {\n if (!withTime) {\n commit(next ? formatDateTime(next, separator) : '')\n setOpen(false)\n return\n }\n // a time is picked next, so the popup stays open\n if (next) commitDate(next, selectedTime ?? defaultTime)\n }}\n selected={selected}\n />\n {withTime && (\n <TimeList\n defaultTime={defaultTime}\n label={timeLabel}\n onPick={(time) => {\n commitDate(selected ?? getDefaultDate(), time)\n setOpen(false)\n inputRef.current?.focus({ preventScroll: true })\n }}\n open={open}\n selectedTime={selectedTime}\n times={times}\n />\n )}\n </div>\n </PopoverContent>\n </Popover>\n )\n },\n)\n\nexport { InputDateTime }\nexport {\n dateTimeStatus,\n formatDateTime,\n parseDateTime,\n type DateTimeStatus,\n} from '../lib/date-time-mask'\n"],"mappings":";;;;;;;;;;;;;;AA4BA,SAAS,qBAAwB,EAC/B,aACA,UACA,QAKC;CACD,MAAM,CAAC,cAAc,mBAAmBA,QAAM,SAAS,WAAW;CAClE,MAAM,eAAe,SAAS,KAAA;CAW9B,OAAO,CAVO,eAAe,OAAO,cAEnBA,QAAM,aACpB,SAAY;EACX,IAAI,CAAC,cAAc,gBAAgB,IAAI;EACvC,WAAW,IAAI;CACjB,GACA,CAAC,cAAc,QAAQ,CAGH,CAAC;AACzB;AAEA,MAAM,8BAAc,IAAI,KAAK;AAE7B,MAAM,iBAAiB,WAAmB,aACxC,KAAK,UAAU,IAAI,UAAU,MAAM,WAAW,YAAY;;AAG5D,SAAS,sBAAsB,EAC7B,eACA,cAAc,OACd,eAAe,IACf,gBACA,cACA,cACA,eACA,MAAM,UACN,WACA,OACA,YAaC;CACD,MAAM,CAAC,MAAM,WAAW,qBAAqB;EAC3C,aAAa;EACb,UAAU;EACV,MAAM;CACR,CAAC;CACD,MAAM,CAAC,MAAM,gBAAgB,qBAAqB;EAChD,aAAa;EACb,UAAU;EACV,MAAM;CACR,CAAC;CAED,MAAM,WAAW,cAAc,IAAI;CACnC,MAAM,SAAS,cAAc,MAAM,QAAQ;CAC3C,MAAM,eAAe,YAAY,SAAS,WAAW,MAAM,IAAI,KAAA;CAC/D,MAAM,CAAC,OAAO,YAAYA,QAAM,eACxB,YAAY,aACpB;CACA,MAAM,UAAUA,QAAM,aACnB,SAAkB;EACjB,IAAI,QAAQ,kBAAkB,KAAA,GAC5B,SAAS,cAA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;OACvB,eAAe,gBAAgB,IAAI;OACnC,IAAI,eAAe,UAAU,KAAA,GAAW,SAAS,IAAI;MACvD;MACA,WAAW,SAAS;OAClB,IAAI,CAAC,UAAU;QACb,OAAO,OAAO,eAAe,MAAM,SAAS,IAAI,EAAE;QAClD,QAAQ,KAAK;QACb;OACF;OAEA,IAAI,MAAM,WAAW,MAAM,gBAAgB,WAAW;MACxD;MACU;KACX,CAAA,GACA,YACC,oBAAC,UAAD;MACe;MACb,OAAO;MACP,SAAS,SAAS;OAChB,WAAW,YAAY,eAAe,GAAG,IAAI;OAC7C,QAAQ,KAAK;OACb,SAAS,SAAS,MAAM,EAAE,eAAe,KAAK,CAAC;MACjD;MACM;MACQ;MACP;KACR,CAAA,CAEA;;GACS,CAAA;EACT;;AAEb,CACF"}
|
|
1
|
+
{"version":3,"file":"input-date-time.js","names":[],"sources":["../../src/components/input-date-time.tsx"],"sourcesContent":["'use client'\n\nimport {\n DateFieldContent,\n DateFieldRoot,\n type DateFieldRootProps,\n DateFieldTrigger,\n type DateFieldTriggerProps,\n} from '../lib/date-field'\nimport {\n DateFieldInput,\n type DateFieldInputProps,\n} from '../lib/date-field-input'\nimport {\n DateFieldTimeList,\n type DateFieldTimeListProps,\n} from '../lib/date-field-time-list'\n\nexport type InputDateTimeProps = DateFieldRootProps\nexport type InputDateTimeInputProps = DateFieldInputProps\nexport type InputDateTimeTriggerProps = DateFieldTriggerProps\nexport type InputDateTimeContentProps = React.ComponentProps<\n typeof DateFieldContent\n>\nexport type InputDateTimeTimeListProps = DateFieldTimeListProps\n\nfunction InputDateTime(props: InputDateTimeProps) {\n return <DateFieldRoot {...props} slot=\"input-date-time\" withTime />\n}\n\nconst InputDateTimeInput = DateFieldInput\nconst InputDateTimeTrigger = DateFieldTrigger\nconst InputDateTimeContent = DateFieldContent\nconst InputDateTimeTimeList = DateFieldTimeList\n\nexport {\n InputDateTime,\n InputDateTimeContent,\n InputDateTimeInput,\n InputDateTimeTimeList,\n InputDateTimeTrigger,\n}\nexport type { DateFieldDetails as InputDateTimeDetails } from '../lib/date-field'\nexport {\n dateTimeStatus,\n formatDateTime,\n parseDateTime,\n type DateTimeStatus,\n} from '../lib/date-time-mask'\n"],"mappings":";;;;;;;;AA0BA,SAAS,cAAc,OAA2B;CAChD,OAAO,oBAAC,eAAD;EAAe,GAAI;EAAO,MAAK;EAAkB,UAAA;CAAU,CAAA;AACpE;AAEA,MAAM,qBAAqB;AAC3B,MAAM,uBAAuB;AAC7B,MAAM,uBAAuB;AAC7B,MAAM,wBAAwB"}
|
|
@@ -1,156 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const require_components_field = require("./field.cjs");
|
|
7
|
-
const require_components_input_group = require("./input-group.cjs");
|
|
8
|
-
const require_components_calendar = require("./calendar.cjs");
|
|
9
|
-
const require_components_popover = require("./popover.cjs");
|
|
10
|
-
let react = require("react");
|
|
11
|
-
react = require_chunk.__toESM(react);
|
|
4
|
+
const require_lib_date_field = require("../lib/date-field.cjs");
|
|
5
|
+
const require_lib_date_field_input = require("../lib/date-field-input.cjs");
|
|
12
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
13
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
14
|
-
let ictus = require("ictus");
|
|
15
|
-
let cn = require("cn");
|
|
16
7
|
//#region src/components/input-date.tsx
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
onChange?.(next);
|
|
23
|
-
}, [isControlled, onChange])];
|
|
24
|
-
}
|
|
25
|
-
function useMaskHintOnFocus(placeholder) {
|
|
26
|
-
if (!(require_components_field.useFieldContext()?.labelPosition === "floating") || placeholder !== void 0) return {};
|
|
27
|
-
return {
|
|
28
|
-
className: "placeholder:text-transparent focus:placeholder:text-gray-placeholder",
|
|
29
|
-
"data-focus-placeholder": ""
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
const InputDate = react.forwardRef(function InputDate({ calendarLabel, calendarProps, className, container, defaultOpen = false, defaultValue = "", disabled, id, onDateChange, onKeyDown, onOpenChange, onValueChange, open: openProp, pickerOnly = false, placeholder, separator = ".", value: valueProp, ...props }, ref) {
|
|
33
|
-
const inputRef = react.useRef(null);
|
|
34
|
-
const maskHint = useMaskHintOnFocus(placeholder);
|
|
35
|
-
const [text, setText] = useControllableState({
|
|
36
|
-
defaultProp: defaultValue,
|
|
37
|
-
onChange: onValueChange,
|
|
38
|
-
prop: valueProp
|
|
39
|
-
});
|
|
40
|
-
const [open, setOpenState] = useControllableState({
|
|
41
|
-
defaultProp: defaultOpen,
|
|
42
|
-
onChange: onOpenChange,
|
|
43
|
-
prop: openProp
|
|
8
|
+
function InputDate(props) {
|
|
9
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_lib_date_field.DateFieldRoot, {
|
|
10
|
+
...props,
|
|
11
|
+
slot: "input-date",
|
|
12
|
+
withTime: false
|
|
44
13
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
setOpenState(next);
|
|
50
|
-
}, [
|
|
51
|
-
calendarProps?.month,
|
|
52
|
-
setOpenState,
|
|
53
|
-
text
|
|
54
|
-
]);
|
|
55
|
-
const commit = react.useCallback((next) => {
|
|
56
|
-
if (next === text) return;
|
|
57
|
-
setText(next);
|
|
58
|
-
onDateChange?.((0, ictus.parseDate)(next));
|
|
59
|
-
}, [
|
|
60
|
-
onDateChange,
|
|
61
|
-
setText,
|
|
62
|
-
text
|
|
63
|
-
]);
|
|
64
|
-
const setInputRef = react.useCallback((node) => {
|
|
65
|
-
inputRef.current = node;
|
|
66
|
-
if (typeof ref === "function") ref(node);
|
|
67
|
-
else if (ref) ref.current = node;
|
|
68
|
-
}, [ref]);
|
|
69
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_popover.Popover, {
|
|
70
|
-
onOpenChange: setOpen,
|
|
71
|
-
open,
|
|
72
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_popover.PopoverAnchor, {
|
|
73
|
-
render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_input_group.InputGroup, { className }),
|
|
74
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_input_group.InputGroupInput, {
|
|
75
|
-
autoComplete: "off",
|
|
76
|
-
...props,
|
|
77
|
-
className: (0, cn.cn)(pickerOnly && "cursor-pointer", maskHint.className),
|
|
78
|
-
"data-focus-placeholder": maskHint["data-focus-placeholder"],
|
|
79
|
-
disabled,
|
|
80
|
-
id,
|
|
81
|
-
inputMode: pickerOnly ? void 0 : "numeric",
|
|
82
|
-
onChange: () => {},
|
|
83
|
-
onClick: pickerOnly && !disabled ? (event) => {
|
|
84
|
-
props.onClick?.(event);
|
|
85
|
-
if (!event.defaultPrevented) setOpen(true);
|
|
86
|
-
} : props.onClick,
|
|
87
|
-
onKeyDown: (event) => {
|
|
88
|
-
onKeyDown?.(event);
|
|
89
|
-
if (event.defaultPrevented) return;
|
|
90
|
-
if (event.key === "ArrowDown") {
|
|
91
|
-
event.preventDefault();
|
|
92
|
-
setOpen(true);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (pickerOnly || !(0, ictus.isDateMaskKey)(event.key)) return;
|
|
96
|
-
event.preventDefault();
|
|
97
|
-
const next = (0, ictus.apply)({
|
|
98
|
-
caret: event.currentTarget.selectionStart ?? 0,
|
|
99
|
-
key: event.key,
|
|
100
|
-
selectionEnd: event.currentTarget.selectionEnd ?? void 0,
|
|
101
|
-
separator,
|
|
102
|
-
value: event.currentTarget.value
|
|
103
|
-
});
|
|
104
|
-
commit(next.value);
|
|
105
|
-
const caret = next.caret;
|
|
106
|
-
const input = inputRef.current;
|
|
107
|
-
requestAnimationFrame(() => {
|
|
108
|
-
input?.setSelectionRange(caret, caret);
|
|
109
|
-
});
|
|
110
|
-
},
|
|
111
|
-
placeholder: placeholder ?? `DD${separator}MM${separator}YYYY`,
|
|
112
|
-
readOnly: pickerOnly,
|
|
113
|
-
ref: setInputRef,
|
|
114
|
-
spellCheck: false,
|
|
115
|
-
value: text
|
|
116
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_input_group.InputGroupAddon, {
|
|
117
|
-
align: "inline-end",
|
|
118
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_popover.PopoverTrigger, { render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_button.Button, {
|
|
119
|
-
"aria-label": calendarLabel,
|
|
120
|
-
color: "neutral",
|
|
121
|
-
disabled,
|
|
122
|
-
size: "icon-small",
|
|
123
|
-
styleVariant: "ghost",
|
|
124
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_epilot_spark_icons.CalendarMonth, {})
|
|
125
|
-
}) })
|
|
126
|
-
})]
|
|
127
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_popover.PopoverContent, {
|
|
128
|
-
align: "start",
|
|
129
|
-
"aria-label": calendarLabel,
|
|
130
|
-
className: "w-auto p-0",
|
|
131
|
-
collisionAvoidance: {
|
|
132
|
-
side: "flip",
|
|
133
|
-
fallbackAxisSide: "none"
|
|
134
|
-
},
|
|
135
|
-
container,
|
|
136
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_calendar.Calendar, {
|
|
137
|
-
...calendarProps,
|
|
138
|
-
mode: "single",
|
|
139
|
-
month: calendarProps?.month ?? month,
|
|
140
|
-
onMonthChange: (next) => {
|
|
141
|
-
calendarProps?.onMonthChange?.(next);
|
|
142
|
-
if (calendarProps?.month === void 0) setMonth(next);
|
|
143
|
-
},
|
|
144
|
-
onSelect: (next) => {
|
|
145
|
-
commit(next ? (0, ictus.formatDate)(next, separator) : "");
|
|
146
|
-
setOpen(false);
|
|
147
|
-
},
|
|
148
|
-
selected
|
|
149
|
-
})
|
|
150
|
-
})]
|
|
151
|
-
});
|
|
152
|
-
});
|
|
14
|
+
}
|
|
15
|
+
const InputDateInput = require_lib_date_field_input.DateFieldInput;
|
|
16
|
+
const InputDateTrigger = require_lib_date_field.DateFieldTrigger;
|
|
17
|
+
const InputDateContent = require_lib_date_field.DateFieldContent;
|
|
153
18
|
//#endregion
|
|
154
19
|
exports.InputDate = InputDate;
|
|
20
|
+
exports.InputDateContent = InputDateContent;
|
|
21
|
+
exports.InputDateInput = InputDateInput;
|
|
22
|
+
exports.InputDateTrigger = InputDateTrigger;
|
|
155
23
|
|
|
156
24
|
//# sourceMappingURL=input-date.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-date.cjs","names":["React","useFieldContext","Popover","PopoverAnchor","InputGroup","InputGroupInput","InputGroupAddon","PopoverTrigger","Button","CalendarMonth","PopoverContent","Calendar"],"sources":["../../src/components/input-date.tsx"],"sourcesContent":["'use client'\n\nimport { CalendarMonth } from '@epilot/spark-icons'\nimport { apply, formatDate, isDateMaskKey, parseDate } from 'ictus'\nimport * as React from 'react'\nimport { cn } from '../utils/cn'\nimport { Button } from './button'\nimport { Calendar, type CalendarProps } from './calendar'\nimport { useFieldContext } from './field'\nimport { InputGroup, InputGroupAddon, InputGroupInput } from './input-group'\nimport {\n Popover,\n PopoverAnchor,\n PopoverContent,\n PopoverTrigger,\n} from './popover'\n\nfunction useControllableState<T>({\n defaultProp,\n onChange,\n prop,\n}: {\n defaultProp: T\n onChange?: (value: T) => void\n prop?: T\n}) {\n const [uncontrolled, setUncontrolled] = React.useState(defaultProp)\n const isControlled = prop !== undefined\n const value = isControlled ? prop : uncontrolled\n\n const setValue = React.useCallback(\n (next: T) => {\n if (!isControlled) setUncontrolled(next)\n onChange?.(next)\n },\n [isControlled, onChange],\n )\n\n return [value, setValue] as const\n}\n\nfunction useMaskHintOnFocus(placeholder: string | undefined): {\n className?: string\n 'data-focus-placeholder'?: ''\n} {\n const floating = useFieldContext()?.labelPosition === 'floating'\n if (!floating || placeholder !== undefined) return {}\n return {\n className:\n 'placeholder:text-transparent focus:placeholder:text-gray-placeholder',\n 'data-focus-placeholder': '',\n }\n}\n\nexport type InputDateProps = Omit<\n React.ComponentProps<'input'>,\n 'children' | 'defaultValue' | 'onChange' | 'readOnly' | 'type' | 'value'\n> & {\n calendarLabel: string\n calendarProps?: Omit<CalendarProps, 'mode' | 'onSelect' | 'selected'>\n /** Element the calendar popup mounts into, e.g. the drawer it sits in. */\n container?: React.ComponentProps<typeof PopoverContent>['container']\n defaultOpen?: boolean\n defaultValue?: string\n onDateChange?: (date: Date | undefined) => void\n onOpenChange?: (open: boolean) => void\n onValueChange?: (value: string) => void\n open?: boolean\n pickerOnly?: boolean\n separator?: string\n value?: string\n}\n\nconst InputDate = React.forwardRef<HTMLInputElement, InputDateProps>(\n function InputDate(\n {\n calendarLabel,\n calendarProps,\n className,\n container,\n defaultOpen = false,\n defaultValue = '',\n disabled,\n id,\n onDateChange,\n onKeyDown,\n onOpenChange,\n onValueChange,\n open: openProp,\n pickerOnly = false,\n placeholder,\n separator = '.',\n value: valueProp,\n ...props\n },\n ref,\n ) {\n const inputRef = React.useRef<HTMLInputElement>(null)\n const maskHint = useMaskHintOnFocus(placeholder)\n const [text, setText] = useControllableState({\n defaultProp: defaultValue,\n onChange: onValueChange,\n prop: valueProp,\n })\n const [open, setOpenState] = useControllableState({\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n prop: openProp,\n })\n const selected = parseDate(text)\n const [month, setMonth] = React.useState<Date | undefined>(\n () => selected ?? calendarProps?.month,\n )\n const setOpen = React.useCallback(\n (next: boolean) => {\n if (next && calendarProps?.month === undefined) {\n setMonth(parseDate(text) ?? new Date())\n }\n setOpenState(next)\n },\n [calendarProps?.month, setOpenState, text],\n )\n\n const commit = React.useCallback(\n (next: string) => {\n if (next === text) return\n setText(next)\n onDateChange?.(parseDate(next))\n },\n [onDateChange, setText, text],\n )\n\n const setInputRef = React.useCallback(\n (node: HTMLInputElement | null) => {\n inputRef.current = node\n if (typeof ref === 'function') ref(node)\n else if (ref) ref.current = node\n },\n [ref],\n )\n\n return (\n <Popover onOpenChange={setOpen} open={open}>\n <PopoverAnchor render={<InputGroup className={className} />}>\n <InputGroupInput\n autoComplete=\"off\"\n {...props}\n className={cn(pickerOnly && 'cursor-pointer', maskHint.className)}\n data-focus-placeholder={maskHint['data-focus-placeholder']}\n disabled={disabled}\n id={id}\n inputMode={pickerOnly ? undefined : 'numeric'}\n onChange={() => {}}\n onClick={\n pickerOnly && !disabled\n ? (event) => {\n props.onClick?.(event)\n if (!event.defaultPrevented) setOpen(true)\n }\n : props.onClick\n }\n onKeyDown={(event) => {\n onKeyDown?.(event)\n if (event.defaultPrevented) return\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n setOpen(true)\n return\n }\n if (pickerOnly || !isDateMaskKey(event.key)) return\n event.preventDefault()\n const next = apply({\n caret: event.currentTarget.selectionStart ?? 0,\n key: event.key,\n selectionEnd: event.currentTarget.selectionEnd ?? undefined,\n separator,\n value: event.currentTarget.value,\n })\n commit(next.value)\n const caret = next.caret\n const input = inputRef.current\n requestAnimationFrame(() => {\n input?.setSelectionRange(caret, caret)\n })\n }}\n placeholder={placeholder ?? `DD${separator}MM${separator}YYYY`}\n readOnly={pickerOnly}\n ref={setInputRef}\n spellCheck={false}\n value={text}\n />\n <InputGroupAddon align=\"inline-end\">\n <PopoverTrigger\n render={\n <Button\n aria-label={calendarLabel}\n color=\"neutral\"\n disabled={disabled}\n size=\"icon-small\"\n styleVariant=\"ghost\"\n >\n <CalendarMonth />\n </Button>\n }\n />\n </InputGroupAddon>\n </PopoverAnchor>\n <PopoverContent\n align=\"start\"\n aria-label={calendarLabel}\n className=\"w-auto p-0\"\n collisionAvoidance={{ side: 'flip', fallbackAxisSide: 'none' }}\n container={container}\n >\n <Calendar\n {...calendarProps}\n mode=\"single\"\n month={calendarProps?.month ?? month}\n onMonthChange={(next) => {\n calendarProps?.onMonthChange?.(next)\n if (calendarProps?.month === undefined) setMonth(next)\n }}\n onSelect={(next) => {\n commit(next ? formatDate(next, separator) : '')\n setOpen(false)\n }}\n selected={selected}\n />\n </PopoverContent>\n </Popover>\n )\n },\n)\n\nexport { InputDate }\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAS,qBAAwB,EAC/B,aACA,UACA,QAKC;CACD,MAAM,CAAC,cAAc,mBAAmBA,MAAM,SAAS,WAAW;CAClE,MAAM,eAAe,SAAS,KAAA;CAW9B,OAAO,CAVO,eAAe,OAAO,cAEnBA,MAAM,aACpB,SAAY;EACX,IAAI,CAAC,cAAc,gBAAgB,IAAI;EACvC,WAAW,IAAI;CACjB,GACA,CAAC,cAAc,QAAQ,CAGH,CAAC;AACzB;AAEA,SAAS,mBAAmB,aAG1B;CAEA,IAAI,EADaC,yBAAAA,gBAAgB,GAAG,kBAAkB,eACrC,gBAAgB,KAAA,GAAW,OAAO,CAAC;CACpD,OAAO;EACL,WACE;EACF,0BAA0B;CAC5B;AACF;AAqBA,MAAM,YAAYD,MAAM,WACtB,SAAS,UACP,EACE,eACA,eACA,WACA,WACA,cAAc,OACd,eAAe,IACf,UACA,IACA,cACA,WACA,cACA,eACA,MAAM,UACN,aAAa,OACb,aACA,YAAY,KACZ,OAAO,WACP,GAAG,SAEL,KACA;CACA,MAAM,WAAWA,MAAM,OAAyB,IAAI;CACpD,MAAM,WAAW,mBAAmB,WAAW;CAC/C,MAAM,CAAC,MAAM,WAAW,qBAAqB;EAC3C,aAAa;EACb,UAAU;EACV,MAAM;CACR,CAAC;CACD,MAAM,CAAC,MAAM,gBAAgB,qBAAqB;EAChD,aAAa;EACb,UAAU;EACV,MAAM;CACR,CAAC;CACD,MAAM,YAAA,GAAA,MAAA,WAAqB,IAAI;CAC/B,MAAM,CAAC,OAAO,YAAYA,MAAM,eACxB,YAAY,eAAe,KACnC;CACA,MAAM,UAAUA,MAAM,aACnB,SAAkB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.cjs","names":["DateFieldRoot","DateFieldInput","DateFieldTrigger","DateFieldContent"],"sources":["../../src/components/input-date.tsx"],"sourcesContent":["'use client'\n\nimport {\n DateFieldContent,\n DateFieldRoot,\n type DateFieldRootProps,\n DateFieldTrigger,\n type DateFieldTriggerProps,\n} from '../lib/date-field'\nimport {\n DateFieldInput,\n type DateFieldInputProps,\n} from '../lib/date-field-input'\n\nexport type InputDateProps = DateFieldRootProps\nexport type InputDateInputProps = DateFieldInputProps\nexport type InputDateTriggerProps = DateFieldTriggerProps\nexport type InputDateContentProps = React.ComponentProps<\n typeof DateFieldContent\n>\n\nfunction InputDate(props: InputDateProps) {\n return <DateFieldRoot {...props} slot=\"input-date\" withTime={false} />\n}\n\nconst InputDateInput = DateFieldInput\nconst InputDateTrigger = DateFieldTrigger\nconst InputDateContent = DateFieldContent\n\nexport { InputDate, InputDateContent, InputDateInput, InputDateTrigger }\nexport type { DateFieldDetails as InputDateDetails } from '../lib/date-field'\n"],"mappings":";;;;;;;AAqBA,SAAS,UAAU,OAAuB;CACxC,OAAO,iBAAA,GAAA,kBAAA,KAACA,uBAAAA,eAAD;EAAe,GAAI;EAAO,MAAK;EAAa,UAAU;CAAQ,CAAA;AACvE;AAEA,MAAM,iBAAiBC,6BAAAA;AACvB,MAAM,mBAAmBC,uBAAAA;AACzB,MAAM,mBAAmBC,uBAAAA"}
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import * as React$1 from "react";
|
|
3
|
+
import { DateFieldContent, DateFieldDetails, DateFieldRootProps, DateFieldTrigger, DateFieldTriggerProps } from "../lib/date-field.cjs";
|
|
4
|
+
import { DateFieldInputProps } from "../lib/date-field-input.cjs";
|
|
6
5
|
|
|
7
6
|
//#region src/components/input-date.d.ts
|
|
8
|
-
type InputDateProps =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
onValueChange?: (value: string) => void;
|
|
17
|
-
open?: boolean;
|
|
18
|
-
pickerOnly?: boolean;
|
|
19
|
-
separator?: string;
|
|
20
|
-
value?: string;
|
|
21
|
-
};
|
|
22
|
-
declare const InputDate: React$1.ForwardRefExoticComponent<Omit<InputDateProps, "ref"> & React$1.RefAttributes<HTMLInputElement>>;
|
|
7
|
+
type InputDateProps = DateFieldRootProps;
|
|
8
|
+
type InputDateInputProps = DateFieldInputProps;
|
|
9
|
+
type InputDateTriggerProps = DateFieldTriggerProps;
|
|
10
|
+
type InputDateContentProps = React.ComponentProps<typeof DateFieldContent>;
|
|
11
|
+
declare function InputDate(props: InputDateProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare const InputDateInput: import("react").ForwardRefExoticComponent<Omit<DateFieldInputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
13
|
+
declare const InputDateTrigger: typeof DateFieldTrigger;
|
|
14
|
+
declare const InputDateContent: typeof DateFieldContent;
|
|
23
15
|
//#endregion
|
|
24
|
-
export { InputDate, InputDateProps };
|
|
16
|
+
export { InputDate, InputDateContent, InputDateContentProps, type DateFieldDetails as InputDateDetails, InputDateInput, InputDateInputProps, InputDateProps, InputDateTrigger, InputDateTriggerProps };
|
|
25
17
|
//# sourceMappingURL=input-date.d.cts.map
|