@loykin/datetime-range 0.0.1-dev.4 → 0.0.1
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/README.md +42 -0
- package/dist/UIAdapterContext-Bm35TZtL.d.cts +96 -0
- package/dist/UIAdapterContext-Bm35TZtL.d.ts +96 -0
- package/dist/adapters/shadcn.cjs +117 -0
- package/dist/adapters/shadcn.cjs.map +1 -0
- package/dist/adapters/shadcn.d.cts +41 -0
- package/dist/adapters/shadcn.d.ts +41 -0
- package/dist/adapters/shadcn.js +115 -0
- package/dist/adapters/shadcn.js.map +1 -0
- package/dist/index.cjs +412 -303
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -3
- package/dist/index.d.ts +36 -3
- package/dist/index.js +344 -237
- package/dist/index.js.map +1 -1
- package/dist/styles.css +226 -211
- package/package.json +6 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
+
import { D as DatetimeRangeUIAdapter } from './UIAdapterContext-Bm35TZtL.cjs';
|
|
4
|
+
export { a as DatetimeRangeProvider, u as useDatetimeRangeUI } from './UIAdapterContext-Bm35TZtL.cjs';
|
|
3
5
|
import { DayPicker } from 'react-day-picker';
|
|
6
|
+
import '@base-ui/react/button';
|
|
7
|
+
import '@base-ui/react/popover';
|
|
8
|
+
import '@base-ui/react/select';
|
|
9
|
+
import '@base-ui/react/tabs';
|
|
10
|
+
import '@base-ui/react/switch';
|
|
11
|
+
import '@base-ui/react/scroll-area';
|
|
4
12
|
|
|
5
13
|
type DateTimeRangeType = 'absolute' | 'relative';
|
|
6
14
|
/** Controls which time fields are shown in absolute mode. */
|
|
@@ -58,6 +66,13 @@ interface DatetimeRangeProps {
|
|
|
58
66
|
use12HourFormat?: boolean;
|
|
59
67
|
/** Show the "Now" toggle in relative mode. @default true */
|
|
60
68
|
showNow?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* How the calendar is presented in Absolute mode: `'popover'` opens it from a button
|
|
71
|
+
* (current default behavior); `'inline'` renders it always visible below the date input,
|
|
72
|
+
* like an embedded shadcn-style calendar. Pick whichever suits the surrounding layout.
|
|
73
|
+
* @default 'popover'
|
|
74
|
+
*/
|
|
75
|
+
calendarMode?: 'popover' | 'inline';
|
|
61
76
|
/** Disable the entire component. @default false */
|
|
62
77
|
disabled?: boolean;
|
|
63
78
|
/** Override UI labels for i18n. */
|
|
@@ -78,8 +93,16 @@ interface DatetimeRangeProps {
|
|
|
78
93
|
/** DOM element the popover portal renders into. Use a scoped container to inherit CSS custom properties. */
|
|
79
94
|
portalContainer?: React__default.RefObject<HTMLElement | null> | HTMLElement | null;
|
|
80
95
|
className?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Replace the underlying Button/Popover/Select/Tabs/Input/Switch implementations —
|
|
98
|
+
* e.g. `createShadcnAdapter(...)` from `@loykin/datetime-range/adapters/shadcn` to render
|
|
99
|
+
* with your app's own shadcn/ui components instead of the built-in ones.
|
|
100
|
+
* Must be referentially stable (module-scope constant or memoized) — a new object every
|
|
101
|
+
* render remounts the affected subtree.
|
|
102
|
+
*/
|
|
103
|
+
uiAdapter?: DatetimeRangeUIAdapter;
|
|
81
104
|
}
|
|
82
|
-
declare function DatetimeRange({ startTime, endTime, onChange, quickPresets, showQuickRanges, showAbsolute, showRelative, precision, relativeFormats, min, max, timezone, use12HourFormat, showNow, disabled, labels: labelsProp, popoverAlign, popoverSide, renderTrigger, portalContainer, className, }: DatetimeRangeProps): React__default.JSX.Element;
|
|
105
|
+
declare function DatetimeRange({ startTime, endTime, onChange, quickPresets, showQuickRanges, showAbsolute, showRelative, precision, relativeFormats, min, max, timezone, use12HourFormat, showNow, calendarMode, disabled, labels: labelsProp, popoverAlign, popoverSide, renderTrigger, portalContainer, className, uiAdapter, }: DatetimeRangeProps): React__default.JSX.Element;
|
|
83
106
|
|
|
84
107
|
type CalendarProps = Omit<React.ComponentProps<typeof DayPicker>, 'mode'>;
|
|
85
108
|
interface DateTimePanelProps {
|
|
@@ -147,8 +170,18 @@ interface SidePanelProps {
|
|
|
147
170
|
timezone?: string;
|
|
148
171
|
use12HourFormat?: boolean;
|
|
149
172
|
labels?: DatetimeRangeLabels;
|
|
173
|
+
/** How the calendar is presented in Absolute mode: a popover triggered by a button, or always visible inline. @default 'popover' */
|
|
174
|
+
calendarMode?: 'popover' | 'inline';
|
|
175
|
+
/**
|
|
176
|
+
* Replace the underlying Button/Popover/Select/Tabs/Input/Switch implementations —
|
|
177
|
+
* e.g. `createShadcnAdapter(...)` from `@loykin/datetime-range/adapters/shadcn` to render
|
|
178
|
+
* with your app's own shadcn/ui components instead of the built-in ones.
|
|
179
|
+
* Must be referentially stable (module-scope constant or memoized) — a new object every
|
|
180
|
+
* render remounts the affected subtree.
|
|
181
|
+
*/
|
|
182
|
+
uiAdapter?: DatetimeRangeUIAdapter;
|
|
150
183
|
}
|
|
151
|
-
declare function SidePanel({ title, value, compareValue, onChange, showAbsolute, showRelative, precision, relativeFormats, showNow, min, max, timezone, use12HourFormat, labels: labelsProp, }: SidePanelProps): React__default.JSX.Element;
|
|
184
|
+
declare function SidePanel({ title, value, compareValue, onChange, showAbsolute, showRelative, precision, relativeFormats, showNow, min, max, timezone, use12HourFormat, labels: labelsProp, calendarMode, uiAdapter, }: SidePanelProps): React__default.JSX.Element;
|
|
152
185
|
|
|
153
186
|
interface UseDatetimeRangeOptions {
|
|
154
187
|
startTime: DateTimeRangeValue;
|
|
@@ -213,4 +246,4 @@ declare function absoluteDate(date: Date): DateTimeRangeValue;
|
|
|
213
246
|
/** Validates that start < end. Returns error message or null. */
|
|
214
247
|
declare function validateRange(start: DateTimeRangeValue, end: DateTimeRangeValue): ValidationErrorType;
|
|
215
248
|
|
|
216
|
-
export { type CalendarProps, DateTimePanel, type DateTimePanelProps, type DateTimeRangeValue, type DateTimeRelativeFormat, type DatetimePrecision, DatetimeRange, type DatetimeRangeLabels, type DatetimeRangeProps, DatetimeSegmentInput, type DatetimeSegmentInputProps, QUICK_PRESETS, type QuickPreset, RELATIVE_FORMATS, SidePanel, type SidePanelProps, type UseDatetimeRangeOptions, type UseDatetimeRangeReturn, type ValidationErrorType, absoluteDate, fromUrlString, relativeAgo, relativeNow, toDate, toDisplayString, toTimestamp, toTimestampMs, toUrlString, useDatetimeRange, validateRange };
|
|
249
|
+
export { type CalendarProps, DateTimePanel, type DateTimePanelProps, type DateTimeRangeValue, type DateTimeRelativeFormat, type DatetimePrecision, DatetimeRange, type DatetimeRangeLabels, type DatetimeRangeProps, DatetimeRangeUIAdapter, DatetimeSegmentInput, type DatetimeSegmentInputProps, QUICK_PRESETS, type QuickPreset, RELATIVE_FORMATS, SidePanel, type SidePanelProps, type UseDatetimeRangeOptions, type UseDatetimeRangeReturn, type ValidationErrorType, absoluteDate, fromUrlString, relativeAgo, relativeNow, toDate, toDisplayString, toTimestamp, toTimestampMs, toUrlString, useDatetimeRange, validateRange };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
+
import { D as DatetimeRangeUIAdapter } from './UIAdapterContext-Bm35TZtL.js';
|
|
4
|
+
export { a as DatetimeRangeProvider, u as useDatetimeRangeUI } from './UIAdapterContext-Bm35TZtL.js';
|
|
3
5
|
import { DayPicker } from 'react-day-picker';
|
|
6
|
+
import '@base-ui/react/button';
|
|
7
|
+
import '@base-ui/react/popover';
|
|
8
|
+
import '@base-ui/react/select';
|
|
9
|
+
import '@base-ui/react/tabs';
|
|
10
|
+
import '@base-ui/react/switch';
|
|
11
|
+
import '@base-ui/react/scroll-area';
|
|
4
12
|
|
|
5
13
|
type DateTimeRangeType = 'absolute' | 'relative';
|
|
6
14
|
/** Controls which time fields are shown in absolute mode. */
|
|
@@ -58,6 +66,13 @@ interface DatetimeRangeProps {
|
|
|
58
66
|
use12HourFormat?: boolean;
|
|
59
67
|
/** Show the "Now" toggle in relative mode. @default true */
|
|
60
68
|
showNow?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* How the calendar is presented in Absolute mode: `'popover'` opens it from a button
|
|
71
|
+
* (current default behavior); `'inline'` renders it always visible below the date input,
|
|
72
|
+
* like an embedded shadcn-style calendar. Pick whichever suits the surrounding layout.
|
|
73
|
+
* @default 'popover'
|
|
74
|
+
*/
|
|
75
|
+
calendarMode?: 'popover' | 'inline';
|
|
61
76
|
/** Disable the entire component. @default false */
|
|
62
77
|
disabled?: boolean;
|
|
63
78
|
/** Override UI labels for i18n. */
|
|
@@ -78,8 +93,16 @@ interface DatetimeRangeProps {
|
|
|
78
93
|
/** DOM element the popover portal renders into. Use a scoped container to inherit CSS custom properties. */
|
|
79
94
|
portalContainer?: React__default.RefObject<HTMLElement | null> | HTMLElement | null;
|
|
80
95
|
className?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Replace the underlying Button/Popover/Select/Tabs/Input/Switch implementations —
|
|
98
|
+
* e.g. `createShadcnAdapter(...)` from `@loykin/datetime-range/adapters/shadcn` to render
|
|
99
|
+
* with your app's own shadcn/ui components instead of the built-in ones.
|
|
100
|
+
* Must be referentially stable (module-scope constant or memoized) — a new object every
|
|
101
|
+
* render remounts the affected subtree.
|
|
102
|
+
*/
|
|
103
|
+
uiAdapter?: DatetimeRangeUIAdapter;
|
|
81
104
|
}
|
|
82
|
-
declare function DatetimeRange({ startTime, endTime, onChange, quickPresets, showQuickRanges, showAbsolute, showRelative, precision, relativeFormats, min, max, timezone, use12HourFormat, showNow, disabled, labels: labelsProp, popoverAlign, popoverSide, renderTrigger, portalContainer, className, }: DatetimeRangeProps): React__default.JSX.Element;
|
|
105
|
+
declare function DatetimeRange({ startTime, endTime, onChange, quickPresets, showQuickRanges, showAbsolute, showRelative, precision, relativeFormats, min, max, timezone, use12HourFormat, showNow, calendarMode, disabled, labels: labelsProp, popoverAlign, popoverSide, renderTrigger, portalContainer, className, uiAdapter, }: DatetimeRangeProps): React__default.JSX.Element;
|
|
83
106
|
|
|
84
107
|
type CalendarProps = Omit<React.ComponentProps<typeof DayPicker>, 'mode'>;
|
|
85
108
|
interface DateTimePanelProps {
|
|
@@ -147,8 +170,18 @@ interface SidePanelProps {
|
|
|
147
170
|
timezone?: string;
|
|
148
171
|
use12HourFormat?: boolean;
|
|
149
172
|
labels?: DatetimeRangeLabels;
|
|
173
|
+
/** How the calendar is presented in Absolute mode: a popover triggered by a button, or always visible inline. @default 'popover' */
|
|
174
|
+
calendarMode?: 'popover' | 'inline';
|
|
175
|
+
/**
|
|
176
|
+
* Replace the underlying Button/Popover/Select/Tabs/Input/Switch implementations —
|
|
177
|
+
* e.g. `createShadcnAdapter(...)` from `@loykin/datetime-range/adapters/shadcn` to render
|
|
178
|
+
* with your app's own shadcn/ui components instead of the built-in ones.
|
|
179
|
+
* Must be referentially stable (module-scope constant or memoized) — a new object every
|
|
180
|
+
* render remounts the affected subtree.
|
|
181
|
+
*/
|
|
182
|
+
uiAdapter?: DatetimeRangeUIAdapter;
|
|
150
183
|
}
|
|
151
|
-
declare function SidePanel({ title, value, compareValue, onChange, showAbsolute, showRelative, precision, relativeFormats, showNow, min, max, timezone, use12HourFormat, labels: labelsProp, }: SidePanelProps): React__default.JSX.Element;
|
|
184
|
+
declare function SidePanel({ title, value, compareValue, onChange, showAbsolute, showRelative, precision, relativeFormats, showNow, min, max, timezone, use12HourFormat, labels: labelsProp, calendarMode, uiAdapter, }: SidePanelProps): React__default.JSX.Element;
|
|
152
185
|
|
|
153
186
|
interface UseDatetimeRangeOptions {
|
|
154
187
|
startTime: DateTimeRangeValue;
|
|
@@ -213,4 +246,4 @@ declare function absoluteDate(date: Date): DateTimeRangeValue;
|
|
|
213
246
|
/** Validates that start < end. Returns error message or null. */
|
|
214
247
|
declare function validateRange(start: DateTimeRangeValue, end: DateTimeRangeValue): ValidationErrorType;
|
|
215
248
|
|
|
216
|
-
export { type CalendarProps, DateTimePanel, type DateTimePanelProps, type DateTimeRangeValue, type DateTimeRelativeFormat, type DatetimePrecision, DatetimeRange, type DatetimeRangeLabels, type DatetimeRangeProps, DatetimeSegmentInput, type DatetimeSegmentInputProps, QUICK_PRESETS, type QuickPreset, RELATIVE_FORMATS, SidePanel, type SidePanelProps, type UseDatetimeRangeOptions, type UseDatetimeRangeReturn, type ValidationErrorType, absoluteDate, fromUrlString, relativeAgo, relativeNow, toDate, toDisplayString, toTimestamp, toTimestampMs, toUrlString, useDatetimeRange, validateRange };
|
|
249
|
+
export { type CalendarProps, DateTimePanel, type DateTimePanelProps, type DateTimeRangeValue, type DateTimeRelativeFormat, type DatetimePrecision, DatetimeRange, type DatetimeRangeLabels, type DatetimeRangeProps, DatetimeRangeUIAdapter, DatetimeSegmentInput, type DatetimeSegmentInputProps, QUICK_PRESETS, type QuickPreset, RELATIVE_FORMATS, SidePanel, type SidePanelProps, type UseDatetimeRangeOptions, type UseDatetimeRangeReturn, type ValidationErrorType, absoluteDate, fromUrlString, relativeAgo, relativeNow, toDate, toDisplayString, toTimestamp, toTimestampMs, toUrlString, useDatetimeRange, validateRange };
|