@innosolutions/inno-calendar 1.0.60 → 1.0.62
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/AGENT.md +31 -4
- package/dist/{agenda-widget-COpTIR70.js → agenda-widget-Couk7jMB.js} +1314 -1296
- package/dist/agenda-widget-Couk7jMB.js.map +1 -0
- package/dist/agenda-widget-DZkEXTh-.cjs +2 -0
- package/dist/agenda-widget-DZkEXTh-.cjs.map +1 -0
- package/dist/components/event/event-card.d.ts.map +1 -1
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.mjs +2 -2
- package/dist/components/primitives/scroll-navigator.d.ts +3 -1
- package/dist/components/primitives/scroll-navigator.d.ts.map +1 -1
- package/dist/components/views/timeline-view.d.ts +1 -1
- package/dist/components/views/timeline-view.d.ts.map +1 -1
- package/dist/core/context/slot-selection-context.d.ts +2 -0
- package/dist/core/context/slot-selection-context.d.ts.map +1 -1
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +4 -4
- package/dist/presets/index.cjs +1 -1
- package/dist/presets/index.mjs +1 -1
- package/dist/slot-selection-context-CRstOosL.js +604 -0
- package/dist/{slot-selection-context-CKGT_45R.js.map → slot-selection-context-CRstOosL.js.map} +1 -1
- package/dist/slot-selection-context-DBCZI2Dn.cjs +2 -0
- package/dist/{slot-selection-context-CS1te8uo.cjs.map → slot-selection-context-DBCZI2Dn.cjs.map} +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/{tailwind-calendar-C3DidCJ5.js → tailwind-calendar-CNhXkxzW.js} +2 -2
- package/dist/{tailwind-calendar-C3DidCJ5.js.map → tailwind-calendar-CNhXkxzW.js.map} +1 -1
- package/dist/{tailwind-calendar-iFeIx0Ci.cjs → tailwind-calendar-VRvPJQwa.cjs} +2 -2
- package/dist/{tailwind-calendar-iFeIx0Ci.cjs.map → tailwind-calendar-VRvPJQwa.cjs.map} +1 -1
- package/dist/week-view-C1Vu2ErD.cjs +11 -0
- package/dist/week-view-C1Vu2ErD.cjs.map +1 -0
- package/dist/{week-view-CNbtlkE_.js → week-view-DY167Wok.js} +700 -670
- package/dist/week-view-DY167Wok.js.map +1 -0
- package/package.json +1 -1
- package/dist/agenda-widget-BtjS59HE.cjs +0 -2
- package/dist/agenda-widget-BtjS59HE.cjs.map +0 -1
- package/dist/agenda-widget-COpTIR70.js.map +0 -1
- package/dist/slot-selection-context-CKGT_45R.js +0 -598
- package/dist/slot-selection-context-CS1te8uo.cjs +0 -2
- package/dist/week-view-B9_48WmF.cjs +0 -11
- package/dist/week-view-B9_48WmF.cjs.map +0 -1
- package/dist/week-view-CNbtlkE_.js.map +0 -1
|
@@ -1,598 +0,0 @@
|
|
|
1
|
-
import { jsx as A } from "react/jsx-runtime";
|
|
2
|
-
import { useState as h, useCallback as w, useContext as L, createContext as $, useMemo as W, useEffect as j, useRef as Se } from "react";
|
|
3
|
-
import { aI as N } from "./position-utils-DMVQFywD.js";
|
|
4
|
-
const z = $(void 0);
|
|
5
|
-
function Re({
|
|
6
|
-
children: n,
|
|
7
|
-
onEventDrop: t
|
|
8
|
-
}) {
|
|
9
|
-
const [e, o] = h(null), l = w((r) => {
|
|
10
|
-
const f = typeof r.startDate == "string" ? new Date(r.startDate) : r.startDate, S = typeof r.endDate == "string" ? new Date(r.endDate) : r.endDate;
|
|
11
|
-
o({
|
|
12
|
-
event: r,
|
|
13
|
-
originalStartDate: f,
|
|
14
|
-
originalEndDate: S
|
|
15
|
-
});
|
|
16
|
-
}, []), c = w((r, f, S, i) => {
|
|
17
|
-
o((y) => y ? {
|
|
18
|
-
...y,
|
|
19
|
-
previewDate: r,
|
|
20
|
-
previewHour: f,
|
|
21
|
-
previewMinute: S,
|
|
22
|
-
...i !== void 0 && { targetResourceId: i }
|
|
23
|
-
} : null);
|
|
24
|
-
}, []), d = w(() => {
|
|
25
|
-
if (!e) return null;
|
|
26
|
-
const { event: r, originalStartDate: f, originalEndDate: S, previewDate: i, previewHour: y, previewMinute: O, targetResourceId: I } = e, k = S.getTime() - f.getTime();
|
|
27
|
-
let s;
|
|
28
|
-
i ? (s = new Date(i), typeof y == "number" ? s.setHours(y, O ?? 0, 0, 0) : s.setHours(
|
|
29
|
-
f.getHours(),
|
|
30
|
-
f.getMinutes(),
|
|
31
|
-
f.getSeconds(),
|
|
32
|
-
0
|
|
33
|
-
)) : s = f;
|
|
34
|
-
const m = new Date(s.getTime() + k), T = {
|
|
35
|
-
event: r,
|
|
36
|
-
newStartDate: s,
|
|
37
|
-
newEndDate: m,
|
|
38
|
-
...I !== void 0 && { newResourceId: I }
|
|
39
|
-
};
|
|
40
|
-
return o(null), t?.(T), T;
|
|
41
|
-
}, [e, t]), u = w(() => {
|
|
42
|
-
o(null);
|
|
43
|
-
}, []);
|
|
44
|
-
return /* @__PURE__ */ A(
|
|
45
|
-
z.Provider,
|
|
46
|
-
{
|
|
47
|
-
value: {
|
|
48
|
-
dragState: e,
|
|
49
|
-
isDragging: e !== null,
|
|
50
|
-
startDrag: l,
|
|
51
|
-
updateDragPreview: c,
|
|
52
|
-
endDrag: d,
|
|
53
|
-
cancelDrag: u
|
|
54
|
-
},
|
|
55
|
-
children: n
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
function Ve() {
|
|
60
|
-
const n = L(z);
|
|
61
|
-
if (!n)
|
|
62
|
-
throw new Error("useDragDrop must be used within a DragDropProvider");
|
|
63
|
-
return n;
|
|
64
|
-
}
|
|
65
|
-
function Ue() {
|
|
66
|
-
return L(z) ?? null;
|
|
67
|
-
}
|
|
68
|
-
const me = "inno-calendar-preferences", pe = {
|
|
69
|
-
from: 0,
|
|
70
|
-
to: 24
|
|
71
|
-
}, be = {
|
|
72
|
-
0: { enabled: !1, from: 8, to: 18 },
|
|
73
|
-
// Sunday - disabled
|
|
74
|
-
1: { enabled: !0, from: 8, to: 18 },
|
|
75
|
-
// Monday
|
|
76
|
-
2: { enabled: !0, from: 8, to: 18 },
|
|
77
|
-
// Tuesday
|
|
78
|
-
3: { enabled: !0, from: 8, to: 18 },
|
|
79
|
-
// Wednesday
|
|
80
|
-
4: { enabled: !0, from: 8, to: 18 },
|
|
81
|
-
// Thursday
|
|
82
|
-
5: { enabled: !0, from: 8, to: 18 },
|
|
83
|
-
// Friday
|
|
84
|
-
6: { enabled: !1, from: 8, to: 18 }
|
|
85
|
-
// Saturday - disabled
|
|
86
|
-
}, He = 30, ye = {
|
|
87
|
-
view: "month",
|
|
88
|
-
badgeVariant: "colored",
|
|
89
|
-
slotDuration: He,
|
|
90
|
-
visibleHours: pe,
|
|
91
|
-
workingHours: be,
|
|
92
|
-
showWorkingHoursOnly: !1,
|
|
93
|
-
showWeekends: !0,
|
|
94
|
-
firstDayOfWeek: 1
|
|
95
|
-
};
|
|
96
|
-
function ke(n) {
|
|
97
|
-
if (typeof window > "u") return {};
|
|
98
|
-
try {
|
|
99
|
-
const t = localStorage.getItem(n);
|
|
100
|
-
if (!t) return {};
|
|
101
|
-
const e = JSON.parse(t), o = {};
|
|
102
|
-
return e.view && typeof e.view == "string" && (o.view = e.view), e.badgeVariant && typeof e.badgeVariant == "string" && (o.badgeVariant = e.badgeVariant), e.slotDuration && typeof e.slotDuration == "number" && (o.slotDuration = e.slotDuration), e.visibleHours && typeof e.visibleHours == "object" && (o.visibleHours = e.visibleHours), e.workingHours && typeof e.workingHours == "object" && (o.workingHours = e.workingHours), typeof e.showWorkingHoursOnly == "boolean" && (o.showWorkingHoursOnly = e.showWorkingHoursOnly), typeof e.showWeekends == "boolean" && (o.showWeekends = e.showWeekends), typeof e.firstDayOfWeek == "number" && (o.firstDayOfWeek = e.firstDayOfWeek), o;
|
|
103
|
-
} catch {
|
|
104
|
-
return console.warn("[InnoCalendar] Failed to load preferences from localStorage"), {};
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function he(n, t) {
|
|
108
|
-
if (!(typeof window > "u"))
|
|
109
|
-
try {
|
|
110
|
-
localStorage.setItem(n, JSON.stringify(t));
|
|
111
|
-
} catch {
|
|
112
|
-
console.warn("[InnoCalendar] Failed to save preferences to localStorage");
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
function Ie(n = {}) {
|
|
116
|
-
const {
|
|
117
|
-
modes: t = {},
|
|
118
|
-
locked: e = {},
|
|
119
|
-
defaults: o = {},
|
|
120
|
-
storageKey: l = me,
|
|
121
|
-
disableStorage: c = !1
|
|
122
|
-
} = n, d = W(
|
|
123
|
-
() => ({
|
|
124
|
-
...ye,
|
|
125
|
-
...o
|
|
126
|
-
}),
|
|
127
|
-
[o]
|
|
128
|
-
), [u, r] = h(() => c ? {} : ke(l)), [f, S] = h({});
|
|
129
|
-
j(() => {
|
|
130
|
-
c || he(l, u);
|
|
131
|
-
}, [u, l, c]);
|
|
132
|
-
const i = w(
|
|
133
|
-
(g) => t[g] ?? "user",
|
|
134
|
-
[t]
|
|
135
|
-
), y = w(
|
|
136
|
-
(g) => i(g) === "locked",
|
|
137
|
-
[i]
|
|
138
|
-
), O = w(
|
|
139
|
-
(g) => i(g) === "user" && !c,
|
|
140
|
-
[i, c]
|
|
141
|
-
), I = W(() => {
|
|
142
|
-
const g = { ...d };
|
|
143
|
-
for (const D of Object.keys(g)) {
|
|
144
|
-
const H = i(D);
|
|
145
|
-
H === "locked" && D in e ? g[D] = e[D] : H === "session" && D in f ? g[D] = f[D] : H === "user" && D in u && (g[D] = u[D]);
|
|
146
|
-
}
|
|
147
|
-
return g;
|
|
148
|
-
}, [d, u, f, e, i]), k = w(
|
|
149
|
-
(g, D) => {
|
|
150
|
-
const H = i(g);
|
|
151
|
-
if (H === "locked") {
|
|
152
|
-
console.warn(`[InnoCalendar] Preference "${g}" is locked and cannot be modified`);
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
H === "session" ? S((p) => ({ ...p, [g]: D })) : r((p) => ({ ...p, [g]: D }));
|
|
156
|
-
},
|
|
157
|
-
[i]
|
|
158
|
-
), s = w(
|
|
159
|
-
(g) => {
|
|
160
|
-
const D = {}, H = {};
|
|
161
|
-
for (const p of Object.keys(g)) {
|
|
162
|
-
const C = i(p), P = g[p];
|
|
163
|
-
if (P !== void 0) {
|
|
164
|
-
if (C === "locked") {
|
|
165
|
-
console.warn(`[InnoCalendar] Preference "${p}" is locked and cannot be modified`);
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
C === "session" ? D[p] = P : H[p] = P;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
Object.keys(D).length > 0 && S((p) => ({ ...p, ...D })), Object.keys(H).length > 0 && r((p) => ({ ...p, ...H }));
|
|
172
|
-
},
|
|
173
|
-
[i]
|
|
174
|
-
), m = w(() => {
|
|
175
|
-
r({}), S({}), c || localStorage.removeItem(l);
|
|
176
|
-
}, [l, c]), T = w(
|
|
177
|
-
(g) => {
|
|
178
|
-
const D = i(g);
|
|
179
|
-
if (D === "locked") {
|
|
180
|
-
console.warn(`[InnoCalendar] Preference "${g}" is locked and cannot be reset`);
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
D === "session" ? S((H) => {
|
|
184
|
-
const { [g]: p, ...C } = H;
|
|
185
|
-
return C;
|
|
186
|
-
}) : r((H) => {
|
|
187
|
-
const { [g]: p, ...C } = H;
|
|
188
|
-
return C;
|
|
189
|
-
});
|
|
190
|
-
},
|
|
191
|
-
[i]
|
|
192
|
-
);
|
|
193
|
-
return {
|
|
194
|
-
preferences: I,
|
|
195
|
-
setPreference: k,
|
|
196
|
-
setPreferences: s,
|
|
197
|
-
resetPreferences: m,
|
|
198
|
-
resetPreference: T,
|
|
199
|
-
isLocked: y,
|
|
200
|
-
isPersisted: O,
|
|
201
|
-
getMode: i
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
const K = $(void 0), ce = {
|
|
205
|
-
0: { enabled: !1, from: 8, to: 17 },
|
|
206
|
-
// Sunday
|
|
207
|
-
1: { enabled: !0, from: 8, to: 17 },
|
|
208
|
-
// Monday
|
|
209
|
-
2: { enabled: !0, from: 8, to: 17 },
|
|
210
|
-
// Tuesday
|
|
211
|
-
3: { enabled: !0, from: 8, to: 17 },
|
|
212
|
-
// Wednesday
|
|
213
|
-
4: { enabled: !0, from: 8, to: 17 },
|
|
214
|
-
// Thursday
|
|
215
|
-
5: { enabled: !0, from: 8, to: 17 },
|
|
216
|
-
// Friday
|
|
217
|
-
6: { enabled: !0, from: 8, to: 12 }
|
|
218
|
-
// Saturday
|
|
219
|
-
}, ve = { start: 0, end: 24 };
|
|
220
|
-
function _e({
|
|
221
|
-
children: n,
|
|
222
|
-
initialEvents: t = [],
|
|
223
|
-
initialUsers: e = [],
|
|
224
|
-
initialScheduleTypes: o = [],
|
|
225
|
-
initialView: l,
|
|
226
|
-
initialDate: c,
|
|
227
|
-
initialSelectedUserId: d = "all",
|
|
228
|
-
initialScheduleTypeIds: u = [],
|
|
229
|
-
initialParticipantIds: r = [],
|
|
230
|
-
initialWorkingHoursView: f = "default",
|
|
231
|
-
initialSearchQuery: S = "",
|
|
232
|
-
preferencesConfig: i,
|
|
233
|
-
initialFocusEventId: y = null,
|
|
234
|
-
onDateChange: O,
|
|
235
|
-
onViewChange: I
|
|
236
|
-
}) {
|
|
237
|
-
const { preferences: k, setPreference: s, isLocked: m } = Ie(i), [T, g] = h(
|
|
238
|
-
l ?? k.view ?? "week"
|
|
239
|
-
), [D, H] = h(
|
|
240
|
-
c ?? /* @__PURE__ */ new Date()
|
|
241
|
-
), [p, C] = h(
|
|
242
|
-
d
|
|
243
|
-
), P = k.badgeVariant ?? "colored", Y = w(
|
|
244
|
-
(a) => {
|
|
245
|
-
m("badgeVariant") || s("badgeVariant", a);
|
|
246
|
-
},
|
|
247
|
-
[s, m]
|
|
248
|
-
), B = k.workingHours ?? ce, G = w(
|
|
249
|
-
(a) => {
|
|
250
|
-
if (!m("workingHours")) {
|
|
251
|
-
const b = k.workingHours ?? ce, v = typeof a == "function" ? a(b) : a;
|
|
252
|
-
s("workingHours", v);
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
|
-
[s, m, k.workingHours]
|
|
256
|
-
), E = k.visibleHours, _ = W(() => E ? {
|
|
257
|
-
start: E.start ?? E.from ?? 0,
|
|
258
|
-
end: E.end ?? E.to ?? 24
|
|
259
|
-
} : ve, [E]), J = w(
|
|
260
|
-
(a) => {
|
|
261
|
-
if (!m("visibleHours")) {
|
|
262
|
-
const b = typeof a == "function" ? a(_) : a;
|
|
263
|
-
s("visibleHours", {
|
|
264
|
-
from: b.start,
|
|
265
|
-
to: b.end
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
},
|
|
269
|
-
[s, m, _]
|
|
270
|
-
), [le, de] = h(
|
|
271
|
-
f === "enabled" ? !0 : f === "disabled" ? !1 : k.showWorkingHoursOnly ?? !1
|
|
272
|
-
), q = le, X = w(
|
|
273
|
-
(a) => {
|
|
274
|
-
de(a), m("showWorkingHoursOnly") || s("showWorkingHoursOnly", a);
|
|
275
|
-
},
|
|
276
|
-
[s, m]
|
|
277
|
-
), Z = k.slotDuration ?? 30, ee = w(
|
|
278
|
-
(a) => {
|
|
279
|
-
m("slotDuration") || s("slotDuration", a);
|
|
280
|
-
},
|
|
281
|
-
[s, m]
|
|
282
|
-
), [x, te] = h(t);
|
|
283
|
-
j(() => {
|
|
284
|
-
te(t);
|
|
285
|
-
}, [t]);
|
|
286
|
-
const [R, fe] = h(u), [M, Pe] = h(r), [V, ge] = h(S), [ne, oe] = h(
|
|
287
|
-
y ?? null
|
|
288
|
-
);
|
|
289
|
-
j(() => {
|
|
290
|
-
y && oe(y);
|
|
291
|
-
}, [y]);
|
|
292
|
-
const re = w(() => oe(null), []), se = w(
|
|
293
|
-
(a) => {
|
|
294
|
-
g(a), m("view") || s("view", a), I?.(a);
|
|
295
|
-
},
|
|
296
|
-
[I, s, m]
|
|
297
|
-
), ae = w(
|
|
298
|
-
(a, b) => {
|
|
299
|
-
H(a), O?.(a, b ?? T);
|
|
300
|
-
},
|
|
301
|
-
[O, T]
|
|
302
|
-
), ie = W(() => {
|
|
303
|
-
let a = x;
|
|
304
|
-
if (R.length > 0 && (a = a.filter(
|
|
305
|
-
(b) => b.scheduleTypeId !== void 0 && R.includes(b.scheduleTypeId)
|
|
306
|
-
)), M.length > 0 && (a = a.filter((b) => b.participants?.length ? b.participants.some(
|
|
307
|
-
(v) => M.includes(v.id)
|
|
308
|
-
) : !1)), p !== "all" && (a = a.filter(
|
|
309
|
-
(b) => b.participants?.some((v) => v.id === p)
|
|
310
|
-
)), V.trim()) {
|
|
311
|
-
const b = V.toLowerCase();
|
|
312
|
-
a = a.filter(
|
|
313
|
-
(v) => N(v.title).toLowerCase().includes(b) || N(v.description).toLowerCase().includes(b) || N(v.scheduleTypeName).toLowerCase().includes(b) || v.participants?.some((De) => De.name.toLowerCase().includes(b))
|
|
314
|
-
);
|
|
315
|
-
}
|
|
316
|
-
return a;
|
|
317
|
-
}, [
|
|
318
|
-
x,
|
|
319
|
-
R,
|
|
320
|
-
M,
|
|
321
|
-
p,
|
|
322
|
-
V
|
|
323
|
-
]), we = W(
|
|
324
|
-
() => ({
|
|
325
|
-
// View & Navigation
|
|
326
|
-
view: T,
|
|
327
|
-
setView: se,
|
|
328
|
-
selectedDate: D,
|
|
329
|
-
setSelectedDate: ae,
|
|
330
|
-
// User Filtering
|
|
331
|
-
selectedUserId: p,
|
|
332
|
-
setSelectedUserId: C,
|
|
333
|
-
// Visual Customization
|
|
334
|
-
badgeVariant: P,
|
|
335
|
-
setBadgeVariant: Y,
|
|
336
|
-
// Time Configuration
|
|
337
|
-
workingHours: B,
|
|
338
|
-
setWorkingHours: G,
|
|
339
|
-
visibleHours: _,
|
|
340
|
-
setVisibleHours: J,
|
|
341
|
-
showWorkingHoursOnly: q,
|
|
342
|
-
setShowWorkingHoursOnly: X,
|
|
343
|
-
slotDuration: Z,
|
|
344
|
-
setSlotDuration: ee,
|
|
345
|
-
// Preferences
|
|
346
|
-
isPreferenceLocked: m,
|
|
347
|
-
// Data
|
|
348
|
-
events: x,
|
|
349
|
-
setEvents: te,
|
|
350
|
-
users: e,
|
|
351
|
-
scheduleTypes: o,
|
|
352
|
-
// Filters
|
|
353
|
-
selectedScheduleTypeIds: R,
|
|
354
|
-
setSelectedScheduleTypeIds: fe,
|
|
355
|
-
// Search
|
|
356
|
-
searchQuery: V,
|
|
357
|
-
setSearchQuery: ge,
|
|
358
|
-
// Computed
|
|
359
|
-
filteredEvents: ie,
|
|
360
|
-
// Focus Event
|
|
361
|
-
focusEventId: ne,
|
|
362
|
-
clearFocusEventId: re
|
|
363
|
-
}),
|
|
364
|
-
[
|
|
365
|
-
T,
|
|
366
|
-
se,
|
|
367
|
-
D,
|
|
368
|
-
ae,
|
|
369
|
-
p,
|
|
370
|
-
P,
|
|
371
|
-
Y,
|
|
372
|
-
B,
|
|
373
|
-
G,
|
|
374
|
-
_,
|
|
375
|
-
J,
|
|
376
|
-
q,
|
|
377
|
-
X,
|
|
378
|
-
Z,
|
|
379
|
-
ee,
|
|
380
|
-
m,
|
|
381
|
-
x,
|
|
382
|
-
e,
|
|
383
|
-
o,
|
|
384
|
-
R,
|
|
385
|
-
V,
|
|
386
|
-
ie,
|
|
387
|
-
ne,
|
|
388
|
-
re
|
|
389
|
-
]
|
|
390
|
-
);
|
|
391
|
-
return /* @__PURE__ */ A(K.Provider, { value: we, children: n });
|
|
392
|
-
}
|
|
393
|
-
function F() {
|
|
394
|
-
const n = L(K);
|
|
395
|
-
if (!n)
|
|
396
|
-
throw new Error(
|
|
397
|
-
"useInnoCalendar must be used within an InnoCalendarProvider"
|
|
398
|
-
);
|
|
399
|
-
return n;
|
|
400
|
-
}
|
|
401
|
-
function xe() {
|
|
402
|
-
return L(K);
|
|
403
|
-
}
|
|
404
|
-
function Fe() {
|
|
405
|
-
const { view: n, setView: t, selectedDate: e, setSelectedDate: o, slotDuration: l } = F();
|
|
406
|
-
return { view: n, setView: t, selectedDate: e, setSelectedDate: o, slotDuration: l };
|
|
407
|
-
}
|
|
408
|
-
function Me() {
|
|
409
|
-
const { events: n, setEvents: t, filteredEvents: e } = F();
|
|
410
|
-
return { events: n, setEvents: t, filteredEvents: e };
|
|
411
|
-
}
|
|
412
|
-
function Ne() {
|
|
413
|
-
const {
|
|
414
|
-
selectedScheduleTypeIds: n,
|
|
415
|
-
setSelectedScheduleTypeIds: t,
|
|
416
|
-
selectedUserId: e,
|
|
417
|
-
setSelectedUserId: o,
|
|
418
|
-
searchQuery: l,
|
|
419
|
-
setSearchQuery: c
|
|
420
|
-
} = F();
|
|
421
|
-
return {
|
|
422
|
-
selectedScheduleTypeIds: n,
|
|
423
|
-
setSelectedScheduleTypeIds: t,
|
|
424
|
-
selectedUserId: e,
|
|
425
|
-
setSelectedUserId: o,
|
|
426
|
-
searchQuery: l,
|
|
427
|
-
setSearchQuery: c
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
function je() {
|
|
431
|
-
const {
|
|
432
|
-
workingHours: n,
|
|
433
|
-
setWorkingHours: t,
|
|
434
|
-
visibleHours: e,
|
|
435
|
-
setVisibleHours: o,
|
|
436
|
-
showWorkingHoursOnly: l,
|
|
437
|
-
setShowWorkingHoursOnly: c
|
|
438
|
-
} = F();
|
|
439
|
-
return {
|
|
440
|
-
workingHours: n,
|
|
441
|
-
setWorkingHours: t,
|
|
442
|
-
visibleHours: e,
|
|
443
|
-
setVisibleHours: o,
|
|
444
|
-
showWorkingHoursOnly: l,
|
|
445
|
-
setShowWorkingHoursOnly: c
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
const Q = $(void 0);
|
|
449
|
-
function U(n) {
|
|
450
|
-
const t = new Date(n.date);
|
|
451
|
-
return typeof n.hour == "number" && t.setHours(n.hour, n.minute ?? 0, 0, 0), t;
|
|
452
|
-
}
|
|
453
|
-
function Oe(n) {
|
|
454
|
-
const t = new Date(n), e = t.getMinutes(), o = Math.floor(e / 30) * 30;
|
|
455
|
-
return t.setMinutes(o, 0, 0), t;
|
|
456
|
-
}
|
|
457
|
-
function Te(n, t) {
|
|
458
|
-
return n.getFullYear() === t.getFullYear() && n.getMonth() === t.getMonth() && n.getDate() === t.getDate();
|
|
459
|
-
}
|
|
460
|
-
function ue(n, t, e, o, l = 30) {
|
|
461
|
-
const c = U(n), d = U(t);
|
|
462
|
-
let u = c, r = d;
|
|
463
|
-
if (d < c && (u = d, r = c), e === "day")
|
|
464
|
-
if (Te(u, r)) {
|
|
465
|
-
const S = Oe(/* @__PURE__ */ new Date());
|
|
466
|
-
u = new Date(u), u.setHours(S.getHours(), S.getMinutes(), 0, 0), r = new Date(u.getTime() + o * 60 * 1e3);
|
|
467
|
-
} else
|
|
468
|
-
u.setHours(0, 0, 0, 0), r.setHours(23, 59, 59, 999);
|
|
469
|
-
else {
|
|
470
|
-
const f = l * 60 * 1e3;
|
|
471
|
-
r = new Date(r.getTime() + f);
|
|
472
|
-
const S = r.getTime() - u.getTime(), i = o * 60 * 1e3;
|
|
473
|
-
S < i && (r = new Date(u.getTime() + i));
|
|
474
|
-
}
|
|
475
|
-
return {
|
|
476
|
-
startDate: u,
|
|
477
|
-
endDate: r
|
|
478
|
-
};
|
|
479
|
-
}
|
|
480
|
-
function Ce(n, t, e, o) {
|
|
481
|
-
const l = U(n), c = U(t), d = U(e), u = c <= d ? c : d, r = c <= d ? d : c;
|
|
482
|
-
if (o === "day") {
|
|
483
|
-
const f = new Date(l);
|
|
484
|
-
f.setHours(0, 0, 0, 0);
|
|
485
|
-
const S = new Date(u);
|
|
486
|
-
S.setHours(0, 0, 0, 0);
|
|
487
|
-
const i = new Date(r);
|
|
488
|
-
return i.setHours(0, 0, 0, 0), f >= S && f <= i;
|
|
489
|
-
}
|
|
490
|
-
return l >= u && l <= r;
|
|
491
|
-
}
|
|
492
|
-
function Ae({
|
|
493
|
-
children: n,
|
|
494
|
-
mode: t = "time",
|
|
495
|
-
onSelect: e,
|
|
496
|
-
minDurationMinutes: o = 30,
|
|
497
|
-
slotDurationMinutes: l = 30,
|
|
498
|
-
enabled: c = !0
|
|
499
|
-
}) {
|
|
500
|
-
const [d, u] = h(null), r = Se(!1), f = w(
|
|
501
|
-
(s) => {
|
|
502
|
-
c && (r.current = !0, u({
|
|
503
|
-
start: s,
|
|
504
|
-
end: s,
|
|
505
|
-
isSelecting: !0
|
|
506
|
-
}));
|
|
507
|
-
},
|
|
508
|
-
[c]
|
|
509
|
-
), S = w(
|
|
510
|
-
(s) => {
|
|
511
|
-
c && r.current && u((m) => m ? {
|
|
512
|
-
...m,
|
|
513
|
-
end: s
|
|
514
|
-
} : null);
|
|
515
|
-
},
|
|
516
|
-
[c]
|
|
517
|
-
), i = w(() => {
|
|
518
|
-
r.current && (r.current = !1, u((s) => {
|
|
519
|
-
if (!s) return null;
|
|
520
|
-
const m = ue(
|
|
521
|
-
s.start,
|
|
522
|
-
s.end,
|
|
523
|
-
t,
|
|
524
|
-
o,
|
|
525
|
-
l
|
|
526
|
-
);
|
|
527
|
-
return e?.(m), {
|
|
528
|
-
...s,
|
|
529
|
-
isSelecting: !1
|
|
530
|
-
};
|
|
531
|
-
}), setTimeout(() => {
|
|
532
|
-
u(null);
|
|
533
|
-
}, 100));
|
|
534
|
-
}, [t, o, l, e]), y = w(() => {
|
|
535
|
-
r.current = !1, u(null);
|
|
536
|
-
}, []), O = w(
|
|
537
|
-
(s) => d ? Ce(s, d.start, d.end, t) : !1,
|
|
538
|
-
[d, t]
|
|
539
|
-
), I = w(() => d ? ue(
|
|
540
|
-
d.start,
|
|
541
|
-
d.end,
|
|
542
|
-
t,
|
|
543
|
-
o,
|
|
544
|
-
l
|
|
545
|
-
) : null, [d, t, o, l]), k = W(
|
|
546
|
-
() => ({
|
|
547
|
-
isSelecting: d?.isSelecting ?? !1,
|
|
548
|
-
startSelection: f,
|
|
549
|
-
updateSelection: S,
|
|
550
|
-
endSelection: i,
|
|
551
|
-
cancelSelection: y,
|
|
552
|
-
isSlotSelected: O,
|
|
553
|
-
getSelectionResult: I,
|
|
554
|
-
mode: t
|
|
555
|
-
}),
|
|
556
|
-
[
|
|
557
|
-
d?.isSelecting,
|
|
558
|
-
f,
|
|
559
|
-
S,
|
|
560
|
-
i,
|
|
561
|
-
y,
|
|
562
|
-
O,
|
|
563
|
-
I,
|
|
564
|
-
t
|
|
565
|
-
]
|
|
566
|
-
);
|
|
567
|
-
return /* @__PURE__ */ A(Q.Provider, { value: k, children: n });
|
|
568
|
-
}
|
|
569
|
-
function $e() {
|
|
570
|
-
const n = L(Q);
|
|
571
|
-
if (!n)
|
|
572
|
-
throw new Error("useSlotSelectionContext must be used within a SlotSelectionProvider");
|
|
573
|
-
return n;
|
|
574
|
-
}
|
|
575
|
-
function ze() {
|
|
576
|
-
return L(Q);
|
|
577
|
-
}
|
|
578
|
-
export {
|
|
579
|
-
Re as D,
|
|
580
|
-
_e as I,
|
|
581
|
-
me as P,
|
|
582
|
-
Ae as S,
|
|
583
|
-
He as a,
|
|
584
|
-
pe as b,
|
|
585
|
-
be as c,
|
|
586
|
-
Ve as d,
|
|
587
|
-
F as e,
|
|
588
|
-
Me as f,
|
|
589
|
-
Ne as g,
|
|
590
|
-
je as h,
|
|
591
|
-
Fe as i,
|
|
592
|
-
Ue as j,
|
|
593
|
-
xe as k,
|
|
594
|
-
ze as l,
|
|
595
|
-
$e as m,
|
|
596
|
-
Ie as u
|
|
597
|
-
};
|
|
598
|
-
//# sourceMappingURL=slot-selection-context-CKGT_45R.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const F=require("react/jsx-runtime"),e=require("react"),V=require("./position-utils-BQpbtF6N.cjs"),M=e.createContext(void 0);function we({children:s,onEventDrop:n}){const[t,o]=e.useState(null),d=e.useCallback(r=>{const g=typeof r.startDate=="string"?new Date(r.startDate):r.startDate,w=typeof r.endDate=="string"?new Date(r.endDate):r.endDate;o({event:r,originalStartDate:g,originalEndDate:w})},[]),i=e.useCallback((r,g,w,u)=>{o(p=>p?{...p,previewDate:r,previewHour:g,previewMinute:w,...u!==void 0&&{targetResourceId:u}}:null)},[]),f=e.useCallback(()=>{if(!t)return null;const{event:r,originalStartDate:g,originalEndDate:w,previewDate:u,previewHour:p,previewMinute:h,targetResourceId:y}=t,H=w.getTime()-g.getTime();let a;u?(a=new Date(u),typeof p=="number"?a.setHours(p,h??0,0,0):a.setHours(g.getHours(),g.getMinutes(),g.getSeconds(),0)):a=g;const b=new Date(a.getTime()+H),O={event:r,newStartDate:a,newEndDate:b,...y!==void 0&&{newResourceId:y}};return o(null),n?.(O),O},[t,n]),c=e.useCallback(()=>{o(null)},[]);return F.jsx(M.Provider,{value:{dragState:t,isDragging:t!==null,startDrag:d,updateDragPreview:i,endDrag:f,cancelDrag:c},children:s})}function be(){const s=e.useContext(M);if(!s)throw new Error("useDragDrop must be used within a DragDropProvider");return s}function ke(){return e.useContext(M)??null}const re="inno-calendar-preferences",ae={from:0,to:24},le={0:{enabled:!1,from:8,to:18},1:{enabled:!0,from:8,to:18},2:{enabled:!0,from:8,to:18},3:{enabled:!0,from:8,to:18},4:{enabled:!0,from:8,to:18},5:{enabled:!0,from:8,to:18},6:{enabled:!1,from:8,to:18}},ue=30,Ce={view:"month",badgeVariant:"colored",slotDuration:ue,visibleHours:ae,workingHours:le,showWorkingHoursOnly:!1,showWeekends:!0,firstDayOfWeek:1};function me(s){if(typeof window>"u")return{};try{const n=localStorage.getItem(s);if(!n)return{};const t=JSON.parse(n),o={};return t.view&&typeof t.view=="string"&&(o.view=t.view),t.badgeVariant&&typeof t.badgeVariant=="string"&&(o.badgeVariant=t.badgeVariant),t.slotDuration&&typeof t.slotDuration=="number"&&(o.slotDuration=t.slotDuration),t.visibleHours&&typeof t.visibleHours=="object"&&(o.visibleHours=t.visibleHours),t.workingHours&&typeof t.workingHours=="object"&&(o.workingHours=t.workingHours),typeof t.showWorkingHoursOnly=="boolean"&&(o.showWorkingHoursOnly=t.showWorkingHoursOnly),typeof t.showWeekends=="boolean"&&(o.showWeekends=t.showWeekends),typeof t.firstDayOfWeek=="number"&&(o.firstDayOfWeek=t.firstDayOfWeek),o}catch{return console.warn("[InnoCalendar] Failed to load preferences from localStorage"),{}}}function pe(s,n){if(!(typeof window>"u"))try{localStorage.setItem(s,JSON.stringify(n))}catch{console.warn("[InnoCalendar] Failed to save preferences to localStorage")}}function ie(s={}){const{modes:n={},locked:t={},defaults:o={},storageKey:d=re,disableStorage:i=!1}=s,f=e.useMemo(()=>({...Ce,...o}),[o]),[c,r]=e.useState(()=>i?{}:me(d)),[g,w]=e.useState({});e.useEffect(()=>{i||pe(d,c)},[c,d,i]);const u=e.useCallback(S=>n[S]??"user",[n]),p=e.useCallback(S=>u(S)==="locked",[u]),h=e.useCallback(S=>u(S)==="user"&&!i,[u,i]),y=e.useMemo(()=>{const S={...f};for(const D of Object.keys(S)){const m=u(D);m==="locked"&&D in t?S[D]=t[D]:m==="session"&&D in g?S[D]=g[D]:m==="user"&&D in c&&(S[D]=c[D])}return S},[f,c,g,t,u]),H=e.useCallback((S,D)=>{const m=u(S);if(m==="locked"){console.warn(`[InnoCalendar] Preference "${S}" is locked and cannot be modified`);return}m==="session"?w(k=>({...k,[S]:D})):r(k=>({...k,[S]:D}))},[u]),a=e.useCallback(S=>{const D={},m={};for(const k of Object.keys(S)){const v=u(k),T=S[k];if(T!==void 0){if(v==="locked"){console.warn(`[InnoCalendar] Preference "${k}" is locked and cannot be modified`);continue}v==="session"?D[k]=T:m[k]=T}}Object.keys(D).length>0&&w(k=>({...k,...D})),Object.keys(m).length>0&&r(k=>({...k,...m}))},[u]),b=e.useCallback(()=>{r({}),w({}),i||localStorage.removeItem(d)},[d,i]),O=e.useCallback(S=>{const D=u(S);if(D==="locked"){console.warn(`[InnoCalendar] Preference "${S}" is locked and cannot be reset`);return}D==="session"?w(m=>{const{[S]:k,...v}=m;return v}):r(m=>{const{[S]:k,...v}=m;return v})},[u]);return{preferences:y,setPreference:H,setPreferences:a,resetPreferences:b,resetPreference:O,isLocked:p,isPersisted:h,getMode:u}}const N=e.createContext(void 0),se={0:{enabled:!1,from:8,to:17},1:{enabled:!0,from:8,to:17},2:{enabled:!0,from:8,to:17},3:{enabled:!0,from:8,to:17},4:{enabled:!0,from:8,to:17},5:{enabled:!0,from:8,to:17},6:{enabled:!0,from:8,to:12}},He={start:0,end:24};function ye({children:s,initialEvents:n=[],initialUsers:t=[],initialScheduleTypes:o=[],initialView:d,initialDate:i,initialSelectedUserId:f="all",initialScheduleTypeIds:c=[],initialParticipantIds:r=[],initialWorkingHoursView:g="default",initialSearchQuery:w="",preferencesConfig:u,initialFocusEventId:p=null,onDateChange:h,onViewChange:y}){const{preferences:H,setPreference:a,isLocked:b}=ie(u),[O,S]=e.useState(d??H.view??"week"),[D,m]=e.useState(i??new Date),[k,v]=e.useState(f),T=H.badgeVariant??"colored",j=e.useCallback(l=>{b("badgeVariant")||a("badgeVariant",l)},[a,b]),K=H.workingHours??se,G=e.useCallback(l=>{if(!b("workingHours")){const C=H.workingHours??se,I=typeof l=="function"?l(C):l;a("workingHours",I)}},[a,b,H.workingHours]),E=H.visibleHours,_=e.useMemo(()=>E?{start:E.start??E.from??0,end:E.end??E.to??24}:He,[E]),Y=e.useCallback(l=>{if(!b("visibleHours")){const C=typeof l=="function"?l(_):l;a("visibleHours",{from:C.start,to:C.end})}},[a,b,_]),[ce,de]=e.useState(g==="enabled"?!0:g==="disabled"?!1:H.showWorkingHoursOnly??!1),$=ce,q=e.useCallback(l=>{de(l),b("showWorkingHoursOnly")||a("showWorkingHoursOnly",l)},[a,b]),z=H.slotDuration??30,B=e.useCallback(l=>{b("slotDuration")||a("slotDuration",l)},[a,b]),[U,Q]=e.useState(n);e.useEffect(()=>{Q(n)},[n]);const[P,fe]=e.useState(c),[L,Ue]=e.useState(r),[x,ge]=e.useState(w),[J,X]=e.useState(p??null);e.useEffect(()=>{p&&X(p)},[p]);const Z=e.useCallback(()=>X(null),[]),ee=e.useCallback(l=>{S(l),b("view")||a("view",l),y?.(l)},[y,a,b]),te=e.useCallback((l,C)=>{m(l),h?.(l,C??O)},[h,O]),ne=e.useMemo(()=>{let l=U;if(P.length>0&&(l=l.filter(C=>C.scheduleTypeId!==void 0&&P.includes(C.scheduleTypeId))),L.length>0&&(l=l.filter(C=>C.participants?.length?C.participants.some(I=>L.includes(I.id)):!1)),k!=="all"&&(l=l.filter(C=>C.participants?.some(I=>I.id===k))),x.trim()){const C=x.toLowerCase();l=l.filter(I=>V.reactNodeToText(I.title).toLowerCase().includes(C)||V.reactNodeToText(I.description).toLowerCase().includes(C)||V.reactNodeToText(I.scheduleTypeName).toLowerCase().includes(C)||I.participants?.some(De=>De.name.toLowerCase().includes(C)))}return l},[U,P,L,k,x]),Se=e.useMemo(()=>({view:O,setView:ee,selectedDate:D,setSelectedDate:te,selectedUserId:k,setSelectedUserId:v,badgeVariant:T,setBadgeVariant:j,workingHours:K,setWorkingHours:G,visibleHours:_,setVisibleHours:Y,showWorkingHoursOnly:$,setShowWorkingHoursOnly:q,slotDuration:z,setSlotDuration:B,isPreferenceLocked:b,events:U,setEvents:Q,users:t,scheduleTypes:o,selectedScheduleTypeIds:P,setSelectedScheduleTypeIds:fe,searchQuery:x,setSearchQuery:ge,filteredEvents:ne,focusEventId:J,clearFocusEventId:Z}),[O,ee,D,te,k,T,j,K,G,_,Y,$,q,z,B,b,U,t,o,P,x,ne,J,Z]);return F.jsx(N.Provider,{value:Se,children:s})}function W(){const s=e.useContext(N);if(!s)throw new Error("useInnoCalendar must be used within an InnoCalendarProvider");return s}function Ie(){return e.useContext(N)}function he(){const{view:s,setView:n,selectedDate:t,setSelectedDate:o,slotDuration:d}=W();return{view:s,setView:n,selectedDate:t,setSelectedDate:o,slotDuration:d}}function Oe(){const{events:s,setEvents:n,filteredEvents:t}=W();return{events:s,setEvents:n,filteredEvents:t}}function ve(){const{selectedScheduleTypeIds:s,setSelectedScheduleTypeIds:n,selectedUserId:t,setSelectedUserId:o,searchQuery:d,setSearchQuery:i}=W();return{selectedScheduleTypeIds:s,setSelectedScheduleTypeIds:n,selectedUserId:t,setSelectedUserId:o,searchQuery:d,setSearchQuery:i}}function Te(){const{workingHours:s,setWorkingHours:n,visibleHours:t,setVisibleHours:o,showWorkingHoursOnly:d,setShowWorkingHoursOnly:i}=W();return{workingHours:s,setWorkingHours:n,visibleHours:t,setVisibleHours:o,showWorkingHoursOnly:d,setShowWorkingHoursOnly:i}}const A=e.createContext(void 0);function R(s){const n=new Date(s.date);return typeof s.hour=="number"&&n.setHours(s.hour,s.minute??0,0,0),n}function Ee(s){const n=new Date(s),t=n.getMinutes(),o=Math.floor(t/30)*30;return n.setMinutes(o,0,0),n}function Pe(s,n){return s.getFullYear()===n.getFullYear()&&s.getMonth()===n.getMonth()&&s.getDate()===n.getDate()}function oe(s,n,t,o,d=30){const i=R(s),f=R(n);let c=i,r=f;if(f<i&&(c=f,r=i),t==="day")if(Pe(c,r)){const w=Ee(new Date);c=new Date(c),c.setHours(w.getHours(),w.getMinutes(),0,0),r=new Date(c.getTime()+o*60*1e3)}else c.setHours(0,0,0,0),r.setHours(23,59,59,999);else{const g=d*60*1e3;r=new Date(r.getTime()+g);const w=r.getTime()-c.getTime(),u=o*60*1e3;w<u&&(r=new Date(c.getTime()+u))}return{startDate:c,endDate:r}}function xe(s,n,t,o){const d=R(s),i=R(n),f=R(t),c=i<=f?i:f,r=i<=f?f:i;if(o==="day"){const g=new Date(d);g.setHours(0,0,0,0);const w=new Date(c);w.setHours(0,0,0,0);const u=new Date(r);return u.setHours(0,0,0,0),g>=w&&g<=u}return d>=c&&d<=r}function Re({children:s,mode:n="time",onSelect:t,minDurationMinutes:o=30,slotDurationMinutes:d=30,enabled:i=!0}){const[f,c]=e.useState(null),r=e.useRef(!1),g=e.useCallback(a=>{i&&(r.current=!0,c({start:a,end:a,isSelecting:!0}))},[i]),w=e.useCallback(a=>{i&&r.current&&c(b=>b?{...b,end:a}:null)},[i]),u=e.useCallback(()=>{r.current&&(r.current=!1,c(a=>{if(!a)return null;const b=oe(a.start,a.end,n,o,d);return t?.(b),{...a,isSelecting:!1}}),setTimeout(()=>{c(null)},100))},[n,o,d,t]),p=e.useCallback(()=>{r.current=!1,c(null)},[]),h=e.useCallback(a=>f?xe(a,f.start,f.end,n):!1,[f,n]),y=e.useCallback(()=>f?oe(f.start,f.end,n,o,d):null,[f,n,o,d]),H=e.useMemo(()=>({isSelecting:f?.isSelecting??!1,startSelection:g,updateSelection:w,endSelection:u,cancelSelection:p,isSlotSelected:h,getSelectionResult:y,mode:n}),[f?.isSelecting,g,w,u,p,h,y,n]);return F.jsx(A.Provider,{value:H,children:s})}function We(){const s=e.useContext(A);if(!s)throw new Error("useSlotSelectionContext must be used within a SlotSelectionProvider");return s}function _e(){return e.useContext(A)}exports.DEFAULT_SLOT_DURATION=ue;exports.DEFAULT_VISIBLE_HOURS=ae;exports.DEFAULT_WORKING_HOURS=le;exports.DragDropProvider=we;exports.InnoCalendarProvider=ye;exports.PREFERENCES_STORAGE_KEY=re;exports.SlotSelectionProvider=Re;exports.useCalendarPreferences=ie;exports.useDragDrop=be;exports.useInnoCalendar=W;exports.useInnoCalendarEvents=Oe;exports.useInnoCalendarFilters=ve;exports.useInnoCalendarTimeConfig=Te;exports.useInnoCalendarView=he;exports.useOptionalDragDrop=ke;exports.useOptionalInnoCalendar=Ie;exports.useOptionalSlotSelection=_e;exports.useSlotSelectionContext=We;
|
|
2
|
-
//# sourceMappingURL=slot-selection-context-CS1te8uo.cjs.map
|