@baishuyun/ui-mobile 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +2 -11
  2. package/dist/ActionSheet/ActionSheet-Ok-UTVMn.js +133 -0
  3. package/dist/ActionSheet/index.js +5 -0
  4. package/dist/Calendar/Calendar-ipjycVqK.js +1580 -0
  5. package/dist/Calendar/index.js +4 -3
  6. package/dist/Calendar/timeUtils-CPYfw0pt.js +27 -0
  7. package/dist/ConfigProvider/ConfigProvider-CNhaKMJa.js +181 -0
  8. package/dist/ConfigProvider/index.js +3 -3
  9. package/dist/Gantt/Gantt-DDItjDkR.js +1099 -0
  10. package/dist/Gantt/index.js +7 -3
  11. package/dist/Icon/Icon-CFvcrGGg.js +23 -0
  12. package/dist/Icon/index.js +3 -0
  13. package/dist/components/ActionSheet/ActionSheet.d.ts +3 -0
  14. package/dist/components/ActionSheet/index.d.ts +2 -0
  15. package/dist/components/ActionSheet/interface.d.ts +75 -0
  16. package/dist/components/Calendar/index.d.ts +1 -1
  17. package/dist/components/Calendar/interface.d.ts +59 -1
  18. package/dist/components/ConfigProvider/context.d.ts +4 -0
  19. package/dist/components/Gantt/Gantt.d.ts +1 -1
  20. package/dist/components/Gantt/GanttBar.d.ts +10 -0
  21. package/dist/components/Gantt/GanttHeader.d.ts +2 -0
  22. package/dist/components/Gantt/GanttTimeLine.d.ts +9 -0
  23. package/dist/components/Gantt/HeaderToolbar.d.ts +6 -0
  24. package/dist/components/Gantt/OffscreenIndicatorArrow.d.ts +8 -0
  25. package/dist/components/Gantt/OffscreenIndicatorOverlay.d.ts +14 -0
  26. package/dist/components/Gantt/StickyLabel.d.ts +10 -0
  27. package/dist/components/Gantt/TodayIndicator.d.ts +14 -0
  28. package/dist/components/Gantt/calcTodayLeft.d.ts +8 -0
  29. package/dist/components/Gantt/context.d.ts +27 -0
  30. package/dist/components/Gantt/hooks/useGanttScroll.d.ts +23 -0
  31. package/dist/components/Gantt/hooks/useGanttViewport.d.ts +20 -0
  32. package/dist/components/Gantt/hooks/useTodayTracker.d.ts +7 -0
  33. package/dist/components/Gantt/index.d.ts +2 -1
  34. package/dist/components/Gantt/interface.d.ts +27 -2
  35. package/dist/components/Gantt/msUntilNextDay.d.ts +2 -0
  36. package/dist/components/Gantt/utils/color.d.ts +2 -0
  37. package/dist/components/Gantt/utils/cx.d.ts +1 -0
  38. package/dist/components/Gantt/utils/dateRangeNormalizer.d.ts +25 -0
  39. package/dist/components/Gantt/utils/dayScale.d.ts +30 -0
  40. package/dist/components/Gantt/utils/headerTimeUtils.d.ts +43 -0
  41. package/dist/components/Gantt/utils/layoutBars.d.ts +26 -0
  42. package/dist/components/Gantt/utils/time.d.ts +4 -0
  43. package/dist/components/Gantt/utils/viewportDateUtils.d.ts +11 -0
  44. package/dist/components/Gantt/utils/zoomReanchor.d.ts +18 -0
  45. package/dist/components/Icon/Icon.d.ts +6 -0
  46. package/dist/components/Icon/index.d.ts +2 -0
  47. package/dist/components/Icon/interface.d.ts +19 -0
  48. package/dist/components/Icon/loadIconfont.d.ts +1 -0
  49. package/dist/components/index.d.ts +7 -2
  50. package/dist/index.js +9 -6
  51. package/dist/locale/index.d.ts +3 -0
  52. package/dist/locale/lang/en-US.json.d.ts +41 -0
  53. package/dist/locale/lang/zh-CN.json.d.ts +41 -0
  54. package/dist/locale/lang/zh-TW.json.d.ts +41 -0
  55. package/dist/style.css +1 -1
  56. package/dist/vendors/useLocale-CMHIlzlj.js +98 -0
  57. package/dist/vendors/{version-v6TU1ff1.js → version-3D9AaDf3.js} +1 -1
  58. package/dist/vite-env.d.ts +1 -0
  59. package/package.json +6 -1
  60. package/dist/Calendar/Calendar-C63wg0aw.js +0 -1601
  61. package/dist/ConfigProvider/ConfigProvider-E792q6ny.js +0 -99
  62. package/dist/Gantt/Gantt-DLmqZPAQ.js +0 -8
  63. package/dist/vendors/useLocale-BbUDQCzl.js +0 -57
