@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.cjs
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
var lucideReact = require('lucide-react');
|
|
4
4
|
var clsx = require('clsx');
|
|
5
|
+
var React2 = require('react');
|
|
5
6
|
var button = require('@base-ui/react/button');
|
|
6
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
8
|
var popover = require('@base-ui/react/popover');
|
|
8
|
-
var React = require('react');
|
|
9
|
-
var tabs = require('@base-ui/react/tabs');
|
|
10
|
-
var input = require('@base-ui/react/input');
|
|
11
9
|
var select = require('@base-ui/react/select');
|
|
12
10
|
var react = require('@hugeicons/react');
|
|
13
11
|
var coreFreeIcons = require('@hugeicons/core-free-icons');
|
|
12
|
+
var tabs = require('@base-ui/react/tabs');
|
|
13
|
+
var input = require('@base-ui/react/input');
|
|
14
14
|
var _switch = require('@base-ui/react/switch');
|
|
15
|
+
var scrollArea = require('@base-ui/react/scroll-area');
|
|
15
16
|
var dateFns = require('date-fns');
|
|
16
17
|
var reactDayPicker = require('react-day-picker');
|
|
17
18
|
var setMonth = require('date-fns/setMonth');
|
|
18
|
-
var scrollArea = require('@base-ui/react/scroll-area');
|
|
19
19
|
var chrono = require('chrono-node');
|
|
20
20
|
|
|
21
21
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -38,7 +38,7 @@ function _interopNamespace(e) {
|
|
|
38
38
|
return Object.freeze(n);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
var
|
|
41
|
+
var React2__default = /*#__PURE__*/_interopDefault(React2);
|
|
42
42
|
var chrono__namespace = /*#__PURE__*/_interopNamespace(chrono);
|
|
43
43
|
|
|
44
44
|
// src/DatetimeRange.tsx
|
|
@@ -50,12 +50,17 @@ function buttonVariants({
|
|
|
50
50
|
size = "default",
|
|
51
51
|
className
|
|
52
52
|
} = {}) {
|
|
53
|
-
return cn("
|
|
53
|
+
return cn("datetime-range-btn", className, variant && `datetime-range-btn--${variant}`, size && `datetime-range-btn--${size}`);
|
|
54
54
|
}
|
|
55
55
|
function Button({
|
|
56
56
|
className,
|
|
57
57
|
variant = "default",
|
|
58
58
|
size = "default",
|
|
59
|
+
// @base-ui/react's own Button/useButton() already defaults type="button" internally on
|
|
60
|
+
// every path this wraps, so this default is redundant today — kept anyway as a fallback
|
|
61
|
+
// that doesn't depend on that undocumented (type isn't part of the public prop types)
|
|
62
|
+
// upstream behavior continuing to hold across base-ui versions.
|
|
63
|
+
type = "button",
|
|
59
64
|
...props
|
|
60
65
|
}) {
|
|
61
66
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -64,6 +69,7 @@ function Button({
|
|
|
64
69
|
"data-slot": "button",
|
|
65
70
|
"data-variant": variant,
|
|
66
71
|
"data-size": size,
|
|
72
|
+
type,
|
|
67
73
|
className: buttonVariants({ variant, size, className: typeof className === "string" ? className : void 0 }),
|
|
68
74
|
...props
|
|
69
75
|
}
|
|
@@ -95,89 +101,25 @@ function PopoverContent({
|
|
|
95
101
|
sideOffset,
|
|
96
102
|
disableAnchorTracking,
|
|
97
103
|
collisionAvoidance,
|
|
98
|
-
className: "
|
|
104
|
+
className: "datetime-range-positioner",
|
|
99
105
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
100
106
|
popover.Popover.Popup,
|
|
101
107
|
{
|
|
102
108
|
"data-slot": "popover-content",
|
|
103
|
-
className: cn("
|
|
109
|
+
className: cn("datetime-range-popover-content", className),
|
|
104
110
|
...props
|
|
105
111
|
}
|
|
106
112
|
)
|
|
107
113
|
}
|
|
108
114
|
) });
|
|
109
115
|
}
|
|
110
|
-
function Tabs({
|
|
111
|
-
className,
|
|
112
|
-
orientation = "horizontal",
|
|
113
|
-
...props
|
|
114
|
-
}) {
|
|
115
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
116
|
-
tabs.Tabs.Root,
|
|
117
|
-
{
|
|
118
|
-
"data-slot": "tabs",
|
|
119
|
-
"data-orientation": orientation,
|
|
120
|
-
className: cn("dr-tabs", className),
|
|
121
|
-
...props
|
|
122
|
-
}
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
function TabsList({
|
|
126
|
-
className,
|
|
127
|
-
variant = "default",
|
|
128
|
-
...props
|
|
129
|
-
}) {
|
|
130
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
131
|
-
tabs.Tabs.List,
|
|
132
|
-
{
|
|
133
|
-
"data-slot": "tabs-list",
|
|
134
|
-
"data-variant": variant,
|
|
135
|
-
className: cn("dr-tabs-list", className),
|
|
136
|
-
...props
|
|
137
|
-
}
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
function TabsTrigger({ className, ...props }) {
|
|
141
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
142
|
-
tabs.Tabs.Tab,
|
|
143
|
-
{
|
|
144
|
-
"data-slot": "tabs-trigger",
|
|
145
|
-
className: cn("dr-tabs-trigger", className),
|
|
146
|
-
...props
|
|
147
|
-
}
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
function TabsContent({ className, ...props }) {
|
|
151
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
152
|
-
tabs.Tabs.Panel,
|
|
153
|
-
{
|
|
154
|
-
"data-slot": "tabs-content",
|
|
155
|
-
className: cn("dr-tabs-content", className),
|
|
156
|
-
...props
|
|
157
|
-
}
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
function Input({ className, type, ...props }) {
|
|
161
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
162
|
-
input.Input,
|
|
163
|
-
{
|
|
164
|
-
type,
|
|
165
|
-
"data-slot": "input",
|
|
166
|
-
className: cn(
|
|
167
|
-
"dr-input",
|
|
168
|
-
className
|
|
169
|
-
),
|
|
170
|
-
...props
|
|
171
|
-
}
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
116
|
var Select = select.Select.Root;
|
|
175
117
|
function SelectValue({ className, ...props }) {
|
|
176
118
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
177
119
|
select.Select.Value,
|
|
178
120
|
{
|
|
179
121
|
"data-slot": "select-value",
|
|
180
|
-
className: cn("
|
|
122
|
+
className: cn("datetime-range-select-value", className),
|
|
181
123
|
...props
|
|
182
124
|
}
|
|
183
125
|
);
|
|
@@ -193,7 +135,7 @@ function SelectTrigger({
|
|
|
193
135
|
{
|
|
194
136
|
"data-slot": "select-trigger",
|
|
195
137
|
"data-size": size,
|
|
196
|
-
className: cn("
|
|
138
|
+
className: cn("datetime-range-select-trigger", className),
|
|
197
139
|
...props,
|
|
198
140
|
children: [
|
|
199
141
|
children,
|
|
@@ -205,7 +147,7 @@ function SelectTrigger({
|
|
|
205
147
|
{
|
|
206
148
|
icon: coreFreeIcons.UnfoldMoreIcon,
|
|
207
149
|
strokeWidth: 2,
|
|
208
|
-
className: "
|
|
150
|
+
className: "datetime-range-select-icon"
|
|
209
151
|
}
|
|
210
152
|
)
|
|
211
153
|
}
|
|
@@ -232,13 +174,13 @@ function SelectContent({
|
|
|
232
174
|
align,
|
|
233
175
|
alignOffset,
|
|
234
176
|
alignItemWithTrigger,
|
|
235
|
-
className: "
|
|
177
|
+
className: "datetime-range-positioner",
|
|
236
178
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
237
179
|
select.Select.Popup,
|
|
238
180
|
{
|
|
239
181
|
"data-slot": "select-content",
|
|
240
182
|
"data-align-trigger": alignItemWithTrigger,
|
|
241
|
-
className: cn("
|
|
183
|
+
className: cn("datetime-range-select-content", className),
|
|
242
184
|
...props,
|
|
243
185
|
children: [
|
|
244
186
|
/* @__PURE__ */ jsxRuntime.jsx(SelectScrollUpButton, {}),
|
|
@@ -259,14 +201,14 @@ function SelectItem({
|
|
|
259
201
|
select.Select.Item,
|
|
260
202
|
{
|
|
261
203
|
"data-slot": "select-item",
|
|
262
|
-
className: cn("
|
|
204
|
+
className: cn("datetime-range-select-item", className),
|
|
263
205
|
...props,
|
|
264
206
|
children: [
|
|
265
|
-
/* @__PURE__ */ jsxRuntime.jsx(select.Select.ItemText, { className: "
|
|
207
|
+
/* @__PURE__ */ jsxRuntime.jsx(select.Select.ItemText, { className: "datetime-range-select-item-text", children }),
|
|
266
208
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
267
209
|
select.Select.ItemIndicator,
|
|
268
210
|
{
|
|
269
|
-
render: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "
|
|
211
|
+
render: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "datetime-range-select-item-indicator" }),
|
|
270
212
|
children: /* @__PURE__ */ jsxRuntime.jsx(react.HugeiconsIcon, { icon: coreFreeIcons.Tick02Icon, strokeWidth: 2, style: { pointerEvents: "none" } })
|
|
271
213
|
}
|
|
272
214
|
)
|
|
@@ -282,7 +224,7 @@ function SelectScrollUpButton({
|
|
|
282
224
|
select.Select.ScrollUpArrow,
|
|
283
225
|
{
|
|
284
226
|
"data-slot": "select-scroll-up-button",
|
|
285
|
-
className: cn("
|
|
227
|
+
className: cn("datetime-range-select-scroll-btn datetime-range-select-scroll-btn--up", className),
|
|
286
228
|
...props,
|
|
287
229
|
children: /* @__PURE__ */ jsxRuntime.jsx(react.HugeiconsIcon, { icon: coreFreeIcons.ArrowUp01Icon, strokeWidth: 2 })
|
|
288
230
|
}
|
|
@@ -296,12 +238,76 @@ function SelectScrollDownButton({
|
|
|
296
238
|
select.Select.ScrollDownArrow,
|
|
297
239
|
{
|
|
298
240
|
"data-slot": "select-scroll-down-button",
|
|
299
|
-
className: cn("
|
|
241
|
+
className: cn("datetime-range-select-scroll-btn datetime-range-select-scroll-btn--down", className),
|
|
300
242
|
...props,
|
|
301
243
|
children: /* @__PURE__ */ jsxRuntime.jsx(react.HugeiconsIcon, { icon: coreFreeIcons.ArrowDown01Icon, strokeWidth: 2 })
|
|
302
244
|
}
|
|
303
245
|
);
|
|
304
246
|
}
|
|
247
|
+
function Tabs({
|
|
248
|
+
className,
|
|
249
|
+
orientation = "horizontal",
|
|
250
|
+
...props
|
|
251
|
+
}) {
|
|
252
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
253
|
+
tabs.Tabs.Root,
|
|
254
|
+
{
|
|
255
|
+
"data-slot": "tabs",
|
|
256
|
+
"data-orientation": orientation,
|
|
257
|
+
className: cn("datetime-range-tabs", className),
|
|
258
|
+
...props
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
function TabsList({
|
|
263
|
+
className,
|
|
264
|
+
variant = "default",
|
|
265
|
+
...props
|
|
266
|
+
}) {
|
|
267
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
268
|
+
tabs.Tabs.List,
|
|
269
|
+
{
|
|
270
|
+
"data-slot": "tabs-list",
|
|
271
|
+
"data-variant": variant,
|
|
272
|
+
className: cn("datetime-range-tabs-list", className),
|
|
273
|
+
...props
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
function TabsTrigger({ className, ...props }) {
|
|
278
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
279
|
+
tabs.Tabs.Tab,
|
|
280
|
+
{
|
|
281
|
+
"data-slot": "tabs-trigger",
|
|
282
|
+
className: cn("datetime-range-tabs-trigger", className),
|
|
283
|
+
...props
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
function TabsContent({ className, ...props }) {
|
|
288
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
289
|
+
tabs.Tabs.Panel,
|
|
290
|
+
{
|
|
291
|
+
"data-slot": "tabs-content",
|
|
292
|
+
className: cn("datetime-range-tabs-content", className),
|
|
293
|
+
...props
|
|
294
|
+
}
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
function Input({ className, type, ...props }) {
|
|
298
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
299
|
+
input.Input,
|
|
300
|
+
{
|
|
301
|
+
type,
|
|
302
|
+
"data-slot": "input",
|
|
303
|
+
className: cn(
|
|
304
|
+
"datetime-range-input",
|
|
305
|
+
className
|
|
306
|
+
),
|
|
307
|
+
...props
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
}
|
|
305
311
|
function Switch({
|
|
306
312
|
className,
|
|
307
313
|
size = "default",
|
|
@@ -312,13 +318,13 @@ function Switch({
|
|
|
312
318
|
{
|
|
313
319
|
"data-slot": "switch",
|
|
314
320
|
"data-size": size,
|
|
315
|
-
className: cn("
|
|
321
|
+
className: cn("datetime-range-switch", className),
|
|
316
322
|
...props,
|
|
317
323
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
318
324
|
_switch.Switch.Thumb,
|
|
319
325
|
{
|
|
320
326
|
"data-slot": "switch-thumb",
|
|
321
|
-
className: "
|
|
327
|
+
className: "datetime-range-switch-thumb"
|
|
322
328
|
}
|
|
323
329
|
)
|
|
324
330
|
}
|
|
@@ -336,7 +342,7 @@ function ScrollArea({
|
|
|
336
342
|
{
|
|
337
343
|
"data-slot": "scroll-area",
|
|
338
344
|
style: { position: "relative", ...style },
|
|
339
|
-
className: cn("
|
|
345
|
+
className: cn("datetime-range-scroll-area", className),
|
|
340
346
|
...props,
|
|
341
347
|
children: [
|
|
342
348
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -344,7 +350,7 @@ function ScrollArea({
|
|
|
344
350
|
{
|
|
345
351
|
ref: viewportRef,
|
|
346
352
|
"data-slot": "scroll-area-viewport",
|
|
347
|
-
className: "
|
|
353
|
+
className: "datetime-range-scroll-area-viewport",
|
|
348
354
|
children
|
|
349
355
|
}
|
|
350
356
|
),
|
|
@@ -365,23 +371,117 @@ function ScrollBar({
|
|
|
365
371
|
{
|
|
366
372
|
"data-slot": "scroll-area-scrollbar",
|
|
367
373
|
orientation,
|
|
368
|
-
className: cn("
|
|
374
|
+
className: cn("datetime-range-scrollbar", className),
|
|
369
375
|
...props,
|
|
370
376
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
371
377
|
scrollArea.ScrollArea.Thumb,
|
|
372
378
|
{
|
|
373
379
|
"data-slot": "scroll-area-thumb",
|
|
374
|
-
className: "
|
|
380
|
+
className: "datetime-range-scrollbar-thumb"
|
|
375
381
|
}
|
|
376
382
|
)
|
|
377
383
|
}
|
|
378
384
|
);
|
|
379
385
|
}
|
|
386
|
+
var defaultUIAdapter = {
|
|
387
|
+
Button,
|
|
388
|
+
Popover,
|
|
389
|
+
PopoverTrigger,
|
|
390
|
+
PopoverContent,
|
|
391
|
+
Select,
|
|
392
|
+
SelectTrigger,
|
|
393
|
+
SelectValue,
|
|
394
|
+
SelectContent,
|
|
395
|
+
SelectItem,
|
|
396
|
+
Tabs,
|
|
397
|
+
TabsList,
|
|
398
|
+
TabsTrigger,
|
|
399
|
+
TabsContent,
|
|
400
|
+
Input,
|
|
401
|
+
Switch,
|
|
402
|
+
ScrollArea
|
|
403
|
+
};
|
|
404
|
+
var DatetimeRangeUIContext = React2.createContext(defaultUIAdapter);
|
|
405
|
+
function useResolvedDatetimeRangeUI(adapter) {
|
|
406
|
+
const parent = React2.useContext(DatetimeRangeUIContext);
|
|
407
|
+
return React2.useMemo(() => adapter ? { ...parent, ...adapter } : parent, [parent, adapter]);
|
|
408
|
+
}
|
|
409
|
+
function DatetimeRangeProvider({ adapter, children }) {
|
|
410
|
+
const value = useResolvedDatetimeRangeUI(adapter);
|
|
411
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DatetimeRangeUIContext.Provider, { value, children });
|
|
412
|
+
}
|
|
413
|
+
function useDatetimeRangeUI() {
|
|
414
|
+
return React2.useContext(DatetimeRangeUIContext);
|
|
415
|
+
}
|
|
416
|
+
function Button2(props) {
|
|
417
|
+
const { Button: Component } = useDatetimeRangeUI();
|
|
418
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...props });
|
|
419
|
+
}
|
|
420
|
+
function Popover2(props) {
|
|
421
|
+
const { Popover: Component } = useDatetimeRangeUI();
|
|
422
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...props });
|
|
423
|
+
}
|
|
424
|
+
function PopoverTrigger2(props) {
|
|
425
|
+
const { PopoverTrigger: Component } = useDatetimeRangeUI();
|
|
426
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...props });
|
|
427
|
+
}
|
|
428
|
+
function PopoverContent2(props) {
|
|
429
|
+
const { PopoverContent: Component } = useDatetimeRangeUI();
|
|
430
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...props });
|
|
431
|
+
}
|
|
432
|
+
function Select2(props) {
|
|
433
|
+
const { Select: Component } = useDatetimeRangeUI();
|
|
434
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...props });
|
|
435
|
+
}
|
|
436
|
+
function SelectTrigger2(props) {
|
|
437
|
+
const { SelectTrigger: Component } = useDatetimeRangeUI();
|
|
438
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...props });
|
|
439
|
+
}
|
|
440
|
+
function SelectValue2(props) {
|
|
441
|
+
const { SelectValue: Component } = useDatetimeRangeUI();
|
|
442
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...props });
|
|
443
|
+
}
|
|
444
|
+
function SelectContent2(props) {
|
|
445
|
+
const { SelectContent: Component } = useDatetimeRangeUI();
|
|
446
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...props });
|
|
447
|
+
}
|
|
448
|
+
function SelectItem2(props) {
|
|
449
|
+
const { SelectItem: Component } = useDatetimeRangeUI();
|
|
450
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...props });
|
|
451
|
+
}
|
|
452
|
+
function Tabs2(props) {
|
|
453
|
+
const { Tabs: Component } = useDatetimeRangeUI();
|
|
454
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...props });
|
|
455
|
+
}
|
|
456
|
+
function TabsList2(props) {
|
|
457
|
+
const { TabsList: Component } = useDatetimeRangeUI();
|
|
458
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...props });
|
|
459
|
+
}
|
|
460
|
+
function TabsTrigger2(props) {
|
|
461
|
+
const { TabsTrigger: Component } = useDatetimeRangeUI();
|
|
462
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...props });
|
|
463
|
+
}
|
|
464
|
+
function TabsContent2(props) {
|
|
465
|
+
const { TabsContent: Component } = useDatetimeRangeUI();
|
|
466
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...props });
|
|
467
|
+
}
|
|
468
|
+
function Input2(props) {
|
|
469
|
+
const { Input: Component } = useDatetimeRangeUI();
|
|
470
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...props });
|
|
471
|
+
}
|
|
472
|
+
function Switch2(props) {
|
|
473
|
+
const { Switch: Component } = useDatetimeRangeUI();
|
|
474
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...props });
|
|
475
|
+
}
|
|
476
|
+
function ScrollArea2(props) {
|
|
477
|
+
const { ScrollArea: Component } = useDatetimeRangeUI();
|
|
478
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...props });
|
|
479
|
+
}
|
|
380
480
|
var AM_VALUE = 0;
|
|
381
481
|
var PM_VALUE = 1;
|
|
382
482
|
function MonthYearPicker({ value, minDate, maxDate, mode = "month", onChange, className }) {
|
|
383
|
-
const yearRef =
|
|
384
|
-
const years =
|
|
483
|
+
const yearRef = React2.useRef(null);
|
|
484
|
+
const years = React2.useMemo(() => {
|
|
385
485
|
const result = [];
|
|
386
486
|
for (let i = 1912; i < 2100; i++) {
|
|
387
487
|
let disabled = false;
|
|
@@ -393,7 +493,7 @@ function MonthYearPicker({ value, minDate, maxDate, mode = "month", onChange, cl
|
|
|
393
493
|
}
|
|
394
494
|
return result;
|
|
395
495
|
}, [value, minDate, maxDate]);
|
|
396
|
-
const months =
|
|
496
|
+
const months = React2.useMemo(() => {
|
|
397
497
|
const result = [];
|
|
398
498
|
for (let i = 0; i < 12; i++) {
|
|
399
499
|
let disabled = false;
|
|
@@ -405,7 +505,7 @@ function MonthYearPicker({ value, minDate, maxDate, mode = "month", onChange, cl
|
|
|
405
505
|
}
|
|
406
506
|
return result;
|
|
407
507
|
}, [value, minDate, maxDate]);
|
|
408
|
-
const onYearChange =
|
|
508
|
+
const onYearChange = React2.useCallback(
|
|
409
509
|
(v) => {
|
|
410
510
|
let newDate = dateFns.setYear(value, v.value);
|
|
411
511
|
if (minDate && newDate < minDate) newDate = setMonth.setMonth(newDate, dateFns.getMonth(minDate));
|
|
@@ -414,14 +514,14 @@ function MonthYearPicker({ value, minDate, maxDate, mode = "month", onChange, cl
|
|
|
414
514
|
},
|
|
415
515
|
[onChange, value, minDate, maxDate]
|
|
416
516
|
);
|
|
417
|
-
|
|
517
|
+
React2.useEffect(() => {
|
|
418
518
|
if (mode === "year") {
|
|
419
519
|
yearRef.current?.scrollIntoView({ behavior: "auto", block: "center" });
|
|
420
520
|
}
|
|
421
521
|
}, [mode, value]);
|
|
422
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(className), children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
522
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(className), children: /* @__PURE__ */ jsxRuntime.jsxs(ScrollArea2, { className: "h-full", children: [
|
|
423
523
|
mode === "year" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-4", children: years.map((year) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref: year.value === dateFns.getYear(value) ? yearRef : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
424
|
-
|
|
524
|
+
Button2,
|
|
425
525
|
{
|
|
426
526
|
disabled: year.disabled,
|
|
427
527
|
variant: dateFns.getYear(value) === year.value ? "default" : "ghost",
|
|
@@ -431,7 +531,7 @@ function MonthYearPicker({ value, minDate, maxDate, mode = "month", onChange, cl
|
|
|
431
531
|
}
|
|
432
532
|
) }, year.value)) }),
|
|
433
533
|
mode === "month" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-3 gap-4 mt-7", children: months.map((month) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
434
|
-
|
|
534
|
+
Button2,
|
|
435
535
|
{
|
|
436
536
|
size: "lg",
|
|
437
537
|
disabled: month.disabled,
|
|
@@ -446,7 +546,7 @@ function MonthYearPicker({ value, minDate, maxDate, mode = "month", onChange, cl
|
|
|
446
546
|
}
|
|
447
547
|
function TimeItem({ option, selected, onSelect, className, disabled }) {
|
|
448
548
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
449
|
-
|
|
549
|
+
Button2,
|
|
450
550
|
{
|
|
451
551
|
variant: "ghost",
|
|
452
552
|
className: cn("flex justify-center px-1 pe-2 ps-1", className),
|
|
@@ -471,22 +571,22 @@ function buildTime({ use12HourFormat, value, formatStr, hour, minute, second, am
|
|
|
471
571
|
return dateFns.setHours(dateFns.setMinutes(dateFns.setSeconds(value, second), minute), hour);
|
|
472
572
|
}
|
|
473
573
|
function TimePicker({ value, onChange, use12HourFormat, min, max, timePicker }) {
|
|
474
|
-
const formatStr =
|
|
574
|
+
const formatStr = React2.useMemo(
|
|
475
575
|
() => use12HourFormat ? "yyyy-MM-dd hh:mm:ss.SSS a xxxx" : "yyyy-MM-dd HH:mm:ss.SSS xxxx",
|
|
476
576
|
[use12HourFormat]
|
|
477
577
|
);
|
|
478
|
-
const [ampm, setAmpm] =
|
|
479
|
-
const [hour, setHour] =
|
|
480
|
-
const [minute, setMinute] =
|
|
481
|
-
const [second, setSecond] =
|
|
482
|
-
|
|
578
|
+
const [ampm, setAmpm] = React2.useState(dateFns.format(value, "a") === "AM" ? AM_VALUE : PM_VALUE);
|
|
579
|
+
const [hour, setHour] = React2.useState(use12HourFormat ? +dateFns.format(value, "hh") : value.getHours());
|
|
580
|
+
const [minute, setMinute] = React2.useState(value.getMinutes());
|
|
581
|
+
const [second, setSecond] = React2.useState(value.getSeconds());
|
|
582
|
+
React2.useEffect(() => {
|
|
483
583
|
onChange(buildTime({ use12HourFormat, value, formatStr, hour, minute, second, ampm }));
|
|
484
584
|
}, [hour, minute, second, ampm, formatStr, use12HourFormat]);
|
|
485
|
-
const hourIn24h =
|
|
585
|
+
const hourIn24h = React2.useMemo(
|
|
486
586
|
() => use12HourFormat ? hour % 12 + ampm * 12 : hour,
|
|
487
587
|
[hour, use12HourFormat, ampm]
|
|
488
588
|
);
|
|
489
|
-
const hours =
|
|
589
|
+
const hours = React2.useMemo(
|
|
490
590
|
() => Array.from({ length: use12HourFormat ? 12 : 24 }, (_, i) => {
|
|
491
591
|
const hourValue = use12HourFormat ? i === 0 ? 12 : i : i;
|
|
492
592
|
const hDate = dateFns.setHours(value, use12HourFormat ? i + ampm * 12 : i);
|
|
@@ -497,7 +597,7 @@ function TimePicker({ value, onChange, use12HourFormat, min, max, timePicker })
|
|
|
497
597
|
}),
|
|
498
598
|
[value, min, max, use12HourFormat, ampm]
|
|
499
599
|
);
|
|
500
|
-
const minutes =
|
|
600
|
+
const minutes = React2.useMemo(() => {
|
|
501
601
|
const anchor = dateFns.setHours(value, hourIn24h);
|
|
502
602
|
return Array.from({ length: 60 }, (_, i) => {
|
|
503
603
|
const mDate = dateFns.setMinutes(anchor, i);
|
|
@@ -507,7 +607,7 @@ function TimePicker({ value, onChange, use12HourFormat, min, max, timePicker })
|
|
|
507
607
|
return { value: i, label: i.toString().padStart(2, "0"), disabled };
|
|
508
608
|
});
|
|
509
609
|
}, [value, min, max, hourIn24h]);
|
|
510
|
-
const seconds =
|
|
610
|
+
const seconds = React2.useMemo(() => {
|
|
511
611
|
const anchor = dateFns.setMilliseconds(dateFns.setMinutes(dateFns.setHours(value, hourIn24h), minute), 0);
|
|
512
612
|
const _min = min ? dateFns.setMilliseconds(min, 0) : void 0;
|
|
513
613
|
const _max = max ? dateFns.setMilliseconds(max, 0) : void 0;
|
|
@@ -519,7 +619,7 @@ function TimePicker({ value, onChange, use12HourFormat, min, max, timePicker })
|
|
|
519
619
|
return { value: i, label: i.toString().padStart(2, "0"), disabled };
|
|
520
620
|
});
|
|
521
621
|
}, [value, minute, min, max, hourIn24h]);
|
|
522
|
-
const ampmOptions =
|
|
622
|
+
const ampmOptions = React2.useMemo(() => {
|
|
523
623
|
const startD = dateFns.startOfDay(value);
|
|
524
624
|
const endD = dateFns.endOfDay(value);
|
|
525
625
|
return [
|
|
@@ -534,11 +634,11 @@ function TimePicker({ value, onChange, use12HourFormat, min, max, timePicker })
|
|
|
534
634
|
return { ...v, disabled };
|
|
535
635
|
});
|
|
536
636
|
}, [value, min, max]);
|
|
537
|
-
const [open, setOpen] =
|
|
538
|
-
const hourViewportRef =
|
|
539
|
-
const minuteViewportRef =
|
|
540
|
-
const secondViewportRef =
|
|
541
|
-
|
|
637
|
+
const [open, setOpen] = React2.useState(false);
|
|
638
|
+
const hourViewportRef = React2.useRef(null);
|
|
639
|
+
const minuteViewportRef = React2.useRef(null);
|
|
640
|
+
const secondViewportRef = React2.useRef(null);
|
|
641
|
+
React2.useEffect(() => {
|
|
542
642
|
const id = setTimeout(() => {
|
|
543
643
|
if (open) {
|
|
544
644
|
const ITEM_H = 32;
|
|
@@ -550,7 +650,7 @@ function TimePicker({ value, onChange, use12HourFormat, min, max, timePicker })
|
|
|
550
650
|
}, 1);
|
|
551
651
|
return () => clearTimeout(id);
|
|
552
652
|
}, [open, hours, hour, minute, second]);
|
|
553
|
-
const onHourChange =
|
|
653
|
+
const onHourChange = React2.useCallback(
|
|
554
654
|
(v) => {
|
|
555
655
|
if (min) {
|
|
556
656
|
const t = buildTime({ use12HourFormat, value, formatStr, hour: v.value, minute, second, ampm });
|
|
@@ -570,7 +670,7 @@ function TimePicker({ value, onChange, use12HourFormat, min, max, timePicker })
|
|
|
570
670
|
},
|
|
571
671
|
[use12HourFormat, value, formatStr, minute, second, ampm, min, max]
|
|
572
672
|
);
|
|
573
|
-
const onMinuteChange =
|
|
673
|
+
const onMinuteChange = React2.useCallback(
|
|
574
674
|
(v) => {
|
|
575
675
|
if (min) {
|
|
576
676
|
const t = buildTime({ use12HourFormat, value, formatStr, hour, minute: v.value, second, ampm });
|
|
@@ -584,7 +684,7 @@ function TimePicker({ value, onChange, use12HourFormat, min, max, timePicker })
|
|
|
584
684
|
},
|
|
585
685
|
[use12HourFormat, value, formatStr, hour, second, ampm, min, max]
|
|
586
686
|
);
|
|
587
|
-
const onAmpmChange =
|
|
687
|
+
const onAmpmChange = React2.useCallback(
|
|
588
688
|
(v) => {
|
|
589
689
|
if (min) {
|
|
590
690
|
const t = buildTime({ use12HourFormat, value, formatStr, hour, minute, second, ampm: v.value });
|
|
@@ -608,7 +708,7 @@ function TimePicker({ value, onChange, use12HourFormat, min, max, timePicker })
|
|
|
608
708
|
},
|
|
609
709
|
[use12HourFormat, value, formatStr, hour, minute, second, min, max]
|
|
610
710
|
);
|
|
611
|
-
const display =
|
|
711
|
+
const display = React2.useMemo(() => {
|
|
612
712
|
const parts = [];
|
|
613
713
|
for (const el of ["hour", "minute", "second"]) {
|
|
614
714
|
if (!timePicker || timePicker[el]) {
|
|
@@ -617,12 +717,12 @@ function TimePicker({ value, onChange, use12HourFormat, min, max, timePicker })
|
|
|
617
717
|
}
|
|
618
718
|
return dateFns.format(value, parts.join(":") + (use12HourFormat ? " a" : ""));
|
|
619
719
|
}, [value, use12HourFormat, timePicker]);
|
|
620
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
720
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Popover2, { open, onOpenChange: setOpen, children: [
|
|
621
721
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
622
|
-
|
|
722
|
+
PopoverTrigger2,
|
|
623
723
|
{
|
|
624
724
|
render: (props) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
625
|
-
|
|
725
|
+
Button2,
|
|
626
726
|
{
|
|
627
727
|
...props,
|
|
628
728
|
variant: "ghost",
|
|
@@ -639,11 +739,11 @@ function TimePicker({ value, onChange, use12HourFormat, min, max, timePicker })
|
|
|
639
739
|
)
|
|
640
740
|
}
|
|
641
741
|
),
|
|
642
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
643
|
-
(!timePicker || timePicker.hour) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
644
|
-
(!timePicker || timePicker.minute) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
645
|
-
(!timePicker || timePicker.second) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
646
|
-
use12HourFormat && /* @__PURE__ */ jsxRuntime.jsx(
|
|
742
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent2, { className: "p-0", side: "top", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-col gap-2 p-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-56 grow", children: [
|
|
743
|
+
(!timePicker || timePicker.hour) && /* @__PURE__ */ jsxRuntime.jsx(ScrollArea2, { className: "h-full grow", viewportRef: hourViewportRef, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex grow flex-col items-stretch overflow-y-auto pe-2 pb-48", children: hours.map((v) => /* @__PURE__ */ jsxRuntime.jsx(TimeItem, { option: v, selected: v.value === hour, onSelect: onHourChange, className: "h-8", disabled: v.disabled }, v.value)) }) }),
|
|
744
|
+
(!timePicker || timePicker.minute) && /* @__PURE__ */ jsxRuntime.jsx(ScrollArea2, { className: "h-full grow", viewportRef: minuteViewportRef, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex grow flex-col items-stretch overflow-y-auto pe-2 pb-48", children: minutes.map((v) => /* @__PURE__ */ jsxRuntime.jsx(TimeItem, { option: v, selected: v.value === minute, onSelect: onMinuteChange, className: "h-8", disabled: v.disabled }, v.value)) }) }),
|
|
745
|
+
(!timePicker || timePicker.second) && /* @__PURE__ */ jsxRuntime.jsx(ScrollArea2, { className: "h-full grow", viewportRef: secondViewportRef, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex grow flex-col items-stretch overflow-y-auto pe-2 pb-48", children: seconds.map((v) => /* @__PURE__ */ jsxRuntime.jsx(TimeItem, { option: v, selected: v.value === second, onSelect: (v2) => setSecond(v2.value), className: "h-8", disabled: v.disabled }, v.value)) }) }),
|
|
746
|
+
use12HourFormat && /* @__PURE__ */ jsxRuntime.jsx(ScrollArea2, { className: "h-full grow", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex grow flex-col items-stretch overflow-y-auto pe-2", children: ampmOptions.map((v) => /* @__PURE__ */ jsxRuntime.jsx(TimeItem, { option: v, selected: v.value === ampm, onSelect: onAmpmChange, className: "h-8", disabled: v.disabled }, v.value)) }) })
|
|
647
747
|
] }) }) })
|
|
648
748
|
] });
|
|
649
749
|
}
|
|
@@ -671,16 +771,16 @@ function DateTimePanel({
|
|
|
671
771
|
getRangeErrorMessage,
|
|
672
772
|
...props
|
|
673
773
|
}) {
|
|
674
|
-
const [monthYearPicker, setMonthYearPicker] =
|
|
675
|
-
const initDate =
|
|
676
|
-
const [month, setMonth] =
|
|
677
|
-
const [date, setDate] =
|
|
678
|
-
const [errorType, setErrorType] =
|
|
679
|
-
const [previousDate, setPreviousDate] =
|
|
680
|
-
const endMonth =
|
|
681
|
-
const minDate =
|
|
682
|
-
const maxDate =
|
|
683
|
-
const validate =
|
|
774
|
+
const [monthYearPicker, setMonthYearPicker] = React2.useState(false);
|
|
775
|
+
const initDate = React2.useMemo(() => new reactDayPicker.TZDate(value || /* @__PURE__ */ new Date(), timezone), [value, timezone]);
|
|
776
|
+
const [month, setMonth] = React2.useState(initDate);
|
|
777
|
+
const [date, setDate] = React2.useState(initDate);
|
|
778
|
+
const [errorType, setErrorType] = React2.useState(null);
|
|
779
|
+
const [previousDate, setPreviousDate] = React2.useState(initDate);
|
|
780
|
+
const endMonth = React2.useMemo(() => dateFns.setYear(month, dateFns.getYear(month) + 1), [month]);
|
|
781
|
+
const minDate = React2.useMemo(() => min ? new reactDayPicker.TZDate(min, timezone) : void 0, [min, timezone]);
|
|
782
|
+
const maxDate = React2.useMemo(() => max ? new reactDayPicker.TZDate(max, timezone) : void 0, [max, timezone]);
|
|
783
|
+
const validate = React2.useCallback(
|
|
684
784
|
(cur, cmp) => {
|
|
685
785
|
if (validateDateRange) return validateDateRange(cur, cmp);
|
|
686
786
|
if (!cmp) return { isValid: true, errorType: null };
|
|
@@ -690,7 +790,7 @@ function DateTimePanel({
|
|
|
690
790
|
},
|
|
691
791
|
[validateDateRange, title]
|
|
692
792
|
);
|
|
693
|
-
const onDayChanged =
|
|
793
|
+
const onDayChanged = React2.useCallback(
|
|
694
794
|
(d) => {
|
|
695
795
|
d.setHours(date.getHours(), date.getMinutes(), date.getSeconds());
|
|
696
796
|
if (min && d < min) d.setHours(min.getHours(), min.getMinutes(), min.getSeconds());
|
|
@@ -700,14 +800,14 @@ function DateTimePanel({
|
|
|
700
800
|
},
|
|
701
801
|
[date, immediate, onChangeAction, min, max]
|
|
702
802
|
);
|
|
703
|
-
const onTimeChanged =
|
|
803
|
+
const onTimeChanged = React2.useCallback(
|
|
704
804
|
(d) => {
|
|
705
805
|
setDate(d);
|
|
706
806
|
if (immediate) onChangeAction(new Date(d), true);
|
|
707
807
|
},
|
|
708
808
|
[immediate, onChangeAction]
|
|
709
809
|
);
|
|
710
|
-
const onSubmit =
|
|
810
|
+
const onSubmit = React2.useCallback(() => {
|
|
711
811
|
const result = validate(date, compareValue);
|
|
712
812
|
setErrorType(result.isValid ? null : result.errorType);
|
|
713
813
|
if (result.isValid) {
|
|
@@ -715,39 +815,39 @@ function DateTimePanel({
|
|
|
715
815
|
setPreviousDate(new Date(date));
|
|
716
816
|
}
|
|
717
817
|
}, [date, onChangeAction, compareValue, validate]);
|
|
718
|
-
const onCancel =
|
|
818
|
+
const onCancel = React2.useCallback(() => {
|
|
719
819
|
setDate(previousDate);
|
|
720
820
|
setMonth(previousDate);
|
|
721
821
|
setErrorType(null);
|
|
722
822
|
onChangeAction(void 0, false);
|
|
723
823
|
}, [previousDate, onChangeAction]);
|
|
724
|
-
const onMonthYearChanged =
|
|
824
|
+
const onMonthYearChanged = React2.useCallback((d, mode) => {
|
|
725
825
|
setMonth(d);
|
|
726
826
|
setMonthYearPicker(mode === "year" ? "month" : false);
|
|
727
827
|
}, []);
|
|
728
|
-
const onNextMonth =
|
|
729
|
-
const onPrevMonth =
|
|
730
|
-
|
|
828
|
+
const onNextMonth = React2.useCallback(() => setMonth(dateFns.addMonths(month, 1)), [month]);
|
|
829
|
+
const onPrevMonth = React2.useCallback(() => setMonth(dateFns.subMonths(month, 1)), [month]);
|
|
830
|
+
React2.useEffect(() => {
|
|
731
831
|
setDate(initDate);
|
|
732
832
|
setMonth(initDate);
|
|
733
833
|
setMonthYearPicker(false);
|
|
734
834
|
setPreviousDate(initDate);
|
|
735
835
|
}, [initDate]);
|
|
736
836
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
737
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
738
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
837
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-panel-header", children: [
|
|
838
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-panel-nav-label", children: [
|
|
739
839
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
740
840
|
/* @__PURE__ */ jsxRuntime.jsx("span", { onClick: () => setMonthYearPicker(monthYearPicker === "month" ? false : "month"), children: dateFns.format(month, "MMMM") }),
|
|
741
841
|
/* @__PURE__ */ jsxRuntime.jsx("span", { onClick: () => setMonthYearPicker(monthYearPicker === "year" ? false : "year"), children: dateFns.format(month, "yyyy") })
|
|
742
842
|
] }),
|
|
743
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
843
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button2, { variant: "ghost", size: "icon", onClick: () => setMonthYearPicker(monthYearPicker ? false : "year"), children: monthYearPicker ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUpIcon, { style: { width: 16, height: 16 } }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDownIcon, { style: { width: 16, height: 16 } }) })
|
|
744
844
|
] }),
|
|
745
|
-
!monthYearPicker && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
746
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
747
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
845
|
+
!monthYearPicker && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-panel-nav-btn", children: [
|
|
846
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button2, { variant: "ghost", size: "icon", "aria-label": "Previous month", onClick: onPrevMonth, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeftIcon, { style: { width: 16, height: 16 } }) }),
|
|
847
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button2, { variant: "ghost", size: "icon", "aria-label": "Next month", onClick: onNextMonth, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRightIcon, { style: { width: 16, height: 16 } }) })
|
|
748
848
|
] })
|
|
749
849
|
] }),
|
|
750
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
850
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-panel-calendar", children: [
|
|
751
851
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
752
852
|
reactDayPicker.DayPicker,
|
|
753
853
|
{
|
|
@@ -772,31 +872,31 @@ function DateTimePanel({
|
|
|
772
872
|
disabled: [max ? { after: max } : null, min ? { before: min } : null].filter(Boolean),
|
|
773
873
|
onMonthChange: setMonth,
|
|
774
874
|
classNames: {
|
|
775
|
-
dropdowns: "
|
|
776
|
-
months: "
|
|
777
|
-
month: "
|
|
875
|
+
dropdowns: "datetime-range-cal-dropdowns",
|
|
876
|
+
months: "datetime-range-cal-months",
|
|
877
|
+
month: "datetime-range-cal-month",
|
|
778
878
|
month_caption: "hidden",
|
|
779
879
|
button_previous: "hidden",
|
|
780
880
|
button_next: "hidden",
|
|
781
|
-
month_grid: "
|
|
782
|
-
weekdays: "
|
|
783
|
-
weekday: "
|
|
784
|
-
week: "
|
|
785
|
-
day: "
|
|
786
|
-
day_button: "
|
|
787
|
-
range_end: "
|
|
788
|
-
selected: "
|
|
789
|
-
today: "
|
|
790
|
-
outside: "
|
|
791
|
-
disabled: "
|
|
792
|
-
range_middle: "
|
|
793
|
-
hidden: "
|
|
881
|
+
month_grid: "datetime-range-cal-month-grid",
|
|
882
|
+
weekdays: "datetime-range-cal-weekdays",
|
|
883
|
+
weekday: "datetime-range-cal-weekday",
|
|
884
|
+
week: "datetime-range-cal-week",
|
|
885
|
+
day: "datetime-range-cal-day",
|
|
886
|
+
day_button: "datetime-range-cal-day-btn",
|
|
887
|
+
range_end: "datetime-range-cal-day-range-end",
|
|
888
|
+
selected: "datetime-range-cal-day-selected",
|
|
889
|
+
today: "datetime-range-cal-day-today",
|
|
890
|
+
outside: "datetime-range-cal-day-outside",
|
|
891
|
+
disabled: "datetime-range-cal-day-disabled",
|
|
892
|
+
range_middle: "datetime-range-cal-day-range-middle",
|
|
893
|
+
hidden: "datetime-range-cal-day-hidden"
|
|
794
894
|
},
|
|
795
895
|
showOutsideDays: true,
|
|
796
896
|
...props
|
|
797
897
|
}
|
|
798
898
|
),
|
|
799
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("
|
|
899
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("datetime-range-panel-overlay", !monthYearPicker && "datetime-range-panel-overlay--hidden") }),
|
|
800
900
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
801
901
|
MonthYearPicker,
|
|
802
902
|
{
|
|
@@ -805,12 +905,12 @@ function DateTimePanel({
|
|
|
805
905
|
onChange: onMonthYearChanged,
|
|
806
906
|
minDate,
|
|
807
907
|
maxDate,
|
|
808
|
-
className: cn("
|
|
908
|
+
className: cn("datetime-range-panel-monthyear", !monthYearPicker && "datetime-range-panel-monthyear--hidden")
|
|
809
909
|
}
|
|
810
910
|
)
|
|
811
911
|
] }),
|
|
812
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
813
|
-
precision !== "date" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
912
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-panel-footer", children: [
|
|
913
|
+
precision !== "date" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "datetime-range-panel-time", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
814
914
|
TimePicker,
|
|
815
915
|
{
|
|
816
916
|
timePicker: precisionToTimePicker(precision),
|
|
@@ -821,10 +921,10 @@ function DateTimePanel({
|
|
|
821
921
|
max: maxDate
|
|
822
922
|
}
|
|
823
923
|
) }),
|
|
824
|
-
(isError || errorType !== null) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
825
|
-
!immediate && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
826
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
827
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
924
|
+
(isError || errorType !== null) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "datetime-range-panel-error", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "datetime-range-panel-error-msg", children: getRangeErrorMessage?.(errorType, title) ?? "Invalid date range." }) }),
|
|
925
|
+
!immediate && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-panel-buttons", children: [
|
|
926
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button2, { variant: "outline", size: "sm", onClick: onCancel, children: "Cancel" }),
|
|
927
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button2, { size: "sm", onClick: onSubmit, children: "Done" })
|
|
828
928
|
] })
|
|
829
929
|
] })
|
|
830
930
|
] });
|
|
@@ -888,8 +988,8 @@ function DatetimeSegmentInput({
|
|
|
888
988
|
isError = false,
|
|
889
989
|
precision = "second"
|
|
890
990
|
}) {
|
|
891
|
-
const containerRef =
|
|
892
|
-
const spanRefs =
|
|
991
|
+
const containerRef = React2.useRef(null);
|
|
992
|
+
const spanRefs = React2.useRef({
|
|
893
993
|
year: null,
|
|
894
994
|
month: null,
|
|
895
995
|
day: null,
|
|
@@ -897,7 +997,7 @@ function DatetimeSegmentInput({
|
|
|
897
997
|
minute: null,
|
|
898
998
|
second: null
|
|
899
999
|
});
|
|
900
|
-
const [typing, setTyping] =
|
|
1000
|
+
const [typing, setTyping] = React2.useState({
|
|
901
1001
|
year: null,
|
|
902
1002
|
month: null,
|
|
903
1003
|
day: null,
|
|
@@ -905,14 +1005,14 @@ function DatetimeSegmentInput({
|
|
|
905
1005
|
minute: null,
|
|
906
1006
|
second: null
|
|
907
1007
|
});
|
|
908
|
-
const date =
|
|
1008
|
+
const date = React2.useMemo(
|
|
909
1009
|
() => !Number.isNaN(value.getTime()) ? value : /* @__PURE__ */ new Date(),
|
|
910
1010
|
[value]
|
|
911
1011
|
);
|
|
912
|
-
const focusSegment =
|
|
1012
|
+
const focusSegment = React2.useCallback((key) => {
|
|
913
1013
|
spanRefs.current[key]?.focus();
|
|
914
1014
|
}, []);
|
|
915
|
-
const commitTyping =
|
|
1015
|
+
const commitTyping = React2.useCallback((key, buf) => {
|
|
916
1016
|
const num = parseInt(buf, 10);
|
|
917
1017
|
const seg = SEGMENTS.find((s) => s.key === key);
|
|
918
1018
|
if (!Number.isNaN(num)) {
|
|
@@ -921,11 +1021,11 @@ function DatetimeSegmentInput({
|
|
|
921
1021
|
}
|
|
922
1022
|
setTyping((prev) => ({ ...prev, [key]: null }));
|
|
923
1023
|
}, [date, onChange]);
|
|
924
|
-
const activeSegments =
|
|
1024
|
+
const activeSegments = React2.useMemo(() => {
|
|
925
1025
|
const count = precision === "date" ? 3 : precision === "hour" ? 4 : precision === "minute" ? 5 : 6;
|
|
926
1026
|
return SEGMENTS.slice(0, count);
|
|
927
1027
|
}, [precision]);
|
|
928
|
-
const handleKeyDown =
|
|
1028
|
+
const handleKeyDown = React2.useCallback((e, seg) => {
|
|
929
1029
|
if (disabled) return;
|
|
930
1030
|
const { key } = seg;
|
|
931
1031
|
const idx = activeSegments.findIndex((s) => s.key === key);
|
|
@@ -970,7 +1070,7 @@ function DatetimeSegmentInput({
|
|
|
970
1070
|
return;
|
|
971
1071
|
}
|
|
972
1072
|
}, [disabled, typing, date, onChange, commitTyping, focusSegment, activeSegments]);
|
|
973
|
-
const handleBlur =
|
|
1073
|
+
const handleBlur = React2.useCallback((key) => {
|
|
974
1074
|
const buf = typing[key];
|
|
975
1075
|
if (buf !== null) commitTyping(key, buf);
|
|
976
1076
|
}, [typing, commitTyping]);
|
|
@@ -984,7 +1084,7 @@ function DatetimeSegmentInput({
|
|
|
984
1084
|
"div",
|
|
985
1085
|
{
|
|
986
1086
|
ref: containerRef,
|
|
987
|
-
className: cn("
|
|
1087
|
+
className: cn("datetime-range-segment-input", className),
|
|
988
1088
|
"data-error": isError || void 0,
|
|
989
1089
|
"data-disabled": disabled || void 0,
|
|
990
1090
|
onMouseDown: (e) => {
|
|
@@ -997,8 +1097,8 @@ function DatetimeSegmentInput({
|
|
|
997
1097
|
children: activeSegments.map((seg, idx) => {
|
|
998
1098
|
const sep = idx === 0 ? null : idx === 3 ? "\xA0" : idx < 3 ? "-" : ":";
|
|
999
1099
|
const isFocused = typing[seg.key] !== null;
|
|
1000
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1001
|
-
sep !== null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "
|
|
1100
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React2__default.default.Fragment, { children: [
|
|
1101
|
+
sep !== null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "datetime-range-segment-sep", "aria-hidden": true, children: sep }),
|
|
1002
1102
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1003
1103
|
"div",
|
|
1004
1104
|
{
|
|
@@ -1011,7 +1111,7 @@ function DatetimeSegmentInput({
|
|
|
1011
1111
|
"aria-valuemin": seg.min,
|
|
1012
1112
|
"aria-valuemax": seg.max,
|
|
1013
1113
|
tabIndex: disabled ? -1 : 0,
|
|
1014
|
-
className: "
|
|
1114
|
+
className: "datetime-range-segment",
|
|
1015
1115
|
"data-focused": isFocused || void 0,
|
|
1016
1116
|
style: { height: "24px", lineHeight: "24px" },
|
|
1017
1117
|
onKeyDown: (e) => handleKeyDown(e, seg),
|
|
@@ -1162,14 +1262,14 @@ function validateRange(start, end) {
|
|
|
1162
1262
|
return null;
|
|
1163
1263
|
}
|
|
1164
1264
|
function RelativeSidePanel({ value, onChange, relativeFormats, showNow, labels }) {
|
|
1165
|
-
const [numValue, setNumValue] =
|
|
1265
|
+
const [numValue, setNumValue] = React2.useState(
|
|
1166
1266
|
value.relativeValue !== void 0 ? String(value.relativeValue) : "5"
|
|
1167
1267
|
);
|
|
1168
|
-
const [format3, setFormat] =
|
|
1268
|
+
const [format3, setFormat] = React2.useState(
|
|
1169
1269
|
value.relativeFormat ?? relativeFormats[0] ?? "Minutes ago"
|
|
1170
1270
|
);
|
|
1171
|
-
const [isNow, setIsNow] =
|
|
1172
|
-
|
|
1271
|
+
const [isNow, setIsNow] = React2.useState(value.relativeNow ?? false);
|
|
1272
|
+
React2.useEffect(() => {
|
|
1173
1273
|
if (value.relativeNow) {
|
|
1174
1274
|
setIsNow(true);
|
|
1175
1275
|
} else {
|
|
@@ -1190,17 +1290,17 @@ function RelativeSidePanel({ value, onChange, relativeFormats, showNow, labels }
|
|
|
1190
1290
|
});
|
|
1191
1291
|
}
|
|
1192
1292
|
};
|
|
1193
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
1293
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-relative", children: [
|
|
1194
1294
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1195
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "
|
|
1196
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
1295
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "datetime-range-relative-label", children: labels.amount }),
|
|
1296
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-relative-row", children: [
|
|
1197
1297
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1198
|
-
|
|
1298
|
+
Input2,
|
|
1199
1299
|
{
|
|
1200
1300
|
type: "text",
|
|
1201
1301
|
inputMode: "numeric",
|
|
1202
1302
|
pattern: "[0-9]*",
|
|
1203
|
-
className: "
|
|
1303
|
+
className: "datetime-range-relative-input",
|
|
1204
1304
|
disabled: isNow,
|
|
1205
1305
|
value: numValue,
|
|
1206
1306
|
onChange: (e) => {
|
|
@@ -1217,7 +1317,7 @@ function RelativeSidePanel({ value, onChange, relativeFormats, showNow, labels }
|
|
|
1217
1317
|
}
|
|
1218
1318
|
),
|
|
1219
1319
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1220
|
-
|
|
1320
|
+
Select2,
|
|
1221
1321
|
{
|
|
1222
1322
|
disabled: isNow,
|
|
1223
1323
|
value: format3,
|
|
@@ -1227,16 +1327,16 @@ function RelativeSidePanel({ value, onChange, relativeFormats, showNow, labels }
|
|
|
1227
1327
|
emit({ numValue, format: f, isNow });
|
|
1228
1328
|
},
|
|
1229
1329
|
children: [
|
|
1230
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1231
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1330
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger2, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue2, { children: format3 }) }),
|
|
1331
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectContent2, { children: relativeFormats.map((f) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem2, { value: f, children: f }, f)) })
|
|
1232
1332
|
]
|
|
1233
1333
|
}
|
|
1234
1334
|
)
|
|
1235
1335
|
] })
|
|
1236
1336
|
] }),
|
|
1237
|
-
showNow && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
1337
|
+
showNow && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-relative-now-row", children: [
|
|
1238
1338
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1239
|
-
|
|
1339
|
+
Switch2,
|
|
1240
1340
|
{
|
|
1241
1341
|
checked: isNow,
|
|
1242
1342
|
onCheckedChange: (checked) => {
|
|
@@ -1245,9 +1345,9 @@ function RelativeSidePanel({ value, onChange, relativeFormats, showNow, labels }
|
|
|
1245
1345
|
}
|
|
1246
1346
|
}
|
|
1247
1347
|
),
|
|
1248
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
1249
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "
|
|
1250
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "
|
|
1348
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-relative-now-labels", children: [
|
|
1349
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "datetime-range-relative-now-label", children: labels.now }),
|
|
1350
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "datetime-range-relative-now-desc", children: labels.nowDescription })
|
|
1251
1351
|
] })
|
|
1252
1352
|
] })
|
|
1253
1353
|
] });
|
|
@@ -1261,67 +1361,72 @@ function AbsoluteContent({
|
|
|
1261
1361
|
min,
|
|
1262
1362
|
max,
|
|
1263
1363
|
timezone,
|
|
1264
|
-
use12HourFormat
|
|
1364
|
+
use12HourFormat,
|
|
1365
|
+
calendarMode = "popover"
|
|
1265
1366
|
}) {
|
|
1266
1367
|
const compareDate = compareValue ? toDate(compareValue) : void 0;
|
|
1267
1368
|
const currentDate = value.type === "absolute" ? toDate(value) : /* @__PURE__ */ new Date();
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1369
|
+
const calendarPanel = /* @__PURE__ */ jsxRuntime.jsx(
|
|
1370
|
+
DateTimePanel,
|
|
1371
|
+
{
|
|
1372
|
+
value: value.type === "absolute" ? currentDate : void 0,
|
|
1373
|
+
compareValue: compareDate,
|
|
1374
|
+
title,
|
|
1375
|
+
immediate: true,
|
|
1376
|
+
precision,
|
|
1377
|
+
min,
|
|
1378
|
+
max,
|
|
1379
|
+
timezone,
|
|
1380
|
+
use12HourFormat,
|
|
1381
|
+
onChangeAction: (d) => {
|
|
1382
|
+
if (!d) return;
|
|
1383
|
+
onChange(absoluteDate(d));
|
|
1276
1384
|
}
|
|
1277
|
-
|
|
1278
|
-
|
|
1385
|
+
}
|
|
1386
|
+
);
|
|
1387
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1388
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-absolute-row", children: [
|
|
1279
1389
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1280
|
-
|
|
1390
|
+
DatetimeSegmentInput,
|
|
1281
1391
|
{
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
type: "button",
|
|
1287
|
-
variant: "outline",
|
|
1288
|
-
size: "icon",
|
|
1289
|
-
className: "dr-absolute-btn",
|
|
1290
|
-
title: "Pick from calendar",
|
|
1291
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarDays, { size: 14 })
|
|
1292
|
-
}
|
|
1293
|
-
)
|
|
1392
|
+
value: currentDate,
|
|
1393
|
+
onChange: (d) => onChange(absoluteDate(d)),
|
|
1394
|
+
className: "datetime-range-absolute-input",
|
|
1395
|
+
precision
|
|
1294
1396
|
}
|
|
1295
1397
|
),
|
|
1296
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
immediate: true,
|
|
1311
|
-
precision,
|
|
1312
|
-
min,
|
|
1313
|
-
max,
|
|
1314
|
-
timezone,
|
|
1315
|
-
use12HourFormat,
|
|
1316
|
-
onChangeAction: (d) => {
|
|
1317
|
-
if (!d) return;
|
|
1318
|
-
onChange(absoluteDate(d));
|
|
1398
|
+
calendarMode === "popover" && /* @__PURE__ */ jsxRuntime.jsxs(Popover2, { children: [
|
|
1399
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1400
|
+
PopoverTrigger2,
|
|
1401
|
+
{
|
|
1402
|
+
render: (triggerProps) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1403
|
+
Button2,
|
|
1404
|
+
{
|
|
1405
|
+
...triggerProps,
|
|
1406
|
+
type: "button",
|
|
1407
|
+
variant: "outline",
|
|
1408
|
+
size: "icon",
|
|
1409
|
+
className: "datetime-range-absolute-btn",
|
|
1410
|
+
title: "Pick from calendar",
|
|
1411
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarDays, { size: 14 })
|
|
1319
1412
|
}
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1413
|
+
)
|
|
1414
|
+
}
|
|
1415
|
+
),
|
|
1416
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1417
|
+
PopoverContent2,
|
|
1418
|
+
{
|
|
1419
|
+
className: "p-0 w-auto",
|
|
1420
|
+
side: "bottom",
|
|
1421
|
+
align: "start",
|
|
1422
|
+
sideOffset: 6,
|
|
1423
|
+
disableAnchorTracking: true,
|
|
1424
|
+
children: calendarPanel
|
|
1425
|
+
}
|
|
1426
|
+
)
|
|
1427
|
+
] })
|
|
1428
|
+
] }),
|
|
1429
|
+
calendarMode === "inline" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "datetime-range-absolute-inline-calendar", children: calendarPanel })
|
|
1325
1430
|
] });
|
|
1326
1431
|
}
|
|
1327
1432
|
function SidePanel({
|
|
@@ -1338,10 +1443,12 @@ function SidePanel({
|
|
|
1338
1443
|
max,
|
|
1339
1444
|
timezone,
|
|
1340
1445
|
use12HourFormat,
|
|
1341
|
-
labels: labelsProp
|
|
1446
|
+
labels: labelsProp,
|
|
1447
|
+
calendarMode,
|
|
1448
|
+
uiAdapter
|
|
1342
1449
|
}) {
|
|
1343
1450
|
const labels = { ...DEFAULT_LABELS, ...labelsProp };
|
|
1344
|
-
|
|
1451
|
+
React2.useEffect(() => {
|
|
1345
1452
|
if (!showRelative && value.type === "relative") {
|
|
1346
1453
|
onChange(absoluteDate(/* @__PURE__ */ new Date()));
|
|
1347
1454
|
} else if (!showAbsolute && value.type === "absolute") {
|
|
@@ -1360,7 +1467,8 @@ function SidePanel({
|
|
|
1360
1467
|
min,
|
|
1361
1468
|
max,
|
|
1362
1469
|
timezone,
|
|
1363
|
-
use12HourFormat
|
|
1470
|
+
use12HourFormat,
|
|
1471
|
+
calendarMode
|
|
1364
1472
|
}
|
|
1365
1473
|
);
|
|
1366
1474
|
const relativeContent = /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1373,13 +1481,13 @@ function SidePanel({
|
|
|
1373
1481
|
labels
|
|
1374
1482
|
}
|
|
1375
1483
|
);
|
|
1376
|
-
|
|
1377
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "
|
|
1484
|
+
const content = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-side-panel", children: [
|
|
1485
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "datetime-range-side-panel-title", children: title }),
|
|
1378
1486
|
hasBothModes ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1379
|
-
|
|
1487
|
+
Tabs2,
|
|
1380
1488
|
{
|
|
1381
1489
|
value: value.type,
|
|
1382
|
-
className: "
|
|
1490
|
+
className: "datetime-range-side-panel-tabs",
|
|
1383
1491
|
onValueChange: (t) => {
|
|
1384
1492
|
if (t === "absolute") {
|
|
1385
1493
|
onChange(absoluteDate(value.type === "absolute" ? toDate(value) : /* @__PURE__ */ new Date()));
|
|
@@ -1388,28 +1496,29 @@ function SidePanel({
|
|
|
1388
1496
|
}
|
|
1389
1497
|
},
|
|
1390
1498
|
children: [
|
|
1391
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1392
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1393
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1499
|
+
/* @__PURE__ */ jsxRuntime.jsxs(TabsList2, { className: "datetime-range-tabs-list--grid datetime-range-tabs-list--grid-2", children: [
|
|
1500
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger2, { value: "absolute", children: labels.absolute }),
|
|
1501
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger2, { value: "relative", children: labels.relative })
|
|
1394
1502
|
] }),
|
|
1395
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1396
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1503
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsContent2, { value: "absolute", children: absoluteContent }),
|
|
1504
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsContent2, { value: "relative", children: relativeContent })
|
|
1397
1505
|
]
|
|
1398
1506
|
}
|
|
1399
1507
|
) : showAbsolute ? absoluteContent : relativeContent
|
|
1400
1508
|
] });
|
|
1509
|
+
return uiAdapter ? /* @__PURE__ */ jsxRuntime.jsx(DatetimeRangeProvider, { adapter: uiAdapter, children: content }) : content;
|
|
1401
1510
|
}
|
|
1402
1511
|
function useDatetimeRange({
|
|
1403
1512
|
startTime,
|
|
1404
1513
|
endTime,
|
|
1405
1514
|
onChange
|
|
1406
1515
|
}) {
|
|
1407
|
-
const [isOpen, setIsOpen] =
|
|
1408
|
-
const [draftStart, setDraftStart] =
|
|
1409
|
-
const [draftEnd, setDraftEnd] =
|
|
1410
|
-
const [error, setError] =
|
|
1411
|
-
const wasOpen =
|
|
1412
|
-
|
|
1516
|
+
const [isOpen, setIsOpen] = React2.useState(false);
|
|
1517
|
+
const [draftStart, setDraftStart] = React2.useState(startTime);
|
|
1518
|
+
const [draftEnd, setDraftEnd] = React2.useState(endTime);
|
|
1519
|
+
const [error, setError] = React2.useState(null);
|
|
1520
|
+
const wasOpen = React2.useRef(false);
|
|
1521
|
+
React2.useEffect(() => {
|
|
1413
1522
|
const justOpened = isOpen && !wasOpen.current;
|
|
1414
1523
|
wasOpen.current = isOpen;
|
|
1415
1524
|
if (justOpened) {
|
|
@@ -1418,8 +1527,8 @@ function useDatetimeRange({
|
|
|
1418
1527
|
setError(null);
|
|
1419
1528
|
}
|
|
1420
1529
|
}, [isOpen, startTime, endTime]);
|
|
1421
|
-
const clearError =
|
|
1422
|
-
const onApply =
|
|
1530
|
+
const clearError = React2.useCallback(() => setError(null), []);
|
|
1531
|
+
const onApply = React2.useCallback(() => {
|
|
1423
1532
|
const err = validateRange(draftStart, draftEnd);
|
|
1424
1533
|
if (err) {
|
|
1425
1534
|
setError(err);
|
|
@@ -1428,13 +1537,13 @@ function useDatetimeRange({
|
|
|
1428
1537
|
onChange(draftStart, draftEnd);
|
|
1429
1538
|
setIsOpen(false);
|
|
1430
1539
|
}, [draftStart, draftEnd, onChange]);
|
|
1431
|
-
const onCancel =
|
|
1540
|
+
const onCancel = React2.useCallback(() => {
|
|
1432
1541
|
setDraftStart(startTime);
|
|
1433
1542
|
setDraftEnd(endTime);
|
|
1434
1543
|
setError(null);
|
|
1435
1544
|
setIsOpen(false);
|
|
1436
1545
|
}, [startTime, endTime]);
|
|
1437
|
-
const onPreset =
|
|
1546
|
+
const onPreset = React2.useCallback((preset) => {
|
|
1438
1547
|
onChange(preset.start, preset.end);
|
|
1439
1548
|
setIsOpen(false);
|
|
1440
1549
|
}, [onChange]);
|
|
@@ -1467,13 +1576,15 @@ function DatetimeRange({
|
|
|
1467
1576
|
timezone,
|
|
1468
1577
|
use12HourFormat = false,
|
|
1469
1578
|
showNow = true,
|
|
1579
|
+
calendarMode = "popover",
|
|
1470
1580
|
disabled = false,
|
|
1471
1581
|
labels: labelsProp,
|
|
1472
1582
|
popoverAlign = "start",
|
|
1473
1583
|
popoverSide = "bottom",
|
|
1474
1584
|
renderTrigger,
|
|
1475
1585
|
portalContainer,
|
|
1476
|
-
className
|
|
1586
|
+
className,
|
|
1587
|
+
uiAdapter
|
|
1477
1588
|
}) {
|
|
1478
1589
|
const labels = { ...DEFAULT_LABELS, ...labelsProp };
|
|
1479
1590
|
const {
|
|
@@ -1499,24 +1610,25 @@ function DatetimeRange({
|
|
|
1499
1610
|
max,
|
|
1500
1611
|
timezone,
|
|
1501
1612
|
use12HourFormat,
|
|
1502
|
-
labels
|
|
1613
|
+
labels,
|
|
1614
|
+
calendarMode
|
|
1503
1615
|
};
|
|
1504
|
-
|
|
1616
|
+
const content = /* @__PURE__ */ jsxRuntime.jsxs(Popover2, { open: isOpen, onOpenChange: disabled ? void 0 : setIsOpen, children: [
|
|
1505
1617
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1506
|
-
|
|
1618
|
+
PopoverTrigger2,
|
|
1507
1619
|
{
|
|
1508
1620
|
disabled,
|
|
1509
1621
|
render: (triggerProps) => renderTrigger ? renderTrigger(triggerProps, { open: isOpen, startTime, endTime }) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1510
|
-
|
|
1622
|
+
Button2,
|
|
1511
1623
|
{
|
|
1512
1624
|
...triggerProps,
|
|
1513
1625
|
variant: "outline",
|
|
1514
1626
|
disabled,
|
|
1515
|
-
className: cn("
|
|
1627
|
+
className: cn("datetime-range-range-trigger", isOpen && "datetime-range-range-trigger--open", className),
|
|
1516
1628
|
children: [
|
|
1517
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarDays, { size: 14, className: "
|
|
1629
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarDays, { size: 14, className: "datetime-range-range-trigger-icon" }),
|
|
1518
1630
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: toDisplayString(startTime, { precision }) }),
|
|
1519
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "
|
|
1631
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "datetime-range-range-trigger-arrow", children: "\u2192" }),
|
|
1520
1632
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: toDisplayString(endTime, { precision }) })
|
|
1521
1633
|
]
|
|
1522
1634
|
}
|
|
@@ -1524,31 +1636,31 @@ function DatetimeRange({
|
|
|
1524
1636
|
}
|
|
1525
1637
|
),
|
|
1526
1638
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1527
|
-
|
|
1639
|
+
PopoverContent2,
|
|
1528
1640
|
{
|
|
1529
|
-
className: "
|
|
1641
|
+
className: "datetime-range-range-popup-content",
|
|
1530
1642
|
align: popoverAlign,
|
|
1531
1643
|
side: popoverSide,
|
|
1532
1644
|
sideOffset: 4,
|
|
1533
1645
|
container: portalContainer,
|
|
1534
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
1535
|
-
showQuickRanges && quickPresets.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
1536
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
1537
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
1646
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-range-popup", children: [
|
|
1647
|
+
showQuickRanges && quickPresets.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "datetime-range-range-quick", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-range-quick-inner", children: [
|
|
1648
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "datetime-range-range-quick-label", children: labels.quickRanges }),
|
|
1649
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "datetime-range-range-quick-list", children: quickPresets.map((preset) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1538
1650
|
"button",
|
|
1539
1651
|
{
|
|
1540
1652
|
type: "button",
|
|
1541
|
-
className: "
|
|
1653
|
+
className: "datetime-range-range-quick-item",
|
|
1542
1654
|
onClick: () => handlePreset(preset),
|
|
1543
1655
|
children: preset.label
|
|
1544
1656
|
},
|
|
1545
1657
|
preset.label
|
|
1546
1658
|
)) })
|
|
1547
1659
|
] }) }),
|
|
1548
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
1549
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
1550
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
1551
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
1660
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-range-pickers", children: [
|
|
1661
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "datetime-range-range-divider" }),
|
|
1662
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-range-panels", children: [
|
|
1663
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "datetime-range-range-panel-slot", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1552
1664
|
SidePanel,
|
|
1553
1665
|
{
|
|
1554
1666
|
title: labels.start,
|
|
@@ -1561,7 +1673,7 @@ function DatetimeRange({
|
|
|
1561
1673
|
...sidePanelProps
|
|
1562
1674
|
}
|
|
1563
1675
|
) }),
|
|
1564
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
1676
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "datetime-range-range-panel-slot", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1565
1677
|
SidePanel,
|
|
1566
1678
|
{
|
|
1567
1679
|
title: labels.end,
|
|
@@ -1575,11 +1687,11 @@ function DatetimeRange({
|
|
|
1575
1687
|
}
|
|
1576
1688
|
) })
|
|
1577
1689
|
] }),
|
|
1578
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
1579
|
-
error === "validation" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "
|
|
1580
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
1581
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1582
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1690
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-range-footer", children: [
|
|
1691
|
+
error === "validation" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "datetime-range-range-error-text", children: "Start must be earlier than end." }) : /* @__PURE__ */ jsxRuntime.jsx("span", {}),
|
|
1692
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "datetime-range-range-actions", children: [
|
|
1693
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button2, { variant: "outline", size: "sm", onClick: handleCancel, children: labels.cancel }),
|
|
1694
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button2, { size: "sm", onClick: handleApply, children: labels.apply })
|
|
1583
1695
|
] })
|
|
1584
1696
|
] })
|
|
1585
1697
|
] })
|
|
@@ -1587,10 +1699,12 @@ function DatetimeRange({
|
|
|
1587
1699
|
}
|
|
1588
1700
|
)
|
|
1589
1701
|
] });
|
|
1702
|
+
return uiAdapter ? /* @__PURE__ */ jsxRuntime.jsx(DatetimeRangeProvider, { adapter: uiAdapter, children: content }) : content;
|
|
1590
1703
|
}
|
|
1591
1704
|
|
|
1592
1705
|
exports.DateTimePanel = DateTimePanel;
|
|
1593
1706
|
exports.DatetimeRange = DatetimeRange;
|
|
1707
|
+
exports.DatetimeRangeProvider = DatetimeRangeProvider;
|
|
1594
1708
|
exports.DatetimeSegmentInput = DatetimeSegmentInput;
|
|
1595
1709
|
exports.QUICK_PRESETS = QUICK_PRESETS;
|
|
1596
1710
|
exports.RELATIVE_FORMATS = RELATIVE_FORMATS;
|
|
@@ -1605,6 +1719,7 @@ exports.toTimestamp = toTimestamp;
|
|
|
1605
1719
|
exports.toTimestampMs = toTimestampMs;
|
|
1606
1720
|
exports.toUrlString = toUrlString;
|
|
1607
1721
|
exports.useDatetimeRange = useDatetimeRange;
|
|
1722
|
+
exports.useDatetimeRangeUI = useDatetimeRangeUI;
|
|
1608
1723
|
exports.validateRange = validateRange;
|
|
1609
1724
|
//# sourceMappingURL=index.cjs.map
|
|
1610
1725
|
//# sourceMappingURL=index.cjs.map
|