@mitcsutt/kiln-ui 0.5.0 → 0.7.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/actions/CopyButton/CopyButton.d.ts +58 -0
- package/dist/components/actions/CopyButton/CopyButton.js +63 -0
- package/dist/components/actions/CopyButton/CopyButton.js.map +1 -0
- package/dist/components/actions/CopyButton/CopyButton.module.js +9 -0
- package/dist/components/actions/CopyButton/CopyButton.module.js.map +1 -0
- package/dist/components/actions/CopyButton/index.d.ts +4 -0
- package/dist/components/actions/CopyButton/useClipboard.d.ts +35 -0
- package/dist/components/actions/CopyButton/useClipboard.js +62 -0
- package/dist/components/actions/CopyButton/useClipboard.js.map +1 -0
- package/dist/components/actions/ToggleChip/ToggleChip.d.ts +6 -0
- package/dist/components/actions/ToggleChip/ToggleChip.js +26 -24
- package/dist/components/actions/ToggleChip/ToggleChip.js.map +1 -1
- package/dist/components/display/Badge/Badge.d.ts +6 -0
- package/dist/components/display/Badge/Badge.js +16 -15
- package/dist/components/display/Badge/Badge.js.map +1 -1
- package/dist/components/display/CodeBlock/CodeBlock.d.ts +44 -3
- package/dist/components/display/CodeBlock/CodeBlock.js +39 -47
- package/dist/components/display/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/components/display/CodeBlock/CodeBlock.module.js +4 -3
- package/dist/components/display/CodeBlock/CodeBlock.module.js.map +1 -1
- package/dist/components/display/CodeBlock/index.d.ts +1 -1
- package/dist/components/display/Swatch/Swatch.d.ts +52 -0
- package/dist/components/display/Swatch/Swatch.js +27 -0
- package/dist/components/display/Swatch/Swatch.js.map +1 -0
- package/dist/components/display/Swatch/Swatch.module.js +6 -0
- package/dist/components/display/Swatch/Swatch.module.js.map +1 -0
- package/dist/components/display/Swatch/index.d.ts +2 -0
- package/dist/components/display/Tag/Tag.d.ts +7 -0
- package/dist/components/display/Tag/Tag.js +31 -26
- package/dist/components/display/Tag/Tag.js.map +1 -1
- package/dist/components/feedback/Indicator/Indicator.d.ts +74 -0
- package/dist/components/feedback/Indicator/Indicator.js +50 -0
- package/dist/components/feedback/Indicator/Indicator.js.map +1 -0
- package/dist/components/feedback/Indicator/Indicator.module.js +12 -0
- package/dist/components/feedback/Indicator/Indicator.module.js.map +1 -0
- package/dist/components/feedback/Indicator/index.d.ts +2 -0
- package/dist/components/feedback/Toaster/Toaster.d.ts +71 -0
- package/dist/components/feedback/Toaster/Toaster.js +121 -0
- package/dist/components/feedback/Toaster/Toaster.js.map +1 -0
- package/dist/components/feedback/Toaster/Toaster.module.js +20 -0
- package/dist/components/feedback/Toaster/Toaster.module.js.map +1 -0
- package/dist/components/feedback/Toaster/index.d.ts +4 -0
- package/dist/components/feedback/Toaster/toast.d.ts +96 -0
- package/dist/components/feedback/Toaster/toast.js +131 -0
- package/dist/components/feedback/Toaster/toast.js.map +1 -0
- package/dist/components/inputs/Calendar/Calendar.d.ts +87 -0
- package/dist/components/inputs/Calendar/Calendar.js +217 -0
- package/dist/components/inputs/Calendar/Calendar.js.map +1 -0
- package/dist/components/inputs/Calendar/Calendar.module.js +18 -0
- package/dist/components/inputs/Calendar/Calendar.module.js.map +1 -0
- package/dist/components/inputs/Calendar/index.d.ts +2 -0
- package/dist/components/inputs/Combobox/Combobox.js +36 -44
- package/dist/components/inputs/Combobox/Combobox.js.map +1 -1
- package/dist/components/inputs/DateField/DateField.d.ts +17 -0
- package/dist/components/inputs/DateField/DateField.js +26 -0
- package/dist/components/inputs/DateField/DateField.js.map +1 -0
- package/dist/components/inputs/DateField/index.d.ts +2 -0
- package/dist/components/inputs/DateInput/DateInput.d.ts +75 -0
- package/dist/components/inputs/DateInput/DateInput.js +139 -0
- package/dist/components/inputs/DateInput/DateInput.js.map +1 -0
- package/dist/components/inputs/DateInput/index.d.ts +3 -0
- package/dist/components/inputs/DateRangeField/DateRangeField.d.ts +18 -3
- package/dist/components/inputs/DateRangeField/DateRangeField.js.map +1 -1
- package/dist/components/inputs/DateRangeField/DateRangeField.module.js +8 -3
- package/dist/components/inputs/DateRangeField/DateRangeField.module.js.map +1 -1
- package/dist/components/inputs/DateRangeField/DateRangePickerField.d.ts +48 -0
- package/dist/components/inputs/DateRangeField/DateRangePickerField.js +246 -0
- package/dist/components/inputs/DateRangeField/DateRangePickerField.js.map +1 -0
- package/dist/components/inputs/DateRangeField/index.d.ts +2 -0
- package/dist/components/inputs/DateTimeField/DateTimeField.d.ts +17 -0
- package/dist/components/inputs/DateTimeField/DateTimeField.js +26 -0
- package/dist/components/inputs/DateTimeField/DateTimeField.js.map +1 -0
- package/dist/components/inputs/DateTimeField/index.d.ts +2 -0
- package/dist/components/inputs/DateTimeInput/DateTimeInput.d.ts +83 -0
- package/dist/components/inputs/DateTimeInput/DateTimeInput.js +216 -0
- package/dist/components/inputs/DateTimeInput/DateTimeInput.js.map +1 -0
- package/dist/components/inputs/DateTimeInput/index.d.ts +2 -0
- package/dist/components/inputs/JsonField/JsonField.d.ts +23 -0
- package/dist/components/inputs/JsonField/JsonField.js +33 -0
- package/dist/components/inputs/JsonField/JsonField.js.map +1 -0
- package/dist/components/inputs/JsonField/index.d.ts +2 -0
- package/dist/components/inputs/JsonInput/JsonInput.d.ts +119 -0
- package/dist/components/inputs/JsonInput/JsonInput.js +282 -0
- package/dist/components/inputs/JsonInput/JsonInput.js.map +1 -0
- package/dist/components/inputs/JsonInput/JsonInput.module.js +16 -0
- package/dist/components/inputs/JsonInput/JsonInput.module.js.map +1 -0
- package/dist/components/inputs/JsonInput/index.d.ts +4 -0
- package/dist/components/inputs/JsonInput/json.d.ts +59 -0
- package/dist/components/inputs/JsonInput/json.js +231 -0
- package/dist/components/inputs/JsonInput/json.js.map +1 -0
- package/dist/components/inputs/TagsInput/TagsInput.js +5 -5
- package/dist/components/inputs/TimeField/TimeField.d.ts +17 -0
- package/dist/components/inputs/TimeField/TimeField.js +26 -0
- package/dist/components/inputs/TimeField/TimeField.js.map +1 -0
- package/dist/components/inputs/TimeField/index.d.ts +2 -0
- package/dist/components/inputs/TimeInput/TimeInput.d.ts +54 -0
- package/dist/components/inputs/TimeInput/TimeInput.js +107 -0
- package/dist/components/inputs/TimeInput/TimeInput.js.map +1 -0
- package/dist/components/inputs/TimeInput/index.d.ts +2 -0
- package/dist/components/inputs/internal/DateSegments.d.ts +80 -0
- package/dist/components/inputs/internal/DateSegments.js +345 -0
- package/dist/components/inputs/internal/DateSegments.js.map +1 -0
- package/dist/components/inputs/internal/dates.d.ts +101 -0
- package/dist/components/inputs/internal/dates.js +262 -0
- package/dist/components/inputs/internal/dates.js.map +1 -0
- package/dist/components/inputs/internal/filterOptions.d.ts +22 -1
- package/dist/components/inputs/internal/filterOptions.js +32 -1
- package/dist/components/inputs/internal/filterOptions.js.map +1 -1
- package/dist/components/inputs/internal/picker.d.ts +31 -0
- package/dist/components/inputs/internal/picker.js +29 -0
- package/dist/components/inputs/internal/picker.js.map +1 -0
- package/dist/components/inputs/internal/picker.module.js +15 -0
- package/dist/components/inputs/internal/picker.module.js.map +1 -0
- package/dist/components/inputs/internal/segments.module.js +10 -0
- package/dist/components/inputs/internal/segments.module.js.map +1 -0
- package/dist/components/layout/Collapse/Collapse.d.ts +39 -0
- package/dist/components/layout/Collapse/Collapse.js +24 -0
- package/dist/components/layout/Collapse/Collapse.js.map +1 -0
- package/dist/components/layout/Collapse/Collapse.module.js +6 -0
- package/dist/components/layout/Collapse/Collapse.module.js.map +1 -0
- package/dist/components/layout/Collapse/index.d.ts +2 -0
- package/dist/components/layout/Collapse/useHeightMotion.d.ts +16 -0
- package/dist/components/layout/Collapse/useHeightMotion.js +60 -0
- package/dist/components/layout/Collapse/useHeightMotion.js.map +1 -0
- package/dist/components/layout/ShowMore/ShowMore.d.ts +59 -0
- package/dist/components/layout/ShowMore/ShowMore.js +114 -0
- package/dist/components/layout/ShowMore/ShowMore.js.map +1 -0
- package/dist/components/layout/ShowMore/ShowMore.module.js +12 -0
- package/dist/components/layout/ShowMore/ShowMore.module.js.map +1 -0
- package/dist/components/layout/ShowMore/index.d.ts +2 -0
- package/dist/components/layout/Transition/Transition.d.ts +63 -0
- package/dist/components/layout/Transition/Transition.js +63 -0
- package/dist/components/layout/Transition/Transition.js.map +1 -0
- package/dist/components/layout/Transition/Transition.module.js +17 -0
- package/dist/components/layout/Transition/Transition.module.js.map +1 -0
- package/dist/components/layout/Transition/index.d.ts +2 -0
- package/dist/components/navigation/Collapsible/Collapsible.d.ts +49 -0
- package/dist/components/navigation/Collapsible/Collapsible.js +83 -0
- package/dist/components/navigation/Collapsible/Collapsible.js.map +1 -0
- package/dist/components/navigation/Collapsible/Collapsible.module.js +11 -0
- package/dist/components/navigation/Collapsible/Collapsible.module.js.map +1 -0
- package/dist/components/navigation/Collapsible/index.d.ts +2 -0
- package/dist/components/navigation/NavLinks/NavLinks.d.ts +32 -4
- package/dist/components/navigation/NavLinks/NavLinks.js +69 -39
- package/dist/components/navigation/NavLinks/NavLinks.js.map +1 -1
- package/dist/components/navigation/NavLinks/NavLinks.module.js +13 -3
- package/dist/components/navigation/NavLinks/NavLinks.module.js.map +1 -1
- package/dist/components/navigation/NavLinks/NavLinksGroup.d.ts +49 -0
- package/dist/components/navigation/NavLinks/NavLinksGroup.js +185 -0
- package/dist/components/navigation/NavLinks/NavLinksGroup.js.map +1 -0
- package/dist/components/navigation/NavLinks/context.d.ts +28 -0
- package/dist/components/navigation/NavLinks/context.js +13 -0
- package/dist/components/navigation/NavLinks/context.js.map +1 -0
- package/dist/components/navigation/NavLinks/index.d.ts +2 -0
- package/dist/components/navigation/NavLinks/treeKeys.d.ts +8 -0
- package/dist/components/navigation/NavLinks/treeKeys.js +57 -0
- package/dist/components/navigation/NavLinks/treeKeys.js.map +1 -0
- package/dist/components/overlays/CommandPalette/CommandPalette.d.ts +120 -0
- package/dist/components/overlays/CommandPalette/CommandPalette.js +386 -0
- package/dist/components/overlays/CommandPalette/CommandPalette.js.map +1 -0
- package/dist/components/overlays/CommandPalette/CommandPalette.module.js +31 -0
- package/dist/components/overlays/CommandPalette/CommandPalette.module.js.map +1 -0
- package/dist/components/overlays/CommandPalette/index.d.ts +2 -0
- package/dist/components/overlays/CommandPalette/shortcut.d.ts +28 -0
- package/dist/components/overlays/CommandPalette/shortcut.js +104 -0
- package/dist/components/overlays/CommandPalette/shortcut.js.map +1 -0
- package/dist/highlight/index.d.ts +18 -0
- package/dist/highlight/index.js +103 -0
- package/dist/highlight/index.js.map +1 -0
- package/dist/index.d.ts +41 -5
- package/dist/index.js +123 -100
- package/dist/styles.css +1 -1
- package/dist/themes/fiesta.css +1 -1
- package/dist/themes/flightdeck.css +1 -1
- package/dist/themes/ledger.css +1 -1
- package/dist/themes/monograph.css +1 -1
- package/dist/themes/riso.css +1 -1
- package/dist/utils/newlines.d.ts +2 -0
- package/dist/utils/newlines.js +10 -0
- package/dist/utils/newlines.js.map +1 -0
- package/package.json +13 -2
- package/skills/custom-theme/SKILL.md +32 -0
- package/skills/custom-theme/references/colour.md +20 -0
- package/skills/custom-theme/references/motion.md +9 -0
- package/skills/custom-theme/references/tokens.md +35 -0
- package/skills/design-rules/SKILL.md +5 -2
- package/skills/setup-and-theming/SKILL.md +2 -1
- package/skills/setup-and-theming/references/paper.md +1 -1
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { cx as e } from "../../../utils/cx.js";
|
|
2
|
+
import { ChevronLeftIcon as t, ChevronRightIcon as n } from "../../../icons/icons.js";
|
|
3
|
+
import { useMergedRefs as r } from "../internal/refs.js";
|
|
4
|
+
import { useLatest as i } from "../internal/useLatest.js";
|
|
5
|
+
import { IconButton as a } from "../../actions/IconButton/IconButton.js";
|
|
6
|
+
import { DEFAULT_LOCALE as o, addDays as s, addMonths as c, clampDate as l, compareDates as u, dayOfWeek as d, daysInMonth as f, defaultFirstDayOfWeek as ee, formatDate as p, formatFullDate as te, formatMonthYear as ne, isSameDay as m, pad as h, parseDate as g, todayIn as re, weekdayNames as ie } from "../internal/dates.js";
|
|
7
|
+
import _ from "./Calendar.module.js";
|
|
8
|
+
import { forwardRef as v, useEffect as ae, useId as oe, useRef as y, useState as b } from "react";
|
|
9
|
+
import { jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
10
|
+
//#region src/components/inputs/Calendar/Calendar.tsx
|
|
11
|
+
var se = {
|
|
12
|
+
previousMonth: "Previous month",
|
|
13
|
+
nextMonth: "Next month"
|
|
14
|
+
}, C = (e) => e.year * 12 + e.month - 1, w = (e) => ({
|
|
15
|
+
year: Math.floor(e / 12),
|
|
16
|
+
month: e % 12 + 1
|
|
17
|
+
}), T = (e) => {
|
|
18
|
+
let t = e ? /^(\d{4})-(\d{2})$/.exec(e) : null;
|
|
19
|
+
if (!t) return null;
|
|
20
|
+
let n = Number(t[2]);
|
|
21
|
+
return n >= 1 && n <= 12 ? {
|
|
22
|
+
year: Number(t[1]),
|
|
23
|
+
month: n
|
|
24
|
+
} : null;
|
|
25
|
+
}, E = (e) => `${h(e.year, 4)}-${h(e.month)}`;
|
|
26
|
+
function ce(e, t) {
|
|
27
|
+
let n = {
|
|
28
|
+
year: e.year,
|
|
29
|
+
month: e.month,
|
|
30
|
+
day: 1
|
|
31
|
+
}, r = (d(n) - t + 7) % 7, i = f(e.year, e.month);
|
|
32
|
+
return Array.from({ length: 6 }, (e, t) => Array.from({ length: 7 }, (e, a) => {
|
|
33
|
+
let o = t * 7 + a - r + 1;
|
|
34
|
+
return o >= 1 && o <= i ? {
|
|
35
|
+
...n,
|
|
36
|
+
day: o
|
|
37
|
+
} : null;
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
var D = v(function(h, v) {
|
|
41
|
+
let { mode: D = "single", value: O, defaultValue: ue, onValueChange: de, min: fe, max: pe, isDateDisabled: me, firstDayOfWeek: he, locale: k = o, timeZone: ge, months: A = 1, month: j, defaultMonth: _e, onMonthChange: ve, disabled: M = !1, readOnly: ye = !1, autoFocus: be = !1, labels: xe, className: Se, ...Ce } = h, N = {
|
|
42
|
+
...se,
|
|
43
|
+
...xe
|
|
44
|
+
}, we = oe(), P = y(null), Te = r(v, P), Ee = i(de), [De, Oe] = b(ue ?? (D === "range" ? le : "")), F = O ?? De, I = typeof F == "string" ? {
|
|
45
|
+
start: g(F),
|
|
46
|
+
end: g(F)
|
|
47
|
+
} : {
|
|
48
|
+
start: g(F.start),
|
|
49
|
+
end: g(F.end)
|
|
50
|
+
}, L = g(fe ?? ""), R = g(pe ?? ""), z = re(ge), B = (he ?? ee(k)) % 7, ke = !M && !ye, [V, H] = b(() => l(I.start ?? z, L, R)), [Ae, je] = b(() => T(_e) ?? {
|
|
51
|
+
year: V.year,
|
|
52
|
+
month: V.month
|
|
53
|
+
}), U = T(j) ?? Ae, [W, G] = b(null), K = y(be), q = (e) => {
|
|
54
|
+
C(e) !== C(U) && (j === void 0 && je(e), ve?.(E(e)));
|
|
55
|
+
}, J = (e) => L !== null && u(e, L) < 0 || R !== null && u(e, R) > 0 || (me?.(p(e)) ?? !1), Me = (e) => {
|
|
56
|
+
let t = l(e, L, R), n = C(U), r = C(t);
|
|
57
|
+
r < n ? q(w(r)) : r > n + A - 1 && q(w(r - A + 1)), K.current = !0, H(t);
|
|
58
|
+
}, Y = C(U), X = C(V);
|
|
59
|
+
if (X < Y || X > Y + A - 1) {
|
|
60
|
+
let e = Math.min(V.day, f(U.year, U.month)), t = l({
|
|
61
|
+
...U,
|
|
62
|
+
day: e
|
|
63
|
+
}, L, R), n = C(t);
|
|
64
|
+
H(n < Y || n > Y + A - 1 ? {
|
|
65
|
+
...U,
|
|
66
|
+
day: e
|
|
67
|
+
} : t);
|
|
68
|
+
}
|
|
69
|
+
ae(() => {
|
|
70
|
+
K.current && (K.current = !1, P.current?.querySelector(`[data-date="${p(V)}"]`)?.focus());
|
|
71
|
+
}, [V, U]);
|
|
72
|
+
let Ne = (e) => {
|
|
73
|
+
if (H(e), !ke || J(e)) return;
|
|
74
|
+
let t = p(e), n;
|
|
75
|
+
n = D === "single" ? t : !I.start || I.end ? {
|
|
76
|
+
start: t,
|
|
77
|
+
end: ""
|
|
78
|
+
} : u(e, I.start) < 0 ? {
|
|
79
|
+
start: t,
|
|
80
|
+
end: p(I.start)
|
|
81
|
+
} : {
|
|
82
|
+
start: p(I.start),
|
|
83
|
+
end: t
|
|
84
|
+
}, O === void 0 && Oe(n), Ee.current?.(n);
|
|
85
|
+
}, Pe = (e) => {
|
|
86
|
+
let t = P.current && getComputedStyle(P.current).direction === "rtl" ? -1 : 1, n = (d(V) - B + 7) % 7, r = {
|
|
87
|
+
ArrowLeft: () => s(V, -t),
|
|
88
|
+
ArrowRight: () => s(V, t),
|
|
89
|
+
ArrowUp: () => s(V, -7),
|
|
90
|
+
ArrowDown: () => s(V, 7),
|
|
91
|
+
Home: () => s(V, -n),
|
|
92
|
+
End: () => s(V, 6 - n),
|
|
93
|
+
PageUp: () => c(V, e.shiftKey ? -12 : -1),
|
|
94
|
+
PageDown: () => c(V, e.shiftKey ? 12 : 1)
|
|
95
|
+
}[e.key];
|
|
96
|
+
if (r) {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
let t = r();
|
|
99
|
+
Me(t), D === "range" && G(t);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), Ne(V));
|
|
103
|
+
}, Fe = (e) => {
|
|
104
|
+
let t = w(C(U) + e);
|
|
105
|
+
q(t);
|
|
106
|
+
let n = w(C(V) + e);
|
|
107
|
+
H(l({
|
|
108
|
+
...n,
|
|
109
|
+
day: Math.min(V.day, f(n.year, n.month))
|
|
110
|
+
}, L, R));
|
|
111
|
+
}, Z = D === "range" && I.start !== null && I.end === null, Q = D === "range" ? I.start : null, $ = D === "range" ? I.end : null;
|
|
112
|
+
Z && W && I.start && ([Q, $] = u(W, I.start) < 0 ? [W, I.start] : [I.start, W]);
|
|
113
|
+
let Ie = ie(k, B), Le = Array.from({ length: A }, (e, t) => w(C(U) + t)), Re = !L || C(U) > C(L), ze = !R || C(U) + A - 1 < C(R);
|
|
114
|
+
return /* @__PURE__ */ x("div", {
|
|
115
|
+
ref: Te,
|
|
116
|
+
role: "group",
|
|
117
|
+
className: e(_.root, Se),
|
|
118
|
+
"data-mode": D,
|
|
119
|
+
"data-months": A,
|
|
120
|
+
"data-disabled": M || void 0,
|
|
121
|
+
"aria-disabled": M || void 0,
|
|
122
|
+
...Ce,
|
|
123
|
+
children: /* @__PURE__ */ x("div", {
|
|
124
|
+
className: _.months,
|
|
125
|
+
children: Le.map((e, r) => {
|
|
126
|
+
let i = `${we}-title-${String(r)}`, o = r === A - 1;
|
|
127
|
+
return /* @__PURE__ */ S("div", {
|
|
128
|
+
className: _.month,
|
|
129
|
+
children: [/* @__PURE__ */ S("div", {
|
|
130
|
+
className: _.header,
|
|
131
|
+
children: [/* @__PURE__ */ x("div", {
|
|
132
|
+
id: i,
|
|
133
|
+
className: _.title,
|
|
134
|
+
"aria-live": "polite",
|
|
135
|
+
children: ne(k, e.year, e.month)
|
|
136
|
+
}), o ? /* @__PURE__ */ S("div", {
|
|
137
|
+
className: _.nav,
|
|
138
|
+
children: [/* @__PURE__ */ x(a, {
|
|
139
|
+
variant: "ghost",
|
|
140
|
+
size: "sm",
|
|
141
|
+
label: N.previousMonth,
|
|
142
|
+
icon: /* @__PURE__ */ x(t, {}),
|
|
143
|
+
disabled: M || !Re,
|
|
144
|
+
onClick: () => {
|
|
145
|
+
Fe(-1);
|
|
146
|
+
}
|
|
147
|
+
}), /* @__PURE__ */ x(a, {
|
|
148
|
+
variant: "ghost",
|
|
149
|
+
size: "sm",
|
|
150
|
+
label: N.nextMonth,
|
|
151
|
+
icon: /* @__PURE__ */ x(n, {}),
|
|
152
|
+
disabled: M || !ze,
|
|
153
|
+
onClick: () => {
|
|
154
|
+
Fe(1);
|
|
155
|
+
}
|
|
156
|
+
})]
|
|
157
|
+
}) : null]
|
|
158
|
+
}), /* @__PURE__ */ S("table", {
|
|
159
|
+
role: "grid",
|
|
160
|
+
className: _.grid,
|
|
161
|
+
"aria-labelledby": i,
|
|
162
|
+
children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ x("tr", { children: Ie.map((e) => /* @__PURE__ */ x("th", {
|
|
163
|
+
scope: "col",
|
|
164
|
+
abbr: e.long,
|
|
165
|
+
className: _.weekday,
|
|
166
|
+
children: e.short
|
|
167
|
+
}, e.long)) }) }), /* @__PURE__ */ x("tbody", { children: ce(e, B).map((e, t) => /* @__PURE__ */ x("tr", { children: e.map((e, t) => {
|
|
168
|
+
if (!e) return /* @__PURE__ */ x("td", {
|
|
169
|
+
role: "gridcell",
|
|
170
|
+
className: _.empty
|
|
171
|
+
}, t);
|
|
172
|
+
let n = p(e), r = J(e), i = m(e, Q), a = m(e, $), o = Q !== null && $ !== null && u(e, Q) >= 0 && u(e, $) <= 0, s = D === "single" ? m(e, I.start) : m(e, I.start) || m(e, I.end) || !Z && o, c = m(e, V);
|
|
173
|
+
return /* @__PURE__ */ x("td", {
|
|
174
|
+
role: "gridcell",
|
|
175
|
+
className: _.day,
|
|
176
|
+
"data-date": n,
|
|
177
|
+
tabIndex: M ? void 0 : c ? 0 : -1,
|
|
178
|
+
"aria-label": te(k, e),
|
|
179
|
+
"aria-selected": s,
|
|
180
|
+
"aria-disabled": M || r || void 0,
|
|
181
|
+
"aria-current": m(e, z) ? "date" : void 0,
|
|
182
|
+
"data-today": m(e, z) || void 0,
|
|
183
|
+
"data-selected": s || void 0,
|
|
184
|
+
"data-unavailable": r || void 0,
|
|
185
|
+
"data-range-start": o && i || void 0,
|
|
186
|
+
"data-range-end": o && a || void 0,
|
|
187
|
+
"data-in-range": o || void 0,
|
|
188
|
+
"data-preview": Z && o || void 0,
|
|
189
|
+
onClick: () => {
|
|
190
|
+
Ne(e);
|
|
191
|
+
},
|
|
192
|
+
onKeyDown: Pe,
|
|
193
|
+
onFocus: () => {
|
|
194
|
+
c || H(e);
|
|
195
|
+
},
|
|
196
|
+
onPointerEnter: () => {
|
|
197
|
+
Z && G(e);
|
|
198
|
+
},
|
|
199
|
+
children: /* @__PURE__ */ x("span", {
|
|
200
|
+
className: _.dayText,
|
|
201
|
+
children: e.day
|
|
202
|
+
})
|
|
203
|
+
}, t);
|
|
204
|
+
}) }, t)) })]
|
|
205
|
+
})]
|
|
206
|
+
}, E(e));
|
|
207
|
+
})
|
|
208
|
+
})
|
|
209
|
+
});
|
|
210
|
+
}), le = {
|
|
211
|
+
start: "",
|
|
212
|
+
end: ""
|
|
213
|
+
};
|
|
214
|
+
//#endregion
|
|
215
|
+
export { D as Calendar };
|
|
216
|
+
|
|
217
|
+
//# sourceMappingURL=Calendar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Calendar.js","names":["styles","Calendar_module_default","DEFAULT_LABELS","monthIndex","m","monthFromIndex","index","parseMonth","match","text","month","formatMonth","pad","monthGrid","first","offset","dayOfWeek","firstDay","length","daysInMonth","day","row","column","Calendar","forwardRef","valueProp","DEFAULT_LOCALE","monthProp","labelsProp","rest","props","labels","autoId","useId","rootRef","useRef","composedRef","useMergedRefs","ref","onValueChangeRef","useLatest","onValueChange","internal","setInternal","useState","defaultValue","mode","EMPTY_RANGE","value","range","parseDate","minDate","min","maxDate","max","today","todayIn","timeZone","firstDayOfWeek","defaultFirstDayOfWeek","locale","interactive","disabled","readOnly","focused","setFocused","clampDate","internalMonth","setInternalMonth","defaultMonth","visible","hovered","setHovered","shouldFocus","autoFocus","setMonth","next","onMonthChange","isUnavailable","compareDates","date","isDateDisabled","formatDate","moveFocus","months","firstVisible","focusedIndex","select","iso","handleKeyDown","ahead","weekStart","move","addDays","addMonths","event","turnPage","step","targetMonth","pending","spanStart","spanEnd","weekdays","weekdayNames","visibleMonths","i","canGoBack","canGoForward","cx","className","titleId","monthNumber","last","formatMonthYear","IconButton","ChevronLeftIcon","ChevronRightIcon","weekday","week","unavailable","isStart","isSameDay","isEnd","inSpan","selected","isFocused","formatFullDate"],"sources":["../../../../src/components/inputs/Calendar/Calendar.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useId,\n useRef,\n useState,\n type HTMLAttributes,\n type KeyboardEvent,\n} from 'react'\nimport { ChevronLeftIcon, ChevronRightIcon } from '#icons'\nimport { cx } from '#utils/cx'\nimport { IconButton } from '#components/actions/IconButton'\nimport type { DateRangeValue } from '#components/inputs/DateRangeField'\nimport { useMergedRefs } from '#components/inputs/internal/refs'\nimport { useLatest } from '#components/inputs/internal/useLatest'\nimport {\n DEFAULT_LOCALE,\n addDays,\n addMonths,\n clampDate,\n compareDates,\n dayOfWeek,\n daysInMonth,\n defaultFirstDayOfWeek,\n formatDate,\n formatFullDate,\n formatMonthYear,\n isSameDay,\n pad,\n parseDate,\n todayIn,\n weekdayNames,\n type CalendarDate,\n} from '#components/inputs/internal/dates'\nimport styles from './Calendar.module.css'\n\n/** Accessible names of the calendar's own buttons. */\nexport interface CalendarLabels {\n /** Default `'Previous month'`. */\n previousMonth: string\n /** Default `'Next month'`. */\n nextMonth: string\n}\n\nconst DEFAULT_LABELS: CalendarLabels = {\n previousMonth: 'Previous month',\n nextMonth: 'Next month',\n}\n\ninterface CalendarCommonProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue'\n> {\n /** Earliest date that can be picked (`YYYY-MM-DD`). */\n min?: string\n /** Latest date that can be picked (`YYYY-MM-DD`). */\n max?: string\n /** Marks other dates unavailable: weekends, public holidays, booked nights. */\n isDateDisabled?: (date: string) => boolean\n /** 0 (Sunday) to 6 (Saturday). Defaults to the locale's own week. */\n firstDayOfWeek?: number\n /** BCP 47 locale for month and weekday names. Default `en-AU`. */\n locale?: string\n /** The zone \"today\" is read in. Defaults to the device's. */\n timeZone?: string\n /** How many months to show side by side (they wrap when narrow). Default `1`. */\n months?: 1 | 2\n /** The first month shown (`YYYY-MM`). Controlled. */\n month?: string\n /** The first month shown at first (`YYYY-MM`). Defaults to the selected or current month. */\n defaultMonth?: string\n onMonthChange?: (month: string) => void\n disabled?: boolean\n /** Dates can be focused and read but not picked. */\n readOnly?: boolean\n /** Focus the current day once mounted, as a picker's popover does. */\n autoFocus?: boolean\n labels?: Partial<CalendarLabels>\n}\n\nexport interface CalendarSingleProps extends CalendarCommonProps {\n /** `single` (default) picks one date; `range` picks a start and an end. */\n mode?: 'single'\n /** `YYYY-MM-DD`, or `''` for none. */\n value?: string\n defaultValue?: string\n onValueChange?: (value: string) => void\n}\n\nexport interface CalendarRangeProps extends CalendarCommonProps {\n mode: 'range'\n /** The first click sets `start` (and clears `end`), the second sets `end`. */\n value?: DateRangeValue\n defaultValue?: DateRangeValue\n onValueChange?: (value: DateRangeValue) => void\n}\n\nexport type CalendarProps = CalendarSingleProps | CalendarRangeProps\n\ninterface Month {\n year: number\n month: number\n}\n\nconst monthIndex = (m: Month) => m.year * 12 + m.month - 1\nconst monthFromIndex = (index: number): Month => ({\n year: Math.floor(index / 12),\n month: (index % 12) + 1,\n})\nconst parseMonth = (text: string | undefined): Month | null => {\n const match = text ? /^(\\d{4})-(\\d{2})$/.exec(text) : null\n if (!match) return null\n const month = Number(match[2])\n return month >= 1 && month <= 12 ? { year: Number(match[1]), month } : null\n}\nconst formatMonth = (m: Month) => `${pad(m.year, 4)}-${pad(m.month)}`\n\n/** Six rows of seven: every month the same height, so a popover never jumps. */\nfunction monthGrid(month: Month, firstDay: number): (CalendarDate | null)[][] {\n const first = { year: month.year, month: month.month, day: 1 }\n const offset = (dayOfWeek(first) - firstDay + 7) % 7\n const length = daysInMonth(month.year, month.month)\n return Array.from({ length: 6 }, (_, row) =>\n Array.from({ length: 7 }, (_, column) => {\n const day = row * 7 + column - offset + 1\n return day >= 1 && day <= length ? { ...first, day } : null\n }),\n )\n}\n\n/**\n * A month grid for picking a date or a range, with the full keyboard of a date grid.\n *\n * @remarks\n * `Calendar` shows one or two months as a grid of days. Click a day or move with the arrow keys\n * and press Enter. In `range` mode the first pick is the start and the second the end, with the\n * days between shaded as you go. `min`, `max` and `isDateDisabled` mark days that can't be picked;\n * they stay focusable, so a screen reader can still say why a date is missing. Month and weekday\n * names come from `locale`, and so does the first day of the week unless you set\n * `firstDayOfWeek`.\n *\n * {@link DateInput | DateInput}, {@link DateTimeInput | DateTimeInput} and\n * {@link DateRangePickerField | DateRangePickerField} open it in a popover. Use it on its own for a calendar\n * that's always visible, such as a booking page.\n *\n * ## Keyboard\n *\n * | Key | Moves to |\n * | --- | --- |\n * | Arrow keys | The previous or next day, or the same day in the previous or next week |\n * | Home / End | The first or last day of the week |\n * | Page Up / Page Down | The same day in the previous or next month |\n * | Shift + Page Up / Page Down | The same day in the previous or next year |\n * | Enter / Space | Picks the focused day |\n *\n * @privateRemarks\n * ARIA grid pattern: one `<table role=\"grid\">` per month, labelled by its title, with a roving\n * tabindex on the day cells (the focused date is the only tab stop). Cells outside the month are\n * empty, so two months side by side never show a date twice. Values are ISO strings; all date\n * maths goes through `internal/dates` (ADR 0042).\n *\n * <Calendar mode=\"range\" months={2} value={stay} onValueChange={setStay} />\n */\nexport const Calendar = forwardRef<HTMLDivElement, CalendarProps>(function Calendar(props, ref) {\n const {\n mode = 'single',\n value: valueProp,\n defaultValue,\n onValueChange,\n min,\n max,\n isDateDisabled,\n firstDayOfWeek,\n locale = DEFAULT_LOCALE,\n timeZone,\n months = 1,\n month: monthProp,\n defaultMonth,\n onMonthChange,\n disabled = false,\n readOnly = false,\n autoFocus = false,\n labels: labelsProp,\n className,\n ...rest\n } = props as CalendarCommonProps & {\n mode?: 'single' | 'range'\n value?: string | DateRangeValue\n defaultValue?: string | DateRangeValue\n onValueChange?: (value: string & DateRangeValue) => void\n }\n const labels = { ...DEFAULT_LABELS, ...labelsProp }\n const autoId = useId()\n const rootRef = useRef<HTMLDivElement>(null)\n const composedRef = useMergedRefs(ref, rootRef)\n const onValueChangeRef = useLatest(onValueChange)\n\n const [internal, setInternal] = useState(defaultValue ?? (mode === 'range' ? EMPTY_RANGE : ''))\n const value = valueProp ?? internal\n const range =\n typeof value === 'string'\n ? { start: parseDate(value), end: parseDate(value) }\n : { start: parseDate(value.start), end: parseDate(value.end) }\n const minDate = parseDate(min ?? '')\n const maxDate = parseDate(max ?? '')\n const today = todayIn(timeZone)\n const firstDay = (firstDayOfWeek ?? defaultFirstDayOfWeek(locale)) % 7\n const interactive = !disabled && !readOnly\n\n const [focused, setFocused] = useState<CalendarDate>(() =>\n clampDate(range.start ?? today, minDate, maxDate),\n )\n const [internalMonth, setInternalMonth] = useState<Month>(\n () => parseMonth(defaultMonth) ?? { year: focused.year, month: focused.month },\n )\n const visible = parseMonth(monthProp) ?? internalMonth\n const [hovered, setHovered] = useState<CalendarDate | null>(null)\n const shouldFocus = useRef(autoFocus)\n\n const setMonth = (next: Month) => {\n if (monthIndex(next) === monthIndex(visible)) return\n if (monthProp === undefined) setInternalMonth(next)\n onMonthChange?.(formatMonth(next))\n }\n\n const isUnavailable = (date: CalendarDate) =>\n (minDate !== null && compareDates(date, minDate) < 0) ||\n (maxDate !== null && compareDates(date, maxDate) > 0) ||\n (isDateDisabled?.(formatDate(date)) ?? false)\n\n // Keep the focused date on screen: arrowing past the last visible month turns the page.\n const moveFocus = (next: CalendarDate) => {\n const date = clampDate(next, minDate, maxDate)\n const first = monthIndex(visible)\n const index = monthIndex(date)\n if (index < first) setMonth(monthFromIndex(index))\n else if (index > first + months - 1) setMonth(monthFromIndex(index - months + 1))\n shouldFocus.current = true\n setFocused(date)\n }\n\n // A controlled month moving elsewhere takes the focused date with it.\n const firstVisible = monthIndex(visible)\n const focusedIndex = monthIndex(focused)\n if (focusedIndex < firstVisible || focusedIndex > firstVisible + months - 1) {\n const day = Math.min(focused.day, daysInMonth(visible.year, visible.month))\n const date = clampDate({ ...visible, day }, minDate, maxDate)\n const index = monthIndex(date)\n setFocused(\n index < firstVisible || index > firstVisible + months - 1 ? { ...visible, day } : date,\n )\n }\n\n useEffect(() => {\n if (!shouldFocus.current) return\n shouldFocus.current = false\n rootRef.current?.querySelector<HTMLElement>(`[data-date=\"${formatDate(focused)}\"]`)?.focus()\n }, [focused, visible])\n\n const select = (date: CalendarDate) => {\n setFocused(date)\n if (!interactive || isUnavailable(date)) return\n const iso = formatDate(date)\n let next: string | DateRangeValue\n if (mode === 'single') {\n next = iso\n } else if (!range.start || range.end) {\n next = { start: iso, end: '' }\n } else if (compareDates(date, range.start) < 0) {\n next = { start: iso, end: formatDate(range.start) }\n } else {\n next = { start: formatDate(range.start), end: iso }\n }\n if (valueProp === undefined) setInternal(next)\n onValueChangeRef.current?.(next as string & DateRangeValue)\n }\n\n const handleKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n const rtl = rootRef.current ? getComputedStyle(rootRef.current).direction === 'rtl' : false\n const ahead = rtl ? -1 : 1\n const weekStart = (dayOfWeek(focused) - firstDay + 7) % 7\n const moves: Record<string, () => CalendarDate> = {\n ArrowLeft: () => addDays(focused, -ahead),\n ArrowRight: () => addDays(focused, ahead),\n ArrowUp: () => addDays(focused, -7),\n ArrowDown: () => addDays(focused, 7),\n Home: () => addDays(focused, -weekStart),\n End: () => addDays(focused, 6 - weekStart),\n PageUp: () => addMonths(focused, event.shiftKey ? -12 : -1),\n PageDown: () => addMonths(focused, event.shiftKey ? 12 : 1),\n }\n const move = moves[event.key]\n if (move) {\n event.preventDefault()\n const next = move()\n moveFocus(next)\n if (mode === 'range') setHovered(next)\n return\n }\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n select(focused)\n }\n }\n\n const turnPage = (step: 1 | -1) => {\n const next = monthFromIndex(monthIndex(visible) + step)\n setMonth(next)\n const target = monthIndex(focused) + step\n const targetMonth = monthFromIndex(target)\n setFocused(\n clampDate(\n {\n ...targetMonth,\n day: Math.min(focused.day, daysInMonth(targetMonth.year, targetMonth.month)),\n },\n minDate,\n maxDate,\n ),\n )\n }\n\n // The shaded span: the chosen range, or start → the hovered day while the end is pending.\n const pending = mode === 'range' && range.start !== null && range.end === null\n let spanStart = mode === 'range' ? range.start : null\n let spanEnd = mode === 'range' ? range.end : null\n if (pending && hovered && range.start) {\n ;[spanStart, spanEnd] =\n compareDates(hovered, range.start) < 0 ? [hovered, range.start] : [range.start, hovered]\n }\n\n const weekdays = weekdayNames(locale, firstDay)\n const visibleMonths = Array.from({ length: months }, (_, i) =>\n monthFromIndex(monthIndex(visible) + i),\n )\n const canGoBack = !minDate || monthIndex(visible) > monthIndex(minDate)\n const canGoForward = !maxDate || monthIndex(visible) + months - 1 < monthIndex(maxDate)\n\n return (\n <div\n ref={composedRef}\n role=\"group\"\n className={cx(styles.root, className)}\n data-mode={mode}\n data-months={months}\n data-disabled={disabled || undefined}\n aria-disabled={disabled || undefined}\n {...rest}\n >\n <div className={styles.months}>\n {visibleMonths.map((month, monthNumber) => {\n const titleId = `${autoId}-title-${String(monthNumber)}`\n const last = monthNumber === months - 1\n return (\n <div key={formatMonth(month)} className={styles.month}>\n <div className={styles.header}>\n <div id={titleId} className={styles.title} aria-live=\"polite\">\n {formatMonthYear(locale, month.year, month.month)}\n </div>\n {last ? (\n <div className={styles.nav}>\n <IconButton\n variant=\"ghost\"\n size=\"sm\"\n label={labels.previousMonth}\n icon={<ChevronLeftIcon />}\n disabled={disabled || !canGoBack}\n onClick={() => {\n turnPage(-1)\n }}\n />\n <IconButton\n variant=\"ghost\"\n size=\"sm\"\n label={labels.nextMonth}\n icon={<ChevronRightIcon />}\n disabled={disabled || !canGoForward}\n onClick={() => {\n turnPage(1)\n }}\n />\n </div>\n ) : null}\n </div>\n <table role=\"grid\" className={styles.grid} aria-labelledby={titleId}>\n <thead>\n <tr>\n {weekdays.map((weekday) => (\n <th\n key={weekday.long}\n scope=\"col\"\n abbr={weekday.long}\n className={styles.weekday}\n >\n {weekday.short}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {monthGrid(month, firstDay).map((week, row) => (\n <tr key={row}>\n {week.map((date, column) => {\n if (!date)\n return <td key={column} role=\"gridcell\" className={styles.empty} />\n const iso = formatDate(date)\n const unavailable = isUnavailable(date)\n const isStart = isSameDay(date, spanStart)\n const isEnd = isSameDay(date, spanEnd)\n const inSpan =\n spanStart !== null &&\n spanEnd !== null &&\n compareDates(date, spanStart) >= 0 &&\n compareDates(date, spanEnd) <= 0\n const selected =\n mode === 'single'\n ? isSameDay(date, range.start)\n : isSameDay(date, range.start) ||\n isSameDay(date, range.end) ||\n (!pending && inSpan)\n const isFocused = isSameDay(date, focused)\n return (\n <td\n key={column}\n role=\"gridcell\"\n className={styles.day}\n data-date={iso}\n tabIndex={disabled ? undefined : isFocused ? 0 : -1}\n aria-label={formatFullDate(locale, date)}\n aria-selected={selected}\n aria-disabled={disabled || unavailable || undefined}\n aria-current={isSameDay(date, today) ? 'date' : undefined}\n data-today={isSameDay(date, today) || undefined}\n data-selected={selected || undefined}\n data-unavailable={unavailable || undefined}\n data-range-start={(inSpan && isStart) || undefined}\n data-range-end={(inSpan && isEnd) || undefined}\n data-in-range={inSpan || undefined}\n data-preview={(pending && inSpan) || undefined}\n onClick={() => {\n select(date)\n }}\n onKeyDown={handleKeyDown}\n onFocus={() => {\n if (!isFocused) setFocused(date)\n }}\n onPointerEnter={() => {\n if (pending) setHovered(date)\n }}\n >\n <span className={styles.dayText}>{date.day}</span>\n </td>\n )\n })}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )\n })}\n </div>\n </div>\n )\n})\n\nconst EMPTY_RANGE: DateRangeValue = { start: '', end: '' }\n"],"mappings":";;;;;;;;;;AA4CA,IAAME,KAAiC;CACrC,eAAe;CACf,WAAW;AACb,GAyDMC,KAAc,MAAaC,EAAE,OAAO,KAAKA,EAAE,QAAQ,GACnDC,KAAkB,OAA0B;CAChD,MAAM,KAAK,MAAMC,IAAQ,EAAE;CAC3B,OAAQA,IAAQ,KAAM;AACxB,IACMC,KAAc,MAA2C;CAC7D,IAAMC,IAAQC,IAAO,oBAAoB,KAAKA,CAAI,IAAI;CACtD,IAAI,CAACD,GAAO,OAAO;CACnB,IAAME,IAAQ,OAAOF,EAAM,EAAE;CAC7B,OAAOE,KAAS,KAAKA,KAAS,KAAK;EAAE,MAAM,OAAOF,EAAM,EAAE;EAAG;CAAM,IAAI;AACzE,G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B,CAAK,KAAK,KAAA;QACtC,iBAAeqE,KAAY,KAAA;QAC3B,oBAAkBL,KAAe,KAAA;QACjC,oBAAmBI,KAAUH,KAAY,KAAA;QACzC,kBAAiBG,KAAUD,KAAU,KAAA;QACrC,iBAAeC,KAAU,KAAA;QACzB,gBAAexB,KAAWwB,KAAW,KAAA;QACrC,eAAe;SACb,GAAO3C,CAAI;QACb;QACA,WAAWS;QACX,eAAe;SACb,AAAKoC,KAAW5D,EAAWe,CAAI;QACjC;QACA,sBAAsB;SACpB,AAAImB,KAAS3B,EAAWQ,CAAI;QAC9B;QAEA,UAAA,kBAAC,QAAD;SAAM,WAAWhF,EAAO;SAAU,UAAAgF,EAAK;QAAU,CAAA;OAC/C,GA5BG1D,CA4BH;MAER,CAAC,EACC,GArDKD,CAqDL,CACL,EACI,CAAA,CACF;KACJ,CAAA,CAAA;IAxGK,GAAAV,EAAYD,CAAK,CAwGtB;GAET,CAAC;EACE,CAAA;CACF,CAAA;AAET,CAAC,GAEKqC,KAA8B;CAAE,OAAO;CAAI,KAAK;AAAG"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/components/inputs/Calendar/Calendar.module.css
|
|
2
|
+
var e = "kiln-Calendar__root", t = "kiln-Calendar__months", n = "kiln-Calendar__month", r = "kiln-Calendar__header", i = "kiln-Calendar__title", a = "kiln-Calendar__nav", o = "kiln-Calendar__grid", s = "kiln-Calendar__weekday", c = "kiln-Calendar__empty", l = "kiln-Calendar__day", u = "kiln-Calendar__dayText", d = {
|
|
3
|
+
root: e,
|
|
4
|
+
months: t,
|
|
5
|
+
month: n,
|
|
6
|
+
header: r,
|
|
7
|
+
title: i,
|
|
8
|
+
nav: a,
|
|
9
|
+
grid: o,
|
|
10
|
+
weekday: s,
|
|
11
|
+
empty: c,
|
|
12
|
+
day: l,
|
|
13
|
+
dayText: u
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { l as day, u as dayText, d as default, c as empty, o as grid, r as header, n as month, t as months, a as nav, e as root, i as title, s as weekday };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=Calendar.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Calendar.module.js","names":["root","months","month","header","title","nav","grid","weekday","empty","day","dayText","Calendar_module_default"],"sources":["../../../../src/components/inputs/Calendar/Calendar.module.css"],"sourcesContent":["/*\n * A month (or two) of days. Figures are tabular in the theme's numeric face so columns line\n * up; the picked day takes the accent, a range's days between take the soft accent as one\n * continuous band, and today is underlined rather than coloured, so it never reads as picked.\n *\n * Component tokens:\n * --calendar-cell-size default var(--control-md)\n * --calendar-day-radius default var(--radius-action)\n * --calendar-selected-bg default var(--color-accent)\n * --calendar-selected-ink default var(--color-accent-ink)\n * --calendar-range-bg default var(--color-accent-soft)\n */\n.root {\n --_cell: var(--calendar-cell-size, var(--control-md));\n\n display: inline-flex;\n flex-direction: column;\n max-inline-size: 100%;\n color: var(--color-ink);\n font-family: var(--font-text);\n}\n\n.months {\n display: flex;\n flex-wrap: wrap;\n gap: var(--space-5);\n}\n\n.month {\n display: flex;\n flex-direction: column;\n gap: var(--space-2);\n}\n\n.header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--space-2);\n min-block-size: var(--control-sm);\n padding-inline-start: var(--space-2);\n}\n\n.title {\n font-family: var(--heading-font);\n font-size: var(--text-md);\n font-weight: var(--heading-weight);\n letter-spacing: var(--heading-tracking);\n font-variant-numeric: tabular-nums lining-nums;\n}\n\n.nav {\n display: inline-flex;\n gap: var(--space-1);\n}\n\n.grid {\n border-collapse: collapse;\n border-spacing: 0;\n table-layout: fixed;\n}\n\n.weekday {\n inline-size: var(--_cell);\n padding-block-end: var(--space-1);\n color: var(--color-ink-muted);\n font-size: var(--text-xs);\n font-weight: var(--label-weight);\n letter-spacing: var(--label-tracking);\n text-align: center;\n text-transform: var(--label-transform);\n}\n\n.empty,\n.day {\n inline-size: var(--_cell);\n block-size: var(--_cell);\n padding: 0;\n}\n\n.day {\n position: relative;\n outline: none;\n font-family: var(--font-numeric);\n font-size: var(--text-sm);\n font-stretch: var(--numeric-stretch);\n font-variant-numeric: tabular-nums lining-nums;\n text-align: center;\n cursor: pointer;\n}\n\n.dayText {\n position: relative;\n z-index: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n inline-size: 100%;\n block-size: 100%;\n border-radius: var(--calendar-day-radius, var(--radius-action));\n transition:\n background-color var(--dur-1) var(--ease-out),\n color var(--dur-1) var(--ease-out);\n}\n\n@media (hover: hover) {\n .day:hover:not([aria-disabled='true'], [data-selected]) .dayText {\n background-color: var(--color-surface-sunken);\n }\n}\n\n.day:focus-visible {\n z-index: 2;\n}\n.day:focus-visible .dayText {\n outline: 2px solid var(--color-focus);\n outline-offset: 2px;\n}\n\n/* Today: an underline, not a fill, so it never reads as the picked day. */\n.day[data-today] .dayText {\n text-decoration: underline;\n text-decoration-thickness: 2px;\n text-underline-offset: 0.3em;\n}\n\n/* The band between a range's ends; at each end it reaches only the inner half. */\n.day[data-in-range]::before {\n position: absolute;\n inset: 0;\n background-color: var(--calendar-range-bg, var(--color-accent-soft));\n content: '';\n}\n.day[data-range-start]::before {\n inset-inline-start: 50%;\n}\n.day[data-range-end]::before {\n inset-inline-end: 50%;\n}\n.day[data-range-start][data-range-end]::before {\n content: none;\n}\n\n.day[data-selected] .dayText,\n.day[data-preview][data-range-start] .dayText,\n.day[data-preview][data-range-end] .dayText {\n background-color: var(--calendar-selected-bg, var(--color-accent));\n color: var(--calendar-selected-ink, var(--color-accent-ink));\n}\n.day[data-in-range][data-selected]:not([data-range-start], [data-range-end]) .dayText {\n background-color: transparent;\n color: var(--color-ink);\n}\n\n/* Unavailable: struck through as well as faded, so it doesn't rest on colour alone. */\n.day[aria-disabled='true'] {\n color: var(--color-ink-subtle);\n cursor: not-allowed;\n}\n.day[data-unavailable] .dayText {\n text-decoration: line-through;\n}\n\n.root[data-disabled] {\n opacity: 0.6;\n}\n"],"mappings":""}
|
|
@@ -2,44 +2,36 @@ import { cx as e } from "../../../utils/cx.js";
|
|
|
2
2
|
import { CheckIcon as t, ChevronDownIcon as n, CloseIcon as r } from "../../../icons/icons.js";
|
|
3
3
|
import { useMergedRefs as i } from "../internal/refs.js";
|
|
4
4
|
import { Spinner as a } from "../../feedback/Spinner/Spinner.js";
|
|
5
|
-
import {
|
|
6
|
-
import te from "../internal/
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
5
|
+
import { PortalAnchorContext as ee, usePortalTheme as o } from "../../overlays/usePortalTheme.js";
|
|
6
|
+
import { markFieldAware as te, useResolvedField as ne } from "../internal/FieldContext.js";
|
|
7
|
+
import re from "../internal/messages.module.js";
|
|
8
|
+
import ie from "../internal/control.module.js";
|
|
9
|
+
import { useControllableState as s } from "./useControllableState.js";
|
|
10
|
+
import { Tag as ae, TagList as oe } from "../../display/Tag/Tag.js";
|
|
11
|
+
import { filterOptions as se, foldText as ce, groupOptions as c } from "../internal/filterOptions.js";
|
|
12
12
|
import l from "./Combobox.module.js";
|
|
13
|
-
import { forwardRef as u, useCallback as d, useEffect as f, useId as
|
|
13
|
+
import { forwardRef as u, useCallback as d, useEffect as f, useId as le, useMemo as ue, useRef as p, useState as m } from "react";
|
|
14
14
|
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
15
15
|
import { Popover as _ } from "radix-ui";
|
|
16
16
|
//#region src/components/inputs/Combobox/Combobox.tsx
|
|
17
|
-
function
|
|
18
|
-
let r = n ?
|
|
19
|
-
for (let e of r) {
|
|
20
|
-
let t = e.group === void 0 ? "" : `g:${e.group}`, n = a.get(t);
|
|
21
|
-
n || (n = {
|
|
22
|
-
key: t,
|
|
23
|
-
label: e.group,
|
|
24
|
-
options: []
|
|
25
|
-
}, a.set(t, n), i.push(n)), n.options.push(e);
|
|
26
|
-
}
|
|
17
|
+
function de(e, t, n) {
|
|
18
|
+
let r = n ? se(e, t) : [...e], i = c(r);
|
|
27
19
|
return {
|
|
28
20
|
sections: i,
|
|
29
21
|
ordered: i.flatMap((e) => e.options)
|
|
30
22
|
};
|
|
31
23
|
}
|
|
32
24
|
var v = (e) => `Remove ${e}`;
|
|
33
|
-
function
|
|
25
|
+
function fe(e) {
|
|
34
26
|
if (e.multiple === !0) {
|
|
35
|
-
let { multiple: t, value: n, defaultValue: r, onValueChange: i, maxSelected: a, removeLabel:
|
|
36
|
-
return [
|
|
27
|
+
let { multiple: t, value: n, defaultValue: r, onValueChange: i, maxSelected: a, removeLabel: ee, ...o } = e;
|
|
28
|
+
return [o, {
|
|
37
29
|
multiple: t,
|
|
38
30
|
value: n,
|
|
39
31
|
defaultValue: r ?? [],
|
|
40
32
|
emit: (e) => i?.([...e]),
|
|
41
33
|
maxSelected: a,
|
|
42
|
-
removeLabel:
|
|
34
|
+
removeLabel: ee ?? v
|
|
43
35
|
}];
|
|
44
36
|
}
|
|
45
37
|
let { multiple: t, value: n, defaultValue: r, onValueChange: i, ...a } = e;
|
|
@@ -52,15 +44,15 @@ function de(e) {
|
|
|
52
44
|
removeLabel: v
|
|
53
45
|
}];
|
|
54
46
|
}
|
|
55
|
-
function
|
|
47
|
+
function pe(e) {
|
|
56
48
|
let t = e?.closest("[data-theme]");
|
|
57
49
|
return t && t !== e?.ownerDocument.documentElement ? t : void 0;
|
|
58
50
|
}
|
|
59
|
-
function
|
|
51
|
+
function me(e) {
|
|
60
52
|
return `${String(e)} ${e === 1 ? "option" : "options"} available`;
|
|
61
53
|
}
|
|
62
|
-
var
|
|
63
|
-
let r =
|
|
54
|
+
var he = u(function({ children: e, onInteractOutside: t }, n) {
|
|
55
|
+
let r = o();
|
|
64
56
|
return /* @__PURE__ */ h(_.Content, {
|
|
65
57
|
ref: n,
|
|
66
58
|
className: l.popup,
|
|
@@ -85,8 +77,8 @@ var me = u(function({ children: e, onInteractOutside: t }, n) {
|
|
|
85
77
|
...r,
|
|
86
78
|
children: e
|
|
87
79
|
});
|
|
88
|
-
}),
|
|
89
|
-
let [
|
|
80
|
+
}), ge = te(u(function(o, te) {
|
|
81
|
+
let [se, c] = fe(o), { options: u, inputValue: v, defaultInputValue: ge, onInputValueChange: _e, filter: ve = "auto", loading: y = !1, loadingMessage: ye = "Loading…", emptyMessage: b = "No matches", open: be, defaultOpen: xe = !1, onOpenChange: Se, creatable: x = !1, clearable: Ce = !1, clearLabel: we = "Clear", size: Te = "md", invalid: Ee, id: De, disabled: Oe, required: ke, readOnly: Ae, name: S, form: je, placeholder: Me, className: Ne, style: Pe, onKeyDown: Fe, onBlur: Ie, onClick: Le, "aria-describedby": Re, "aria-invalid": ze, "aria-label": Be, "aria-labelledby": Ve, ...He } = se, { multiple: C, maxSelected: Ue, removeLabel: We } = c, w = ne({
|
|
90
82
|
id: De,
|
|
91
83
|
describedBy: Re,
|
|
92
84
|
invalid: Ee,
|
|
@@ -94,13 +86,13 @@ var me = u(function({ children: e, onInteractOutside: t }, n) {
|
|
|
94
86
|
required: ke,
|
|
95
87
|
disabled: Oe,
|
|
96
88
|
readOnly: Ae
|
|
97
|
-
}), Ge =
|
|
98
|
-
for (let e of
|
|
99
|
-
let A = d((e) =>
|
|
89
|
+
}), Ge = le(), T = w.id ?? `${Ge}combobox`, Ke = `${T}-listbox`, qe = `${T}-status`, E = !w.disabled && !w.readOnly, D = p(null), O = p(null), Je = i(te, D), k = p(/* @__PURE__ */ new Map());
|
|
90
|
+
for (let e of u) k.current.set(e.value, e.label);
|
|
91
|
+
let A = d((e) => u.find((t) => t.value === e)?.label ?? k.current.get(e) ?? e, [u]), [j, M] = s(c.value, c.defaultValue, c.emit), N = !C && j[0] !== void 0 ? A(j[0]) : "", [P, Ye] = s(v, ge ?? (C || c.defaultValue[0] === void 0 ? "" : A(c.defaultValue[0])), _e), Xe = p(P);
|
|
100
92
|
Xe.current = P;
|
|
101
93
|
let F = d((e) => {
|
|
102
94
|
e !== Xe.current && Ye(e);
|
|
103
|
-
}, [Ye]), [I, L] = m(!1), [R, Ze] =
|
|
95
|
+
}, [Ye]), [I, L] = m(!1), [R, Ze] = s(be, xe, Se), z = p(R);
|
|
104
96
|
z.current = R;
|
|
105
97
|
let B = d((e) => {
|
|
106
98
|
e !== z.current && Ze(e);
|
|
@@ -113,11 +105,11 @@ var me = u(function({ children: e, onInteractOutside: t }, n) {
|
|
|
113
105
|
N,
|
|
114
106
|
F
|
|
115
107
|
]);
|
|
116
|
-
let $e = ve === "auto" && (C || I), { sections: H, ordered: U } =
|
|
117
|
-
|
|
108
|
+
let $e = ve === "auto" && (C || I), { sections: H, ordered: U } = ue(() => de(u, P, $e), [
|
|
109
|
+
u,
|
|
118
110
|
P,
|
|
119
111
|
$e
|
|
120
|
-
]), et =
|
|
112
|
+
]), et = ue(() => new Map(u.map((e, t) => [e.value, t])), [u]), tt = (e) => `${T}-option-${String(et.get(e) ?? 0)}`, nt = C && Ue !== void 0 && j.length >= Ue, W = (e) => j.includes(e), G = (e) => !!e.disabled || nt && !W(e.value), K = U.filter((e) => !G(e)), q = P.trim(), rt = x && q !== "" && (C || I), it = !y && U.length === 0 && !rt, at = U.length > 0 || y || it, J = R && E && at, ot = J && !y && !x && q !== "" && (C || I), st = K.find((e) => e.value === Qe) ?? (ot ? K[0] : void 0), Y = J ? st : void 0, [ct, lt] = m(""), X = y ? "" : U.length === 0 ? typeof b == "string" ? b : "No matches" : me(U.length);
|
|
121
113
|
f(() => {
|
|
122
114
|
if (!J || X === "") {
|
|
123
115
|
J || lt("");
|
|
@@ -143,7 +135,7 @@ var me = u(function({ children: e, onInteractOutside: t }, n) {
|
|
|
143
135
|
}
|
|
144
136
|
}, Q = () => {
|
|
145
137
|
if (!x || q === "") return !1;
|
|
146
|
-
let e =
|
|
138
|
+
let e = ce(q), t = u.find((t) => !t.disabled && ce(t.label) === e), n = t?.value ?? q, r = t?.label ?? q;
|
|
147
139
|
return k.current.set(n, r), C ? (F(""), L(!1), W(n) || nt ? !1 : (M([...j, n]), !0)) : (L(!1), F(r), j[0] !== n && (M([n]), !0));
|
|
148
140
|
}, dt = (e) => {
|
|
149
141
|
E && M(j.filter((t) => t !== e));
|
|
@@ -240,13 +232,13 @@ var me = u(function({ children: e, onInteractOutside: t }, n) {
|
|
|
240
232
|
onOpenChange: (e) => {
|
|
241
233
|
e || B(!1);
|
|
242
234
|
},
|
|
243
|
-
children: /* @__PURE__ */ g(
|
|
235
|
+
children: /* @__PURE__ */ g(ee.Provider, {
|
|
244
236
|
value: O,
|
|
245
237
|
children: [/* @__PURE__ */ h(_.Anchor, {
|
|
246
238
|
asChild: !0,
|
|
247
239
|
children: /* @__PURE__ */ g("div", {
|
|
248
240
|
ref: O,
|
|
249
|
-
className: e(
|
|
241
|
+
className: e(ie.box, l.root, Ne),
|
|
250
242
|
style: Pe,
|
|
251
243
|
"data-size": Te,
|
|
252
244
|
"data-multiple": C || void 0,
|
|
@@ -259,11 +251,11 @@ var me = u(function({ children: e, onInteractOutside: t }, n) {
|
|
|
259
251
|
children: [
|
|
260
252
|
/* @__PURE__ */ g("div", {
|
|
261
253
|
className: l.values,
|
|
262
|
-
children: [C && j.length > 0 ? /* @__PURE__ */ h(
|
|
254
|
+
children: [C && j.length > 0 ? /* @__PURE__ */ h(oe, {
|
|
263
255
|
className: l.chips,
|
|
264
256
|
children: j.map((e) => {
|
|
265
257
|
let t = A(e);
|
|
266
|
-
return /* @__PURE__ */ h(
|
|
258
|
+
return /* @__PURE__ */ h(ae, {
|
|
267
259
|
className: l.chip,
|
|
268
260
|
onRemove: E ? () => {
|
|
269
261
|
dt(e), D.current?.focus();
|
|
@@ -341,14 +333,14 @@ var me = u(function({ children: e, onInteractOutside: t }, n) {
|
|
|
341
333
|
id: qe,
|
|
342
334
|
role: "status",
|
|
343
335
|
"aria-live": "polite",
|
|
344
|
-
className:
|
|
336
|
+
className: re.visuallyHidden,
|
|
345
337
|
children: ct
|
|
346
338
|
})
|
|
347
339
|
]
|
|
348
340
|
})
|
|
349
341
|
}), /* @__PURE__ */ h(_.Portal, {
|
|
350
|
-
container: J ?
|
|
351
|
-
children: /* @__PURE__ */ g(
|
|
342
|
+
container: J ? pe(O.current) : void 0,
|
|
343
|
+
children: /* @__PURE__ */ g(he, {
|
|
352
344
|
onInteractOutside: bt,
|
|
353
345
|
children: [
|
|
354
346
|
/* @__PURE__ */ h("div", {
|
|
@@ -389,6 +381,6 @@ var me = u(function({ children: e, onInteractOutside: t }, n) {
|
|
|
389
381
|
});
|
|
390
382
|
}));
|
|
391
383
|
//#endregion
|
|
392
|
-
export {
|
|
384
|
+
export { ge as Combobox };
|
|
393
385
|
|
|
394
386
|
//# sourceMappingURL=Combobox.js.map
|