@itilite/lumina-ui 1.0.8-alpha → 1.0.10-alpha

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.
@@ -0,0 +1,62 @@
1
+ import * as React from 'react';
2
+
3
+ interface TimeValue {
4
+ hour: string;
5
+ minute: string;
6
+ period: "AM" | "PM";
7
+ }
8
+ interface DateRangeValue {
9
+ startDate: Date | null;
10
+ endDate: Date | null;
11
+ startTime: TimeValue;
12
+ endTime: TimeValue;
13
+ timezone: string;
14
+ activePreset?: string;
15
+ }
16
+ interface PresetOption {
17
+ label: string;
18
+ key: string;
19
+ getRange: () => (Date | null)[];
20
+ }
21
+ interface TimezoneOption {
22
+ label: string;
23
+ value: string;
24
+ }
25
+ interface DateRangePickerProps {
26
+ /** Controlled value for the date range */
27
+ value?: DateRangeValue;
28
+ /** Called when the user clicks "Done" */
29
+ onChange?: (value: DateRangeValue) => void;
30
+ /** Called on every selection change (live) */
31
+ onRangeChange?: (value: DateRangeValue) => void;
32
+ /** Label for the confirm button. Defaults to "Done" */
33
+ confirmLabel?: string;
34
+ /** Additional class name for the root wrapper */
35
+ className?: string;
36
+ /** Whether the picker is disabled */
37
+ disabled?: boolean;
38
+ /** Disable dates before today */
39
+ disablePastDates?: boolean;
40
+ /** Minimum selectable date (ISO string) */
41
+ minDate?: string | null;
42
+ /** Maximum selectable date (ISO string) */
43
+ maxDate?: string | null;
44
+ /** Show a single calendar instead of two */
45
+ showSingleCalendar?: boolean;
46
+ /** Id prefix for accessibility */
47
+ id?: string;
48
+ defaultTimezone?: string;
49
+ isTimezoneDisabled?: boolean;
50
+ timezoneOptions?: TimezoneOption[];
51
+ /** Initial active preset key. Defaults to "custom". e.g. "this-month", "yesterday" */
52
+ defaultPreset?: string;
53
+ /** Custom presets passed from parent */
54
+ presets?: PresetOption[];
55
+ }
56
+
57
+ declare function AdvancedDateRangePicker({ value, onChange, confirmLabel, className, disabled, disablePastDates, minDate, maxDate, showSingleCalendar, id, defaultTimezone, isTimezoneDisabled, timezoneOptions, defaultPreset, presets, }: DateRangePickerProps): React.JSX.Element;
58
+ declare namespace AdvancedDateRangePicker {
59
+ var displayName: string;
60
+ }
61
+
62
+ export { AdvancedDateRangePicker as A, type DateRangePickerProps as D, type PresetOption as P, type TimeValue as T, type DateRangeValue as a, type TimezoneOption as b };
@@ -0,0 +1,62 @@
1
+ import * as React from 'react';
2
+
3
+ interface TimeValue {
4
+ hour: string;
5
+ minute: string;
6
+ period: "AM" | "PM";
7
+ }
8
+ interface DateRangeValue {
9
+ startDate: Date | null;
10
+ endDate: Date | null;
11
+ startTime: TimeValue;
12
+ endTime: TimeValue;
13
+ timezone: string;
14
+ activePreset?: string;
15
+ }
16
+ interface PresetOption {
17
+ label: string;
18
+ key: string;
19
+ getRange: () => (Date | null)[];
20
+ }
21
+ interface TimezoneOption {
22
+ label: string;
23
+ value: string;
24
+ }
25
+ interface DateRangePickerProps {
26
+ /** Controlled value for the date range */
27
+ value?: DateRangeValue;
28
+ /** Called when the user clicks "Done" */
29
+ onChange?: (value: DateRangeValue) => void;
30
+ /** Called on every selection change (live) */
31
+ onRangeChange?: (value: DateRangeValue) => void;
32
+ /** Label for the confirm button. Defaults to "Done" */
33
+ confirmLabel?: string;
34
+ /** Additional class name for the root wrapper */
35
+ className?: string;
36
+ /** Whether the picker is disabled */
37
+ disabled?: boolean;
38
+ /** Disable dates before today */
39
+ disablePastDates?: boolean;
40
+ /** Minimum selectable date (ISO string) */
41
+ minDate?: string | null;
42
+ /** Maximum selectable date (ISO string) */
43
+ maxDate?: string | null;
44
+ /** Show a single calendar instead of two */
45
+ showSingleCalendar?: boolean;
46
+ /** Id prefix for accessibility */
47
+ id?: string;
48
+ defaultTimezone?: string;
49
+ isTimezoneDisabled?: boolean;
50
+ timezoneOptions?: TimezoneOption[];
51
+ /** Initial active preset key. Defaults to "custom". e.g. "this-month", "yesterday" */
52
+ defaultPreset?: string;
53
+ /** Custom presets passed from parent */
54
+ presets?: PresetOption[];
55
+ }
56
+
57
+ declare function AdvancedDateRangePicker({ value, onChange, confirmLabel, className, disabled, disablePastDates, minDate, maxDate, showSingleCalendar, id, defaultTimezone, isTimezoneDisabled, timezoneOptions, defaultPreset, presets, }: DateRangePickerProps): React.JSX.Element;
58
+ declare namespace AdvancedDateRangePicker {
59
+ var displayName: string;
60
+ }
61
+
62
+ export { AdvancedDateRangePicker as A, type DateRangePickerProps as D, type PresetOption as P, type TimeValue as T, type DateRangeValue as a, type TimezoneOption as b };
@@ -0,0 +1,60 @@
1
+ import * as React from 'react';
2
+
3
+ interface TimeValue {
4
+ hour: string;
5
+ minute: string;
6
+ period: "AM" | "PM";
7
+ }
8
+ interface DateRangeValue {
9
+ startDate: Date | null;
10
+ endDate: Date | null;
11
+ startTime: TimeValue;
12
+ endTime: TimeValue;
13
+ timezone: string;
14
+ activePreset?: string;
15
+ }
16
+ interface PresetOption {
17
+ label: string;
18
+ key: string;
19
+ getRange: () => (Date | null)[];
20
+ }
21
+ interface TimezoneOption {
22
+ label: string;
23
+ value: string;
24
+ }
25
+ interface DateRangePickerProps {
26
+ /** Controlled value for the date range */
27
+ value?: DateRangeValue;
28
+ /** Called when the user clicks "Done" */
29
+ onChange?: (value: DateRangeValue) => void;
30
+ /** Called on every selection change (live) */
31
+ onRangeChange?: (value: DateRangeValue) => void;
32
+ /** Label for the confirm button. Defaults to "Done" */
33
+ confirmLabel?: string;
34
+ /** Additional class name for the root wrapper */
35
+ className?: string;
36
+ /** Whether the picker is disabled */
37
+ disabled?: boolean;
38
+ /** Disable dates before today */
39
+ disablePastDates?: boolean;
40
+ /** Minimum selectable date (ISO string) */
41
+ minDate?: string | null;
42
+ /** Maximum selectable date (ISO string) */
43
+ maxDate?: string | null;
44
+ /** Show a single calendar instead of two */
45
+ showSingleCalendar?: boolean;
46
+ /** Id prefix for accessibility */
47
+ id?: string;
48
+ defaultTimezone?: string;
49
+ isTimezoneDisabled?: boolean;
50
+ timezoneOptions?: TimezoneOption[];
51
+ /** Initial active preset key. Defaults to "custom". e.g. "this-month", "yesterday" */
52
+ defaultPreset?: string;
53
+ }
54
+
55
+ declare function AdvancedDateRangePicker({ value, onChange, confirmLabel, className, disabled, disablePastDates, minDate, maxDate, showSingleCalendar, id, defaultTimezone, isTimezoneDisabled, timezoneOptions, defaultPreset, }: DateRangePickerProps): React.JSX.Element;
56
+ declare namespace AdvancedDateRangePicker {
57
+ var displayName: string;
58
+ }
59
+
60
+ export { AdvancedDateRangePicker as A, type DateRangePickerProps as D, type PresetOption as P, type TimeValue as T, type DateRangeValue as a, type TimezoneOption as b };
@@ -0,0 +1,60 @@
1
+ import * as React from 'react';
2
+
3
+ interface TimeValue {
4
+ hour: string;
5
+ minute: string;
6
+ period: "AM" | "PM";
7
+ }
8
+ interface DateRangeValue {
9
+ startDate: Date | null;
10
+ endDate: Date | null;
11
+ startTime: TimeValue;
12
+ endTime: TimeValue;
13
+ timezone: string;
14
+ activePreset?: string;
15
+ }
16
+ interface PresetOption {
17
+ label: string;
18
+ key: string;
19
+ getRange: () => (Date | null)[];
20
+ }
21
+ interface TimezoneOption {
22
+ label: string;
23
+ value: string;
24
+ }
25
+ interface DateRangePickerProps {
26
+ /** Controlled value for the date range */
27
+ value?: DateRangeValue;
28
+ /** Called when the user clicks "Done" */
29
+ onChange?: (value: DateRangeValue) => void;
30
+ /** Called on every selection change (live) */
31
+ onRangeChange?: (value: DateRangeValue) => void;
32
+ /** Label for the confirm button. Defaults to "Done" */
33
+ confirmLabel?: string;
34
+ /** Additional class name for the root wrapper */
35
+ className?: string;
36
+ /** Whether the picker is disabled */
37
+ disabled?: boolean;
38
+ /** Disable dates before today */
39
+ disablePastDates?: boolean;
40
+ /** Minimum selectable date (ISO string) */
41
+ minDate?: string | null;
42
+ /** Maximum selectable date (ISO string) */
43
+ maxDate?: string | null;
44
+ /** Show a single calendar instead of two */
45
+ showSingleCalendar?: boolean;
46
+ /** Id prefix for accessibility */
47
+ id?: string;
48
+ defaultTimezone?: string;
49
+ isTimezoneDisabled?: boolean;
50
+ timezoneOptions?: TimezoneOption[];
51
+ /** Initial active preset key. Defaults to "custom". e.g. "this-month", "yesterday" */
52
+ defaultPreset?: string;
53
+ }
54
+
55
+ declare function AdvancedDateRangePicker({ value, onChange, confirmLabel, className, disabled, disablePastDates, minDate, maxDate, showSingleCalendar, id, defaultTimezone, isTimezoneDisabled, timezoneOptions, defaultPreset, }: DateRangePickerProps): React.JSX.Element;
56
+ declare namespace AdvancedDateRangePicker {
57
+ var displayName: string;
58
+ }
59
+
60
+ export { AdvancedDateRangePicker as A, type DateRangePickerProps as D, type PresetOption as P, type TimeValue as T, type DateRangeValue as a, type TimezoneOption as b };
@@ -1,2 +1,2 @@
1
1
  import 'react';