@@ -1,1601 +0,0 @@
1
- import { t as e } from "../vendors/useLocale-BbUDQCzl.js";
2
- import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
- import r, { createContext as i, forwardRef as a, useCallback as o, useContext as s, useEffect as c, useLayoutEffect as l, useMemo as u, useRef as d, useState as f } from "react";
4
- import { useControllableValue as p, useLatest as m, useSize as h } from "ahooks";
5
- import g from "dayjs";
6
- import _ from "dayjs/plugin/isoWeek";
7
- import v from "dayjs/plugin/timezone";
8
- import y from "dayjs/plugin/utc";
9
- //#region src/components/Calendar/Calendar.module.scss
10
- var b = {
11
- "bsy-mobile-calendar": "_bsy-mobile-calendar_12jhk_1",
12
- "bsy-mobile-calendar__body": "_bsy-mobile-calendar__body_12jhk_15"
13
- }, x = !1;
14
- x ||= (g.extend(y), g.extend(v), g.extend(_), !0);
15
- //#endregion
16
- //#region src/components/Calendar/utils/timeUtils.ts
17
- var S = () => g(null), C = (e, t) => !!(t && e.$x?.$timezone === t), w = (e, t) => {
18
- if (e == null || e === "") return S();
19
- if (g.isDayjs(e)) return e.isValid() ? !t || C(e, t) ? e : e.tz(t) : S();
20
- if (typeof e == "number" || e instanceof Date) {
21
- let n = g(e);
22
- return n.isValid() ? t ? n.tz(t) : n : S();
23
- }
24
- if (typeof e == "string") {
25
- let n = g(e);
26
- return n.isValid() ? t ? n.tz(t) : n : S();
27
- }
28
- return S();
29
- }, T = (e) => e ? g().tz(e) : g(), E = (e) => {
30
- let t = e ? g().tz(e).utcOffset() : g().utcOffset(), n = t >= 0 ? "+" : "-", r = Math.abs(t), i = Math.floor(r / 60), a = r % 60;
31
- return a === 0 ? `GMT${n}${i}` : `GMT${n}${i}:${String(a).padStart(2, "0")}`;
32
- }, D = i(null), O = ({ children: n, currentDate: r, setCurrentDate: i, viewMode: a, setViewMode: s, scheduleColor: c, timeZone: l, events: d, onEventClick: f, onDayClick: p }) => {
33
- let { t: m } = e(), h = u(() => E(l), [l]), _ = o(() => {
34
- let e = T(l);
35
- g(r).isSame(e, "day") || i(e.toDate());
36
- }, [
37
- r,
38
- i,
39
- l
40
- ]), v = u(() => m("calendar.yearMonth", {
41
- year: r.getFullYear(),
42
- monthShort: m(`calendar.monthShort.${r.getMonth() + 1}`)
43
- }), [r, m]), y = u(() => ({
44
- currentDate: r,
45
- setCurrentDate: i,
46
- goToToday: _,
47
- viewMode: a,
48
- setViewMode: s,
49
- yearMonthText: v,
50
- scheduleColor: c,
51
- timeZone: l,
52
- timezoneLabel: h,
53
- events: d,
54
- onEventClick: f,
55
- onDayClick: p
56
- }), [
57
- r,
58
- i,
59
- _,
60
- a,
61
- s,
62
- v,
63
- c,
64
- l,
65
- h,
66
- d,
67
- f,
68
- p
69
- ]);
70
- return /* @__PURE__ */ t(D.Provider, {
71
- value: y,
72
- children: n
73
- });
74
- }, k = () => {
75
- let e = s(D);
76
- if (!e) throw Error("useCalendarContext must be used within a CalendarProvider");
77
- return e;
78
- }, A = (...e) => e.filter(Boolean).join(" "), j = {
79
- "bsy-mobile-calendar-header": "_bsy-mobile-calendar-header_r7swj_1",
80
- "bsy-mobile-calendar-header__left": "_bsy-mobile-calendar-header__left_r7swj_12",
81
- "bsy-mobile-calendar-header__year-month": "_bsy-mobile-calendar-header__year-month_r7swj_18",
82
- "bsy-mobile-calendar-header__today": "_bsy-mobile-calendar-header__today_r7swj_23",
83
- "bsy-mobile-calendar-segmented": "_bsy-mobile-calendar-segmented_r7swj_33",
84
- "bsy-mobile-calendar-segmented__item": "_bsy-mobile-calendar-segmented__item_r7swj_39",
85
- "bsy-mobile-calendar-segmented__item--active": "_bsy-mobile-calendar-segmented__item--active_r7swj_50"
86
- }, ee = [
87
- {
88
- key: "calendar.viewDay",
89
- value: "day"
90
- },
91
- {
92
- key: "calendar.viewThreeDay",
93
- value: "threeDay"
94
- },
95
- {
96
- key: "calendar.viewMonth",
97
- value: "month"
98
- }
99
- ], te = () => {
100
- let { yearMonthText: r, goToToday: i, viewMode: a, setViewMode: o } = k(), { t: s } = e();
101
- return /* @__PURE__ */ n("div", {
102
- className: j["bsy-mobile-calendar-header"],
103
- children: [/* @__PURE__ */ n("div", {
104
- className: j["bsy-mobile-calendar-header__left"],
105
- children: [/* @__PURE__ */ t("span", {
106
- className: j["bsy-mobile-calendar-header__year-month"],
107
- children: r
108
- }), /* @__PURE__ */ t("button", {
109
- className: j["bsy-mobile-calendar-header__today"],
110
- onClick: i,
111
- type: "button",
112
- children: s("calendar.today")
113
- })]
114
- }), /* @__PURE__ */ t("div", {
115
- className: j["bsy-mobile-calendar-segmented"],
116
- role: "tablist",
117
- children: ee.map((e) => /* @__PURE__ */ t("button", {
118
- type: "button",
119
- role: "tab",
120
- "aria-selected": a === e.value,
121
- className: A(j["bsy-mobile-calendar-segmented__item"], a === e.value && j["bsy-mobile-calendar-segmented__item--active"]),
122
- onClick: () => o(e.value),
123
- children: s(e.key)
124
- }, e.value))
125
- })]
126
- });
127
- }, M = "0.4s", N = "cubic-bezier(0.25, 0.8, 0.25, 1)", P = 26, ne = {
128
- HEADER_HEIGHT: 24,
129
- SLOT_HEIGHT: 22,
130
- SLOT_GAP: 4,
131
- WEEK_PADDING_X: 10
132
- }, F = [
133
- 1,
134
- 2,
135
- 3,
136
- 4,
137
- 5,
138
- 6,
139
- 7
140
- ], I = {
141
- "bsy-mobile-calendar-month": "_bsy-mobile-calendar-month_lsyxr_1",
142
- "bsy-mobile-calendar-weekday-header": "_bsy-mobile-calendar-weekday-header_lsyxr_7",
143
- "bsy-mobile-calendar-weekday-header__item": "_bsy-mobile-calendar-weekday-header__item_lsyxr_13",
144
- "bsy-mobile-calendar-carousel": "_bsy-mobile-calendar-carousel_lsyxr_21",
145
- "bsy-mobile-calendar-month-slide": "_bsy-mobile-calendar-month-slide_lsyxr_28",
146
- "bsy-mobile-calendar-week-row": "_bsy-mobile-calendar-week-row_lsyxr_35",
147
- "bsy-mobile-calendar-week-row__cells": "_bsy-mobile-calendar-week-row__cells_lsyxr_40",
148
- "bsy-mobile-calendar-day-cell": "_bsy-mobile-calendar-day-cell_lsyxr_45",
149
- "bsy-mobile-calendar-day-cell__header": "_bsy-mobile-calendar-day-cell__header_lsyxr_51",
150
- "bsy-mobile-calendar-day-cell__body": "_bsy-mobile-calendar-day-cell__body_lsyxr_59",
151
- "bsy-mobile-calendar-day-cell__text": "_bsy-mobile-calendar-day-cell__text_lsyxr_63",
152
- "bsy-mobile-calendar-day-cell__text--today": "_bsy-mobile-calendar-day-cell__text--today_lsyxr_72",
153
- "bsy-mobile-calendar-day-cell__text--other": "_bsy-mobile-calendar-day-cell__text--other_lsyxr_78",
154
- "bsy-mobile-calendar-day-cell__badge": "_bsy-mobile-calendar-day-cell__badge_lsyxr_81",
155
- "bsy-mobile-calendar-week-events": "_bsy-mobile-calendar-week-events_lsyxr_97",
156
- "bsy-mobile-calendar-week-events__segment": "_bsy-mobile-calendar-week-events__segment_lsyxr_108"
157
- }, re = () => {
158
- let { t: n } = e();
159
- return /* @__PURE__ */ t("div", {
160
- className: I["bsy-mobile-calendar-weekday-header"],
161
- children: F.map((e) => /* @__PURE__ */ t("div", {
162
- className: I["bsy-mobile-calendar-weekday-header__item"],
163
- children: n(`calendar.weekday.${e}`)
164
- }, e))
165
- });
166
- }, ie = a(function({ date: e, isCurrentMonth: r, isToday: i, hiddenCount: a = 0 }, o) {
167
- return /* @__PURE__ */ n("div", {
168
- ref: o,
169
- className: I["bsy-mobile-calendar-day-cell"],
170
- children: [/* @__PURE__ */ n("div", {
171
- className: I["bsy-mobile-calendar-day-cell__header"],
172
- children: [/* @__PURE__ */ t("div", {
173
- className: A(I["bsy-mobile-calendar-day-cell__text"], !r && I["bsy-mobile-calendar-day-cell__text--other"], i && I["bsy-mobile-calendar-day-cell__text--today"]),
174
- children: e.date()
175
- }), a > 0 ? /* @__PURE__ */ n("div", {
176
- className: I["bsy-mobile-calendar-day-cell__badge"],
177
- children: ["+", a]
178
- }) : null]
179
- }), /* @__PURE__ */ t("div", { className: I["bsy-mobile-calendar-day-cell__body"] })]
180
- });
181
- }), L = {
182
- "bsy-mobile-calendar-event-card": "_bsy-mobile-calendar-event-card_r9n00_1",
183
- "bsy-mobile-calendar-event-card--timed": "_bsy-mobile-calendar-event-card--timed_r9n00_17",
184
- "bsy-mobile-calendar-event-card--start": "_bsy-mobile-calendar-event-card--start_r9n00_30",
185
- "bsy-mobile-calendar-event-card--end": "_bsy-mobile-calendar-event-card--end_r9n00_34",
186
- "bsy-mobile-calendar-event-card--continue": "_bsy-mobile-calendar-event-card--continue_r9n00_38",
187
- "bsy-mobile-calendar-event-card__timed-body": "_bsy-mobile-calendar-event-card__timed-body_r9n00_42",
188
- "bsy-mobile-calendar-event-card__title": "_bsy-mobile-calendar-event-card__title_r9n00_46",
189
- "bsy-mobile-calendar-event-card__time": "_bsy-mobile-calendar-event-card__time_r9n00_42"
190
- }, R = r.memo(({ label: e, showLabel: r = !0, isStart: i = !0, isEnd: a = !0, isContinue: o = !1, height: s = 22, style: c, className: l, onClick: u, variant: d = "allDay", timeText: f }) => /* @__PURE__ */ t("div", {
191
- className: A(L["bsy-mobile-calendar-event-card"], d === "timed" && L["bsy-mobile-calendar-event-card--timed"], i && L["bsy-mobile-calendar-event-card--start"], a && L["bsy-mobile-calendar-event-card--end"], o && L["bsy-mobile-calendar-event-card--continue"], l),
192
- style: {
193
- height: s,
194
- lineHeight: d === "timed" ? "normal" : `${s}px`,
195
- ...c
196
- },
197
- onClick: u ? (e) => {
198
- e.stopPropagation(), u();
199
- } : void 0,
200
- role: u ? "button" : void 0,
201
- children: r ? d === "timed" ? /* @__PURE__ */ n("div", {
202
- className: L["bsy-mobile-calendar-event-card__timed-body"],
203
- children: [/* @__PURE__ */ t("div", {
204
- className: L["bsy-mobile-calendar-event-card__title"],
205
- children: e
206
- }), !!f && /* @__PURE__ */ t("div", {
207
- className: L["bsy-mobile-calendar-event-card__time"],
208
- children: f
209
- })]
210
- }) : e : null
211
- }));
212
- //#endregion
213
- //#region src/components/Calendar/utils/monthLayoutAlgorithm.ts
214
- function ae(e) {
215
- let { startCol: t, endCol: n, row: r } = e, { HEADER_HEIGHT: i, SLOT_HEIGHT: a, SLOT_GAP: o, WEEK_PADDING_X: s } = ne, c = 100 / 7, l = s;
216
- return {
217
- top: i + r * (a + o),
218
- height: a,
219
- left: `calc(${t * c}% + ${l}px)`,
220
- width: `calc(${(n - t) * c}% - ${l}px)`
221
- };
222
- }
223
- function z(e, t, n) {
224
- let r = g(e.startTime), i = g(e.endTime), a = t.add(n, "day"), o = r.isBefore(t) ? t : r, s = i.isAfter(a) ? a : i, c = o.diff(t, "day"), l = r.startOf("day").diff(t.startOf("day"), "day"), u = s.hour() === 0 && s.minute() === 0 && s.second() === 0 ? s.diff(t, "day") : s.diff(t, "day") + 1;
225
- return o.valueOf() === s.valueOf() && c >= 0 && c < n && (u = Math.min(c + 1, n)), {
226
- event: e,
227
- startDayIndex: c,
228
- endDayIndex: u,
229
- span: u - c,
230
- originalStartDayIndex: l
231
- };
232
- }
233
- function oe(e, t, n) {
234
- if (!e || e.length === 0) return /* @__PURE__ */ new Map();
235
- let r = e.map((e) => z(e, t, n));
236
- r.sort((e, t) => e.startDayIndex === t.startDayIndex ? t.span - e.span : e.startDayIndex - t.startDayIndex);
237
- let i = /* @__PURE__ */ new Map(), a = [];
238
- for (let e of r) {
239
- let { event: t, startDayIndex: n, endDayIndex: r } = e, o = -1;
240
- for (let e = 0; e <= a.length; e += 1) {
241
- a[e] || (a[e] = []);
242
- let t = !0;
243
- for (let i = n; i < r; i += 1) if (a[e][i]) {
244
- t = !1;
245
- break;
246
- }
247
- if (t) {
248
- o = e;
249
- break;
250
- }
251
- }
252
- a[o] || (a[o] = []);
253
- for (let e = n; e < r; e += 1) a[o][e] = t.id;
254
- i.set(t.id, o);
255
- }
256
- return i;
257
- }
258
- function se(e, t) {
259
- let { event: n, startDayIndex: r, endDayIndex: i, originalStartDayIndex: a } = e, o = [], s = r;
260
- for (; s < i;) {
261
- let e = Math.floor(s / 7), r = (e + 1) * 7, c = Math.min(i, r), l = s % 7;
262
- o.push({
263
- event: n,
264
- weekIndex: e,
265
- startCol: l,
266
- endCol: c - e * 7,
267
- row: t,
268
- isStart: s === a,
269
- isEnd: c === i,
270
- isWeekStart: l === 0
271
- }), s = c;
272
- }
273
- return o;
274
- }
275
- function ce(e, t, n, r, i) {
276
- let a = /* @__PURE__ */ new Set();
277
- if (!t || t.length === 0) return a;
278
- let o = t.map((e) => z(e, n, r)), s = Array.from({ length: r }, () => []);
279
- for (let e of o) for (let t = e.startDayIndex; t < e.endDayIndex; t += 1) s[t].push(e);
280
- for (let t = 0; t < r; t += 1) {
281
- let n = s[t].filter((e) => !a.has(e.event.id));
282
- for (let t of n) (e.get(t.event.id) ?? 0) >= i && a.add(t.event.id);
283
- }
284
- return a;
285
- }
286
- function le(e, t, n = 6) {
287
- let r = n * 7;
288
- if (!e || e.length === 0) return {
289
- weekLayouts: Array.from({ length: n }, () => []),
290
- eventRowMap: /* @__PURE__ */ new Map(),
291
- gridEvents: []
292
- };
293
- let i = oe(e, t, r), a = e.map((e) => z(e, t, r)), o = Array.from({ length: n }, () => []);
294
- for (let e of a) {
295
- let t = se(e, i.get(e.event.id) ?? 0);
296
- for (let e of t) o[e.weekIndex].push(e);
297
- }
298
- return {
299
- weekLayouts: o,
300
- eventRowMap: i,
301
- gridEvents: a
302
- };
303
- }
304
- function ue(e, t, n) {
305
- let r = Array(7).fill(0), i = Array.from({ length: 7 }, () => /* @__PURE__ */ new Set());
306
- for (let a of e) {
307
- let e = a.event.id;
308
- if (t.has(e) || a.row >= n) for (let t = a.startCol; t < a.endCol; t += 1) i[t].has(e) || (i[t].add(e), r[t] += 1);
309
- }
310
- return r;
311
- }
312
- var de = r.memo(({ segments: e, hiddenScheduleIds: n, maxVisibleRows: r }) => {
313
- let { onEventClick: i } = k(), a = e.filter((e) => !n.has(e.event.id) && e.row < r);
314
- return /* @__PURE__ */ t("div", {
315
- className: I["bsy-mobile-calendar-week-events"],
316
- children: a.map((e) => {
317
- let n = ae(e), { event: r, isStart: a, isEnd: o, isWeekStart: s } = e, c = a || s;
318
- return /* @__PURE__ */ t(R, {
319
- className: I["bsy-mobile-calendar-week-events__segment"],
320
- label: r.label,
321
- showLabel: c,
322
- isStart: a,
323
- isEnd: o,
324
- isContinue: !a && s,
325
- height: n.height,
326
- style: {
327
- top: n.top,
328
- left: n.left,
329
- width: n.width
330
- },
331
- onClick: () => i?.(r)
332
- }, `${r.id}-${e.weekIndex}-${e.startCol}`);
333
- })
334
- });
335
- });
336
- //#endregion
337
- //#region src/components/Calendar/utils/dateUtils.ts
338
- function fe(e) {
339
- let t = g(e).startOf("isoWeek");
340
- return Array.from({ length: 7 }, (e, n) => t.add(n, "day"));
341
- }
342
- function pe(e) {
343
- let t = e.startOf("month"), n = t.isoWeekday() - 1, r = t.subtract(n, "day"), i = [];
344
- for (let e = 0; e < 42; e += 1) i.push(r.add(e, "day"));
345
- return i;
346
- }
347
- function me(e) {
348
- let t = [];
349
- for (let n = 0; n < e.length; n += 7) t.push(e.slice(n, n + 7));
350
- return t;
351
- }
352
- function B(e, t) {
353
- return e.isSame(T(t), "day");
354
- }
355
- function he(e, t) {
356
- return e.isSame(t, "month");
357
- }
358
- function V(e) {
359
- return g(e.startTime).format("YYYY-MM-DD") !== g(e.endTime).format("YYYY-MM-DD");
360
- }
361
- function ge(e, t) {
362
- let n = t.startOf("day"), r = g(e.startTime).startOf("day"), i = g(e.endTime).startOf("day");
363
- return !n.isBefore(r) && !n.isAfter(i);
364
- }
365
- function _e(e, t) {
366
- let n = t.startOf("day");
367
- return e.filter((e) => {
368
- let t = g(e.startTime), r = g(e.endTime), i = t.startOf("day"), a = r.hour() === 0 && r.minute() === 0 && r.second() === 0, o = t.valueOf() === r.valueOf(), s = r.startOf("day");
369
- return a && !o && (s = r.subtract(1, "day").startOf("day")), !n.isBefore(i) && !n.isAfter(s);
370
- });
371
- }
372
- //#endregion
373
- //#region src/components/Calendar/CalendarMonth/WeekRow/WeekRow.tsx
374
- var ve = ({ dates: e, monthDate: r, segments: i, hiddenCounts: a, hiddenScheduleIds: o, maxVisibleRows: s, cellRef: c, onDayClick: l }) => {
375
- let { timeZone: u } = k();
376
- return /* @__PURE__ */ n("div", {
377
- className: I["bsy-mobile-calendar-week-row"],
378
- onClick: (t) => {
379
- if (!l) return;
380
- let n = t.currentTarget.getBoundingClientRect(), r = t.clientX - n.left, i = n.width / 7, a = Math.floor(r / i);
381
- a >= 0 && a < e.length && l(e[a]);
382
- },
383
- children: [/* @__PURE__ */ t("div", {
384
- className: I["bsy-mobile-calendar-week-row__cells"],
385
- children: e.map((e, n) => /* @__PURE__ */ t(ie, {
386
- ref: n === 0 ? c : void 0,
387
- date: e,
388
- isCurrentMonth: he(e, r),
389
- isToday: B(e, u),
390
- hiddenCount: a[n] || 0
391
- }, e.format("YYYY-MM-DD")))
392
- }), /* @__PURE__ */ t(de, {
393
- segments: i,
394
- hiddenScheduleIds: o,
395
- maxVisibleRows: s
396
- })]
397
- });
398
- };
399
- //#endregion
400
- //#region src/components/Calendar/hooks/useMonthDates.ts
401
- function ye(e) {
402
- return { weeks: u(() => me(pe(e)), [e.format("YYYY-MM")]) };
403
- }
404
- //#endregion
405
- //#region src/components/Calendar/hooks/useCellHeight.ts
406
- var { HEADER_HEIGHT: be, SLOT_HEIGHT: xe, SLOT_GAP: Se } = ne;
407
- function Ce() {
408
- let e = d(null), [t, n] = f(2);
409
- return c(() => {
410
- let t = e.current;
411
- if (!t) return;
412
- let r = (e) => {
413
- let t = e - be;
414
- return Math.max(1, Math.floor(t / (xe + Se)));
415
- }, i = new ResizeObserver((e) => {
416
- requestAnimationFrame(() => {
417
- let t = e[0]?.contentRect.height;
418
- t && n(r(t));
419
- });
420
- });
421
- i.observe(t);
422
- let a = t.getBoundingClientRect().height;
423
- return a > 0 && n(r(a)), () => i.disconnect();
424
- }, []), {
425
- cellRef: e,
426
- maxVisibleRows: t
427
- };
428
- }
429
- //#endregion
430
- //#region src/components/Calendar/hooks/useMonthEventLayout.ts
431
- function we({ events: e, monthDate: t, maxVisibleRows: n }) {
432
- return u(() => {
433
- if (!e || e.length === 0) return {
434
- weekLayouts: Array.from({ length: 6 }, () => []),
435
- hiddenScheduleIds: /* @__PURE__ */ new Set(),
436
- weekHiddenCounts: Array.from({ length: 6 }, () => Array(7).fill(0))
437
- };
438
- let r = pe(t)[0], { weekLayouts: i, eventRowMap: a } = le(e, r, 6), o = ce(a, e, r, 42, n);
439
- return {
440
- weekLayouts: i,
441
- hiddenScheduleIds: o,
442
- weekHiddenCounts: i.map((e) => ue(e, o, n))
443
- };
444
- }, [
445
- e,
446
- t.format("YYYY-MM"),
447
- n
448
- ]);
449
- }
450
- //#endregion
451
- //#region src/components/Calendar/CalendarMonth/MonthSlide/MonthSlide.tsx
452
- var Te = ({ monthDate: e, containerWidth: n, events: r, style: i, onDayClick: a }) => {
453
- let { weeks: o } = ye(e), { cellRef: s, maxVisibleRows: c } = Ce(), { weekLayouts: l, hiddenScheduleIds: u, weekHiddenCounts: d } = we({
454
- events: r,
455
- monthDate: e,
456
- maxVisibleRows: c
457
- });
458
- return /* @__PURE__ */ t("div", {
459
- className: I["bsy-mobile-calendar-month-slide"],
460
- style: {
461
- width: n,
462
- ...i
463
- },
464
- children: o.map((n, r) => /* @__PURE__ */ t(ve, {
465
- dates: n,
466
- monthDate: e,
467
- segments: l[r] || [],
468
- hiddenCounts: d[r] || Array(7).fill(0),
469
- hiddenScheduleIds: u,
470
- maxVisibleRows: c,
471
- cellRef: r === 0 ? s : void 0,
472
- onDayClick: a
473
- }, `week-${r}`))
474
- });
475
- }, Ee = (e) => e.subtract(1, "month"), De = (e) => e.add(1, "month");
476
- function Oe({ currentDate: e, setCurrentDate: t, containerWidth: n }) {
477
- let r = u(() => [
478
- Ee(e),
479
- e,
480
- De(e)
481
- ], [e.format("YYYY-MM")]), [i, a] = f(0), [s, c] = f(!1), l = d({
482
- startX: 0,
483
- startY: 0,
484
- startTime: 0,
485
- isDragging: !1,
486
- isVerticalScroll: !1,
487
- directionLocked: !1
488
- }), p = m(e), h = m(t), g = m(n), _ = m(i), v = o((e) => {
489
- if (l.current.isDragging) return;
490
- let t = e.touches[0];
491
- l.current = {
492
- startX: t.clientX,
493
- startY: t.clientY,
494
- startTime: Date.now(),
495
- isDragging: !0,
496
- isVerticalScroll: !1,
497
- directionLocked: !1
498
- }, c(!1);
499
- }, []), y = o((e) => {
500
- if (!l.current.isDragging) return;
501
- let t = e.touches[0], n = t.clientX - l.current.startX, r = t.clientY - l.current.startY;
502
- if (!l.current.directionLocked && (Math.abs(n) > 10 || Math.abs(r) > 10) && (l.current.directionLocked = !0, Math.abs(r) > Math.abs(n))) {
503
- l.current.isVerticalScroll = !0;
504
- return;
505
- }
506
- l.current.isVerticalScroll || a(n);
507
- }, []), b = o(() => {
508
- if (!l.current.isDragging) return;
509
- let e = g.current ?? 0, t = _.current ?? 0;
510
- if (l.current.isDragging = !1, !e || l.current.isVerticalScroll) return;
511
- let n = Date.now() - l.current.startTime, r = Math.abs(t) / n, i = Math.abs(t) > e * .35 || r > .3;
512
- c(!0), a(i && t !== 0 ? -(t > 0 ? -1 : 1) * e : 0);
513
- }, [g, _]), x = o(() => {
514
- let e = _.current ?? 0, t = p.current, n = h.current;
515
- if (e !== 0 && t && n) {
516
- let r = (e > 0 ? -1 : 1) == 1 ? De(t) : Ee(t);
517
- c(!1), a(0), n(r);
518
- }
519
- }, [
520
- _,
521
- p,
522
- h
523
- ]);
524
- return {
525
- months: r,
526
- translateX: i,
527
- transitionEnabled: s,
528
- bindEvents: u(() => ({
529
- onTouchStart: v,
530
- onTouchMove: y,
531
- onTouchEnd: b,
532
- onTouchCancel: b
533
- }), [
534
- v,
535
- y,
536
- b
537
- ]),
538
- handleTransitionEnd: x
539
- };
540
- }
541
- //#endregion
542
- //#region src/components/Calendar/CalendarMonth/MonthCarousel/MonthCarousel.tsx
543
- var ke = ({ currentDate: e, setCurrentDate: n, containerWidth: r, events: i }) => {
544
- let { onDayClick: a } = k(), { months: o, translateX: s, transitionEnabled: c, bindEvents: l, handleTransitionEnd: u } = Oe({
545
- currentDate: e,
546
- setCurrentDate: n,
547
- containerWidth: r
548
- }), d = (e) => {
549
- let t = _e(i, e);
550
- a?.(e.toDate(), t);
551
- };
552
- return r ? /* @__PURE__ */ t("div", {
553
- className: I["bsy-mobile-calendar-carousel"],
554
- ...l,
555
- children: /* @__PURE__ */ t("div", {
556
- style: {
557
- width: r * 3,
558
- marginLeft: -r,
559
- height: "100%",
560
- display: "flex",
561
- transform: `translateX(${s}px)`,
562
- transition: c ? "transform 300ms cubic-bezier(0.25, 0.1, 0.25, 1)" : "none",
563
- willChange: "transform"
564
- },
565
- onTransitionEnd: u,
566
- children: o.map((e) => /* @__PURE__ */ t(Te, {
567
- monthDate: e,
568
- containerWidth: r,
569
- events: i,
570
- style: {
571
- width: r,
572
- flexShrink: 0
573
- },
574
- onDayClick: d
575
- }, e.format("YYYY-MM")))
576
- })
577
- }) : null;
578
- }, Ae = () => {
579
- let e = d(null), r = h(e), { currentDate: i, setCurrentDate: a, events: s } = k(), c = u(() => g(i), [i]), l = o((e) => {
580
- a(e.toDate());
581
- }, [a]);
582
- return /* @__PURE__ */ n("div", {
583
- ref: e,
584
- className: I["bsy-mobile-calendar-month"],
585
- children: [/* @__PURE__ */ t(re, {}), /* @__PURE__ */ t(ke, {
586
- currentDate: c,
587
- setCurrentDate: l,
588
- containerWidth: r?.width ?? 0,
589
- events: s
590
- })]
591
- });
592
- }, je = (e) => e.subtract(1, "week"), Me = (e) => e.add(1, "week");
593
- function Ne({ selectedDate: e, setSelectedDate: t, containerWidth: n }) {
594
- let r = u(() => [
595
- je(e),
596
- e,
597
- Me(e)
598
- ], [e.format("YYYY-MM-DD")]), [i, a] = f(0), [s, c] = f(!1), l = d({
599
- startX: 0,
600
- startY: 0,
601
- startTime: 0,
602
- isDragging: !1,
603
- isVerticalScroll: !1,
604
- directionLocked: !1
605
- }), p = m(e), h = m(t), g = m(n), _ = m(i), v = o((e) => {
606
- if (l.current.isDragging) return;
607
- let t = e.touches[0];
608
- l.current = {
609
- startX: t.clientX,
610
- startY: t.clientY,
611
- startTime: Date.now(),
612
- isDragging: !0,
613
- isVerticalScroll: !1,
614
- directionLocked: !1
615
- }, c(!1);
616
- }, []), y = o((e) => {
617
- if (!l.current.isDragging) return;
618
- let t = e.touches[0], n = t.clientX - l.current.startX, r = t.clientY - l.current.startY;
619
- if (!l.current.directionLocked && (Math.abs(n) > 10 || Math.abs(r) > 10) && (l.current.directionLocked = !0, Math.abs(r) > Math.abs(n))) {
620
- l.current.isVerticalScroll = !0;
621
- return;
622
- }
623
- l.current.isVerticalScroll || a(n);
624
- }, []), b = o(() => {
625
- if (!l.current.isDragging) return;
626
- let e = g.current ?? 0, t = _.current ?? 0;
627
- if (l.current.isDragging = !1, !e || l.current.isVerticalScroll) return;
628
- let n = Date.now() - l.current.startTime, r = Math.abs(t) / n, i = Math.abs(t) > e * .35 || r > .3;
629
- c(!0), a(i && t !== 0 ? -(t > 0 ? -1 : 1) * e : 0);
630
- }, [g, _]), x = o(() => {
631
- let e = _.current ?? 0, t = p.current, n = h.current;
632
- if (e !== 0 && t && n) {
633
- let r = (e > 0 ? -1 : 1) == 1 ? Me(t) : je(t);
634
- c(!1), a(0), n(r);
635
- }
636
- }, [
637
- _,
638
- p,
639
- h
640
- ]);
641
- return {
642
- weeks: r,
643
- translateX: i,
644
- transitionEnabled: s,
645
- bindEvents: u(() => ({
646
- onTouchStart: v,
647
- onTouchMove: y,
648
- onTouchEnd: b,
649
- onTouchCancel: b
650
- }), [
651
- v,
652
- y,
653
- b
654
- ]),
655
- handleTransitionEnd: x
656
- };
657
- }
658
- //#endregion
659
- //#region src/components/Calendar/CalendarDay/CalendarDay.module.scss
660
- var H = {
661
- "bsy-mobile-calendar-day": "_bsy-mobile-calendar-day_12vkp_1",
662
- "bsy-mobile-calendar-day__header-wrap": "_bsy-mobile-calendar-day__header-wrap_12vkp_7",
663
- "bsy-mobile-calendar-day__header": "_bsy-mobile-calendar-day__header_12vkp_7",
664
- "bsy-mobile-calendar-day__tz": "_bsy-mobile-calendar-day__tz_12vkp_15",
665
- "bsy-mobile-calendar-day__body": "_bsy-mobile-calendar-day__body_12vkp_25",
666
- "bsy-mobile-calendar-day__time-grid": "_bsy-mobile-calendar-day__time-grid_12vkp_30",
667
- "bsy-mobile-calendar-day__time-col": "_bsy-mobile-calendar-day__time-col_12vkp_34",
668
- "bsy-mobile-calendar-day__time-label": "_bsy-mobile-calendar-day__time-label_12vkp_39",
669
- "bsy-mobile-calendar-day__content-col": "_bsy-mobile-calendar-day__content-col_12vkp_47",
670
- "bsy-mobile-calendar-day__hour-cell": "_bsy-mobile-calendar-day__hour-cell_12vkp_52",
671
- "bsy-mobile-calendar-day__timed-layer": "_bsy-mobile-calendar-day__timed-layer_12vkp_57",
672
- "bsy-mobile-calendar-day__timed-item": "_bsy-mobile-calendar-day__timed-item_12vkp_69",
673
- "bsy-mobile-calendar-week-carousel": "_bsy-mobile-calendar-week-carousel_12vkp_75",
674
- "bsy-mobile-calendar-week-slide": "_bsy-mobile-calendar-week-slide_12vkp_81",
675
- "bsy-mobile-calendar-week-slide__weekdays": "_bsy-mobile-calendar-week-slide__weekdays_12vkp_86",
676
- "bsy-mobile-calendar-week-slide__dates": "_bsy-mobile-calendar-week-slide__dates_12vkp_91",
677
- "bsy-mobile-calendar-week-slide__weekday": "_bsy-mobile-calendar-week-slide__weekday_12vkp_86",
678
- "bsy-mobile-calendar-week-slide__weekday--weekend": "_bsy-mobile-calendar-week-slide__weekday--weekend_12vkp_103",
679
- "bsy-mobile-calendar-week-slide__weekday--today": "_bsy-mobile-calendar-week-slide__weekday--today_12vkp_106",
680
- "bsy-mobile-calendar-week-slide__weekday--future": "_bsy-mobile-calendar-week-slide__weekday--future_12vkp_109",
681
- "bsy-mobile-calendar-week-slide__date-item": "_bsy-mobile-calendar-week-slide__date-item_12vkp_112",
682
- "bsy-mobile-calendar-week-slide__date-circle": "_bsy-mobile-calendar-week-slide__date-circle_12vkp_118",
683
- "bsy-mobile-calendar-week-slide__date-circle--today": "_bsy-mobile-calendar-week-slide__date-circle--today_12vkp_128",
684
- "bsy-mobile-calendar-week-slide__date-circle--today-idle": "_bsy-mobile-calendar-week-slide__date-circle--today-idle_12vkp_132",
685
- "bsy-mobile-calendar-week-slide__date-circle--past": "_bsy-mobile-calendar-week-slide__date-circle--past_12vkp_136",
686
- "bsy-mobile-calendar-week-slide__date-circle--future": "_bsy-mobile-calendar-week-slide__date-circle--future_12vkp_139",
687
- "bsy-mobile-calendar-week-slide__date-circle--selected": "_bsy-mobile-calendar-week-slide__date-circle--selected_12vkp_142",
688
- "bsy-mobile-calendar-now-line": "_bsy-mobile-calendar-now-line_12vkp_146",
689
- "bsy-mobile-calendar-now-dot": "_bsy-mobile-calendar-now-dot_12vkp_156",
690
- "bsy-mobile-calendar-allday": "_bsy-mobile-calendar-allday_12vkp_166",
691
- "bsy-mobile-calendar-allday__content": "_bsy-mobile-calendar-allday__content_12vkp_170",
692
- "bsy-mobile-calendar-allday__list": "_bsy-mobile-calendar-allday__list_12vkp_177",
693
- "bsy-mobile-calendar-allday__expand": "_bsy-mobile-calendar-allday__expand_12vkp_181"
694
- }, Pe = ({ weekDate: r, currentDate: i, containerWidth: a, onDateClick: o }) => {
695
- let { timeZone: s } = k(), { t: c } = e(), l = fe(r.toDate()), u = T(s).startOf("day"), d = l.some((e) => B(e, s)), f = u.day(), p = i.isSame(u, "day");
696
- return /* @__PURE__ */ n("div", {
697
- className: H["bsy-mobile-calendar-week-slide"],
698
- style: { width: a },
699
- children: [/* @__PURE__ */ t("div", {
700
- className: H["bsy-mobile-calendar-week-slide__weekdays"],
701
- children: F.map((e, n) => {
702
- let r = n >= 5, i = n === 6 ? 0 : n + 1, a = l.find((e) => e.day() === i), o = d && i === f, s = a ? a.isAfter(u) : !1;
703
- return /* @__PURE__ */ t("div", {
704
- className: A(H["bsy-mobile-calendar-week-slide__weekday"], r && H["bsy-mobile-calendar-week-slide__weekday--weekend"], o && H["bsy-mobile-calendar-week-slide__weekday--today"], s && H["bsy-mobile-calendar-week-slide__weekday--future"]),
705
- children: c(`calendar.weekday.${e}`)
706
- }, e);
707
- })
708
- }), /* @__PURE__ */ t("div", {
709
- className: H["bsy-mobile-calendar-week-slide__dates"],
710
- children: l.map((e) => {
711
- let n = B(e, s), r = e.isSame(i, "day") && !n, a = e.isBefore(u);
712
- return /* @__PURE__ */ t("div", {
713
- className: H["bsy-mobile-calendar-week-slide__date-item"],
714
- onClick: () => o?.(e),
715
- children: /* @__PURE__ */ t("div", {
716
- className: A(H["bsy-mobile-calendar-week-slide__date-circle"], n && (p ? H["bsy-mobile-calendar-week-slide__date-circle--today"] : H["bsy-mobile-calendar-week-slide__date-circle--today-idle"]), !n && a && H["bsy-mobile-calendar-week-slide__date-circle--past"], !n && !a && H["bsy-mobile-calendar-week-slide__date-circle--future"], r && H["bsy-mobile-calendar-week-slide__date-circle--selected"]),
717
- children: e.date()
718
- })
719
- }, e.format("YYYY-MM-DD"));
720
- })
721
- })]
722
- });
723
- }, Fe = ({ currentDate: e, setCurrentDate: n, containerWidth: r }) => {
724
- let { weeks: i, translateX: a, transitionEnabled: o, bindEvents: s, handleTransitionEnd: c } = Ne({
725
- selectedDate: e,
726
- setSelectedDate: n,
727
- containerWidth: r
728
- });
729
- return r ? /* @__PURE__ */ t("div", {
730
- className: H["bsy-mobile-calendar-week-carousel"],
731
- ...s,
732
- children: /* @__PURE__ */ t("div", {
733
- style: {
734
- width: r * 3,
735
- marginLeft: -r,
736
- height: "100%",
737
- display: "flex",
738
- transform: `translateX(${a}px)`,
739
- transition: o ? "transform 300ms cubic-bezier(0.25, 0.1, 0.25, 1)" : "none",
740
- willChange: "transform"
741
- },
742
- onTransitionEnd: c,
743
- children: i.map((i) => /* @__PURE__ */ t(Pe, {
744
- weekDate: i,
745
- currentDate: e,
746
- containerWidth: r,
747
- onDateClick: n
748
- }, i.format("YYYY-MM-DD")))
749
- })
750
- }) : null;
751
- }, Ie = r.memo(({ events: r, onEventClick: i }) => {
752
- let { t: a } = e(), o = d(null), [s, c] = f(0), [u, p] = f(!1), m = u ? r.length : Math.min(r.length, 3), h = r.slice(0, m), g = r.length - 3, _ = r.length > 3, v = u && r.length > 8;
753
- return l(() => {
754
- o.current && c(r.length > 0 ? o.current.scrollHeight : 0);
755
- }, [r, u]), /* @__PURE__ */ t("div", {
756
- className: H["bsy-mobile-calendar-allday"],
757
- style: { height: s },
758
- children: /* @__PURE__ */ n("div", {
759
- ref: o,
760
- className: H["bsy-mobile-calendar-allday__content"],
761
- children: [/* @__PURE__ */ t("div", {
762
- className: H["bsy-mobile-calendar-allday__list"],
763
- style: v ? {
764
- maxHeight: 204,
765
- overflowY: "auto"
766
- } : void 0,
767
- children: h.map((e) => /* @__PURE__ */ t(R, {
768
- label: e.label,
769
- style: { width: "100%" },
770
- onClick: () => i?.(e)
771
- }, e.id))
772
- }), _ ? /* @__PURE__ */ n("div", {
773
- className: H["bsy-mobile-calendar-allday__expand"],
774
- onClick: () => p((e) => !e),
775
- children: [/* @__PURE__ */ t("span", { children: u ? a("calendar.collapse") : a("calendar.moreRecords", { count: g }) }), /* @__PURE__ */ t("svg", {
776
- width: "16",
777
- height: "16",
778
- viewBox: "0 0 16 16",
779
- fill: "none",
780
- style: {
781
- transform: u ? "rotate(180deg)" : "rotate(0deg)",
782
- transition: "transform 200ms ease"
783
- },
784
- children: /* @__PURE__ */ t("path", {
785
- d: "M4 6L8 10L12 6",
786
- stroke: "#666666",
787
- strokeWidth: "1.5",
788
- strokeLinecap: "round",
789
- strokeLinejoin: "round"
790
- })
791
- })]
792
- }) : null]
793
- })
794
- });
795
- }), Le = ({ currentDate: e, setCurrentDate: r, containerWidth: i, allDayEvents: a, onEventClick: o }) => {
796
- let { timezoneLabel: s } = k();
797
- return /* @__PURE__ */ n("div", {
798
- className: H["bsy-mobile-calendar-day__header-wrap"],
799
- children: [/* @__PURE__ */ n("div", {
800
- className: H["bsy-mobile-calendar-day__header"],
801
- children: [/* @__PURE__ */ t("div", {
802
- className: H["bsy-mobile-calendar-day__tz"],
803
- children: s
804
- }), /* @__PURE__ */ t(Fe, {
805
- currentDate: e,
806
- setCurrentDate: r,
807
- containerWidth: i
808
- })]
809
- }), /* @__PURE__ */ t(Ie, {
810
- events: a,
811
- onEventClick: o
812
- })]
813
- });
814
- }, Re = (e) => g(e.startTime).format("YYYY-MM-DD") !== g(e.endTime).format("YYYY-MM-DD"), U = (e) => {
815
- let t = g(e.startTime), n = g(e.endTime);
816
- return n.diff(t, "minute") < 22 ? t.add(22, "minute") : n;
817
- }, W = (e, t) => {
818
- let n = g(e.startTime), r = U(e), i = g(t.startTime), a = U(t);
819
- return n.isBefore(a) && r.isAfter(i);
820
- }, ze = (e) => {
821
- if (e.length === 0) return [];
822
- let t = [...e].sort((e, t) => g(e.startTime).valueOf() - g(t.startTime).valueOf()), n = [], r = [t[0]], i = U(t[0]);
823
- for (let e = 1; e < t.length; e += 1) {
824
- let a = t[e];
825
- if (g(a.startTime).isBefore(i)) {
826
- r.push(a);
827
- let e = U(a);
828
- e.isAfter(i) && (i = e);
829
- } else n.push(r), r = [a], i = U(a);
830
- }
831
- return n.push(r), n;
832
- }, Be = (e) => {
833
- let t = /* @__PURE__ */ new Map(), n = [], r = [...e].sort((e, t) => g(e.startTime).valueOf() - g(t.startTime).valueOf());
834
- for (let e of r) {
835
- let r = !1;
836
- for (let i = 0; i < n.length; i += 1) if (n[i].every((t) => !W(t, e))) {
837
- n[i].push(e), t.set(e.id, i), r = !0;
838
- break;
839
- }
840
- r || (n.push([e]), t.set(e.id, n.length - 1));
841
- }
842
- return t;
843
- }, Ve = (e, t, n, r, i) => {
844
- let a = n;
845
- for (let n of r) if (n.id !== e.id) {
846
- let r = i.get(n.id) ?? 0;
847
- r > t && W(e, n) && (a = Math.min(a, r));
848
- }
849
- return a - t;
850
- }, He = (e, t) => {
851
- let n = Math.max(...Array.from(t.values())) + 1, r = /* @__PURE__ */ new Map(), i = n > 10;
852
- for (let a of e) {
853
- let o = t.get(a.id) ?? 0;
854
- if (i) {
855
- let e = o * 15;
856
- r.set(a.id, {
857
- left: e,
858
- width: 85,
859
- isPercent: !1
860
- });
861
- } else {
862
- let i = Ve(a, o, n, e, t), s = 100 / n;
863
- r.set(a.id, {
864
- left: o * s,
865
- width: s * i,
866
- isPercent: !0
867
- });
868
- }
869
- }
870
- return r;
871
- }, G = (e, t) => {
872
- let n = e.filter(Re), r = ze(e.filter((e) => !Re(e))), i = [];
873
- for (let e of r) {
874
- let n = Be(e), r = He(e, n), a = Math.max(...Array.from(n.values())) + 1;
875
- for (let o of e) {
876
- let e = g(o.startTime), s = g(o.endTime), c = e.hour() * 60 + e.minute(), l = s.hour() * 60 + s.minute(), u = Math.max(l - c, 22), d = c / t.interval * t.rowHeight, f = u / t.interval * t.rowHeight, p = r.get(o.id);
877
- i.push({
878
- event: o,
879
- top: d,
880
- height: f,
881
- left: p.left,
882
- width: p.width,
883
- isPercent: p.isPercent,
884
- column: n.get(o.id) ?? 0,
885
- totalColumns: a
886
- });
887
- }
888
- }
889
- return {
890
- timedEvents: i,
891
- allDayEvents: n
892
- };
893
- }, K = Array.from({ length: 24 }, (e, t) => `${t.toString().padStart(2, "0")}:00`), Ue = {
894
- interval: 60,
895
- rowHeight: 60
896
- }, We = (e) => {
897
- let t = g(e.startTime), n = g(e.endTime);
898
- return `${t.format("HH:mm")}-${n.format("HH:mm")}`;
899
- }, Ge = (e, t, n) => Math.min(Math.max(e, t), n), Ke = ({ events: e, currentDate: r, onEventClick: i }) => {
900
- let { timeZone: a } = k(), o = d(null), s = d(null), [l, p] = f(() => Date.now()), m = u(() => G(e, Ue), [e]), h = u(() => new Map(e.map((e) => [e.id, e])), [e]), _ = m.timedEvents ?? [], v = u(() => g(r).isSame(T(a), "day"), [r, a]);
901
- c(() => {
902
- if (!v) {
903
- s.current = null;
904
- return;
905
- }
906
- p(Date.now());
907
- let e = window.setInterval(() => {
908
- p(Date.now());
909
- }, 60 * 1e3);
910
- return () => {
911
- window.clearInterval(e);
912
- };
913
- }, [v]);
914
- let y = u(() => {
915
- if (!v) return null;
916
- let e = w(l, a);
917
- return 20 + (e.hour() * 60 + e.minute() + e.second() / 60) / 60 * 60;
918
- }, [
919
- v,
920
- l,
921
- a
922
- ]), b = u(() => y === null ? null : y - 20, [y]);
923
- return c(() => {
924
- if (!v || !o.current || y === null) return;
925
- let e = g(r).format("YYYY-MM-DD");
926
- if (s.current === e) return;
927
- let t = o.current, n = Math.max(t.scrollHeight - t.clientHeight, 0);
928
- t.scrollTop = Ge(y - t.clientHeight * .35, 0, n), s.current = e;
929
- }, [
930
- r,
931
- v,
932
- y
933
- ]), /* @__PURE__ */ t("div", {
934
- className: H["bsy-mobile-calendar-day__body"],
935
- ref: o,
936
- children: /* @__PURE__ */ n("div", {
937
- className: H["bsy-mobile-calendar-day__time-grid"],
938
- children: [/* @__PURE__ */ t("div", {
939
- className: H["bsy-mobile-calendar-day__time-col"],
940
- children: K.map((e, n) => /* @__PURE__ */ t("div", {
941
- className: H["bsy-mobile-calendar-day__time-label"],
942
- style: { top: 20 + n * 60 },
943
- children: e
944
- }, e))
945
- }), /* @__PURE__ */ n("div", {
946
- className: H["bsy-mobile-calendar-day__content-col"],
947
- children: [
948
- /* @__PURE__ */ t("div", { style: { height: 20 } }),
949
- K.map((e) => /* @__PURE__ */ t("div", { className: H["bsy-mobile-calendar-day__hour-cell"] }, e)),
950
- /* @__PURE__ */ n("div", {
951
- className: H["bsy-mobile-calendar-day__timed-layer"],
952
- children: [_.map((e) => {
953
- let { event: n, top: r, height: a, left: o, width: s, isPercent: c } = e, l = h.get(n.id);
954
- return l ? /* @__PURE__ */ t(R, {
955
- className: H["bsy-mobile-calendar-day__timed-item"],
956
- label: n.label,
957
- timeText: We(l),
958
- variant: "timed",
959
- height: a,
960
- style: {
961
- top: r,
962
- left: c ? `calc(${o}% + 4px)` : o + 4,
963
- width: c ? `calc(${s}% - 8px)` : s - 8
964
- },
965
- onClick: () => i?.(l)
966
- }, n.id) : null;
967
- }), b === null ? null : /* @__PURE__ */ t("div", {
968
- className: H["bsy-mobile-calendar-now-line"],
969
- style: { top: b },
970
- children: /* @__PURE__ */ t("div", { className: H["bsy-mobile-calendar-now-dot"] })
971
- })]
972
- })
973
- ]
974
- })]
975
- })
976
- });
977
- }, qe = () => {
978
- let { currentDate: e, setCurrentDate: r, events: i, onEventClick: a } = k(), s = d(null), c = h(s), l = u(() => {
979
- let t = g(e);
980
- return i.filter((e) => V(e) && ge(e, t));
981
- }, [i, e]), f = u(() => {
982
- let t = g(e);
983
- return i.filter((e) => !V(e) && g(e.startTime).isSame(t, "day"));
984
- }, [i, e]), p = u(() => c?.width ? c.width - 56 : 0, [c?.width]), m = o((e) => {
985
- r(e.toDate());
986
- }, [r]);
987
- return /* @__PURE__ */ n("div", {
988
- className: H["bsy-mobile-calendar-day"],
989
- ref: s,
990
- children: [/* @__PURE__ */ t(Le, {
991
- currentDate: g(e),
992
- setCurrentDate: m,
993
- containerWidth: p,
994
- allDayEvents: l,
995
- onEventClick: a
996
- }), /* @__PURE__ */ t(Ke, {
997
- events: f,
998
- currentDate: e,
999
- onEventClick: a
1000
- })]
1001
- });
1002
- };
1003
- function q(e) {
1004
- return e + 4;
1005
- }
1006
- function Je(e, t, n) {
1007
- let r = q(n), i = n > 0 ? -t / r : 0, a = Math.floor(i) - 2;
1008
- return Array.from({ length: 7 }, (t, n) => ({
1009
- date: e.add(a + n, "day"),
1010
- offset: a + n
1011
- }));
1012
- }
1013
- function Ye(e, t) {
1014
- return e * t + e * 4;
1015
- }
1016
- function Xe({ baseDate: e, setBaseDate: t, columnWidth: n }) {
1017
- let [r, i] = f(0), [a, s] = f(!1), l = d({
1018
- startX: 0,
1019
- startY: 0,
1020
- startTime: 0,
1021
- startTranslateX: 0,
1022
- isDragging: !1,
1023
- isVerticalScroll: !1,
1024
- directionLocked: !1
1025
- }), p = m(e), h = m(t), g = m(n), _ = m(r), v = d(e.format("YYYY-MM-DD"));
1026
- c(() => {
1027
- let t = e.format("YYYY-MM-DD");
1028
- v.current !== t && (i(0), s(!1), v.current = t);
1029
- }, [e]);
1030
- let y = u(() => Je(e, r, n), [
1031
- e.format("YYYY-MM-DD"),
1032
- r,
1033
- n
1034
- ]), b = o((e) => Ye(e, g.current ?? 0), [g]), x = r, S = o((e) => {
1035
- if (l.current.isDragging) return;
1036
- let t = e.touches[0];
1037
- l.current = {
1038
- startX: t.clientX,
1039
- startY: t.clientY,
1040
- startTime: Date.now(),
1041
- startTranslateX: _.current ?? 0,
1042
- isDragging: !0,
1043
- isVerticalScroll: !1,
1044
- directionLocked: !1
1045
- }, s(!1);
1046
- }, [_]), C = o((e) => {
1047
- if (!l.current.isDragging) return;
1048
- let t = e.touches[0], n = t.clientX - l.current.startX, r = t.clientY - l.current.startY;
1049
- if (!l.current.directionLocked && (Math.abs(n) > 10 || Math.abs(r) > 10) && (l.current.directionLocked = !0, Math.abs(r) > Math.abs(n))) {
1050
- l.current.isVerticalScroll = !0;
1051
- return;
1052
- }
1053
- l.current.isVerticalScroll || i(l.current.startTranslateX + n);
1054
- }, []), w = o(() => {
1055
- if (!l.current.isDragging) return;
1056
- let e = _.current ?? 0, t = g.current ?? 0;
1057
- if (l.current.isDragging = !1, !t || l.current.isVerticalScroll) return;
1058
- let n = q(t), r = e - l.current.startTranslateX, a = Date.now() - l.current.startTime, o = Math.abs(r) / a, c = Math.abs(r) > t * .35 || o > .3, u;
1059
- u = c ? r > 0 ? Math.ceil(e / n) * n : Math.floor(e / n) * n : Math.round(e / n) * n, s(!0), i(u);
1060
- }, [g, _]), T = o(() => {
1061
- s(!1);
1062
- let e = _.current ?? 0, t = g.current ?? 0, n = p.current, r = h.current;
1063
- if (t > 0 && n && r) {
1064
- let a = q(t), o = -e / a, s = Math.round(o);
1065
- if (s !== 0) {
1066
- let e = n.add(s, "day");
1067
- v.current = e.format("YYYY-MM-DD"), r(e), i(0);
1068
- }
1069
- }
1070
- }, [
1071
- g,
1072
- _,
1073
- p,
1074
- h
1075
- ]), E = o(() => {
1076
- i(0), s(!1);
1077
- }, []);
1078
- return {
1079
- visibleDays: y,
1080
- offsetX: r,
1081
- trackTransformX: x,
1082
- transitionEnabled: a,
1083
- bindEvents: u(() => ({
1084
- onTouchStart: S,
1085
- onTouchMove: C,
1086
- onTouchEnd: w,
1087
- onTouchCancel: w
1088
- }), [
1089
- S,
1090
- C,
1091
- w
1092
- ]),
1093
- handleTransitionEnd: T,
1094
- getColumnLeft: b,
1095
- resetPosition: E
1096
- };
1097
- }
1098
- //#endregion
1099
- //#region src/components/Calendar/CalendarThreeDay/ThreeDayCarousel.context.tsx
1100
- var Ze = i(null), Qe = ({ children: e, value: n }) => {
1101
- let r = u(() => n, [n]);
1102
- return /* @__PURE__ */ t(Ze.Provider, {
1103
- value: r,
1104
- children: e
1105
- });
1106
- }, J = () => {
1107
- let e = s(Ze);
1108
- if (!e) throw Error("useThreeDayCarouselContext must be used within a ThreeDayCarouselProvider");
1109
- return e;
1110
- }, Y = {
1111
- "bsy-mobile-calendar-threeday": "_bsy-mobile-calendar-threeday_bnwsm_1",
1112
- "bsy-mobile-calendar-threeday__header-wrap": "_bsy-mobile-calendar-threeday__header-wrap_bnwsm_7",
1113
- "bsy-mobile-calendar-threeday__header": "_bsy-mobile-calendar-threeday__header_bnwsm_7",
1114
- "bsy-mobile-calendar-threeday__tz": "_bsy-mobile-calendar-threeday__tz_bnwsm_15",
1115
- "bsy-mobile-calendar-threeday__tz-empty": "_bsy-mobile-calendar-threeday__tz-empty_bnwsm_21",
1116
- "bsy-mobile-calendar-threeday__tz-label": "_bsy-mobile-calendar-threeday__tz-label_bnwsm_24",
1117
- "bsy-mobile-calendar-threeday__dates": "_bsy-mobile-calendar-threeday__dates_bnwsm_32",
1118
- "bsy-mobile-calendar-threeday__dates-track": "_bsy-mobile-calendar-threeday__dates-track_bnwsm_38",
1119
- "bsy-mobile-calendar-threeday__date-col": "_bsy-mobile-calendar-threeday__date-col_bnwsm_43",
1120
- "bsy-mobile-calendar-threeday__weekday": "_bsy-mobile-calendar-threeday__weekday_bnwsm_50",
1121
- "bsy-mobile-calendar-threeday__weekday--weekend": "_bsy-mobile-calendar-threeday__weekday--weekend_bnwsm_55",
1122
- "bsy-mobile-calendar-threeday__weekday--today": "_bsy-mobile-calendar-threeday__weekday--today_bnwsm_58",
1123
- "bsy-mobile-calendar-threeday__weekday--past": "_bsy-mobile-calendar-threeday__weekday--past_bnwsm_61",
1124
- "bsy-mobile-calendar-threeday__date-num": "_bsy-mobile-calendar-threeday__date-num_bnwsm_64",
1125
- "bsy-mobile-calendar-threeday__date-num--today": "_bsy-mobile-calendar-threeday__date-num--today_bnwsm_71",
1126
- "bsy-mobile-calendar-threeday__date-num--past": "_bsy-mobile-calendar-threeday__date-num--past_bnwsm_74",
1127
- "bsy-mobile-calendar-threeday__date-num--future": "_bsy-mobile-calendar-threeday__date-num--future_bnwsm_77",
1128
- "bsy-mobile-calendar-threeday__allday": "_bsy-mobile-calendar-threeday__allday_bnwsm_80",
1129
- "bsy-mobile-calendar-threeday__allday-area": "_bsy-mobile-calendar-threeday__allday-area_bnwsm_88",
1130
- "bsy-mobile-calendar-threeday__allday-track": "_bsy-mobile-calendar-threeday__allday-track_bnwsm_94",
1131
- "bsy-mobile-calendar-threeday__allday-card": "_bsy-mobile-calendar-threeday__allday-card_bnwsm_99",
1132
- "bsy-mobile-calendar-threeday__expand-btn": "_bsy-mobile-calendar-threeday__expand-btn_bnwsm_107",
1133
- "bsy-mobile-calendar-threeday__collapse": "_bsy-mobile-calendar-threeday__collapse_bnwsm_118",
1134
- "bsy-mobile-calendar-threeday__body": "_bsy-mobile-calendar-threeday__body_bnwsm_130",
1135
- "bsy-mobile-calendar-threeday__body-content": "_bsy-mobile-calendar-threeday__body-content_bnwsm_135",
1136
- "bsy-mobile-calendar-threeday__body-time": "_bsy-mobile-calendar-threeday__body-time_bnwsm_139",
1137
- "bsy-mobile-calendar-threeday__time-label": "_bsy-mobile-calendar-threeday__time-label_bnwsm_153",
1138
- "bsy-mobile-calendar-threeday__grid": "_bsy-mobile-calendar-threeday__grid_bnwsm_161",
1139
- "bsy-mobile-calendar-threeday__grid-track": "_bsy-mobile-calendar-threeday__grid-track_bnwsm_168",
1140
- "bsy-mobile-calendar-threeday__day-col": "_bsy-mobile-calendar-threeday__day-col_bnwsm_173",
1141
- "bsy-mobile-calendar-threeday__hour-cell": "_bsy-mobile-calendar-threeday__hour-cell_bnwsm_177",
1142
- "bsy-mobile-calendar-threeday__timed-layer": "_bsy-mobile-calendar-threeday__timed-layer_bnwsm_182",
1143
- "bsy-mobile-calendar-threeday__timed-item": "_bsy-mobile-calendar-threeday__timed-item_bnwsm_195",
1144
- "bsy-mobile-calendar-threeday__now-line": "_bsy-mobile-calendar-threeday__now-line_bnwsm_200",
1145
- "bsy-mobile-calendar-threeday__now-dot": "_bsy-mobile-calendar-threeday__now-dot_bnwsm_209"
1146
- }, $e = () => {
1147
- let { visibleDays: r, trackTransformX: i, transitionEnabled: a, bindEvents: o, handleTransitionEnd: s, columnWidth: c, getColumnLeft: l } = J(), { timeZone: d, timezoneLabel: f } = k(), { t: p } = e(), m = u(() => T(d).startOf("day"), [d]), h = u(() => ({
1148
- transform: `translateX(${i}px)`,
1149
- transition: a ? `transform ${M} ${N}` : "none"
1150
- }), [i, a]);
1151
- return /* @__PURE__ */ n("div", {
1152
- className: Y["bsy-mobile-calendar-threeday__header"],
1153
- children: [/* @__PURE__ */ n("div", {
1154
- className: Y["bsy-mobile-calendar-threeday__tz"],
1155
- children: [/* @__PURE__ */ t("div", { className: Y["bsy-mobile-calendar-threeday__tz-empty"] }), /* @__PURE__ */ t("div", {
1156
- className: Y["bsy-mobile-calendar-threeday__tz-label"],
1157
- children: f
1158
- })]
1159
- }), /* @__PURE__ */ t("div", {
1160
- className: Y["bsy-mobile-calendar-threeday__dates"],
1161
- ...o,
1162
- children: /* @__PURE__ */ t("div", {
1163
- className: Y["bsy-mobile-calendar-threeday__dates-track"],
1164
- style: h,
1165
- onTransitionEnd: s,
1166
- children: r.map(({ date: e, offset: r }) => {
1167
- let i = e.isSame(m, "day"), a = e.isBefore(m, "day"), o = e.isoWeekday(), s = o === 6 || o === 7, u = l(r);
1168
- return /* @__PURE__ */ n("div", {
1169
- className: Y["bsy-mobile-calendar-threeday__date-col"],
1170
- style: {
1171
- position: "absolute",
1172
- left: u,
1173
- width: c
1174
- },
1175
- children: [/* @__PURE__ */ t("div", {
1176
- className: A(Y["bsy-mobile-calendar-threeday__weekday"], s && Y["bsy-mobile-calendar-threeday__weekday--weekend"], i && Y["bsy-mobile-calendar-threeday__weekday--today"], !i && a && Y["bsy-mobile-calendar-threeday__weekday--past"]),
1177
- children: p(`calendar.weekdayPrefixed.${o}`)
1178
- }), /* @__PURE__ */ t("div", {
1179
- className: A(Y["bsy-mobile-calendar-threeday__date-num"], i && Y["bsy-mobile-calendar-threeday__date-num--today"], !i && a && Y["bsy-mobile-calendar-threeday__date-num--past"], !i && !a && Y["bsy-mobile-calendar-threeday__date-num--future"]),
1180
- children: e.date()
1181
- })]
1182
- }, e.format("YYYY-MM-DD"));
1183
- })
1184
- })
1185
- })]
1186
- });
1187
- }, et = Array.from({ length: 24 }, (e, t) => `${t.toString().padStart(2, "0")}:00`), tt = {
1188
- interval: 60,
1189
- rowHeight: 60
1190
- }, X = 4, nt = 8, rt = 4, Z = 8, it = (e) => {
1191
- let t = g(e.startTime), n = g(e.endTime);
1192
- return `${t.format("HH:mm")}-${n.format("HH:mm")}`;
1193
- }, at = (e, t, n) => Math.min(Math.max(e, t), n), ot = ({ events: e, currentDate: r, onEventClick: i }) => {
1194
- let { timeZone: a } = k(), { visibleDays: o, trackTransformX: s, transitionEnabled: l, bindEvents: p, columnWidth: m, getColumnLeft: h } = J(), _ = d(null), v = d(null), [y, b] = f(() => Date.now()), x = u(() => T(a).startOf("day"), [a]), S = u(() => o.map(({ date: t, offset: n }, r) => ({
1195
- date: t,
1196
- offset: n,
1197
- layout: G(e.filter((e) => g(e.startTime).isSame(t, "day") || g(e.startTime).isBefore(t, "day") && g(e.endTime).isAfter(t, "day")), tt),
1198
- isFirstVisibleDay: r === 2
1199
- })), [o, e]), C = u(() => new Map(e.map((e) => [e.id, e])), [e]), E = u(() => o.findIndex(({ date: e }) => e.isSame(x, "day")), [o, x]), D = u(() => g(r).isSame(x, "day"), [r, x]);
1200
- c(() => {
1201
- if (E === -1) {
1202
- v.current = null;
1203
- return;
1204
- }
1205
- b(Date.now());
1206
- let e = window.setInterval(() => b(Date.now()), 60 * 1e3);
1207
- return () => window.clearInterval(e);
1208
- }, [E]);
1209
- let O = u(() => {
1210
- if (E === -1) return null;
1211
- let e = w(y, a);
1212
- return 20 + (e.hour() * 60 + e.minute() + e.second() / 60) / 60 * 60;
1213
- }, [
1214
- E,
1215
- y,
1216
- a
1217
- ]), A = u(() => O === null ? null : O - 20, [O]);
1218
- c(() => {
1219
- if (!D || !_.current || O === null) return;
1220
- let e = g(r).format("YYYY-MM-DD");
1221
- if (v.current === e) return;
1222
- let t = _.current, n = Math.max(t.scrollHeight - t.clientHeight, 0);
1223
- t.scrollTop = at(O - t.clientHeight * .35, 0, n), v.current = e;
1224
- }, [
1225
- r,
1226
- D,
1227
- O
1228
- ]);
1229
- let j = u(() => ({
1230
- transform: `translateX(${s}px)`,
1231
- transition: l ? `transform ${M} ${N}` : "none"
1232
- }), [s, l]);
1233
- return /* @__PURE__ */ t("div", {
1234
- className: Y["bsy-mobile-calendar-threeday__body"],
1235
- ref: _,
1236
- children: /* @__PURE__ */ n("div", {
1237
- className: Y["bsy-mobile-calendar-threeday__body-content"],
1238
- children: [/* @__PURE__ */ t("div", {
1239
- className: Y["bsy-mobile-calendar-threeday__body-time"],
1240
- children: et.map((e, n) => /* @__PURE__ */ t("div", {
1241
- className: Y["bsy-mobile-calendar-threeday__time-label"],
1242
- style: { top: 20 + n * 60 },
1243
- children: e
1244
- }, e))
1245
- }), /* @__PURE__ */ t("div", {
1246
- className: Y["bsy-mobile-calendar-threeday__grid"],
1247
- ...p,
1248
- children: /* @__PURE__ */ t("div", {
1249
- className: Y["bsy-mobile-calendar-threeday__grid-track"],
1250
- style: j,
1251
- children: S.map((e) => {
1252
- let { date: r, offset: a, layout: o, isFirstVisibleDay: s } = e, c = o.timedEvents ?? [], l = r.isSame(x, "day"), u = h(a);
1253
- return /* @__PURE__ */ n("div", {
1254
- className: Y["bsy-mobile-calendar-threeday__day-col"],
1255
- style: {
1256
- position: "absolute",
1257
- left: u,
1258
- width: m
1259
- },
1260
- children: [
1261
- /* @__PURE__ */ t("div", { style: { height: 20 } }),
1262
- et.map((e) => /* @__PURE__ */ t("div", { className: Y["bsy-mobile-calendar-threeday__hour-cell"] }, e)),
1263
- /* @__PURE__ */ n("div", {
1264
- className: Y["bsy-mobile-calendar-threeday__timed-layer"],
1265
- children: [c.map((e) => {
1266
- let { event: n, top: r, height: a, left: o, width: c, isPercent: l, column: u, totalColumns: d } = e, f = C.get(n.id);
1267
- if (!f) return null;
1268
- let p = s ? nt : rt, h = Math.max(0, m - p), g = Math.max(d ?? 1, 1), _ = Math.max(0, c - p), v = Math.max(Z, h - (g - 1) * Z), y = at(_, Math.min(Z, h), Math.min(h, v)), b = Math.max(0, h - y), x = (g > 1 ? (u ?? 0) / (g - 1) : 0) * b, S = s ? x + X : x;
1269
- return /* @__PURE__ */ t(R, {
1270
- className: Y["bsy-mobile-calendar-threeday__timed-item"],
1271
- label: n.label,
1272
- timeText: it(f),
1273
- variant: "timed",
1274
- height: a,
1275
- style: {
1276
- top: r,
1277
- left: l ? s ? `calc(${o}% + ${X}px)` : `${o}%` : S,
1278
- width: l ? s ? `calc(${c}% - ${nt}px)` : `calc(${c}% - ${rt}px)` : y
1279
- },
1280
- onClick: () => i?.(f)
1281
- }, n.id);
1282
- }), l && A !== null ? /* @__PURE__ */ t("div", {
1283
- className: Y["bsy-mobile-calendar-threeday__now-line"],
1284
- style: { top: A },
1285
- children: /* @__PURE__ */ t("div", { className: Y["bsy-mobile-calendar-threeday__now-dot"] })
1286
- }) : null]
1287
- })
1288
- ]
1289
- }, r.format("YYYY-MM-DD"));
1290
- })
1291
- })
1292
- })]
1293
- })
1294
- });
1295
- };
1296
- //#endregion
1297
- //#region src/components/Calendar/utils/threeDaysAlgorithm.ts
1298
- function st(e, t) {
1299
- let n = t.startOf("day"), r = g(e.startTime), i = g(e.endTime), a = r.startOf("day").diff(n, "day"), o = i.hour() === 0 && i.minute() === 0 && i.second() === 0 ? i.startOf("day").diff(n, "day") : i.startOf("day").add(1, "day").diff(n, "day");
1300
- return {
1301
- event: e,
1302
- startCol: a,
1303
- endCol: o,
1304
- span: o - a,
1305
- startTimestamp: r.startOf("day").valueOf()
1306
- };
1307
- }
1308
- function ct(e, t) {
1309
- return e.startCol < t.endCol && e.endCol > t.startCol;
1310
- }
1311
- function lt(e, t) {
1312
- if (!e || e.length === 0) return [];
1313
- let n = [...e.map((e) => st(e, t))].sort((e, t) => e.startTimestamp === t.startTimestamp ? t.span - e.span : e.startTimestamp - t.startTimestamp), r = [], i = [];
1314
- for (let e of n) {
1315
- let t = !1;
1316
- for (let n = 0; n < r.length; n += 1) if (!r[n].some((t) => ct(t, e))) {
1317
- r[n].push(e), i.push({
1318
- ...e,
1319
- row: n
1320
- }), t = !0;
1321
- break;
1322
- }
1323
- t || (r.push([e]), i.push({
1324
- ...e,
1325
- row: r.length - 1
1326
- }));
1327
- }
1328
- return i;
1329
- }
1330
- //#endregion
1331
- //#region src/components/Calendar/CalendarThreeDay/ThreeDayAllDayEvents/ThreeDayAllDayEvents.tsx
1332
- var ut = 22;
1333
- function dt(e, t, n, r) {
1334
- let i = q(r), a = e * i, o = t * i, s = a + n, c = o + n, l = r * 3 + 8, u = Math.max(s, 0), d = Math.min(c, l) - u;
1335
- return {
1336
- left: u,
1337
- width: d,
1338
- visible: d > 0,
1339
- isStart: s >= 0,
1340
- isEnd: c <= l
1341
- };
1342
- }
1343
- function ft(e, t, n) {
1344
- let r = q(n), i = [
1345
- 0,
1346
- 0,
1347
- 0
1348
- ], a = Math.round(-t / r);
1349
- for (let t of e) if (!(t.row < 3)) for (let e = 0; e < 3; e++) {
1350
- let n = a + e;
1351
- n >= t.startCol && n < t.endCol && (i[e] += 1);
1352
- }
1353
- return i;
1354
- }
1355
- var pt = ({ events: e, baseDate: r, onEventClick: i }) => {
1356
- let { offsetX: a, transitionEnabled: o, bindEvents: s, columnWidth: c } = J(), [l, d] = f(!1), p = u(() => lt(e, r), [e, r]), m = u(() => {
1357
- let e = p.filter((e) => dt(e.startCol, e.endCol, a, c).visible);
1358
- return e.length === 0 ? -1 : Math.max(...e.map((e) => e.row));
1359
- }, [
1360
- p,
1361
- a,
1362
- c
1363
- ]) + 1, h = m > 3, g = l && m > 8, _ = l ? Math.min(m, 8) : Math.min(m, 3), v = u(() => l || !h ? [
1364
- 0,
1365
- 0,
1366
- 0
1367
- ] : ft(p, a, c), [
1368
- p,
1369
- a,
1370
- c,
1371
- l,
1372
- h
1373
- ]), y = !l && h && v.some((e) => e > 0), b = u(() => m === 0 ? 0 : _ * P + (y ? ut : 0) + 8, [
1374
- m,
1375
- _,
1376
- y
1377
- ]), x = u(() => m === 0 ? 0 : g ? m * P : _ * P + (y ? ut : 0), [
1378
- m,
1379
- _,
1380
- y,
1381
- g
1382
- ]), S = q(c);
1383
- return /* @__PURE__ */ n("div", {
1384
- className: Y["bsy-mobile-calendar-threeday__allday"],
1385
- style: { height: b },
1386
- children: [l && h ? /* @__PURE__ */ t("div", {
1387
- className: Y["bsy-mobile-calendar-threeday__collapse"],
1388
- onClick: () => d(!1),
1389
- children: /* @__PURE__ */ t("svg", {
1390
- width: "16",
1391
- height: "16",
1392
- viewBox: "0 0 16 16",
1393
- fill: "none",
1394
- style: { transform: "rotate(180deg)" },
1395
- children: /* @__PURE__ */ t("path", {
1396
- d: "M4 6L8 10L12 6",
1397
- stroke: "#666666",
1398
- strokeWidth: "1.5",
1399
- strokeLinecap: "round",
1400
- strokeLinejoin: "round"
1401
- })
1402
- })
1403
- }) : null, /* @__PURE__ */ t("div", {
1404
- className: Y["bsy-mobile-calendar-threeday__allday-area"],
1405
- style: g ? {
1406
- overflowY: "auto",
1407
- maxHeight: 8 * P
1408
- } : void 0,
1409
- ...s,
1410
- children: /* @__PURE__ */ n("div", {
1411
- className: Y["bsy-mobile-calendar-threeday__allday-track"],
1412
- style: {
1413
- height: x,
1414
- transition: o ? `height ${M} ${N}` : "none"
1415
- },
1416
- children: [p.map((e) => {
1417
- let { event: n, startCol: r, endCol: o, row: s } = e;
1418
- if (!l && s >= 3) return null;
1419
- let u = dt(r, o, a, c);
1420
- return u.visible ? /* @__PURE__ */ t(R, {
1421
- className: Y["bsy-mobile-calendar-threeday__allday-card"],
1422
- label: n.label,
1423
- variant: "allDay",
1424
- height: 22,
1425
- isStart: u.isStart,
1426
- isEnd: u.isEnd,
1427
- isContinue: !u.isStart,
1428
- style: {
1429
- left: u.left,
1430
- width: u.width - 4,
1431
- top: s * P + 4
1432
- },
1433
- onClick: () => i?.(n)
1434
- }, n.id) : null;
1435
- }), y ? v.map((e, r) => {
1436
- if (e === 0) return null;
1437
- let i = r * S;
1438
- return /* @__PURE__ */ t("div", {
1439
- className: Y["bsy-mobile-calendar-threeday__expand-btn"],
1440
- style: {
1441
- left: i,
1442
- width: c - 4,
1443
- top: 3 * P + 4
1444
- },
1445
- onClick: () => d(!0),
1446
- children: /* @__PURE__ */ n("span", { children: [
1447
- "还有",
1448
- e,
1449
- "条记录"
1450
- ] })
1451
- }, `expand-btn-${r}`);
1452
- }) : null]
1453
- })
1454
- })]
1455
- });
1456
- }, mt = () => {
1457
- let { currentDate: e, setCurrentDate: r, events: i, onEventClick: a } = k(), s = d(null), c = h(s), l = u(() => c?.width ? (c.width - 56 - 8 - 8) / 3 : 0, [c?.width]), f = u(() => g(e), [e]), { visibleDays: p, offsetX: m, trackTransformX: _, transitionEnabled: v, bindEvents: y, handleTransitionEnd: b, getColumnLeft: x, resetPosition: S } = Xe({
1458
- baseDate: f,
1459
- setBaseDate: o((e) => {
1460
- r(e.toDate());
1461
- }, [r]),
1462
- columnWidth: l
1463
- }), C = u(() => i.filter((e) => V(e)), [i]), w = u(() => i.filter((e) => !V(e)), [i]), T = u(() => ({
1464
- visibleDays: p,
1465
- offsetX: m,
1466
- trackTransformX: _,
1467
- transitionEnabled: v,
1468
- bindEvents: y,
1469
- handleTransitionEnd: b,
1470
- columnWidth: l,
1471
- getColumnLeft: x,
1472
- resetPosition: S
1473
- }), [
1474
- p,
1475
- m,
1476
- _,
1477
- v,
1478
- y,
1479
- b,
1480
- l,
1481
- x,
1482
- S
1483
- ]);
1484
- return /* @__PURE__ */ t("div", {
1485
- className: Y["bsy-mobile-calendar-threeday"],
1486
- ref: s,
1487
- children: l > 0 ? /* @__PURE__ */ n(Qe, {
1488
- value: T,
1489
- children: [/* @__PURE__ */ n("div", {
1490
- className: Y["bsy-mobile-calendar-threeday__header-wrap"],
1491
- children: [/* @__PURE__ */ t($e, {}), /* @__PURE__ */ t(pt, {
1492
- events: C,
1493
- baseDate: f,
1494
- onEventClick: a
1495
- })]
1496
- }), /* @__PURE__ */ t(ot, {
1497
- events: w,
1498
- currentDate: e,
1499
- onEventClick: a
1500
- })]
1501
- }) : null
1502
- });
1503
- }, ht = (e, t = {}) => {
1504
- let { timeZone: n } = t;
1505
- return Array.isArray(e) ? e.map((e, t) => ({
1506
- ...e,
1507
- id: e.id ?? String(t),
1508
- label: e.label ?? "",
1509
- startTime: w(e.startTime, n),
1510
- endTime: w(e.endTime, n)
1511
- })) : [];
1512
- }, Q = {
1513
- "#005EEF": {
1514
- normal: "#EFF5FF",
1515
- hover: "#D9E8FF"
1516
- },
1517
- "#3642E9": {
1518
- normal: "#EDEEFF",
1519
- hover: "#DEE0FF"
1520
- },
1521
- "#10A9C4": {
1522
- normal: "#EBFCFF",
1523
- hover: "#DDFAFF"
1524
- },
1525
- "#32A645": {
1526
- normal: "#f2ffef",
1527
- hover: "#E4FFE0"
1528
- },
1529
- "#FFC502": {
1530
- normal: "#FFFAE8",
1531
- hover: "#FFF4D0"
1532
- },
1533
- "#FF9921": {
1534
- normal: "#FFF5EA",
1535
- hover: "#FFECD7"
1536
- },
1537
- "#F06648": {
1538
- normal: "#FFF0ED",
1539
- hover: "#FFE3DD"
1540
- },
1541
- "#F168B6": {
1542
- normal: "#FFEFF8",
1543
- hover: "#FFDEF1"
1544
- },
1545
- "#6C6C6E": {
1546
- normal: "#F2F3F5",
1547
- hover: "#E6E6E7"
1548
- }
1549
- }, $ = /* @__PURE__ */ new Map(), gt = (e) => {
1550
- if (!e) return {
1551
- normal: "#e8f0fe",
1552
- hover: "#d7e3fd"
1553
- };
1554
- if ($.has(e)) return $.get(e);
1555
- let t = e.toUpperCase();
1556
- if (Q[t]) return $.set(e, Q[t]), Q[t];
1557
- let n = parseInt(e.slice(1, 3), 16), r = parseInt(e.slice(3, 5), 16), i = parseInt(e.slice(5, 7), 16), a = .88, o = .8, s = {
1558
- normal: `rgb(${Math.round(n + (255 - n) * a)}, ${Math.round(r + (255 - r) * a)}, ${Math.round(i + (255 - i) * a)})`,
1559
- hover: `rgb(${Math.round(n + (255 - n) * o)}, ${Math.round(r + (255 - r) * o)}, ${Math.round(i + (255 - i) * o)})`
1560
- };
1561
- return $.set(e, s), s;
1562
- }, _t = (e) => {
1563
- let t = gt(e);
1564
- return {
1565
- "--bsy-mobile-calendar-color": e,
1566
- "--bsy-mobile-calendar-bg": t.normal,
1567
- "--bsy-mobile-calendar-hover": t.hover
1568
- };
1569
- }, vt = (e) => {
1570
- let { events: r, scheduleColor: i, timeZone: a, className: o, onEventClick: s, onDayClick: c } = e, [l, d] = p(e, {
1571
- defaultValue: "month",
1572
- defaultValuePropName: "defaultMode",
1573
- valuePropName: "mode",
1574
- trigger: "onModeChange"
1575
- }), [f, m] = p(e, { defaultValue: T(a).toDate() }), h = u(() => ht(r, { timeZone: a }), [r, a]), g = u(() => _t(i), [i]);
1576
- return /* @__PURE__ */ t("div", {
1577
- className: A(b["bsy-mobile-calendar"], o),
1578
- style: g,
1579
- children: /* @__PURE__ */ n(O, {
1580
- currentDate: f,
1581
- setCurrentDate: m,
1582
- viewMode: l,
1583
- setViewMode: d,
1584
- scheduleColor: i,
1585
- timeZone: a,
1586
- events: h,
1587
- onEventClick: s,
1588
- onDayClick: c,
1589
- children: [/* @__PURE__ */ t(te, {}), /* @__PURE__ */ n("div", {
1590
- className: b["bsy-mobile-calendar__body"],
1591
- children: [
1592
- l === "month" ? /* @__PURE__ */ t(Ae, {}) : null,
1593
- l === "day" ? /* @__PURE__ */ t(qe, {}) : null,
1594
- l === "threeDay" ? /* @__PURE__ */ t(mt, {}) : null
1595
- ]
1596
- })]
1597
- })
1598
- });
1599
- };
1600
- //#endregion
1601
- export { vt as t };