@loykin/datetime-range 0.0.1-dev.4 → 0.0.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/README.md +42 -0
- package/dist/UIAdapterContext-By3WJ5Ep.d.cts +96 -0
- package/dist/UIAdapterContext-By3WJ5Ep.d.ts +96 -0
- package/dist/adapters/shadcn.cjs +118 -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 +116 -0
- package/dist/adapters/shadcn.js.map +1 -0
- package/dist/index.cjs +418 -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 +350 -237
- package/dist/index.js.map +1 -1
- package/dist/styles.css +226 -211
- package/package.json +6 -1
package/dist/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { ChevronUpIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CalendarDays, Clock, CheckIcon } from 'lucide-react';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
|
+
import React2, { createContext, useContext, useState, useMemo, useCallback, useEffect, useRef } from 'react';
|
|
3
4
|
import { Button as Button$1 } from '@base-ui/react/button';
|
|
4
5
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
6
|
import { Popover as Popover$1 } from '@base-ui/react/popover';
|
|
6
|
-
import React, { useState, useMemo, useCallback, useEffect, useRef } from 'react';
|
|
7
|
-
import { Tabs as Tabs$1 } from '@base-ui/react/tabs';
|
|
8
|
-
import { Input as Input$1 } from '@base-ui/react/input';
|
|
9
7
|
import { Select as Select$1 } from '@base-ui/react/select';
|
|
10
8
|
import { HugeiconsIcon } from '@hugeicons/react';
|
|
11
|
-
import {
|
|
9
|
+
import { Tick02Icon, UnfoldMoreIcon, ArrowUp01Icon, ArrowDown01Icon } from '@hugeicons/core-free-icons';
|
|
10
|
+
import { Tabs as Tabs$1 } from '@base-ui/react/tabs';
|
|
11
|
+
import { Input as Input$1 } from '@base-ui/react/input';
|
|
12
12
|
import { Switch as Switch$1 } from '@base-ui/react/switch';
|
|
13
|
+
import { ScrollArea as ScrollArea$1 } from '@base-ui/react/scroll-area';
|
|
13
14
|
import { setYear, getYear, addMonths, subMonths, format, startOfYear, endOfYear, startOfMonth, endOfMonth, getMonth, setHours, endOfHour, startOfHour, setMinutes, endOfMinute, startOfMinute, setMilliseconds, setSeconds, startOfDay, endOfDay, addHours, subHours, parse } from 'date-fns';
|
|
14
15
|
import { TZDate, DayPicker } from 'react-day-picker';
|
|
15
16
|
import { setMonth } from 'date-fns/setMonth';
|
|
16
|
-
import { ScrollArea as ScrollArea$1 } from '@base-ui/react/scroll-area';
|
|
17
17
|
import * as chrono from 'chrono-node';
|
|
18
18
|
|
|
19
19
|
// src/DatetimeRange.tsx
|
|
@@ -25,12 +25,17 @@ function buttonVariants({
|
|
|
25
25
|
size = "default",
|
|
26
26
|
className
|
|
27
27
|
} = {}) {
|
|
28
|
-
return cn("
|
|
28
|
+
return cn("datetime-range-btn", className, variant && `datetime-range-btn--${variant}`, size && `datetime-range-btn--${size}`);
|
|
29
29
|
}
|
|
30
30
|
function Button({
|
|
31
31
|
className,
|
|
32
32
|
variant = "default",
|
|
33
33
|
size = "default",
|
|
34
|
+
// @base-ui/react's own Button/useButton() already defaults type="button" internally on
|
|
35
|
+
// every path this wraps, so this default is redundant today — kept anyway as a fallback
|
|
36
|
+
// that doesn't depend on that undocumented (type isn't part of the public prop types)
|
|
37
|
+
// upstream behavior continuing to hold across base-ui versions.
|
|
38
|
+
type = "button",
|
|
34
39
|
...props
|
|
35
40
|
}) {
|
|
36
41
|
return /* @__PURE__ */ jsx(
|
|
@@ -39,6 +44,7 @@ function Button({
|
|
|
39
44
|
"data-slot": "button",
|
|
40
45
|
"data-variant": variant,
|
|
41
46
|
"data-size": size,
|
|
47
|
+
type,
|
|
42
48
|
className: buttonVariants({ variant, size, className: typeof className === "string" ? className : void 0 }),
|
|
43
49
|
...props
|
|
44
50
|
}
|
|
@@ -70,89 +76,25 @@ function PopoverContent({
|
|
|
70
76
|
sideOffset,
|
|
71
77
|
disableAnchorTracking,
|
|
72
78
|
collisionAvoidance,
|
|
73
|
-
className: "
|
|
79
|
+
className: "datetime-range-positioner",
|
|
74
80
|
children: /* @__PURE__ */ jsx(
|
|
75
81
|
Popover$1.Popup,
|
|
76
82
|
{
|
|
77
83
|
"data-slot": "popover-content",
|
|
78
|
-
className: cn("
|
|
84
|
+
className: cn("datetime-range-popover-content", className),
|
|
79
85
|
...props
|
|
80
86
|
}
|
|
81
87
|
)
|
|
82
88
|
}
|
|
83
89
|
) });
|
|
84
90
|
}
|
|
85
|
-
function Tabs({
|
|
86
|
-
className,
|
|
87
|
-
orientation = "horizontal",
|
|
88
|
-
...props
|
|
89
|
-
}) {
|
|
90
|
-
return /* @__PURE__ */ jsx(
|
|
91
|
-
Tabs$1.Root,
|
|
92
|
-
{
|
|
93
|
-
"data-slot": "tabs",
|
|
94
|
-
"data-orientation": orientation,
|
|
95
|
-
className: cn("dr-tabs", className),
|
|
96
|
-
...props
|
|
97
|
-
}
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
function TabsList({
|
|
101
|
-
className,
|
|
102
|
-
variant = "default",
|
|
103
|
-
...props
|
|
104
|
-
}) {
|
|
105
|
-
return /* @__PURE__ */ jsx(
|
|
106
|
-
Tabs$1.List,
|
|
107
|
-
{
|
|
108
|
-
"data-slot": "tabs-list",
|
|
109
|
-
"data-variant": variant,
|
|
110
|
-
className: cn("dr-tabs-list", className),
|
|
111
|
-
...props
|
|
112
|
-
}
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
function TabsTrigger({ className, ...props }) {
|
|
116
|
-
return /* @__PURE__ */ jsx(
|
|
117
|
-
Tabs$1.Tab,
|
|
118
|
-
{
|
|
119
|
-
"data-slot": "tabs-trigger",
|
|
120
|
-
className: cn("dr-tabs-trigger", className),
|
|
121
|
-
...props
|
|
122
|
-
}
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
function TabsContent({ className, ...props }) {
|
|
126
|
-
return /* @__PURE__ */ jsx(
|
|
127
|
-
Tabs$1.Panel,
|
|
128
|
-
{
|
|
129
|
-
"data-slot": "tabs-content",
|
|
130
|
-
className: cn("dr-tabs-content", className),
|
|
131
|
-
...props
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
function Input({ className, type, ...props }) {
|
|
136
|
-
return /* @__PURE__ */ jsx(
|
|
137
|
-
Input$1,
|
|
138
|
-
{
|
|
139
|
-
type,
|
|
140
|
-
"data-slot": "input",
|
|
141
|
-
className: cn(
|
|
142
|
-
"dr-input",
|
|
143
|
-
className
|
|
144
|
-
),
|
|
145
|
-
...props
|
|
146
|
-
}
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
91
|
var Select = Select$1.Root;
|
|
150
92
|
function SelectValue({ className, ...props }) {
|
|
151
93
|
return /* @__PURE__ */ jsx(
|
|
152
94
|
Select$1.Value,
|
|
153
95
|
{
|
|
154
96
|
"data-slot": "select-value",
|
|
155
|
-
className: cn("
|
|
97
|
+
className: cn("datetime-range-select-value", className),
|
|
156
98
|
...props
|
|
157
99
|
}
|
|
158
100
|
);
|
|
@@ -168,7 +110,7 @@ function SelectTrigger({
|
|
|
168
110
|
{
|
|
169
111
|
"data-slot": "select-trigger",
|
|
170
112
|
"data-size": size,
|
|
171
|
-
className: cn("
|
|
113
|
+
className: cn("datetime-range-select-trigger", className),
|
|
172
114
|
...props,
|
|
173
115
|
children: [
|
|
174
116
|
children,
|
|
@@ -180,7 +122,7 @@ function SelectTrigger({
|
|
|
180
122
|
{
|
|
181
123
|
icon: UnfoldMoreIcon,
|
|
182
124
|
strokeWidth: 2,
|
|
183
|
-
className: "
|
|
125
|
+
className: "datetime-range-select-icon"
|
|
184
126
|
}
|
|
185
127
|
)
|
|
186
128
|
}
|
|
@@ -207,13 +149,13 @@ function SelectContent({
|
|
|
207
149
|
align,
|
|
208
150
|
alignOffset,
|
|
209
151
|
alignItemWithTrigger,
|
|
210
|
-
className: "
|
|
152
|
+
className: "datetime-range-positioner",
|
|
211
153
|
children: /* @__PURE__ */ jsxs(
|
|
212
154
|
Select$1.Popup,
|
|
213
155
|
{
|
|
214
156
|
"data-slot": "select-content",
|
|
215
157
|
"data-align-trigger": alignItemWithTrigger,
|
|
216
|
-
className: cn("
|
|
158
|
+
className: cn("datetime-range-select-content", className),
|
|
217
159
|
...props,
|
|
218
160
|
children: [
|
|
219
161
|
/* @__PURE__ */ jsx(SelectScrollUpButton, {}),
|
|
@@ -234,14 +176,14 @@ function SelectItem({
|
|
|
234
176
|
Select$1.Item,
|
|
235
177
|
{
|
|
236
178
|
"data-slot": "select-item",
|
|
237
|
-
className: cn("
|
|
179
|
+
className: cn("datetime-range-select-item", className),
|
|
238
180
|
...props,
|
|
239
181
|
children: [
|
|
240
|
-
/* @__PURE__ */ jsx(Select$1.ItemText, { className: "
|
|
182
|
+
/* @__PURE__ */ jsx(Select$1.ItemText, { className: "datetime-range-select-item-text", children }),
|
|
241
183
|
/* @__PURE__ */ jsx(
|
|
242
184
|
Select$1.ItemIndicator,
|
|
243
185
|
{
|
|
244
|
-
render: /* @__PURE__ */ jsx("span", { className: "
|
|
186
|
+
render: /* @__PURE__ */ jsx("span", { className: "datetime-range-select-item-indicator" }),
|
|
245
187
|
children: /* @__PURE__ */ jsx(HugeiconsIcon, { icon: Tick02Icon, strokeWidth: 2, style: { pointerEvents: "none" } })
|
|
246
188
|
}
|
|
247
189
|
)
|
|
@@ -257,7 +199,7 @@ function SelectScrollUpButton({
|
|
|
257
199
|
Select$1.ScrollUpArrow,
|
|
258
200
|
{
|
|
259
201
|
"data-slot": "select-scroll-up-button",
|
|
260
|
-
className: cn("
|
|
202
|
+
className: cn("datetime-range-select-scroll-btn datetime-range-select-scroll-btn--up", className),
|
|
261
203
|
...props,
|
|
262
204
|
children: /* @__PURE__ */ jsx(HugeiconsIcon, { icon: ArrowUp01Icon, strokeWidth: 2 })
|
|
263
205
|
}
|
|
@@ -271,12 +213,76 @@ function SelectScrollDownButton({
|
|
|
271
213
|
Select$1.ScrollDownArrow,
|
|
272
214
|
{
|
|
273
215
|
"data-slot": "select-scroll-down-button",
|
|
274
|
-
className: cn("
|
|
216
|
+
className: cn("datetime-range-select-scroll-btn datetime-range-select-scroll-btn--down", className),
|
|
275
217
|
...props,
|
|
276
218
|
children: /* @__PURE__ */ jsx(HugeiconsIcon, { icon: ArrowDown01Icon, strokeWidth: 2 })
|
|
277
219
|
}
|
|
278
220
|
);
|
|
279
221
|
}
|
|
222
|
+
function Tabs({
|
|
223
|
+
className,
|
|
224
|
+
orientation = "horizontal",
|
|
225
|
+
...props
|
|
226
|
+
}) {
|
|
227
|
+
return /* @__PURE__ */ jsx(
|
|
228
|
+
Tabs$1.Root,
|
|
229
|
+
{
|
|
230
|
+
"data-slot": "tabs",
|
|
231
|
+
"data-orientation": orientation,
|
|
232
|
+
className: cn("datetime-range-tabs", className),
|
|
233
|
+
...props
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
function TabsList({
|
|
238
|
+
className,
|
|
239
|
+
variant = "default",
|
|
240
|
+
...props
|
|
241
|
+
}) {
|
|
242
|
+
return /* @__PURE__ */ jsx(
|
|
243
|
+
Tabs$1.List,
|
|
244
|
+
{
|
|
245
|
+
"data-slot": "tabs-list",
|
|
246
|
+
"data-variant": variant,
|
|
247
|
+
className: cn("datetime-range-tabs-list", className),
|
|
248
|
+
...props
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
function TabsTrigger({ className, ...props }) {
|
|
253
|
+
return /* @__PURE__ */ jsx(
|
|
254
|
+
Tabs$1.Tab,
|
|
255
|
+
{
|
|
256
|
+
"data-slot": "tabs-trigger",
|
|
257
|
+
className: cn("datetime-range-tabs-trigger", className),
|
|
258
|
+
...props
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
function TabsContent({ className, ...props }) {
|
|
263
|
+
return /* @__PURE__ */ jsx(
|
|
264
|
+
Tabs$1.Panel,
|
|
265
|
+
{
|
|
266
|
+
"data-slot": "tabs-content",
|
|
267
|
+
className: cn("datetime-range-tabs-content", className),
|
|
268
|
+
...props
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
function Input({ className, type, ...props }) {
|
|
273
|
+
return /* @__PURE__ */ jsx(
|
|
274
|
+
Input$1,
|
|
275
|
+
{
|
|
276
|
+
type,
|
|
277
|
+
"data-slot": "input",
|
|
278
|
+
className: cn(
|
|
279
|
+
"datetime-range-input",
|
|
280
|
+
className
|
|
281
|
+
),
|
|
282
|
+
...props
|
|
283
|
+
}
|
|
284
|
+
);
|
|
285
|
+
}
|
|
280
286
|
function Switch({
|
|
281
287
|
className,
|
|
282
288
|
size = "default",
|
|
@@ -287,13 +293,13 @@ function Switch({
|
|
|
287
293
|
{
|
|
288
294
|
"data-slot": "switch",
|
|
289
295
|
"data-size": size,
|
|
290
|
-
className: cn("
|
|
296
|
+
className: cn("datetime-range-switch", className),
|
|
291
297
|
...props,
|
|
292
298
|
children: /* @__PURE__ */ jsx(
|
|
293
299
|
Switch$1.Thumb,
|
|
294
300
|
{
|
|
295
301
|
"data-slot": "switch-thumb",
|
|
296
|
-
className: "
|
|
302
|
+
className: "datetime-range-switch-thumb"
|
|
297
303
|
}
|
|
298
304
|
)
|
|
299
305
|
}
|
|
@@ -311,7 +317,7 @@ function ScrollArea({
|
|
|
311
317
|
{
|
|
312
318
|
"data-slot": "scroll-area",
|
|
313
319
|
style: { position: "relative", ...style },
|
|
314
|
-
className: cn("
|
|
320
|
+
className: cn("datetime-range-scroll-area", className),
|
|
315
321
|
...props,
|
|
316
322
|
children: [
|
|
317
323
|
/* @__PURE__ */ jsx(
|
|
@@ -319,7 +325,7 @@ function ScrollArea({
|
|
|
319
325
|
{
|
|
320
326
|
ref: viewportRef,
|
|
321
327
|
"data-slot": "scroll-area-viewport",
|
|
322
|
-
className: "
|
|
328
|
+
className: "datetime-range-scroll-area-viewport",
|
|
323
329
|
children
|
|
324
330
|
}
|
|
325
331
|
),
|
|
@@ -340,18 +346,112 @@ function ScrollBar({
|
|
|
340
346
|
{
|
|
341
347
|
"data-slot": "scroll-area-scrollbar",
|
|
342
348
|
orientation,
|
|
343
|
-
className: cn("
|
|
349
|
+
className: cn("datetime-range-scrollbar", className),
|
|
344
350
|
...props,
|
|
345
351
|
children: /* @__PURE__ */ jsx(
|
|
346
352
|
ScrollArea$1.Thumb,
|
|
347
353
|
{
|
|
348
354
|
"data-slot": "scroll-area-thumb",
|
|
349
|
-
className: "
|
|
355
|
+
className: "datetime-range-scrollbar-thumb"
|
|
350
356
|
}
|
|
351
357
|
)
|
|
352
358
|
}
|
|
353
359
|
);
|
|
354
360
|
}
|
|
361
|
+
var defaultUIAdapter = {
|
|
362
|
+
Button,
|
|
363
|
+
Popover,
|
|
364
|
+
PopoverTrigger,
|
|
365
|
+
PopoverContent,
|
|
366
|
+
Select,
|
|
367
|
+
SelectTrigger,
|
|
368
|
+
SelectValue,
|
|
369
|
+
SelectContent,
|
|
370
|
+
SelectItem,
|
|
371
|
+
Tabs,
|
|
372
|
+
TabsList,
|
|
373
|
+
TabsTrigger,
|
|
374
|
+
TabsContent,
|
|
375
|
+
Input,
|
|
376
|
+
Switch,
|
|
377
|
+
ScrollArea
|
|
378
|
+
};
|
|
379
|
+
var DatetimeRangeUIContext = createContext(defaultUIAdapter);
|
|
380
|
+
function useResolvedDatetimeRangeUI(adapter) {
|
|
381
|
+
const parent = useContext(DatetimeRangeUIContext);
|
|
382
|
+
return useMemo(() => adapter ? { ...parent, ...adapter } : parent, [parent, adapter]);
|
|
383
|
+
}
|
|
384
|
+
function DatetimeRangeProvider({ adapter, children }) {
|
|
385
|
+
const value = useResolvedDatetimeRangeUI(adapter);
|
|
386
|
+
return /* @__PURE__ */ jsx(DatetimeRangeUIContext.Provider, { value, children });
|
|
387
|
+
}
|
|
388
|
+
function useDatetimeRangeUI() {
|
|
389
|
+
return useContext(DatetimeRangeUIContext);
|
|
390
|
+
}
|
|
391
|
+
function Button2(props) {
|
|
392
|
+
const { Button: Component } = useDatetimeRangeUI();
|
|
393
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
394
|
+
}
|
|
395
|
+
function Popover2(props) {
|
|
396
|
+
const { Popover: Component } = useDatetimeRangeUI();
|
|
397
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
398
|
+
}
|
|
399
|
+
function PopoverTrigger2(props) {
|
|
400
|
+
const { PopoverTrigger: Component } = useDatetimeRangeUI();
|
|
401
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
402
|
+
}
|
|
403
|
+
function PopoverContent2(props) {
|
|
404
|
+
const { PopoverContent: Component } = useDatetimeRangeUI();
|
|
405
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
406
|
+
}
|
|
407
|
+
function Select2(props) {
|
|
408
|
+
const { Select: Component } = useDatetimeRangeUI();
|
|
409
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
410
|
+
}
|
|
411
|
+
function SelectTrigger2(props) {
|
|
412
|
+
const { SelectTrigger: Component } = useDatetimeRangeUI();
|
|
413
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
414
|
+
}
|
|
415
|
+
function SelectValue2(props) {
|
|
416
|
+
const { SelectValue: Component } = useDatetimeRangeUI();
|
|
417
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
418
|
+
}
|
|
419
|
+
function SelectContent2(props) {
|
|
420
|
+
const { SelectContent: Component } = useDatetimeRangeUI();
|
|
421
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
422
|
+
}
|
|
423
|
+
function SelectItem2(props) {
|
|
424
|
+
const { SelectItem: Component } = useDatetimeRangeUI();
|
|
425
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
426
|
+
}
|
|
427
|
+
function Tabs2(props) {
|
|
428
|
+
const { Tabs: Component } = useDatetimeRangeUI();
|
|
429
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
430
|
+
}
|
|
431
|
+
function TabsList2(props) {
|
|
432
|
+
const { TabsList: Component } = useDatetimeRangeUI();
|
|
433
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
434
|
+
}
|
|
435
|
+
function TabsTrigger2(props) {
|
|
436
|
+
const { TabsTrigger: Component } = useDatetimeRangeUI();
|
|
437
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
438
|
+
}
|
|
439
|
+
function TabsContent2(props) {
|
|
440
|
+
const { TabsContent: Component } = useDatetimeRangeUI();
|
|
441
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
442
|
+
}
|
|
443
|
+
function Input2(props) {
|
|
444
|
+
const { Input: Component } = useDatetimeRangeUI();
|
|
445
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
446
|
+
}
|
|
447
|
+
function Switch2(props) {
|
|
448
|
+
const { Switch: Component } = useDatetimeRangeUI();
|
|
449
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
450
|
+
}
|
|
451
|
+
function ScrollArea2(props) {
|
|
452
|
+
const { ScrollArea: Component } = useDatetimeRangeUI();
|
|
453
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
454
|
+
}
|
|
355
455
|
var AM_VALUE = 0;
|
|
356
456
|
var PM_VALUE = 1;
|
|
357
457
|
function MonthYearPicker({ value, minDate, maxDate, mode = "month", onChange, className }) {
|
|
@@ -394,9 +494,9 @@ function MonthYearPicker({ value, minDate, maxDate, mode = "month", onChange, cl
|
|
|
394
494
|
yearRef.current?.scrollIntoView({ behavior: "auto", block: "center" });
|
|
395
495
|
}
|
|
396
496
|
}, [mode, value]);
|
|
397
|
-
return /* @__PURE__ */ jsx("div", { className: cn(className), children: /* @__PURE__ */ jsxs(
|
|
497
|
+
return /* @__PURE__ */ jsx("div", { className: cn(className), children: /* @__PURE__ */ jsxs(ScrollArea2, { className: "h-full", children: [
|
|
398
498
|
mode === "year" && /* @__PURE__ */ jsx("div", { className: "grid grid-cols-4", children: years.map((year) => /* @__PURE__ */ jsx("div", { ref: year.value === getYear(value) ? yearRef : void 0, children: /* @__PURE__ */ jsx(
|
|
399
|
-
|
|
499
|
+
Button2,
|
|
400
500
|
{
|
|
401
501
|
disabled: year.disabled,
|
|
402
502
|
variant: getYear(value) === year.value ? "default" : "ghost",
|
|
@@ -406,7 +506,7 @@ function MonthYearPicker({ value, minDate, maxDate, mode = "month", onChange, cl
|
|
|
406
506
|
}
|
|
407
507
|
) }, year.value)) }),
|
|
408
508
|
mode === "month" && /* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-4 mt-7", children: months.map((month) => /* @__PURE__ */ jsx(
|
|
409
|
-
|
|
509
|
+
Button2,
|
|
410
510
|
{
|
|
411
511
|
size: "lg",
|
|
412
512
|
disabled: month.disabled,
|
|
@@ -421,7 +521,7 @@ function MonthYearPicker({ value, minDate, maxDate, mode = "month", onChange, cl
|
|
|
421
521
|
}
|
|
422
522
|
function TimeItem({ option, selected, onSelect, className, disabled }) {
|
|
423
523
|
return /* @__PURE__ */ jsxs(
|
|
424
|
-
|
|
524
|
+
Button2,
|
|
425
525
|
{
|
|
426
526
|
variant: "ghost",
|
|
427
527
|
className: cn("flex justify-center px-1 pe-2 ps-1", className),
|
|
@@ -592,12 +692,12 @@ function TimePicker({ value, onChange, use12HourFormat, min, max, timePicker })
|
|
|
592
692
|
}
|
|
593
693
|
return format(value, parts.join(":") + (use12HourFormat ? " a" : ""));
|
|
594
694
|
}, [value, use12HourFormat, timePicker]);
|
|
595
|
-
return /* @__PURE__ */ jsxs(
|
|
695
|
+
return /* @__PURE__ */ jsxs(Popover2, { open, onOpenChange: setOpen, children: [
|
|
596
696
|
/* @__PURE__ */ jsx(
|
|
597
|
-
|
|
697
|
+
PopoverTrigger2,
|
|
598
698
|
{
|
|
599
699
|
render: (props) => /* @__PURE__ */ jsxs(
|
|
600
|
-
|
|
700
|
+
Button2,
|
|
601
701
|
{
|
|
602
702
|
...props,
|
|
603
703
|
variant: "ghost",
|
|
@@ -614,11 +714,11 @@ function TimePicker({ value, onChange, use12HourFormat, min, max, timePicker })
|
|
|
614
714
|
)
|
|
615
715
|
}
|
|
616
716
|
),
|
|
617
|
-
/* @__PURE__ */ jsx(
|
|
618
|
-
(!timePicker || timePicker.hour) && /* @__PURE__ */ jsx(
|
|
619
|
-
(!timePicker || timePicker.minute) && /* @__PURE__ */ jsx(
|
|
620
|
-
(!timePicker || timePicker.second) && /* @__PURE__ */ jsx(
|
|
621
|
-
use12HourFormat && /* @__PURE__ */ jsx(
|
|
717
|
+
/* @__PURE__ */ jsx(PopoverContent2, { className: "p-0", side: "top", children: /* @__PURE__ */ jsx("div", { className: "flex-col gap-2 p-2", children: /* @__PURE__ */ jsxs("div", { className: "flex h-56 grow", children: [
|
|
718
|
+
(!timePicker || timePicker.hour) && /* @__PURE__ */ jsx(ScrollArea2, { className: "h-full grow", viewportRef: hourViewportRef, children: /* @__PURE__ */ jsx("div", { className: "flex grow flex-col items-stretch overflow-y-auto pe-2 pb-48", children: hours.map((v) => /* @__PURE__ */ jsx(TimeItem, { option: v, selected: v.value === hour, onSelect: onHourChange, className: "h-8", disabled: v.disabled }, v.value)) }) }),
|
|
719
|
+
(!timePicker || timePicker.minute) && /* @__PURE__ */ jsx(ScrollArea2, { className: "h-full grow", viewportRef: minuteViewportRef, children: /* @__PURE__ */ jsx("div", { className: "flex grow flex-col items-stretch overflow-y-auto pe-2 pb-48", children: minutes.map((v) => /* @__PURE__ */ jsx(TimeItem, { option: v, selected: v.value === minute, onSelect: onMinuteChange, className: "h-8", disabled: v.disabled }, v.value)) }) }),
|
|
720
|
+
(!timePicker || timePicker.second) && /* @__PURE__ */ jsx(ScrollArea2, { className: "h-full grow", viewportRef: secondViewportRef, children: /* @__PURE__ */ jsx("div", { className: "flex grow flex-col items-stretch overflow-y-auto pe-2 pb-48", children: seconds.map((v) => /* @__PURE__ */ jsx(TimeItem, { option: v, selected: v.value === second, onSelect: (v2) => setSecond(v2.value), className: "h-8", disabled: v.disabled }, v.value)) }) }),
|
|
721
|
+
use12HourFormat && /* @__PURE__ */ jsx(ScrollArea2, { className: "h-full grow", children: /* @__PURE__ */ jsx("div", { className: "flex grow flex-col items-stretch overflow-y-auto pe-2", children: ampmOptions.map((v) => /* @__PURE__ */ jsx(TimeItem, { option: v, selected: v.value === ampm, onSelect: onAmpmChange, className: "h-8", disabled: v.disabled }, v.value)) }) })
|
|
622
722
|
] }) }) })
|
|
623
723
|
] });
|
|
624
724
|
}
|
|
@@ -709,20 +809,20 @@ function DateTimePanel({
|
|
|
709
809
|
setPreviousDate(initDate);
|
|
710
810
|
}, [initDate]);
|
|
711
811
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
712
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
713
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
812
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-panel-header", children: [
|
|
813
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-panel-nav-label", children: [
|
|
714
814
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
715
815
|
/* @__PURE__ */ jsx("span", { onClick: () => setMonthYearPicker(monthYearPicker === "month" ? false : "month"), children: format(month, "MMMM") }),
|
|
716
816
|
/* @__PURE__ */ jsx("span", { onClick: () => setMonthYearPicker(monthYearPicker === "year" ? false : "year"), children: format(month, "yyyy") })
|
|
717
817
|
] }),
|
|
718
|
-
/* @__PURE__ */ jsx(
|
|
818
|
+
/* @__PURE__ */ jsx(Button2, { variant: "ghost", size: "icon", onClick: () => setMonthYearPicker(monthYearPicker ? false : "year"), children: monthYearPicker ? /* @__PURE__ */ jsx(ChevronUpIcon, { style: { width: 16, height: 16 } }) : /* @__PURE__ */ jsx(ChevronDownIcon, { style: { width: 16, height: 16 } }) })
|
|
719
819
|
] }),
|
|
720
|
-
!monthYearPicker && /* @__PURE__ */ jsxs("div", { className: "
|
|
721
|
-
/* @__PURE__ */ jsx(
|
|
722
|
-
/* @__PURE__ */ jsx(
|
|
820
|
+
!monthYearPicker && /* @__PURE__ */ jsxs("div", { className: "datetime-range-panel-nav-btn", children: [
|
|
821
|
+
/* @__PURE__ */ jsx(Button2, { variant: "ghost", size: "icon", "aria-label": "Previous month", onClick: onPrevMonth, children: /* @__PURE__ */ jsx(ChevronLeftIcon, { style: { width: 16, height: 16 } }) }),
|
|
822
|
+
/* @__PURE__ */ jsx(Button2, { variant: "ghost", size: "icon", "aria-label": "Next month", onClick: onNextMonth, children: /* @__PURE__ */ jsx(ChevronRightIcon, { style: { width: 16, height: 16 } }) })
|
|
723
823
|
] })
|
|
724
824
|
] }),
|
|
725
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
825
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-panel-calendar", children: [
|
|
726
826
|
/* @__PURE__ */ jsx(
|
|
727
827
|
DayPicker,
|
|
728
828
|
{
|
|
@@ -747,31 +847,31 @@ function DateTimePanel({
|
|
|
747
847
|
disabled: [max ? { after: max } : null, min ? { before: min } : null].filter(Boolean),
|
|
748
848
|
onMonthChange: setMonth,
|
|
749
849
|
classNames: {
|
|
750
|
-
dropdowns: "
|
|
751
|
-
months: "
|
|
752
|
-
month: "
|
|
850
|
+
dropdowns: "datetime-range-cal-dropdowns",
|
|
851
|
+
months: "datetime-range-cal-months",
|
|
852
|
+
month: "datetime-range-cal-month",
|
|
753
853
|
month_caption: "hidden",
|
|
754
854
|
button_previous: "hidden",
|
|
755
855
|
button_next: "hidden",
|
|
756
|
-
month_grid: "
|
|
757
|
-
weekdays: "
|
|
758
|
-
weekday: "
|
|
759
|
-
week: "
|
|
760
|
-
day: "
|
|
761
|
-
day_button: "
|
|
762
|
-
range_end: "
|
|
763
|
-
selected: "
|
|
764
|
-
today: "
|
|
765
|
-
outside: "
|
|
766
|
-
disabled: "
|
|
767
|
-
range_middle: "
|
|
768
|
-
hidden: "
|
|
856
|
+
month_grid: "datetime-range-cal-month-grid",
|
|
857
|
+
weekdays: "datetime-range-cal-weekdays",
|
|
858
|
+
weekday: "datetime-range-cal-weekday",
|
|
859
|
+
week: "datetime-range-cal-week",
|
|
860
|
+
day: "datetime-range-cal-day",
|
|
861
|
+
day_button: "datetime-range-cal-day-btn",
|
|
862
|
+
range_end: "datetime-range-cal-day-range-end",
|
|
863
|
+
selected: "datetime-range-cal-day-selected",
|
|
864
|
+
today: "datetime-range-cal-day-today",
|
|
865
|
+
outside: "datetime-range-cal-day-outside",
|
|
866
|
+
disabled: "datetime-range-cal-day-disabled",
|
|
867
|
+
range_middle: "datetime-range-cal-day-range-middle",
|
|
868
|
+
hidden: "datetime-range-cal-day-hidden"
|
|
769
869
|
},
|
|
770
870
|
showOutsideDays: true,
|
|
771
871
|
...props
|
|
772
872
|
}
|
|
773
873
|
),
|
|
774
|
-
/* @__PURE__ */ jsx("div", { className: cn("
|
|
874
|
+
/* @__PURE__ */ jsx("div", { className: cn("datetime-range-panel-overlay", !monthYearPicker && "datetime-range-panel-overlay--hidden") }),
|
|
775
875
|
/* @__PURE__ */ jsx(
|
|
776
876
|
MonthYearPicker,
|
|
777
877
|
{
|
|
@@ -780,12 +880,12 @@ function DateTimePanel({
|
|
|
780
880
|
onChange: onMonthYearChanged,
|
|
781
881
|
minDate,
|
|
782
882
|
maxDate,
|
|
783
|
-
className: cn("
|
|
883
|
+
className: cn("datetime-range-panel-monthyear", !monthYearPicker && "datetime-range-panel-monthyear--hidden")
|
|
784
884
|
}
|
|
785
885
|
)
|
|
786
886
|
] }),
|
|
787
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
788
|
-
precision !== "date" && /* @__PURE__ */ jsx("div", { className: "
|
|
887
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-panel-footer", children: [
|
|
888
|
+
precision !== "date" && /* @__PURE__ */ jsx("div", { className: "datetime-range-panel-time", children: /* @__PURE__ */ jsx(
|
|
789
889
|
TimePicker,
|
|
790
890
|
{
|
|
791
891
|
timePicker: precisionToTimePicker(precision),
|
|
@@ -796,10 +896,10 @@ function DateTimePanel({
|
|
|
796
896
|
max: maxDate
|
|
797
897
|
}
|
|
798
898
|
) }),
|
|
799
|
-
(isError || errorType !== null) && /* @__PURE__ */ jsx("div", { className: "
|
|
800
|
-
!immediate && /* @__PURE__ */ jsxs("div", { className: "
|
|
801
|
-
/* @__PURE__ */ jsx(
|
|
802
|
-
/* @__PURE__ */ jsx(
|
|
899
|
+
(isError || errorType !== null) && /* @__PURE__ */ jsx("div", { className: "datetime-range-panel-error", children: /* @__PURE__ */ jsx("span", { className: "datetime-range-panel-error-msg", children: getRangeErrorMessage?.(errorType, title) ?? "Invalid date range." }) }),
|
|
900
|
+
!immediate && /* @__PURE__ */ jsxs("div", { className: "datetime-range-panel-buttons", children: [
|
|
901
|
+
/* @__PURE__ */ jsx(Button2, { variant: "outline", size: "sm", onClick: onCancel, children: "Cancel" }),
|
|
902
|
+
/* @__PURE__ */ jsx(Button2, { size: "sm", onClick: onSubmit, children: "Done" })
|
|
803
903
|
] })
|
|
804
904
|
] })
|
|
805
905
|
] });
|
|
@@ -959,7 +1059,7 @@ function DatetimeSegmentInput({
|
|
|
959
1059
|
"div",
|
|
960
1060
|
{
|
|
961
1061
|
ref: containerRef,
|
|
962
|
-
className: cn("
|
|
1062
|
+
className: cn("datetime-range-segment-input", className),
|
|
963
1063
|
"data-error": isError || void 0,
|
|
964
1064
|
"data-disabled": disabled || void 0,
|
|
965
1065
|
onMouseDown: (e) => {
|
|
@@ -972,8 +1072,8 @@ function DatetimeSegmentInput({
|
|
|
972
1072
|
children: activeSegments.map((seg, idx) => {
|
|
973
1073
|
const sep = idx === 0 ? null : idx === 3 ? "\xA0" : idx < 3 ? "-" : ":";
|
|
974
1074
|
const isFocused = typing[seg.key] !== null;
|
|
975
|
-
return /* @__PURE__ */ jsxs(
|
|
976
|
-
sep !== null && /* @__PURE__ */ jsx("span", { className: "
|
|
1075
|
+
return /* @__PURE__ */ jsxs(React2.Fragment, { children: [
|
|
1076
|
+
sep !== null && /* @__PURE__ */ jsx("span", { className: "datetime-range-segment-sep", "aria-hidden": true, children: sep }),
|
|
977
1077
|
/* @__PURE__ */ jsx(
|
|
978
1078
|
"div",
|
|
979
1079
|
{
|
|
@@ -986,7 +1086,7 @@ function DatetimeSegmentInput({
|
|
|
986
1086
|
"aria-valuemin": seg.min,
|
|
987
1087
|
"aria-valuemax": seg.max,
|
|
988
1088
|
tabIndex: disabled ? -1 : 0,
|
|
989
|
-
className: "
|
|
1089
|
+
className: "datetime-range-segment",
|
|
990
1090
|
"data-focused": isFocused || void 0,
|
|
991
1091
|
style: { height: "24px", lineHeight: "24px" },
|
|
992
1092
|
onKeyDown: (e) => handleKeyDown(e, seg),
|
|
@@ -1165,17 +1265,17 @@ function RelativeSidePanel({ value, onChange, relativeFormats, showNow, labels }
|
|
|
1165
1265
|
});
|
|
1166
1266
|
}
|
|
1167
1267
|
};
|
|
1168
|
-
return /* @__PURE__ */ jsxs("div", { className: "
|
|
1268
|
+
return /* @__PURE__ */ jsxs("div", { className: "datetime-range-relative", children: [
|
|
1169
1269
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
1170
|
-
/* @__PURE__ */ jsx("p", { className: "
|
|
1171
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
1270
|
+
/* @__PURE__ */ jsx("p", { className: "datetime-range-relative-label", children: labels.amount }),
|
|
1271
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-relative-row", children: [
|
|
1172
1272
|
/* @__PURE__ */ jsx(
|
|
1173
|
-
|
|
1273
|
+
Input2,
|
|
1174
1274
|
{
|
|
1175
1275
|
type: "text",
|
|
1176
1276
|
inputMode: "numeric",
|
|
1177
1277
|
pattern: "[0-9]*",
|
|
1178
|
-
className: "
|
|
1278
|
+
className: "datetime-range-relative-input",
|
|
1179
1279
|
disabled: isNow,
|
|
1180
1280
|
value: numValue,
|
|
1181
1281
|
onChange: (e) => {
|
|
@@ -1192,7 +1292,7 @@ function RelativeSidePanel({ value, onChange, relativeFormats, showNow, labels }
|
|
|
1192
1292
|
}
|
|
1193
1293
|
),
|
|
1194
1294
|
/* @__PURE__ */ jsxs(
|
|
1195
|
-
|
|
1295
|
+
Select2,
|
|
1196
1296
|
{
|
|
1197
1297
|
disabled: isNow,
|
|
1198
1298
|
value: format3,
|
|
@@ -1202,16 +1302,16 @@ function RelativeSidePanel({ value, onChange, relativeFormats, showNow, labels }
|
|
|
1202
1302
|
emit({ numValue, format: f, isNow });
|
|
1203
1303
|
},
|
|
1204
1304
|
children: [
|
|
1205
|
-
/* @__PURE__ */ jsx(
|
|
1206
|
-
/* @__PURE__ */ jsx(
|
|
1305
|
+
/* @__PURE__ */ jsx(SelectTrigger2, { children: /* @__PURE__ */ jsx(SelectValue2, { children: format3 }) }),
|
|
1306
|
+
/* @__PURE__ */ jsx(SelectContent2, { children: relativeFormats.map((f) => /* @__PURE__ */ jsx(SelectItem2, { value: f, children: f }, f)) })
|
|
1207
1307
|
]
|
|
1208
1308
|
}
|
|
1209
1309
|
)
|
|
1210
1310
|
] })
|
|
1211
1311
|
] }),
|
|
1212
|
-
showNow && /* @__PURE__ */ jsxs("div", { className: "
|
|
1312
|
+
showNow && /* @__PURE__ */ jsxs("div", { className: "datetime-range-relative-now-row", children: [
|
|
1213
1313
|
/* @__PURE__ */ jsx(
|
|
1214
|
-
|
|
1314
|
+
Switch2,
|
|
1215
1315
|
{
|
|
1216
1316
|
checked: isNow,
|
|
1217
1317
|
onCheckedChange: (checked) => {
|
|
@@ -1220,9 +1320,9 @@ function RelativeSidePanel({ value, onChange, relativeFormats, showNow, labels }
|
|
|
1220
1320
|
}
|
|
1221
1321
|
}
|
|
1222
1322
|
),
|
|
1223
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
1224
|
-
/* @__PURE__ */ jsx("label", { className: "
|
|
1225
|
-
/* @__PURE__ */ jsx("span", { className: "
|
|
1323
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-relative-now-labels", children: [
|
|
1324
|
+
/* @__PURE__ */ jsx("label", { className: "datetime-range-relative-now-label", children: labels.now }),
|
|
1325
|
+
/* @__PURE__ */ jsx("span", { className: "datetime-range-relative-now-desc", children: labels.nowDescription })
|
|
1226
1326
|
] })
|
|
1227
1327
|
] })
|
|
1228
1328
|
] });
|
|
@@ -1236,67 +1336,72 @@ function AbsoluteContent({
|
|
|
1236
1336
|
min,
|
|
1237
1337
|
max,
|
|
1238
1338
|
timezone,
|
|
1239
|
-
use12HourFormat
|
|
1339
|
+
use12HourFormat,
|
|
1340
|
+
calendarMode = "popover"
|
|
1240
1341
|
}) {
|
|
1241
1342
|
const compareDate = compareValue ? toDate(compareValue) : void 0;
|
|
1242
1343
|
const currentDate = value.type === "absolute" ? toDate(value) : /* @__PURE__ */ new Date();
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1344
|
+
const calendarPanel = /* @__PURE__ */ jsx(
|
|
1345
|
+
DateTimePanel,
|
|
1346
|
+
{
|
|
1347
|
+
value: value.type === "absolute" ? currentDate : void 0,
|
|
1348
|
+
compareValue: compareDate,
|
|
1349
|
+
title,
|
|
1350
|
+
immediate: true,
|
|
1351
|
+
precision,
|
|
1352
|
+
min,
|
|
1353
|
+
max,
|
|
1354
|
+
timezone,
|
|
1355
|
+
use12HourFormat,
|
|
1356
|
+
onChangeAction: (d) => {
|
|
1357
|
+
if (!d) return;
|
|
1358
|
+
onChange(absoluteDate(d));
|
|
1251
1359
|
}
|
|
1252
|
-
|
|
1253
|
-
|
|
1360
|
+
}
|
|
1361
|
+
);
|
|
1362
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
1363
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-absolute-row", children: [
|
|
1254
1364
|
/* @__PURE__ */ jsx(
|
|
1255
|
-
|
|
1365
|
+
DatetimeSegmentInput,
|
|
1256
1366
|
{
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
type: "button",
|
|
1262
|
-
variant: "outline",
|
|
1263
|
-
size: "icon",
|
|
1264
|
-
className: "dr-absolute-btn",
|
|
1265
|
-
title: "Pick from calendar",
|
|
1266
|
-
children: /* @__PURE__ */ jsx(CalendarDays, { size: 14 })
|
|
1267
|
-
}
|
|
1268
|
-
)
|
|
1367
|
+
value: currentDate,
|
|
1368
|
+
onChange: (d) => onChange(absoluteDate(d)),
|
|
1369
|
+
className: "datetime-range-absolute-input",
|
|
1370
|
+
precision
|
|
1269
1371
|
}
|
|
1270
1372
|
),
|
|
1271
|
-
/* @__PURE__ */
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
immediate: true,
|
|
1286
|
-
precision,
|
|
1287
|
-
min,
|
|
1288
|
-
max,
|
|
1289
|
-
timezone,
|
|
1290
|
-
use12HourFormat,
|
|
1291
|
-
onChangeAction: (d) => {
|
|
1292
|
-
if (!d) return;
|
|
1293
|
-
onChange(absoluteDate(d));
|
|
1373
|
+
calendarMode === "popover" && /* @__PURE__ */ jsxs(Popover2, { children: [
|
|
1374
|
+
/* @__PURE__ */ jsx(
|
|
1375
|
+
PopoverTrigger2,
|
|
1376
|
+
{
|
|
1377
|
+
render: (triggerProps) => /* @__PURE__ */ jsx(
|
|
1378
|
+
Button2,
|
|
1379
|
+
{
|
|
1380
|
+
...triggerProps,
|
|
1381
|
+
type: "button",
|
|
1382
|
+
variant: "outline",
|
|
1383
|
+
size: "icon",
|
|
1384
|
+
className: "datetime-range-absolute-btn",
|
|
1385
|
+
title: "Pick from calendar",
|
|
1386
|
+
children: /* @__PURE__ */ jsx(CalendarDays, { size: 14 })
|
|
1294
1387
|
}
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1388
|
+
)
|
|
1389
|
+
}
|
|
1390
|
+
),
|
|
1391
|
+
/* @__PURE__ */ jsx(
|
|
1392
|
+
PopoverContent2,
|
|
1393
|
+
{
|
|
1394
|
+
className: "p-0 w-auto",
|
|
1395
|
+
side: "bottom",
|
|
1396
|
+
align: "start",
|
|
1397
|
+
sideOffset: 6,
|
|
1398
|
+
disableAnchorTracking: true,
|
|
1399
|
+
children: calendarPanel
|
|
1400
|
+
}
|
|
1401
|
+
)
|
|
1402
|
+
] })
|
|
1403
|
+
] }),
|
|
1404
|
+
calendarMode === "inline" && /* @__PURE__ */ jsx("div", { className: "datetime-range-absolute-inline-calendar", children: calendarPanel })
|
|
1300
1405
|
] });
|
|
1301
1406
|
}
|
|
1302
1407
|
function SidePanel({
|
|
@@ -1313,7 +1418,9 @@ function SidePanel({
|
|
|
1313
1418
|
max,
|
|
1314
1419
|
timezone,
|
|
1315
1420
|
use12HourFormat,
|
|
1316
|
-
labels: labelsProp
|
|
1421
|
+
labels: labelsProp,
|
|
1422
|
+
calendarMode,
|
|
1423
|
+
uiAdapter
|
|
1317
1424
|
}) {
|
|
1318
1425
|
const labels = { ...DEFAULT_LABELS, ...labelsProp };
|
|
1319
1426
|
useEffect(() => {
|
|
@@ -1335,7 +1442,8 @@ function SidePanel({
|
|
|
1335
1442
|
min,
|
|
1336
1443
|
max,
|
|
1337
1444
|
timezone,
|
|
1338
|
-
use12HourFormat
|
|
1445
|
+
use12HourFormat,
|
|
1446
|
+
calendarMode
|
|
1339
1447
|
}
|
|
1340
1448
|
);
|
|
1341
1449
|
const relativeContent = /* @__PURE__ */ jsx(
|
|
@@ -1348,13 +1456,13 @@ function SidePanel({
|
|
|
1348
1456
|
labels
|
|
1349
1457
|
}
|
|
1350
1458
|
);
|
|
1351
|
-
|
|
1352
|
-
/* @__PURE__ */ jsx("p", { className: "
|
|
1459
|
+
const content = /* @__PURE__ */ jsxs("div", { className: "datetime-range-side-panel", children: [
|
|
1460
|
+
/* @__PURE__ */ jsx("p", { className: "datetime-range-side-panel-title", children: title }),
|
|
1353
1461
|
hasBothModes ? /* @__PURE__ */ jsxs(
|
|
1354
|
-
|
|
1462
|
+
Tabs2,
|
|
1355
1463
|
{
|
|
1356
1464
|
value: value.type,
|
|
1357
|
-
className: "
|
|
1465
|
+
className: "datetime-range-side-panel-tabs",
|
|
1358
1466
|
onValueChange: (t) => {
|
|
1359
1467
|
if (t === "absolute") {
|
|
1360
1468
|
onChange(absoluteDate(value.type === "absolute" ? toDate(value) : /* @__PURE__ */ new Date()));
|
|
@@ -1363,16 +1471,17 @@ function SidePanel({
|
|
|
1363
1471
|
}
|
|
1364
1472
|
},
|
|
1365
1473
|
children: [
|
|
1366
|
-
/* @__PURE__ */ jsxs(
|
|
1367
|
-
/* @__PURE__ */ jsx(
|
|
1368
|
-
/* @__PURE__ */ jsx(
|
|
1474
|
+
/* @__PURE__ */ jsxs(TabsList2, { className: "datetime-range-tabs-list--grid datetime-range-tabs-list--grid-2", children: [
|
|
1475
|
+
/* @__PURE__ */ jsx(TabsTrigger2, { value: "absolute", children: labels.absolute }),
|
|
1476
|
+
/* @__PURE__ */ jsx(TabsTrigger2, { value: "relative", children: labels.relative })
|
|
1369
1477
|
] }),
|
|
1370
|
-
/* @__PURE__ */ jsx(
|
|
1371
|
-
/* @__PURE__ */ jsx(
|
|
1478
|
+
/* @__PURE__ */ jsx(TabsContent2, { value: "absolute", children: absoluteContent }),
|
|
1479
|
+
/* @__PURE__ */ jsx(TabsContent2, { value: "relative", children: relativeContent })
|
|
1372
1480
|
]
|
|
1373
1481
|
}
|
|
1374
1482
|
) : showAbsolute ? absoluteContent : relativeContent
|
|
1375
1483
|
] });
|
|
1484
|
+
return uiAdapter ? /* @__PURE__ */ jsx(DatetimeRangeProvider, { adapter: uiAdapter, children: content }) : content;
|
|
1376
1485
|
}
|
|
1377
1486
|
function useDatetimeRange({
|
|
1378
1487
|
startTime,
|
|
@@ -1442,13 +1551,15 @@ function DatetimeRange({
|
|
|
1442
1551
|
timezone,
|
|
1443
1552
|
use12HourFormat = false,
|
|
1444
1553
|
showNow = true,
|
|
1554
|
+
calendarMode = "popover",
|
|
1445
1555
|
disabled = false,
|
|
1446
1556
|
labels: labelsProp,
|
|
1447
1557
|
popoverAlign = "start",
|
|
1448
1558
|
popoverSide = "bottom",
|
|
1449
1559
|
renderTrigger,
|
|
1450
1560
|
portalContainer,
|
|
1451
|
-
className
|
|
1561
|
+
className,
|
|
1562
|
+
uiAdapter
|
|
1452
1563
|
}) {
|
|
1453
1564
|
const labels = { ...DEFAULT_LABELS, ...labelsProp };
|
|
1454
1565
|
const {
|
|
@@ -1474,24 +1585,25 @@ function DatetimeRange({
|
|
|
1474
1585
|
max,
|
|
1475
1586
|
timezone,
|
|
1476
1587
|
use12HourFormat,
|
|
1477
|
-
labels
|
|
1588
|
+
labels,
|
|
1589
|
+
calendarMode
|
|
1478
1590
|
};
|
|
1479
|
-
|
|
1591
|
+
const content = /* @__PURE__ */ jsxs(Popover2, { open: isOpen, onOpenChange: disabled ? void 0 : setIsOpen, children: [
|
|
1480
1592
|
/* @__PURE__ */ jsx(
|
|
1481
|
-
|
|
1593
|
+
PopoverTrigger2,
|
|
1482
1594
|
{
|
|
1483
1595
|
disabled,
|
|
1484
1596
|
render: (triggerProps) => renderTrigger ? renderTrigger(triggerProps, { open: isOpen, startTime, endTime }) : /* @__PURE__ */ jsxs(
|
|
1485
|
-
|
|
1597
|
+
Button2,
|
|
1486
1598
|
{
|
|
1487
1599
|
...triggerProps,
|
|
1488
1600
|
variant: "outline",
|
|
1489
1601
|
disabled,
|
|
1490
|
-
className: cn("
|
|
1602
|
+
className: cn("datetime-range-range-trigger", isOpen && "datetime-range-range-trigger--open", className),
|
|
1491
1603
|
children: [
|
|
1492
|
-
/* @__PURE__ */ jsx(CalendarDays, { size: 14, className: "
|
|
1604
|
+
/* @__PURE__ */ jsx(CalendarDays, { size: 14, className: "datetime-range-range-trigger-icon" }),
|
|
1493
1605
|
/* @__PURE__ */ jsx("span", { children: toDisplayString(startTime, { precision }) }),
|
|
1494
|
-
/* @__PURE__ */ jsx("span", { className: "
|
|
1606
|
+
/* @__PURE__ */ jsx("span", { className: "datetime-range-range-trigger-arrow", children: "\u2192" }),
|
|
1495
1607
|
/* @__PURE__ */ jsx("span", { children: toDisplayString(endTime, { precision }) })
|
|
1496
1608
|
]
|
|
1497
1609
|
}
|
|
@@ -1499,31 +1611,31 @@ function DatetimeRange({
|
|
|
1499
1611
|
}
|
|
1500
1612
|
),
|
|
1501
1613
|
/* @__PURE__ */ jsx(
|
|
1502
|
-
|
|
1614
|
+
PopoverContent2,
|
|
1503
1615
|
{
|
|
1504
|
-
className: "
|
|
1616
|
+
className: "datetime-range-range-popup-content",
|
|
1505
1617
|
align: popoverAlign,
|
|
1506
1618
|
side: popoverSide,
|
|
1507
1619
|
sideOffset: 4,
|
|
1508
1620
|
container: portalContainer,
|
|
1509
|
-
children: /* @__PURE__ */ jsxs("div", { className: "
|
|
1510
|
-
showQuickRanges && quickPresets.length > 0 && /* @__PURE__ */ jsx("div", { className: "
|
|
1511
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
1512
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
1621
|
+
children: /* @__PURE__ */ jsxs("div", { className: "datetime-range-range-popup", children: [
|
|
1622
|
+
showQuickRanges && quickPresets.length > 0 && /* @__PURE__ */ jsx("div", { className: "datetime-range-range-quick", children: /* @__PURE__ */ jsxs("div", { className: "datetime-range-range-quick-inner", children: [
|
|
1623
|
+
/* @__PURE__ */ jsx("div", { className: "datetime-range-range-quick-label", children: labels.quickRanges }),
|
|
1624
|
+
/* @__PURE__ */ jsx("div", { className: "datetime-range-range-quick-list", children: quickPresets.map((preset) => /* @__PURE__ */ jsx(
|
|
1513
1625
|
"button",
|
|
1514
1626
|
{
|
|
1515
1627
|
type: "button",
|
|
1516
|
-
className: "
|
|
1628
|
+
className: "datetime-range-range-quick-item",
|
|
1517
1629
|
onClick: () => handlePreset(preset),
|
|
1518
1630
|
children: preset.label
|
|
1519
1631
|
},
|
|
1520
1632
|
preset.label
|
|
1521
1633
|
)) })
|
|
1522
1634
|
] }) }),
|
|
1523
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
1524
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
1525
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
1526
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
1635
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-range-pickers", children: [
|
|
1636
|
+
/* @__PURE__ */ jsx("div", { className: "datetime-range-range-divider" }),
|
|
1637
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-range-panels", children: [
|
|
1638
|
+
/* @__PURE__ */ jsx("div", { className: "datetime-range-range-panel-slot", children: /* @__PURE__ */ jsx(
|
|
1527
1639
|
SidePanel,
|
|
1528
1640
|
{
|
|
1529
1641
|
title: labels.start,
|
|
@@ -1536,7 +1648,7 @@ function DatetimeRange({
|
|
|
1536
1648
|
...sidePanelProps
|
|
1537
1649
|
}
|
|
1538
1650
|
) }),
|
|
1539
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
1651
|
+
/* @__PURE__ */ jsx("div", { className: "datetime-range-range-panel-slot", children: /* @__PURE__ */ jsx(
|
|
1540
1652
|
SidePanel,
|
|
1541
1653
|
{
|
|
1542
1654
|
title: labels.end,
|
|
@@ -1550,11 +1662,11 @@ function DatetimeRange({
|
|
|
1550
1662
|
}
|
|
1551
1663
|
) })
|
|
1552
1664
|
] }),
|
|
1553
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
1554
|
-
error === "validation" ? /* @__PURE__ */ jsx("span", { className: "
|
|
1555
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
1556
|
-
/* @__PURE__ */ jsx(
|
|
1557
|
-
/* @__PURE__ */ jsx(
|
|
1665
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-range-footer", children: [
|
|
1666
|
+
error === "validation" ? /* @__PURE__ */ jsx("span", { className: "datetime-range-range-error-text", children: "Start must be earlier than end." }) : /* @__PURE__ */ jsx("span", {}),
|
|
1667
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-range-actions", children: [
|
|
1668
|
+
/* @__PURE__ */ jsx(Button2, { variant: "outline", size: "sm", onClick: handleCancel, children: labels.cancel }),
|
|
1669
|
+
/* @__PURE__ */ jsx(Button2, { size: "sm", onClick: handleApply, children: labels.apply })
|
|
1558
1670
|
] })
|
|
1559
1671
|
] })
|
|
1560
1672
|
] })
|
|
@@ -1562,8 +1674,9 @@ function DatetimeRange({
|
|
|
1562
1674
|
}
|
|
1563
1675
|
)
|
|
1564
1676
|
] });
|
|
1677
|
+
return uiAdapter ? /* @__PURE__ */ jsx(DatetimeRangeProvider, { adapter: uiAdapter, children: content }) : content;
|
|
1565
1678
|
}
|
|
1566
1679
|
|
|
1567
|
-
export { DateTimePanel, DatetimeRange, DatetimeSegmentInput, QUICK_PRESETS, RELATIVE_FORMATS, SidePanel, absoluteDate, fromUrlString, relativeAgo, relativeNow, toDate, toDisplayString, toTimestamp, toTimestampMs, toUrlString, useDatetimeRange, validateRange };
|
|
1680
|
+
export { DateTimePanel, DatetimeRange, DatetimeRangeProvider, DatetimeSegmentInput, QUICK_PRESETS, RELATIVE_FORMATS, SidePanel, absoluteDate, fromUrlString, relativeAgo, relativeNow, toDate, toDisplayString, toTimestamp, toTimestampMs, toUrlString, useDatetimeRange, useDatetimeRangeUI, validateRange };
|
|
1568
1681
|
//# sourceMappingURL=index.js.map
|
|
1569
1682
|
//# sourceMappingURL=index.js.map
|