2
- export { A as AdvancedDateRangePicker, A as default } from '../../AdvancedDateRangePicker-D7xn4So6.mjs';
2
+ export { A as AdvancedDateRangePicker, A as default } from '../../AdvancedDateRangePicker-DGg-rucL.mjs';
@@ -1,2 +1,2 @@
1
1
  import 'react';
2
- export { A as AdvancedDateRangePicker, A as default } from '../../AdvancedDateRangePicker-D7xn4So6.js';
2
+ export { A as AdvancedDateRangePicker, A as default } from '../../AdvancedDateRangePicker-DGg-rucL.js';
@@ -1391,10 +1391,11 @@ function AdvancedDateRangePicker({
1391
1391
  defaultTimezone = "UTC",
1392
1392
  isTimezoneDisabled = false,
1393
1393
  timezoneOptions = [],
1394
- defaultPreset = "custom"
1394
+ defaultPreset = "custom",
1395
+ presets
1395
1396
  }) {
1396
1397
  var _a, _b, _c;
1397
- const PRESETS = (0, import_react4.useMemo)(() => getPresets(), []);
1398
+ const PRESETS = (0, import_react4.useMemo)(() => presets || getPresets(), [presets]);
1398
1399
  const [startDate, setStartDate] = (0, import_react4.useState)((_a = value == null ? void 0 : value.startDate) != null ? _a : null);
1399
1400
  const [endDate, setEndDate] = (0, import_react4.useState)((_b = value == null ? void 0 : value.endDate) != null ? _b : null);
1400
1401
  const [timezone, setTimezone] = (0, import_react4.useState)((_c = value == null ? void 0 : value.timezone) != null ? _c : defaultTimezone);
@@ -1423,8 +1424,19 @@ function AdvancedDateRangePicker({
1423
1424
  setTimezone((_c2 = value.timezone) != null ? _c2 : defaultTimezone);
1424
1425
  if (value.startTime) setFromTimeStr(formatTime(value.startTime));
1425
1426
  if (value.endTime) setToTimeStr(formatTime(value.endTime));
1427
+ if (value.activePreset) {
1428
+ setActivePreset(value.activePreset);
1429
+ } else {
1430
+ const matchedPreset = PRESETS.find((p) => {
1431
+ if (p.key === "custom") return false;
1432
+ const [s, e] = p.getRange();
1433
+ if (!s || !e || !value.startDate || !value.endDate) return false;
1434
+ return (0, import_dayjs2.default)(s).isSame((0, import_dayjs2.default)(value.startDate), "day") && (0, import_dayjs2.default)(e).isSame((0, import_dayjs2.default)(value.endDate), "day");
1435
+ });
1436
+ setActivePreset(matchedPreset ? matchedPreset.key : "custom");
1437
+ }
1426
1438
  }
1427
- }, [value, defaultTimezone]);
1439
+ }, [value, defaultTimezone, PRESETS]);
1428
1440
  (0, import_react4.useEffect)(() => {
1429
1441
  setFromDateStr(formatForDisplay(startDate));
1430
1442
  }, [startDate]);
