@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.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,7 +25,7 @@ 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,
|
|
@@ -70,89 +70,25 @@ function PopoverContent({
|
|
|
70
70
|
sideOffset,
|
|
71
71
|
disableAnchorTracking,
|
|
72
72
|
collisionAvoidance,
|
|
73
|
-
className: "
|
|
73
|
+
className: "datetime-range-positioner",
|
|
74
74
|
children: /* @__PURE__ */ jsx(
|
|
75
75
|
Popover$1.Popup,
|
|
76
76
|
{
|
|
77
77
|
"data-slot": "popover-content",
|
|
78
|
-
className: cn("
|
|
78
|
+
className: cn("datetime-range-popover-content", className),
|
|
79
79
|
...props
|
|
80
80
|
}
|
|
81
81
|
)
|
|
82
82
|
}
|
|
83
83
|
) });
|
|
84
84
|
}
|
|
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
85
|
var Select = Select$1.Root;
|
|
150
86
|
function SelectValue({ className, ...props }) {
|
|
151
87
|
return /* @__PURE__ */ jsx(
|
|
152
88
|
Select$1.Value,
|
|
153
89
|
{
|
|
154
90
|
"data-slot": "select-value",
|
|
155
|
-
className: cn("
|
|
91
|
+
className: cn("datetime-range-select-value", className),
|
|
156
92
|
...props
|
|
157
93
|
}
|
|
158
94
|
);
|
|
@@ -168,7 +104,7 @@ function SelectTrigger({
|
|
|
168
104
|
{
|
|
169
105
|
"data-slot": "select-trigger",
|
|
170
106
|
"data-size": size,
|
|
171
|
-
className: cn("
|
|
107
|
+
className: cn("datetime-range-select-trigger", className),
|
|
172
108
|
...props,
|
|
173
109
|
children: [
|
|
174
110
|
children,
|
|
@@ -180,7 +116,7 @@ function SelectTrigger({
|
|
|
180
116
|
{
|
|
181
117
|
icon: UnfoldMoreIcon,
|
|
182
118
|
strokeWidth: 2,
|
|
183
|
-
className: "
|
|
119
|
+
className: "datetime-range-select-icon"
|
|
184
120
|
}
|
|
185
121
|
)
|
|
186
122
|
}
|
|
@@ -207,13 +143,13 @@ function SelectContent({
|
|
|
207
143
|
align,
|
|
208
144
|
alignOffset,
|
|
209
145
|
alignItemWithTrigger,
|
|
210
|
-
className: "
|
|
146
|
+
className: "datetime-range-positioner",
|
|
211
147
|
children: /* @__PURE__ */ jsxs(
|
|
212
148
|
Select$1.Popup,
|
|
213
149
|
{
|
|
214
150
|
"data-slot": "select-content",
|
|
215
151
|
"data-align-trigger": alignItemWithTrigger,
|
|
216
|
-
className: cn("
|
|
152
|
+
className: cn("datetime-range-select-content", className),
|
|
217
153
|
...props,
|
|
218
154
|
children: [
|
|
219
155
|
/* @__PURE__ */ jsx(SelectScrollUpButton, {}),
|
|
@@ -234,14 +170,14 @@ function SelectItem({
|
|
|
234
170
|
Select$1.Item,
|
|
235
171
|
{
|
|
236
172
|
"data-slot": "select-item",
|
|
237
|
-
className: cn("
|
|
173
|
+
className: cn("datetime-range-select-item", className),
|
|
238
174
|
...props,
|
|
239
175
|
children: [
|
|
240
|
-
/* @__PURE__ */ jsx(Select$1.ItemText, { className: "
|
|
176
|
+
/* @__PURE__ */ jsx(Select$1.ItemText, { className: "datetime-range-select-item-text", children }),
|
|
241
177
|
/* @__PURE__ */ jsx(
|
|
242
178
|
Select$1.ItemIndicator,
|
|
243
179
|
{
|
|
244
|
-
render: /* @__PURE__ */ jsx("span", { className: "
|
|
180
|
+
render: /* @__PURE__ */ jsx("span", { className: "datetime-range-select-item-indicator" }),
|
|
245
181
|
children: /* @__PURE__ */ jsx(HugeiconsIcon, { icon: Tick02Icon, strokeWidth: 2, style: { pointerEvents: "none" } })
|
|
246
182
|
}
|
|
247
183
|
)
|
|
@@ -257,7 +193,7 @@ function SelectScrollUpButton({
|
|
|
257
193
|
Select$1.ScrollUpArrow,
|
|
258
194
|
{
|
|
259
195
|
"data-slot": "select-scroll-up-button",
|
|
260
|
-
className: cn("
|
|
196
|
+
className: cn("datetime-range-select-scroll-btn datetime-range-select-scroll-btn--up", className),
|
|
261
197
|
...props,
|
|
262
198
|
children: /* @__PURE__ */ jsx(HugeiconsIcon, { icon: ArrowUp01Icon, strokeWidth: 2 })
|
|
263
199
|
}
|
|
@@ -271,12 +207,76 @@ function SelectScrollDownButton({
|
|
|
271
207
|
Select$1.ScrollDownArrow,
|
|
272
208
|
{
|
|
273
209
|
"data-slot": "select-scroll-down-button",
|
|
274
|
-
className: cn("
|
|
210
|
+
className: cn("datetime-range-select-scroll-btn datetime-range-select-scroll-btn--down", className),
|
|
275
211
|
...props,
|
|
276
212
|
children: /* @__PURE__ */ jsx(HugeiconsIcon, { icon: ArrowDown01Icon, strokeWidth: 2 })
|
|
277
213
|
}
|
|
278
214
|
);
|
|
279
215
|
}
|
|
216
|
+
function Tabs({
|
|
217
|
+
className,
|
|
218
|
+
orientation = "horizontal",
|
|
219
|
+
...props
|
|
220
|
+
}) {
|
|
221
|
+
return /* @__PURE__ */ jsx(
|
|
222
|
+
Tabs$1.Root,
|
|
223
|
+
{
|
|
224
|
+
"data-slot": "tabs",
|
|
225
|
+
"data-orientation": orientation,
|
|
226
|
+
className: cn("datetime-range-tabs", className),
|
|
227
|
+
...props
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
function TabsList({
|
|
232
|
+
className,
|
|
233
|
+
variant = "default",
|
|
234
|
+
...props
|
|
235
|
+
}) {
|
|
236
|
+
return /* @__PURE__ */ jsx(
|
|
237
|
+
Tabs$1.List,
|
|
238
|
+
{
|
|
239
|
+
"data-slot": "tabs-list",
|
|
240
|
+
"data-variant": variant,
|
|
241
|
+
className: cn("datetime-range-tabs-list", className),
|
|
242
|
+
...props
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
function TabsTrigger({ className, ...props }) {
|
|
247
|
+
return /* @__PURE__ */ jsx(
|
|
248
|
+
Tabs$1.Tab,
|
|
249
|
+
{
|
|
250
|
+
"data-slot": "tabs-trigger",
|
|
251
|
+
className: cn("datetime-range-tabs-trigger", className),
|
|
252
|
+
...props
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
function TabsContent({ className, ...props }) {
|
|
257
|
+
return /* @__PURE__ */ jsx(
|
|
258
|
+
Tabs$1.Panel,
|
|
259
|
+
{
|
|
260
|
+
"data-slot": "tabs-content",
|
|
261
|
+
className: cn("datetime-range-tabs-content", className),
|
|
262
|
+
...props
|
|
263
|
+
}
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
function Input({ className, type, ...props }) {
|
|
267
|
+
return /* @__PURE__ */ jsx(
|
|
268
|
+
Input$1,
|
|
269
|
+
{
|
|
270
|
+
type,
|
|
271
|
+
"data-slot": "input",
|
|
272
|
+
className: cn(
|
|
273
|
+
"datetime-range-input",
|
|
274
|
+
className
|
|
275
|
+
),
|
|
276
|
+
...props
|
|
277
|
+
}
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
280
|
function Switch({
|
|
281
281
|
className,
|
|
282
282
|
size = "default",
|
|
@@ -287,13 +287,13 @@ function Switch({
|
|
|
287
287
|
{
|
|
288
288
|
"data-slot": "switch",
|
|
289
289
|
"data-size": size,
|
|
290
|
-
className: cn("
|
|
290
|
+
className: cn("datetime-range-switch", className),
|
|
291
291
|
...props,
|
|
292
292
|
children: /* @__PURE__ */ jsx(
|
|
293
293
|
Switch$1.Thumb,
|
|
294
294
|
{
|
|
295
295
|
"data-slot": "switch-thumb",
|
|
296
|
-
className: "
|
|
296
|
+
className: "datetime-range-switch-thumb"
|
|
297
297
|
}
|
|
298
298
|
)
|
|
299
299
|
}
|
|
@@ -311,7 +311,7 @@ function ScrollArea({
|
|
|
311
311
|
{
|
|
312
312
|
"data-slot": "scroll-area",
|
|
313
313
|
style: { position: "relative", ...style },
|
|
314
|
-
className: cn("
|
|
314
|
+
className: cn("datetime-range-scroll-area", className),
|
|
315
315
|
...props,
|
|
316
316
|
children: [
|
|
317
317
|
/* @__PURE__ */ jsx(
|
|
@@ -319,7 +319,7 @@ function ScrollArea({
|
|
|
319
319
|
{
|
|
320
320
|
ref: viewportRef,
|
|
321
321
|
"data-slot": "scroll-area-viewport",
|
|
322
|
-
className: "
|
|
322
|
+
className: "datetime-range-scroll-area-viewport",
|
|
323
323
|
children
|
|
324
324
|
}
|
|
325
325
|
),
|
|
@@ -340,18 +340,112 @@ function ScrollBar({
|
|
|
340
340
|
{
|
|
341
341
|
"data-slot": "scroll-area-scrollbar",
|
|
342
342
|
orientation,
|
|
343
|
-
className: cn("
|
|
343
|
+
className: cn("datetime-range-scrollbar", className),
|
|
344
344
|
...props,
|
|
345
345
|
children: /* @__PURE__ */ jsx(
|
|
346
346
|
ScrollArea$1.Thumb,
|
|
347
347
|
{
|
|
348
348
|
"data-slot": "scroll-area-thumb",
|
|
349
|
-
className: "
|
|
349
|
+
className: "datetime-range-scrollbar-thumb"
|
|
350
350
|
}
|
|
351
351
|
)
|
|
352
352
|
}
|
|
353
353
|
);
|
|
354
354
|
}
|
|
355
|
+
var defaultUIAdapter = {
|
|
356
|
+
Button,
|
|
357
|
+
Popover,
|
|
358
|
+
PopoverTrigger,
|
|
359
|
+
PopoverContent,
|
|
360
|
+
Select,
|
|
361
|
+
SelectTrigger,
|
|
362
|
+
SelectValue,
|
|
363
|
+
SelectContent,
|
|
364
|
+
SelectItem,
|
|
365
|
+
Tabs,
|
|
366
|
+
TabsList,
|
|
367
|
+
TabsTrigger,
|
|
368
|
+
TabsContent,
|
|
369
|
+
Input,
|
|
370
|
+
Switch,
|
|
371
|
+
ScrollArea
|
|
372
|
+
};
|
|
373
|
+
var DatetimeRangeUIContext = createContext(defaultUIAdapter);
|
|
374
|
+
function useResolvedDatetimeRangeUI(adapter) {
|
|
375
|
+
const parent = useContext(DatetimeRangeUIContext);
|
|
376
|
+
return useMemo(() => adapter ? { ...parent, ...adapter } : parent, [parent, adapter]);
|
|
377
|
+
}
|
|
378
|
+
function DatetimeRangeProvider({ adapter, children }) {
|
|
379
|
+
const value = useResolvedDatetimeRangeUI(adapter);
|
|
380
|
+
return /* @__PURE__ */ jsx(DatetimeRangeUIContext.Provider, { value, children });
|
|
381
|
+
}
|
|
382
|
+
function useDatetimeRangeUI() {
|
|
383
|
+
return useContext(DatetimeRangeUIContext);
|
|
384
|
+
}
|
|
385
|
+
function Button2(props) {
|
|
386
|
+
const { Button: Component } = useDatetimeRangeUI();
|
|
387
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
388
|
+
}
|
|
389
|
+
function Popover2(props) {
|
|
390
|
+
const { Popover: Component } = useDatetimeRangeUI();
|
|
391
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
392
|
+
}
|
|
393
|
+
function PopoverTrigger2(props) {
|
|
394
|
+
const { PopoverTrigger: Component } = useDatetimeRangeUI();
|
|
395
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
396
|
+
}
|
|
397
|
+
function PopoverContent2(props) {
|
|
398
|
+
const { PopoverContent: Component } = useDatetimeRangeUI();
|
|
399
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
400
|
+
}
|
|
401
|
+
function Select2(props) {
|
|
402
|
+
const { Select: Component } = useDatetimeRangeUI();
|
|
403
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
404
|
+
}
|
|
405
|
+
function SelectTrigger2(props) {
|
|
406
|
+
const { SelectTrigger: Component } = useDatetimeRangeUI();
|
|
407
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
408
|
+
}
|
|
409
|
+
function SelectValue2(props) {
|
|
410
|
+
const { SelectValue: Component } = useDatetimeRangeUI();
|
|
411
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
412
|
+
}
|
|
413
|
+
function SelectContent2(props) {
|
|
414
|
+
const { SelectContent: Component } = useDatetimeRangeUI();
|
|
415
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
416
|
+
}
|
|
417
|
+
function SelectItem2(props) {
|
|
418
|
+
const { SelectItem: Component } = useDatetimeRangeUI();
|
|
419
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
420
|
+
}
|
|
421
|
+
function Tabs2(props) {
|
|
422
|
+
const { Tabs: Component } = useDatetimeRangeUI();
|
|
423
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
424
|
+
}
|
|
425
|
+
function TabsList2(props) {
|
|
426
|
+
const { TabsList: Component } = useDatetimeRangeUI();
|
|
427
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
428
|
+
}
|
|
429
|
+
function TabsTrigger2(props) {
|
|
430
|
+
const { TabsTrigger: Component } = useDatetimeRangeUI();
|
|
431
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
432
|
+
}
|
|
433
|
+
function TabsContent2(props) {
|
|
434
|
+
const { TabsContent: Component } = useDatetimeRangeUI();
|
|
435
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
436
|
+
}
|
|
437
|
+
function Input2(props) {
|
|
438
|
+
const { Input: Component } = useDatetimeRangeUI();
|
|
439
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
440
|
+
}
|
|
441
|
+
function Switch2(props) {
|
|
442
|
+
const { Switch: Component } = useDatetimeRangeUI();
|
|
443
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
444
|
+
}
|
|
445
|
+
function ScrollArea2(props) {
|
|
446
|
+
const { ScrollArea: Component } = useDatetimeRangeUI();
|
|
447
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
448
|
+
}
|
|
355
449
|
var AM_VALUE = 0;
|
|
356
450
|
var PM_VALUE = 1;
|
|
357
451
|
function MonthYearPicker({ value, minDate, maxDate, mode = "month", onChange, className }) {
|
|
@@ -394,9 +488,9 @@ function MonthYearPicker({ value, minDate, maxDate, mode = "month", onChange, cl
|
|
|
394
488
|
yearRef.current?.scrollIntoView({ behavior: "auto", block: "center" });
|
|
395
489
|
}
|
|
396
490
|
}, [mode, value]);
|
|
397
|
-
return /* @__PURE__ */ jsx("div", { className: cn(className), children: /* @__PURE__ */ jsxs(
|
|
491
|
+
return /* @__PURE__ */ jsx("div", { className: cn(className), children: /* @__PURE__ */ jsxs(ScrollArea2, { className: "h-full", children: [
|
|
398
492
|
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
|
-
|
|
493
|
+
Button2,
|
|
400
494
|
{
|
|
401
495
|
disabled: year.disabled,
|
|
402
496
|
variant: getYear(value) === year.value ? "default" : "ghost",
|
|
@@ -406,7 +500,7 @@ function MonthYearPicker({ value, minDate, maxDate, mode = "month", onChange, cl
|
|
|
406
500
|
}
|
|
407
501
|
) }, year.value)) }),
|
|
408
502
|
mode === "month" && /* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-4 mt-7", children: months.map((month) => /* @__PURE__ */ jsx(
|
|
409
|
-
|
|
503
|
+
Button2,
|
|
410
504
|
{
|
|
411
505
|
size: "lg",
|
|
412
506
|
disabled: month.disabled,
|
|
@@ -421,7 +515,7 @@ function MonthYearPicker({ value, minDate, maxDate, mode = "month", onChange, cl
|
|
|
421
515
|
}
|
|
422
516
|
function TimeItem({ option, selected, onSelect, className, disabled }) {
|
|
423
517
|
return /* @__PURE__ */ jsxs(
|
|
424
|
-
|
|
518
|
+
Button2,
|
|
425
519
|
{
|
|
426
520
|
variant: "ghost",
|
|
427
521
|
className: cn("flex justify-center px-1 pe-2 ps-1", className),
|
|
@@ -592,12 +686,12 @@ function TimePicker({ value, onChange, use12HourFormat, min, max, timePicker })
|
|
|
592
686
|
}
|
|
593
687
|
return format(value, parts.join(":") + (use12HourFormat ? " a" : ""));
|
|
594
688
|
}, [value, use12HourFormat, timePicker]);
|
|
595
|
-
return /* @__PURE__ */ jsxs(
|
|
689
|
+
return /* @__PURE__ */ jsxs(Popover2, { open, onOpenChange: setOpen, children: [
|
|
596
690
|
/* @__PURE__ */ jsx(
|
|
597
|
-
|
|
691
|
+
PopoverTrigger2,
|
|
598
692
|
{
|
|
599
693
|
render: (props) => /* @__PURE__ */ jsxs(
|
|
600
|
-
|
|
694
|
+
Button2,
|
|
601
695
|
{
|
|
602
696
|
...props,
|
|
603
697
|
variant: "ghost",
|
|
@@ -614,11 +708,11 @@ function TimePicker({ value, onChange, use12HourFormat, min, max, timePicker })
|
|
|
614
708
|
)
|
|
615
709
|
}
|
|
616
710
|
),
|
|
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(
|
|
711
|
+
/* @__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: [
|
|
712
|
+
(!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)) }) }),
|
|
713
|
+
(!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)) }) }),
|
|
714
|
+
(!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)) }) }),
|
|
715
|
+
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
716
|
] }) }) })
|
|
623
717
|
] });
|
|
624
718
|
}
|
|
@@ -709,20 +803,20 @@ function DateTimePanel({
|
|
|
709
803
|
setPreviousDate(initDate);
|
|
710
804
|
}, [initDate]);
|
|
711
805
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
712
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
713
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
806
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-panel-header", children: [
|
|
807
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-panel-nav-label", children: [
|
|
714
808
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
715
809
|
/* @__PURE__ */ jsx("span", { onClick: () => setMonthYearPicker(monthYearPicker === "month" ? false : "month"), children: format(month, "MMMM") }),
|
|
716
810
|
/* @__PURE__ */ jsx("span", { onClick: () => setMonthYearPicker(monthYearPicker === "year" ? false : "year"), children: format(month, "yyyy") })
|
|
717
811
|
] }),
|
|
718
|
-
/* @__PURE__ */ jsx(
|
|
812
|
+
/* @__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
813
|
] }),
|
|
720
|
-
!monthYearPicker && /* @__PURE__ */ jsxs("div", { className: "
|
|
721
|
-
/* @__PURE__ */ jsx(
|
|
722
|
-
/* @__PURE__ */ jsx(
|
|
814
|
+
!monthYearPicker && /* @__PURE__ */ jsxs("div", { className: "datetime-range-panel-nav-btn", children: [
|
|
815
|
+
/* @__PURE__ */ jsx(Button2, { variant: "ghost", size: "icon", "aria-label": "Previous month", onClick: onPrevMonth, children: /* @__PURE__ */ jsx(ChevronLeftIcon, { style: { width: 16, height: 16 } }) }),
|
|
816
|
+
/* @__PURE__ */ jsx(Button2, { variant: "ghost", size: "icon", "aria-label": "Next month", onClick: onNextMonth, children: /* @__PURE__ */ jsx(ChevronRightIcon, { style: { width: 16, height: 16 } }) })
|
|
723
817
|
] })
|
|
724
818
|
] }),
|
|
725
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
819
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-panel-calendar", children: [
|
|
726
820
|
/* @__PURE__ */ jsx(
|
|
727
821
|
DayPicker,
|
|
728
822
|
{
|
|
@@ -747,31 +841,31 @@ function DateTimePanel({
|
|
|
747
841
|
disabled: [max ? { after: max } : null, min ? { before: min } : null].filter(Boolean),
|
|
748
842
|
onMonthChange: setMonth,
|
|
749
843
|
classNames: {
|
|
750
|
-
dropdowns: "
|
|
751
|
-
months: "
|
|
752
|
-
month: "
|
|
844
|
+
dropdowns: "datetime-range-cal-dropdowns",
|
|
845
|
+
months: "datetime-range-cal-months",
|
|
846
|
+
month: "datetime-range-cal-month",
|
|
753
847
|
month_caption: "hidden",
|
|
754
848
|
button_previous: "hidden",
|
|
755
849
|
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: "
|
|
850
|
+
month_grid: "datetime-range-cal-month-grid",
|
|
851
|
+
weekdays: "datetime-range-cal-weekdays",
|
|
852
|
+
weekday: "datetime-range-cal-weekday",
|
|
853
|
+
week: "datetime-range-cal-week",
|
|
854
|
+
day: "datetime-range-cal-day",
|
|
855
|
+
day_button: "datetime-range-cal-day-btn",
|
|
856
|
+
range_end: "datetime-range-cal-day-range-end",
|
|
857
|
+
selected: "datetime-range-cal-day-selected",
|
|
858
|
+
today: "datetime-range-cal-day-today",
|
|
859
|
+
outside: "datetime-range-cal-day-outside",
|
|
860
|
+
disabled: "datetime-range-cal-day-disabled",
|
|
861
|
+
range_middle: "datetime-range-cal-day-range-middle",
|
|
862
|
+
hidden: "datetime-range-cal-day-hidden"
|
|
769
863
|
},
|
|
770
864
|
showOutsideDays: true,
|
|
771
865
|
...props
|
|
772
866
|
}
|
|
773
867
|
),
|
|
774
|
-
/* @__PURE__ */ jsx("div", { className: cn("
|
|
868
|
+
/* @__PURE__ */ jsx("div", { className: cn("datetime-range-panel-overlay", !monthYearPicker && "datetime-range-panel-overlay--hidden") }),
|
|
775
869
|
/* @__PURE__ */ jsx(
|
|
776
870
|
MonthYearPicker,
|
|
777
871
|
{
|
|
@@ -780,12 +874,12 @@ function DateTimePanel({
|
|
|
780
874
|
onChange: onMonthYearChanged,
|
|
781
875
|
minDate,
|
|
782
876
|
maxDate,
|
|
783
|
-
className: cn("
|
|
877
|
+
className: cn("datetime-range-panel-monthyear", !monthYearPicker && "datetime-range-panel-monthyear--hidden")
|
|
784
878
|
}
|
|
785
879
|
)
|
|
786
880
|
] }),
|
|
787
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
788
|
-
precision !== "date" && /* @__PURE__ */ jsx("div", { className: "
|
|
881
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-panel-footer", children: [
|
|
882
|
+
precision !== "date" && /* @__PURE__ */ jsx("div", { className: "datetime-range-panel-time", children: /* @__PURE__ */ jsx(
|
|
789
883
|
TimePicker,
|
|
790
884
|
{
|
|
791
885
|
timePicker: precisionToTimePicker(precision),
|
|
@@ -796,10 +890,10 @@ function DateTimePanel({
|
|
|
796
890
|
max: maxDate
|
|
797
891
|
}
|
|
798
892
|
) }),
|
|
799
|
-
(isError || errorType !== null) && /* @__PURE__ */ jsx("div", { className: "
|
|
800
|
-
!immediate && /* @__PURE__ */ jsxs("div", { className: "
|
|
801
|
-
/* @__PURE__ */ jsx(
|
|
802
|
-
/* @__PURE__ */ jsx(
|
|
893
|
+
(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." }) }),
|
|
894
|
+
!immediate && /* @__PURE__ */ jsxs("div", { className: "datetime-range-panel-buttons", children: [
|
|
895
|
+
/* @__PURE__ */ jsx(Button2, { variant: "outline", size: "sm", onClick: onCancel, children: "Cancel" }),
|
|
896
|
+
/* @__PURE__ */ jsx(Button2, { size: "sm", onClick: onSubmit, children: "Done" })
|
|
803
897
|
] })
|
|
804
898
|
] })
|
|
805
899
|
] });
|
|
@@ -959,7 +1053,7 @@ function DatetimeSegmentInput({
|
|
|
959
1053
|
"div",
|
|
960
1054
|
{
|
|
961
1055
|
ref: containerRef,
|
|
962
|
-
className: cn("
|
|
1056
|
+
className: cn("datetime-range-segment-input", className),
|
|
963
1057
|
"data-error": isError || void 0,
|
|
964
1058
|
"data-disabled": disabled || void 0,
|
|
965
1059
|
onMouseDown: (e) => {
|
|
@@ -972,8 +1066,8 @@ function DatetimeSegmentInput({
|
|
|
972
1066
|
children: activeSegments.map((seg, idx) => {
|
|
973
1067
|
const sep = idx === 0 ? null : idx === 3 ? "\xA0" : idx < 3 ? "-" : ":";
|
|
974
1068
|
const isFocused = typing[seg.key] !== null;
|
|
975
|
-
return /* @__PURE__ */ jsxs(
|
|
976
|
-
sep !== null && /* @__PURE__ */ jsx("span", { className: "
|
|
1069
|
+
return /* @__PURE__ */ jsxs(React2.Fragment, { children: [
|
|
1070
|
+
sep !== null && /* @__PURE__ */ jsx("span", { className: "datetime-range-segment-sep", "aria-hidden": true, children: sep }),
|
|
977
1071
|
/* @__PURE__ */ jsx(
|
|
978
1072
|
"div",
|
|
979
1073
|
{
|
|
@@ -986,7 +1080,7 @@ function DatetimeSegmentInput({
|
|
|
986
1080
|
"aria-valuemin": seg.min,
|
|
987
1081
|
"aria-valuemax": seg.max,
|
|
988
1082
|
tabIndex: disabled ? -1 : 0,
|
|
989
|
-
className: "
|
|
1083
|
+
className: "datetime-range-segment",
|
|
990
1084
|
"data-focused": isFocused || void 0,
|
|
991
1085
|
style: { height: "24px", lineHeight: "24px" },
|
|
992
1086
|
onKeyDown: (e) => handleKeyDown(e, seg),
|
|
@@ -1165,17 +1259,17 @@ function RelativeSidePanel({ value, onChange, relativeFormats, showNow, labels }
|
|
|
1165
1259
|
});
|
|
1166
1260
|
}
|
|
1167
1261
|
};
|
|
1168
|
-
return /* @__PURE__ */ jsxs("div", { className: "
|
|
1262
|
+
return /* @__PURE__ */ jsxs("div", { className: "datetime-range-relative", children: [
|
|
1169
1263
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
1170
|
-
/* @__PURE__ */ jsx("p", { className: "
|
|
1171
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
1264
|
+
/* @__PURE__ */ jsx("p", { className: "datetime-range-relative-label", children: labels.amount }),
|
|
1265
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-relative-row", children: [
|
|
1172
1266
|
/* @__PURE__ */ jsx(
|
|
1173
|
-
|
|
1267
|
+
Input2,
|
|
1174
1268
|
{
|
|
1175
1269
|
type: "text",
|
|
1176
1270
|
inputMode: "numeric",
|
|
1177
1271
|
pattern: "[0-9]*",
|
|
1178
|
-
className: "
|
|
1272
|
+
className: "datetime-range-relative-input",
|
|
1179
1273
|
disabled: isNow,
|
|
1180
1274
|
value: numValue,
|
|
1181
1275
|
onChange: (e) => {
|
|
@@ -1192,7 +1286,7 @@ function RelativeSidePanel({ value, onChange, relativeFormats, showNow, labels }
|
|
|
1192
1286
|
}
|
|
1193
1287
|
),
|
|
1194
1288
|
/* @__PURE__ */ jsxs(
|
|
1195
|
-
|
|
1289
|
+
Select2,
|
|
1196
1290
|
{
|
|
1197
1291
|
disabled: isNow,
|
|
1198
1292
|
value: format3,
|
|
@@ -1202,16 +1296,16 @@ function RelativeSidePanel({ value, onChange, relativeFormats, showNow, labels }
|
|
|
1202
1296
|
emit({ numValue, format: f, isNow });
|
|
1203
1297
|
},
|
|
1204
1298
|
children: [
|
|
1205
|
-
/* @__PURE__ */ jsx(
|
|
1206
|
-
/* @__PURE__ */ jsx(
|
|
1299
|
+
/* @__PURE__ */ jsx(SelectTrigger2, { children: /* @__PURE__ */ jsx(SelectValue2, { children: format3 }) }),
|
|
1300
|
+
/* @__PURE__ */ jsx(SelectContent2, { children: relativeFormats.map((f) => /* @__PURE__ */ jsx(SelectItem2, { value: f, children: f }, f)) })
|
|
1207
1301
|
]
|
|
1208
1302
|
}
|
|
1209
1303
|
)
|
|
1210
1304
|
] })
|
|
1211
1305
|
] }),
|
|
1212
|
-
showNow && /* @__PURE__ */ jsxs("div", { className: "
|
|
1306
|
+
showNow && /* @__PURE__ */ jsxs("div", { className: "datetime-range-relative-now-row", children: [
|
|
1213
1307
|
/* @__PURE__ */ jsx(
|
|
1214
|
-
|
|
1308
|
+
Switch2,
|
|
1215
1309
|
{
|
|
1216
1310
|
checked: isNow,
|
|
1217
1311
|
onCheckedChange: (checked) => {
|
|
@@ -1220,9 +1314,9 @@ function RelativeSidePanel({ value, onChange, relativeFormats, showNow, labels }
|
|
|
1220
1314
|
}
|
|
1221
1315
|
}
|
|
1222
1316
|
),
|
|
1223
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
1224
|
-
/* @__PURE__ */ jsx("label", { className: "
|
|
1225
|
-
/* @__PURE__ */ jsx("span", { className: "
|
|
1317
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-relative-now-labels", children: [
|
|
1318
|
+
/* @__PURE__ */ jsx("label", { className: "datetime-range-relative-now-label", children: labels.now }),
|
|
1319
|
+
/* @__PURE__ */ jsx("span", { className: "datetime-range-relative-now-desc", children: labels.nowDescription })
|
|
1226
1320
|
] })
|
|
1227
1321
|
] })
|
|
1228
1322
|
] });
|
|
@@ -1236,67 +1330,72 @@ function AbsoluteContent({
|
|
|
1236
1330
|
min,
|
|
1237
1331
|
max,
|
|
1238
1332
|
timezone,
|
|
1239
|
-
use12HourFormat
|
|
1333
|
+
use12HourFormat,
|
|
1334
|
+
calendarMode = "popover"
|
|
1240
1335
|
}) {
|
|
1241
1336
|
const compareDate = compareValue ? toDate(compareValue) : void 0;
|
|
1242
1337
|
const currentDate = value.type === "absolute" ? toDate(value) : /* @__PURE__ */ new Date();
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1338
|
+
const calendarPanel = /* @__PURE__ */ jsx(
|
|
1339
|
+
DateTimePanel,
|
|
1340
|
+
{
|
|
1341
|
+
value: value.type === "absolute" ? currentDate : void 0,
|
|
1342
|
+
compareValue: compareDate,
|
|
1343
|
+
title,
|
|
1344
|
+
immediate: true,
|
|
1345
|
+
precision,
|
|
1346
|
+
min,
|
|
1347
|
+
max,
|
|
1348
|
+
timezone,
|
|
1349
|
+
use12HourFormat,
|
|
1350
|
+
onChangeAction: (d) => {
|
|
1351
|
+
if (!d) return;
|
|
1352
|
+
onChange(absoluteDate(d));
|
|
1251
1353
|
}
|
|
1252
|
-
|
|
1253
|
-
|
|
1354
|
+
}
|
|
1355
|
+
);
|
|
1356
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
1357
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-absolute-row", children: [
|
|
1254
1358
|
/* @__PURE__ */ jsx(
|
|
1255
|
-
|
|
1359
|
+
DatetimeSegmentInput,
|
|
1256
1360
|
{
|
|
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
|
-
)
|
|
1361
|
+
value: currentDate,
|
|
1362
|
+
onChange: (d) => onChange(absoluteDate(d)),
|
|
1363
|
+
className: "datetime-range-absolute-input",
|
|
1364
|
+
precision
|
|
1269
1365
|
}
|
|
1270
1366
|
),
|
|
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));
|
|
1367
|
+
calendarMode === "popover" && /* @__PURE__ */ jsxs(Popover2, { children: [
|
|
1368
|
+
/* @__PURE__ */ jsx(
|
|
1369
|
+
PopoverTrigger2,
|
|
1370
|
+
{
|
|
1371
|
+
render: (triggerProps) => /* @__PURE__ */ jsx(
|
|
1372
|
+
Button2,
|
|
1373
|
+
{
|
|
1374
|
+
...triggerProps,
|
|
1375
|
+
type: "button",
|
|
1376
|
+
variant: "outline",
|
|
1377
|
+
size: "icon",
|
|
1378
|
+
className: "datetime-range-absolute-btn",
|
|
1379
|
+
title: "Pick from calendar",
|
|
1380
|
+
children: /* @__PURE__ */ jsx(CalendarDays, { size: 14 })
|
|
1294
1381
|
}
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1382
|
+
)
|
|
1383
|
+
}
|
|
1384
|
+
),
|
|
1385
|
+
/* @__PURE__ */ jsx(
|
|
1386
|
+
PopoverContent2,
|
|
1387
|
+
{
|
|
1388
|
+
className: "p-0 w-auto",
|
|
1389
|
+
side: "bottom",
|
|
1390
|
+
align: "start",
|
|
1391
|
+
sideOffset: 6,
|
|
1392
|
+
disableAnchorTracking: true,
|
|
1393
|
+
children: calendarPanel
|
|
1394
|
+
}
|
|
1395
|
+
)
|
|
1396
|
+
] })
|
|
1397
|
+
] }),
|
|
1398
|
+
calendarMode === "inline" && /* @__PURE__ */ jsx("div", { className: "datetime-range-absolute-inline-calendar", children: calendarPanel })
|
|
1300
1399
|
] });
|
|
1301
1400
|
}
|
|
1302
1401
|
function SidePanel({
|
|
@@ -1313,7 +1412,9 @@ function SidePanel({
|
|
|
1313
1412
|
max,
|
|
1314
1413
|
timezone,
|
|
1315
1414
|
use12HourFormat,
|
|
1316
|
-
labels: labelsProp
|
|
1415
|
+
labels: labelsProp,
|
|
1416
|
+
calendarMode,
|
|
1417
|
+
uiAdapter
|
|
1317
1418
|
}) {
|
|
1318
1419
|
const labels = { ...DEFAULT_LABELS, ...labelsProp };
|
|
1319
1420
|
useEffect(() => {
|
|
@@ -1335,7 +1436,8 @@ function SidePanel({
|
|
|
1335
1436
|
min,
|
|
1336
1437
|
max,
|
|
1337
1438
|
timezone,
|
|
1338
|
-
use12HourFormat
|
|
1439
|
+
use12HourFormat,
|
|
1440
|
+
calendarMode
|
|
1339
1441
|
}
|
|
1340
1442
|
);
|
|
1341
1443
|
const relativeContent = /* @__PURE__ */ jsx(
|
|
@@ -1348,13 +1450,13 @@ function SidePanel({
|
|
|
1348
1450
|
labels
|
|
1349
1451
|
}
|
|
1350
1452
|
);
|
|
1351
|
-
|
|
1352
|
-
/* @__PURE__ */ jsx("p", { className: "
|
|
1453
|
+
const content = /* @__PURE__ */ jsxs("div", { className: "datetime-range-side-panel", children: [
|
|
1454
|
+
/* @__PURE__ */ jsx("p", { className: "datetime-range-side-panel-title", children: title }),
|
|
1353
1455
|
hasBothModes ? /* @__PURE__ */ jsxs(
|
|
1354
|
-
|
|
1456
|
+
Tabs2,
|
|
1355
1457
|
{
|
|
1356
1458
|
value: value.type,
|
|
1357
|
-
className: "
|
|
1459
|
+
className: "datetime-range-side-panel-tabs",
|
|
1358
1460
|
onValueChange: (t) => {
|
|
1359
1461
|
if (t === "absolute") {
|
|
1360
1462
|
onChange(absoluteDate(value.type === "absolute" ? toDate(value) : /* @__PURE__ */ new Date()));
|
|
@@ -1363,16 +1465,17 @@ function SidePanel({
|
|
|
1363
1465
|
}
|
|
1364
1466
|
},
|
|
1365
1467
|
children: [
|
|
1366
|
-
/* @__PURE__ */ jsxs(
|
|
1367
|
-
/* @__PURE__ */ jsx(
|
|
1368
|
-
/* @__PURE__ */ jsx(
|
|
1468
|
+
/* @__PURE__ */ jsxs(TabsList2, { className: "datetime-range-tabs-list--grid datetime-range-tabs-list--grid-2", children: [
|
|
1469
|
+
/* @__PURE__ */ jsx(TabsTrigger2, { value: "absolute", children: labels.absolute }),
|
|
1470
|
+
/* @__PURE__ */ jsx(TabsTrigger2, { value: "relative", children: labels.relative })
|
|
1369
1471
|
] }),
|
|
1370
|
-
/* @__PURE__ */ jsx(
|
|
1371
|
-
/* @__PURE__ */ jsx(
|
|
1472
|
+
/* @__PURE__ */ jsx(TabsContent2, { value: "absolute", children: absoluteContent }),
|
|
1473
|
+
/* @__PURE__ */ jsx(TabsContent2, { value: "relative", children: relativeContent })
|
|
1372
1474
|
]
|
|
1373
1475
|
}
|
|
1374
1476
|
) : showAbsolute ? absoluteContent : relativeContent
|
|
1375
1477
|
] });
|
|
1478
|
+
return uiAdapter ? /* @__PURE__ */ jsx(DatetimeRangeProvider, { adapter: uiAdapter, children: content }) : content;
|
|
1376
1479
|
}
|
|
1377
1480
|
function useDatetimeRange({
|
|
1378
1481
|
startTime,
|
|
@@ -1442,13 +1545,15 @@ function DatetimeRange({
|
|
|
1442
1545
|
timezone,
|
|
1443
1546
|
use12HourFormat = false,
|
|
1444
1547
|
showNow = true,
|
|
1548
|
+
calendarMode = "popover",
|
|
1445
1549
|
disabled = false,
|
|
1446
1550
|
labels: labelsProp,
|
|
1447
1551
|
popoverAlign = "start",
|
|
1448
1552
|
popoverSide = "bottom",
|
|
1449
1553
|
renderTrigger,
|
|
1450
1554
|
portalContainer,
|
|
1451
|
-
className
|
|
1555
|
+
className,
|
|
1556
|
+
uiAdapter
|
|
1452
1557
|
}) {
|
|
1453
1558
|
const labels = { ...DEFAULT_LABELS, ...labelsProp };
|
|
1454
1559
|
const {
|
|
@@ -1474,24 +1579,25 @@ function DatetimeRange({
|
|
|
1474
1579
|
max,
|
|
1475
1580
|
timezone,
|
|
1476
1581
|
use12HourFormat,
|
|
1477
|
-
labels
|
|
1582
|
+
labels,
|
|
1583
|
+
calendarMode
|
|
1478
1584
|
};
|
|
1479
|
-
|
|
1585
|
+
const content = /* @__PURE__ */ jsxs(Popover2, { open: isOpen, onOpenChange: disabled ? void 0 : setIsOpen, children: [
|
|
1480
1586
|
/* @__PURE__ */ jsx(
|
|
1481
|
-
|
|
1587
|
+
PopoverTrigger2,
|
|
1482
1588
|
{
|
|
1483
1589
|
disabled,
|
|
1484
1590
|
render: (triggerProps) => renderTrigger ? renderTrigger(triggerProps, { open: isOpen, startTime, endTime }) : /* @__PURE__ */ jsxs(
|
|
1485
|
-
|
|
1591
|
+
Button2,
|
|
1486
1592
|
{
|
|
1487
1593
|
...triggerProps,
|
|
1488
1594
|
variant: "outline",
|
|
1489
1595
|
disabled,
|
|
1490
|
-
className: cn("
|
|
1596
|
+
className: cn("datetime-range-range-trigger", isOpen && "datetime-range-range-trigger--open", className),
|
|
1491
1597
|
children: [
|
|
1492
|
-
/* @__PURE__ */ jsx(CalendarDays, { size: 14, className: "
|
|
1598
|
+
/* @__PURE__ */ jsx(CalendarDays, { size: 14, className: "datetime-range-range-trigger-icon" }),
|
|
1493
1599
|
/* @__PURE__ */ jsx("span", { children: toDisplayString(startTime, { precision }) }),
|
|
1494
|
-
/* @__PURE__ */ jsx("span", { className: "
|
|
1600
|
+
/* @__PURE__ */ jsx("span", { className: "datetime-range-range-trigger-arrow", children: "\u2192" }),
|
|
1495
1601
|
/* @__PURE__ */ jsx("span", { children: toDisplayString(endTime, { precision }) })
|
|
1496
1602
|
]
|
|
1497
1603
|
}
|
|
@@ -1499,31 +1605,31 @@ function DatetimeRange({
|
|
|
1499
1605
|
}
|
|
1500
1606
|
),
|
|
1501
1607
|
/* @__PURE__ */ jsx(
|
|
1502
|
-
|
|
1608
|
+
PopoverContent2,
|
|
1503
1609
|
{
|
|
1504
|
-
className: "
|
|
1610
|
+
className: "datetime-range-range-popup-content",
|
|
1505
1611
|
align: popoverAlign,
|
|
1506
1612
|
side: popoverSide,
|
|
1507
1613
|
sideOffset: 4,
|
|
1508
1614
|
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: "
|
|
1615
|
+
children: /* @__PURE__ */ jsxs("div", { className: "datetime-range-range-popup", children: [
|
|
1616
|
+
showQuickRanges && quickPresets.length > 0 && /* @__PURE__ */ jsx("div", { className: "datetime-range-range-quick", children: /* @__PURE__ */ jsxs("div", { className: "datetime-range-range-quick-inner", children: [
|
|
1617
|
+
/* @__PURE__ */ jsx("div", { className: "datetime-range-range-quick-label", children: labels.quickRanges }),
|
|
1618
|
+
/* @__PURE__ */ jsx("div", { className: "datetime-range-range-quick-list", children: quickPresets.map((preset) => /* @__PURE__ */ jsx(
|
|
1513
1619
|
"button",
|
|
1514
1620
|
{
|
|
1515
1621
|
type: "button",
|
|
1516
|
-
className: "
|
|
1622
|
+
className: "datetime-range-range-quick-item",
|
|
1517
1623
|
onClick: () => handlePreset(preset),
|
|
1518
1624
|
children: preset.label
|
|
1519
1625
|
},
|
|
1520
1626
|
preset.label
|
|
1521
1627
|
)) })
|
|
1522
1628
|
] }) }),
|
|
1523
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
1524
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
1525
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
1526
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
1629
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-range-pickers", children: [
|
|
1630
|
+
/* @__PURE__ */ jsx("div", { className: "datetime-range-range-divider" }),
|
|
1631
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-range-panels", children: [
|
|
1632
|
+
/* @__PURE__ */ jsx("div", { className: "datetime-range-range-panel-slot", children: /* @__PURE__ */ jsx(
|
|
1527
1633
|
SidePanel,
|
|
1528
1634
|
{
|
|
1529
1635
|
title: labels.start,
|
|
@@ -1536,7 +1642,7 @@ function DatetimeRange({
|
|
|
1536
1642
|
...sidePanelProps
|
|
1537
1643
|
}
|
|
1538
1644
|
) }),
|
|
1539
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
1645
|
+
/* @__PURE__ */ jsx("div", { className: "datetime-range-range-panel-slot", children: /* @__PURE__ */ jsx(
|
|
1540
1646
|
SidePanel,
|
|
1541
1647
|
{
|
|
1542
1648
|
title: labels.end,
|
|
@@ -1550,11 +1656,11 @@ function DatetimeRange({
|
|
|
1550
1656
|
}
|
|
1551
1657
|
) })
|
|
1552
1658
|
] }),
|
|
1553
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
1554
|
-
error === "validation" ? /* @__PURE__ */ jsx("span", { className: "
|
|
1555
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
1556
|
-
/* @__PURE__ */ jsx(
|
|
1557
|
-
/* @__PURE__ */ jsx(
|
|
1659
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-range-footer", children: [
|
|
1660
|
+
error === "validation" ? /* @__PURE__ */ jsx("span", { className: "datetime-range-range-error-text", children: "Start must be earlier than end." }) : /* @__PURE__ */ jsx("span", {}),
|
|
1661
|
+
/* @__PURE__ */ jsxs("div", { className: "datetime-range-range-actions", children: [
|
|
1662
|
+
/* @__PURE__ */ jsx(Button2, { variant: "outline", size: "sm", onClick: handleCancel, children: labels.cancel }),
|
|
1663
|
+
/* @__PURE__ */ jsx(Button2, { size: "sm", onClick: handleApply, children: labels.apply })
|
|
1558
1664
|
] })
|
|
1559
1665
|
] })
|
|
1560
1666
|
] })
|
|
@@ -1562,8 +1668,9 @@ function DatetimeRange({
|
|
|
1562
1668
|
}
|
|
1563
1669
|
)
|
|
1564
1670
|
] });
|
|
1671
|
+
return uiAdapter ? /* @__PURE__ */ jsx(DatetimeRangeProvider, { adapter: uiAdapter, children: content }) : content;
|
|
1565
1672
|
}
|
|
1566
1673
|
|
|
1567
|
-
export { DateTimePanel, DatetimeRange, DatetimeSegmentInput, QUICK_PRESETS, RELATIVE_FORMATS, SidePanel, absoluteDate, fromUrlString, relativeAgo, relativeNow, toDate, toDisplayString, toTimestamp, toTimestampMs, toUrlString, useDatetimeRange, validateRange };
|
|
1674
|
+
export { DateTimePanel, DatetimeRange, DatetimeRangeProvider, DatetimeSegmentInput, QUICK_PRESETS, RELATIVE_FORMATS, SidePanel, absoluteDate, fromUrlString, relativeAgo, relativeNow, toDate, toDisplayString, toTimestamp, toTimestampMs, toUrlString, useDatetimeRange, useDatetimeRangeUI, validateRange };
|
|
1568
1675
|
//# sourceMappingURL=index.js.map
|
|
1569
1676
|
//# sourceMappingURL=index.js.map
|