rangeflow 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +210 -210
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { createContext as e, createElement as t, memo as n, startTransition as r, useCallback as i, useContext as a, useEffect as o,
|
|
2
|
-
import
|
|
3
|
-
import { immer as
|
|
4
|
-
import { createStore as
|
|
5
|
-
import { jsx as
|
|
6
|
-
import { RestrictToHorizontalAxis as
|
|
7
|
-
import { DragDropProvider as
|
|
8
|
-
import
|
|
9
|
-
import { AnimatePresence as ne, motion as
|
|
1
|
+
import { createContext as e, createElement as t, memo as n, startTransition as r, useCallback as i, useContext as a, useEffect as o, useId as s, useMemo as c, useRef as l, useState as u } from "react";
|
|
2
|
+
import d from "dayjs";
|
|
3
|
+
import { immer as f } from "zustand/middleware/immer";
|
|
4
|
+
import { createStore as p } from "zustand/vanilla";
|
|
5
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
6
|
+
import { RestrictToHorizontalAxis as g, restrictShapeToBoundingRectangle as _ } from "@dnd-kit/abstract/modifiers";
|
|
7
|
+
import { DragDropProvider as v, DragOverlay as y, useDragDropMonitor as ee, useDraggable as te } from "@dnd-kit/react";
|
|
8
|
+
import b, { clsx as x } from "clsx";
|
|
9
|
+
import { AnimatePresence as ne, motion as S } from "motion/react";
|
|
10
10
|
import { useStore as re } from "zustand";
|
|
11
11
|
import { KeyboardSensor as ie, PointerSensor as ae } from "@dnd-kit/dom";
|
|
12
|
-
import { Group as oe, Panel as
|
|
13
|
-
import { Modifier as
|
|
14
|
-
import { Rectangle as
|
|
15
|
-
import { effect as
|
|
16
|
-
import { DayPicker as
|
|
12
|
+
import { Group as oe, Panel as C, Separator as w } from "react-resizable-panels";
|
|
13
|
+
import { Modifier as se, configurator as ce } from "@dnd-kit/abstract";
|
|
14
|
+
import { Rectangle as T } from "@dnd-kit/geometry";
|
|
15
|
+
import { effect as E, signal as D } from "@dnd-kit/state";
|
|
16
|
+
import { DayPicker as le } from "react-day-picker";
|
|
17
17
|
import * as O from "@radix-ui/react-popover";
|
|
18
18
|
//#region src/package/rangeflow/constants/date-ranges.ts
|
|
19
|
-
var
|
|
19
|
+
var ue = [
|
|
20
20
|
{
|
|
21
21
|
label: "2 Weeks",
|
|
22
|
-
from:
|
|
23
|
-
to:
|
|
22
|
+
from: d().subtract(1, "weeks").toDate(),
|
|
23
|
+
to: d().add(1, "weeks").toDate()
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
label: "30 Days",
|
|
27
|
-
from:
|
|
28
|
-
to:
|
|
27
|
+
from: d().subtract(15, "day").toDate(),
|
|
28
|
+
to: d().add(15, "day").toDate()
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
label: "90 Days",
|
|
32
|
-
from:
|
|
33
|
-
to:
|
|
32
|
+
from: d().subtract(45, "day").toDate(),
|
|
33
|
+
to: d().add(45, "day").toDate()
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
label: "6 Months",
|
|
37
|
-
from:
|
|
38
|
-
to:
|
|
37
|
+
from: d().subtract(3, "months").toDate(),
|
|
38
|
+
to: d().add(3, "months").toDate()
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
label: "1 Year",
|
|
42
|
-
from:
|
|
43
|
-
to:
|
|
42
|
+
from: d().subtract(6, "months").toDate(),
|
|
43
|
+
to: d().add(6, "months").toDate()
|
|
44
44
|
}
|
|
45
45
|
], k = "left-spacer", A = "right-spacer", j = "slider-track-thumb";
|
|
46
46
|
//#endregion
|
|
@@ -60,11 +60,11 @@ function N(e, t) {
|
|
|
60
60
|
//#region src/package/rangeflow/utils/create-slider-values.ts
|
|
61
61
|
var P = N([1, 100], [5, 100]);
|
|
62
62
|
function F(e, t) {
|
|
63
|
-
let n =
|
|
63
|
+
let n = d(e.from).startOf("day"), r = d(e.to).startOf("day").diff(n, "day"), i = d(t.from).startOf("day"), a = d(t.to).startOf("day"), o = Math.max(i.diff(n, "day"), 0), s = Math.max(a.diff(i, "day"), 0) * 100 / r, c = o * 100 / r, l = Math.max(P(s), 5), u = M(c - (l - s), 0, Math.max(100 - l, 0));
|
|
64
64
|
return {
|
|
65
65
|
size: l,
|
|
66
|
-
left:
|
|
67
|
-
right: Math.max(100 -
|
|
66
|
+
left: u,
|
|
67
|
+
right: Math.max(100 - u - l, 0)
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
//#endregion
|
|
@@ -85,33 +85,33 @@ function I(e, t, n) {
|
|
|
85
85
|
//#endregion
|
|
86
86
|
//#region src/package/rangeflow/context/hooks/use-context-events.ts
|
|
87
87
|
function L({ onChange: e }) {
|
|
88
|
-
let t =
|
|
88
|
+
let t = l({ onChange: e });
|
|
89
89
|
return o(() => {
|
|
90
90
|
t.current.onChange = e;
|
|
91
|
-
}),
|
|
91
|
+
}), c(() => ({ onChange: (e) => t.current.onChange?.(e) }), []);
|
|
92
92
|
}
|
|
93
93
|
//#endregion
|
|
94
94
|
//#region src/package/rangeflow/context/hooks/use-context-refs.ts
|
|
95
95
|
function R() {
|
|
96
|
-
let e =
|
|
97
|
-
return
|
|
96
|
+
let e = l(null);
|
|
97
|
+
return c(() => ({ slider: { root: e } }), []);
|
|
98
98
|
}
|
|
99
99
|
//#endregion
|
|
100
100
|
//#region src/package/rangeflow/context/hooks/use-context-slots.ts
|
|
101
101
|
function z(e) {
|
|
102
|
-
return
|
|
102
|
+
return c(() => ({ ...e }), [e]);
|
|
103
103
|
}
|
|
104
104
|
//#endregion
|
|
105
105
|
//#region src/package/rangeflow/context/root.ts
|
|
106
|
-
var B = (e) =>
|
|
106
|
+
var B = (e) => p()(f((t) => ({
|
|
107
107
|
...e,
|
|
108
108
|
update: (e) => t(e),
|
|
109
109
|
reset: () => t(() => structuredClone(e))
|
|
110
110
|
}))), V = e(null);
|
|
111
111
|
//#endregion
|
|
112
112
|
//#region src/package/rangeflow/context/ContextProvider.tsx
|
|
113
|
-
function H({ children: e, defaultRange: t, defaultSelected: n, disabled: r, duration: i, calendar: a = !0, ranges: o =
|
|
114
|
-
let
|
|
113
|
+
function H({ children: e, defaultRange: t, defaultSelected: n, disabled: r, duration: i, calendar: a = !0, ranges: o = ue, CalendarProps: s, Slots: l, api: d, onChange: f }) {
|
|
114
|
+
let p = R(), h = L({ onChange: f }), g = z(l), [_] = u(() => B({
|
|
115
115
|
ranges: o,
|
|
116
116
|
disabled: r,
|
|
117
117
|
duration: i,
|
|
@@ -120,40 +120,40 @@ function H({ children: e, defaultRange: t, defaultSelected: n, disabled: r, dura
|
|
|
120
120
|
default_range: t,
|
|
121
121
|
selected_date: n,
|
|
122
122
|
slider: F(t, n),
|
|
123
|
-
CalendarProps:
|
|
123
|
+
CalendarProps: s
|
|
124
124
|
}));
|
|
125
|
-
I(_,
|
|
126
|
-
let v =
|
|
125
|
+
I(_, p, d);
|
|
126
|
+
let v = c(() => ({
|
|
127
127
|
store: _,
|
|
128
128
|
events: h,
|
|
129
|
-
refs:
|
|
129
|
+
refs: p,
|
|
130
130
|
slots: g
|
|
131
131
|
}), [
|
|
132
132
|
_,
|
|
133
133
|
h,
|
|
134
|
-
|
|
134
|
+
p,
|
|
135
135
|
g
|
|
136
136
|
]);
|
|
137
|
-
return /* @__PURE__ */
|
|
137
|
+
return /* @__PURE__ */ m(V.Provider, {
|
|
138
138
|
value: v,
|
|
139
139
|
children: e
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
//#endregion
|
|
143
143
|
//#region src/package/rangeflow/animations/OdometerText.tsx
|
|
144
|
-
var U = n(({ children: e, className: t }) => /* @__PURE__ */
|
|
145
|
-
className:
|
|
144
|
+
var U = n(({ children: e, className: t }) => /* @__PURE__ */ m("span", {
|
|
145
|
+
className: b("inline-flex tabular-nums", t),
|
|
146
146
|
children: [...e].map((e, t) => {
|
|
147
147
|
let n = e === " " ? "\xA0" : e;
|
|
148
|
-
return /* @__PURE__ */
|
|
148
|
+
return /* @__PURE__ */ h("span", {
|
|
149
149
|
className: "relative inline-block overflow-hidden leading-none",
|
|
150
|
-
children: [/* @__PURE__ */
|
|
150
|
+
children: [/* @__PURE__ */ m("span", {
|
|
151
151
|
className: "invisible",
|
|
152
152
|
children: n
|
|
153
|
-
}), /* @__PURE__ */
|
|
153
|
+
}), /* @__PURE__ */ m(ne, {
|
|
154
154
|
initial: !1,
|
|
155
155
|
mode: "popLayout",
|
|
156
|
-
children: /* @__PURE__ */
|
|
156
|
+
children: /* @__PURE__ */ m(S.span, {
|
|
157
157
|
animate: {
|
|
158
158
|
y: 0,
|
|
159
159
|
filter: "blur(0px)",
|
|
@@ -189,7 +189,7 @@ var U = n(({ children: e, className: t }) => /* @__PURE__ */ p("span", {
|
|
|
189
189
|
//#endregion
|
|
190
190
|
//#region src/package/rangeflow/hooks/use-days-in-range.ts
|
|
191
191
|
function W(e) {
|
|
192
|
-
return
|
|
192
|
+
return c(() => d(e.to).diff(d(e.from), "day"), [e.from, e.to]);
|
|
193
193
|
}
|
|
194
194
|
//#endregion
|
|
195
195
|
//#region src/package/rangeflow/hooks/use-rangeflow-slots.ts
|
|
@@ -203,15 +203,15 @@ function K(e) {
|
|
|
203
203
|
}
|
|
204
204
|
//#endregion
|
|
205
205
|
//#region src/package/rangeflow/components/DateSlider/DateLabelsTrack.tsx
|
|
206
|
-
function
|
|
206
|
+
function de(e) {
|
|
207
207
|
return e > 120 ? "MMM YYYY" : e > 7 ? "MMM DD" : "ddd DD";
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function fe(e) {
|
|
210
210
|
return e > 120 ? 8 : e > 30 ? 10 : e > 7 ? 8 : Math.min(e + 1, 8);
|
|
211
211
|
}
|
|
212
|
-
var
|
|
213
|
-
let e = K((e) => e.range), n = W(e), { DateLabelsTrack: r } = G(), i =
|
|
214
|
-
let t =
|
|
212
|
+
var pe = n(() => {
|
|
213
|
+
let e = K((e) => e.range), n = W(e), { DateLabelsTrack: r } = G(), i = c(() => {
|
|
214
|
+
let t = de(n), r = fe(n), i = d(e.from), a = d(e.to).diff(i);
|
|
215
215
|
return Array.from({ length: r }, (e, n) => {
|
|
216
216
|
let o = n / (r - 1);
|
|
217
217
|
return i.add(a * o, "ms").format(t);
|
|
@@ -221,24 +221,24 @@ var fe = n(() => {
|
|
|
221
221
|
e.to,
|
|
222
222
|
n
|
|
223
223
|
]);
|
|
224
|
-
return r ? t(r) : /* @__PURE__ */
|
|
225
|
-
className:
|
|
226
|
-
children: i.map((e, t) => /* @__PURE__ */
|
|
227
|
-
className:
|
|
224
|
+
return r ? t(r) : /* @__PURE__ */ m("div", {
|
|
225
|
+
className: b("rangeflow-labels flex w-full items-center justify-between select-none", "absolute top-10 left-0 px-2", "text-xs tracking-tighter text-(--rangeflow-text-faint) uppercase"),
|
|
226
|
+
children: i.map((e, t) => /* @__PURE__ */ m(U, {
|
|
227
|
+
className: b("rangeflow-label", { "font-medium text-(--rangeflow-text-muted)": t === 0 || t === i.length - 1 }),
|
|
228
228
|
children: e
|
|
229
229
|
}, t))
|
|
230
230
|
});
|
|
231
231
|
});
|
|
232
232
|
//#endregion
|
|
233
233
|
//#region src/package/rangeflow/icons/DoubleChevronLeftIcon.tsx
|
|
234
|
-
function
|
|
235
|
-
return /* @__PURE__ */
|
|
234
|
+
function me() {
|
|
235
|
+
return /* @__PURE__ */ m("svg", {
|
|
236
236
|
fill: "none",
|
|
237
237
|
height: "15",
|
|
238
238
|
viewBox: "0 0 15 15",
|
|
239
239
|
width: "15",
|
|
240
240
|
xmlns: "http://www.w3.org/2000/svg",
|
|
241
|
-
children: /* @__PURE__ */
|
|
241
|
+
children: /* @__PURE__ */ m("path", {
|
|
242
242
|
clipRule: "evenodd",
|
|
243
243
|
d: "M6.85355 3.85355C7.04882 3.65829 7.04882 3.34171 6.85355 3.14645C6.65829 2.95118 6.34171 2.95118 6.14645 3.14645L2.14645 7.14645C1.95118 7.34171 1.95118 7.65829 2.14645 7.85355L6.14645 11.8536C6.34171 12.0488 6.65829 12.0488 6.85355 11.8536C7.04882 11.6583 7.04882 11.3417 6.85355 11.1464L3.20711 7.5L6.85355 3.85355ZM12.8536 3.85355C13.0488 3.65829 13.0488 3.34171 12.8536 3.14645C12.6583 2.95118 12.3417 2.95118 12.1464 3.14645L8.14645 7.14645C7.95118 7.34171 7.95118 7.65829 8.14645 7.85355L12.1464 11.8536C12.3417 12.0488 12.6583 12.0488 12.8536 11.8536C13.0488 11.6583 13.0488 11.3417 12.8536 11.1464L9.20711 7.5L12.8536 3.85355Z",
|
|
244
244
|
fill: "currentColor",
|
|
@@ -248,14 +248,14 @@ function pe() {
|
|
|
248
248
|
}
|
|
249
249
|
//#endregion
|
|
250
250
|
//#region src/package/rangeflow/icons/DoubleChevronRightIcon.tsx
|
|
251
|
-
function
|
|
252
|
-
return /* @__PURE__ */
|
|
251
|
+
function he() {
|
|
252
|
+
return /* @__PURE__ */ m("svg", {
|
|
253
253
|
fill: "none",
|
|
254
254
|
height: "15",
|
|
255
255
|
viewBox: "0 0 15 15",
|
|
256
256
|
width: "15",
|
|
257
257
|
xmlns: "http://www.w3.org/2000/svg",
|
|
258
|
-
children: /* @__PURE__ */
|
|
258
|
+
children: /* @__PURE__ */ m("path", {
|
|
259
259
|
clipRule: "evenodd",
|
|
260
260
|
d: "M2.14645 11.1464C1.95118 11.3417 1.95118 11.6583 2.14645 11.8536C2.34171 12.0488 2.65829 12.0488 2.85355 11.8536L6.85355 7.85355C7.04882 7.65829 7.04882 7.34171 6.85355 7.14645L2.85355 3.14645C2.65829 2.95118 2.34171 2.95118 2.14645 3.14645C1.95118 3.34171 1.95118 3.65829 2.14645 3.85355L5.79289 7.5L2.14645 11.1464ZM8.14645 11.1464C7.95118 11.3417 7.95118 11.6583 8.14645 11.8536C8.34171 12.0488 8.65829 12.0488 8.85355 11.8536L12.8536 7.85355C13.0488 7.65829 13.0488 7.34171 12.8536 7.14645L8.85355 3.14645C8.65829 2.95118 8.34171 2.95118 8.14645 3.14645C7.95118 3.34171 7.95118 3.65829 8.14645 3.85355L11.7929 7.5L8.14645 11.1464Z",
|
|
261
261
|
fill: "currentColor",
|
|
@@ -265,20 +265,20 @@ function me() {
|
|
|
265
265
|
}
|
|
266
266
|
//#endregion
|
|
267
267
|
//#region src/package/rangeflow/components/DateSlider/DateTickers.tsx
|
|
268
|
-
var
|
|
268
|
+
var ge = n(() => {
|
|
269
269
|
let { DateTickers: e } = G(), n = Math.min(Math.max(70, W(K((e) => e.range))), 100);
|
|
270
|
-
return e ? t(e) : /* @__PURE__ */
|
|
270
|
+
return e ? t(e) : /* @__PURE__ */ m("div", {
|
|
271
271
|
className: "rangeflow-tickers flex items-center gap-2",
|
|
272
|
-
children: /* @__PURE__ */
|
|
272
|
+
children: /* @__PURE__ */ m("div", {
|
|
273
273
|
className: "flex w-full justify-between",
|
|
274
|
-
children: Array.from({ length: n }).map((e, t) => /* @__PURE__ */
|
|
274
|
+
children: Array.from({ length: n }).map((e, t) => /* @__PURE__ */ m("div", { className: "rangeflow-ticker h-3 w-0.5 rounded-xs bg-(--rangeflow-ticker)" }, t))
|
|
275
275
|
})
|
|
276
276
|
});
|
|
277
277
|
});
|
|
278
278
|
//#endregion
|
|
279
279
|
//#region src/package/rangeflow/components/DateSlider/RangeStepButton.tsx
|
|
280
280
|
function q({ children: e, onClick: t }) {
|
|
281
|
-
return /* @__PURE__ */
|
|
281
|
+
return /* @__PURE__ */ m(S.span, {
|
|
282
282
|
className: "rangeflow-step-button shrink-0 cursor-pointer text-(--rangeflow-text) select-none hover:text-(--rangeflow-text-muted)",
|
|
283
283
|
whileHover: { scale: 1.1 },
|
|
284
284
|
onClick: t,
|
|
@@ -287,15 +287,15 @@ function q({ children: e, onClick: t }) {
|
|
|
287
287
|
}
|
|
288
288
|
//#endregion
|
|
289
289
|
//#region src/package/rangeflow/utils/derive-selection-from-layout.ts
|
|
290
|
-
var
|
|
291
|
-
function
|
|
292
|
-
let n = e[j], r = e[k], i = e[A], a =
|
|
290
|
+
var _e = N([5, 100], [1, 100]);
|
|
291
|
+
function ve(e, t) {
|
|
292
|
+
let n = e[j], r = e[k], i = e[A], a = d(t.from).startOf("day"), o = d(t.to).startOf("day").diff(a, "day"), s = _e(n), c = r + (n - s), l = Math.round(n) <= 5 ? 1 : Math.max(Math.round(s * o / 100), 1), u = M(Math.round(c * o / 100), 0, Math.max(o - l, 0));
|
|
293
293
|
return {
|
|
294
294
|
size: n,
|
|
295
295
|
left: r,
|
|
296
296
|
right: i,
|
|
297
|
-
from: a.add(
|
|
298
|
-
to: a.add(
|
|
297
|
+
from: a.add(u, "day").toDate(),
|
|
298
|
+
to: a.add(u + l, "day").toDate()
|
|
299
299
|
};
|
|
300
300
|
}
|
|
301
301
|
//#endregion
|
|
@@ -308,7 +308,7 @@ function J() {
|
|
|
308
308
|
function Y() {
|
|
309
309
|
let e = J();
|
|
310
310
|
return i((t) => {
|
|
311
|
-
let { range: n, update: r } = e.getState(), { size: i, left: a, right: o, from: s, to: c } =
|
|
311
|
+
let { range: n, update: r } = e.getState(), { size: i, left: a, right: o, from: s, to: c } = ve(t, n);
|
|
312
312
|
r((e) => {
|
|
313
313
|
e.slider.size = i, e.slider.left = a, e.slider.right = o, e.selected_date = {
|
|
314
314
|
from: s,
|
|
@@ -324,9 +324,9 @@ function X() {
|
|
|
324
324
|
}
|
|
325
325
|
//#endregion
|
|
326
326
|
//#region src/package/rangeflow/components/DateSlider/Slider/SliderLeftSpacer.tsx
|
|
327
|
-
function
|
|
328
|
-
let e = K((e) => e.slider.left), [t] =
|
|
329
|
-
return /* @__PURE__ */
|
|
327
|
+
function ye() {
|
|
328
|
+
let e = K((e) => e.slider.left), [t] = u(() => e);
|
|
329
|
+
return /* @__PURE__ */ m(C, {
|
|
330
330
|
className: "focus:outline-none",
|
|
331
331
|
defaultSize: `${t}%`,
|
|
332
332
|
id: k,
|
|
@@ -336,9 +336,9 @@ function ve() {
|
|
|
336
336
|
}
|
|
337
337
|
//#endregion
|
|
338
338
|
//#region src/package/rangeflow/components/DateSlider/Slider/SliderRightSpacer.tsx
|
|
339
|
-
function
|
|
340
|
-
let e = K((e) => e.slider.right), [t] =
|
|
341
|
-
return /* @__PURE__ */
|
|
339
|
+
function be() {
|
|
340
|
+
let e = K((e) => e.slider.right), [t] = u(() => e);
|
|
341
|
+
return /* @__PURE__ */ m(C, {
|
|
342
342
|
className: "focus:outline-none",
|
|
343
343
|
defaultSize: `${t}%`,
|
|
344
344
|
id: A,
|
|
@@ -348,41 +348,41 @@ function ye() {
|
|
|
348
348
|
}
|
|
349
349
|
//#endregion
|
|
350
350
|
//#region src/package/rangeflow/components/DateSlider/SliderValue.tsx
|
|
351
|
-
var
|
|
352
|
-
let { SliderValueLabel: e } = G(), n = K((e) => e.slider.size), r = K((e) => e.selected_date), i =
|
|
353
|
-
let e = Math.max(
|
|
351
|
+
var xe = n(() => {
|
|
352
|
+
let { SliderValueLabel: e } = G(), n = K((e) => e.slider.size), r = K((e) => e.selected_date), i = c(() => {
|
|
353
|
+
let e = Math.max(d(r.to).diff(r.from, "day"), 1);
|
|
354
354
|
return n < 10 ? `${e}D` : e === 1 ? "1 Day" : `${e} Days`;
|
|
355
355
|
}, [
|
|
356
356
|
r.from,
|
|
357
357
|
r.to,
|
|
358
358
|
n
|
|
359
359
|
]);
|
|
360
|
-
return /* @__PURE__ */
|
|
360
|
+
return /* @__PURE__ */ m("div", {
|
|
361
361
|
"data-track-handle": "true",
|
|
362
|
-
className:
|
|
362
|
+
className: b("rangeflow-thumb-label flex h-full w-full items-center justify-center", "mx-[clamp(0.5rem,5vw,5%)] cursor-grab", "text-xs font-medium text-nowrap text-(--rangeflow-text)"),
|
|
363
363
|
children: e ? t(e, { label: i }) : i
|
|
364
364
|
});
|
|
365
365
|
}), Z = N([1, 100], [5, 100]);
|
|
366
|
-
function
|
|
367
|
-
let t = K((e) => e.slider.size), n = K((e) => e.duration), r = W(K((e) => e.range)), [i] =
|
|
368
|
-
return /* @__PURE__ */
|
|
366
|
+
function Se({ onHandleRef: e }) {
|
|
367
|
+
let t = K((e) => e.slider.size), n = K((e) => e.duration), r = W(K((e) => e.range)), [i] = u(() => t), a = n?.min ? Math.min(Z(n.min * 100 / r), 100) : 5, o = n?.max ? Math.min(Z(n.max * 100 / r), 100) : 100;
|
|
368
|
+
return /* @__PURE__ */ m(C, {
|
|
369
369
|
defaultSize: `${i}%`,
|
|
370
370
|
elementRef: e,
|
|
371
371
|
id: j,
|
|
372
372
|
maxSize: `${o}%`,
|
|
373
373
|
minSize: `${a}%`,
|
|
374
|
-
children: /* @__PURE__ */
|
|
374
|
+
children: /* @__PURE__ */ m("div", {
|
|
375
375
|
"data-track-handle-container": "",
|
|
376
|
-
className:
|
|
377
|
-
children: /* @__PURE__ */
|
|
376
|
+
className: b("rangeflow-thumb flex items-center justify-center", "h-full rounded-sm border border-(--rangeflow-border-strong) inset-shadow-sm shadow-(color:--rangeflow-shadow-color)", "backdrop-blur-[2.5px]", "cursor-default select-none"),
|
|
377
|
+
children: /* @__PURE__ */ m(xe, {})
|
|
378
378
|
})
|
|
379
379
|
});
|
|
380
380
|
}
|
|
381
381
|
//#endregion
|
|
382
382
|
//#region src/package/rangeflow/components/DateSlider/Slider/index.tsx
|
|
383
|
-
var
|
|
384
|
-
function
|
|
385
|
-
let t = Y(), { slider: { root: n } } = X(), i =
|
|
383
|
+
var Ce = (e, t, n) => !!e?.querySelector("[data-separator=\"active\"]") && t["slider-track-thumb"] === n["slider-track-thumb"];
|
|
384
|
+
function we({ onHandleRef: e }) {
|
|
385
|
+
let t = Y(), { slider: { root: n } } = X(), i = l(null), a = l(null), o = l(null), s = x("rangeflow-separator h-3/4 w-0.75 self-center rounded-full transition-[background-color,opacity] duration-150", "bg-(--rangeflow-separator) hover:bg-(--rangeflow-separator-active) focus:outline-none", "data-[separator=active]:bg-(--rangeflow-separator-active)", "opacity-0 group-has-[[data-track-handle-container]:hover]:opacity-100", "hover:opacity-100 data-[separator=active]:opacity-100 data-[separator=focus]:opacity-100"), { ref: c } = te({
|
|
386
386
|
id: "track-handle-draggable",
|
|
387
387
|
sensors: [ae.configure({ preventActivation: (e) => !(e.target instanceof HTMLDivElement) || !e.target.dataset.trackHandle }), ie]
|
|
388
388
|
});
|
|
@@ -402,16 +402,16 @@ function Ce({ onHandleRef: e }) {
|
|
|
402
402
|
onDragEnd: () => {
|
|
403
403
|
a.current = null;
|
|
404
404
|
}
|
|
405
|
-
}), /* @__PURE__ */
|
|
406
|
-
ref:
|
|
407
|
-
className:
|
|
408
|
-
children: /* @__PURE__ */
|
|
405
|
+
}), /* @__PURE__ */ m("div", {
|
|
406
|
+
ref: c,
|
|
407
|
+
className: x("absolute top-[50%] left-0 z-1 -translate-y-[50%]", "h-7 w-full"),
|
|
408
|
+
children: /* @__PURE__ */ h(oe, {
|
|
409
409
|
className: "group h-full w-full",
|
|
410
410
|
elementRef: i,
|
|
411
411
|
groupRef: n,
|
|
412
412
|
onLayoutChange: (e) => {
|
|
413
413
|
let a = o.current;
|
|
414
|
-
if (a &&
|
|
414
|
+
if (a && Ce(i.current, a, e)) {
|
|
415
415
|
n.current?.setLayout(a);
|
|
416
416
|
return;
|
|
417
417
|
}
|
|
@@ -420,54 +420,54 @@ function Ce({ onHandleRef: e }) {
|
|
|
420
420
|
});
|
|
421
421
|
},
|
|
422
422
|
children: [
|
|
423
|
-
/* @__PURE__ */
|
|
424
|
-
/* @__PURE__ */
|
|
425
|
-
/* @__PURE__ */
|
|
426
|
-
/* @__PURE__ */
|
|
427
|
-
/* @__PURE__ */
|
|
423
|
+
/* @__PURE__ */ m(ye, {}),
|
|
424
|
+
/* @__PURE__ */ m(w, { className: s }),
|
|
425
|
+
/* @__PURE__ */ m(Se, { onHandleRef: e }),
|
|
426
|
+
/* @__PURE__ */ m(w, { className: s }),
|
|
427
|
+
/* @__PURE__ */ m(be, {})
|
|
428
428
|
]
|
|
429
429
|
})
|
|
430
430
|
});
|
|
431
431
|
}
|
|
432
432
|
//#endregion
|
|
433
433
|
//#region src/package/rangeflow/components/DateSlider/SliderTrack.tsx
|
|
434
|
-
function
|
|
435
|
-
let t = K((e) => e.update), n = K((e) => e.range), r = W(n), i = K((e) => e.disabled?.before), a = K((e) => e.disabled?.after), o =
|
|
436
|
-
return /* @__PURE__ */
|
|
434
|
+
function Te({ onHandleRef: e }) {
|
|
435
|
+
let t = K((e) => e.update), n = K((e) => e.range), r = W(n), i = K((e) => e.disabled?.before), a = K((e) => e.disabled?.after), o = c(() => !i || d(n.from).isAfter(i), [n.from, i]), s = c(() => !a || d(n.to).isBefore(a), [n.to, a]);
|
|
436
|
+
return /* @__PURE__ */ h("div", {
|
|
437
437
|
className: "flex items-center select-none",
|
|
438
438
|
children: [
|
|
439
|
-
o ? /* @__PURE__ */
|
|
439
|
+
o ? /* @__PURE__ */ m(q, {
|
|
440
440
|
onClick: () => {
|
|
441
441
|
t((e) => {
|
|
442
|
-
let t =
|
|
443
|
-
e.range.from = i && t.isBefore(i) ?
|
|
442
|
+
let t = d(e.range.from).subtract(r / 2, "day");
|
|
443
|
+
e.range.from = i && t.isBefore(i) ? d(i).toDate() : t.toDate();
|
|
444
444
|
});
|
|
445
445
|
},
|
|
446
|
-
children: /* @__PURE__ */
|
|
446
|
+
children: /* @__PURE__ */ m(me, {})
|
|
447
447
|
}) : null,
|
|
448
|
-
/* @__PURE__ */
|
|
448
|
+
/* @__PURE__ */ h("div", {
|
|
449
449
|
className: "relative flex-1 px-2",
|
|
450
|
-
children: [/* @__PURE__ */
|
|
450
|
+
children: [/* @__PURE__ */ m(we, { onHandleRef: e }), /* @__PURE__ */ m(ge, {})]
|
|
451
451
|
}),
|
|
452
|
-
|
|
452
|
+
s ? /* @__PURE__ */ m(q, {
|
|
453
453
|
onClick: () => {
|
|
454
454
|
t((e) => {
|
|
455
|
-
let t =
|
|
456
|
-
e.range.to = a && t.isAfter(a) ?
|
|
455
|
+
let t = d(e.range.to).add(r / 2, "day");
|
|
456
|
+
e.range.to = a && t.isAfter(a) ? d(a).toDate() : t.toDate();
|
|
457
457
|
});
|
|
458
458
|
},
|
|
459
|
-
children: /* @__PURE__ */
|
|
459
|
+
children: /* @__PURE__ */ m(he, {})
|
|
460
460
|
}) : null
|
|
461
461
|
]
|
|
462
462
|
});
|
|
463
463
|
}
|
|
464
464
|
//#endregion
|
|
465
465
|
//#region src/package/rangeflow/components/DateSlider/utils/restrict-inner-to-element.ts
|
|
466
|
-
var
|
|
466
|
+
var Ee = class e extends se {
|
|
467
467
|
innerRect = D(null);
|
|
468
468
|
containerRect = D(null);
|
|
469
469
|
constructor(e, t) {
|
|
470
|
-
super(e, t), this.destroy =
|
|
470
|
+
super(e, t), this.destroy = E(() => {
|
|
471
471
|
if (!this.options) return;
|
|
472
472
|
let { dragOperation: t } = e;
|
|
473
473
|
if (!t.status.initialized) return;
|
|
@@ -479,33 +479,33 @@ var Te = class e extends w {
|
|
|
479
479
|
}
|
|
480
480
|
apply({ transform: e }) {
|
|
481
481
|
let t = this.innerRect.value, n = this.containerRect.value;
|
|
482
|
-
return !t || !n ? e :
|
|
482
|
+
return !t || !n ? e : _(new T(t.left, t.top, t.width, t.height), e, n);
|
|
483
483
|
}
|
|
484
|
-
static configure =
|
|
484
|
+
static configure = ce(e);
|
|
485
485
|
};
|
|
486
486
|
//#endregion
|
|
487
487
|
//#region src/package/rangeflow/components/DateSlider/index.tsx
|
|
488
|
-
function
|
|
489
|
-
let [e, t] =
|
|
490
|
-
return /* @__PURE__ */
|
|
488
|
+
function De() {
|
|
489
|
+
let [e, t] = u(null), [n, r] = u(null);
|
|
490
|
+
return /* @__PURE__ */ m("div", {
|
|
491
491
|
ref: t,
|
|
492
492
|
className: "rangeflow-slider relative my-8 h-3 w-full px-2",
|
|
493
|
-
children: /* @__PURE__ */
|
|
494
|
-
modifiers: [
|
|
493
|
+
children: /* @__PURE__ */ h(v, {
|
|
494
|
+
modifiers: [Ee.configure({
|
|
495
495
|
inner: n,
|
|
496
496
|
container: e
|
|
497
|
-
}),
|
|
497
|
+
}), g],
|
|
498
498
|
children: [
|
|
499
|
-
/* @__PURE__ */
|
|
500
|
-
/* @__PURE__ */
|
|
501
|
-
/* @__PURE__ */
|
|
499
|
+
/* @__PURE__ */ m(Te, { onHandleRef: r }),
|
|
500
|
+
/* @__PURE__ */ m(pe, {}),
|
|
501
|
+
/* @__PURE__ */ m(y, { children: null })
|
|
502
502
|
]
|
|
503
503
|
})
|
|
504
504
|
});
|
|
505
505
|
}
|
|
506
506
|
//#endregion
|
|
507
507
|
//#region src/package/rangeflow/components/RangeTabs/hooks/use-apply-slider-layout.ts
|
|
508
|
-
function
|
|
508
|
+
function Oe() {
|
|
509
509
|
let e = Y(), t = K((e) => e.range.from.getTime()), n = K((e) => e.range.to.getTime()), { slider: { root: i } } = X();
|
|
510
510
|
o(() => {
|
|
511
511
|
r(() => {
|
|
@@ -520,77 +520,77 @@ function De() {
|
|
|
520
520
|
}
|
|
521
521
|
//#endregion
|
|
522
522
|
//#region src/package/rangeflow/components/RangeTabs/index.tsx
|
|
523
|
-
function
|
|
524
|
-
|
|
525
|
-
let e = K((e) => e.ranges),
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
]),
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
523
|
+
function ke() {
|
|
524
|
+
Oe();
|
|
525
|
+
let e = s(), t = K((e) => e.ranges), n = K((e) => e.update), r = K((e) => e.range.from), i = K((e) => e.range.to), a = K((e) => e.disabled?.before), o = K((e) => e.disabled?.after), l = c(() => t.filter((e) => !(a && d(e.from).isBefore(a, "day") || o && d(e.to).isAfter(o, "day"))), [
|
|
526
|
+
t,
|
|
527
|
+
a,
|
|
528
|
+
o
|
|
529
|
+
]), u = c(() => l.findIndex((e) => d(e.from).isSame(r, "day") && d(e.to).isSame(i, "day")), [
|
|
530
|
+
l,
|
|
531
|
+
r,
|
|
532
|
+
i
|
|
533
533
|
]);
|
|
534
|
-
return /* @__PURE__ */
|
|
534
|
+
return /* @__PURE__ */ m("div", {
|
|
535
535
|
className: "rangeflow-tabs flex items-center justify-center select-none",
|
|
536
|
-
children: /* @__PURE__ */
|
|
536
|
+
children: /* @__PURE__ */ m("div", {
|
|
537
537
|
className: "relative flex items-center overflow-hidden",
|
|
538
|
-
children:
|
|
539
|
-
"data-active":
|
|
540
|
-
className:
|
|
538
|
+
children: l.map((t, r) => /* @__PURE__ */ h("button", {
|
|
539
|
+
"data-active": u === r || void 0,
|
|
540
|
+
className: b("rangeflow-tab relative z-1 flex items-center px-1.5 py-1 focus:outline-none"),
|
|
541
541
|
onClick: () => {
|
|
542
|
-
|
|
543
|
-
|
|
542
|
+
n((e) => {
|
|
543
|
+
e.range.from = t.from, e.range.to = t.to;
|
|
544
544
|
});
|
|
545
545
|
},
|
|
546
|
-
children: [/* @__PURE__ */
|
|
547
|
-
className:
|
|
548
|
-
children:
|
|
549
|
-
}),
|
|
546
|
+
children: [/* @__PURE__ */ m("span", {
|
|
547
|
+
className: b("relative z-1 text-xs tracking-tight text-(--rangeflow-text-muted)", { "font-medium text-(--rangeflow-text)": u === r }),
|
|
548
|
+
children: t.label
|
|
549
|
+
}), u === r && /* @__PURE__ */ m(S.div, {
|
|
550
550
|
className: "rangeflow-tab-indicator absolute inset-0 rounded-sm bg-(--rangeflow-active-bg)",
|
|
551
551
|
initial: !1,
|
|
552
|
-
layoutId:
|
|
552
|
+
layoutId: e,
|
|
553
553
|
transition: {
|
|
554
554
|
type: "spring",
|
|
555
555
|
stiffness: 200,
|
|
556
556
|
damping: 25
|
|
557
557
|
}
|
|
558
558
|
})]
|
|
559
|
-
}, `${
|
|
559
|
+
}, `${t.from.getTime()}_${t.to.getTime()}`))
|
|
560
560
|
})
|
|
561
561
|
});
|
|
562
562
|
}
|
|
563
563
|
//#endregion
|
|
564
564
|
//#region src/package/rangeflow/components/Calendar/CalendarDayButton.tsx
|
|
565
|
-
function
|
|
566
|
-
let i =
|
|
565
|
+
function Ae({ className: e, day: t, modifiers: n, ...r }) {
|
|
566
|
+
let i = l(null);
|
|
567
567
|
o(() => {
|
|
568
568
|
n.focused && i.current?.focus();
|
|
569
569
|
}, [n.focused]);
|
|
570
570
|
let a = n.selected && !n.range_start && !n.range_middle && !n.range_end;
|
|
571
|
-
return /* @__PURE__ */
|
|
571
|
+
return /* @__PURE__ */ m("button", {
|
|
572
572
|
ref: i,
|
|
573
573
|
"data-range-end": n.range_end || void 0,
|
|
574
574
|
"data-range-middle": n.range_middle || void 0,
|
|
575
575
|
"data-range-start": n.range_start || void 0,
|
|
576
576
|
"data-selected": a || void 0,
|
|
577
577
|
"data-today": n.today || void 0,
|
|
578
|
-
className:
|
|
578
|
+
className: b("rangeflow-day flex h-9 w-9 items-center justify-center rounded-sm leading-none", "text-xs text-(--rangeflow-text-muted) transition-colors", "hover:bg-(--rangeflow-hover-bg)", "focus-visible:ring-1 focus-visible:ring-(--rangeflow-ring) focus-visible:outline-none", "data-[today=true]:font-bold data-[today=true]:text-(--rangeflow-today)", "data-[selected=true]:bg-(--rangeflow-accent-solid) data-[selected=true]:text-(--rangeflow-accent-contrast) data-[selected=true]:hover:bg-(--rangeflow-accent-solid-hover)", "data-[range-start=true]:bg-(--rangeflow-accent-solid) data-[range-start=true]:text-(--rangeflow-accent-contrast)", "data-[range-end=true]:bg-(--rangeflow-accent-solid) data-[range-end=true]:text-(--rangeflow-accent-contrast)", e),
|
|
579
579
|
...r
|
|
580
580
|
});
|
|
581
581
|
}
|
|
582
582
|
//#endregion
|
|
583
583
|
//#region src/package/rangeflow/components/Calendar/Chevron.tsx
|
|
584
|
-
var
|
|
584
|
+
var je = {
|
|
585
585
|
up: "rotate-180",
|
|
586
586
|
down: "",
|
|
587
587
|
left: "rotate-90",
|
|
588
588
|
right: "-rotate-90"
|
|
589
589
|
};
|
|
590
|
-
function
|
|
591
|
-
return /* @__PURE__ */
|
|
590
|
+
function Me({ className: e, orientation: t = "down", size: n = 16 }) {
|
|
591
|
+
return /* @__PURE__ */ m("svg", {
|
|
592
592
|
"aria-hidden": "true",
|
|
593
|
-
className:
|
|
593
|
+
className: b("shrink-0", je[t], e),
|
|
594
594
|
fill: "none",
|
|
595
595
|
height: n,
|
|
596
596
|
stroke: "currentColor",
|
|
@@ -599,26 +599,26 @@ function je({ className: e, orientation: t = "down", size: n = 16 }) {
|
|
|
599
599
|
strokeWidth: 2,
|
|
600
600
|
viewBox: "0 0 24 24",
|
|
601
601
|
width: n,
|
|
602
|
-
children: /* @__PURE__ */
|
|
602
|
+
children: /* @__PURE__ */ m("path", { d: "m6 9 6 6 6-6" })
|
|
603
603
|
});
|
|
604
604
|
}
|
|
605
605
|
//#endregion
|
|
606
606
|
//#region src/package/rangeflow/components/Calendar/index.tsx
|
|
607
|
-
function
|
|
608
|
-
return /* @__PURE__ */
|
|
607
|
+
function Ne({ captionLayout: e = "label", className: t, classNames: n, components: r, showOutsideDays: i = !0, ...a }) {
|
|
608
|
+
return /* @__PURE__ */ m(le, {
|
|
609
609
|
captionLayout: e,
|
|
610
|
-
className:
|
|
610
|
+
className: b("rangeflow-calendar w-fit p-3 select-none", t),
|
|
611
611
|
showOutsideDays: i,
|
|
612
612
|
classNames: {
|
|
613
613
|
months: "relative flex flex-col gap-4 md:flex-row",
|
|
614
614
|
month: "flex w-full flex-col gap-4",
|
|
615
615
|
nav: "absolute inset-x-0 top-0 flex h-7 items-center justify-between",
|
|
616
|
-
button_previous:
|
|
617
|
-
button_next:
|
|
616
|
+
button_previous: b("inline-flex h-7 w-7 items-center justify-center rounded-sm", "text-(--rangeflow-text-subtle) transition-colors hover:bg-(--rangeflow-hover-bg) hover:text-(--rangeflow-text-muted)", "aria-disabled:pointer-events-none aria-disabled:opacity-40"),
|
|
617
|
+
button_next: b("inline-flex h-7 w-7 items-center justify-center rounded-sm", "text-(--rangeflow-text-subtle) transition-colors hover:bg-(--rangeflow-hover-bg) hover:text-(--rangeflow-text-muted)", "aria-disabled:pointer-events-none aria-disabled:opacity-40"),
|
|
618
618
|
month_caption: "flex h-7 items-center justify-center text-xs font-medium text-(--rangeflow-text-muted)",
|
|
619
619
|
caption_label: "text-xs font-medium",
|
|
620
620
|
dropdowns: "flex items-center gap-1 text-xs font-medium text-(--rangeflow-text-muted)",
|
|
621
|
-
dropdown_root:
|
|
621
|
+
dropdown_root: b("relative flex items-center gap-1 rounded-sm border border-(--rangeflow-border) px-1.5 py-0.5", "has-[:focus]:ring-1 has-[:focus]:ring-(--rangeflow-ring)"),
|
|
622
622
|
dropdown: "absolute inset-0 cursor-pointer opacity-0",
|
|
623
623
|
month_grid: "mt-2 w-full border-collapse",
|
|
624
624
|
weekdays: "flex",
|
|
@@ -636,8 +636,8 @@ function Me({ captionLayout: e = "label", className: t, classNames: n, component
|
|
|
636
636
|
...n
|
|
637
637
|
},
|
|
638
638
|
components: {
|
|
639
|
-
DayButton:
|
|
640
|
-
Chevron:
|
|
639
|
+
DayButton: Ae,
|
|
640
|
+
Chevron: Me,
|
|
641
641
|
...r
|
|
642
642
|
},
|
|
643
643
|
...a
|
|
@@ -645,12 +645,12 @@ function Me({ captionLayout: e = "label", className: t, classNames: n, component
|
|
|
645
645
|
}
|
|
646
646
|
//#endregion
|
|
647
647
|
//#region src/package/rangeflow/components/Popover/index.tsx
|
|
648
|
-
var
|
|
648
|
+
var Pe = n(({ align: e = "center", className: t, sideOffset: n = 6, children: r, ...i }) => /* @__PURE__ */ m(O.Portal, { children: /* @__PURE__ */ m(O.Content, {
|
|
649
649
|
asChild: !0,
|
|
650
650
|
align: e,
|
|
651
651
|
sideOffset: n,
|
|
652
652
|
...i,
|
|
653
|
-
children: /* @__PURE__ */
|
|
653
|
+
children: /* @__PURE__ */ m(S.div, {
|
|
654
654
|
animate: {
|
|
655
655
|
opacity: 1,
|
|
656
656
|
scale: 1,
|
|
@@ -668,17 +668,17 @@ var Ne = n(({ align: e = "center", className: t, sideOffset: n = 6, children: r,
|
|
|
668
668
|
damping: 32,
|
|
669
669
|
mass: .8
|
|
670
670
|
},
|
|
671
|
-
className:
|
|
671
|
+
className: b("rangeflow-date-picker-portal rangeflow-popover z-50 rounded-lg border border-(--rangeflow-border) bg-(--rangeflow-bg) p-2 text-(--rangeflow-text) shadow-md shadow-(color:--rangeflow-shadow-color) backdrop-blur-[10px] outline-none", t),
|
|
672
672
|
children: r
|
|
673
673
|
})
|
|
674
|
-
}) })),
|
|
674
|
+
}) })), Fe = O.Root, Ie = O.Trigger;
|
|
675
675
|
O.Anchor;
|
|
676
676
|
//#endregion
|
|
677
677
|
//#region src/package/rangeflow/components/PickerBar/CalendarPopover.tsx
|
|
678
|
-
function
|
|
678
|
+
function Le({ children: e }) {
|
|
679
679
|
let t = K((e) => e.update), n = K((e) => e.range), r = K((e) => e.selected_date), i = K((e) => e.disabled), a = K((e) => e.duration), o = K((e) => e.CalendarProps), { slider: { root: s } } = X(), c = () => {
|
|
680
|
-
let e =
|
|
681
|
-
return
|
|
680
|
+
let e = d(n.from), t = d(n.to);
|
|
681
|
+
return d(r.from).isBefore(e) && (e = d(r.from).subtract(10, "day")), d(r.to).isAfter(t) && (t = d(r.to).add(10, "day")), {
|
|
682
682
|
from: e.toDate(),
|
|
683
683
|
to: t.toDate()
|
|
684
684
|
};
|
|
@@ -692,18 +692,18 @@ function Q({ children: e }) {
|
|
|
692
692
|
t.range = e;
|
|
693
693
|
});
|
|
694
694
|
};
|
|
695
|
-
return /* @__PURE__ */
|
|
695
|
+
return /* @__PURE__ */ h(Fe, {
|
|
696
696
|
modal: !0,
|
|
697
697
|
onOpenChange: (e) => {
|
|
698
698
|
e === !1 && l();
|
|
699
699
|
},
|
|
700
|
-
children: [/* @__PURE__ */
|
|
700
|
+
children: [/* @__PURE__ */ m(Ie, {
|
|
701
701
|
className: "cursor-pointer",
|
|
702
702
|
children: e
|
|
703
|
-
}), /* @__PURE__ */
|
|
703
|
+
}), /* @__PURE__ */ m(Pe, {
|
|
704
704
|
align: "start",
|
|
705
705
|
sideOffset: 10,
|
|
706
|
-
children: /* @__PURE__ */
|
|
706
|
+
children: /* @__PURE__ */ m(Ne, {
|
|
707
707
|
defaultMonth: r.from,
|
|
708
708
|
numberOfMonths: 2,
|
|
709
709
|
showOutsideDays: !1,
|
|
@@ -715,7 +715,7 @@ function Q({ children: e }) {
|
|
|
715
715
|
selected: r,
|
|
716
716
|
onSelect: (e) => {
|
|
717
717
|
if (!e?.from || !e?.to) return;
|
|
718
|
-
let n =
|
|
718
|
+
let n = d(e.from).startOf("day"), r = d(e.to).startOf("day"), i = {
|
|
719
719
|
from: n.toDate(),
|
|
720
720
|
to: r.toDate()
|
|
721
721
|
};
|
|
@@ -729,14 +729,14 @@ function Q({ children: e }) {
|
|
|
729
729
|
}
|
|
730
730
|
//#endregion
|
|
731
731
|
//#region src/package/rangeflow/icons/CalendarIcon.tsx
|
|
732
|
-
function
|
|
733
|
-
return /* @__PURE__ */
|
|
732
|
+
function Q() {
|
|
733
|
+
return /* @__PURE__ */ m("svg", {
|
|
734
734
|
fill: "none",
|
|
735
735
|
height: "15",
|
|
736
736
|
viewBox: "0 0 15 15",
|
|
737
737
|
width: "15",
|
|
738
738
|
xmlns: "http://www.w3.org/2000/svg",
|
|
739
|
-
children: /* @__PURE__ */
|
|
739
|
+
children: /* @__PURE__ */ m("path", {
|
|
740
740
|
clipRule: "evenodd",
|
|
741
741
|
d: "M4.5 1C4.77614 1 5 1.22386 5 1.5V2H10V1.5C10 1.22386 10.2239 1 10.5 1C10.7761 1 11 1.22386 11 1.5V2H12.5C13.3284 2 14 2.67157 14 3.5V12.5C14 13.3284 13.3284 14 12.5 14H2.5C1.67157 14 1 13.3284 1 12.5V3.5C1 2.67157 1.67157 2 2.5 2H4V1.5C4 1.22386 4.22386 1 4.5 1ZM10 3V3.5C10 3.77614 10.2239 4 10.5 4C10.7761 4 11 3.77614 11 3.5V3H12.5C12.7761 3 13 3.22386 13 3.5V5H2V3.5C2 3.22386 2.22386 3 2.5 3H4V3.5C4 3.77614 4.22386 4 4.5 4C4.77614 4 5 3.77614 5 3.5V3H10ZM2 6V12.5C2 12.7761 2.22386 13 2.5 13H12.5C12.7761 13 13 12.7761 13 12.5V6H2ZM7 7.5C7 7.22386 7.22386 7 7.5 7C7.77614 7 8 7.22386 8 7.5C8 7.77614 7.77614 8 7.5 8C7.22386 8 7 7.77614 7 7.5ZM9.5 7C9.22386 7 9 7.22386 9 7.5C9 7.77614 9.22386 8 9.5 8C9.77614 8 10 7.77614 10 7.5C10 7.22386 9.77614 7 9.5 7ZM11 7.5C11 7.22386 11.2239 7 11.5 7C11.7761 7 12 7.22386 12 7.5C12 7.77614 11.7761 8 11.5 8C11.2239 8 11 7.77614 11 7.5ZM11.5 9C11.2239 9 11 9.22386 11 9.5C11 9.77614 11.2239 10 11.5 10C11.7761 10 12 9.77614 12 9.5C12 9.22386 11.7761 9 11.5 9ZM9 9.5C9 9.22386 9.22386 9 9.5 9C9.77614 9 10 9.22386 10 9.5C10 9.77614 9.77614 10 9.5 10C9.22386 10 9 9.77614 9 9.5ZM7.5 9C7.22386 9 7 9.22386 7 9.5C7 9.77614 7.22386 10 7.5 10C7.77614 10 8 9.77614 8 9.5C8 9.22386 7.77614 9 7.5 9ZM5 9.5C5 9.22386 5.22386 9 5.5 9C5.77614 9 6 9.22386 6 9.5C6 9.77614 5.77614 10 5.5 10C5.22386 10 5 9.77614 5 9.5ZM3.5 9C3.22386 9 3 9.22386 3 9.5C3 9.77614 3.22386 10 3.5 10C3.77614 10 4 9.77614 4 9.5C4 9.22386 3.77614 9 3.5 9ZM3 11.5C3 11.2239 3.22386 11 3.5 11C3.77614 11 4 11.2239 4 11.5C4 11.7761 3.77614 12 3.5 12C3.22386 12 3 11.7761 3 11.5ZM5.5 11C5.22386 11 5 11.2239 5 11.5C5 11.7761 5.22386 12 5.5 12C5.77614 12 6 11.7761 6 11.5C6 11.2239 5.77614 11 5.5 11ZM7 11.5C7 11.2239 7.22386 11 7.5 11C7.77614 11 8 11.2239 8 11.5C8 11.7761 7.77614 12 7.5 12C7.22386 12 7 11.7761 7 11.5ZM9.5 11C9.22386 11 9 11.2239 9 11.5C9 11.7761 9.22386 12 9.5 12C9.77614 12 10 11.7761 10 11.5C10 11.2239 9.77614 11 9.5 11Z",
|
|
742
742
|
fill: "currentColor",
|
|
@@ -747,8 +747,8 @@ function Ie() {
|
|
|
747
747
|
//#endregion
|
|
748
748
|
//#region src/package/rangeflow/components/PickerBar/SelectedDate.tsx
|
|
749
749
|
function $() {
|
|
750
|
-
let e = K((e) => e.selected_date), { SelectedDate: n } = G(), { from: r, to: i } =
|
|
751
|
-
let t =
|
|
750
|
+
let e = K((e) => e.selected_date), { SelectedDate: n } = G(), { from: r, to: i } = c(() => {
|
|
751
|
+
let t = d(), n = d(e.from), r = d(e.to), i = n.isSame(r, "year") ? "DD MMM" : "DD MMM YYYY", a = {
|
|
752
752
|
from: n.format(i),
|
|
753
753
|
to: r.format(i)
|
|
754
754
|
};
|
|
@@ -757,12 +757,12 @@ function $() {
|
|
|
757
757
|
return n ? t(n, {
|
|
758
758
|
from: r,
|
|
759
759
|
to: i
|
|
760
|
-
}) : /* @__PURE__ */
|
|
760
|
+
}) : /* @__PURE__ */ h("div", {
|
|
761
761
|
className: "rangeflow-selected-date flex items-center gap-2 text-xs font-medium text-(--rangeflow-accent-text) select-none hover:opacity-90",
|
|
762
762
|
children: [
|
|
763
|
-
/* @__PURE__ */
|
|
763
|
+
/* @__PURE__ */ m(Q, {}),
|
|
764
764
|
r,
|
|
765
|
-
/* @__PURE__ */
|
|
765
|
+
/* @__PURE__ */ m("span", {
|
|
766
766
|
className: "text-(--rangeflow-text-faint)",
|
|
767
767
|
children: "—"
|
|
768
768
|
}),
|
|
@@ -772,52 +772,52 @@ function $() {
|
|
|
772
772
|
}
|
|
773
773
|
//#endregion
|
|
774
774
|
//#region src/package/rangeflow/components/PickerBar/index.tsx
|
|
775
|
-
function
|
|
775
|
+
function Re() {
|
|
776
776
|
let e = K((e) => e.calendar), { RangeTabs: n } = G();
|
|
777
|
-
return /* @__PURE__ */
|
|
777
|
+
return /* @__PURE__ */ h("div", {
|
|
778
778
|
className: "flex h-full items-center justify-between px-2",
|
|
779
|
-
children: [e ? /* @__PURE__ */
|
|
779
|
+
children: [e ? /* @__PURE__ */ m(Le, { children: /* @__PURE__ */ m($, {}) }) : /* @__PURE__ */ m($, {}), n ? t(n) : /* @__PURE__ */ m(ke, {})]
|
|
780
780
|
});
|
|
781
781
|
}
|
|
782
782
|
//#endregion
|
|
783
783
|
//#region src/package/rangeflow/hooks/use-rangeflow-events.ts
|
|
784
|
-
function
|
|
784
|
+
function ze() {
|
|
785
785
|
return a(V).events;
|
|
786
786
|
}
|
|
787
787
|
//#endregion
|
|
788
788
|
//#region src/package/rangeflow/hooks/use-emit-date-change.ts
|
|
789
|
-
function
|
|
790
|
-
let e = J(), { onChange: t } =
|
|
789
|
+
function Be() {
|
|
790
|
+
let e = J(), { onChange: t } = ze();
|
|
791
791
|
o(() => e.subscribe((e, n) => {
|
|
792
792
|
e.selected_date !== n.selected_date && t(e.selected_date);
|
|
793
793
|
}), [e, t]);
|
|
794
794
|
}
|
|
795
795
|
//#endregion
|
|
796
796
|
//#region src/package/rangeflow/Root.tsx
|
|
797
|
-
function
|
|
798
|
-
return
|
|
797
|
+
function Ve() {
|
|
798
|
+
return Be(), /* @__PURE__ */ h("div", {
|
|
799
799
|
className: "rangeflow-date-picker rangeflow-root h-35 w-140 rounded-lg border border-(--rangeflow-border) bg-(--rangeflow-bg) text-(--rangeflow-text) shadow-md shadow-(color:--rangeflow-shadow-color)",
|
|
800
|
-
children: [/* @__PURE__ */
|
|
800
|
+
children: [/* @__PURE__ */ m("div", {
|
|
801
801
|
className: "rangeflow-header h-10 border-b border-(--rangeflow-border) p-2",
|
|
802
|
-
children: /* @__PURE__ */
|
|
803
|
-
}), /* @__PURE__ */
|
|
802
|
+
children: /* @__PURE__ */ m(Re, {})
|
|
803
|
+
}), /* @__PURE__ */ m("div", {
|
|
804
804
|
className: "rangeflow-body mx-2",
|
|
805
|
-
children: /* @__PURE__ */
|
|
805
|
+
children: /* @__PURE__ */ m(De, {})
|
|
806
806
|
})]
|
|
807
807
|
});
|
|
808
808
|
}
|
|
809
809
|
//#endregion
|
|
810
810
|
//#region src/package/rangeflow/index.tsx
|
|
811
|
-
function
|
|
812
|
-
return /* @__PURE__ */
|
|
811
|
+
function He(e) {
|
|
812
|
+
return /* @__PURE__ */ m(H, {
|
|
813
813
|
...e,
|
|
814
|
-
children: /* @__PURE__ */
|
|
814
|
+
children: /* @__PURE__ */ m(Ve, {})
|
|
815
815
|
});
|
|
816
816
|
}
|
|
817
817
|
//#endregion
|
|
818
818
|
//#region src/package/rangeflow/hooks/use-rangeflow.ts
|
|
819
|
-
function
|
|
820
|
-
let e =
|
|
819
|
+
function Ue() {
|
|
820
|
+
let e = l(null), t = l(null), n = i((n) => {
|
|
821
821
|
let r = e.current;
|
|
822
822
|
if (!r) return;
|
|
823
823
|
let { selected_date: i, update: a } = r.getState(), { size: o, left: s, right: c } = F(n, i);
|
|
@@ -852,4 +852,4 @@ function He() {
|
|
|
852
852
|
};
|
|
853
853
|
}
|
|
854
854
|
//#endregion
|
|
855
|
-
export {
|
|
855
|
+
export { He as RangeFlow, Ue as useRangeflow };
|