@cognite/aura 0.3.3 → 0.3.5

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.
Files changed (54) hide show
  1. package/README.md +27 -0
  2. package/dist/components/index.d.ts +3 -1
  3. package/dist/components/index.js +31 -30
  4. package/dist/components/ui/core/{date-time-pickers/shared/calendar-header → calendar}/calendar-header.js +4 -4
  5. package/dist/components/ui/core/{date-time-pickers/shared/calendar → calendar}/calendar.js +13 -13
  6. package/dist/components/ui/core/calendar/constants.d.ts +1 -0
  7. package/dist/components/ui/core/data-grid/data-grid-cell.d.ts +10 -0
  8. package/dist/components/ui/core/data-grid/data-grid-cell.js +23 -0
  9. package/dist/components/ui/core/data-grid/data-grid-header-row.d.ts +13 -0
  10. package/dist/components/ui/core/data-grid/data-grid-header-row.js +56 -0
  11. package/dist/components/ui/core/data-grid/data-grid-row.d.ts +18 -0
  12. package/dist/components/ui/core/data-grid/data-grid-row.js +77 -0
  13. package/dist/components/ui/core/data-grid/data-grid.d.ts +43 -0
  14. package/dist/components/ui/core/data-grid/data-grid.fixtures.d.ts +12 -0
  15. package/dist/components/ui/core/data-grid/data-grid.js +134 -0
  16. package/dist/components/ui/core/data-grid/data-grid.utils.d.ts +9 -0
  17. package/dist/components/ui/core/data-grid/data-grid.utils.js +40 -0
  18. package/dist/components/ui/core/data-grid/index.d.ts +1 -0
  19. package/dist/components/ui/core/data-grid/index.js +2 -0
  20. package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.js +1 -1
  21. package/dist/components/ui/core/date-time-pickers/date-picker/types.d.ts +2 -1
  22. package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.js +1 -1
  23. package/dist/components/ui/core/date-time-pickers/date-range-picker/types.d.ts +2 -1
  24. package/dist/components/ui/core/date-time-pickers/date-time-picker/index.d.ts +1 -0
  25. package/dist/components/ui/core/date-time-pickers/date-time-picker/types.d.ts +36 -0
  26. package/dist/components/ui/core/date-time-pickers/date-time-picker/use-date-time-picker.d.ts +3 -0
  27. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.js +1 -1
  28. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/types.d.ts +7 -6
  29. package/dist/components/ui/core/date-time-pickers/index.d.ts +3 -1
  30. package/dist/components/ui/core/date-time-pickers/index.js +6 -5
  31. package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.d.ts +3 -2
  32. package/dist/components/ui/core/date-time-pickers/shared/constants.d.ts +3 -8
  33. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.d.ts +3 -3
  34. package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.d.ts +3 -2
  35. package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.d.ts +3 -2
  36. package/dist/components/ui/core/date-time-pickers/time-picker/types.d.ts +5 -4
  37. package/dist/components/ui/core/date-time-pickers/time-range-picker/index.d.ts +1 -0
  38. package/dist/components/ui/core/date-time-pickers/time-range-picker/types.d.ts +40 -0
  39. package/dist/components/ui/core/date-time-pickers/time-range-picker/use-time-range-picker.d.ts +3 -0
  40. package/dist/components/ui/core/date-time-pickers/utils/format-utils.d.ts +1 -0
  41. package/dist/components/ui/core/date-time-pickers/utils/time-utils.d.ts +3 -3
  42. package/dist/components/ui/core/overflow-list/overflow-list.utils.d.ts +52 -0
  43. package/dist/components/ui/core/segmented-control/segmented-control.d.ts +12 -6
  44. package/dist/components/ui/core/segmented-control/segmented-control.js +74 -32
  45. package/dist/components/ui/core/slider/slider.d.ts +9 -0
  46. package/dist/components/ui/core/slider/slider.js +40 -0
  47. package/dist/index.d.ts +1 -1
  48. package/dist/styles.css +1 -1
  49. package/dist/styles.source.css +3 -0
  50. package/package.json +24 -2
  51. /package/dist/components/ui/core/{date-time-pickers/shared/calendar-header → calendar}/calendar-header.d.ts +0 -0
  52. /package/dist/components/ui/core/{date-time-pickers/utils → calendar}/calendar-utils.d.ts +0 -0
  53. /package/dist/components/ui/core/{date-time-pickers/utils → calendar}/calendar-utils.js +0 -0
  54. /package/dist/components/ui/core/{date-time-pickers/shared/calendar → calendar}/calendar.d.ts +0 -0
