@epilot/spark-ui 0.31.0 → 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.d.cts +1 -1
- package/dist/components/alert-dialog.d.ts +1 -1
- package/dist/components/attachment.cjs +1 -1
- package/dist/components/attachment.d.cts +2 -2
- package/dist/components/attachment.d.ts +2 -2
- package/dist/components/attachment.js +1 -1
- package/dist/components/autocomplete.cjs +8 -6
- 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 +8 -6
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/badge.cjs +1 -1
- package/dist/components/badge.js +1 -1
- 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 +1 -1
- package/dist/components/box.cjs.map +1 -1
- package/dist/components/box.js +2 -2
- 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 +1 -1
- package/dist/components/bubble.d.cts +1 -1
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/bubble.js +1 -1
- package/dist/components/button-group.cjs +1 -1
- package/dist/components/button-group.js +1 -1
- package/dist/components/button.cjs +27 -10
- package/dist/components/button.cjs.map +1 -1
- package/dist/components/button.d.cts +3 -28
- package/dist/components/button.d.ts +3 -28
- package/dist/components/button.js +27 -11
- 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 +5 -4
- 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 +6 -5
- package/dist/components/card.js.map +1 -1
- package/dist/components/checkbox-card.cjs +177 -0
- package/dist/components/checkbox-card.cjs.map +1 -0
- package/dist/components/checkbox-card.d.cts +47 -0
- package/dist/components/checkbox-card.d.ts +47 -0
- package/dist/components/checkbox-card.js +170 -0
- package/dist/components/checkbox-card.js.map +1 -0
- package/dist/components/checkbox.cjs +5 -18
- package/dist/components/checkbox.cjs.map +1 -1
- package/dist/components/checkbox.js +6 -19
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/combobox.cjs +3 -2
- package/dist/components/combobox.cjs.map +1 -1
- package/dist/components/combobox.js +3 -2
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/drawer.cjs +1 -1
- package/dist/components/drawer.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 +68 -10
- 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 +67 -10
- 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/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 +5 -4
- 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 +4 -3
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input-otp.cjs +4 -4
- package/dist/components/input-otp.cjs.map +1 -1
- package/dist/components/input-otp.js +4 -4
- package/dist/components/input-otp.js.map +1 -1
- package/dist/components/input.cjs +5 -3
- 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 +5 -3
- package/dist/components/input.js.map +1 -1
- package/dist/components/line-chart.cjs +3 -3
- package/dist/components/line-chart.js +4 -4
- package/dist/components/link.cjs +31 -0
- package/dist/components/link.cjs.map +1 -0
- package/dist/components/link.d.cts +16 -0
- package/dist/components/link.d.ts +16 -0
- package/dist/components/link.js +28 -0
- package/dist/components/link.js.map +1 -0
- package/dist/components/list.cjs +1 -1
- package/dist/components/list.js +1 -1
- package/dist/components/marker.cjs +1 -1
- package/dist/components/marker.d.cts +1 -1
- package/dist/components/marker.d.ts +1 -1
- package/dist/components/marker.js +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 +1 -1
- package/dist/components/page-header.cjs +1 -1
- package/dist/components/page-header.d.cts +1 -1
- package/dist/components/page-header.d.ts +1 -1
- 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.d.cts +1 -1
- package/dist/components/period-tabs.d.ts +1 -1
- package/dist/components/pill.cjs +42 -23
- 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 +42 -24
- 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 +3 -3
- package/dist/components/power-history-chart.js +4 -4
- package/dist/components/power-network.js +1 -1
- 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/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/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 +2 -1
- 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 +2 -1
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/tabs.cjs +2 -2
- package/dist/components/tabs.cjs.map +1 -1
- package/dist/components/tabs.js +1 -1
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/textarea.cjs +9 -3
- package/dist/components/textarea.cjs.map +1 -1
- package/dist/components/textarea.js +9 -3
- 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/toggle.d.cts +1 -1
- package/dist/components/toggle.d.ts +1 -1
- package/dist/components/tooltip.cjs +2 -1
- 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 +2 -1
- package/dist/components/tooltip.js.map +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
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { r as ButtonProps } from "../button-DBcEcIMk.cjs";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import { Tabs } from "@base-ui/react/tabs";
|
|
6
|
+
|
|
7
|
+
//#region src/components/image-carousel.d.ts
|
|
8
|
+
type ImageCarouselProps = Omit<Tabs.Root.Props, 'value' | 'defaultValue' | 'onValueChange' | 'orientation'> & {
|
|
9
|
+
/** Names the carousel for screen readers, in the reader's language. */'aria-label': string; /** The 0-based index of the slide on view. Use when the carousel is controlled. */
|
|
10
|
+
value?: number; /** The slide on view first. Default: 0 */
|
|
11
|
+
defaultValue?: number; /** Called with the slide's index after an arrow, a dot or a swipe moves to it. */
|
|
12
|
+
onValueChange?: (value: number) => void;
|
|
13
|
+
};
|
|
14
|
+
type NamedProps<Props> = Props & {
|
|
15
|
+
/** Names the part for screen readers, in the reader's language. */'aria-label': string;
|
|
16
|
+
};
|
|
17
|
+
declare const ImageCarousel: React$1.ForwardRefExoticComponent<Omit<ImageCarouselProps, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
|
|
18
|
+
type ImageCarouselTrackProps = React$1.ComponentProps<'div'>;
|
|
19
|
+
declare const ImageCarouselTrack: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedHTMLProps<React$1.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
|
|
20
|
+
type ImageCarouselSlideProps = NamedProps<React$1.ComponentProps<'div'>>;
|
|
21
|
+
declare function ImageCarouselSlide({
|
|
22
|
+
className,
|
|
23
|
+
...props
|
|
24
|
+
}: ImageCarouselSlideProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
type ImageCarouselPreviousProps = NamedProps<ButtonProps>;
|
|
26
|
+
declare function ImageCarouselPrevious({
|
|
27
|
+
className,
|
|
28
|
+
children,
|
|
29
|
+
onClick,
|
|
30
|
+
...props
|
|
31
|
+
}: ImageCarouselPreviousProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
type ImageCarouselNextProps = NamedProps<ButtonProps>;
|
|
33
|
+
declare function ImageCarouselNext({
|
|
34
|
+
className,
|
|
35
|
+
children,
|
|
36
|
+
onClick,
|
|
37
|
+
...props
|
|
38
|
+
}: ImageCarouselNextProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
type ImageCarouselDotsProps = Tabs.List.Props;
|
|
40
|
+
declare function ImageCarouselDots({
|
|
41
|
+
className,
|
|
42
|
+
...props
|
|
43
|
+
}: ImageCarouselDotsProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
type ImageCarouselDotProps = NamedProps<Omit<Tabs.Tab.Props, 'children'>> & {
|
|
45
|
+
/** The 0-based index of the slide this dot shows. */value: number;
|
|
46
|
+
};
|
|
47
|
+
declare function ImageCarouselDot({
|
|
48
|
+
className,
|
|
49
|
+
value,
|
|
50
|
+
...props
|
|
51
|
+
}: ImageCarouselDotProps): import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { ImageCarousel, ImageCarouselDot, type ImageCarouselDotProps, ImageCarouselDots, type ImageCarouselDotsProps, ImageCarouselNext, type ImageCarouselNextProps, ImageCarouselPrevious, type ImageCarouselPreviousProps, type ImageCarouselProps, ImageCarouselSlide, type ImageCarouselSlideProps, ImageCarouselTrack, type ImageCarouselTrackProps };
|
|
54
|
+
//# sourceMappingURL=image-carousel.d.cts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { r as ButtonProps } from "../button-B_RNHEc7.js";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import { Tabs } from "@base-ui/react/tabs";
|
|
6
|
+
|
|
7
|
+
//#region src/components/image-carousel.d.ts
|
|
8
|
+
type ImageCarouselProps = Omit<Tabs.Root.Props, 'value' | 'defaultValue' | 'onValueChange' | 'orientation'> & {
|
|
9
|
+
/** Names the carousel for screen readers, in the reader's language. */'aria-label': string; /** The 0-based index of the slide on view. Use when the carousel is controlled. */
|
|
10
|
+
value?: number; /** The slide on view first. Default: 0 */
|
|
11
|
+
defaultValue?: number; /** Called with the slide's index after an arrow, a dot or a swipe moves to it. */
|
|
12
|
+
onValueChange?: (value: number) => void;
|
|
13
|
+
};
|
|
14
|
+
type NamedProps<Props> = Props & {
|
|
15
|
+
/** Names the part for screen readers, in the reader's language. */'aria-label': string;
|
|
16
|
+
};
|
|
17
|
+
declare const ImageCarousel: React$1.ForwardRefExoticComponent<Omit<ImageCarouselProps, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
|
|
18
|
+
type ImageCarouselTrackProps = React$1.ComponentProps<'div'>;
|
|
19
|
+
declare const ImageCarouselTrack: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedHTMLProps<React$1.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
|
|
20
|
+
type ImageCarouselSlideProps = NamedProps<React$1.ComponentProps<'div'>>;
|
|
21
|
+
declare function ImageCarouselSlide({
|
|
22
|
+
className,
|
|
23
|
+
...props
|
|
24
|
+
}: ImageCarouselSlideProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
type ImageCarouselPreviousProps = NamedProps<ButtonProps>;
|
|
26
|
+
declare function ImageCarouselPrevious({
|
|
27
|
+
className,
|
|
28
|
+
children,
|
|
29
|
+
onClick,
|
|
30
|
+
...props
|
|
31
|
+
}: ImageCarouselPreviousProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
type ImageCarouselNextProps = NamedProps<ButtonProps>;
|
|
33
|
+
declare function ImageCarouselNext({
|
|
34
|
+
className,
|
|
35
|
+
children,
|
|
36
|
+
onClick,
|
|
37
|
+
...props
|
|
38
|
+
}: ImageCarouselNextProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
type ImageCarouselDotsProps = Tabs.List.Props;
|
|
40
|
+
declare function ImageCarouselDots({
|
|
41
|
+
className,
|
|
42
|
+
...props
|
|
43
|
+
}: ImageCarouselDotsProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
type ImageCarouselDotProps = NamedProps<Omit<Tabs.Tab.Props, 'children'>> & {
|
|
45
|
+
/** The 0-based index of the slide this dot shows. */value: number;
|
|
46
|
+
};
|
|
47
|
+
declare function ImageCarouselDot({
|
|
48
|
+
className,
|
|
49
|
+
value,
|
|
50
|
+
...props
|
|
51
|
+
}: ImageCarouselDotProps): import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { ImageCarousel, ImageCarouselDot, type ImageCarouselDotProps, ImageCarouselDots, type ImageCarouselDotsProps, ImageCarouselNext, type ImageCarouselNextProps, ImageCarouselPrevious, type ImageCarouselPreviousProps, type ImageCarouselProps, ImageCarouselSlide, type ImageCarouselSlideProps, ImageCarouselTrack, type ImageCarouselTrackProps };
|
|
54
|
+
//# sourceMappingURL=image-carousel.d.ts.map
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../utils/cn.js";
|
|
4
|
+
import { useIsomorphicLayoutEffect } from "../hooks/use-isomorphic-layout-effect.js";
|
|
5
|
+
import { useReducedMotion } from "../hooks/use-reduced-motion.js";
|
|
6
|
+
import { Button } from "./button.js";
|
|
7
|
+
import * as React$1 from "react";
|
|
8
|
+
import { ChevronLeft, ChevronRight } from "@epilot/spark-icons";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
import { Tabs } from "@base-ui/react/tabs";
|
|
11
|
+
//#region src/components/image-carousel.tsx
|
|
12
|
+
const ImageCarouselContext = React$1.createContext(null);
|
|
13
|
+
function useImageCarousel(part) {
|
|
14
|
+
const context = React$1.useContext(ImageCarouselContext);
|
|
15
|
+
if (!context) throw new Error(`${part} must be placed inside ImageCarousel.`);
|
|
16
|
+
return context;
|
|
17
|
+
}
|
|
18
|
+
const SlideIndexContext = React$1.createContext(0);
|
|
19
|
+
const toSlideRange = (index, count) => count ? Math.min(Math.max(index, 0), count - 1) : index;
|
|
20
|
+
const ImageCarousel = React$1.forwardRef(({ value: valueProp, defaultValue = 0, onValueChange, className, ...props }, ref) => {
|
|
21
|
+
const [uncontrolledValue, setUncontrolledValue] = React$1.useState(defaultValue);
|
|
22
|
+
const [count, setCount] = React$1.useState(0);
|
|
23
|
+
const value = toSlideRange(valueProp ?? uncontrolledValue, count);
|
|
24
|
+
const setValue = React$1.useCallback((next) => {
|
|
25
|
+
if (next === value) return;
|
|
26
|
+
if (valueProp === void 0) setUncontrolledValue(next);
|
|
27
|
+
onValueChange?.(next);
|
|
28
|
+
}, [
|
|
29
|
+
value,
|
|
30
|
+
valueProp,
|
|
31
|
+
onValueChange
|
|
32
|
+
]);
|
|
33
|
+
const context = React$1.useMemo(() => ({
|
|
34
|
+
value,
|
|
35
|
+
count,
|
|
36
|
+
setValue,
|
|
37
|
+
setCount
|
|
38
|
+
}), [
|
|
39
|
+
value,
|
|
40
|
+
count,
|
|
41
|
+
setValue
|
|
42
|
+
]);
|
|
43
|
+
return /* @__PURE__ */ jsx(ImageCarouselContext.Provider, {
|
|
44
|
+
value: context,
|
|
45
|
+
children: /* @__PURE__ */ jsx(Tabs.Root, {
|
|
46
|
+
ref,
|
|
47
|
+
role: "region",
|
|
48
|
+
"data-slot": "image-carousel",
|
|
49
|
+
className: cn("group/carousel relative", className),
|
|
50
|
+
value,
|
|
51
|
+
onValueChange: (next) => setValue(next),
|
|
52
|
+
...props
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
ImageCarousel.displayName = "ImageCarousel";
|
|
57
|
+
/** The index of the slide the track rests on, or undefined between slides. */
|
|
58
|
+
function restingSlide(track) {
|
|
59
|
+
const width = track.clientWidth;
|
|
60
|
+
if (!width) return void 0;
|
|
61
|
+
const index = Math.round(track.scrollLeft / width);
|
|
62
|
+
return Math.abs(track.scrollLeft - index * width) < 1 ? index : void 0;
|
|
63
|
+
}
|
|
64
|
+
const ImageCarouselTrack = React$1.forwardRef(({ className, children, onScroll, ...props }, ref) => {
|
|
65
|
+
const { value, setValue, setCount } = useImageCarousel("ImageCarouselTrack");
|
|
66
|
+
const trackRef = React$1.useRef(null);
|
|
67
|
+
const isFirstScroll = React$1.useRef(true);
|
|
68
|
+
const reducedMotion = useReducedMotion();
|
|
69
|
+
const slides = React$1.Children.toArray(children);
|
|
70
|
+
const count = slides.length;
|
|
71
|
+
useIsomorphicLayoutEffect(() => {
|
|
72
|
+
setCount(count);
|
|
73
|
+
}, [count, setCount]);
|
|
74
|
+
React$1.useImperativeHandle(ref, () => trackRef.current);
|
|
75
|
+
React$1.useEffect(() => {
|
|
76
|
+
const instant = isFirstScroll.current || reducedMotion;
|
|
77
|
+
isFirstScroll.current = false;
|
|
78
|
+
const track = trackRef.current;
|
|
79
|
+
if (!track?.clientWidth || restingSlide(track) === value) return;
|
|
80
|
+
track.scrollTo?.({
|
|
81
|
+
left: value * track.clientWidth,
|
|
82
|
+
behavior: instant ? "auto" : "smooth"
|
|
83
|
+
});
|
|
84
|
+
}, [value, reducedMotion]);
|
|
85
|
+
return /* @__PURE__ */ jsx("div", {
|
|
86
|
+
ref: trackRef,
|
|
87
|
+
"data-slot": "image-carousel-track",
|
|
88
|
+
tabIndex: 0,
|
|
89
|
+
className: cn("no-scrollbar flex snap-x snap-mandatory overflow-x-auto rounded-md focus-visible:focus-outline", className),
|
|
90
|
+
onScroll: (event) => {
|
|
91
|
+
onScroll?.(event);
|
|
92
|
+
const index = restingSlide(event.currentTarget);
|
|
93
|
+
if (index !== void 0) setValue(Math.min(index, count - 1));
|
|
94
|
+
},
|
|
95
|
+
...props,
|
|
96
|
+
children: slides.map((slide, index) => /* @__PURE__ */ jsx(SlideIndexContext.Provider, {
|
|
97
|
+
value: index,
|
|
98
|
+
children: slide
|
|
99
|
+
}, React$1.isValidElement(slide) ? slide.key : index))
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
ImageCarouselTrack.displayName = "ImageCarouselTrack";
|
|
103
|
+
function ImageCarouselSlide({ className, ...props }) {
|
|
104
|
+
const { value } = useImageCarousel("ImageCarouselSlide");
|
|
105
|
+
return /* @__PURE__ */ jsx("div", {
|
|
106
|
+
role: "group",
|
|
107
|
+
"aria-hidden": React$1.useContext(SlideIndexContext) !== value,
|
|
108
|
+
"data-slot": "image-carousel-slide",
|
|
109
|
+
className: cn("w-full shrink-0 snap-start", className),
|
|
110
|
+
...props
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const arrowClasses = "absolute top-1/2 -translate-y-1/2 rounded-full shadow-sm";
|
|
114
|
+
function ImageCarouselPrevious({ className, children, onClick, ...props }) {
|
|
115
|
+
const { value, setValue } = useImageCarousel("ImageCarouselPrevious");
|
|
116
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
117
|
+
"data-slot": "image-carousel-previous",
|
|
118
|
+
className: cn(arrowClasses, "left-2", className),
|
|
119
|
+
color: "neutral",
|
|
120
|
+
disabled: value <= 0,
|
|
121
|
+
focusableWhenDisabled: true,
|
|
122
|
+
size: "icon-small",
|
|
123
|
+
styleVariant: "surface",
|
|
124
|
+
onClick: (event) => {
|
|
125
|
+
onClick?.(event);
|
|
126
|
+
if (!event.defaultPrevented) setValue(value - 1);
|
|
127
|
+
},
|
|
128
|
+
...props,
|
|
129
|
+
children: children ?? /* @__PURE__ */ jsx(ChevronLeft, {})
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function ImageCarouselNext({ className, children, onClick, ...props }) {
|
|
133
|
+
const { value, count, setValue } = useImageCarousel("ImageCarouselNext");
|
|
134
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
135
|
+
"data-slot": "image-carousel-next",
|
|
136
|
+
className: cn(arrowClasses, "right-2", className),
|
|
137
|
+
color: "neutral",
|
|
138
|
+
disabled: value >= count - 1,
|
|
139
|
+
focusableWhenDisabled: true,
|
|
140
|
+
size: "icon-small",
|
|
141
|
+
styleVariant: "surface",
|
|
142
|
+
onClick: (event) => {
|
|
143
|
+
onClick?.(event);
|
|
144
|
+
if (!event.defaultPrevented) setValue(value + 1);
|
|
145
|
+
},
|
|
146
|
+
...props,
|
|
147
|
+
children: children ?? /* @__PURE__ */ jsx(ChevronRight, {})
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function ImageCarouselDots({ className, ...props }) {
|
|
151
|
+
return /* @__PURE__ */ jsx(Tabs.List, {
|
|
152
|
+
activateOnFocus: true,
|
|
153
|
+
"data-slot": "image-carousel-dots",
|
|
154
|
+
className: cn("absolute bottom-2 left-1/2 flex -translate-x-1/2 rounded-full bg-gray-2 px-1 shadow-sm", className),
|
|
155
|
+
...props
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function ImageCarouselDot({ className, value, ...props }) {
|
|
159
|
+
useImageCarousel("ImageCarouselDot");
|
|
160
|
+
return /* @__PURE__ */ jsx(Tabs.Tab, {
|
|
161
|
+
"data-slot": "image-carousel-dot",
|
|
162
|
+
className: cn("group/dot grid size-[24px] cursor-pointer place-items-center rounded-full focus-visible:focus-outline", className),
|
|
163
|
+
value,
|
|
164
|
+
...props,
|
|
165
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
166
|
+
"aria-hidden": "true",
|
|
167
|
+
className: "size-2 rounded-full bg-gray-a7 transition-colors group-hover/dot:bg-gray-a9 group-data-active/dot:bg-primary motion-reduce:transition-none"
|
|
168
|
+
})
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
export { ImageCarousel, ImageCarouselDot, ImageCarouselDots, ImageCarouselNext, ImageCarouselPrevious, ImageCarouselSlide, ImageCarouselTrack };
|
|
173
|
+
|
|
174
|
+
//# sourceMappingURL=image-carousel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-carousel.js","names":["React","TabsPrimitive"],"sources":["../../src/components/image-carousel.tsx"],"sourcesContent":["'use client'\n\nimport { Tabs as TabsPrimitive } from '@base-ui/react/tabs'\nimport { ChevronLeft, ChevronRight } from '@epilot/spark-icons'\nimport * as React from 'react'\nimport { useIsomorphicLayoutEffect } from '../hooks/use-isomorphic-layout-effect'\nimport { useReducedMotion } from '../hooks/use-reduced-motion'\nimport { cn } from '../utils/cn'\nimport { Button, type ButtonProps } from './button'\n\ntype ImageCarouselProps = Omit<\n TabsPrimitive.Root.Props,\n 'value' | 'defaultValue' | 'onValueChange' | 'orientation'\n> & {\n /** Names the carousel for screen readers, in the reader's language. */\n 'aria-label': string\n /** The 0-based index of the slide on view. Use when the carousel is controlled. */\n value?: number\n /** The slide on view first. Default: 0 */\n defaultValue?: number\n /** Called with the slide's index after an arrow, a dot or a swipe moves to it. */\n onValueChange?: (value: number) => void\n}\n\ninterface ImageCarouselContextValue {\n value: number\n count: number\n setValue: (value: number) => void\n setCount: (count: number) => void\n}\n\nconst ImageCarouselContext =\n React.createContext<ImageCarouselContextValue | null>(null)\n\nfunction useImageCarousel(part: string) {\n const context = React.useContext(ImageCarouselContext)\n if (!context) throw new Error(`${part} must be placed inside ImageCarousel.`)\n return context\n}\n\nconst SlideIndexContext = React.createContext(0)\n\ntype NamedProps<Props> = Props & {\n /** Names the part for screen readers, in the reader's language. */\n 'aria-label': string\n}\n\nconst toSlideRange = (index: number, count: number) =>\n count ? Math.min(Math.max(index, 0), count - 1) : index\n\nconst ImageCarousel = React.forwardRef<HTMLDivElement, ImageCarouselProps>(\n (\n { value: valueProp, defaultValue = 0, onValueChange, className, ...props },\n ref,\n ) => {\n const [uncontrolledValue, setUncontrolledValue] =\n React.useState(defaultValue)\n const [count, setCount] = React.useState(0)\n const value = toSlideRange(valueProp ?? uncontrolledValue, count)\n\n const setValue = React.useCallback(\n (next: number) => {\n if (next === value) return\n if (valueProp === undefined) setUncontrolledValue(next)\n onValueChange?.(next)\n },\n [value, valueProp, onValueChange],\n )\n const context = React.useMemo(\n () => ({ value, count, setValue, setCount }),\n [value, count, setValue],\n )\n\n return (\n <ImageCarouselContext.Provider value={context}>\n <TabsPrimitive.Root\n ref={ref}\n role=\"region\"\n data-slot=\"image-carousel\"\n className={cn('group/carousel relative', className)}\n value={value}\n onValueChange={(next: number) => setValue(next)}\n {...props}\n />\n </ImageCarouselContext.Provider>\n )\n },\n)\n\nImageCarousel.displayName = 'ImageCarousel'\n\ntype ImageCarouselTrackProps = React.ComponentProps<'div'>\n\n/** The index of the slide the track rests on, or undefined between slides. */\nfunction restingSlide(track: HTMLElement) {\n const width = track.clientWidth\n if (!width) return undefined\n const index = Math.round(track.scrollLeft / width)\n return Math.abs(track.scrollLeft - index * width) < 1 ? index : undefined\n}\n\nconst ImageCarouselTrack = React.forwardRef<\n HTMLDivElement,\n ImageCarouselTrackProps\n>(({ className, children, onScroll, ...props }, ref) => {\n const { value, setValue, setCount } = useImageCarousel('ImageCarouselTrack')\n const trackRef = React.useRef<HTMLDivElement>(null)\n const isFirstScroll = React.useRef(true)\n const reducedMotion = useReducedMotion()\n const slides = React.Children.toArray(children)\n const count = slides.length\n\n useIsomorphicLayoutEffect(() => {\n setCount(count)\n }, [count, setCount])\n\n React.useImperativeHandle(ref, () => trackRef.current as HTMLDivElement)\n\n React.useEffect(() => {\n const instant = isFirstScroll.current || reducedMotion\n isFirstScroll.current = false\n const track = trackRef.current\n if (!track?.clientWidth || restingSlide(track) === value) return\n track.scrollTo?.({\n left: value * track.clientWidth,\n behavior: instant ? 'auto' : 'smooth',\n })\n }, [value, reducedMotion])\n\n return (\n <div\n ref={trackRef}\n data-slot=\"image-carousel-track\"\n // a scrolling region must be reachable by keyboard (WCAG 2.1.1)\n // oxlint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- see above\n tabIndex={0}\n className={cn(\n 'no-scrollbar flex snap-x snap-mandatory overflow-x-auto rounded-md focus-visible:focus-outline',\n className,\n )}\n onScroll={(event) => {\n onScroll?.(event)\n const index = restingSlide(event.currentTarget)\n if (index !== undefined) setValue(Math.min(index, count - 1))\n }}\n {...props}\n >\n {slides.map((slide, index) => (\n <SlideIndexContext.Provider\n key={React.isValidElement(slide) ? slide.key : index}\n value={index}\n >\n {slide}\n </SlideIndexContext.Provider>\n ))}\n </div>\n )\n})\n\nImageCarouselTrack.displayName = 'ImageCarouselTrack'\n\ntype ImageCarouselSlideProps = NamedProps<React.ComponentProps<'div'>>\n\nfunction ImageCarouselSlide({ className, ...props }: ImageCarouselSlideProps) {\n const { value } = useImageCarousel('ImageCarouselSlide')\n const index = React.useContext(SlideIndexContext)\n\n return (\n <div\n role=\"group\"\n aria-hidden={index !== value}\n data-slot=\"image-carousel-slide\"\n className={cn('w-full shrink-0 snap-start', className)}\n {...props}\n />\n )\n}\n\ntype ImageCarouselPreviousProps = NamedProps<ButtonProps>\n\nconst arrowClasses = 'absolute top-1/2 -translate-y-1/2 rounded-full shadow-sm'\n\nfunction ImageCarouselPrevious({\n className,\n children,\n onClick,\n ...props\n}: ImageCarouselPreviousProps) {\n const { value, setValue } = useImageCarousel('ImageCarouselPrevious')\n\n return (\n <Button\n data-slot=\"image-carousel-previous\"\n className={cn(arrowClasses, 'left-2', className)}\n color=\"neutral\"\n disabled={value <= 0}\n focusableWhenDisabled\n size=\"icon-small\"\n styleVariant=\"surface\"\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented) setValue(value - 1)\n }}\n {...props}\n >\n {children ?? <ChevronLeft />}\n </Button>\n )\n}\n\ntype ImageCarouselNextProps = NamedProps<ButtonProps>\n\nfunction ImageCarouselNext({\n className,\n children,\n onClick,\n ...props\n}: ImageCarouselNextProps) {\n const { value, count, setValue } = useImageCarousel('ImageCarouselNext')\n\n return (\n <Button\n data-slot=\"image-carousel-next\"\n className={cn(arrowClasses, 'right-2', className)}\n color=\"neutral\"\n disabled={value >= count - 1}\n focusableWhenDisabled\n size=\"icon-small\"\n styleVariant=\"surface\"\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented) setValue(value + 1)\n }}\n {...props}\n >\n {children ?? <ChevronRight />}\n </Button>\n )\n}\n\ntype ImageCarouselDotsProps = TabsPrimitive.List.Props\n\nfunction ImageCarouselDots({ className, ...props }: ImageCarouselDotsProps) {\n return (\n <TabsPrimitive.List\n activateOnFocus\n data-slot=\"image-carousel-dots\"\n className={cn(\n 'absolute bottom-2 left-1/2 flex -translate-x-1/2 rounded-full bg-gray-2 px-1 shadow-sm',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype ImageCarouselDotProps = NamedProps<\n Omit<TabsPrimitive.Tab.Props, 'children'>\n> & {\n /** The 0-based index of the slide this dot shows. */\n value: number\n}\n\nfunction ImageCarouselDot({\n className,\n value,\n ...props\n}: ImageCarouselDotProps) {\n useImageCarousel('ImageCarouselDot')\n\n return (\n <TabsPrimitive.Tab\n data-slot=\"image-carousel-dot\"\n // a fixed 24px target around the small dot (WCAG 2.5.8), at any scaling\n className={cn(\n 'group/dot grid size-[24px] cursor-pointer place-items-center rounded-full focus-visible:focus-outline',\n className,\n )}\n value={value}\n {...props}\n >\n <span\n aria-hidden=\"true\"\n className=\"size-2 rounded-full bg-gray-a7 transition-colors group-hover/dot:bg-gray-a9 group-data-active/dot:bg-primary motion-reduce:transition-none\"\n />\n </TabsPrimitive.Tab>\n )\n}\n\nexport {\n ImageCarousel,\n ImageCarouselDot,\n ImageCarouselDots,\n ImageCarouselNext,\n ImageCarouselPrevious,\n ImageCarouselSlide,\n ImageCarouselTrack,\n}\nexport type {\n ImageCarouselDotProps,\n ImageCarouselDotsProps,\n ImageCarouselNextProps,\n ImageCarouselPreviousProps,\n ImageCarouselProps,\n ImageCarouselSlideProps,\n ImageCarouselTrackProps,\n}\n"],"mappings":";;;;;;;;;;;AA+BA,MAAM,uBACJA,QAAM,cAAgD,IAAI;AAE5D,SAAS,iBAAiB,MAAc;CACtC,MAAM,UAAUA,QAAM,WAAW,oBAAoB;CACrD,IAAI,CAAC,SAAS,M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A;CACgB,CAAA;AAEvB"}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
react = require_chunk.__toESM(react);
|
|
6
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
6
|
let class_variance_authority = require("class-variance-authority");
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
8
|
let cn = require("cn");
|
|
9
9
|
//#region src/components/info-block.tsx
|
|
10
10
|
const infoBlockVariants = (0, class_variance_authority.cva)("flex items-center gap-3", {
|
|
@@ -5,7 +5,7 @@ import { VariantProps } from "class-variance-authority";
|
|
|
5
5
|
|
|
6
6
|
//#region src/components/info-block.d.ts
|
|
7
7
|
declare const InfoBlock: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & VariantProps<(props?: ({
|
|
8
|
-
variant?: "
|
|
8
|
+
variant?: "bare" | "default" | null | undefined;
|
|
9
9
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string> & React$1.RefAttributes<HTMLDivElement>>;
|
|
10
10
|
declare const InfoBlockIcon: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
|
|
11
11
|
declare const InfoBlockContent: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
|
|
@@ -5,7 +5,7 @@ import { VariantProps } from "class-variance-authority";
|
|
|
5
5
|
|
|
6
6
|
//#region src/components/info-block.d.ts
|
|
7
7
|
declare const InfoBlock: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & VariantProps<(props?: ({
|
|
8
|
-
variant?: "
|
|
8
|
+
variant?: "bare" | "default" | null | undefined;
|
|
9
9
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string> & React$1.RefAttributes<HTMLDivElement>>;
|
|
10
10
|
declare const InfoBlockIcon: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
|
|
11
11
|
declare const InfoBlockContent: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import * as React$1 from "react";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
4
|
import { cva } from "class-variance-authority";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/info-block.tsx
|
|
7
7
|
const infoBlockVariants = cva("flex items-center gap-3", {
|
|
8
8
|
variants: { variant: {
|
|
@@ -1,215 +1,29 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
5
|
-
const require_components_button = require("./button.cjs");
|
|
6
|
-
const require_components_input_group = require("./input-group.cjs");
|
|
7
|
-
const require_lib_calendar_day_button = require("../lib/calendar-day-button.cjs");
|
|
8
|
-
const require_components_calendar = require("./calendar.cjs");
|
|
9
4
|
const require_lib_date_time_mask = require("../lib/date-time-mask.cjs");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
react = require_chunk.__toESM(react);
|
|
14
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
5
|
+
const require_lib_date_field = require("../lib/date-field.cjs");
|
|
6
|
+
const require_lib_date_field_input = require("../lib/date-field-input.cjs");
|
|
7
|
+
const require_lib_date_field_time_list = require("../lib/date-field-time-list.cjs");
|
|
15
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
16
|
-
let ictus_time = require("ictus/time");
|
|
17
|
-
let cn = require("cn");
|
|
18
9
|
//#region src/components/input-date-time.tsx
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
onChange?.(next);
|
|
25
|
-
}, [isControlled, onChange])];
|
|
26
|
-
}
|
|
27
|
-
const today = () => /* @__PURE__ */ new Date();
|
|
28
|
-
const placeholderOf = (separator, withTime) => `DD${separator}MM${separator}YYYY${withTime ? ", HH:MM" : ""}`;
|
|
29
|
-
/** The field text, the popup and the month shown, and how a pick becomes text. */
|
|
30
|
-
function useInputDateTimeState({ calendarMonth, defaultOpen = false, defaultValue = "", getDefaultDate, onDateChange, onOpenChange, onValueChange, open: openProp, separator, value, withTime }) {
|
|
31
|
-
const [text, setText] = useControllableState({
|
|
32
|
-
defaultProp: defaultValue,
|
|
33
|
-
onChange: onValueChange,
|
|
34
|
-
prop: value
|
|
35
|
-
});
|
|
36
|
-
const [open, setOpenState] = useControllableState({
|
|
37
|
-
defaultProp: defaultOpen,
|
|
38
|
-
onChange: onOpenChange,
|
|
39
|
-
prop: openProp
|
|
10
|
+
function InputDateTime(props) {
|
|
11
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_lib_date_field.DateFieldRoot, {
|
|
12
|
+
...props,
|
|
13
|
+
slot: "input-date-time",
|
|
14
|
+
withTime: true
|
|
40
15
|
});
|
|
41
|
-
const selected = require_lib_date_time_mask.parseDatePart(text);
|
|
42
|
-
const parsed = require_lib_date_time_mask.parseDateTime(text, withTime);
|
|
43
|
-
const selectedTime = withTime && parsed ? (0, ictus_time.formatTime)(parsed) : void 0;
|
|
44
|
-
const [month, setMonth] = react.useState(() => selected ?? calendarMonth);
|
|
45
|
-
const setOpen = react.useCallback((next) => {
|
|
46
|
-
if (next && calendarMonth === void 0) setMonth(require_lib_date_time_mask.parseDatePart(text) ?? getDefaultDate());
|
|
47
|
-
setOpenState(next);
|
|
48
|
-
}, [
|
|
49
|
-
calendarMonth,
|
|
50
|
-
getDefaultDate,
|
|
51
|
-
setOpenState,
|
|
52
|
-
text
|
|
53
|
-
]);
|
|
54
|
-
const commit = react.useCallback((next) => {
|
|
55
|
-
if (next === text) return;
|
|
56
|
-
setText(next);
|
|
57
|
-
onDateChange?.(require_lib_date_time_mask.parseDateTime(next, withTime));
|
|
58
|
-
}, [
|
|
59
|
-
onDateChange,
|
|
60
|
-
setText,
|
|
61
|
-
text,
|
|
62
|
-
withTime
|
|
63
|
-
]);
|
|
64
|
-
const commitDate = (day, time = "00:00") => {
|
|
65
|
-
const next = new Date(day);
|
|
66
|
-
const [hours = 0, minutes = 0] = time.split(":").map(Number);
|
|
67
|
-
next.setHours(hours, minutes, 0, 0);
|
|
68
|
-
commit(require_lib_date_time_mask.formatDateTime(next, separator, withTime));
|
|
69
|
-
};
|
|
70
|
-
return {
|
|
71
|
-
commit,
|
|
72
|
-
commitDate,
|
|
73
|
-
month,
|
|
74
|
-
open,
|
|
75
|
-
selected,
|
|
76
|
-
selectedTime,
|
|
77
|
-
setMonth,
|
|
78
|
-
setOpen,
|
|
79
|
-
text
|
|
80
|
-
};
|
|
81
16
|
}
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
calendarMonth: calendarProps?.month,
|
|
87
|
-
defaultOpen,
|
|
88
|
-
defaultValue,
|
|
89
|
-
getDefaultDate,
|
|
90
|
-
onDateChange,
|
|
91
|
-
onOpenChange,
|
|
92
|
-
onValueChange,
|
|
93
|
-
open: openProp,
|
|
94
|
-
separator,
|
|
95
|
-
value: valueProp,
|
|
96
|
-
withTime
|
|
97
|
-
});
|
|
98
|
-
const setInputRef = react.useCallback((node) => {
|
|
99
|
-
inputRef.current = node;
|
|
100
|
-
if (typeof ref === "function") ref(node);
|
|
101
|
-
else if (ref) ref.current = node;
|
|
102
|
-
}, [ref]);
|
|
103
|
-
const times = react.useMemo(() => withTime ? require_lib_input_date_parts.timesOf(timeStep, selectedTime) : [], [
|
|
104
|
-
selectedTime,
|
|
105
|
-
timeStep,
|
|
106
|
-
withTime
|
|
107
|
-
]);
|
|
108
|
-
const handlers = require_lib_input_date_parts.useMaskHandlers({
|
|
109
|
-
commit,
|
|
110
|
-
inputRef,
|
|
111
|
-
onKeyDown,
|
|
112
|
-
onOpen: () => setOpen(true),
|
|
113
|
-
onPaste,
|
|
114
|
-
onRejectedKey: () => {
|
|
115
|
-
if (rejectedKeyMessage) announce(rejectedKeyMessage);
|
|
116
|
-
},
|
|
117
|
-
pickerOnly,
|
|
118
|
-
separator,
|
|
119
|
-
withTime
|
|
120
|
-
});
|
|
121
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_popover.Popover, {
|
|
122
|
-
onOpenChange: setOpen,
|
|
123
|
-
open,
|
|
124
|
-
children: [
|
|
125
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_popover.PopoverAnchor, {
|
|
126
|
-
render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "min-w-0" }),
|
|
127
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_input_group.InputGroup, {
|
|
128
|
-
className,
|
|
129
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_input_group.InputGroupInput, {
|
|
130
|
-
autoComplete: "off",
|
|
131
|
-
...props,
|
|
132
|
-
className: (0, cn.cn)(pickerOnly && "cursor-pointer"),
|
|
133
|
-
disabled,
|
|
134
|
-
id,
|
|
135
|
-
inputMode: pickerOnly ? void 0 : "numeric",
|
|
136
|
-
onChange: () => {},
|
|
137
|
-
onClick: (event) => {
|
|
138
|
-
props.onClick?.(event);
|
|
139
|
-
if (pickerOnly && !disabled && !event.defaultPrevented) setOpen(true);
|
|
140
|
-
},
|
|
141
|
-
...handlers,
|
|
142
|
-
placeholder: placeholder ?? placeholderOf(separator, withTime),
|
|
143
|
-
readOnly: pickerOnly,
|
|
144
|
-
ref: setInputRef,
|
|
145
|
-
spellCheck: false,
|
|
146
|
-
value: text
|
|
147
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_input_group.InputGroupAddon, {
|
|
148
|
-
align: "inline-end",
|
|
149
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_popover.PopoverTrigger, { render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_button.Button, {
|
|
150
|
-
"aria-label": calendarLabel,
|
|
151
|
-
color: "neutral",
|
|
152
|
-
disabled,
|
|
153
|
-
size: "icon-small",
|
|
154
|
-
styleVariant: "ghost",
|
|
155
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_epilot_spark_icons.CalendarMonth, {})
|
|
156
|
-
}) })
|
|
157
|
-
})]
|
|
158
|
-
})
|
|
159
|
-
}),
|
|
160
|
-
status,
|
|
161
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_popover.PopoverContent, {
|
|
162
|
-
align: "start",
|
|
163
|
-
"aria-label": calendarLabel,
|
|
164
|
-
className: "w-auto p-0",
|
|
165
|
-
collisionAvoidance: {
|
|
166
|
-
side: "flip",
|
|
167
|
-
fallbackAxisSide: "none"
|
|
168
|
-
},
|
|
169
|
-
container,
|
|
170
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
171
|
-
className: "flex max-sm:flex-col has-[[data-slot=calendar-list]]:[&>[data-slot=input-date-times]]:hidden",
|
|
172
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_calendar.Calendar, {
|
|
173
|
-
autoFocus: true,
|
|
174
|
-
...calendarProps,
|
|
175
|
-
components: {
|
|
176
|
-
DayButton: require_lib_calendar_day_button.ScrollFreeDayButton,
|
|
177
|
-
...calendarProps?.components
|
|
178
|
-
},
|
|
179
|
-
mode: "single",
|
|
180
|
-
month: calendarProps?.month ?? month,
|
|
181
|
-
onMonthChange: (next) => {
|
|
182
|
-
calendarProps?.onMonthChange?.(next);
|
|
183
|
-
if (calendarProps?.month === void 0) setMonth(next);
|
|
184
|
-
},
|
|
185
|
-
onSelect: (next) => {
|
|
186
|
-
if (!withTime) {
|
|
187
|
-
commit(next ? require_lib_date_time_mask.formatDateTime(next, separator) : "");
|
|
188
|
-
setOpen(false);
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
if (next) commitDate(next, selectedTime ?? defaultTime);
|
|
192
|
-
},
|
|
193
|
-
selected
|
|
194
|
-
}), withTime && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_lib_input_date_parts.TimeList, {
|
|
195
|
-
defaultTime,
|
|
196
|
-
label: timeLabel,
|
|
197
|
-
onPick: (time) => {
|
|
198
|
-
commitDate(selected ?? getDefaultDate(), time);
|
|
199
|
-
setOpen(false);
|
|
200
|
-
inputRef.current?.focus({ preventScroll: true });
|
|
201
|
-
},
|
|
202
|
-
open,
|
|
203
|
-
selectedTime,
|
|
204
|
-
times
|
|
205
|
-
})]
|
|
206
|
-
})
|
|
207
|
-
})
|
|
208
|
-
]
|
|
209
|
-
});
|
|
210
|
-
});
|
|
17
|
+
const InputDateTimeInput = require_lib_date_field_input.DateFieldInput;
|
|
18
|
+
const InputDateTimeTrigger = require_lib_date_field.DateFieldTrigger;
|
|
19
|
+
const InputDateTimeContent = require_lib_date_field.DateFieldContent;
|
|
20
|
+
const InputDateTimeTimeList = require_lib_date_field_time_list.DateFieldTimeList;
|
|
211
21
|
//#endregion
|
|
212
22
|
exports.InputDateTime = InputDateTime;
|
|
23
|
+
exports.InputDateTimeContent = InputDateTimeContent;
|
|
24
|
+
exports.InputDateTimeInput = InputDateTimeInput;
|
|
25
|
+
exports.InputDateTimeTimeList = InputDateTimeTimeList;
|
|
26
|
+
exports.InputDateTimeTrigger = InputDateTimeTrigger;
|
|
213
27
|
exports.dateTimeStatus = require_lib_date_time_mask.dateTimeStatus;
|
|
214
28
|
exports.formatDateTime = require_lib_date_time_mask.formatDateTime;
|
|
215
29
|
exports.parseDateTime = require_lib_date_time_mask.parseDateTime;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-date-time.cjs","names":["React","parseDatePart","parseDateTime","formatDateTime","useAnnouncement","timesOf","useMaskHandlers","Popover","PopoverAnchor","InputGroup","InputGroupInput","InputGroupAddon","PopoverTrigger","Button","CalendarMonth","PopoverContent","Calendar","ScrollFreeDayButton","TimeList"],"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,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,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,WAAWC,2BAAAA,cAAc,IAAI;CACnC,MAAM,SAASC,2BAAAA,cAAc,MAAM,QAAQ;CAC3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,2BAAAA,gBAAD,EACE,QACE,iBAAA,GAAA,kBAAA,KAACC,0BAAAA,QAAD;OACE,cAAY;OACZ,OAAM;OACI;OACV,MAAK;OACL,cAAa;iBAEb,iBAAA,GAAA,kBAAA,KAACC,oBAAAA,eAAD,CAAgB,CAAA;MACV,CAAA,EAEX,CAAA;KACc,CAAA,CACP;;GACC,CAAA;GACd;GACD,iBAAA,GAAA,kBAAA,KAACC,2BAAAA,gBAAD;IACE,OAAM;IACN,cAAY;IACZ,WAAU;IACV,oBAAoB;KAAE,MAAM;KAAQ,kBAAkB;IAAO;IAClD;cAGX,iBAAA,GAAA,kBAAA,MAAC,OAAD;KAAK,WAAU;eAAf,CACE,iBAAA,GAAA,kBAAA,KAACC,4BAAAA,UAAD;MAEE,WAAA;MACA,GAAI;MAEJ,YAAY;OACV,WAAWC,gCAAAA;OACX,GAAG,eAAe;MACpB;MACA,MAAK;MACL,OAAO,eAAe,SAAS;MAC/B,gBAAgB,SAAS;OACvB,eAAe,gBAAgB,IAAI;OACnC,IAAI,eAAe,UAAU,KAAA,GAAW,SAAS,IAAI;MACvD;MACA,WAAW,SAAS;OAClB,IAAI,CAAC,UAAU;QACb,OAAO,OAAOd,2BAAAA,eAAe,MAAM,SAAS,IAAI,EAAE;QAClD,QAAQ,KAAK;QACb;OACF;OAEA,IAAI,MAAM,WAAW,MAAM,gBAAgB,WAAW;MACxD;MACU;KACX,CAAA,GACA,YACC,iBAAA,GAAA,kBAAA,KAACe,6BAAAA,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.cjs","names":["DateFieldRoot","DateFieldInput","DateFieldTrigger","DateFieldContent","DateFieldTimeList"],"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,iBAAA,GAAA,kBAAA,KAACA,uBAAAA,eAAD;EAAe,GAAI;EAAO,MAAK;EAAkB,UAAA;CAAU,CAAA;AACpE;AAEA,MAAM,qBAAqBC,6BAAAA;AAC3B,MAAM,uBAAuBC,uBAAAA;AAC7B,MAAM,uBAAuBC,uBAAAA;AAC7B,MAAM,wBAAwBC,iCAAAA"}
|