rangeflow 1.0.3 → 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 +213 -214
- 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,10 @@ 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
|
+
className: "focus:outline-none",
|
|
330
331
|
defaultSize: `${t}%`,
|
|
331
332
|
id: k,
|
|
332
333
|
minSize: 0,
|
|
@@ -335,9 +336,10 @@ function ve() {
|
|
|
335
336
|
}
|
|
336
337
|
//#endregion
|
|
337
338
|
//#region src/package/rangeflow/components/DateSlider/Slider/SliderRightSpacer.tsx
|
|
338
|
-
function
|
|
339
|
-
let e = K((e) => e.slider.right), [t] =
|
|
340
|
-
return /* @__PURE__ */
|
|
339
|
+
function be() {
|
|
340
|
+
let e = K((e) => e.slider.right), [t] = u(() => e);
|
|
341
|
+
return /* @__PURE__ */ m(C, {
|
|
342
|
+
className: "focus:outline-none",
|
|
341
343
|
defaultSize: `${t}%`,
|
|
342
344
|
id: A,
|
|
343
345
|
minSize: 0,
|
|
@@ -346,41 +348,41 @@ function ye() {
|
|
|
346
348
|
}
|
|
347
349
|
//#endregion
|
|
348
350
|
//#region src/package/rangeflow/components/DateSlider/SliderValue.tsx
|
|
349
|
-
var
|
|
350
|
-
let { SliderValueLabel: e } = G(), n = K((e) => e.slider.size), r = K((e) => e.selected_date), i =
|
|
351
|
-
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);
|
|
352
354
|
return n < 10 ? `${e}D` : e === 1 ? "1 Day" : `${e} Days`;
|
|
353
355
|
}, [
|
|
354
356
|
r.from,
|
|
355
357
|
r.to,
|
|
356
358
|
n
|
|
357
359
|
]);
|
|
358
|
-
return /* @__PURE__ */
|
|
360
|
+
return /* @__PURE__ */ m("div", {
|
|
359
361
|
"data-track-handle": "true",
|
|
360
|
-
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)"),
|
|
361
363
|
children: e ? t(e, { label: i }) : i
|
|
362
364
|
});
|
|
363
365
|
}), Z = N([1, 100], [5, 100]);
|
|
364
|
-
function
|
|
365
|
-
let t = K((e) => e.slider.size), n = K((e) => e.duration), r = W(K((e) => e.range)), [i] =
|
|
366
|
-
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, {
|
|
367
369
|
defaultSize: `${i}%`,
|
|
368
370
|
elementRef: e,
|
|
369
371
|
id: j,
|
|
370
372
|
maxSize: `${o}%`,
|
|
371
373
|
minSize: `${a}%`,
|
|
372
|
-
children: /* @__PURE__ */
|
|
374
|
+
children: /* @__PURE__ */ m("div", {
|
|
373
375
|
"data-track-handle-container": "",
|
|
374
|
-
className:
|
|
375
|
-
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, {})
|
|
376
378
|
})
|
|
377
379
|
});
|
|
378
380
|
}
|
|
379
381
|
//#endregion
|
|
380
382
|
//#region src/package/rangeflow/components/DateSlider/Slider/index.tsx
|
|
381
|
-
var
|
|
382
|
-
function
|
|
383
|
-
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({
|
|
384
386
|
id: "track-handle-draggable",
|
|
385
387
|
sensors: [ae.configure({ preventActivation: (e) => !(e.target instanceof HTMLDivElement) || !e.target.dataset.trackHandle }), ie]
|
|
386
388
|
});
|
|
@@ -400,16 +402,16 @@ function Ce({ onHandleRef: e }) {
|
|
|
400
402
|
onDragEnd: () => {
|
|
401
403
|
a.current = null;
|
|
402
404
|
}
|
|
403
|
-
}), /* @__PURE__ */
|
|
404
|
-
ref:
|
|
405
|
-
className:
|
|
406
|
-
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, {
|
|
407
409
|
className: "group h-full w-full",
|
|
408
410
|
elementRef: i,
|
|
409
411
|
groupRef: n,
|
|
410
412
|
onLayoutChange: (e) => {
|
|
411
413
|
let a = o.current;
|
|
412
|
-
if (a &&
|
|
414
|
+
if (a && Ce(i.current, a, e)) {
|
|
413
415
|
n.current?.setLayout(a);
|
|
414
416
|
return;
|
|
415
417
|
}
|
|
@@ -418,54 +420,54 @@ function Ce({ onHandleRef: e }) {
|
|
|
418
420
|
});
|
|
419
421
|
},
|
|
420
422
|
children: [
|
|
421
|
-
/* @__PURE__ */
|
|
422
|
-
/* @__PURE__ */
|
|
423
|
-
/* @__PURE__ */
|
|
424
|
-
/* @__PURE__ */
|
|
425
|
-
/* @__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, {})
|
|
426
428
|
]
|
|
427
429
|
})
|
|
428
430
|
});
|
|
429
431
|
}
|
|
430
432
|
//#endregion
|
|
431
433
|
//#region src/package/rangeflow/components/DateSlider/SliderTrack.tsx
|
|
432
|
-
function
|
|
433
|
-
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 =
|
|
434
|
-
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", {
|
|
435
437
|
className: "flex items-center select-none",
|
|
436
438
|
children: [
|
|
437
|
-
o ? /* @__PURE__ */
|
|
439
|
+
o ? /* @__PURE__ */ m(q, {
|
|
438
440
|
onClick: () => {
|
|
439
441
|
t((e) => {
|
|
440
|
-
let t =
|
|
441
|
-
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();
|
|
442
444
|
});
|
|
443
445
|
},
|
|
444
|
-
children: /* @__PURE__ */
|
|
446
|
+
children: /* @__PURE__ */ m(me, {})
|
|
445
447
|
}) : null,
|
|
446
|
-
/* @__PURE__ */
|
|
448
|
+
/* @__PURE__ */ h("div", {
|
|
447
449
|
className: "relative flex-1 px-2",
|
|
448
|
-
children: [/* @__PURE__ */
|
|
450
|
+
children: [/* @__PURE__ */ m(we, { onHandleRef: e }), /* @__PURE__ */ m(ge, {})]
|
|
449
451
|
}),
|
|
450
|
-
|
|
452
|
+
s ? /* @__PURE__ */ m(q, {
|
|
451
453
|
onClick: () => {
|
|
452
454
|
t((e) => {
|
|
453
|
-
let t =
|
|
454
|
-
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();
|
|
455
457
|
});
|
|
456
458
|
},
|
|
457
|
-
children: /* @__PURE__ */
|
|
459
|
+
children: /* @__PURE__ */ m(he, {})
|
|
458
460
|
}) : null
|
|
459
461
|
]
|
|
460
462
|
});
|
|
461
463
|
}
|
|
462
464
|
//#endregion
|
|
463
465
|
//#region src/package/rangeflow/components/DateSlider/utils/restrict-inner-to-element.ts
|
|
464
|
-
var
|
|
466
|
+
var Ee = class e extends se {
|
|
465
467
|
innerRect = D(null);
|
|
466
468
|
containerRect = D(null);
|
|
467
469
|
constructor(e, t) {
|
|
468
|
-
super(e, t), this.destroy =
|
|
470
|
+
super(e, t), this.destroy = E(() => {
|
|
469
471
|
if (!this.options) return;
|
|
470
472
|
let { dragOperation: t } = e;
|
|
471
473
|
if (!t.status.initialized) return;
|
|
@@ -477,33 +479,33 @@ var Te = class e extends w {
|
|
|
477
479
|
}
|
|
478
480
|
apply({ transform: e }) {
|
|
479
481
|
let t = this.innerRect.value, n = this.containerRect.value;
|
|
480
|
-
return !t || !n ? e :
|
|
482
|
+
return !t || !n ? e : _(new T(t.left, t.top, t.width, t.height), e, n);
|
|
481
483
|
}
|
|
482
|
-
static configure =
|
|
484
|
+
static configure = ce(e);
|
|
483
485
|
};
|
|
484
486
|
//#endregion
|
|
485
487
|
//#region src/package/rangeflow/components/DateSlider/index.tsx
|
|
486
|
-
function
|
|
487
|
-
let [e, t] =
|
|
488
|
-
return /* @__PURE__ */
|
|
488
|
+
function De() {
|
|
489
|
+
let [e, t] = u(null), [n, r] = u(null);
|
|
490
|
+
return /* @__PURE__ */ m("div", {
|
|
489
491
|
ref: t,
|
|
490
492
|
className: "rangeflow-slider relative my-8 h-3 w-full px-2",
|
|
491
|
-
children: /* @__PURE__ */
|
|
492
|
-
modifiers: [
|
|
493
|
+
children: /* @__PURE__ */ h(v, {
|
|
494
|
+
modifiers: [Ee.configure({
|
|
493
495
|
inner: n,
|
|
494
496
|
container: e
|
|
495
|
-
}),
|
|
497
|
+
}), g],
|
|
496
498
|
children: [
|
|
497
|
-
/* @__PURE__ */
|
|
498
|
-
/* @__PURE__ */
|
|
499
|
-
/* @__PURE__ */
|
|
499
|
+
/* @__PURE__ */ m(Te, { onHandleRef: r }),
|
|
500
|
+
/* @__PURE__ */ m(pe, {}),
|
|
501
|
+
/* @__PURE__ */ m(y, { children: null })
|
|
500
502
|
]
|
|
501
503
|
})
|
|
502
504
|
});
|
|
503
505
|
}
|
|
504
506
|
//#endregion
|
|
505
507
|
//#region src/package/rangeflow/components/RangeTabs/hooks/use-apply-slider-layout.ts
|
|
506
|
-
function
|
|
508
|
+
function Oe() {
|
|
507
509
|
let e = Y(), t = K((e) => e.range.from.getTime()), n = K((e) => e.range.to.getTime()), { slider: { root: i } } = X();
|
|
508
510
|
o(() => {
|
|
509
511
|
r(() => {
|
|
@@ -518,80 +520,77 @@ function De() {
|
|
|
518
520
|
}
|
|
519
521
|
//#endregion
|
|
520
522
|
//#region src/package/rangeflow/components/RangeTabs/index.tsx
|
|
521
|
-
function
|
|
522
|
-
|
|
523
|
-
let e = K((e) => e.ranges),
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
]),
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
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
|
|
531
533
|
]);
|
|
532
|
-
return /* @__PURE__ */
|
|
534
|
+
return /* @__PURE__ */ m("div", {
|
|
533
535
|
className: "rangeflow-tabs flex items-center justify-center select-none",
|
|
534
|
-
children: /* @__PURE__ */
|
|
536
|
+
children: /* @__PURE__ */ m("div", {
|
|
535
537
|
className: "relative flex items-center overflow-hidden",
|
|
536
|
-
children:
|
|
537
|
-
|
|
538
|
-
"
|
|
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"),
|
|
539
541
|
onClick: () => {
|
|
540
|
-
|
|
541
|
-
|
|
542
|
+
n((e) => {
|
|
543
|
+
e.range.from = t.from, e.range.to = t.to;
|
|
542
544
|
});
|
|
543
545
|
},
|
|
544
|
-
children: [/* @__PURE__ */
|
|
545
|
-
className:
|
|
546
|
-
children:
|
|
547
|
-
}),
|
|
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, {
|
|
548
550
|
className: "rangeflow-tab-indicator absolute inset-0 rounded-sm bg-(--rangeflow-active-bg)",
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
x: 0,
|
|
552
|
-
y: 0
|
|
553
|
-
},
|
|
551
|
+
initial: !1,
|
|
552
|
+
layoutId: e,
|
|
554
553
|
transition: {
|
|
555
554
|
type: "spring",
|
|
556
555
|
stiffness: 200,
|
|
557
556
|
damping: 25
|
|
558
557
|
}
|
|
559
558
|
})]
|
|
560
|
-
}, `${
|
|
559
|
+
}, `${t.from.getTime()}_${t.to.getTime()}`))
|
|
561
560
|
})
|
|
562
561
|
});
|
|
563
562
|
}
|
|
564
563
|
//#endregion
|
|
565
564
|
//#region src/package/rangeflow/components/Calendar/CalendarDayButton.tsx
|
|
566
|
-
function
|
|
567
|
-
let i =
|
|
565
|
+
function Ae({ className: e, day: t, modifiers: n, ...r }) {
|
|
566
|
+
let i = l(null);
|
|
568
567
|
o(() => {
|
|
569
568
|
n.focused && i.current?.focus();
|
|
570
569
|
}, [n.focused]);
|
|
571
570
|
let a = n.selected && !n.range_start && !n.range_middle && !n.range_end;
|
|
572
|
-
return /* @__PURE__ */
|
|
571
|
+
return /* @__PURE__ */ m("button", {
|
|
573
572
|
ref: i,
|
|
574
573
|
"data-range-end": n.range_end || void 0,
|
|
575
574
|
"data-range-middle": n.range_middle || void 0,
|
|
576
575
|
"data-range-start": n.range_start || void 0,
|
|
577
576
|
"data-selected": a || void 0,
|
|
578
577
|
"data-today": n.today || void 0,
|
|
579
|
-
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),
|
|
580
579
|
...r
|
|
581
580
|
});
|
|
582
581
|
}
|
|
583
582
|
//#endregion
|
|
584
583
|
//#region src/package/rangeflow/components/Calendar/Chevron.tsx
|
|
585
|
-
var
|
|
584
|
+
var je = {
|
|
586
585
|
up: "rotate-180",
|
|
587
586
|
down: "",
|
|
588
587
|
left: "rotate-90",
|
|
589
588
|
right: "-rotate-90"
|
|
590
589
|
};
|
|
591
|
-
function
|
|
592
|
-
return /* @__PURE__ */
|
|
590
|
+
function Me({ className: e, orientation: t = "down", size: n = 16 }) {
|
|
591
|
+
return /* @__PURE__ */ m("svg", {
|
|
593
592
|
"aria-hidden": "true",
|
|
594
|
-
className:
|
|
593
|
+
className: b("shrink-0", je[t], e),
|
|
595
594
|
fill: "none",
|
|
596
595
|
height: n,
|
|
597
596
|
stroke: "currentColor",
|
|
@@ -600,26 +599,26 @@ function je({ className: e, orientation: t = "down", size: n = 16 }) {
|
|
|
600
599
|
strokeWidth: 2,
|
|
601
600
|
viewBox: "0 0 24 24",
|
|
602
601
|
width: n,
|
|
603
|
-
children: /* @__PURE__ */
|
|
602
|
+
children: /* @__PURE__ */ m("path", { d: "m6 9 6 6 6-6" })
|
|
604
603
|
});
|
|
605
604
|
}
|
|
606
605
|
//#endregion
|
|
607
606
|
//#region src/package/rangeflow/components/Calendar/index.tsx
|
|
608
|
-
function
|
|
609
|
-
return /* @__PURE__ */
|
|
607
|
+
function Ne({ captionLayout: e = "label", className: t, classNames: n, components: r, showOutsideDays: i = !0, ...a }) {
|
|
608
|
+
return /* @__PURE__ */ m(le, {
|
|
610
609
|
captionLayout: e,
|
|
611
|
-
className:
|
|
610
|
+
className: b("rangeflow-calendar w-fit p-3 select-none", t),
|
|
612
611
|
showOutsideDays: i,
|
|
613
612
|
classNames: {
|
|
614
613
|
months: "relative flex flex-col gap-4 md:flex-row",
|
|
615
614
|
month: "flex w-full flex-col gap-4",
|
|
616
615
|
nav: "absolute inset-x-0 top-0 flex h-7 items-center justify-between",
|
|
617
|
-
button_previous:
|
|
618
|
-
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"),
|
|
619
618
|
month_caption: "flex h-7 items-center justify-center text-xs font-medium text-(--rangeflow-text-muted)",
|
|
620
619
|
caption_label: "text-xs font-medium",
|
|
621
620
|
dropdowns: "flex items-center gap-1 text-xs font-medium text-(--rangeflow-text-muted)",
|
|
622
|
-
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)"),
|
|
623
622
|
dropdown: "absolute inset-0 cursor-pointer opacity-0",
|
|
624
623
|
month_grid: "mt-2 w-full border-collapse",
|
|
625
624
|
weekdays: "flex",
|
|
@@ -637,8 +636,8 @@ function Me({ captionLayout: e = "label", className: t, classNames: n, component
|
|
|
637
636
|
...n
|
|
638
637
|
},
|
|
639
638
|
components: {
|
|
640
|
-
DayButton:
|
|
641
|
-
Chevron:
|
|
639
|
+
DayButton: Ae,
|
|
640
|
+
Chevron: Me,
|
|
642
641
|
...r
|
|
643
642
|
},
|
|
644
643
|
...a
|
|
@@ -646,12 +645,12 @@ function Me({ captionLayout: e = "label", className: t, classNames: n, component
|
|
|
646
645
|
}
|
|
647
646
|
//#endregion
|
|
648
647
|
//#region src/package/rangeflow/components/Popover/index.tsx
|
|
649
|
-
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, {
|
|
650
649
|
asChild: !0,
|
|
651
650
|
align: e,
|
|
652
651
|
sideOffset: n,
|
|
653
652
|
...i,
|
|
654
|
-
children: /* @__PURE__ */
|
|
653
|
+
children: /* @__PURE__ */ m(S.div, {
|
|
655
654
|
animate: {
|
|
656
655
|
opacity: 1,
|
|
657
656
|
scale: 1,
|
|
@@ -669,17 +668,17 @@ var Ne = n(({ align: e = "center", className: t, sideOffset: n = 6, children: r,
|
|
|
669
668
|
damping: 32,
|
|
670
669
|
mass: .8
|
|
671
670
|
},
|
|
672
|
-
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),
|
|
673
672
|
children: r
|
|
674
673
|
})
|
|
675
|
-
}) })),
|
|
674
|
+
}) })), Fe = O.Root, Ie = O.Trigger;
|
|
676
675
|
O.Anchor;
|
|
677
676
|
//#endregion
|
|
678
677
|
//#region src/package/rangeflow/components/PickerBar/CalendarPopover.tsx
|
|
679
|
-
function
|
|
678
|
+
function Le({ children: e }) {
|
|
680
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 = () => {
|
|
681
|
-
let e =
|
|
682
|
-
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")), {
|
|
683
682
|
from: e.toDate(),
|
|
684
683
|
to: t.toDate()
|
|
685
684
|
};
|
|
@@ -693,18 +692,18 @@ function Q({ children: e }) {
|
|
|
693
692
|
t.range = e;
|
|
694
693
|
});
|
|
695
694
|
};
|
|
696
|
-
return /* @__PURE__ */
|
|
695
|
+
return /* @__PURE__ */ h(Fe, {
|
|
697
696
|
modal: !0,
|
|
698
697
|
onOpenChange: (e) => {
|
|
699
698
|
e === !1 && l();
|
|
700
699
|
},
|
|
701
|
-
children: [/* @__PURE__ */
|
|
700
|
+
children: [/* @__PURE__ */ m(Ie, {
|
|
702
701
|
className: "cursor-pointer",
|
|
703
702
|
children: e
|
|
704
|
-
}), /* @__PURE__ */
|
|
703
|
+
}), /* @__PURE__ */ m(Pe, {
|
|
705
704
|
align: "start",
|
|
706
705
|
sideOffset: 10,
|
|
707
|
-
children: /* @__PURE__ */
|
|
706
|
+
children: /* @__PURE__ */ m(Ne, {
|
|
708
707
|
defaultMonth: r.from,
|
|
709
708
|
numberOfMonths: 2,
|
|
710
709
|
showOutsideDays: !1,
|
|
@@ -716,7 +715,7 @@ function Q({ children: e }) {
|
|
|
716
715
|
selected: r,
|
|
717
716
|
onSelect: (e) => {
|
|
718
717
|
if (!e?.from || !e?.to) return;
|
|
719
|
-
let n =
|
|
718
|
+
let n = d(e.from).startOf("day"), r = d(e.to).startOf("day"), i = {
|
|
720
719
|
from: n.toDate(),
|
|
721
720
|
to: r.toDate()
|
|
722
721
|
};
|
|
@@ -730,14 +729,14 @@ function Q({ children: e }) {
|
|
|
730
729
|
}
|
|
731
730
|
//#endregion
|
|
732
731
|
//#region src/package/rangeflow/icons/CalendarIcon.tsx
|
|
733
|
-
function
|
|
734
|
-
return /* @__PURE__ */
|
|
732
|
+
function Q() {
|
|
733
|
+
return /* @__PURE__ */ m("svg", {
|
|
735
734
|
fill: "none",
|
|
736
735
|
height: "15",
|
|
737
736
|
viewBox: "0 0 15 15",
|
|
738
737
|
width: "15",
|
|
739
738
|
xmlns: "http://www.w3.org/2000/svg",
|
|
740
|
-
children: /* @__PURE__ */
|
|
739
|
+
children: /* @__PURE__ */ m("path", {
|
|
741
740
|
clipRule: "evenodd",
|
|
742
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",
|
|
743
742
|
fill: "currentColor",
|
|
@@ -748,8 +747,8 @@ function Ie() {
|
|
|
748
747
|
//#endregion
|
|
749
748
|
//#region src/package/rangeflow/components/PickerBar/SelectedDate.tsx
|
|
750
749
|
function $() {
|
|
751
|
-
let e = K((e) => e.selected_date), { SelectedDate: n } = G(), { from: r, to: i } =
|
|
752
|
-
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 = {
|
|
753
752
|
from: n.format(i),
|
|
754
753
|
to: r.format(i)
|
|
755
754
|
};
|
|
@@ -758,12 +757,12 @@ function $() {
|
|
|
758
757
|
return n ? t(n, {
|
|
759
758
|
from: r,
|
|
760
759
|
to: i
|
|
761
|
-
}) : /* @__PURE__ */
|
|
760
|
+
}) : /* @__PURE__ */ h("div", {
|
|
762
761
|
className: "rangeflow-selected-date flex items-center gap-2 text-xs font-medium text-(--rangeflow-accent-text) select-none hover:opacity-90",
|
|
763
762
|
children: [
|
|
764
|
-
/* @__PURE__ */
|
|
763
|
+
/* @__PURE__ */ m(Q, {}),
|
|
765
764
|
r,
|
|
766
|
-
/* @__PURE__ */
|
|
765
|
+
/* @__PURE__ */ m("span", {
|
|
767
766
|
className: "text-(--rangeflow-text-faint)",
|
|
768
767
|
children: "—"
|
|
769
768
|
}),
|
|
@@ -773,52 +772,52 @@ function $() {
|
|
|
773
772
|
}
|
|
774
773
|
//#endregion
|
|
775
774
|
//#region src/package/rangeflow/components/PickerBar/index.tsx
|
|
776
|
-
function
|
|
775
|
+
function Re() {
|
|
777
776
|
let e = K((e) => e.calendar), { RangeTabs: n } = G();
|
|
778
|
-
return /* @__PURE__ */
|
|
777
|
+
return /* @__PURE__ */ h("div", {
|
|
779
778
|
className: "flex h-full items-center justify-between px-2",
|
|
780
|
-
children: [e ? /* @__PURE__ */
|
|
779
|
+
children: [e ? /* @__PURE__ */ m(Le, { children: /* @__PURE__ */ m($, {}) }) : /* @__PURE__ */ m($, {}), n ? t(n) : /* @__PURE__ */ m(ke, {})]
|
|
781
780
|
});
|
|
782
781
|
}
|
|
783
782
|
//#endregion
|
|
784
783
|
//#region src/package/rangeflow/hooks/use-rangeflow-events.ts
|
|
785
|
-
function
|
|
784
|
+
function ze() {
|
|
786
785
|
return a(V).events;
|
|
787
786
|
}
|
|
788
787
|
//#endregion
|
|
789
788
|
//#region src/package/rangeflow/hooks/use-emit-date-change.ts
|
|
790
|
-
function
|
|
791
|
-
let e = J(), { onChange: t } =
|
|
789
|
+
function Be() {
|
|
790
|
+
let e = J(), { onChange: t } = ze();
|
|
792
791
|
o(() => e.subscribe((e, n) => {
|
|
793
792
|
e.selected_date !== n.selected_date && t(e.selected_date);
|
|
794
793
|
}), [e, t]);
|
|
795
794
|
}
|
|
796
795
|
//#endregion
|
|
797
796
|
//#region src/package/rangeflow/Root.tsx
|
|
798
|
-
function
|
|
799
|
-
return
|
|
797
|
+
function Ve() {
|
|
798
|
+
return Be(), /* @__PURE__ */ h("div", {
|
|
800
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)",
|
|
801
|
-
children: [/* @__PURE__ */
|
|
800
|
+
children: [/* @__PURE__ */ m("div", {
|
|
802
801
|
className: "rangeflow-header h-10 border-b border-(--rangeflow-border) p-2",
|
|
803
|
-
children: /* @__PURE__ */
|
|
804
|
-
}), /* @__PURE__ */
|
|
802
|
+
children: /* @__PURE__ */ m(Re, {})
|
|
803
|
+
}), /* @__PURE__ */ m("div", {
|
|
805
804
|
className: "rangeflow-body mx-2",
|
|
806
|
-
children: /* @__PURE__ */
|
|
805
|
+
children: /* @__PURE__ */ m(De, {})
|
|
807
806
|
})]
|
|
808
807
|
});
|
|
809
808
|
}
|
|
810
809
|
//#endregion
|
|
811
810
|
//#region src/package/rangeflow/index.tsx
|
|
812
|
-
function
|
|
813
|
-
return /* @__PURE__ */
|
|
811
|
+
function He(e) {
|
|
812
|
+
return /* @__PURE__ */ m(H, {
|
|
814
813
|
...e,
|
|
815
|
-
children: /* @__PURE__ */
|
|
814
|
+
children: /* @__PURE__ */ m(Ve, {})
|
|
816
815
|
});
|
|
817
816
|
}
|
|
818
817
|
//#endregion
|
|
819
818
|
//#region src/package/rangeflow/hooks/use-rangeflow.ts
|
|
820
|
-
function
|
|
821
|
-
let e =
|
|
819
|
+
function Ue() {
|
|
820
|
+
let e = l(null), t = l(null), n = i((n) => {
|
|
822
821
|
let r = e.current;
|
|
823
822
|
if (!r) return;
|
|
824
823
|
let { selected_date: i, update: a } = r.getState(), { size: o, left: s, right: c } = F(n, i);
|
|
@@ -853,4 +852,4 @@ function He() {
|
|
|
853
852
|
};
|
|
854
853
|
}
|
|
855
854
|
//#endregion
|
|
856
|
-
export {
|
|
855
|
+
export { He as RangeFlow, Ue as useRangeflow };
|