@@ -0,0 +1,134 @@
1
+ import { cn as e } from "../../../../lib/utils.js";
2
+ import { useControllableState as t } from "../../../../lib/use-controllable-state.js";
3
+ import { collectCustomCellColumnIds as n } from "./data-grid.utils.js";
4
+ import { DataGridHeaderRow as r } from "./data-grid-header-row.js";
5
+ import { DataGridRow as i } from "./data-grid-row.js";
6
+ import { useEffect as a, useImperativeHandle as o, useMemo as s, useRef as c } from "react";
7
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
8
+ import { getCoreRowModel as ee, getExpandedRowModel as te, getFilteredRowModel as ne, getSortedRowModel as re, useReactTable as ie } from "@tanstack/react-table";
9
+ import { useVirtualizer as ae } from "@tanstack/react-virtual";
10
+ //#region libs/aura/src/components/ui/core/data-grid/data-grid.tsx
11
+ var oe = [], d = 120, f = {
12
+ default: 36,
13
+ compact: 32
14
+ }, p = {
15
+ default: 36,
16
+ compact: 32
17
+ };
18
+ function m({ data: m, columns: h, getRowId: se, rowCount: g, globalFilterFn: _ = "auto", enableSorting: v = !1, manualSorting: y = !1, sorting: ce, defaultSorting: le, onSortingChange: ue, getSubRows: b, expanded: de, defaultExpanded: x, onExpandedChange: S, getRowCanExpand: C, maxDepth: w = 5, pinnedColumns: T = oe, gridRef: E, size: D = "default", children: O, className: k, onRowClick: A, rowHeight: j, headerHeight: M, "aria-label": N, "aria-labelledby": P }) {
19
+ let F = c(null), [fe, I] = t({
20
+ prop: ce,
21
+ defaultProp: le ?? [],
22
+ onChange: ue
23
+ }), L = b !== void 0, [R, z] = t({
24
+ prop: de,
25
+ defaultProp: x ?? {},
26
+ onChange: S
27
+ }), B = v && !y, V = s(() => ({
28
+ left: T,
29
+ right: []
30
+ }), [T]), H = s(() => new Set(T), [T]), U = T[T.length - 1], pe = s(() => n(h), [h]), W = ie({
31
+ data: m,
32
+ columns: h,
33
+ state: {
34
+ columnPinning: V,
35
+ sorting: fe,
36
+ ...L ? { expanded: R } : {}
37
+ },
38
+ onSortingChange: I,
39
+ ...L ? { onExpandedChange: z } : {},
40
+ autoResetExpanded: !1,
41
+ enableSorting: v,
42
+ manualSorting: y,
43
+ getCoreRowModel: ee(),
44
+ getFilteredRowModel: ne(),
45
+ globalFilterFn: _,
46
+ ...B ? { getSortedRowModel: re() } : {},
47
+ ...L ? { getExpandedRowModel: te() } : {},
48
+ getRowId: se,
49
+ getSubRows: b,
50
+ getRowCanExpand: C
51
+ }), { rows: G } = W.getRowModel(), K = W.getHeaderGroups(), q = W.getAllColumns(), J = W.getVisibleFlatColumns(), Y = j ?? f[D], me = M ?? p[D], X = m.length === 0, Z = ae({
52
+ count: G.length,
53
+ getScrollElement: () => F.current,
54
+ estimateSize: () => Y,
55
+ overscan: 10
56
+ }), he = {
57
+ "--data-grid-body-height": `${Z.getTotalSize()}px`,
58
+ "--data-grid-body-min-height": `${Y * 4}px`
59
+ };
60
+ o(E, () => ({
61
+ scrollToRow: (e) => Z.scrollToIndex(e),
62
+ resetSorting: () => I([])
63
+ })), a(() => {
64
+ for (let e of T) {
65
+ let t = q.find((t) => t.id === e);
66
+ t && t.columnDef.size === void 0 && console.warn(`[Aura DataGrid] Pinned column "${e}" has no \`size\` set. Pinned columns must declare an explicit \`size\` to keep the sticky offset aligned with the rendered column width.`);
67
+ }
68
+ }, [T, q]);
69
+ let Q = s(() => {
70
+ let e = J.some((e) => e.columnDef.size === void 0 && !H.has(e.id));
71
+ return J.map((t, n) => {
72
+ let r = t.columnDef.size, i = n === J.length - 1;
73
+ return H.has(t.id) ? `${r ?? d}px` : r === void 0 ? `minmax(${d}px, 1fr)` : !e && i ? `minmax(${r}px, 1fr)` : `${r}px`;
74
+ }).join(" ");
75
+ }, [J, H]), $ = s(() => {
76
+ let e = /* @__PURE__ */ new Map(), t = 0;
77
+ for (let n of T) {
78
+ let r = J.find((e) => e.id === n);
79
+ r && (e.set(n, t), t += r.columnDef.size ?? d);
80
+ }
81
+ return e;
82
+ }, [J, T]);
83
+ return /* @__PURE__ */ u("div", {
84
+ "data-slot": "data-grid",
85
+ className: e("relative flex h-full min-h-0 w-full flex-col overflow-clip rounded-xl bg-default text-sm", k),
86
+ children: [O, /* @__PURE__ */ l("div", {
87
+ ref: F,
88
+ "data-slot": "data-grid-scroll-container",
89
+ className: "relative order-2 h-full min-h-0 w-full flex-1 overflow-auto",
90
+ role: "table",
91
+ "aria-rowcount": (g ?? G.length) + K.length,
92
+ "aria-colcount": J.length,
93
+ "aria-label": N,
94
+ "aria-labelledby": P,
95
+ children: /* @__PURE__ */ u("div", {
96
+ className: "min-w-fit w-full",
97
+ children: [/* @__PURE__ */ l("div", {
98
+ role: "rowgroup",
99
+ "data-slot": "data-grid-header-group",
100
+ className: "contents",
101
+ children: K.map((e, t) => /* @__PURE__ */ l(r, {
102
+ headerGroup: e,
103
+ headerRowIndex: t,
104
+ resolvedHeaderHeight: me,
105
+ gridTemplateColumns: Q,
106
+ pinnedColumnIds: H,
107
+ lastPinnedColumnId: U,
108
+ pinnedLeftByColumnId: $
109
+ }, e.id))
110
+ }), /* @__PURE__ */ l("div", {
111
+ role: "rowgroup",
112
+ "data-slot": "data-grid-body",
113
+ className: e("relative min-h-(--data-grid-body-min-height)", !X && "h-(--data-grid-body-height)"),
114
+ style: he,
115
+ children: !X && Z.getVirtualItems().map((e) => /* @__PURE__ */ l(i, {
116
+ row: G[e.index],
117
+ virtualRow: e,
118
+ headerGroupCount: K.length,
119
+ gridTemplateColumns: Q,
120
+ pinnedColumnIds: H,
121
+ lastPinnedColumnId: U,
122
+ pinnedLeftByColumnId: $,
123
+ customCellColumnIds: pe,
124
+ maxDepth: w,
125
+ hasExpanding: L,
126
+ onRowClick: A
127
+ }, G[e.index].id))
128
+ })]
129
+ })
130
+ })]
131
+ });
132
+ }
133
+ //#endregion
134
+ export { m as DataGrid };
@@ -0,0 +1,9 @@
1
+ import { ColumnDef } from '@tanstack/react-table';
2
+ declare const PINNED_COLUMN_Z_INDEX = 10;
3
+ declare function getAriaSort(sortDirection: false | 'asc' | 'desc', canSort: boolean): 'ascending' | 'descending' | 'none' | undefined;
4
+ declare function getTextValue(value: unknown): string | undefined;
5
+ declare function isAccessorColumn<TData>(def: ColumnDef<TData>): boolean;
6
+ declare function isFromIgnoredCellTarget(target?: EventTarget | null): boolean;
7
+ declare function isFromExpandToggleTarget(target?: EventTarget | null): boolean;
8
+ declare function collectCustomCellColumnIds<TData>(columns: ColumnDef<TData>[]): Set<string>;
9
+ export { PINNED_COLUMN_Z_INDEX, collectCustomCellColumnIds, getAriaSort, getTextValue, isAccessorColumn, isFromExpandToggleTarget, isFromIgnoredCellTarget, };
@@ -0,0 +1,40 @@
1
+ //#region libs/aura/src/components/ui/core/data-grid/data-grid.utils.ts
2
+ function e(e, t) {
3
+ return e === "asc" ? "ascending" : e === "desc" ? "descending" : t ? "none" : void 0;
4
+ }
5
+ function t(e) {
6
+ if (typeof e == "string" || typeof e == "number") return String(e);
7
+ }
8
+ function n(e) {
9
+ let t = "accessorKey" in e && e.accessorKey !== void 0, n = "accessorFn" in e && e.accessorFn !== void 0;
10
+ return t || n;
11
+ }
12
+ function r(e) {
13
+ return e instanceof Element && !!e.closest("[data-row-activation=\"ignore\"]");
14
+ }
15
+ function i(e) {
16
+ return e instanceof Element && !!e.closest("[data-row-expand-toggle=\"true\"]");
17
+ }
18
+ function a(e) {
19
+ let t = /* @__PURE__ */ new Set(), n = (e) => {
20
+ for (let r of e) {
21
+ if (o(r)) {
22
+ n(r.columns);
23
+ continue;
24
+ }
25
+ if (Object.prototype.hasOwnProperty.call(r, "cell")) {
26
+ if ("id" in r && typeof r.id == "string") {
27
+ t.add(r.id);
28
+ continue;
29
+ }
30
+ "accessorKey" in r && typeof r.accessorKey == "string" && t.add(r.accessorKey);
31
+ }
32
+ }
33
+ };
34
+ return n(e), t;
35
+ }
36
+ function o(e) {
37
+ return "columns" in e && Array.isArray(e.columns);
38
+ }
39
+ //#endregion
40
+ export { a as collectCustomCellColumnIds, e as getAriaSort, t as getTextValue, n as isAccessorColumn, i as isFromExpandToggleTarget, r as isFromIgnoredCellTarget };
@@ -0,0 +1 @@
1
+ export { DataGrid, type DataGridHandle } from './data-grid';
@@ -0,0 +1,2 @@
1
+ import { DataGrid as e } from "./data-grid.js";
2
+ export { e as DataGrid };
@@ -1,6 +1,6 @@
1
1
  import { cn as e } from "../../../../../lib/utils.js";
