@mechane-ai/elements 0.33.0 → 0.35.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/README.md +3 -1
- package/dist/ai.js +2 -2
- package/dist/{categorical-values-bWZBzMpX.js → categorical-values-DpnNvPkc.js} +2 -2
- package/dist/{chart-frame-Cr4P6MF5.js → chart-frame-BV0IPZtQ.js} +1 -1
- package/dist/{chart-input-3wX0JoPE.js → chart-input-CN8PMrni.js} +2 -2
- package/dist/charts/cartesian.js +539 -565
- package/dist/charts/distribution.js +2 -2
- package/dist/charts/graph.js +2 -2
- package/dist/charts/hierarchy.js +3 -3
- package/dist/charts/matrix.js +2 -2
- package/dist/charts/timeline.js +2 -2
- package/dist/charts.js +1 -1
- package/dist/collections.js +2 -2
- package/dist/content/tree.js +1 -1
- package/dist/elements.css +28 -0
- package/dist/feedback.js +1 -1
- package/dist/forms/dates.js +519 -73
- package/dist/forms-BQQFas9g.js +118 -0
- package/dist/forms.js +3 -1
- package/dist/navigation/commands.js +1 -1
- package/dist/packages/charts/src/chart-data.d.ts +1 -2
- package/dist/packages/forms/src/dates/calendar.d.ts +2 -5
- package/dist/packages/forms/src/dates/civil.d.ts +28 -0
- package/dist/packages/forms/src/dates/date-inputs.d.ts +20 -0
- package/dist/packages/forms/src/dates/date-picker.d.ts +13 -0
- package/dist/packages/forms/src/dates/date-range-picker.d.ts +14 -12
- package/dist/packages/forms/src/dates/index.d.ts +8 -0
- package/dist/packages/forms/src/dates/month-calendar.d.ts +19 -0
- package/dist/packages/forms/src/dates/month-picker.d.ts +14 -0
- package/dist/packages/forms/src/dates/month-range-picker.d.ts +18 -0
- package/dist/packages/forms/src/dates/picker-popover.d.ts +22 -0
- package/dist/{pierre-tree-Dd5Vd79M.js → pierre-tree-CYCRjdGG.js} +1 -1
- package/dist/{src-BOZsJ8td.js → src-BHllGfI8.js} +4 -4
- package/dist/{src-CD6veX7n.js → src-BYKjPC-0.js} +278 -387
- package/package.json +1 -1
package/dist/forms/dates.js
CHANGED
|
@@ -1,22 +1,108 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { n as e, t } from "../forms-BQQFas9g.js";
|
|
2
|
+
import { D as n, T as r, w as i } from "../src-C-Sx37kz.js";
|
|
3
|
+
import { r as a } from "../src-d7EAi61b.js";
|
|
3
4
|
import "@stylexjs/stylex";
|
|
4
|
-
import { useState as
|
|
5
|
-
import { jsx as
|
|
6
|
-
import { CalendarDays as
|
|
7
|
-
import { DayButton as
|
|
5
|
+
import { useEffect as o, useId as s, useRef as c, useState as l } from "react";
|
|
6
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
7
|
+
import { CalendarDays as p, ChevronLeft as m, ChevronRight as h } from "lucide-react";
|
|
8
|
+
import { DayButton as g, DayPicker as _, TZDate as v } from "@daypicker/react";
|
|
9
|
+
// packages/forms/src/dates/civil.ts
|
|
10
|
+
var y = {
|
|
11
|
+
maximumYear: 9999,
|
|
12
|
+
monthsPerYear: 12,
|
|
13
|
+
leapCycle: 4,
|
|
14
|
+
century: 100,
|
|
15
|
+
leapCentury: 400,
|
|
16
|
+
longMonthDays: 31,
|
|
17
|
+
shortMonthDays: 30,
|
|
18
|
+
februaryDays: 28,
|
|
19
|
+
leapFebruaryDays: 29,
|
|
20
|
+
yearDigits: 4,
|
|
21
|
+
componentDigits: 2
|
|
22
|
+
};
|
|
23
|
+
function b(e) {
|
|
24
|
+
return Number.isInteger(e.year) && e.year >= 1 && e.year <= y.maximumYear ? Number.isInteger(e.month) && e.month >= 1 && e.month <= y.monthsPerYear : !1;
|
|
25
|
+
}
|
|
26
|
+
function x(e) {
|
|
27
|
+
if (!b(e) || !Number.isInteger(e.day) || e.day < 1) return !1;
|
|
28
|
+
let t = e.year % y.leapCycle === 0 && (e.year % y.century !== 0 || e.year % y.leapCentury === 0) ? y.leapFebruaryDays : y.februaryDays, { longMonthDays: n, shortMonthDays: r } = y, i = [
|
|
29
|
+
n,
|
|
30
|
+
t,
|
|
31
|
+
n,
|
|
32
|
+
r,
|
|
33
|
+
n,
|
|
34
|
+
r,
|
|
35
|
+
n,
|
|
36
|
+
n,
|
|
37
|
+
r,
|
|
38
|
+
n,
|
|
39
|
+
r,
|
|
40
|
+
n
|
|
41
|
+
];
|
|
42
|
+
return e.day <= (i[e.month - 1] ?? 0);
|
|
43
|
+
}
|
|
44
|
+
function S(e) {
|
|
45
|
+
return e.year * y.monthsPerYear + e.month;
|
|
46
|
+
}
|
|
47
|
+
function C(e) {
|
|
48
|
+
return `${w(e)}-${String(e.day).padStart(y.componentDigits, "0")}`;
|
|
49
|
+
}
|
|
50
|
+
function w(e) {
|
|
51
|
+
return `${String(e.year).padStart(y.yearDigits, "0")}-${String(e.month).padStart(y.componentDigits, "0")}`;
|
|
52
|
+
}
|
|
53
|
+
function T(e) {
|
|
54
|
+
let [t = 0, n = 0, r = 0] = e.split("-").map(Number), i = {
|
|
55
|
+
year: t,
|
|
56
|
+
month: n,
|
|
57
|
+
day: r
|
|
58
|
+
};
|
|
59
|
+
return x(i) && C(i) === e ? i : void 0;
|
|
60
|
+
}
|
|
61
|
+
function E(e) {
|
|
62
|
+
let [t = 0, n = 0] = e.split("-").map(Number), r = {
|
|
63
|
+
year: t,
|
|
64
|
+
month: n
|
|
65
|
+
};
|
|
66
|
+
return b(r) && w(r) === e ? r : void 0;
|
|
67
|
+
}
|
|
68
|
+
function D(e, t) {
|
|
69
|
+
return x(e) ? new Intl.DateTimeFormat(t, {
|
|
70
|
+
dateStyle: "medium",
|
|
71
|
+
timeZone: "UTC",
|
|
72
|
+
calendar: "gregory"
|
|
73
|
+
}).format(Date.parse(`${C(e)}T12:00:00Z`)) : "Invalid date";
|
|
74
|
+
}
|
|
75
|
+
function O(e, t) {
|
|
76
|
+
return b(e) ? new Intl.DateTimeFormat(t, {
|
|
77
|
+
month: "short",
|
|
78
|
+
year: "numeric",
|
|
79
|
+
timeZone: "UTC",
|
|
80
|
+
calendar: "gregory"
|
|
81
|
+
}).format(Date.parse(`${w(e)}-01T12:00:00Z`)) : "Invalid month";
|
|
82
|
+
}
|
|
83
|
+
function k(e, t, n) {
|
|
84
|
+
if (!x(e)) return "Select a valid date.";
|
|
85
|
+
if (t !== void 0 && C(e) < C(t)) return `Select a date on or after ${C(t)}.`;
|
|
86
|
+
if (n !== void 0 && C(e) > C(n)) return `Select a date on or before ${C(n)}.`;
|
|
87
|
+
}
|
|
88
|
+
function A(e, t, n) {
|
|
89
|
+
if (!b(e)) return "Select a valid month.";
|
|
90
|
+
if (t !== void 0 && S(e) < S(t)) return `Select a month on or after ${w(t)}.`;
|
|
91
|
+
if (n !== void 0 && S(e) > S(n)) return `Select a month on or before ${w(n)}.`;
|
|
92
|
+
}
|
|
8
93
|
// packages/forms/src/dates/calendar.tsx
|
|
9
|
-
function
|
|
10
|
-
|
|
94
|
+
function j(e, t) {
|
|
95
|
+
let n = new v(0, t);
|
|
96
|
+
return n.setFullYear(e.year, e.month - 1, e.day), n.setHours(12, 0, 0, 0), n;
|
|
11
97
|
}
|
|
12
|
-
function
|
|
98
|
+
function M(e) {
|
|
13
99
|
return {
|
|
14
100
|
year: e.getFullYear(),
|
|
15
101
|
month: e.getMonth() + 1,
|
|
16
102
|
day: e.getDate()
|
|
17
103
|
};
|
|
18
104
|
}
|
|
19
|
-
function
|
|
105
|
+
function N({ className: e, modifiers: t, ...n }) {
|
|
20
106
|
let r = {
|
|
21
107
|
0: { className: "x9f619 x9c6wpo x1ff4b4a x1f9pz31 x992rv9 x1717udv xmkeg23 x1y0btm7 x9r1u3d x1ok0vyi xjbqb8w xbixft x1hz01jw xj57cvi xtqrqnz x1778rvt xss6m8b x1ypdohk xqqsu6m xzro3xz x13qnu6 x9v5kkp x19rmrnh x1bqaal x19tlqzf xtgyt42" },
|
|
22
108
|
8: { className: "x9f619 x9c6wpo x1ff4b4a x1f9pz31 x992rv9 x1717udv xmkeg23 x1y0btm7 x9r1u3d x1ok0vyi xjbqb8w x1hz01jw xj57cvi xtqrqnz x1778rvt xss6m8b x1ypdohk xqqsu6m xzro3xz x13qnu6 x9v5kkp x19rmrnh x1bqaal x19tlqzf xtgyt42 x153jb6y" },
|
|
@@ -35,27 +121,31 @@ function f({ className: e, modifiers: t, ...n }) {
|
|
|
35
121
|
7: { className: "x9f619 x9c6wpo x1ff4b4a x1f9pz31 x992rv9 x1717udv xmkeg23 x1y0btm7 x1hz01jw xj57cvi xtqrqnz x1778rvt xss6m8b x1ypdohk x13qnu6 x9v5kkp x19rmrnh x1bqaal x19tlqzf xtgyt42 x1ey3b81 x1j5cv7l x2u8bby xbixft x1r7kqkb xqqsu6m xzro3xz" },
|
|
36
122
|
15: { className: "x9f619 x9c6wpo x1ff4b4a x1f9pz31 x992rv9 x1717udv xmkeg23 x1y0btm7 x1hz01jw xj57cvi xtqrqnz x1778rvt xss6m8b x1ypdohk x13qnu6 x9v5kkp x19rmrnh x1bqaal x19tlqzf xtgyt42 x1ey3b81 x1j5cv7l x2u8bby xbixft x1r7kqkb xqqsu6m xzro3xz" }
|
|
37
123
|
}[(t.outside === !0) << 3 | (t.today === !0) << 2 | (t.selected === !0) << 1 | t.range_middle === !0];
|
|
38
|
-
return /* @__PURE__ */
|
|
124
|
+
return /* @__PURE__ */ d(g, {
|
|
39
125
|
...n,
|
|
40
126
|
modifiers: t,
|
|
41
127
|
className: [e, r.className].filter(Boolean).join(" ")
|
|
42
128
|
});
|
|
43
129
|
}
|
|
44
|
-
function
|
|
45
|
-
let { locale: t, timeZone: n,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
130
|
+
function P(e) {
|
|
131
|
+
let { locale: t, timeZone: n, weekStartsOn: r = 1, label: i } = e, a = x(e.today) ? e.today : {
|
|
132
|
+
year: 2e3,
|
|
133
|
+
month: 1,
|
|
134
|
+
day: 1
|
|
135
|
+
}, o = x(e.initialMonth) ? e.initialMonth : a, s = e.minimum !== void 0 && x(e.minimum) ? e.minimum : void 0, c = e.maximum !== void 0 && x(e.maximum) ? e.maximum : void 0, l = [];
|
|
136
|
+
s !== void 0 && l.push({ before: j(s, n) }), c !== void 0 && l.push({ after: j(c, n) });
|
|
137
|
+
let u = {
|
|
138
|
+
"aria-label": i,
|
|
49
139
|
timeZone: n,
|
|
50
140
|
noonSafe: !0,
|
|
51
141
|
autoFocus: e.autoFocus ?? !1,
|
|
52
|
-
weekStartsOn:
|
|
53
|
-
today:
|
|
54
|
-
defaultMonth:
|
|
55
|
-
startMonth:
|
|
56
|
-
disabled:
|
|
142
|
+
weekStartsOn: r,
|
|
143
|
+
today: j(a, n),
|
|
144
|
+
defaultMonth: j(o, n),
|
|
145
|
+
startMonth: s === void 0 ? void 0 : j(s, n),
|
|
146
|
+
disabled: l,
|
|
57
147
|
showOutsideDays: !0,
|
|
58
|
-
components: { DayButton:
|
|
148
|
+
components: { DayButton: N },
|
|
59
149
|
classNames: {
|
|
60
150
|
root: { className: "xbixft xpvm0e4 x1hz01jw xj57cvi xtqrqnz x1778rvt x1717udv xezivpi x193iq5w xw2csxc" }.className ?? "",
|
|
61
151
|
months: { className: "x78zum5 x1a02dak x1n2onr6 x1j825kq" }.className ?? "",
|
|
@@ -86,76 +176,137 @@ function p(e) {
|
|
|
86
176
|
}).format(e)
|
|
87
177
|
}
|
|
88
178
|
};
|
|
89
|
-
if (
|
|
90
|
-
...
|
|
179
|
+
if (c !== void 0 && (u.endMonth = j(c, n)), e.mode === "single") return /* @__PURE__ */ d(_, {
|
|
180
|
+
...u,
|
|
91
181
|
mode: "single",
|
|
92
|
-
selected: e.value
|
|
93
|
-
onSelect: (t) => e.onValueChange(t === void 0 ? void 0 :
|
|
182
|
+
selected: e.value !== void 0 && x(e.value) ? j(e.value, n) : void 0,
|
|
183
|
+
onSelect: (t) => e.onValueChange(t === void 0 ? void 0 : M(t))
|
|
94
184
|
}, n);
|
|
95
|
-
let
|
|
96
|
-
from:
|
|
97
|
-
to: e.value.to
|
|
185
|
+
let f = e.value === void 0 || !x(e.value.from) ? void 0 : {
|
|
186
|
+
from: j(e.value.from, n),
|
|
187
|
+
to: e.value.to !== void 0 && x(e.value.to) ? j(e.value.to, n) : void 0
|
|
98
188
|
};
|
|
99
|
-
return /* @__PURE__ */
|
|
100
|
-
...
|
|
189
|
+
return /* @__PURE__ */ d(_, {
|
|
190
|
+
...u,
|
|
101
191
|
mode: "range",
|
|
102
192
|
resetOnSelect: !0,
|
|
103
|
-
selected:
|
|
193
|
+
selected: f,
|
|
104
194
|
onSelect: (t) => e.onValueChange(t?.from === void 0 ? void 0 : {
|
|
105
|
-
from:
|
|
106
|
-
to: t.to === void 0 ? void 0 :
|
|
195
|
+
from: M(t.from),
|
|
196
|
+
to: t.to === void 0 ? void 0 : M(t.to)
|
|
107
197
|
})
|
|
108
198
|
}, n);
|
|
109
199
|
}
|
|
110
|
-
// packages/forms/src/dates/date-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
200
|
+
// packages/forms/src/dates/date-inputs.tsx
|
|
201
|
+
var F = { input: {
|
|
202
|
+
kzqmXN: "xh8yej3",
|
|
203
|
+
k7Eaqz: "xeuugli",
|
|
204
|
+
$$css: !0
|
|
205
|
+
} };
|
|
206
|
+
function I({ label: n, value: r, minimum: i, maximum: a, onValueChange: o }) {
|
|
207
|
+
return /* @__PURE__ */ f(t.Root, { children: [/* @__PURE__ */ d(t.Label, { children: n }), /* @__PURE__ */ d(e, {
|
|
208
|
+
type: "date",
|
|
209
|
+
value: r === void 0 ? "" : C(r),
|
|
210
|
+
min: i === void 0 ? "0001-01-01" : C(i),
|
|
211
|
+
max: a === void 0 ? "9999-12-31" : C(a),
|
|
212
|
+
onChange: (e) => o(T(e.target.value)),
|
|
213
|
+
xstyle: F.input
|
|
214
|
+
})] });
|
|
215
|
+
}
|
|
216
|
+
function L({ label: n, value: r, minimum: i, maximum: a, onValueChange: o }) {
|
|
217
|
+
return /* @__PURE__ */ f(t.Root, { children: [/* @__PURE__ */ d(t.Label, { children: n }), /* @__PURE__ */ d(e, {
|
|
218
|
+
type: "month",
|
|
219
|
+
value: r === void 0 ? "" : w(r),
|
|
220
|
+
min: i === void 0 ? "0001-01" : w(i),
|
|
221
|
+
max: a === void 0 ? "9999-12" : w(a),
|
|
222
|
+
onChange: (e) => o(E(e.target.value)),
|
|
223
|
+
xstyle: F.input
|
|
224
|
+
})] });
|
|
225
|
+
}
|
|
226
|
+
function R({ children: e }) {
|
|
227
|
+
return /* @__PURE__ */ d("div", {
|
|
228
|
+
className: "xrvj5dj xnby9oq x1hnptsi",
|
|
229
|
+
children: e
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
// packages/forms/src/dates/picker-popover.tsx
|
|
233
|
+
function z({ label: e, value: t, onValueChange: r, formatValue: o, validateValue: c, presets: u = [], density: m = "standard", disabled: h, isClearable: g = !0, timeZone: _, children: v }) {
|
|
234
|
+
let [y, b] = l(!1), [x, S] = l(t), C = s(), w = x === void 0 ? void 0 : c(x);
|
|
235
|
+
function T(e) {
|
|
236
|
+
r(e), b(!1);
|
|
237
|
+
}
|
|
238
|
+
return /* @__PURE__ */ f(a.Root, {
|
|
239
|
+
open: y,
|
|
240
|
+
onOpenChange: (e) => {
|
|
241
|
+
e && S(t), b(e);
|
|
242
|
+
},
|
|
243
|
+
children: [/* @__PURE__ */ f(a.Trigger, {
|
|
244
|
+
disabled: h,
|
|
245
|
+
render: /* @__PURE__ */ d(i, {
|
|
246
|
+
density: m,
|
|
247
|
+
variant: "outline"
|
|
248
|
+
}),
|
|
249
|
+
"aria-label": t === void 0 ? e : `${e}: ${o(t)}`,
|
|
250
|
+
children: [/* @__PURE__ */ d(p, {
|
|
121
251
|
size: 16,
|
|
122
252
|
"aria-hidden": "true"
|
|
123
|
-
}),
|
|
124
|
-
}), /* @__PURE__ */
|
|
125
|
-
align: "
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
253
|
+
}), t === void 0 ? e : o(t)]
|
|
254
|
+
}), /* @__PURE__ */ d(a.Portal, { children: /* @__PURE__ */ d(a.Positioner, {
|
|
255
|
+
align: "end",
|
|
256
|
+
collisionPadding: 1,
|
|
257
|
+
children: /* @__PURE__ */ d(a.Popup, {
|
|
258
|
+
"aria-label": e,
|
|
259
|
+
className: "x1vae6as x1rxfojk",
|
|
260
|
+
children: /* @__PURE__ */ f("div", {
|
|
261
|
+
className: "x78zum5 xdt5ytf x1n8ia3y xeuugli",
|
|
130
262
|
children: [
|
|
131
|
-
|
|
263
|
+
/* @__PURE__ */ d(a.Title, { children: e }),
|
|
264
|
+
u.length > 0 && /* @__PURE__ */ d("div", {
|
|
132
265
|
role: "group",
|
|
133
266
|
"aria-label": "Date presets",
|
|
134
267
|
className: "x78zum5 x1a02dak xunmzkg xmmm7uk xso031l x1q0q8m5 x1qndepd",
|
|
135
|
-
children:
|
|
268
|
+
children: u.map((e) => /* @__PURE__ */ d(i, {
|
|
136
269
|
variant: "ghost",
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
},
|
|
270
|
+
disabled: c(e.value) !== void 0,
|
|
271
|
+
onClick: () => T(e.value),
|
|
140
272
|
children: e.label
|
|
141
273
|
}, e.id))
|
|
142
274
|
}),
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
onValueChange: (e) => {
|
|
150
|
-
l(e), e?.to !== void 0 && g(!1);
|
|
151
|
-
}
|
|
275
|
+
y && v(x, S),
|
|
276
|
+
/* @__PURE__ */ d("div", {
|
|
277
|
+
id: C,
|
|
278
|
+
"aria-live": "polite",
|
|
279
|
+
className: "xr5kp14 xy8obcc xas2l8k",
|
|
280
|
+
children: w
|
|
152
281
|
}),
|
|
153
|
-
/* @__PURE__ */
|
|
154
|
-
className: "x78zum5 x1a02dak x1qughib
|
|
155
|
-
children: [/* @__PURE__ */
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
282
|
+
/* @__PURE__ */ f("div", {
|
|
283
|
+
className: "x78zum5 x1a02dak x6s0dn4 x1qughib x1hnptsi x3bg4vu x178xt8z x13fuv20 xhjagg4",
|
|
284
|
+
children: [/* @__PURE__ */ d("span", {
|
|
285
|
+
className: "x153jb6y xy8obcc xas2l8k",
|
|
286
|
+
children: _
|
|
287
|
+
}), /* @__PURE__ */ f("div", {
|
|
288
|
+
className: "x78zum5 x1a02dak x6s0dn4 x1hnptsi",
|
|
289
|
+
children: [
|
|
290
|
+
g && /* @__PURE__ */ d(n, {
|
|
291
|
+
disabled: t === void 0,
|
|
292
|
+
onClick: () => T(void 0),
|
|
293
|
+
children: "Clear"
|
|
294
|
+
}),
|
|
295
|
+
/* @__PURE__ */ d(i, {
|
|
296
|
+
variant: "ghost",
|
|
297
|
+
onClick: () => b(!1),
|
|
298
|
+
children: "Cancel"
|
|
299
|
+
}),
|
|
300
|
+
/* @__PURE__ */ d(i, {
|
|
301
|
+
variant: "solid",
|
|
302
|
+
disabled: x === void 0 || w !== void 0,
|
|
303
|
+
"aria-describedby": w === void 0 ? void 0 : C,
|
|
304
|
+
onClick: () => {
|
|
305
|
+
x !== void 0 && c(x) === void 0 && T(x);
|
|
306
|
+
},
|
|
307
|
+
children: "Apply"
|
|
308
|
+
})
|
|
309
|
+
]
|
|
159
310
|
})]
|
|
160
311
|
})
|
|
161
312
|
]
|
|
@@ -164,4 +315,299 @@ function m({ label: s, value: c, onValueChange: l, formatValue: u, presets: d =
|
|
|
164
315
|
}) })]
|
|
165
316
|
});
|
|
166
317
|
}
|
|
167
|
-
|
|
318
|
+
// packages/forms/src/dates/date-picker.tsx
|
|
319
|
+
function B({ label: e, value: t, onValueChange: n, formatValue: r, density: i, disabled: a, isClearable: o, ...s }) {
|
|
320
|
+
return /* @__PURE__ */ d(z, {
|
|
321
|
+
label: e,
|
|
322
|
+
value: t,
|
|
323
|
+
onValueChange: n,
|
|
324
|
+
formatValue: r ?? ((e) => D(e, s.locale)),
|
|
325
|
+
validateValue: (e) => k(e, s.minimum, s.maximum),
|
|
326
|
+
density: i,
|
|
327
|
+
disabled: a,
|
|
328
|
+
isClearable: o,
|
|
329
|
+
timeZone: s.timeZone,
|
|
330
|
+
children: (t, n) => /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(I, {
|
|
331
|
+
label: "Date",
|
|
332
|
+
value: t,
|
|
333
|
+
minimum: s.minimum,
|
|
334
|
+
maximum: s.maximum,
|
|
335
|
+
onValueChange: n
|
|
336
|
+
}), /* @__PURE__ */ d(P, {
|
|
337
|
+
...s,
|
|
338
|
+
label: e,
|
|
339
|
+
mode: "single",
|
|
340
|
+
autoFocus: !0,
|
|
341
|
+
value: t,
|
|
342
|
+
initialMonth: t !== void 0 && x(t) ? t : s.initialMonth,
|
|
343
|
+
onValueChange: n
|
|
344
|
+
})] })
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
// packages/forms/src/dates/date-range-picker.tsx
|
|
348
|
+
function V({ label: e, value: t, onValueChange: n, formatValue: r, presets: i, validateRange: a, density: o, disabled: s, isClearable: c, ...l }) {
|
|
349
|
+
function p(e) {
|
|
350
|
+
if (e.to === void 0) return "Select a start and end date.";
|
|
351
|
+
let t = k(e.from, l.minimum, l.maximum) ?? k(e.to, l.minimum, l.maximum);
|
|
352
|
+
return t === void 0 ? C(e.from) > C(e.to) ? "End date must be on or after start date." : a?.({
|
|
353
|
+
from: e.from,
|
|
354
|
+
to: e.to
|
|
355
|
+
}) : t;
|
|
356
|
+
}
|
|
357
|
+
function m(e) {
|
|
358
|
+
if (e.to === void 0) return D(e.from, l.locale);
|
|
359
|
+
let t = {
|
|
360
|
+
from: e.from,
|
|
361
|
+
to: e.to
|
|
362
|
+
};
|
|
363
|
+
return r?.(t) ?? `${D(t.from, l.locale)} – ${D(t.to, l.locale)}`;
|
|
364
|
+
}
|
|
365
|
+
return /* @__PURE__ */ d(z, {
|
|
366
|
+
label: e,
|
|
367
|
+
value: t,
|
|
368
|
+
formatValue: m,
|
|
369
|
+
validateValue: p,
|
|
370
|
+
presets: i,
|
|
371
|
+
density: o,
|
|
372
|
+
disabled: s,
|
|
373
|
+
isClearable: c,
|
|
374
|
+
timeZone: l.timeZone,
|
|
375
|
+
onValueChange: (e) => {
|
|
376
|
+
e === void 0 ? n(void 0) : e.to !== void 0 && n({
|
|
377
|
+
from: e.from,
|
|
378
|
+
to: e.to
|
|
379
|
+
});
|
|
380
|
+
},
|
|
381
|
+
children: (t, n) => /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ f(R, { children: [/* @__PURE__ */ d(I, {
|
|
382
|
+
label: "Start date",
|
|
383
|
+
value: t?.from,
|
|
384
|
+
minimum: l.minimum,
|
|
385
|
+
maximum: l.maximum,
|
|
386
|
+
onValueChange: (e) => n(e === void 0 ? void 0 : {
|
|
387
|
+
from: e,
|
|
388
|
+
to: t?.to
|
|
389
|
+
})
|
|
390
|
+
}), /* @__PURE__ */ d(I, {
|
|
391
|
+
label: "End date",
|
|
392
|
+
value: t?.to,
|
|
393
|
+
minimum: l.minimum,
|
|
394
|
+
maximum: l.maximum,
|
|
395
|
+
onValueChange: (e) => {
|
|
396
|
+
t === void 0 ? e !== void 0 && n({
|
|
397
|
+
from: e,
|
|
398
|
+
to: e
|
|
399
|
+
}) : n({
|
|
400
|
+
from: t.from,
|
|
401
|
+
to: e
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
})] }), /* @__PURE__ */ d(P, {
|
|
405
|
+
...l,
|
|
406
|
+
label: e,
|
|
407
|
+
mode: "range",
|
|
408
|
+
autoFocus: !0,
|
|
409
|
+
value: t,
|
|
410
|
+
initialMonth: t !== void 0 && x(t.from) ? t.from : l.initialMonth,
|
|
411
|
+
onValueChange: n
|
|
412
|
+
})] })
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
// packages/forms/src/dates/month-calendar.tsx
|
|
416
|
+
var H = { month: {
|
|
417
|
+
kzqmXN: "xh8yej3",
|
|
418
|
+
$$css: !0
|
|
419
|
+
} };
|
|
420
|
+
function U(e, t, n) {
|
|
421
|
+
let r = b(e) ? e : {
|
|
422
|
+
year: 2e3,
|
|
423
|
+
month: 1
|
|
424
|
+
};
|
|
425
|
+
return t !== void 0 && S(r) < S(t) ? t : n !== void 0 && S(r) > S(n) ? n : r;
|
|
426
|
+
}
|
|
427
|
+
function W({ label: e, selection: t, onSelect: n, locale: a, today: s, initialMonth: u, minimum: p, maximum: g }) {
|
|
428
|
+
let _ = U(u, p, g), [v, y] = l(_.year), [b, x] = l(_), C = c(/* @__PURE__ */ new Map()), w = c(!1);
|
|
429
|
+
o(() => {
|
|
430
|
+
w.current && (w.current = !1, C.current.get(b.month)?.focus());
|
|
431
|
+
}, [b]);
|
|
432
|
+
function T(e, t) {
|
|
433
|
+
let n = {
|
|
434
|
+
ArrowLeft: -1,
|
|
435
|
+
ArrowRight: 1,
|
|
436
|
+
ArrowUp: -3,
|
|
437
|
+
ArrowDown: 3,
|
|
438
|
+
PageUp: -12,
|
|
439
|
+
PageDown: 12
|
|
440
|
+
}[e.key];
|
|
441
|
+
if (e.key === "Home" && (n = 1 - t.month), e.key === "End" && (n = 12 - t.month), n === void 0) return;
|
|
442
|
+
e.preventDefault();
|
|
443
|
+
let r = Math.max(12, Math.min(119999, S(t) - 1 + n)), i = U({
|
|
444
|
+
year: Math.floor(r / 12),
|
|
445
|
+
month: r % 12 + 1
|
|
446
|
+
}, p, g);
|
|
447
|
+
w.current = !0, y(i.year), x(i);
|
|
448
|
+
}
|
|
449
|
+
function E(e) {
|
|
450
|
+
let t = U({
|
|
451
|
+
year: e,
|
|
452
|
+
month: b.month
|
|
453
|
+
}, p, g);
|
|
454
|
+
y(t.year), x(t);
|
|
455
|
+
}
|
|
456
|
+
return /* @__PURE__ */ f("div", {
|
|
457
|
+
className: "x78zum5 xdt5ytf x1hnptsi xeuugli",
|
|
458
|
+
children: [/* @__PURE__ */ f("div", {
|
|
459
|
+
className: "x78zum5 x6s0dn4 x1qughib x1hnptsi",
|
|
460
|
+
children: [
|
|
461
|
+
/* @__PURE__ */ d(r, {
|
|
462
|
+
"aria-label": "Previous year",
|
|
463
|
+
disabled: v <= (p?.year ?? 1),
|
|
464
|
+
onClick: () => E(v - 1),
|
|
465
|
+
children: /* @__PURE__ */ d(m, { size: 16 })
|
|
466
|
+
}),
|
|
467
|
+
/* @__PURE__ */ d("span", {
|
|
468
|
+
"aria-live": "polite",
|
|
469
|
+
className: "xk4h15q xss6m8b",
|
|
470
|
+
children: v
|
|
471
|
+
}),
|
|
472
|
+
/* @__PURE__ */ d(r, {
|
|
473
|
+
"aria-label": "Next year",
|
|
474
|
+
disabled: v >= (g?.year ?? 9999),
|
|
475
|
+
onClick: () => E(v + 1),
|
|
476
|
+
children: /* @__PURE__ */ d(h, { size: 16 })
|
|
477
|
+
})
|
|
478
|
+
]
|
|
479
|
+
}), /* @__PURE__ */ d("div", {
|
|
480
|
+
role: "group",
|
|
481
|
+
"aria-label": e,
|
|
482
|
+
className: "xrvj5dj x185a7wo xunmzkg",
|
|
483
|
+
children: Array.from({ length: 12 }, (e, r) => {
|
|
484
|
+
let o = {
|
|
485
|
+
year: v,
|
|
486
|
+
month: r + 1
|
|
487
|
+
}, c = S(o), l = t === void 0 ? void 0 : S(t.from), u = t?.to === void 0 ? void 0 : S(t.to), f = c === l || c === u, m = l !== void 0 && u !== void 0 && c > l && c < u, h = p !== void 0 && c < S(p), _ = g !== void 0 && c > S(g), y = h || _;
|
|
488
|
+
return /* @__PURE__ */ d(i, {
|
|
489
|
+
variant: f || m ? "solid" : "ghost",
|
|
490
|
+
"aria-label": O(o, a),
|
|
491
|
+
"aria-pressed": f || m,
|
|
492
|
+
"aria-current": v === s.year && o.month === s.month ? "date" : void 0,
|
|
493
|
+
disabled: y,
|
|
494
|
+
tabIndex: b.year === v && b.month === o.month ? 0 : -1,
|
|
495
|
+
ref: (e) => {
|
|
496
|
+
e === null ? C.current.delete(o.month) : C.current.set(o.month, e);
|
|
497
|
+
},
|
|
498
|
+
onFocus: () => x(o),
|
|
499
|
+
onKeyDown: (e) => T(e, o),
|
|
500
|
+
onClick: () => n(o),
|
|
501
|
+
xstyle: H.month,
|
|
502
|
+
children: new Intl.DateTimeFormat(a, {
|
|
503
|
+
month: "short",
|
|
504
|
+
timeZone: "UTC",
|
|
505
|
+
calendar: "gregory"
|
|
506
|
+
}).format(/* @__PURE__ */ new Date(`${String(v).padStart(4, "0")}-${String(o.month).padStart(2, "0")}-01T12:00:00Z`))
|
|
507
|
+
}, o.month);
|
|
508
|
+
})
|
|
509
|
+
})]
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
// packages/forms/src/dates/month-picker.tsx
|
|
513
|
+
function G({ label: e, value: t, onValueChange: n, formatValue: r, density: i, disabled: a, isClearable: o, ...s }) {
|
|
514
|
+
return /* @__PURE__ */ d(z, {
|
|
515
|
+
label: e,
|
|
516
|
+
value: t,
|
|
517
|
+
onValueChange: n,
|
|
518
|
+
formatValue: r ?? ((e) => O(e, s.locale)),
|
|
519
|
+
validateValue: (e) => A(e, s.minimum, s.maximum),
|
|
520
|
+
density: i,
|
|
521
|
+
disabled: a,
|
|
522
|
+
isClearable: o,
|
|
523
|
+
timeZone: s.timeZone,
|
|
524
|
+
children: (t, n) => /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(L, {
|
|
525
|
+
label: "Month",
|
|
526
|
+
value: t,
|
|
527
|
+
minimum: s.minimum,
|
|
528
|
+
maximum: s.maximum,
|
|
529
|
+
onValueChange: n
|
|
530
|
+
}), /* @__PURE__ */ d(W, {
|
|
531
|
+
...s,
|
|
532
|
+
label: e,
|
|
533
|
+
selection: t === void 0 ? void 0 : { from: t },
|
|
534
|
+
initialMonth: t !== void 0 && b(t) ? t : s.initialMonth,
|
|
535
|
+
onSelect: n
|
|
536
|
+
})] })
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
// packages/forms/src/dates/month-range-picker.tsx
|
|
540
|
+
function K({ label: e, value: t, onValueChange: n, formatValue: r, presets: i, validateRange: a, density: o, disabled: s, isClearable: c, ...l }) {
|
|
541
|
+
function p(e) {
|
|
542
|
+
if (e.to === void 0) return "Select a start and end month.";
|
|
543
|
+
let t = A(e.from, l.minimum, l.maximum) ?? A(e.to, l.minimum, l.maximum);
|
|
544
|
+
return t === void 0 ? S(e.from) > S(e.to) ? "End month must be on or after start month." : a?.({
|
|
545
|
+
from: e.from,
|
|
546
|
+
to: e.to
|
|
547
|
+
}) : t;
|
|
548
|
+
}
|
|
549
|
+
function m(e) {
|
|
550
|
+
if (e.to === void 0) return O(e.from, l.locale);
|
|
551
|
+
let t = {
|
|
552
|
+
from: e.from,
|
|
553
|
+
to: e.to
|
|
554
|
+
};
|
|
555
|
+
return r?.(t) ?? `${O(t.from, l.locale)} – ${O(t.to, l.locale)}`;
|
|
556
|
+
}
|
|
557
|
+
return /* @__PURE__ */ d(z, {
|
|
558
|
+
label: e,
|
|
559
|
+
value: t,
|
|
560
|
+
formatValue: m,
|
|
561
|
+
validateValue: p,
|
|
562
|
+
presets: i,
|
|
563
|
+
density: o,
|
|
564
|
+
disabled: s,
|
|
565
|
+
isClearable: c,
|
|
566
|
+
timeZone: l.timeZone,
|
|
567
|
+
onValueChange: (e) => {
|
|
568
|
+
e === void 0 ? n(void 0) : e.to !== void 0 && n({
|
|
569
|
+
from: e.from,
|
|
570
|
+
to: e.to
|
|
571
|
+
});
|
|
572
|
+
},
|
|
573
|
+
children: (t, n) => /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ f(R, { children: [/* @__PURE__ */ d(L, {
|
|
574
|
+
label: "Start month",
|
|
575
|
+
value: t?.from,
|
|
576
|
+
minimum: l.minimum,
|
|
577
|
+
maximum: l.maximum,
|
|
578
|
+
onValueChange: (e) => n(e === void 0 ? void 0 : {
|
|
579
|
+
from: e,
|
|
580
|
+
to: t?.to
|
|
581
|
+
})
|
|
582
|
+
}), /* @__PURE__ */ d(L, {
|
|
583
|
+
label: "End month",
|
|
584
|
+
value: t?.to,
|
|
585
|
+
minimum: l.minimum,
|
|
586
|
+
maximum: l.maximum,
|
|
587
|
+
onValueChange: (e) => {
|
|
588
|
+
t === void 0 ? e !== void 0 && n({
|
|
589
|
+
from: e,
|
|
590
|
+
to: e
|
|
591
|
+
}) : n({
|
|
592
|
+
from: t.from,
|
|
593
|
+
to: e
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
})] }), /* @__PURE__ */ d(W, {
|
|
597
|
+
...l,
|
|
598
|
+
label: e,
|
|
599
|
+
selection: t,
|
|
600
|
+
initialMonth: t !== void 0 && b(t.from) ? t.from : l.initialMonth,
|
|
601
|
+
onSelect: (e) => {
|
|
602
|
+
t === void 0 || t.to !== void 0 ? n({ from: e }) : S(e) < S(t.from) ? n({
|
|
603
|
+
from: e,
|
|
604
|
+
to: t.from
|
|
605
|
+
}) : n({
|
|
606
|
+
from: t.from,
|
|
607
|
+
to: e
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
})] })
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
export { P as Calendar, B as DatePicker, V as DateRangePicker, G as MonthPicker, K as MonthRangePicker };
|