@@ -1511,9 +1523,10 @@ function AdvancedDateRangePicker({
1511
1523
  endDate,
1512
1524
  startTime: fromTime,
1513
1525
  endTime: toTime,
1514
- timezone
1526
+ timezone,
1527
+ activePreset
1515
1528
  });
1516
- }, [isReady, onChange, startDate, endDate, fromTimeStr, toTimeStr, timezone]);
1529
+ }, [isReady, onChange, startDate, endDate, fromTimeStr, toTimeStr, timezone, activePreset]);
1517
1530
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: (0, import_clsx3.default)(AdvancedDateRangePicker_module_default.root, className, { [AdvancedDateRangePicker_module_default.singleCalendar]: isSingle }), id, children: [
1518
1531
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: AdvancedDateRangePicker_module_default.inner, children: [
1519
1532
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("aside", { className: AdvancedDateRangePicker_module_default.left, children: PRESETS.map((p) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  AdvancedDateRangePicker,
3
3
  AdvancedDateRangePicker_default
4
- } from "../../chunk-UC4NTBDH.mjs";
4
+ } from "../../chunk-GGWY2SYX.mjs";
5
5
  import "../../chunk-GU5F7Z7I.mjs";
6
6
  import "../../chunk-MLCMZRUC.mjs";
7
7
  import "../../chunk-FPH63V2R.mjs";