@innosolutions/inno-calendar 1.0.70 → 1.0.71

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