@leonardaustin/ui 0.26.1 → 0.27.0
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/components/tables/Pagination.d.ts +1 -1
- package/dist/components/tables/Pagination.js +7 -8
- package/dist/components/ui/CalendarGrid.js +10 -10
- package/dist/components/ui/DatePicker.d.ts +1 -1
- package/dist/components/ui/DatePicker.js +5 -10
- package/dist/components/ui/DateRangePicker.d.ts +3 -1
- package/dist/components/ui/DateRangePicker.js +56 -62
- package/dist/components/ui/DateTimePicker.js +20 -20
- package/dist/components/ui/MetadataGrid.d.ts +2 -2
- package/dist/components/ui/MetadataGrid.js +11 -11
- package/dist/components/ui/PaginationBar.d.ts +1 -1
- package/dist/components/ui/PaginationBar.js +4 -5
- package/dist/components/ui/Select.js +1 -1
- package/dist/core.css +15 -0
- package/dist/lib/calendar.d.ts +2 -0
- package/dist/lib/calendar.js +234 -229
- package/dist/styles.css +16 -0
- package/package.json +1 -1
|
@@ -16,4 +16,4 @@ export interface PaginationProps extends Omit<ComponentPropsWithRef<"div">, "chi
|
|
|
16
16
|
*/
|
|
17
17
|
summary?: ReactNode | ((total: number | undefined) => ReactNode);
|
|
18
18
|
}
|
|
19
|
-
export declare function Pagination({ page, totalPages, onPageChange, loading, total, summary, className, ref, ...rest }: PaginationProps): import("react/jsx-runtime").JSX.Element
|
|
19
|
+
export declare function Pagination({ page, totalPages, onPageChange, loading, total, summary, className, ref, ...rest }: PaginationProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,17 +3,16 @@ import { Fragment as t, jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
|
3
3
|
import { ChevronLeft as i, ChevronRight as a } from "lucide-react";
|
|
4
4
|
//#region src/components/tables/Pagination.tsx
|
|
5
5
|
function o({ page: o, totalPages: s, onPageChange: c, loading: l = !1, total: u, summary: d, className: f, ref: p, ...m }) {
|
|
6
|
-
|
|
7
|
-
let
|
|
8
|
-
for (let e = 1; e <= s; e++) e === 1 || e === s || e >= o - 1 && e <= o + 1 ? h.push(e) : h[h.length - 1] !== "ellipsis" && h.push("ellipsis");
|
|
6
|
+
let h = s <= 1 && !l && u === void 0 && d == null, g = d !== null && (l || u !== void 0 || d !== void 0), _ = [];
|
|
7
|
+
for (let e = 1; e <= s; e++) e === 1 || e === s || e >= o - 1 && e <= o + 1 ? _.push(e) : _[_.length - 1] !== "ellipsis" && _.push("ellipsis");
|
|
9
8
|
return /* @__PURE__ */ r("div", {
|
|
10
9
|
ref: p,
|
|
11
10
|
...m,
|
|
12
|
-
className: e("flex items-center gap-1", f),
|
|
13
|
-
children: [
|
|
11
|
+
className: h ? "contents" : e("flex items-center gap-1", f),
|
|
12
|
+
children: [/* @__PURE__ */ n("span", {
|
|
14
13
|
role: "status",
|
|
15
|
-
className: "text-text-tertiary text-xs",
|
|
16
|
-
children: l ? "Loading results..." : d === void 0 ? `${u} in total` : typeof d == "function" ? d(u) : d
|
|
14
|
+
className: g ? "text-text-tertiary text-xs" : "sr-only",
|
|
15
|
+
children: g && (l ? "Loading results..." : d === void 0 ? `${u} in total` : typeof d == "function" ? d(u) : d)
|
|
17
16
|
}), s > 1 && /* @__PURE__ */ r(t, { children: [
|
|
18
17
|
/* @__PURE__ */ n("button", {
|
|
19
18
|
type: "button",
|
|
@@ -26,7 +25,7 @@ function o({ page: o, totalPages: s, onPageChange: c, loading: l = !1, total: u,
|
|
|
26
25
|
"aria-label": "Previous page",
|
|
27
26
|
children: /* @__PURE__ */ n(i, { className: "h-3.5 w-3.5" })
|
|
28
27
|
}),
|
|
29
|
-
|
|
28
|
+
_.map((t, r) => t === "ellipsis" ? /* @__PURE__ */ n("span", {
|
|
30
29
|
className: "text-text-tertiary flex h-7 w-7 items-center justify-center text-xs",
|
|
31
30
|
children: "..."
|
|
32
31
|
}, `e${r}`) : /* @__PURE__ */ n("button", {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cn as e } from "../../lib/cn.js";
|
|
2
2
|
import { mergeRefs as t } from "../../lib/mergeRefs.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { MONTHS_LONG as n } from "../../lib/months.js";
|
|
4
|
+
import { calendarDateFromParts as r, calendarDateParts as i } from "../../lib/calendar.js";
|
|
5
5
|
import { useRef as a, useState as o } from "react";
|
|
6
6
|
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
7
|
import { ChevronLeft as l, ChevronRight as u } from "lucide-react";
|
|
@@ -16,8 +16,8 @@ var d = [
|
|
|
16
16
|
"Su"
|
|
17
17
|
];
|
|
18
18
|
function f(e, t, n) {
|
|
19
|
-
let
|
|
20
|
-
return
|
|
19
|
+
let r = i(e, n), a = i(t, n);
|
|
20
|
+
return r.year === a.year && r.month === a.month && r.day === a.day;
|
|
21
21
|
}
|
|
22
22
|
function p(e, t, n) {
|
|
23
23
|
if (!t || !n) return !1;
|
|
@@ -34,7 +34,7 @@ function h(e, t) {
|
|
|
34
34
|
function g({ year: g, month: _, timeZone: v, selected: y, rangeStart: b, rangeEnd: x, hoverDate: S, onSelect: C, onMonthChange: w, onHover: T, minDate: E, maxDate: D, className: O, ref: k, ...A }) {
|
|
35
35
|
let j = m(g, _), M = h(g, _), N = /* @__PURE__ */ new Date(), P = a(null), [F, I] = o(null);
|
|
36
36
|
function L() {
|
|
37
|
-
return F !== null && F >= 1 && F <= j ? F : y &&
|
|
37
|
+
return F !== null && F >= 1 && F <= j ? F : y && i(y, v).year === g && i(y, v).month - 1 === _ ? i(y, v).day : b && i(b, v).year === g && i(b, v).month - 1 === _ ? i(b, v).day : i(N, v).year === g && i(N, v).month - 1 === _ ? i(N, v).day : 1;
|
|
38
38
|
}
|
|
39
39
|
let R = L();
|
|
40
40
|
function z(e, t) {
|
|
@@ -85,7 +85,7 @@ function g({ year: g, month: _, timeZone: v, selected: y, rangeStart: b, rangeEn
|
|
|
85
85
|
className: "text-text-primary text-xs font-semibold",
|
|
86
86
|
"aria-live": "polite",
|
|
87
87
|
children: [
|
|
88
|
-
|
|
88
|
+
n[_],
|
|
89
89
|
" ",
|
|
90
90
|
g
|
|
91
91
|
]
|
|
@@ -103,9 +103,9 @@ function g({ year: g, month: _, timeZone: v, selected: y, rangeStart: b, rangeEn
|
|
|
103
103
|
children: [d.map((e) => /* @__PURE__ */ s("div", {
|
|
104
104
|
className: "text-text-tertiary text-2xs flex h-8 items-center justify-center font-medium",
|
|
105
105
|
children: e
|
|
106
|
-
}, e)), H.map((t,
|
|
107
|
-
if (t === null) return /* @__PURE__ */ s("div", { className: "h-8" }, `empty-${
|
|
108
|
-
let a =
|
|
106
|
+
}, e)), H.map((t, i) => {
|
|
107
|
+
if (t === null) return /* @__PURE__ */ s("div", { className: "h-8" }, `empty-${i}`);
|
|
108
|
+
let a = r({
|
|
109
109
|
year: g,
|
|
110
110
|
month: _ + 1,
|
|
111
111
|
day: t,
|
|
@@ -119,7 +119,7 @@ function g({ year: g, month: _, timeZone: v, selected: y, rangeStart: b, rangeEn
|
|
|
119
119
|
"data-day": t,
|
|
120
120
|
disabled: !!m,
|
|
121
121
|
tabIndex: t === R ? 0 : -1,
|
|
122
|
-
"aria-label": `${
|
|
122
|
+
"aria-label": `${n[_]} ${t}, ${g}`,
|
|
123
123
|
"aria-current": o ? "date" : void 0,
|
|
124
124
|
onClick: () => C(a),
|
|
125
125
|
onKeyDown: (e) => z(e, t),
|
|
@@ -13,7 +13,7 @@ export interface DatePickerProps extends Omit<ComponentPropsWithRef<"div">, "chi
|
|
|
13
13
|
/** Called with the chosen date. */
|
|
14
14
|
onValueChange?: (date: Date | null) => void;
|
|
15
15
|
placeholder?: string;
|
|
16
|
-
/**
|
|
16
|
+
/** Formats the trigger date. Defaults to en-GB, e.g. "25 Oct 2026". */
|
|
17
17
|
format?: (date: Date) => string;
|
|
18
18
|
}
|
|
19
19
|
export declare function DatePicker({ controlSize, label, timeZone, value: valueProp, defaultValue, onValueChange, placeholder, format, ref, ...rest }: DatePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,19 +3,14 @@ import { mergeRefs as t } from "../../lib/mergeRefs.js";
|
|
|
3
3
|
import { useControlSize as n } from "../../providers/ControlSizeContext.js";
|
|
4
4
|
import { useControllableState as r } from "../../hooks/useControllableState.js";
|
|
5
5
|
import { usePopover as i } from "../../hooks/usePopover.js";
|
|
6
|
-
import { calendarDateParts as a } from "../../lib/calendar.js";
|
|
7
|
-
import { MONTHS_SHORT as o } from "../../lib/months.js";
|
|
6
|
+
import { calendarDateParts as a, formatPickerDate as o } from "../../lib/calendar.js";
|
|
8
7
|
import { CalendarGrid as s } from "./CalendarGrid.js";
|
|
9
8
|
import { useMemo as c, useState as l } from "react";
|
|
10
9
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
11
10
|
import { Calendar as f } from "lucide-react";
|
|
12
11
|
//#region src/components/ui/DatePicker.tsx
|
|
13
|
-
function p(
|
|
14
|
-
let
|
|
15
|
-
return `${o[r - 1]} ${i}, ${n}`;
|
|
16
|
-
}
|
|
17
|
-
function m({ controlSize: o, label: m, timeZone: h, value: g, defaultValue: _ = null, onValueChange: v, placeholder: y = "Select date...", format: b, ref: x, ...S }) {
|
|
18
|
-
let C = n(o), [w, T] = r({
|
|
12
|
+
function p({ controlSize: p, label: m, timeZone: h, value: g, defaultValue: _ = null, onValueChange: v, placeholder: y = "Select date...", format: b, ref: x, ...S }) {
|
|
13
|
+
let C = n(p), [w, T] = r({
|
|
19
14
|
value: g,
|
|
20
15
|
defaultValue: _,
|
|
21
16
|
onChange: v
|
|
@@ -53,7 +48,7 @@ function m({ controlSize: o, label: m, timeZone: h, value: g, defaultValue: _ =
|
|
|
53
48
|
onClick: H,
|
|
54
49
|
"data-control-size": C,
|
|
55
50
|
className: e("ui-sized-control flex h-7 w-full cursor-pointer items-center rounded-md text-xs", "bg-bg-secondary border-border text-text-primary border", "hover:bg-bg-hover hover:border-border-strong", "transition-colors duration-[100ms]", "px-2 pr-7"),
|
|
56
|
-
children: w ? b ? b(w) :
|
|
51
|
+
children: w ? b ? b(w) : o(w, h) : /* @__PURE__ */ u("span", {
|
|
57
52
|
className: "text-text-placeholder",
|
|
58
53
|
children: y
|
|
59
54
|
})
|
|
@@ -81,4 +76,4 @@ function m({ controlSize: o, label: m, timeZone: h, value: g, defaultValue: _ =
|
|
|
81
76
|
});
|
|
82
77
|
}
|
|
83
78
|
//#endregion
|
|
84
|
-
export {
|
|
79
|
+
export { p as DatePicker };
|
|
@@ -17,5 +17,7 @@ export interface DateRangePickerProps extends Omit<ComponentPropsWithRef<"div">,
|
|
|
17
17
|
onValueChange?: (range: DateRange) => void;
|
|
18
18
|
/** Text shown when no range is selected. Defaults to "Select date range...". */
|
|
19
19
|
placeholder?: string;
|
|
20
|
+
/** Formats each date in the trigger. Defaults to en-GB, e.g. "25 Oct 2026". */
|
|
21
|
+
format?: (date: Date) => string;
|
|
20
22
|
}
|
|
21
|
-
export declare function DateRangePicker({ controlSize, label, value: valueProp, defaultValue, onValueChange, placeholder, ref, className, ...rest }: DateRangePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare function DateRangePicker({ controlSize, label, value: valueProp, defaultValue, onValueChange, placeholder, format, ref, className, ...rest }: DateRangePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,79 +3,73 @@ import { mergeRefs as t } from "../../lib/mergeRefs.js";
|
|
|
3
3
|
import { useControlSize as n } from "../../providers/ControlSizeContext.js";
|
|
4
4
|
import { useControllableState as r } from "../../hooks/useControllableState.js";
|
|
5
5
|
import { usePopover as i } from "../../hooks/usePopover.js";
|
|
6
|
-
import {
|
|
6
|
+
import { formatPickerDate as a } from "../../lib/calendar.js";
|
|
7
7
|
import { CalendarGrid as o } from "./CalendarGrid.js";
|
|
8
8
|
import { useMemo as s, useState as c } from "react";
|
|
9
9
|
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
10
10
|
import { Calendar as d } from "lucide-react";
|
|
11
11
|
//#region src/components/ui/DateRangePicker.tsx
|
|
12
|
-
|
|
13
|
-
return `${a[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`;
|
|
14
|
-
}
|
|
15
|
-
function p(e) {
|
|
16
|
-
return e.start && e.end ? `${f(e.start)} – ${f(e.end)}` : e.start ? f(e.start) : "";
|
|
17
|
-
}
|
|
18
|
-
var m = {
|
|
12
|
+
var f = {
|
|
19
13
|
start: null,
|
|
20
14
|
end: null
|
|
21
15
|
};
|
|
22
|
-
function
|
|
23
|
-
let
|
|
16
|
+
function p({ controlSize: p, label: m, value: h, defaultValue: g = f, onValueChange: _, placeholder: v = "Select date range...", format: y = a, ref: b, className: x, ...S }) {
|
|
17
|
+
let C = n(p), [w, T] = r({
|
|
24
18
|
value: h,
|
|
25
19
|
defaultValue: g,
|
|
26
20
|
onChange: _
|
|
27
|
-
}), { open:
|
|
21
|
+
}), { open: E, show: D, close: O, rootRef: k, anchorRef: ee, triggerRef: te, popupRef: A, labelId: j, popupId: M, triggerAria: N } = i({
|
|
28
22
|
haspopup: "dialog",
|
|
29
|
-
labelled: !!
|
|
30
|
-
}),
|
|
31
|
-
function
|
|
32
|
-
if (
|
|
33
|
-
|
|
23
|
+
labelled: !!m
|
|
24
|
+
}), P = s(() => t(b, k), [b, k]), F = /* @__PURE__ */ new Date(), [I, L] = c(w.start?.getFullYear() ?? F.getFullYear()), [R, z] = c(w.start?.getMonth() ?? F.getMonth()), [B, V] = c(null), [H, U] = c("start"), [W, G] = c(w.start), [K, q] = c(w.end), J = R === 11 ? I + 1 : I, Y = R === 11 ? 0 : R + 1;
|
|
25
|
+
function X() {
|
|
26
|
+
if (E) {
|
|
27
|
+
O("toggle");
|
|
34
28
|
return;
|
|
35
29
|
}
|
|
36
|
-
|
|
30
|
+
G(w.start), q(w.end), U("start"), w.start && (L(w.start.getFullYear()), z(w.start.getMonth())), D();
|
|
37
31
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
start:
|
|
41
|
-
end:
|
|
42
|
-
}),
|
|
32
|
+
function Z(e) {
|
|
33
|
+
H === "start" ? (G(e), q(null), U("end")) : (W && e < W ? (q(W), G(e)) : q(e), U("start"), T({
|
|
34
|
+
start: W && e < W ? e : W,
|
|
35
|
+
end: W && e < W ? W : e
|
|
36
|
+
}), O("select"));
|
|
43
37
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
38
|
+
function ne() {
|
|
39
|
+
R === 0 ? (L(I - 1), z(11)) : z(R - 1);
|
|
46
40
|
}
|
|
47
|
-
function
|
|
48
|
-
|
|
41
|
+
function re() {
|
|
42
|
+
R === 11 ? (L(I + 1), z(0)) : z(R + 1);
|
|
49
43
|
}
|
|
50
|
-
let
|
|
44
|
+
let { start: Q, end: $ } = w;
|
|
51
45
|
return /* @__PURE__ */ u("div", {
|
|
52
|
-
...
|
|
53
|
-
ref:
|
|
54
|
-
className: e("flex flex-col gap-1.5",
|
|
55
|
-
children: [
|
|
56
|
-
id:
|
|
46
|
+
...S,
|
|
47
|
+
ref: P,
|
|
48
|
+
className: e("flex flex-col gap-1.5", x),
|
|
49
|
+
children: [m && /* @__PURE__ */ l("span", {
|
|
50
|
+
id: j,
|
|
57
51
|
className: "ui-field-label text-xs font-medium",
|
|
58
|
-
children:
|
|
52
|
+
children: m
|
|
59
53
|
}), /* @__PURE__ */ u("div", {
|
|
60
54
|
className: "relative",
|
|
61
|
-
ref:
|
|
55
|
+
ref: ee,
|
|
62
56
|
children: [
|
|
63
57
|
/* @__PURE__ */ l("button", {
|
|
64
58
|
type: "button",
|
|
65
|
-
ref:
|
|
66
|
-
...
|
|
67
|
-
onClick:
|
|
68
|
-
"data-control-size":
|
|
59
|
+
ref: te,
|
|
60
|
+
...N,
|
|
61
|
+
onClick: X,
|
|
62
|
+
"data-control-size": C,
|
|
69
63
|
className: e("ui-sized-control flex h-7 w-full cursor-pointer items-center rounded-md text-xs", "bg-bg-secondary border-border text-text-primary border", "hover:bg-bg-hover hover:border-border-strong", "transition-colors duration-[100ms]", "px-2 pr-7"),
|
|
70
|
-
children:
|
|
64
|
+
children: Q ? $ ? `${y(Q)} – ${y($)}` : y(Q) : /* @__PURE__ */ l("span", {
|
|
71
65
|
className: "text-text-placeholder",
|
|
72
66
|
children: v
|
|
73
67
|
})
|
|
74
68
|
}),
|
|
75
69
|
/* @__PURE__ */ l(d, { className: "text-text-tertiary pointer-events-none absolute top-1/2 right-2 h-3 w-3 -translate-y-1/2" }),
|
|
76
|
-
|
|
77
|
-
ref:
|
|
78
|
-
id:
|
|
70
|
+
E && /* @__PURE__ */ u("div", {
|
|
71
|
+
ref: A,
|
|
72
|
+
id: M,
|
|
79
73
|
role: "dialog",
|
|
80
74
|
"aria-label": "Choose date range",
|
|
81
75
|
className: e("ui-glass ui-glass-popover bg-bg-tertiary border-border-strong animate-scale-in fixed top-0 left-0 z-[100] rounded-md border shadow-lg", "p-3"),
|
|
@@ -84,7 +78,7 @@ function h({ controlSize: a, label: f, value: h, defaultValue: g = m, onValueCha
|
|
|
84
78
|
children: [
|
|
85
79
|
/* @__PURE__ */ l("button", {
|
|
86
80
|
type: "button",
|
|
87
|
-
onClick:
|
|
81
|
+
onClick: ne,
|
|
88
82
|
"aria-label": "Previous month",
|
|
89
83
|
className: "text-text-tertiary hover:text-text-primary hover:bg-bg-hover flex h-6 w-6 cursor-pointer items-center justify-center rounded-md transition-colors duration-[100ms]",
|
|
90
84
|
children: /* @__PURE__ */ l("span", {
|
|
@@ -95,11 +89,11 @@ function h({ controlSize: a, label: f, value: h, defaultValue: g = m, onValueCha
|
|
|
95
89
|
/* @__PURE__ */ l("span", {
|
|
96
90
|
className: "text-text-tertiary text-2xs",
|
|
97
91
|
"aria-live": "polite",
|
|
98
|
-
children:
|
|
92
|
+
children: H === "start" ? "Select start date" : "Select end date"
|
|
99
93
|
}),
|
|
100
94
|
/* @__PURE__ */ l("button", {
|
|
101
95
|
type: "button",
|
|
102
|
-
onClick:
|
|
96
|
+
onClick: re,
|
|
103
97
|
"aria-label": "Next month",
|
|
104
98
|
className: "text-text-tertiary hover:text-text-primary hover:bg-bg-hover flex h-6 w-6 cursor-pointer items-center justify-center rounded-md transition-colors duration-[100ms]",
|
|
105
99
|
children: /* @__PURE__ */ l("span", {
|
|
@@ -111,27 +105,27 @@ function h({ controlSize: a, label: f, value: h, defaultValue: g = m, onValueCha
|
|
|
111
105
|
}), /* @__PURE__ */ u("div", {
|
|
112
106
|
className: "flex gap-4",
|
|
113
107
|
children: [/* @__PURE__ */ l(o, {
|
|
114
|
-
year:
|
|
115
|
-
month:
|
|
116
|
-
rangeStart:
|
|
117
|
-
rangeEnd:
|
|
118
|
-
hoverDate:
|
|
119
|
-
onSelect:
|
|
108
|
+
year: I,
|
|
109
|
+
month: R,
|
|
110
|
+
rangeStart: W,
|
|
111
|
+
rangeEnd: K,
|
|
112
|
+
hoverDate: H === "end" ? B : null,
|
|
113
|
+
onSelect: Z,
|
|
120
114
|
onMonthChange: (e, t) => {
|
|
121
|
-
|
|
115
|
+
L(e), z(t);
|
|
122
116
|
},
|
|
123
|
-
onHover:
|
|
117
|
+
onHover: V
|
|
124
118
|
}), /* @__PURE__ */ l(o, {
|
|
125
|
-
year:
|
|
126
|
-
month:
|
|
127
|
-
rangeStart:
|
|
128
|
-
rangeEnd:
|
|
129
|
-
hoverDate:
|
|
130
|
-
onSelect:
|
|
119
|
+
year: J,
|
|
120
|
+
month: Y,
|
|
121
|
+
rangeStart: W,
|
|
122
|
+
rangeEnd: K,
|
|
123
|
+
hoverDate: H === "end" ? B : null,
|
|
124
|
+
onSelect: Z,
|
|
131
125
|
onMonthChange: (e, t) => {
|
|
132
|
-
t === 0 ? (
|
|
126
|
+
t === 0 ? (L(e - 1), z(11)) : (L(e), z(t - 1));
|
|
133
127
|
},
|
|
134
|
-
onHover:
|
|
128
|
+
onHover: V
|
|
135
129
|
})]
|
|
136
130
|
})]
|
|
137
131
|
})
|
|
@@ -140,4 +134,4 @@ function h({ controlSize: a, label: f, value: h, defaultValue: g = m, onValueCha
|
|
|
140
134
|
});
|
|
141
135
|
}
|
|
142
136
|
//#endregion
|
|
143
|
-
export {
|
|
137
|
+
export { p as DateRangePicker };
|
|
@@ -4,8 +4,8 @@ import { clamp as n } from "../../lib/math.js";
|
|
|
4
4
|
import { useControlSize as r } from "../../providers/ControlSizeContext.js";
|
|
5
5
|
import { useControllableState as i } from "../../hooks/useControllableState.js";
|
|
6
6
|
import { usePopover as a } from "../../hooks/usePopover.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { MONTHS_SHORT as o } from "../../lib/months.js";
|
|
8
|
+
import { calendarDateFromParts as s, calendarDateParts as c } from "../../lib/calendar.js";
|
|
9
9
|
import { CalendarGrid as l } from "./CalendarGrid.js";
|
|
10
10
|
import { useId as u, useMemo as d, useState as f } from "react";
|
|
11
11
|
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
@@ -40,8 +40,8 @@ function v(e, t) {
|
|
|
40
40
|
timeZoneName: "short",
|
|
41
41
|
hourCycle: "h23"
|
|
42
42
|
}).format(e);
|
|
43
|
-
let n =
|
|
44
|
-
return `${n} ${r}, ${i} ${a}:${String(e.getMinutes()).padStart(2, "0")} ${
|
|
43
|
+
let n = o[e.getMonth()], r = e.getDate(), i = e.getFullYear(), { hour12: a, period: s } = g(e.getHours());
|
|
44
|
+
return `${n} ${r}, ${i} ${a}:${String(e.getMinutes()).padStart(2, "0")} ${s}`;
|
|
45
45
|
}
|
|
46
46
|
function y(e) {
|
|
47
47
|
return String(e).padStart(2, "0");
|
|
@@ -58,14 +58,14 @@ function b({ value: e, defaultValue: t = null, onValueChange: n, ...r }) {
|
|
|
58
58
|
onValueChange: o
|
|
59
59
|
}, r.timeZone ?? "browser-local");
|
|
60
60
|
}
|
|
61
|
-
function x({ controlSize: i, label:
|
|
61
|
+
function x({ controlSize: i, label: o, timeZone: b, value: x, onValueChange: S, placeholder: C = "Select date & time...", ref: w, className: T, ...E }) {
|
|
62
62
|
let D = r(i), { open: O, show: k, close: A, rootRef: j, anchorRef: ee, triggerRef: te, popupRef: ne, labelId: re, popupId: ie, triggerAria: ae } = a({
|
|
63
63
|
haspopup: "dialog",
|
|
64
|
-
labelled: !!
|
|
65
|
-
}), oe = d(() => t(w, j), [w, j]), [M, N] = f(null), [P, F] = f(!1), [I, L] = f("reject"), R = u(), z =
|
|
64
|
+
labelled: !!o
|
|
65
|
+
}), oe = d(() => t(w, j), [w, j]), [M, N] = f(null), [P, F] = f(!1), [I, L] = f("reject"), R = u(), z = c(x ?? /* @__PURE__ */ new Date(), b), B = x ? g(c(x, b).hour) : {
|
|
66
66
|
hour12: 12,
|
|
67
67
|
period: "PM"
|
|
68
|
-
}, [V, H] = f(z.year), [U, W] = f(z.month - 1), [G, K] = f(String(B.hour12)), [q, J] = f(x ? y(
|
|
68
|
+
}, [V, H] = f(z.year), [U, W] = f(z.month - 1), [G, K] = f(String(B.hour12)), [q, J] = f(x ? y(c(x, b).minute) : "00"), [Y, X] = f(B.period), [Z, Q] = f(x);
|
|
69
69
|
function se(e) {
|
|
70
70
|
Q(e);
|
|
71
71
|
}
|
|
@@ -78,28 +78,28 @@ function x({ controlSize: i, label: c, timeZone: b, value: x, onValueChange: S,
|
|
|
78
78
|
function le() {
|
|
79
79
|
if (!Z) return;
|
|
80
80
|
let e = n(parseInt(G, 10) || 12, 1, 12), t = n(parseInt(q, 10) || 0, 0, 59), r = _(e, Y), i = {
|
|
81
|
-
...
|
|
81
|
+
...c(Z, b),
|
|
82
82
|
hour: r,
|
|
83
83
|
minute: t,
|
|
84
84
|
second: 0,
|
|
85
85
|
millisecond: 0
|
|
86
|
-
}, a = x ?
|
|
86
|
+
}, a = x ? c(x, b) : null, o;
|
|
87
87
|
try {
|
|
88
|
-
|
|
88
|
+
o = I === "reject" && x && a && [
|
|
89
89
|
"year",
|
|
90
90
|
"month",
|
|
91
91
|
"day",
|
|
92
92
|
"hour",
|
|
93
93
|
"minute"
|
|
94
|
-
].every((e) => a[e] === i[e]) ? new Date(x) :
|
|
95
|
-
let e =
|
|
94
|
+
].every((e) => a[e] === i[e]) ? new Date(x) : s(i, b, I);
|
|
95
|
+
let e = c(o, b);
|
|
96
96
|
if (e.hour !== r || e.minute !== t || e.day !== i.day) throw RangeError("This time does not exist in the selected timezone");
|
|
97
97
|
} catch (e) {
|
|
98
98
|
let t = e instanceof Error ? e.message : "Invalid date and time";
|
|
99
99
|
N(t), F(t.includes("twice"));
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
|
-
N(null), S(
|
|
102
|
+
N(null), S(o), A("select");
|
|
103
103
|
}
|
|
104
104
|
function $() {
|
|
105
105
|
if (O) {
|
|
@@ -107,14 +107,14 @@ function x({ controlSize: i, label: c, timeZone: b, value: x, onValueChange: S,
|
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
109
|
if (x) {
|
|
110
|
-
H(
|
|
111
|
-
let e = g(
|
|
112
|
-
K(String(e.hour12)), X(e.period), J(y(
|
|
110
|
+
H(c(x, b).year), W(c(x, b).month - 1), Q(x);
|
|
111
|
+
let e = g(c(x, b).hour);
|
|
112
|
+
K(String(e.hour12)), X(e.period), J(y(c(x, b).minute));
|
|
113
113
|
}
|
|
114
114
|
N(null);
|
|
115
115
|
let e = !1;
|
|
116
116
|
if (x && b) try {
|
|
117
|
-
|
|
117
|
+
s(c(x, b), b, "reject");
|
|
118
118
|
} catch (t) {
|
|
119
119
|
e = t instanceof Error && t.message.includes("twice");
|
|
120
120
|
}
|
|
@@ -124,10 +124,10 @@ function x({ controlSize: i, label: c, timeZone: b, value: x, onValueChange: S,
|
|
|
124
124
|
...E,
|
|
125
125
|
ref: oe,
|
|
126
126
|
className: e("flex flex-col gap-1.5", T),
|
|
127
|
-
children: [
|
|
127
|
+
children: [o && /* @__PURE__ */ p("span", {
|
|
128
128
|
id: re,
|
|
129
129
|
className: "ui-field-label text-xs font-medium",
|
|
130
|
-
children:
|
|
130
|
+
children: o
|
|
131
131
|
}), /* @__PURE__ */ m("div", {
|
|
132
132
|
className: "relative",
|
|
133
133
|
ref: ee,
|
|
@@ -35,9 +35,9 @@ interface MetadataItem {
|
|
|
35
35
|
value: ReactNode;
|
|
36
36
|
}
|
|
37
37
|
export interface MetadataGridProps extends Omit<HTMLAttributes<HTMLElement>, "children"> {
|
|
38
|
-
/** Ref to the root
|
|
38
|
+
/** Ref to the root `dl` element. */
|
|
39
39
|
ref?: Ref<HTMLElement>;
|
|
40
|
-
/** Inline
|
|
40
|
+
/** Inline places labels beside values in two columns; stacked places labels above values. */
|
|
41
41
|
layout?: "inline" | "stacked";
|
|
42
42
|
/** Stacked layout columns at mobile-first breakpoints. */
|
|
43
43
|
columns?: LayoutResponsive<number>;
|
|
@@ -8,7 +8,7 @@ function c(e, t) {
|
|
|
8
8
|
return n("stripe", t, (t) => Math.floor(e / t) % 2 == 0 ? "var(--ui-metadata-stripe-color, var(--bg-tertiary))" : "transparent", 1);
|
|
9
9
|
}
|
|
10
10
|
function l({ items: l, labelWidth: u = "100px", layout: d = "inline", columns: f = 1, gap: p = 3, striped: m = !1, className: h, ref: g, style: _, ...v }) {
|
|
11
|
-
let y = g
|
|
11
|
+
let y = g;
|
|
12
12
|
return d === "stacked" ? /* @__PURE__ */ a("dl", {
|
|
13
13
|
...v,
|
|
14
14
|
ref: y,
|
|
@@ -29,9 +29,9 @@ function l({ items: l, labelWidth: u = "100px", layout: d = "inline", columns: f
|
|
|
29
29
|
children: t.value
|
|
30
30
|
})]
|
|
31
31
|
}, t.label))
|
|
32
|
-
}) : m ? /* @__PURE__ */ a("
|
|
32
|
+
}) : m ? /* @__PURE__ */ a("dl", {
|
|
33
33
|
...v,
|
|
34
|
-
ref:
|
|
34
|
+
ref: y,
|
|
35
35
|
className: e("gap-x-3 text-xs", h),
|
|
36
36
|
style: {
|
|
37
37
|
display: "grid",
|
|
@@ -46,30 +46,30 @@ function l({ items: l, labelWidth: u = "100px", layout: d = "inline", columns: f
|
|
|
46
46
|
gridColumn: "1 / -1",
|
|
47
47
|
gridTemplateColumns: "subgrid"
|
|
48
48
|
},
|
|
49
|
-
children: [/* @__PURE__ */ a("
|
|
49
|
+
children: [/* @__PURE__ */ a("dt", {
|
|
50
50
|
className: "text-text-tertiary font-label",
|
|
51
51
|
children: e.label
|
|
52
|
-
}), typeof e.value == "string" || typeof e.value == "number" ? /* @__PURE__ */ a("
|
|
52
|
+
}), typeof e.value == "string" || typeof e.value == "number" ? /* @__PURE__ */ a("dd", {
|
|
53
53
|
className: "text-text-primary font-data",
|
|
54
54
|
children: e.value
|
|
55
|
-
}) : /* @__PURE__ */ a("
|
|
55
|
+
}) : /* @__PURE__ */ a("dd", { children: e.value })]
|
|
56
56
|
}, e.label))
|
|
57
|
-
}) : /* @__PURE__ */ a("
|
|
57
|
+
}) : /* @__PURE__ */ a("dl", {
|
|
58
58
|
...v,
|
|
59
|
-
ref:
|
|
59
|
+
ref: y,
|
|
60
60
|
className: e("gap-x-3 gap-y-2 text-xs", h),
|
|
61
61
|
style: {
|
|
62
62
|
display: "grid",
|
|
63
63
|
gridTemplateColumns: `${u} 1fr`,
|
|
64
64
|
..._
|
|
65
65
|
},
|
|
66
|
-
children: l.map((e) => /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a("
|
|
66
|
+
children: l.map((e) => /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a("dt", {
|
|
67
67
|
className: "text-text-tertiary font-label",
|
|
68
68
|
children: e.label
|
|
69
|
-
}), typeof e.value == "string" || typeof e.value == "number" ? /* @__PURE__ */ a("
|
|
69
|
+
}), typeof e.value == "string" || typeof e.value == "number" ? /* @__PURE__ */ a("dd", {
|
|
70
70
|
className: "text-text-primary font-data",
|
|
71
71
|
children: e.value
|
|
72
|
-
}) : /* @__PURE__ */ a("
|
|
72
|
+
}) : /* @__PURE__ */ a("dd", { children: e.value })] }, e.label))
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
//#endregion
|
|
@@ -42,7 +42,7 @@ export interface PaginationBarProps extends Omit<ComponentPropsWithRef<"div">, "
|
|
|
42
42
|
summary?: ReactNode | ((total: number) => ReactNode);
|
|
43
43
|
/** Show a short total caption after the range or custom summary. */
|
|
44
44
|
showTotal?: boolean;
|
|
45
|
-
/** Show a loading caption
|
|
45
|
+
/** Show a loading caption, disable navigation, and mark the page-size selector busy. */
|
|
46
46
|
loading?: boolean;
|
|
47
47
|
/**
|
|
48
48
|
* Options for the page-size dropdown.
|
|
@@ -28,15 +28,14 @@ function s({ page: s, pageSize: c, total: l, summary: u, showTotal: d = !1, load
|
|
|
28
28
|
children: [h && /* @__PURE__ */ i(t, {
|
|
29
29
|
size: "sm",
|
|
30
30
|
value: String(c),
|
|
31
|
-
onValueChange: (e) =>
|
|
32
|
-
f || h(Number(e));
|
|
33
|
-
},
|
|
31
|
+
onValueChange: (e) => h(Number(e)),
|
|
34
32
|
options: p,
|
|
35
33
|
className: "w-28",
|
|
36
|
-
|
|
34
|
+
role: "group",
|
|
35
|
+
"aria-busy": f || void 0
|
|
37
36
|
}), /* @__PURE__ */ a("span", {
|
|
38
37
|
role: "status",
|
|
39
|
-
className: e("text-text-tertiary text-xs", !f && "
|
|
38
|
+
className: e("text-text-tertiary text-xs", !f && "ui-pagination-count"),
|
|
40
39
|
children: [f ? "Loading results..." : u === void 0 ? /* @__PURE__ */ a(r, { children: [
|
|
41
40
|
b,
|
|
42
41
|
"–",
|
|
@@ -104,7 +104,7 @@ function u({ label: u, labelPlacement: d = "above", error: f, options: p, classN
|
|
|
104
104
|
}),
|
|
105
105
|
I && /* @__PURE__ */ s("span", {
|
|
106
106
|
"aria-hidden": "true",
|
|
107
|
-
className: "ui-select-placeholder
|
|
107
|
+
className: "ui-select-placeholder font-control pointer-events-none absolute top-1/2 -translate-y-1/2 truncate",
|
|
108
108
|
children: A
|
|
109
109
|
}),
|
|
110
110
|
/* @__PURE__ */ s(l, { className: "text-text-tertiary pointer-events-none absolute top-1/2 right-2.5 h-3.5 w-3.5 -translate-y-1/2" })
|
package/dist/core.css
CHANGED
|
@@ -1931,6 +1931,7 @@ select.ui-sized-control[data-control-size="comfortable"] {
|
|
|
1931
1931
|
padding-inline-end: 2.25rem;
|
|
1932
1932
|
}
|
|
1933
1933
|
.ui-select-placeholder {
|
|
1934
|
+
color: var(--text-secondary);
|
|
1934
1935
|
left: calc(var(--spacing) * 2);
|
|
1935
1936
|
right: calc(var(--spacing) * 7);
|
|
1936
1937
|
font-size: 0.75rem;
|
|
@@ -1945,6 +1946,7 @@ select.ui-sized-control[data-control-size="comfortable"] {
|
|
|
1945
1946
|
font-size: 1rem;
|
|
1946
1947
|
}
|
|
1947
1948
|
select:disabled + .ui-select-placeholder {
|
|
1949
|
+
color: var(--text-disabled);
|
|
1948
1950
|
opacity: 0.4;
|
|
1949
1951
|
}
|
|
1950
1952
|
.ui-password-input[data-control-size="comfortable"] {
|
|
@@ -2179,6 +2181,19 @@ select:disabled + .ui-select-placeholder {
|
|
|
2179
2181
|
|
|
2180
2182
|
/* Component defaults stay below consumer utilities in the cascade. */
|
|
2181
2183
|
@layer components {
|
|
2184
|
+
@media (width < 40rem) {
|
|
2185
|
+
.ui-pagination-count:where(:not(:focus-within)) {
|
|
2186
|
+
clip-path: inset(50%);
|
|
2187
|
+
white-space: nowrap;
|
|
2188
|
+
border-width: 0;
|
|
2189
|
+
width: 1px;
|
|
2190
|
+
height: 1px;
|
|
2191
|
+
margin: -1px;
|
|
2192
|
+
padding: 0;
|
|
2193
|
+
position: absolute;
|
|
2194
|
+
overflow: hidden;
|
|
2195
|
+
}}
|
|
2196
|
+
|
|
2182
2197
|
.ui-stack,
|
|
2183
2198
|
.ui-inline,
|
|
2184
2199
|
.ui-grid {
|
package/dist/lib/calendar.d.ts
CHANGED
|
@@ -155,6 +155,8 @@ export declare function getMonthWeeks(date: Date, weekStartsOn?: Weekday): Date[
|
|
|
155
155
|
export declare function getViewRange(view: CalendarView, date: Date, options?: CalendarViewOptions): DateRange;
|
|
156
156
|
/** The anchor date one page before (-1) or after (1) `date`. */
|
|
157
157
|
export declare function shiftDate(view: CalendarView, date: Date, direction: -1 | 1, options?: CalendarViewOptions): Date;
|
|
158
|
+
/** Default picker display in en-GB order, e.g. "25 Oct 2026". */
|
|
159
|
+
export declare function formatPickerDate(date: Date, timeZone?: string): string;
|
|
158
160
|
/** Cached `Intl.DateTimeFormat`. */
|
|
159
161
|
export declare function getFormatter(locale: string, options: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
160
162
|
export interface FormatOptions {
|