@loykin/datetime-range 0.0.1-dev.0 → 0.0.1-dev.2
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/index.cjs +176 -232
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -2
- package/dist/index.d.ts +50 -2
- package/dist/index.js +175 -233
- package/dist/index.js.map +1 -1
- package/dist/styles.css +651 -93
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -75,9 +75,11 @@ interface DatetimeRangeProps {
|
|
|
75
75
|
startTime: DateTimeRangeValue;
|
|
76
76
|
endTime: DateTimeRangeValue;
|
|
77
77
|
}) => React__default.ReactElement;
|
|
78
|
+
/** DOM element the popover portal renders into. Use a scoped container to inherit CSS custom properties. */
|
|
79
|
+
portalContainer?: React__default.RefObject<HTMLElement | null> | HTMLElement | null;
|
|
78
80
|
className?: string;
|
|
79
81
|
}
|
|
80
|
-
declare function DatetimeRange({ startTime, endTime, onChange, quickPresets, showQuickRanges, showAbsolute, showRelative, precision, relativeFormats, min, max, timezone, use12HourFormat, showNow, disabled, labels: labelsProp, popoverAlign, popoverSide, renderTrigger, className, }: DatetimeRangeProps): React__default.JSX.Element;
|
|
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;
|
|
81
83
|
|
|
82
84
|
type CalendarProps = Omit<React.ComponentProps<typeof DayPicker>, 'mode'>;
|
|
83
85
|
interface DateTimePanelProps {
|
|
@@ -128,6 +130,52 @@ interface DatetimeSegmentInputProps {
|
|
|
128
130
|
}
|
|
129
131
|
declare function DatetimeSegmentInput({ value, onChange, disabled, className, isError, precision, }: DatetimeSegmentInputProps): React__default.JSX.Element;
|
|
130
132
|
|
|
133
|
+
interface SidePanelProps {
|
|
134
|
+
title: string;
|
|
135
|
+
value: DateTimeRangeValue;
|
|
136
|
+
compareValue?: DateTimeRangeValue;
|
|
137
|
+
onChange: (value: DateTimeRangeValue) => void;
|
|
138
|
+
/** Show absolute date/time tab. @default true */
|
|
139
|
+
showAbsolute?: boolean;
|
|
140
|
+
/** Show relative time tab. @default true */
|
|
141
|
+
showRelative?: boolean;
|
|
142
|
+
precision?: DatetimePrecision;
|
|
143
|
+
relativeFormats?: DateTimeRelativeFormat[];
|
|
144
|
+
showNow?: boolean;
|
|
145
|
+
min?: Date;
|
|
146
|
+
max?: Date;
|
|
147
|
+
timezone?: string;
|
|
148
|
+
use12HourFormat?: boolean;
|
|
149
|
+
labels?: DatetimeRangeLabels;
|
|
150
|
+
}
|
|
151
|
+
declare function SidePanel({ title, value, compareValue, onChange, showAbsolute, showRelative, precision, relativeFormats, showNow, min, max, timezone, use12HourFormat, labels: labelsProp, }: SidePanelProps): React__default.JSX.Element;
|
|
152
|
+
|
|
153
|
+
interface UseDatetimeRangeOptions {
|
|
154
|
+
startTime: DateTimeRangeValue;
|
|
155
|
+
endTime: DateTimeRangeValue;
|
|
156
|
+
onChange: (startTime: DateTimeRangeValue, endTime: DateTimeRangeValue) => void;
|
|
157
|
+
}
|
|
158
|
+
interface UseDatetimeRangeReturn {
|
|
159
|
+
/** Popover open state. */
|
|
160
|
+
isOpen: boolean;
|
|
161
|
+
setIsOpen: (open: boolean) => void;
|
|
162
|
+
/** Draft values — edited inside the picker, committed on apply. */
|
|
163
|
+
draftStart: DateTimeRangeValue;
|
|
164
|
+
setDraftStart: (value: DateTimeRangeValue) => void;
|
|
165
|
+
draftEnd: DateTimeRangeValue;
|
|
166
|
+
setDraftEnd: (value: DateTimeRangeValue) => void;
|
|
167
|
+
/** Validation error — 'validation' if start >= end, null otherwise. */
|
|
168
|
+
error: ValidationErrorType;
|
|
169
|
+
clearError: () => void;
|
|
170
|
+
/** Validate and commit draft values. Calls onChange on success. */
|
|
171
|
+
onApply: () => void;
|
|
172
|
+
/** Discard draft values and close. */
|
|
173
|
+
onCancel: () => void;
|
|
174
|
+
/** Commit a preset directly (skips draft). */
|
|
175
|
+
onPreset: (preset: QuickPreset) => void;
|
|
176
|
+
}
|
|
177
|
+
declare function useDatetimeRange({ startTime, endTime, onChange, }: UseDatetimeRangeOptions): UseDatetimeRangeReturn;
|
|
178
|
+
|
|
131
179
|
declare const RELATIVE_FORMATS: DateTimeRelativeFormat[];
|
|
132
180
|
declare const QUICK_PRESETS: QuickPreset[];
|
|
133
181
|
/** Converts a DateTimeRangeValue to a Date object. */
|
|
@@ -165,4 +213,4 @@ declare function absoluteDate(date: Date): DateTimeRangeValue;
|
|
|
165
213
|
/** Validates that start < end. Returns error message or null. */
|
|
166
214
|
declare function validateRange(start: DateTimeRangeValue, end: DateTimeRangeValue): ValidationErrorType;
|
|
167
215
|
|
|
168
|
-
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, type ValidationErrorType, absoluteDate, fromUrlString, relativeAgo, relativeNow, toDate, toDisplayString, toTimestamp, toTimestampMs, toUrlString, validateRange };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -75,9 +75,11 @@ interface DatetimeRangeProps {
|
|
|
75
75
|
startTime: DateTimeRangeValue;
|
|
76
76
|
endTime: DateTimeRangeValue;
|
|
77
77
|
}) => React__default.ReactElement;
|
|
78
|
+
/** DOM element the popover portal renders into. Use a scoped container to inherit CSS custom properties. */
|
|
79
|
+
portalContainer?: React__default.RefObject<HTMLElement | null> | HTMLElement | null;
|
|
78
80
|
className?: string;
|
|
79
81
|
}
|
|
80
|
-
declare function DatetimeRange({ startTime, endTime, onChange, quickPresets, showQuickRanges, showAbsolute, showRelative, precision, relativeFormats, min, max, timezone, use12HourFormat, showNow, disabled, labels: labelsProp, popoverAlign, popoverSide, renderTrigger, className, }: DatetimeRangeProps): React__default.JSX.Element;
|
|
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;
|
|
81
83
|
|
|
82
84
|
type CalendarProps = Omit<React.ComponentProps<typeof DayPicker>, 'mode'>;
|
|
83
85
|
interface DateTimePanelProps {
|
|
@@ -128,6 +130,52 @@ interface DatetimeSegmentInputProps {
|
|
|
128
130
|
}
|
|
129
131
|
declare function DatetimeSegmentInput({ value, onChange, disabled, className, isError, precision, }: DatetimeSegmentInputProps): React__default.JSX.Element;
|
|
130
132
|
|
|
133
|
+
interface SidePanelProps {
|
|
134
|
+
title: string;
|
|
135
|
+
value: DateTimeRangeValue;
|
|
136
|
+
compareValue?: DateTimeRangeValue;
|
|
137
|
+
onChange: (value: DateTimeRangeValue) => void;
|
|
138
|
+
/** Show absolute date/time tab. @default true */
|
|
139
|
+
showAbsolute?: boolean;
|
|
140
|
+
/** Show relative time tab. @default true */
|
|
141
|
+
showRelative?: boolean;
|
|
142
|
+
precision?: DatetimePrecision;
|
|
143
|
+
relativeFormats?: DateTimeRelativeFormat[];
|
|
144
|
+
showNow?: boolean;
|
|
145
|
+
min?: Date;
|
|
146
|
+
max?: Date;
|
|
147
|
+
timezone?: string;
|
|
148
|
+
use12HourFormat?: boolean;
|
|
149
|
+
labels?: DatetimeRangeLabels;
|
|
150
|
+
}
|
|
151
|
+
declare function SidePanel({ title, value, compareValue, onChange, showAbsolute, showRelative, precision, relativeFormats, showNow, min, max, timezone, use12HourFormat, labels: labelsProp, }: SidePanelProps): React__default.JSX.Element;
|
|
152
|
+
|
|
153
|
+
interface UseDatetimeRangeOptions {
|
|
154
|
+
startTime: DateTimeRangeValue;
|
|
155
|
+
endTime: DateTimeRangeValue;
|
|
156
|
+
onChange: (startTime: DateTimeRangeValue, endTime: DateTimeRangeValue) => void;
|
|
157
|
+
}
|
|
158
|
+
interface UseDatetimeRangeReturn {
|
|
159
|
+
/** Popover open state. */
|
|
160
|
+
isOpen: boolean;
|
|
161
|
+
setIsOpen: (open: boolean) => void;
|
|
162
|
+
/** Draft values — edited inside the picker, committed on apply. */
|
|
163
|
+
draftStart: DateTimeRangeValue;
|
|
164
|
+
setDraftStart: (value: DateTimeRangeValue) => void;
|
|
165
|
+
draftEnd: DateTimeRangeValue;
|
|
166
|
+
setDraftEnd: (value: DateTimeRangeValue) => void;
|
|
167
|
+
/** Validation error — 'validation' if start >= end, null otherwise. */
|
|
168
|
+
error: ValidationErrorType;
|
|
169
|
+
clearError: () => void;
|
|
170
|
+
/** Validate and commit draft values. Calls onChange on success. */
|
|
171
|
+
onApply: () => void;
|
|
172
|
+
/** Discard draft values and close. */
|
|
173
|
+
onCancel: () => void;
|
|
174
|
+
/** Commit a preset directly (skips draft). */
|
|
175
|
+
onPreset: (preset: QuickPreset) => void;
|
|
176
|
+
}
|
|
177
|
+
declare function useDatetimeRange({ startTime, endTime, onChange, }: UseDatetimeRangeOptions): UseDatetimeRangeReturn;
|
|
178
|
+
|
|
131
179
|
declare const RELATIVE_FORMATS: DateTimeRelativeFormat[];
|
|
132
180
|
declare const QUICK_PRESETS: QuickPreset[];
|
|
133
181
|
/** Converts a DateTimeRangeValue to a Date object. */
|
|
@@ -165,4 +213,4 @@ declare function absoluteDate(date: Date): DateTimeRangeValue;
|
|
|
165
213
|
/** Validates that start < end. Returns error message or null. */
|
|
166
214
|
declare function validateRange(start: DateTimeRangeValue, end: DateTimeRangeValue): ValidationErrorType;
|
|
167
215
|
|
|
168
|
-
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, type ValidationErrorType, absoluteDate, fromUrlString, relativeAgo, relativeNow, toDate, toDisplayString, toTimestamp, toTimestampMs, toUrlString, validateRange };
|
|
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 };
|