@bolid-ui/themes 0.2.3 → 0.3.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/badge.props.cjs +1 -1
- package/dist/components/badge.props.d.cts +16 -0
- package/dist/components/badge.props.d.ts +16 -0
- package/dist/components/badge.props.js +14 -8
- package/dist/components/date-range-selection/date-range-selection.cjs +1 -0
- package/dist/components/date-range-selection/date-range-selection.d.cts +159 -0
- package/dist/components/date-range-selection/date-range-selection.d.ts +159 -0
- package/dist/components/date-range-selection/date-range-selection.js +913 -0
- package/dist/components/date-range-selection/date-range-selection.props.cjs +1 -0
- package/dist/components/date-range-selection/date-range-selection.props.d.cts +66 -0
- package/dist/components/date-range-selection/date-range-selection.props.d.ts +66 -0
- package/dist/components/date-range-selection/date-range-selection.props.js +40 -0
- package/dist/components/date-range-selection/index.d.cts +1 -0
- package/dist/components/date-range-selection/index.d.ts +1 -0
- package/dist/components/index.d.cts +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/theme.cjs +1 -1
- package/dist/components/theme.js +69 -65
- package/dist/components/tooltip.cjs +1 -1
- package/dist/components/tooltip.d.cts +1 -1
- package/dist/components/tooltip.d.ts +1 -1
- package/dist/components/tooltip.js +6 -4
- package/dist/components/tooltip.props.cjs +1 -1
- package/dist/components/tooltip.props.d.cts +5 -0
- package/dist/components/tooltip.props.d.ts +5 -0
- package/dist/components/tooltip.props.js +9 -0
- package/dist/helpers/is-webkit-gtk.cjs +1 -0
- package/dist/helpers/is-webkit-gtk.d.cts +9 -0
- package/dist/helpers/is-webkit-gtk.d.ts +9 -0
- package/dist/helpers/is-webkit-gtk.js +10 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +49 -48
- package/dist/props/index.cjs +1 -1
- package/dist/props/index.d.cts +1 -0
- package/dist/props/index.d.ts +1 -0
- package/dist/props/index.js +37 -36
- package/dist/styles.css +783 -26
- package/package.json +2 -2
|
@@ -0,0 +1,913 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { extractProps as e } from "../../helpers/extract-props.js";
|
|
3
|
+
import { marginPropDefs as t } from "../../props/margin.props.js";
|
|
4
|
+
import { MinusIcon as n, PlusIcon as r } from "../icons.js";
|
|
5
|
+
import { dateRangeSelectionRootPropDefs as i, dateRangeSelectionSlotPropDefs as a } from "./date-range-selection.props.js";
|
|
6
|
+
import { IconButton as o } from "../icon-button.js";
|
|
7
|
+
import s from "classnames";
|
|
8
|
+
import * as c from "react";
|
|
9
|
+
import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
10
|
+
import { createPortal as f } from "react-dom";
|
|
11
|
+
//#region src/components/date-range-selection/date-range-selection.tsx
|
|
12
|
+
var p = 1e3, m = 60 * p, h = 60 * m, g = 24 * h, _ = 7 * g, v = 30 * g, y = 365 * g, b = 12, x = .01, S = 100, C = 20, w = 1e5, T = 4, E = 1;
|
|
13
|
+
function D(e, t) {
|
|
14
|
+
if (e.length !== t.length) return !1;
|
|
15
|
+
for (let n = 0; n < e.length; n++) {
|
|
16
|
+
let r = e[n], i = t[n];
|
|
17
|
+
if (!(!r && !i) && (!r || !i || r.x !== i.x || r.y !== i.y || r.width !== i.width || r.height !== i.height)) return !1;
|
|
18
|
+
}
|
|
19
|
+
return !0;
|
|
20
|
+
}
|
|
21
|
+
var O = c.createContext(null), k = c.createContext(null);
|
|
22
|
+
function A(e) {
|
|
23
|
+
let t = c.useRef(e);
|
|
24
|
+
return c.useLayoutEffect(() => {
|
|
25
|
+
t.current = e;
|
|
26
|
+
}), c.useCallback((...e) => {
|
|
27
|
+
t.current(...e);
|
|
28
|
+
}, []);
|
|
29
|
+
}
|
|
30
|
+
function j({ onMoveStart: e, onMove: t, onMoveEnd: n }) {
|
|
31
|
+
let r = c.useRef({
|
|
32
|
+
isMoving: !1,
|
|
33
|
+
lastPosition: null,
|
|
34
|
+
id: null
|
|
35
|
+
}), i = A((n, i, a, o) => {
|
|
36
|
+
i === 0 && a === 0 || (r.current.isMoving || (r.current.isMoving = !0, e?.({
|
|
37
|
+
type: "movestart",
|
|
38
|
+
pointerType: o,
|
|
39
|
+
shiftKey: n.shiftKey,
|
|
40
|
+
ctrlKey: n.ctrlKey,
|
|
41
|
+
metaKey: n.metaKey,
|
|
42
|
+
altKey: n.altKey
|
|
43
|
+
})), t?.({
|
|
44
|
+
type: "move",
|
|
45
|
+
pointerType: o,
|
|
46
|
+
deltaX: i,
|
|
47
|
+
deltaY: a,
|
|
48
|
+
shiftKey: n.shiftKey,
|
|
49
|
+
ctrlKey: n.ctrlKey,
|
|
50
|
+
metaKey: n.metaKey,
|
|
51
|
+
altKey: n.altKey
|
|
52
|
+
}));
|
|
53
|
+
}), a = A((e, t) => {
|
|
54
|
+
r.current.isMoving && (r.current.isMoving = !1, n?.({
|
|
55
|
+
type: "moveend",
|
|
56
|
+
pointerType: t,
|
|
57
|
+
shiftKey: e.shiftKey,
|
|
58
|
+
ctrlKey: e.ctrlKey,
|
|
59
|
+
metaKey: e.metaKey,
|
|
60
|
+
altKey: e.altKey
|
|
61
|
+
}));
|
|
62
|
+
});
|
|
63
|
+
return c.useMemo(() => {
|
|
64
|
+
let e = {};
|
|
65
|
+
e.onPointerDown = (e) => {
|
|
66
|
+
if (e.button !== 0 || r.current.id !== null) return;
|
|
67
|
+
e.preventDefault(), r.current.isMoving = !1, r.current.id = e.pointerId, r.current.lastPosition = {
|
|
68
|
+
pageX: e.pageX,
|
|
69
|
+
pageY: e.pageY
|
|
70
|
+
};
|
|
71
|
+
let t = (e) => {
|
|
72
|
+
e.pointerId === r.current.id && (i(e, e.pageX - (r.current.lastPosition?.pageX ?? 0), e.pageY - (r.current.lastPosition?.pageY ?? 0), e.pointerType || "mouse"), r.current.lastPosition = {
|
|
73
|
+
pageX: e.pageX,
|
|
74
|
+
pageY: e.pageY
|
|
75
|
+
});
|
|
76
|
+
}, n = (e) => {
|
|
77
|
+
e.pointerId === r.current.id && (a(e, e.pointerType || "mouse"), r.current.id = null, window.removeEventListener("pointermove", t), window.removeEventListener("pointerup", n), window.removeEventListener("pointercancel", n));
|
|
78
|
+
};
|
|
79
|
+
window.addEventListener("pointermove", t), window.addEventListener("pointerup", n), window.addEventListener("pointercancel", n);
|
|
80
|
+
};
|
|
81
|
+
let t = (e, t, n) => {
|
|
82
|
+
r.current.isMoving = !1, i(e, t, n, "keyboard"), a(e, "keyboard");
|
|
83
|
+
};
|
|
84
|
+
return e.onKeyDown = (e) => {
|
|
85
|
+
switch (e.key) {
|
|
86
|
+
case "ArrowLeft":
|
|
87
|
+
e.preventDefault(), t(e, -1, 0);
|
|
88
|
+
break;
|
|
89
|
+
case "ArrowRight":
|
|
90
|
+
e.preventDefault(), t(e, 1, 0);
|
|
91
|
+
break;
|
|
92
|
+
case "ArrowUp":
|
|
93
|
+
e.preventDefault(), t(e, 0, -1);
|
|
94
|
+
break;
|
|
95
|
+
case "ArrowDown":
|
|
96
|
+
e.preventDefault(), t(e, 0, 1);
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}, { moveProps: e };
|
|
100
|
+
}, [a, i]);
|
|
101
|
+
}
|
|
102
|
+
function M(e, t) {
|
|
103
|
+
c.useEffect(() => {
|
|
104
|
+
if (!e) return;
|
|
105
|
+
if (window.ResizeObserver === void 0) return window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
|
|
106
|
+
let n = new ResizeObserver(() => t());
|
|
107
|
+
return n.observe(e), () => n.disconnect();
|
|
108
|
+
}, [e, t]);
|
|
109
|
+
}
|
|
110
|
+
function N(e, t) {
|
|
111
|
+
if (e instanceof Date) return new Date(t);
|
|
112
|
+
let n = e, r = t - e.valueOf();
|
|
113
|
+
return r === 0 ? e : r > 0 && typeof n.add == "function" ? n.add(r, "millisecond") : r < 0 && typeof n.subtract == "function" ? n.subtract(-r, "millisecond") : new Date(t);
|
|
114
|
+
}
|
|
115
|
+
function P(e) {
|
|
116
|
+
return N(e, e.valueOf());
|
|
117
|
+
}
|
|
118
|
+
function F(e) {
|
|
119
|
+
return {
|
|
120
|
+
start: P(e.start),
|
|
121
|
+
end: P(e.end)
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function I(e) {
|
|
125
|
+
let t = P(e.start), n = P(e.end);
|
|
126
|
+
return t.valueOf() <= n.valueOf() ? {
|
|
127
|
+
start: t,
|
|
128
|
+
end: n
|
|
129
|
+
} : {
|
|
130
|
+
start: n,
|
|
131
|
+
end: t
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function L(e, t, n, r = I) {
|
|
135
|
+
let [i, a] = c.useState(() => r(t)), o = e !== void 0;
|
|
136
|
+
return [r(o ? e : i), c.useCallback((e) => {
|
|
137
|
+
let t = r(e);
|
|
138
|
+
o || a(t), n?.(F(t));
|
|
139
|
+
}, [
|
|
140
|
+
o,
|
|
141
|
+
r,
|
|
142
|
+
n
|
|
143
|
+
])];
|
|
144
|
+
}
|
|
145
|
+
function R(e, t, n) {
|
|
146
|
+
return N(e, Math.min(Math.max(e.valueOf(), t.valueOf()), n.valueOf()));
|
|
147
|
+
}
|
|
148
|
+
function z(e, t = p) {
|
|
149
|
+
let n = ee(t);
|
|
150
|
+
return N(e, Math.round(e.valueOf() / n) * n);
|
|
151
|
+
}
|
|
152
|
+
function ee(e) {
|
|
153
|
+
return typeof e == "number" && Number.isFinite(e) && e > 0 ? e : p;
|
|
154
|
+
}
|
|
155
|
+
function B(e, t) {
|
|
156
|
+
return typeof e == "number" && Number.isFinite(e) && e > 0 ? e : t;
|
|
157
|
+
}
|
|
158
|
+
function V(e, t) {
|
|
159
|
+
return N(e, e.valueOf() + t);
|
|
160
|
+
}
|
|
161
|
+
function te(e) {
|
|
162
|
+
let t = e;
|
|
163
|
+
if (typeof t.startOf == "function") return t.startOf("day");
|
|
164
|
+
let n = new Date(e.valueOf());
|
|
165
|
+
return n.setHours(0, 0, 0, 0), n;
|
|
166
|
+
}
|
|
167
|
+
function ne(e) {
|
|
168
|
+
let t = e;
|
|
169
|
+
if (typeof t.endOf == "function") return t.endOf("day");
|
|
170
|
+
let n = new Date(e.valueOf());
|
|
171
|
+
return n.setHours(23, 59, 59, 999), n;
|
|
172
|
+
}
|
|
173
|
+
function re(e, t, n = 4, r = .5) {
|
|
174
|
+
let i = Number.isFinite(n) && n >= 1 ? n : 4, a = Number.isFinite(r) ? Math.min(Math.max(r, 0), 1) : .5, o = t.valueOf() - e.valueOf();
|
|
175
|
+
return {
|
|
176
|
+
start: V(e, -o * (i - 1) * a),
|
|
177
|
+
end: V(t, o * (i - 1) * (1 - a))
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function H(e) {
|
|
181
|
+
let t = e;
|
|
182
|
+
return typeof t.format == "function" ? t.format() : typeof t.toISOString == "function" ? t.toISOString() : new Date(e.valueOf()).toISOString();
|
|
183
|
+
}
|
|
184
|
+
function ie(e, t, n) {
|
|
185
|
+
let r = I(e), i = I({
|
|
186
|
+
start: z(r.start, n),
|
|
187
|
+
end: z(r.end, n)
|
|
188
|
+
});
|
|
189
|
+
return i.end.valueOf() - i.start.valueOf() >= t ? i : {
|
|
190
|
+
start: i.start,
|
|
191
|
+
end: V(i.start, t)
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function ae(e) {
|
|
195
|
+
let t = ee(e.align), n = Math.max(B(e.minDuration, p), t), r = c.useCallback((e) => ie(e, n, t), [t, n]), i = e.placeholderValue ?? e.value?.start ?? e.defaultValue?.start ?? /* @__PURE__ */ new Date(), a = e.defaultValue ? r(e.defaultValue) : {
|
|
196
|
+
start: te(i),
|
|
197
|
+
end: ne(i)
|
|
198
|
+
}, o = c.useCallback((t) => {
|
|
199
|
+
e.onChange?.(t), e.onUpdate?.(t);
|
|
200
|
+
}, [e.onChange, e.onUpdate]), [s, l] = L(e.value, r(a), o, r), [u, d] = c.useState(!1), [f, m] = c.useState(null), h = c.useCallback((e) => {
|
|
201
|
+
m(null), l(r(e));
|
|
202
|
+
}, [r, l]), g = u ? s : f ?? s, _ = re(g.start, g.end, e.numberOfIntervals, e.placeOnRuler), v = e.minValue && e.minValue.valueOf() > _.start.valueOf() ? e.minValue : _.start, b = e.maxValue && e.maxValue.valueOf() < _.end.valueOf() ? e.maxValue : _.end, x = Math.max(Math.min(B(e.maxDuration, 15 * y), b.valueOf() - v.valueOf()), n), S = n < x, C = c.useRef(null), w = c.useCallback((e) => {
|
|
203
|
+
C.current = e ? F(e) : null, m(e ? F(e) : null);
|
|
204
|
+
}, []), T = c.useCallback(() => {
|
|
205
|
+
d(!0), w(s);
|
|
206
|
+
}, [w, s]), E = c.useCallback(() => {
|
|
207
|
+
d(!1), C.current && h(C.current);
|
|
208
|
+
}, [h]), D = c.useCallback((e) => {
|
|
209
|
+
if (!C.current) return;
|
|
210
|
+
let { start: t, end: n } = C.current, r = V(t, e), i = V(n, e), a = i.valueOf() - r.valueOf();
|
|
211
|
+
r.valueOf() < v.valueOf() ? (r = v, i = R(V(r, a), r, b)) : i.valueOf() > b.valueOf() && (i = b, r = R(V(i, -a), v, i)), w({
|
|
212
|
+
start: r,
|
|
213
|
+
end: i
|
|
214
|
+
});
|
|
215
|
+
}, [
|
|
216
|
+
b,
|
|
217
|
+
v,
|
|
218
|
+
w
|
|
219
|
+
]), O = c.useCallback((e, { visualMinDuration: t = n } = {}) => {
|
|
220
|
+
if (!C.current) return;
|
|
221
|
+
let { start: r, end: i } = C.current, a = Math.max(t, n), o = Math.min(x, i.valueOf() - v.valueOf());
|
|
222
|
+
w({
|
|
223
|
+
start: R(V(r, e), V(i, -o), V(i, -a)),
|
|
224
|
+
end: i
|
|
225
|
+
});
|
|
226
|
+
}, [
|
|
227
|
+
x,
|
|
228
|
+
n,
|
|
229
|
+
v,
|
|
230
|
+
w
|
|
231
|
+
]), k = c.useCallback((e, { visualMinDuration: t = n } = {}) => {
|
|
232
|
+
if (!C.current) return;
|
|
233
|
+
let { start: r, end: i } = C.current, a = Math.max(t, n), o = Math.min(x, b.valueOf() - r.valueOf());
|
|
234
|
+
w({
|
|
235
|
+
start: r,
|
|
236
|
+
end: R(V(i, e), V(r, a), V(r, o))
|
|
237
|
+
});
|
|
238
|
+
}, [
|
|
239
|
+
x,
|
|
240
|
+
b,
|
|
241
|
+
n,
|
|
242
|
+
w
|
|
243
|
+
]), A = c.useCallback((e, { visualMinDuration: r = n, fixedPoint: i = .5 } = {}) => {
|
|
244
|
+
if (!C.current) return;
|
|
245
|
+
let { start: a, end: o } = C.current, s = o.valueOf() - a.valueOf(), c = s * e;
|
|
246
|
+
c = t * Math.round(c / t), c = Math.min(Math.max(c, Math.max(r, n)), x);
|
|
247
|
+
let l = V(a, -i * (c - s)), u = V(l, c), d = u.valueOf() - l.valueOf();
|
|
248
|
+
l.valueOf() < v.valueOf() ? (l = v, u = R(V(l, d), l, b)) : u.valueOf() > b.valueOf() && (u = b, l = R(V(u, -d), v, u)), w({
|
|
249
|
+
start: l,
|
|
250
|
+
end: u
|
|
251
|
+
});
|
|
252
|
+
}, [
|
|
253
|
+
t,
|
|
254
|
+
x,
|
|
255
|
+
b,
|
|
256
|
+
n,
|
|
257
|
+
v,
|
|
258
|
+
w
|
|
259
|
+
]);
|
|
260
|
+
return {
|
|
261
|
+
viewportInterval: _,
|
|
262
|
+
value: f ?? s,
|
|
263
|
+
setValue: h,
|
|
264
|
+
setDraggingValue: w,
|
|
265
|
+
canResize: S,
|
|
266
|
+
startDragging: T,
|
|
267
|
+
move: D,
|
|
268
|
+
scale: A,
|
|
269
|
+
moveStart: O,
|
|
270
|
+
moveEnd: k,
|
|
271
|
+
endDragging: E,
|
|
272
|
+
align: t,
|
|
273
|
+
isDragging: u
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function oe(e, t, n) {
|
|
277
|
+
return t.start + (n - e.start) * (t.end - t.start) / (e.end - e.start);
|
|
278
|
+
}
|
|
279
|
+
function U(e, t) {
|
|
280
|
+
return (t.end - t.start) / (e.end - e.start);
|
|
281
|
+
}
|
|
282
|
+
function W(e, t, ...n) {
|
|
283
|
+
return n.map((n) => ({
|
|
284
|
+
duration: e * n,
|
|
285
|
+
period: t,
|
|
286
|
+
multiplier: n
|
|
287
|
+
}));
|
|
288
|
+
}
|
|
289
|
+
var G = [
|
|
290
|
+
...W(p, "second", 1, 2, 5, 10, 15, 30),
|
|
291
|
+
...W(m, "minute", 1, 2, 5, 10, 20, 30),
|
|
292
|
+
...W(h, "hour", 1, 2, 3, 6, 12),
|
|
293
|
+
...W(g, "day", 1, 2, 3),
|
|
294
|
+
...W(_, "week", 1, 2),
|
|
295
|
+
...W(v, "month", 1, 2, 3, 6),
|
|
296
|
+
...W(y, "year", 1, 2, 5, 10, 15, 20, 30)
|
|
297
|
+
];
|
|
298
|
+
function se({ minWidth: e, maxWidth: t, timelineWidth: n, timelineDuration: r }) {
|
|
299
|
+
let i = e / n * r, a = t / n * r, o = [];
|
|
300
|
+
for (let e of G) if (i <= e.duration) {
|
|
301
|
+
if (e.duration <= a) o.push(e);
|
|
302
|
+
else if (!o.length) return e;
|
|
303
|
+
}
|
|
304
|
+
return o.length ? o[Math.floor(o.length / 2)] : G[G.length - 1];
|
|
305
|
+
}
|
|
306
|
+
function ce(e, t) {
|
|
307
|
+
let n = new Date(e);
|
|
308
|
+
switch (t.period) {
|
|
309
|
+
case "second":
|
|
310
|
+
n.setSeconds(n.getSeconds() + t.multiplier);
|
|
311
|
+
break;
|
|
312
|
+
case "minute":
|
|
313
|
+
n.setMinutes(n.getMinutes() + t.multiplier);
|
|
314
|
+
break;
|
|
315
|
+
case "hour":
|
|
316
|
+
n.setHours(n.getHours() + t.multiplier);
|
|
317
|
+
break;
|
|
318
|
+
case "day":
|
|
319
|
+
n.setDate(n.getDate() + t.multiplier);
|
|
320
|
+
break;
|
|
321
|
+
case "week":
|
|
322
|
+
n.setDate(n.getDate() + t.multiplier * 7);
|
|
323
|
+
break;
|
|
324
|
+
case "month":
|
|
325
|
+
n.setMonth(n.getMonth() + t.multiplier);
|
|
326
|
+
break;
|
|
327
|
+
case "year":
|
|
328
|
+
n.setFullYear(n.getFullYear() + t.multiplier);
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
return n.valueOf();
|
|
332
|
+
}
|
|
333
|
+
function le(e, t) {
|
|
334
|
+
let n = new Date(1977, 0, 1), r = n.getTime() - e.valueOf(), i = Math.floor(r / t.duration / t.multiplier), a = n.getTime() - i * t.duration * t.multiplier;
|
|
335
|
+
for (; e.valueOf() < a;) a -= t.duration * t.multiplier;
|
|
336
|
+
return a;
|
|
337
|
+
}
|
|
338
|
+
function ue({ viewportStart: e, viewportEnd: t, minTickWidth: n, maxTickWidth: r, viewportWidth: i }) {
|
|
339
|
+
if (i <= 0) return [];
|
|
340
|
+
let a = se({
|
|
341
|
+
minWidth: n,
|
|
342
|
+
maxWidth: r,
|
|
343
|
+
timelineDuration: t.valueOf() - e.valueOf(),
|
|
344
|
+
timelineWidth: i
|
|
345
|
+
}), o = [], s = le(e, a), c = -Infinity;
|
|
346
|
+
for (let n = 0; s < t.valueOf(); n++) {
|
|
347
|
+
if (n >= w) throw Error("DateRangeSelection: too many ticks");
|
|
348
|
+
o.push(N(e, s));
|
|
349
|
+
let t = ce(s, a);
|
|
350
|
+
if (t <= c) break;
|
|
351
|
+
c = s, s = t;
|
|
352
|
+
}
|
|
353
|
+
return o;
|
|
354
|
+
}
|
|
355
|
+
function de(e, t) {
|
|
356
|
+
let n = new Intl.DateTimeFormat(void 0, {
|
|
357
|
+
timeZone: t,
|
|
358
|
+
year: "numeric",
|
|
359
|
+
month: "2-digit",
|
|
360
|
+
day: "2-digit",
|
|
361
|
+
hour: "2-digit",
|
|
362
|
+
minute: "2-digit",
|
|
363
|
+
second: "2-digit",
|
|
364
|
+
hour12: !1
|
|
365
|
+
}).formatToParts(new Date(e.valueOf())), r = (e) => n.find((t) => t.type === e)?.value ?? "";
|
|
366
|
+
return r("second") === "00" && r("minute") === "00" && (r("hour") === "00" || r("hour") === "24") ? r("day") === "01" ? r("month") === "01" ? r("year") : `${r("month")}-${r("year")}` : `${r("day")}.${r("month")}.${r("year").slice(-2)}` : r("second") === "00" ? `${r("hour")}:${r("minute")}` : `${r("hour")}:${r("minute")}:${r("second")}`;
|
|
367
|
+
}
|
|
368
|
+
function fe({ tickHeight: e, viewportHeight: t }) {
|
|
369
|
+
let n = (t - e) / 2;
|
|
370
|
+
return (t) => `M${t},${n}l0,${e}`;
|
|
371
|
+
}
|
|
372
|
+
function pe({ tickHeight: e, viewportHeight: t }) {
|
|
373
|
+
let n = t - 2 * e;
|
|
374
|
+
return (t) => `M${t},0l0,${e}m0,${n}l0,${e}`;
|
|
375
|
+
}
|
|
376
|
+
function me({ tickHeight: e, viewportHeight: t }) {
|
|
377
|
+
let n = e, r = t;
|
|
378
|
+
return (e) => `M${e},0l${r},${r}l${n},0l${-r},${-r}l${-n},0`;
|
|
379
|
+
}
|
|
380
|
+
function K(e, t, n) {
|
|
381
|
+
if (!e) return NaN;
|
|
382
|
+
let r = U({
|
|
383
|
+
start: t.start.valueOf(),
|
|
384
|
+
end: t.end.valueOf()
|
|
385
|
+
}, {
|
|
386
|
+
start: 0,
|
|
387
|
+
end: n
|
|
388
|
+
});
|
|
389
|
+
return Math.round((e.valueOf() - t.start.valueOf()) * r);
|
|
390
|
+
}
|
|
391
|
+
function q() {
|
|
392
|
+
let e = c.useContext(O);
|
|
393
|
+
if (!e) throw Error("useViewportDimensions must be used within DateRangeSelection");
|
|
394
|
+
return e;
|
|
395
|
+
}
|
|
396
|
+
function J() {
|
|
397
|
+
let e = c.useContext(k);
|
|
398
|
+
if (!e) throw Error("useViewportInterval must be used within DateRangeSelection");
|
|
399
|
+
return e;
|
|
400
|
+
}
|
|
401
|
+
function he({ children: e, onMove: t, onMoveStart: n, onMoveEnd: r, dragDisabled: i }, a) {
|
|
402
|
+
let o = c.useRef(null), s = typeof t == "function", { moveProps: l } = j({
|
|
403
|
+
onMoveStart: n,
|
|
404
|
+
onMove: (e) => {
|
|
405
|
+
let n = o.current;
|
|
406
|
+
if (e.deltaX !== 0 && n) {
|
|
407
|
+
let { width: r } = n.getBoundingClientRect(), i = e.deltaX * 100 / r;
|
|
408
|
+
i = Math.round(i * 100) / 100, i !== 0 && t?.(i, e);
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
onMoveEnd: r
|
|
412
|
+
});
|
|
413
|
+
return /* @__PURE__ */ d("div", {
|
|
414
|
+
ref: a,
|
|
415
|
+
className: "rt-DateRangeSelectionRulerViewport",
|
|
416
|
+
children: [/* @__PURE__ */ u("svg", {
|
|
417
|
+
ref: o,
|
|
418
|
+
className: "rt-DateRangeSelectionSvg",
|
|
419
|
+
width: "100%",
|
|
420
|
+
height: "100%",
|
|
421
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
422
|
+
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
423
|
+
children: e
|
|
424
|
+
}), s ? /* @__PURE__ */ u("div", {
|
|
425
|
+
className: "rt-DateRangeSelectionRulerDragger",
|
|
426
|
+
"data-inactive": i ? "" : void 0,
|
|
427
|
+
...l
|
|
428
|
+
}) : null]
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
var ge = c.forwardRef(he);
|
|
432
|
+
function Y({ theme: e, minTickWidth: t, maxTickWidth: n, hasLabels: r, geometry: i, className: a, labelsClassName: o, formatTime: f, timeZone: p }) {
|
|
433
|
+
let m = q(), h = J(), g = c.useMemo(() => ue({
|
|
434
|
+
minTickWidth: t,
|
|
435
|
+
maxTickWidth: n,
|
|
436
|
+
viewportStart: h.start,
|
|
437
|
+
viewportEnd: h.end,
|
|
438
|
+
viewportWidth: m.width
|
|
439
|
+
}), [
|
|
440
|
+
n,
|
|
441
|
+
t,
|
|
442
|
+
h,
|
|
443
|
+
m.width
|
|
444
|
+
]), _ = c.useMemo(() => {
|
|
445
|
+
let e = U({
|
|
446
|
+
start: h.start.valueOf(),
|
|
447
|
+
end: h.end.valueOf()
|
|
448
|
+
}, {
|
|
449
|
+
start: 0,
|
|
450
|
+
end: m.width
|
|
451
|
+
});
|
|
452
|
+
return g.map((t) => Math.round((t.valueOf() - h.start.valueOf()) * e));
|
|
453
|
+
}, [
|
|
454
|
+
g,
|
|
455
|
+
h,
|
|
456
|
+
m.width
|
|
457
|
+
]), v = c.useMemo(() => _.map(i).join(""), [i, _]), y = c.useMemo(() => !r || _.length < 2 ? null : g.map((e) => f ? f(e) : de(e, p)), [
|
|
458
|
+
f,
|
|
459
|
+
r,
|
|
460
|
+
_.length,
|
|
461
|
+
g,
|
|
462
|
+
p
|
|
463
|
+
]), b = c.useRef([]), [x, S] = c.useState([]);
|
|
464
|
+
c.useLayoutEffect(() => {
|
|
465
|
+
if (!y) {
|
|
466
|
+
S((e) => e.length ? [] : e);
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
let e = y.map((e, t) => {
|
|
470
|
+
let n = b.current[t];
|
|
471
|
+
if (!n) return;
|
|
472
|
+
let r = n.getBBox();
|
|
473
|
+
return {
|
|
474
|
+
x: r.x,
|
|
475
|
+
y: r.y,
|
|
476
|
+
width: r.width,
|
|
477
|
+
height: r.height
|
|
478
|
+
};
|
|
479
|
+
});
|
|
480
|
+
S((t) => D(t, e) ? t : e);
|
|
481
|
+
}, [
|
|
482
|
+
y,
|
|
483
|
+
_,
|
|
484
|
+
m.width,
|
|
485
|
+
m.height
|
|
486
|
+
]);
|
|
487
|
+
let C = y ? y.map((e, t) => {
|
|
488
|
+
let n = x[t];
|
|
489
|
+
return /* @__PURE__ */ d("g", { children: [n ? /* @__PURE__ */ u("rect", {
|
|
490
|
+
className: "rt-DateRangeSelectionTickLabelRect",
|
|
491
|
+
x: n.x - T,
|
|
492
|
+
y: n.y - E,
|
|
493
|
+
width: n.width + T * 2,
|
|
494
|
+
height: n.height + E * 2
|
|
495
|
+
}) : null, /* @__PURE__ */ u("text", {
|
|
496
|
+
ref: (e) => {
|
|
497
|
+
b.current[t] = e;
|
|
498
|
+
},
|
|
499
|
+
className: s("rt-DateRangeSelectionTickText", o),
|
|
500
|
+
dominantBaseline: "central",
|
|
501
|
+
x: _[t],
|
|
502
|
+
y: "50%",
|
|
503
|
+
children: e
|
|
504
|
+
})] }, t);
|
|
505
|
+
}) : null;
|
|
506
|
+
return /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("path", {
|
|
507
|
+
className: s("rt-DateRangeSelectionTicks", a),
|
|
508
|
+
"data-theme": e,
|
|
509
|
+
d: v
|
|
510
|
+
}), C] });
|
|
511
|
+
}
|
|
512
|
+
function _e({ timeZone: e }) {
|
|
513
|
+
let { height: t } = q();
|
|
514
|
+
return /* @__PURE__ */ u(Y, {
|
|
515
|
+
minTickWidth: 8,
|
|
516
|
+
maxTickWidth: 20,
|
|
517
|
+
theme: "dim",
|
|
518
|
+
geometry: fe({
|
|
519
|
+
tickHeight: 4,
|
|
520
|
+
viewportHeight: t
|
|
521
|
+
}),
|
|
522
|
+
timeZone: e
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
function ve({ displayTickLabels: e, formatTime: t, timeZone: n }) {
|
|
526
|
+
let { height: r } = q();
|
|
527
|
+
return /* @__PURE__ */ u(Y, {
|
|
528
|
+
minTickWidth: 80,
|
|
529
|
+
maxTickWidth: 200,
|
|
530
|
+
theme: "normal",
|
|
531
|
+
geometry: pe({
|
|
532
|
+
tickHeight: 4,
|
|
533
|
+
viewportHeight: r
|
|
534
|
+
}),
|
|
535
|
+
hasLabels: e,
|
|
536
|
+
formatTime: t,
|
|
537
|
+
timeZone: n
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
function ye({ theme: e, geometry: t, tickWidth: n, minValue: r, maxValue: i, className: a }) {
|
|
541
|
+
let o = q(), l = J(), d = K(r, l, o.width), f = K(i, l, o.width), p = c.useMemo(() => {
|
|
542
|
+
let e = [];
|
|
543
|
+
if (!Number.isNaN(d) && d > 0) {
|
|
544
|
+
let t = d - n;
|
|
545
|
+
for (d > o.width && (t = d - n * Math.floor((d - o.width) / n)), e.push(t); t > 0;) t -= n, e.push(t);
|
|
546
|
+
}
|
|
547
|
+
if (!Number.isNaN(f) && f < o.width) {
|
|
548
|
+
let t = f;
|
|
549
|
+
for (f < 0 && (t = f + n * Math.floor((0 - f) / n) - n), e.push(t); t < o.width;) t += n, e.push(t);
|
|
550
|
+
}
|
|
551
|
+
return e.map(t).join("");
|
|
552
|
+
}, [
|
|
553
|
+
d,
|
|
554
|
+
t,
|
|
555
|
+
f,
|
|
556
|
+
n,
|
|
557
|
+
o.width
|
|
558
|
+
]);
|
|
559
|
+
return /* @__PURE__ */ u("path", {
|
|
560
|
+
className: s("rt-DateRangeSelectionTicks", a),
|
|
561
|
+
"data-theme": e,
|
|
562
|
+
d: p
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
function be() {
|
|
566
|
+
let e = q(), { start: t, end: n } = J(), [, r] = c.useState({}), i = Date.now(), a = n.valueOf() > i, o = Math.max(p, b * (n.valueOf() - t.valueOf()) / e.width, t.valueOf() - i);
|
|
567
|
+
return c.useEffect(() => {
|
|
568
|
+
let e = null;
|
|
569
|
+
return a && (e = window.setInterval(() => r({}), o)), () => {
|
|
570
|
+
e && window.clearInterval(e);
|
|
571
|
+
};
|
|
572
|
+
}, [a, o]), i < t.valueOf() || n.valueOf() < i ? null : /* @__PURE__ */ u("path", {
|
|
573
|
+
d: `M${(i - t.valueOf()) / (n.valueOf() - t.valueOf()) * e.width},0l0,${e.height}`,
|
|
574
|
+
className: "rt-DateRangeSelectionNowLine"
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
function xe({ className: e, children: t, start: n, end: r, minValue: i, maxValue: a, onMove: o, onMoveStart: l, onMoveEnd: p, displayNow: m, displayTickLabels: h, formatTime: g, timeZone: _, dragging: v, dragDisabled: y, renderAdditionalRulerContent: b, rootRef: x }) {
|
|
578
|
+
let [S, C] = c.useState(null), w = c.useMemo(() => ({
|
|
579
|
+
start: n,
|
|
580
|
+
end: r
|
|
581
|
+
}), [n, r]), [T, E] = c.useState({
|
|
582
|
+
width: 0,
|
|
583
|
+
height: 0
|
|
584
|
+
}), D = c.useCallback(() => {
|
|
585
|
+
if (!S) return;
|
|
586
|
+
let { width: e, height: t } = S.getBoundingClientRect();
|
|
587
|
+
E({
|
|
588
|
+
width: e,
|
|
589
|
+
height: t
|
|
590
|
+
});
|
|
591
|
+
}, [S]);
|
|
592
|
+
M(S, D), c.useLayoutEffect(() => {
|
|
593
|
+
D();
|
|
594
|
+
}, [D]);
|
|
595
|
+
let A = !!(i || a);
|
|
596
|
+
return /* @__PURE__ */ u("div", {
|
|
597
|
+
ref: x,
|
|
598
|
+
className: s("rt-DateRangeSelectionDateTimeRuler", e),
|
|
599
|
+
"data-dragging": v ? "" : void 0,
|
|
600
|
+
children: /* @__PURE__ */ u(k.Provider, {
|
|
601
|
+
value: w,
|
|
602
|
+
children: /* @__PURE__ */ d(O.Provider, {
|
|
603
|
+
value: T,
|
|
604
|
+
children: [/* @__PURE__ */ d(ge, {
|
|
605
|
+
ref: C,
|
|
606
|
+
onMove: o,
|
|
607
|
+
onMoveStart: l,
|
|
608
|
+
onMoveEnd: p,
|
|
609
|
+
dragDisabled: y,
|
|
610
|
+
children: [
|
|
611
|
+
/* @__PURE__ */ u(_e, { timeZone: _ }),
|
|
612
|
+
/* @__PURE__ */ u(ve, {
|
|
613
|
+
displayTickLabels: h,
|
|
614
|
+
formatTime: g,
|
|
615
|
+
timeZone: _
|
|
616
|
+
}),
|
|
617
|
+
A ? /* @__PURE__ */ u(ye, {
|
|
618
|
+
theme: "dim",
|
|
619
|
+
minValue: i,
|
|
620
|
+
maxValue: a,
|
|
621
|
+
geometry: me({
|
|
622
|
+
tickHeight: 10,
|
|
623
|
+
viewportHeight: T.height
|
|
624
|
+
}),
|
|
625
|
+
tickWidth: T.height + 10
|
|
626
|
+
}) : null,
|
|
627
|
+
m ? /* @__PURE__ */ u(be, {}) : null,
|
|
628
|
+
b?.({
|
|
629
|
+
interval: w,
|
|
630
|
+
dimensions: T
|
|
631
|
+
})
|
|
632
|
+
]
|
|
633
|
+
}), S ? f(t, S) : null]
|
|
634
|
+
})
|
|
635
|
+
})
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
function Se({ state: e, style: t, className: n, id: r, disabled: i = !1, readOnly: a = !1, "aria-labelledby": o }) {
|
|
639
|
+
let l = !i && !a, { start: f, end: p } = J(), m = q(), [h, g] = c.useState(null), _ = c.useRef({ isZooming: !1 }), v = c.useId(), y = r ?? v, w = o?.trim() || void 0, T = Math.max(m.width, 1), E = b * (p.valueOf() - f.valueOf()) / T, D = c.useCallback(() => {
|
|
640
|
+
e.endDragging(), g(null);
|
|
641
|
+
}, [e]), { moveProps: O } = j({
|
|
642
|
+
onMoveStart: (t) => {
|
|
643
|
+
g("dragger"), e.startDragging(), _.current = { isZooming: e.canResize && (t.ctrlKey || t.metaKey) };
|
|
644
|
+
},
|
|
645
|
+
onMoveEnd: D,
|
|
646
|
+
onMove: (t) => {
|
|
647
|
+
if (t.deltaX !== 0) if (_.current.isZooming) {
|
|
648
|
+
let n = Math.exp(t.deltaX * C / T);
|
|
649
|
+
n = Math.min(Math.max(n, x), S), e.scale(n, { visualMinDuration: E });
|
|
650
|
+
} else {
|
|
651
|
+
let n = t.deltaX * (p.valueOf() - f.valueOf()) / T;
|
|
652
|
+
t.pointerType === "keyboard" && (n = n > 0 ? Math.max(n, e.align) : Math.min(n, -e.align)), e.move(n, { visualMinDuration: E });
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}), { moveProps: k } = j({
|
|
656
|
+
onMoveStart: () => {
|
|
657
|
+
g("start"), e.startDragging();
|
|
658
|
+
},
|
|
659
|
+
onMoveEnd: D,
|
|
660
|
+
onMove: (t) => {
|
|
661
|
+
if (t.deltaX === 0) return;
|
|
662
|
+
let n = t.deltaX * (p.valueOf() - f.valueOf()) / T;
|
|
663
|
+
t.pointerType === "keyboard" && (n = n > 0 ? Math.max(n, e.align) : Math.min(n, -e.align)), e.moveStart(n, { visualMinDuration: E });
|
|
664
|
+
}
|
|
665
|
+
}), { moveProps: A } = j({
|
|
666
|
+
onMoveStart: () => {
|
|
667
|
+
g("end"), e.startDragging();
|
|
668
|
+
},
|
|
669
|
+
onMoveEnd: D,
|
|
670
|
+
onMove: (t) => {
|
|
671
|
+
if (t.deltaX === 0) return;
|
|
672
|
+
let n = t.deltaX * (p.valueOf() - f.valueOf()) / T;
|
|
673
|
+
t.pointerType === "keyboard" && (n = n > 0 ? Math.max(n, e.align) : Math.min(n, -e.align)), e.moveEnd(n, { visualMinDuration: E });
|
|
674
|
+
}
|
|
675
|
+
}), { start: M, end: N } = e.value, P = oe({
|
|
676
|
+
start: f.valueOf(),
|
|
677
|
+
end: p.valueOf()
|
|
678
|
+
}, {
|
|
679
|
+
start: 0,
|
|
680
|
+
end: m.width
|
|
681
|
+
}, M.valueOf()), F = oe({
|
|
682
|
+
start: f.valueOf(),
|
|
683
|
+
end: p.valueOf()
|
|
684
|
+
}, {
|
|
685
|
+
start: 0,
|
|
686
|
+
end: m.width
|
|
687
|
+
}, N.valueOf()), I = c.useRef(null), L = c.useRef(null), R = c.useRef(null);
|
|
688
|
+
return /* @__PURE__ */ d("div", {
|
|
689
|
+
className: s("rt-DateRangeSelectionControl", n),
|
|
690
|
+
style: {
|
|
691
|
+
...t,
|
|
692
|
+
left: P,
|
|
693
|
+
width: F - P
|
|
694
|
+
},
|
|
695
|
+
children: [
|
|
696
|
+
/* @__PURE__ */ u("div", {
|
|
697
|
+
className: "rt-DateRangeSelectionControlDragger",
|
|
698
|
+
"data-dragging": h === "dragger" ? "" : void 0,
|
|
699
|
+
"data-inactive": h && h !== "dragger" ? "" : void 0,
|
|
700
|
+
...l ? O : {},
|
|
701
|
+
onClick: i ? void 0 : () => I.current?.focus(),
|
|
702
|
+
children: /* @__PURE__ */ u("div", {
|
|
703
|
+
className: "rt-DateRangeSelectionSliderInputWrapper",
|
|
704
|
+
children: /* @__PURE__ */ u("input", {
|
|
705
|
+
id: `${y}-range`,
|
|
706
|
+
ref: I,
|
|
707
|
+
className: "rt-DateRangeSelectionSliderInput",
|
|
708
|
+
type: "range",
|
|
709
|
+
step: 1,
|
|
710
|
+
"aria-label": w ? void 0 : "Range",
|
|
711
|
+
"aria-labelledby": w,
|
|
712
|
+
"aria-orientation": "horizontal",
|
|
713
|
+
"aria-valuetext": `${H(M)} - ${H(N)}`,
|
|
714
|
+
value: 0,
|
|
715
|
+
disabled: i,
|
|
716
|
+
readOnly: a,
|
|
717
|
+
onChange: () => {}
|
|
718
|
+
})
|
|
719
|
+
})
|
|
720
|
+
}),
|
|
721
|
+
e.canResize ? /* @__PURE__ */ u("div", {
|
|
722
|
+
className: "rt-DateRangeSelectionControlStart",
|
|
723
|
+
"data-dragging": h === "start" ? "" : void 0,
|
|
724
|
+
"data-inactive": h && h !== "start" ? "" : void 0,
|
|
725
|
+
...l ? k : {},
|
|
726
|
+
onClick: i ? void 0 : () => L.current?.focus(),
|
|
727
|
+
children: /* @__PURE__ */ u("div", {
|
|
728
|
+
className: "rt-DateRangeSelectionSliderInputWrapper",
|
|
729
|
+
children: /* @__PURE__ */ u("input", {
|
|
730
|
+
id: `${y}-start`,
|
|
731
|
+
ref: L,
|
|
732
|
+
className: "rt-DateRangeSelectionSliderInput",
|
|
733
|
+
type: "range",
|
|
734
|
+
step: 1,
|
|
735
|
+
"aria-label": w ? void 0 : "Start of range",
|
|
736
|
+
"aria-labelledby": w,
|
|
737
|
+
"aria-orientation": "horizontal",
|
|
738
|
+
"aria-valuetext": H(M),
|
|
739
|
+
value: 0,
|
|
740
|
+
disabled: i,
|
|
741
|
+
readOnly: a,
|
|
742
|
+
onChange: () => {}
|
|
743
|
+
})
|
|
744
|
+
})
|
|
745
|
+
}) : null,
|
|
746
|
+
e.canResize ? /* @__PURE__ */ u("div", {
|
|
747
|
+
className: "rt-DateRangeSelectionControlEnd",
|
|
748
|
+
"data-dragging": h === "end" ? "" : void 0,
|
|
749
|
+
"data-inactive": h && h !== "end" ? "" : void 0,
|
|
750
|
+
...l ? A : {},
|
|
751
|
+
onClick: i ? void 0 : () => R.current?.focus(),
|
|
752
|
+
children: /* @__PURE__ */ u("div", {
|
|
753
|
+
className: "rt-DateRangeSelectionSliderInputWrapper",
|
|
754
|
+
children: /* @__PURE__ */ u("input", {
|
|
755
|
+
id: `${y}-end`,
|
|
756
|
+
ref: R,
|
|
757
|
+
className: "rt-DateRangeSelectionSliderInput",
|
|
758
|
+
type: "range",
|
|
759
|
+
step: 1,
|
|
760
|
+
"aria-label": w ? void 0 : "End of range",
|
|
761
|
+
"aria-labelledby": w,
|
|
762
|
+
"aria-orientation": "horizontal",
|
|
763
|
+
"aria-valuetext": H(N),
|
|
764
|
+
value: 0,
|
|
765
|
+
disabled: i,
|
|
766
|
+
readOnly: a,
|
|
767
|
+
onChange: () => {}
|
|
768
|
+
})
|
|
769
|
+
})
|
|
770
|
+
}) : null
|
|
771
|
+
]
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
var Ce = c.createContext(null);
|
|
775
|
+
function X(e) {
|
|
776
|
+
let t = c.useContext(Ce);
|
|
777
|
+
if (!t) throw Error(`${e} must be used within DateRangeSelection.Root`);
|
|
778
|
+
return t;
|
|
779
|
+
}
|
|
780
|
+
function we(n) {
|
|
781
|
+
let { value: r, defaultValue: a, onChange: o, onUpdate: l, minValue: f, maxValue: p, minDuration: m, maxDuration: h, align: g, placeholderValue: _, numberOfIntervals: v, placeOnRuler: y, ...b } = n, x = ae({
|
|
782
|
+
value: r,
|
|
783
|
+
defaultValue: a,
|
|
784
|
+
onChange: o,
|
|
785
|
+
onUpdate: l,
|
|
786
|
+
minValue: f,
|
|
787
|
+
maxValue: p,
|
|
788
|
+
minDuration: m,
|
|
789
|
+
maxDuration: h,
|
|
790
|
+
align: g,
|
|
791
|
+
placeholderValue: _,
|
|
792
|
+
numberOfIntervals: v,
|
|
793
|
+
placeOnRuler: y
|
|
794
|
+
}), { children: S, className: C, color: w, radius: T, style: E, id: D, disabled: O, readOnly: k, ref: A, ...j } = e(b, i, t), M = c.Children.toArray(S).some((e) => c.isValidElement(e) && e.type === Z), N = c.useId(), P = D ?? N, F = c.useMemo(() => ({
|
|
795
|
+
state: x,
|
|
796
|
+
id: P,
|
|
797
|
+
minValue: f,
|
|
798
|
+
maxValue: p,
|
|
799
|
+
disabled: O,
|
|
800
|
+
readOnly: k
|
|
801
|
+
}), [
|
|
802
|
+
x,
|
|
803
|
+
P,
|
|
804
|
+
f,
|
|
805
|
+
p,
|
|
806
|
+
O,
|
|
807
|
+
k
|
|
808
|
+
]);
|
|
809
|
+
return /* @__PURE__ */ u(Ce.Provider, {
|
|
810
|
+
value: F,
|
|
811
|
+
children: /* @__PURE__ */ d("div", {
|
|
812
|
+
...j,
|
|
813
|
+
ref: A,
|
|
814
|
+
id: P,
|
|
815
|
+
"data-accent-color": w,
|
|
816
|
+
"data-radius": T,
|
|
817
|
+
"data-disabled": O ? "" : void 0,
|
|
818
|
+
"data-readonly": k ? "" : void 0,
|
|
819
|
+
className: s("rt-DateRangeSelectionRoot", C),
|
|
820
|
+
style: E,
|
|
821
|
+
dir: "ltr",
|
|
822
|
+
children: [M ? null : /* @__PURE__ */ u(Z, {}), S]
|
|
823
|
+
})
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
we.displayName = "DateRangeSelection.Root";
|
|
827
|
+
function Z({ className: e, displayNow: t, displayTickLabels: n = !0, draggableRuler: r, timeZone: i, formatTime: a, renderAdditionalRulerContent: o, ref: l }) {
|
|
828
|
+
let d = X("DateRangeSelection.Ruler"), f = d.state, p = d.minValue, m = d.maxValue, { disabled: h, readOnly: g } = d, _ = !h && !g, [v, y] = c.useState(!1), b = c.useCallback(() => {
|
|
829
|
+
f.setDraggingValue(f.value), y(!0);
|
|
830
|
+
}, [f]), x = c.useCallback((e) => {
|
|
831
|
+
let t = f.viewportInterval.end.valueOf() - f.viewportInterval.start.valueOf(), n = -Math.floor(e * t / 100);
|
|
832
|
+
f.move(n);
|
|
833
|
+
}, [f]), S = c.useCallback(() => {
|
|
834
|
+
y(!1), f.endDragging();
|
|
835
|
+
}, [f]);
|
|
836
|
+
return /* @__PURE__ */ u(xe, {
|
|
837
|
+
rootRef: l,
|
|
838
|
+
className: s(e),
|
|
839
|
+
dragging: v,
|
|
840
|
+
...f.viewportInterval,
|
|
841
|
+
onMoveStart: b,
|
|
842
|
+
onMove: r && _ ? x : void 0,
|
|
843
|
+
onMoveEnd: S,
|
|
844
|
+
dragDisabled: f.isDragging,
|
|
845
|
+
displayNow: t,
|
|
846
|
+
displayTickLabels: n,
|
|
847
|
+
minValue: p,
|
|
848
|
+
maxValue: m,
|
|
849
|
+
formatTime: a,
|
|
850
|
+
timeZone: i,
|
|
851
|
+
renderAdditionalRulerContent: o,
|
|
852
|
+
children: /* @__PURE__ */ u(Se, {
|
|
853
|
+
id: d.id,
|
|
854
|
+
state: f,
|
|
855
|
+
disabled: h,
|
|
856
|
+
readOnly: g
|
|
857
|
+
})
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
Z.displayName = "DateRangeSelection.Ruler";
|
|
861
|
+
var Q = c.forwardRef((t, n) => {
|
|
862
|
+
let { className: r, color: i, ...o } = e(t, a);
|
|
863
|
+
return /* @__PURE__ */ u("div", {
|
|
864
|
+
"data-accent-color": i,
|
|
865
|
+
...o,
|
|
866
|
+
ref: n,
|
|
867
|
+
className: s("rt-DateRangeSelectionSlot", r)
|
|
868
|
+
});
|
|
869
|
+
});
|
|
870
|
+
Q.displayName = "DateRangeSelection.Slot";
|
|
871
|
+
var $ = c.forwardRef(({ factor: e = 1, defaultAriaLabel: t, className: n, disabled: r, children: i, ...a }, c) => {
|
|
872
|
+
let { state: l, disabled: d, readOnly: f } = X("DateRangeSelection scale button"), p = r ?? (d || f);
|
|
873
|
+
return /* @__PURE__ */ u(o, {
|
|
874
|
+
type: "button",
|
|
875
|
+
variant: "ghost",
|
|
876
|
+
size: "1",
|
|
877
|
+
"aria-label": t,
|
|
878
|
+
...a,
|
|
879
|
+
disabled: p,
|
|
880
|
+
ref: c,
|
|
881
|
+
className: s("rt-DateRangeSelectionScaleButton", n),
|
|
882
|
+
onClick: () => {
|
|
883
|
+
p || (l.startDragging(), l.scale(e), l.endDragging());
|
|
884
|
+
},
|
|
885
|
+
children: i
|
|
886
|
+
});
|
|
887
|
+
});
|
|
888
|
+
$.displayName = "DateRangeSelection.ScaleButton";
|
|
889
|
+
var Te = c.forwardRef(({ factor: e = .5, children: t, ...r }, i) => /* @__PURE__ */ u(Q, { children: /* @__PURE__ */ u($, {
|
|
890
|
+
ref: i,
|
|
891
|
+
factor: e,
|
|
892
|
+
defaultAriaLabel: "Decrease range",
|
|
893
|
+
...r,
|
|
894
|
+
children: t ?? /* @__PURE__ */ u(n, {})
|
|
895
|
+
}) }));
|
|
896
|
+
Te.displayName = "DateRangeSelection.DecreaseButton";
|
|
897
|
+
var Ee = c.forwardRef(({ factor: e = 1.5, children: t, ...n }, i) => /* @__PURE__ */ d(Q, { children: [/* @__PURE__ */ u($, {
|
|
898
|
+
ref: i,
|
|
899
|
+
factor: e,
|
|
900
|
+
defaultAriaLabel: "Increase range",
|
|
901
|
+
...n,
|
|
902
|
+
children: t ?? /* @__PURE__ */ u(r, {})
|
|
903
|
+
}), " "] }));
|
|
904
|
+
Ee.displayName = "DateRangeSelection.IncreaseButton";
|
|
905
|
+
var De = {
|
|
906
|
+
Root: we,
|
|
907
|
+
Ruler: Z,
|
|
908
|
+
Slot: Q,
|
|
909
|
+
DecreaseButton: Te,
|
|
910
|
+
IncreaseButton: Ee
|
|
911
|
+
};
|
|
912
|
+
//#endregion
|
|
913
|
+
export { De as DateRangeSelection, ae as useDateRangeSelectionState };
|