@pos-360/horizon 0.27.0 → 0.27.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/dist/{chunk-HM5GFDXY.mjs → chunk-2LATCE3V.mjs} +89 -42
- package/dist/chunk-2LATCE3V.mjs.map +1 -0
- package/dist/{chunk-ZXSNRAGZ.js → chunk-JP5BJYYD.js} +89 -42
- package/dist/chunk-JP5BJYYD.js.map +1 -0
- package/dist/index.js +103 -103
- package/dist/index.mjs +1 -1
- package/dist/primitives.js +103 -103
- package/dist/primitives.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-HM5GFDXY.mjs.map +0 -1
- package/dist/chunk-ZXSNRAGZ.js.map +0 -1
|
@@ -2302,27 +2302,33 @@ function DateRangePicker({
|
|
|
2302
2302
|
from: void 0,
|
|
2303
2303
|
to: void 0
|
|
2304
2304
|
});
|
|
2305
|
+
const [draft, setDraft] = React10__namespace.useState({
|
|
2306
|
+
from: void 0,
|
|
2307
|
+
to: void 0
|
|
2308
|
+
});
|
|
2305
2309
|
const [hoverDate, setHoverDate] = React10__namespace.useState();
|
|
2306
2310
|
const [leftMonth, setLeftMonth] = React10__namespace.useState(
|
|
2307
2311
|
() => dateFns.startOfMonth(value?.from ?? /* @__PURE__ */ new Date())
|
|
2308
2312
|
);
|
|
2309
2313
|
const [activePreset, setActivePreset] = React10__namespace.useState();
|
|
2310
|
-
const
|
|
2314
|
+
const committedRange = value ?? internalRange;
|
|
2315
|
+
const handleOpenChange = (newOpen) => {
|
|
2316
|
+
if (newOpen) {
|
|
2317
|
+
setDraft(committedRange);
|
|
2318
|
+
if (committedRange.from) setLeftMonth(dateFns.startOfMonth(committedRange.from));
|
|
2319
|
+
}
|
|
2320
|
+
setOpen(newOpen);
|
|
2321
|
+
};
|
|
2311
2322
|
const handleDayClick = (date) => {
|
|
2312
|
-
const { from, to } =
|
|
2323
|
+
const { from, to } = draft;
|
|
2313
2324
|
if (!from || from && to) {
|
|
2314
|
-
|
|
2325
|
+
setDraft({ from: date, to: void 0 });
|
|
2315
2326
|
setActivePreset(void 0);
|
|
2316
|
-
if (onChange) onChange(newRange2);
|
|
2317
|
-
else setInternalRange(newRange2);
|
|
2318
2327
|
return;
|
|
2319
2328
|
}
|
|
2320
2329
|
const [start, end] = dateFns.isBefore(from, date) ? [from, date] : [date, from];
|
|
2321
|
-
|
|
2322
|
-
if (onChange) onChange(newRange);
|
|
2323
|
-
else setInternalRange(newRange);
|
|
2330
|
+
setDraft({ from: start, to: end });
|
|
2324
2331
|
setHoverDate(void 0);
|
|
2325
|
-
setOpen(false);
|
|
2326
2332
|
};
|
|
2327
2333
|
const handlePreset = (preset) => {
|
|
2328
2334
|
const newRange = preset.getRange();
|
|
@@ -2332,8 +2338,21 @@ function DateRangePicker({
|
|
|
2332
2338
|
if (newRange.from) setLeftMonth(dateFns.startOfMonth(newRange.from));
|
|
2333
2339
|
setOpen(false);
|
|
2334
2340
|
};
|
|
2341
|
+
const handleApply = () => {
|
|
2342
|
+
if (draft.from && !draft.to) return;
|
|
2343
|
+
const newRange = draft.from && draft.to ? draft : void 0;
|
|
2344
|
+
if (onChange) onChange(newRange);
|
|
2345
|
+
else setInternalRange(newRange ?? { from: void 0, to: void 0 });
|
|
2346
|
+
setOpen(false);
|
|
2347
|
+
};
|
|
2348
|
+
const handleClear = () => {
|
|
2349
|
+
setDraft({ from: void 0, to: void 0 });
|
|
2350
|
+
setActivePreset(void 0);
|
|
2351
|
+
};
|
|
2352
|
+
const canClear = !!(draft.from || committedRange.from);
|
|
2353
|
+
const canApply = !(draft.from && !draft.to) && !!(draft.from || committedRange.from);
|
|
2335
2354
|
const rightMonth = dateFns.addMonths(leftMonth, 1);
|
|
2336
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange:
|
|
2355
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange: handleOpenChange, children: [
|
|
2337
2356
|
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2338
2357
|
"button",
|
|
2339
2358
|
{
|
|
@@ -2343,12 +2362,12 @@ function DateRangePicker({
|
|
|
2343
2362
|
"hover:bg-gray-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2",
|
|
2344
2363
|
"dark:border-neutral-600 dark:bg-neutral-800 dark:hover:bg-neutral-700",
|
|
2345
2364
|
"disabled:pointer-events-none disabled:opacity-50",
|
|
2346
|
-
|
|
2365
|
+
committedRange.from ? "text-gray-900 dark:text-gray-100" : "text-gray-400 dark:text-gray-500",
|
|
2347
2366
|
className
|
|
2348
2367
|
),
|
|
2349
2368
|
children: [
|
|
2350
2369
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarIcon, { className: "w-4 h-4 shrink-0 text-gray-400 dark:text-gray-500" }),
|
|
2351
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: formatDateRange(
|
|
2370
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: formatDateRange(committedRange, placeholder) })
|
|
2352
2371
|
]
|
|
2353
2372
|
}
|
|
2354
2373
|
) }),
|
|
@@ -2369,34 +2388,62 @@ function DateRangePicker({
|
|
|
2369
2388
|
preset.label
|
|
2370
2389
|
))
|
|
2371
2390
|
] }, section.title)) }),
|
|
2372
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex
|
|
2373
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2391
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
2392
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-4 p-4", children: [
|
|
2393
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2394
|
+
CalendarMonth,
|
|
2395
|
+
{
|
|
2396
|
+
month: leftMonth,
|
|
2397
|
+
range: draft,
|
|
2398
|
+
hoverDate,
|
|
2399
|
+
onDayClick: handleDayClick,
|
|
2400
|
+
onDayHover: setHoverDate,
|
|
2401
|
+
onPrevMonth: () => setLeftMonth(dateFns.subMonths(leftMonth, 1)),
|
|
2402
|
+
showPrevNav: true,
|
|
2403
|
+
showNextNav: false
|
|
2404
|
+
}
|
|
2405
|
+
),
|
|
2406
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-px bg-gray-100 dark:bg-neutral-700 self-stretch" }),
|
|
2407
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2408
|
+
CalendarMonth,
|
|
2409
|
+
{
|
|
2410
|
+
month: rightMonth,
|
|
2411
|
+
range: draft,
|
|
2412
|
+
hoverDate,
|
|
2413
|
+
onDayClick: handleDayClick,
|
|
2414
|
+
onDayHover: setHoverDate,
|
|
2415
|
+
onNextMonth: () => setLeftMonth(dateFns.addMonths(leftMonth, 1)),
|
|
2416
|
+
showPrevNav: false,
|
|
2417
|
+
showNextNav: true
|
|
2418
|
+
}
|
|
2419
|
+
)
|
|
2420
|
+
] }),
|
|
2421
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-2 px-4 py-3 border-t border-gray-100 dark:border-neutral-700", children: [
|
|
2422
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2423
|
+
"button",
|
|
2424
|
+
{
|
|
2425
|
+
onClick: handleClear,
|
|
2426
|
+
disabled: !canClear,
|
|
2427
|
+
className: chunk5XF7Y25B_js.cn(
|
|
2428
|
+
"px-3 py-1.5 rounded-md text-sm transition-colors",
|
|
2429
|
+
canClear ? "text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-neutral-700" : "text-gray-300 dark:text-gray-600 cursor-not-allowed"
|
|
2430
|
+
),
|
|
2431
|
+
children: "Clear"
|
|
2432
|
+
}
|
|
2433
|
+
),
|
|
2434
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2435
|
+
"button",
|
|
2436
|
+
{
|
|
2437
|
+
onClick: handleApply,
|
|
2438
|
+
disabled: !canApply,
|
|
2439
|
+
className: chunk5XF7Y25B_js.cn(
|
|
2440
|
+
"px-3 py-1.5 rounded-md text-sm font-medium transition-colors",
|
|
2441
|
+
canApply ? "bg-blue-600 text-white hover:bg-blue-700 dark:hover:bg-blue-500" : "bg-blue-100 text-blue-300 cursor-not-allowed dark:bg-blue-950/30 dark:text-blue-800"
|
|
2442
|
+
),
|
|
2443
|
+
children: "Apply"
|
|
2444
|
+
}
|
|
2445
|
+
)
|
|
2446
|
+
] })
|
|
2400
2447
|
] })
|
|
2401
2448
|
] }) })
|
|
2402
2449
|
] });
|
|
@@ -2579,5 +2626,5 @@ exports.useColumnVisibility = useColumnVisibility;
|
|
|
2579
2626
|
exports.useFormContext = useFormContext;
|
|
2580
2627
|
exports.useFormFieldContext = useFormFieldContext;
|
|
2581
2628
|
exports.useTableSelection = useTableSelection;
|
|
2582
|
-
//# sourceMappingURL=chunk-
|
|
2583
|
-
//# sourceMappingURL=chunk-
|
|
2629
|
+
//# sourceMappingURL=chunk-JP5BJYYD.js.map
|
|
2630
|
+
//# sourceMappingURL=chunk-JP5BJYYD.js.map
|