2
2
  import { Popover as t, PopoverContent as n, PopoverTrigger as r } from "../../popover/popover.js";
3
- import { Calendar as i } from "../shared/calendar/calendar.js";
3
+ import { Calendar as i } from "../../calendar/calendar.js";
4
4
  import { DateTimeInput as a } from "../shared/date-time-input/date-time-input.js";
5
5
  import { ShortcutsPanel as o } from "../shared/shortcuts-panel/shortcuts-panel.js";
6
6
  import { useDatePicker as s } from "./use-date-picker.js";
@@ -1,4 +1,5 @@
1
1
  import { Dayjs } from 'dayjs';
2
+ import { ShortcutValueDayjs } from '../shared/shortcuts-panel/shortcuts-panel';
2
3
  export interface UseDatePickerProps {
3
4
  value: Dayjs | null;
4
5
  onChange: (date: Dayjs | null) => void;
@@ -11,7 +12,7 @@ export interface UseDatePickerReturn {
11
12
  handleOpenChange: (open: boolean) => void;
12
13
  handleDateClick: (date: Dayjs) => void;
13
14
  handleMonthChange: (month: Dayjs) => void;
14
- handleApplyShortcut: (shortcutValue: Dayjs | [Dayjs, Dayjs] | [Dayjs | null, Dayjs | null]) => void;
15
+ handleApplyShortcut: (shortcutValue: ShortcutValueDayjs) => void;
15
16
  inputRef: React.RefObject<HTMLDivElement>;
16
17
  popoverRef: React.RefObject<HTMLDivElement>;
17
18
  }
@@ -1,6 +1,6 @@
1
1
  import { cn as e } from "../../../../../lib/utils.js";
2
2
  import { Popover as t, PopoverContent as n, PopoverTrigger as r } from "../../popover/popover.js";
3
- import { Calendar as i } from "../shared/calendar/calendar.js";
3
+ import { Calendar as i } from "../../calendar/calendar.js";
4
4
  import { DateTimeInput as a } from "../shared/date-time-input/date-time-input.js";
5
5
  import { ShortcutsPanel as o } from "../shared/shortcuts-panel/shortcuts-panel.js";
6
6
  import { useDateRangePicker as s } from "./use-date-range-picker.js";
@@ -1,5 +1,6 @@
1
1
  import { Dayjs } from 'dayjs';
2
2
  import { RangeSelectionStep } from '../shared/hooks/use-range-step-manager';
3
+ import { ShortcutValueDayjs } from '../shared/shortcuts-panel/shortcuts-panel';
3
4
  export type { RangeSelectionStep };
4
5
  export interface UseDateRangePickerProps {
5
6
  value: [Dayjs | null, Dayjs | null];
@@ -18,7 +19,7 @@ export interface UseDateRangePickerReturn {
18
19
  handleMonthChange: (month: Dayjs) => void;
19
20
  handleDateHover: (date: Dayjs | null) => void;
20
21
  handleSetStep: (step: RangeSelectionStep) => void;
21
- handleApplyShortcut: (range: Dayjs | [Dayjs, Dayjs] | [Dayjs | null, Dayjs | null]) => void;
22
+ handleApplyShortcut: (range: ShortcutValueDayjs) => void;
22
23
  inputRef: React.RefObject<HTMLDivElement>;
23
24
  popoverRef: React.RefObject<HTMLDivElement>;
24
25
  }
@@ -0,0 +1 @@
1
+ export type { DateTimePickerProps, UseDateTimePickerProps, UseDateTimePickerReturn, } from './types';
@@ -0,0 +1,36 @@
1
+ import { Dayjs } from 'dayjs';
2
+ import { ShortcutItem, ShortcutValueDayjs } from '../shared/shortcuts-panel/shortcuts-panel';
3
+ import { AmPm, TimeFormat } from '../utils/format-utils';
4
+ export interface UseDateTimePickerProps {
5
+ value: Dayjs | null;
6
+ onChange: (datetime: Dayjs | null) => void;
7
+ timeFormat?: TimeFormat;
8
+ defaultDate?: Dayjs;
9
+ }
10
+ export interface UseDateTimePickerReturn {
11
+ isOpen: boolean;
12
+ displayedMonth: Dayjs;
13
+ tempDate: Dayjs | null;
14
+ hour: number;
15
+ minute: number;
16
+ amPm: AmPm;
17
+ displayValue: Dayjs | null;
18
+ canApply: boolean;
19
+ handleOpenChange: (open: boolean) => void;
20
+ handleApply: () => void;
21
+ handleDateClick: (date: Dayjs) => void;
22
+ handleMonthChange: (month: Dayjs) => void;
23
+ handleHourChange: (hour: number) => void;
24
+ handleMinuteChange: (minute: number) => void;
25
+ handleAmPmChange: (amPm: AmPm) => void;
26
+ handleApplyShortcut: (shortcutValue: ShortcutValueDayjs) => void;
27
+ inputRef: React.RefObject<HTMLDivElement>;
28
+ popoverRef: React.RefObject<HTMLDivElement>;
29
+ }
30
+ export interface DateTimePickerProps extends UseDateTimePickerProps {
31
+ format?: string;
32
+ placeholder?: string;
33
+ displayWeekNumber?: boolean;
34
+ shortcuts?: ShortcutItem[];
35
+ className?: string;
36
+ }
@@ -0,0 +1,3 @@
1
+ import { UseDateTimePickerProps, UseDateTimePickerReturn } from './types';
2
+ export type { UseDateTimePickerProps, UseDateTimePickerReturn };
3
+ export declare const useDateTimePicker: ({ value, onChange, timeFormat, defaultDate, }: UseDateTimePickerProps) => UseDateTimePickerReturn;
@@ -1,7 +1,7 @@
1
1
  import { cn as e } from "../../../../../lib/utils.js";
2
2
  import { Button as t } from "../../button/button.js";
3
3
  import { Popover as ee, PopoverContent as te, PopoverTrigger as n } from "../../popover/popover.js";
4
- import { Calendar as r } from "../shared/calendar/calendar.js";
4
+ import { Calendar as r } from "../../calendar/calendar.js";
5
5
  import { DateTimeInput as i } from "../shared/date-time-input/date-time-input.js";
6
6
  import { ShortcutsPanel as a } from "../shared/shortcuts-panel/shortcuts-panel.js";
7
7
  import { convert12HourTo24Hour as o } from "../utils/time-utils.js";
@@ -1,6 +1,7 @@
1
1
  import { Dayjs } from 'dayjs';
2
2
  import { RangeSelectionStep } from '../shared/hooks/use-range-step-manager';
3
- import { TimeFormat } from '../utils/format-utils';
3
+ import { ShortcutValueDayjs } from '../shared/shortcuts-panel/shortcuts-panel';
4
+ import { AmPm, TimeFormat } from '../utils/format-utils';
4
5
  export type { RangeSelectionStep };
5
6
  export interface UseDateTimeRangePickerProps {
6
7
  value: [Dayjs | null, Dayjs | null];
@@ -19,8 +20,8 @@ export interface UseDateTimeRangePickerReturn {
19
20
  tempStartMinute: number;
20
21
  tempEndHour: number;
21
22
  tempEndMinute: number;
22
- startAmPm: 'AM' | 'PM';
23
- endAmPm: 'AM' | 'PM';
23
+ startAmPm: AmPm;
24
+ endAmPm: AmPm;
24
25
  handleOpenChange: (open: boolean) => void;
25
26
  handleSetStep: (step: RangeSelectionStep) => void;
26
27
  handleDateClick: (date: Dayjs) => void;
@@ -30,12 +31,12 @@ export interface UseDateTimeRangePickerReturn {
30
31
  handleStartMinuteChange: (minute: number) => void;
31
32
  handleEndHourChange: (hour: number) => void;
32
33
  handleEndMinuteChange: (minute: number) => void;
33
- handleStartAmPmChange: (value: 'AM' | 'PM') => void;
34
- handleEndAmPmChange: (value: 'AM' | 'PM') => void;
34
+ handleStartAmPmChange: (value: AmPm) => void;
35
+ handleEndAmPmChange: (value: AmPm) => void;
35
36
  handleNext: () => void;
36
37
  handleApply: () => void;
37
38
  handleBack: () => void;
38
- handleApplyShortcut: (range: Dayjs | [Dayjs, Dayjs] | [Dayjs | null, Dayjs | null]) => void;
39
+ handleApplyShortcut: (range: ShortcutValueDayjs) => void;
39
40
  popoverRef: React.RefObject<HTMLDivElement>;
40
41
  inputRef: React.RefObject<HTMLDivElement>;
41
42
  }
@@ -7,4 +7,6 @@ export type { DateRangePickerProps } from './date-range-picker';
7
7
  export { DateTimeRangePicker } from './date-time-range-picker';
8
8
  export type { DateTimeRangePickerProps } from './date-time-range-picker';
9
9
  export type { ShortcutItem } from './date-time-range-picker';
10
- export type { TimeFormat } from './utils/format-utils';
10
+ export type { AmPm, TimeFormat } from './utils/format-utils';
11
+ export { Calendar } from '../calendar/calendar';
12
+ export type { CalendarProps } from '../calendar/calendar';
@@ -1,5 +1,6 @@
1
- import { DatePicker as e } from "./date-picker/date-picker.js";
2
- import { TimePicker as t } from "./time-picker/time-picker.js";
3
- import { DateRangePicker as n } from "./date-range-picker/date-range-picker.js";
4
- import { DateTimeRangePicker as r } from "./date-time-range-picker/date-time-range-picker.js";
5
- export { e as DatePicker, n as DateRangePicker, r as DateTimeRangePicker, t as TimePicker };
1
+ import { Calendar as e } from "../calendar/calendar.js";
2
+ import { DatePicker as t } from "./date-picker/date-picker.js";
3
+ import { TimePicker as n } from "./time-picker/time-picker.js";
4
+ import { DateRangePicker as r } from "./date-range-picker/date-range-picker.js";
5
+ import { DateTimeRangePicker as i } from "./date-time-range-picker/date-time-range-picker.js";
6
+ export { e as Calendar, t as DatePicker, r as DateRangePicker, i as DateTimeRangePicker, n as TimePicker };
@@ -1,7 +1,8 @@
1
1
  import { FC } from 'react';
2
+ import { AmPm } from '../../utils/format-utils';
2
3
  export type AmPmScrollProps = {
3
- value: 'AM' | 'PM' | null;
4
- onChange: (value: 'AM' | 'PM') => void;
4
+ value: AmPm | null;
5
+ onChange: (value: AmPm) => void;
5
6
  className?: string;
6
7
  };
7
8
  export declare const AmPmScroll: FC<AmPmScrollProps>;
@@ -1,20 +1,15 @@
1
- /**
2
- * Shared numeric constants for date/time picker components.
3
- * Colors and typography are applied via Tailwind utility classes — no CSS
4
- * variable strings are exported from here.
5
- */
1
+ import { AmPm } from '../utils/format-utils';
6
2
  export declare const HOURS_IN_DAY = 24;
7
3
  export declare const HOURS_IN_12H = 12;
8
4
  export declare const MINUTES_IN_HOUR = 60;
9
5
  export declare const MINUTE_INCREMENT = 1;
10
- export declare const DAYS_IN_WEEK = 7;
11
6
  export declare const DEFAULT_START_HOUR = 9;
12
7
  export declare const DEFAULT_END_HOUR = 17;
13
8
  export declare const DEFAULT_MINUTE = 0;
14
9
  export declare const START_OF_DAY_HOUR = 0;
15
10
  export declare const END_OF_DAY_HOUR = 23;
16
11
  export declare const END_OF_DAY_MINUTE = 59;
17
- export declare const DEFAULT_START_AMPM: 'AM' | 'PM';
18
- export declare const DEFAULT_END_AMPM: 'AM' | 'PM';
12
+ export declare const DEFAULT_START_AMPM: AmPm;
13
+ export declare const DEFAULT_END_AMPM: AmPm;
19
14
  export declare const NOON_HOUR = 12;
20
15
  export declare const MIDNIGHT_HOUR = 0;
@@ -1,4 +1,4 @@
1
- import { TimeFormat } from '../../utils/format-utils';
1
+ import { AmPm, TimeFormat } from '../../utils/format-utils';
2
2
  export interface UseTimeStateOptions {
3
3
  initialHour?: number;
4
4
  initialMinute?: number;
@@ -7,11 +7,11 @@ export interface UseTimeStateOptions {
7
7
  export interface UseTimeStateReturn {
8
8
  hour: number;
9
9
  minute: number;
10
- amPm: 'AM' | 'PM';
10
+ amPm: AmPm;
11
11
  hour24: number;
12
12
  handleHourChange: (hour: number) => void;
13
13
  handleMinuteChange: (minute: number) => void;
14
- handleAmPmChange: (amPm: 'AM' | 'PM') => void;
14
+ handleAmPmChange: (amPm: AmPm) => void;
15
15
  resetTime: (hour: number, minute: number) => void;
16
16
  }
17
17
  export declare const useTimeState: ({ initialHour, initialMinute, timeFormat, }?: UseTimeStateOptions) => UseTimeStateReturn;
@@ -1,13 +1,14 @@
1
1
  import { FC } from 'react';
2
2
  import { Dayjs } from 'dayjs';
3
+ export type ShortcutValueDayjs = Dayjs | [Dayjs | null, Dayjs | null];
3
4
  export interface ShortcutItem {
4
5
  id?: string;
5
6
  label: string;
6
- getValue: () => [Dayjs, Dayjs] | Dayjs | [Dayjs | null, Dayjs | null];
7
+ getValue: () => ShortcutValueDayjs;
7
8
  }
8
9
  export interface ShortcutsPanelProps {
9
10
  shortcuts?: ShortcutItem[];
10
- onShortcutClick: (value: [Dayjs, Dayjs] | Dayjs | [Dayjs | null, Dayjs | null]) => void;
11
+ onShortcutClick: (value: ShortcutValueDayjs) => void;
11
12
  className?: string;
12
13
  }
13
14
  export declare const ShortcutsPanel: FC<ShortcutsPanelProps>;
@@ -1,4 +1,5 @@
1
1
  import { FC } from 'react';
2
+ import { AmPm } from '../../utils/format-utils';
2
3
  type TimePickerPanelBaseProps = {
3
4
  hour: number;
4
5
  minute: number;
@@ -8,8 +9,8 @@ type TimePickerPanelBaseProps = {
8
9
  };
9
10
  export type TimePickerPanelProps = TimePickerPanelBaseProps & ({
10
11
  timeFormat: '12h';
11
- amPm: 'AM' | 'PM';
12
- onAmPmChange: (amPm: 'AM' | 'PM') => void;
12
+ amPm: AmPm;
13
+ onAmPmChange: (amPm: AmPm) => void;
13
14
  } | {
14
15
  timeFormat?: '24h';
15
16
  amPm?: undefined;
@@ -1,5 +1,6 @@
1
1
  import { Dayjs } from 'dayjs';
2
- import { TimeFormat } from '../utils/format-utils';
2
+ import { ShortcutValueDayjs } from '../shared/shortcuts-panel/shortcuts-panel';
3
+ import { AmPm, TimeFormat } from '../utils/format-utils';
3
4
  export interface UseTimePickerProps {
4
5
  value: Dayjs | null;
5
6
  onChange: (time: Dayjs | null) => void;
@@ -10,14 +11,14 @@ export interface UseTimePickerReturn {
10
11
  isOpen: boolean;
11
12
  hour: number;
12
13
  minute: number;
13
- amPm: 'AM' | 'PM';
14
+ amPm: AmPm;
14
15
  displayValue: Dayjs | null;
15
16
  handleOpenChange: (open: boolean) => void;
16
17
  handleApply: () => void;
17
18
  handleHourChange: (hour: number) => void;
18
19
  handleMinuteChange: (minute: number) => void;
19
- handleAmPmChange: (amPm: 'AM' | 'PM') => void;
20
- handleApplyShortcut: (shortcutValue: Dayjs | [Dayjs, Dayjs] | [Dayjs | null, Dayjs | null]) => void;
20
+ handleAmPmChange: (amPm: AmPm) => void;
21
+ handleApplyShortcut: (shortcutValue: ShortcutValueDayjs) => void;
21
22
  inputRef: React.RefObject<HTMLDivElement>;
22
23
  popoverRef: React.RefObject<HTMLDivElement>;
23
24
  }
@@ -0,0 +1 @@
1
+ export type { TimeRangePickerProps, UseTimeRangePickerProps, UseTimeRangePickerReturn, } from './types';
@@ -0,0 +1,40 @@
1
+ import { Dayjs } from 'dayjs';
2
+ import { RangeSelectionStep } from '../shared/hooks/use-range-step-manager';
3
+ import { ShortcutItem, ShortcutValueDayjs } from '../shared/shortcuts-panel/shortcuts-panel';
4
+ import { AmPm, TimeFormat } from '../utils/format-utils';
5
+ export interface UseTimeRangePickerProps {
6
+ value: [Dayjs | null, Dayjs | null];
7
+ onChange: (range: [Dayjs | null, Dayjs | null]) => void;
8
+ timeFormat?: TimeFormat;
9
+ defaultDate?: Dayjs;
10
+ }
11
+ export interface UseTimeRangePickerReturn {
12
+ isOpen: boolean;
13
+ step: RangeSelectionStep;
14
+ tempStartHour: number;
15
+ tempStartMinute: number;
16
+ tempEndHour: number;
17
+ tempEndMinute: number;
18
+ startAmPm: AmPm;
19
+ endAmPm: AmPm;
20
+ displayValue: [Dayjs | null, Dayjs | null];
21
+ handleOpenChange: (open: boolean) => void;
22
+ handleSetStep: (step: RangeSelectionStep) => void;
23
+ handleStartHourChange: (hour: number) => void;
24
+ handleStartMinuteChange: (minute: number) => void;
25
+ handleEndHourChange: (hour: number) => void;
26
+ handleEndMinuteChange: (minute: number) => void;
27
+ handleStartAmPmChange: (amPm: AmPm) => void;
28
+ handleEndAmPmChange: (amPm: AmPm) => void;
29
+ handleNext: () => void;
30
+ handleApply: () => void;
31
+ handleApplyShortcut: (shortcutValue: ShortcutValueDayjs) => void;
32
+ inputRef: React.RefObject<HTMLDivElement>;
33
+ popoverRef: React.RefObject<HTMLDivElement>;
34
+ }
35
+ export interface TimeRangePickerProps extends UseTimeRangePickerProps {
36
+ format?: string;
37
+ placeholder?: string;
38
+ shortcuts?: ShortcutItem[];
39
+ className?: string;
40
+ }
@@ -0,0 +1,3 @@
1
+ import { UseTimeRangePickerProps, UseTimeRangePickerReturn } from './types';
2
+ export type { UseTimeRangePickerProps, UseTimeRangePickerReturn };
3
+ export declare const useTimeRangePicker: ({ value, onChange, timeFormat, defaultDate, }: UseTimeRangePickerProps) => UseTimeRangePickerReturn;
@@ -1,5 +1,6 @@
1
1
  import { Dayjs } from 'dayjs';
2
2
  export type TimeFormat = '12h' | '24h';
3
+ export type AmPm = 'AM' | 'PM';
3
4
  /**
4
5
  * Formats a date for display
5
6
  * @param date - Dayjs date object
@@ -1,4 +1,4 @@
1
- import { TimeFormat } from './format-utils';
1
+ import { AmPm, TimeFormat } from './format-utils';
2
2
  /**
3
3
  * Generates an array of hours.
4
4
  * If timeFormat is '12h', generates hours from 1 to 12.
@@ -30,11 +30,11 @@ export declare const parseTime: (timeString: string) => {
30
30
  /**
31
31
  * Gets AM/PM period from a 24-hour format hour.
32
32
  */
33
- export declare const getAmPmFromHour: (hour: number) => "AM" | "PM";
33
+ export declare const getAmPmFromHour: (hour: number) => AmPm;
34
34
  /**
35
35
  * Converts a 12-hour format hour and AM/PM period to a 24-hour format hour.
36
36
  */
37
- export declare const convert12HourTo24Hour: (hour: number, ampm: "AM" | "PM") => number;
37
+ export declare const convert12HourTo24Hour: (hour: number, ampm: AmPm) => number;
38
38
  /**
39
39
  * Converts a 24-hour format hour to a 12-hour display value (1-12).
40
40
  * Used when displaying time in 12-hour format.
@@ -0,0 +1,52 @@
1
+ import { ComponentType, ReactElement, ReactNode } from 'react';
2
+ export type OverflowComponent = ComponentType<{
3
+ items: ReactElement[];
4
+ }>;
5
+ export type ItemElement = ReactElement<Record<string, unknown>>;
6
+ export type CollapseStrategy = 'asc' | 'desc' | 'innerAscFirstKeepLast' | 'innerDescFirstKeepLast';
7
+ export type CollapseUnit = number | number[];
8
+ export declare function resolveCollapseOrder(order: CollapseUnit[] | CollapseStrategy, itemCount: number): CollapseUnit[];
9
+ export type CollapseState = {
10
+ hiddenIndices: number[];
11
+ overflowAt: number;
12
+ };
13
+ export declare const INITIAL_STATE: CollapseState;
14
+ export declare function arraysEqual(a: number[], b: number[]): boolean;
15
+ export declare function totalWidth(itemWidths: number[], gap: number): number;
16
+ export declare const FIT_EPSILON = 0.5;
17
+ export declare function getMeasurements(measureEl: HTMLElement, overflowEl: HTMLElement, hasSep: boolean, orientation?: 'horizontal' | 'vertical', lastItemFlexibleSelector?: string): {
18
+ itemWidths: number[];
19
+ gap: number;
20
+ overflowWidth: number;
21
+ outerMarginLeft: number;
22
+ outerMarginRight: number;
23
+ lastItemFlexibleWidth?: number;
24
+ };
25
+ export declare function hideUntilFit(total: number, itemWidths: number[], gap: number, overflowCost: number, hideOrder: CollapseUnit[], containerWidth: number): {
26
+ hidden: Set<number>;
27
+ firstHidden: number | null;
28
+ };
29
+ export declare function computeCollapseState({ containerSize, itemWidths, gap, overflowWidth, outerMarginLeft, outerMarginRight, collapseOrder, }: {
30
+ containerSize: number;
31
+ itemWidths: number[];
32
+ gap: number;
33
+ overflowWidth: number;
34
+ outerMarginLeft?: number;
35
+ outerMarginRight?: number;
36
+ collapseOrder: CollapseUnit[];
37
+ }): CollapseState;
38
+ export declare function computeCollapsedMinWidth({ itemWidths, gap, overflowWidth, outerMarginLeft, outerMarginRight, collapseOrder, lastItemMinVisible, lastItemFlexibleWidth, }: {
39
+ itemWidths: number[];
40
+ gap: number;
41
+ overflowWidth: number;
42
+ outerMarginLeft?: number;
43
+ outerMarginRight?: number;
44
+ collapseOrder: CollapseUnit[];
45
+ lastItemMinVisible?: number;
46
+ lastItemFlexibleWidth?: number;
47
+ }): number;
48
+ export declare function collapseStatesEqual(a: CollapseState, b: CollapseState): boolean;
49
+ export declare function buildVisibleTokens(items: ReactElement[], hiddenSet: Set<number>, overflowAt: number, hiddenItems: ReactElement[], Overflow: OverflowComponent): Array<{
50
+ key: string | number;
51
+ node: ReactNode;
52
+ }>;
@@ -1,20 +1,26 @@
1
- import { ReactNode } from 'react';
1
+ import { ComponentProps, ReactNode } from 'react';
2
2
  import { Tabs as TabsPrimitive } from '@base-ui/react/tabs';
3
3
  import { VariantProps } from 'class-variance-authority';
4
4
  import { ClassProp } from 'class-variance-authority/types';
5
5
  declare function SegmentedControl({ className, ...props }: TabsPrimitive.Root.Props): ReactNode;
6
- interface SegmentedControlListVariantProps {
6
+ interface SegmentedControlSizeVariantProps {
7
7
  size?: 'small' | 'default' | null;
8
8
  }
9
- declare const segmentedControlListVariants: (props?: (SegmentedControlListVariantProps & ClassProp) | undefined) => string;
9
+ declare const segmentedControlListVariants: (props?: (SegmentedControlSizeVariantProps & ClassProp) | undefined) => string;
10
+ type SegmentedControlSize = NonNullable<VariantProps<typeof segmentedControlListVariants>['size']>;
10
11
  type SegmentedControlListProps = TabsPrimitive.List.Props & VariantProps<typeof segmentedControlListVariants>;
11
12
  declare function SegmentedControlList({ className, size, children, ...props }: SegmentedControlListProps): ReactNode;
12
- interface SegmentedControlButtonVariantProps {
13
- size?: 'small' | 'default' | null;
13
+ declare const segmentedControlIndicatorVariants: (props?: (SegmentedControlSizeVariantProps & ClassProp) | undefined) => string;
14
+ type SegmentedControlIndicatorProps = ComponentProps<'div'> & VariantProps<typeof segmentedControlIndicatorVariants> & {
15
+ activeSelector?: string;
16
+ };
17
+ declare function SegmentedControlIndicator({ className, size, activeSelector, style, ...props }: SegmentedControlIndicatorProps): ReactNode;
18
+ interface SegmentedControlButtonVariantProps extends SegmentedControlSizeVariantProps {
14
19
  tabContent?: 'icon-label' | 'label-only' | 'icon-only' | null;
15
20
  }
16
21
  declare const segmentedControlButtonVariants: (props?: (SegmentedControlButtonVariantProps & ClassProp) | undefined) => string;
17
22
  type SegmentedControlButtonProps = TabsPrimitive.Tab.Props & VariantProps<typeof segmentedControlButtonVariants>;
18
23
  declare function SegmentedControlButton({ className, size, tabContent, ...props }: SegmentedControlButtonProps): ReactNode;
19
24
  declare function SegmentedControlContent({ className, ...props }: TabsPrimitive.Panel.Props): ReactNode;
20
- export { SegmentedControl, SegmentedControlButton, SegmentedControlContent, SegmentedControlList, segmentedControlButtonVariants, segmentedControlListVariants, };
25
+ export { SegmentedControl, SegmentedControlButton, SegmentedControlContent, SegmentedControlIndicator, SegmentedControlList, segmentedControlButtonVariants, segmentedControlIndicatorVariants, segmentedControlListVariants, };
26
+ export type { SegmentedControlSize };