chesai-ui 0.16.10 → 0.16.12

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.
@@ -1,220 +1,101 @@
1
- import { jsxs as r, jsx as t, Fragment as R } from "react/jsx-runtime";
2
- import { useMediaQuery as ue } from "@uidotdev/usehooks";
3
- import { clsx as X } from "clsx";
4
- import { format as W } from "date-fns";
5
- import { useDragControls as fe, useMotionValue as L, AnimatePresence as Q, motion as S } from "framer-motion";
6
- import { Clock as he, Repeat as pe, X as U, Trash2 as J, GripHorizontal as ye } from "lucide-react";
7
- import { useRef as ve, useState as M, useEffect as K } from "react";
8
- import { createPortal as P } from "react-dom";
9
- import { Button as x } from "../button/index.mjs";
10
- import { ButtonGroup as ge } from "../button-group/index.mjs";
11
- import { DatePicker as z } from "../date-picker/date-picker.mjs";
12
- import { IconButton as w } from "../icon-button/index.mjs";
13
- import { Input as xe } from "../input/index.mjs";
14
- import { Sheet as we, SheetContent as be, SheetHeader as Ne, SheetTitle as ke } from "../sheet/index.mjs";
15
- import { TimePicker as Z } from "../time-picker/index.mjs";
16
- import { Typography as b } from "../typography/index.mjs";
17
- import { Switch as De } from "../switch/index.mjs";
18
- import { Select as ee } from "../select/index.mjs";
19
- import { NumberInput as te } from "../number-input/index.mjs";
20
- import { useFullCalendar as Ce } from "./calendar-context.mjs";
21
- const N = 380, Oe = (s, i) => {
22
- const o = s.frequency, a = s.interval;
23
- let d = "";
24
- if (a > 1 ? d = `Every ${a} ${o === "daily" ? "days" : o === "weekly" ? "weeks" : o === "monthly" ? "months" : "years"}` : d = o === "daily" ? "Daily" : o === "weekly" ? "Weekly" : o === "monthly" ? "Monthly" : "Annually", o === "weekly" && s.daysOfWeek && s.daysOfWeek.length > 0) {
25
- const k = [
26
- "Sunday",
27
- "Monday",
28
- "Tuesday",
29
- "Wednesday",
30
- "Thursday",
31
- "Friday",
32
- "Saturday"
33
- ];
34
- s.daysOfWeek.length === 7 ? d = a > 1 ? `Every ${a} weeks on all days` : "Every day" : s.daysOfWeek.length === 5 && [1, 2, 3, 4, 5].every((y) => s.daysOfWeek.includes(y)) ? d = a > 1 ? `Every ${a} weeks on weekdays` : "Every weekday (Monday to Friday)" : d += ` on ${s.daysOfWeek.map((y) => k[y]).join(", ")}`;
35
- } else o === "monthly" ? d += ` on day ${i.getDate()}` : o === "yearly" && (d += ` on ${W(i, "MMM d")}`);
36
- return s.endType === "on_date" && s.until ? d += `, until ${W(s.until, "MMM d, yyyy")}` : s.endType === "after_occurrences" && s.count && (d += `, for ${s.count} occurrences`), d;
37
- }, A = ({
38
- checked: s,
39
- onChange: i,
40
- label: o,
41
- children: a
42
- }) => /* @__PURE__ */ r("div", { className: "flex items-center gap-4 h-10 w-full", children: [
43
- /* @__PURE__ */ r("label", { className: "flex items-center gap-3 cursor-pointer shrink-0", children: [
44
- /* @__PURE__ */ r("div", { className: "relative flex items-center justify-center w-5 h-5 shrink-0", children: [
45
- /* @__PURE__ */ t(
46
- "input",
47
- {
48
- type: "radio",
49
- className: "peer sr-only",
50
- checked: s,
51
- onChange: i
52
- }
53
- ),
54
- /* @__PURE__ */ t(
55
- "div",
56
- {
57
- className: X(
58
- "w-5 h-5 rounded-full border-2 transition-colors",
59
- s ? "border-primary" : "border-outline-variant hover:border-on-surface-variant"
60
- )
61
- }
62
- ),
63
- /* @__PURE__ */ t(
64
- "div",
65
- {
66
- className: X(
67
- "absolute w-2.5 h-2.5 rounded-full bg-primary transition-transform duration-200",
68
- s ? "scale-100" : "scale-0"
69
- )
70
- }
71
- )
72
- ] }),
73
- /* @__PURE__ */ t("span", { className: "text-sm font-medium text-on-surface select-none", children: o })
74
- ] }),
75
- a && /* @__PURE__ */ t("div", { className: "flex-1 flex items-center", children: a })
76
- ] }), Xe = () => {
77
- const s = Ce(), {
1
+ import { jsxs as s, jsx as a, Fragment as L } from "react/jsx-runtime";
2
+ import { useMediaQuery as Q } from "@uidotdev/usehooks";
3
+ import { useDragControls as U, useMotionValue as E, AnimatePresence as _, motion as q } from "framer-motion";
4
+ import { Clock as J, Repeat as K, X as z, Trash2 as H, GripHorizontal as Z } from "lucide-react";
5
+ import { useRef as $, useState as R, useEffect as Y } from "react";
6
+ import { Button as A } from "../button/index.mjs";
7
+ import { DatePicker as O } from "../date-picker/date-picker.mjs";
8
+ import { IconButton as u } from "../icon-button/index.mjs";
9
+ import { Input as ee } from "../input/index.mjs";
10
+ import { Sheet as te, SheetContent as ae, SheetHeader as re, SheetTitle as ne } from "../sheet/index.mjs";
11
+ import { TimePicker as j } from "../time-picker/index.mjs";
12
+ import { Switch as ie } from "../switch/index.mjs";
13
+ import { useFullCalendar as se } from "./calendar-context.mjs";
14
+ import { RecurrenceSelect as oe } from "./recurrence-select.mjs";
15
+ const f = 380, ye = () => {
16
+ const T = se(), {
78
17
  popover: i,
79
- closePopover: o,
80
- draftEvent: a,
81
- setDraftEvent: d,
82
- onEventCreate: k,
83
- onEventUpdate: y,
84
- onEventDelete: H,
85
- hidePopoverTitle: ae,
86
- hidePopoverTime: ne,
87
- hidePopoverRecurrence: re,
88
- renderPopoverHeader: q,
89
- renderPopoverFooter: Y,
90
- renderPopoverCustomFields: V
91
- } = s, v = ue("(max-width: 768px)"), E = ve(null), _ = fe(), D = L(0), C = L(0), [ie, O] = M(!1), [g, le] = M(450), [c, u] = M({
92
- frequency: "weekly",
93
- interval: 1,
94
- daysOfWeek: [],
95
- endType: "never",
96
- count: 13,
97
- until: new Date(Date.now() + 720 * 60 * 60 * 1e3)
98
- });
99
- K(() => {
100
- if (!i.isOpen || v || typeof window > "u" || !window.ResizeObserver)
18
+ closePopover: l,
19
+ draftEvent: t,
20
+ setDraftEvent: w,
21
+ onEventCreate: N,
22
+ onEventUpdate: b,
23
+ onEventDelete: y,
24
+ hidePopoverTitle: V,
25
+ hidePopoverTime: W,
26
+ hidePopoverRecurrence: B,
27
+ renderPopoverHeader: D,
28
+ renderPopoverFooter: C,
29
+ renderPopoverCustomFields: k
30
+ } = T, c = Q("(max-width: 768px)"), g = $(null), F = U(), p = E(0), v = E(0), [d, I] = R(450);
31
+ Y(() => {
32
+ if (!i.isOpen || c || typeof window > "u" || !window.ResizeObserver)
101
33
  return;
102
- const e = new ResizeObserver((n) => {
103
- for (const l of n)
104
- le(l.target.getBoundingClientRect().height);
34
+ const e = new ResizeObserver((r) => {
35
+ for (const n of r)
36
+ I(n.target.getBoundingClientRect().height);
105
37
  });
106
- return E.current && e.observe(E.current), () => e.disconnect();
107
- }, [i.isOpen, v]), K(() => {
108
- if (i.isOpen && !v) {
109
- const n = window.innerWidth, l = window.innerHeight;
38
+ return g.current && e.observe(g.current), () => e.disconnect();
39
+ }, [i.isOpen, c]), Y(() => {
40
+ if (i.isOpen && !c) {
41
+ const r = window.innerWidth, n = window.innerHeight;
110
42
  if (i.anchorRect) {
111
- let p = i.anchorRect.right + 16, f = i.anchorRect.top;
112
- p + N > n && (p = i.anchorRect.left - N - 16), f + g > l && (f = l - g - 16), p = Math.max(
43
+ let h = i.anchorRect.right + 16, m = i.anchorRect.top;
44
+ h + f > r && (h = i.anchorRect.left - f - 16), m + d > n && (m = n - d - 16), h = Math.max(
113
45
  16,
114
- Math.min(p, n - N - 16)
115
- ), f = Math.max(
46
+ Math.min(h, r - f - 16)
47
+ ), m = Math.max(
116
48
  16,
117
- Math.min(f, l - g - 16)
118
- ), D.set(p), C.set(f);
49
+ Math.min(m, n - d - 16)
50
+ ), p.set(h), v.set(m);
119
51
  } else
120
- D.set(n / 2 - N / 2), C.set(l / 2 - g / 2);
52
+ p.set(r / 2 - f / 2), v.set(n / 2 - d / 2);
121
53
  }
122
- }, [i.isOpen, i.anchorRect, v, g, D, C]);
123
- const [se, oe] = M(1), $ = async () => {
124
- if (!a) return;
125
- const e = new Date(a.start);
126
- a.isAllDay ? e.setHours(0, 0, 0, 0) : e.setHours(
127
- a.start.getHours(),
128
- a.start.getMinutes(),
54
+ }, [i.isOpen, i.anchorRect, c, d, p, v]);
55
+ const [X, G] = R(1), P = async () => {
56
+ if (!t) return;
57
+ const e = new Date(t.start);
58
+ t.isAllDay ? e.setHours(0, 0, 0, 0) : e.setHours(
59
+ t.start.getHours(),
60
+ t.start.getMinutes(),
129
61
  0,
130
62
  0
131
63
  );
132
- const n = new Date(a.end);
133
- a.isAllDay ? n.setHours(23, 59, 59, 999) : n.setHours(
134
- a.end.getHours(),
135
- a.end.getMinutes(),
64
+ const r = new Date(t.end);
65
+ t.isAllDay ? r.setHours(23, 59, 59, 999) : r.setHours(
66
+ t.end.getHours(),
67
+ t.end.getMinutes(),
136
68
  0,
137
69
  0
138
70
  );
139
- const l = {
140
- ...a,
71
+ const n = {
72
+ ...t,
141
73
  start: e,
142
- end: n,
143
- title: a.title || "(No title)"
74
+ end: r,
75
+ title: t.title || "(No title)"
144
76
  };
145
- delete l.isDraft, i.mode === "create" && k ? await k(l) : i.mode === "edit" && y && await y(l), o();
146
- }, j = async () => {
147
- a?.id && H && await H(a.id), o();
148
- }, m = (e) => {
149
- d((n) => n ? { ...n, ...e } : null);
150
- }, T = (e) => {
151
- d((n) => {
152
- if (!n) return null;
153
- const l = e.data !== void 0 ? { ...n.data || {}, ...e.data } : n.data;
154
- return { ...n, ...e, data: l };
155
- });
156
- }, F = a ? [
157
- { value: "none", label: "Does not repeat" },
158
- { value: "daily", label: "Daily" },
159
- {
160
- value: "weekly",
161
- label: `Weekly on ${W(a.start, "EEEE")}`
162
- },
163
- {
164
- value: "monthly",
165
- label: `Monthly on the ${a.start.getDate()}`
166
- },
167
- {
168
- value: "yearly",
169
- label: `Annually on ${W(a.start, "MMM d")}`
170
- },
171
- { value: "weekdays", label: "Every weekday (Monday to Friday)" }
172
- ] : [];
173
- let h = "none";
174
- if (a?.recurrence) {
175
- const e = a.recurrence;
176
- e.interval === 1 && e.endType === "never" && (e.frequency === "daily" ? h = "daily" : e.frequency === "weekly" && e.daysOfWeek?.length === 1 && e.daysOfWeek[0] === a.start.getDay() ? h = "weekly" : e.frequency === "weekly" && e.daysOfWeek?.length === 5 && [1, 2, 3, 4, 5].every((n) => e.daysOfWeek.includes(n)) ? h = "weekdays" : e.frequency === "monthly" ? h = "monthly" : e.frequency === "yearly" && (h = "yearly")), h === "none" && (h = "custom_active", F.push({
177
- value: "custom_active",
178
- label: Oe(e, a.start)
179
- }));
180
- }
181
- F.push({ value: "custom", label: "Custom..." });
182
- const ce = (e) => {
183
- e === "none" ? m({ recurrence: void 0 }) : e === "custom" ? (u(
184
- a?.recurrence || {
185
- frequency: "weekly",
186
- interval: 1,
187
- daysOfWeek: [a?.start?.getDay() || 0],
188
- endType: "never",
189
- count: 13,
190
- until: new Date(Date.now() + 720 * 60 * 60 * 1e3)
191
- }
192
- ), O(!0)) : e === "weekdays" ? m({
193
- recurrence: {
194
- frequency: "weekly",
195
- interval: 1,
196
- endType: "never",
197
- daysOfWeek: [1, 2, 3, 4, 5]
198
- }
199
- }) : e !== "custom_active" && m({
200
- recurrence: {
201
- frequency: e,
202
- interval: 1,
203
- endType: "never",
204
- daysOfWeek: e === "weekly" ? [a?.start?.getDay() || 0] : void 0
205
- }
77
+ delete n.isDraft, i.mode === "create" && N ? await N(n) : i.mode === "edit" && b && await b(n), l();
78
+ }, M = async () => {
79
+ t?.id && y && await y(t.id), l();
80
+ }, o = (e) => {
81
+ w((r) => r ? { ...r, ...e } : null);
82
+ }, x = (e) => {
83
+ w((r) => {
84
+ if (!r) return null;
85
+ const n = e.data !== void 0 ? { ...r.data || {}, ...e.data } : r.data;
86
+ return { ...r, ...e, data: n };
206
87
  });
207
88
  };
208
- if (!a) return null;
209
- const B = /* @__PURE__ */ r("div", { className: "flex flex-col gap-6 p-6 font-manrope text-on-surface min-w-[340px]", children: [
210
- q && /* @__PURE__ */ t("div", { className: "flex flex-col gap-4", children: q(a, T) }),
211
- !ae && /* @__PURE__ */ t("div", { className: "pl-10 pr-2", children: /* @__PURE__ */ t(
212
- xe,
89
+ if (!t) return null;
90
+ const S = /* @__PURE__ */ s("div", { className: "flex flex-col gap-6 p-6 font-manrope text-on-surface min-w-[340px]", children: [
91
+ D && /* @__PURE__ */ a("div", { className: "flex flex-col gap-4", children: D(t, x) }),
92
+ !V && /* @__PURE__ */ a("div", { className: "pl-10 pr-2", children: /* @__PURE__ */ a(
93
+ ee,
213
94
  {
214
95
  variant: "underlined",
215
96
  placeholder: "Add title",
216
- value: a.title,
217
- onChange: (e) => m({ title: e.target.value }),
97
+ value: t.title,
98
+ onChange: (e) => o({ title: e.target.value }),
218
99
  autoFocus: !0,
219
100
  className: "shadow-none px-0",
220
101
  classNames: {
@@ -223,91 +104,91 @@ const N = 380, Oe = (s, i) => {
223
104
  }
224
105
  }
225
106
  ) }),
226
- !ne && /* @__PURE__ */ r("div", { className: "flex items-start gap-4", children: [
227
- /* @__PURE__ */ t(he, { className: "w-5 h-5 mt-2.5 text-on-surface-variant shrink-0" }),
228
- /* @__PURE__ */ r("div", { className: "flex flex-col gap-3 w-full min-w-0", children: [
229
- /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5 w-full", children: [
230
- /* @__PURE__ */ t(
231
- z,
107
+ !W && /* @__PURE__ */ s("div", { className: "flex items-start gap-4", children: [
108
+ /* @__PURE__ */ a(J, { className: "w-5 h-5 mt-2.5 text-on-surface-variant shrink-0" }),
109
+ /* @__PURE__ */ s("div", { className: "flex flex-col gap-3 w-full min-w-0", children: [
110
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-1.5 w-full", children: [
111
+ /* @__PURE__ */ a(
112
+ O,
232
113
  {
233
114
  variant: "docked",
234
115
  inputVariant: "filled",
235
116
  size: "sm",
236
117
  shape: "full",
237
- value: a.start,
118
+ value: t.start,
238
119
  onChange: (e) => {
239
120
  if (!e) return;
240
- const n = new Date(a.start);
241
- n.setFullYear(
121
+ const r = new Date(t.start);
122
+ r.setFullYear(
242
123
  e.getFullYear(),
243
124
  e.getMonth(),
244
125
  e.getDate()
245
126
  );
246
- let l = new Date(a.end);
247
- a.isAllDay ? a.end < n && l.setFullYear(
127
+ let n = new Date(t.end);
128
+ t.isAllDay ? t.end < r && n.setFullYear(
248
129
  e.getFullYear(),
249
130
  e.getMonth(),
250
131
  e.getDate()
251
- ) : l.setFullYear(
132
+ ) : n.setFullYear(
252
133
  e.getFullYear(),
253
134
  e.getMonth(),
254
135
  e.getDate()
255
- ), m({ start: n, end: l });
136
+ ), o({ start: r, end: n });
256
137
  }
257
138
  }
258
139
  ),
259
- a.isAllDay && /* @__PURE__ */ r(R, { children: [
260
- /* @__PURE__ */ t("span", { className: "text-on-surface-variant shrink-0", children: "-" }),
261
- /* @__PURE__ */ t(
262
- z,
140
+ t.isAllDay && /* @__PURE__ */ s(L, { children: [
141
+ /* @__PURE__ */ a("span", { className: "text-on-surface-variant shrink-0", children: "-" }),
142
+ /* @__PURE__ */ a(
143
+ O,
263
144
  {
264
145
  variant: "docked",
265
146
  inputVariant: "filled",
266
147
  size: "sm",
267
148
  shape: "full",
268
- value: a.end,
149
+ value: t.end,
269
150
  onChange: (e) => {
270
151
  if (!e) return;
271
- const n = new Date(a.end);
272
- if (n.setFullYear(
152
+ const r = new Date(t.end);
153
+ if (r.setFullYear(
273
154
  e.getFullYear(),
274
155
  e.getMonth(),
275
156
  e.getDate()
276
- ), m({ end: n }), a.start > n) {
277
- const l = new Date(a.start);
278
- l.setFullYear(
157
+ ), o({ end: r }), t.start > r) {
158
+ const n = new Date(t.start);
159
+ n.setFullYear(
279
160
  e.getFullYear(),
280
161
  e.getMonth(),
281
162
  e.getDate()
282
- ), m({ start: l });
163
+ ), o({ start: n });
283
164
  }
284
165
  }
285
166
  }
286
167
  )
287
168
  ] })
288
169
  ] }),
289
- /* @__PURE__ */ r("div", { className: "flex items-center gap-2 mt-1 w-fit", children: [
290
- /* @__PURE__ */ t(
291
- De,
170
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-2 mt-1 w-fit", children: [
171
+ /* @__PURE__ */ a(
172
+ ie,
292
173
  {
293
174
  id: "all-day-switch",
294
175
  size: "sm",
295
- checked: !!a.isAllDay,
176
+ checked: !!t.isAllDay,
296
177
  onCheckedChange: (e) => {
297
178
  if (e)
298
- m({ isAllDay: e });
179
+ o({ isAllDay: e });
299
180
  else {
300
- const n = new Date(a.end);
301
- n.setFullYear(
302
- a.start.getFullYear(),
303
- a.start.getMonth(),
304
- a.start.getDate()
305
- ), m({ isAllDay: e, end: n });
181
+ const r = new Date(t.end);
182
+ r.setFullYear(
183
+ t.start.getFullYear(),
184
+ t.start.getMonth(),
185
+ t.start.getDate()
186
+ ), o({ isAllDay: e, end: r });
306
187
  }
307
188
  }
308
189
  }
309
190
  ),
310
- /* @__PURE__ */ t(
191
+ /* @__PURE__ */ a(
311
192
  "label",
312
193
  {
313
194
  htmlFor: "all-day-switch",
@@ -316,298 +197,101 @@ const N = 380, Oe = (s, i) => {
316
197
  }
317
198
  )
318
199
  ] }),
319
- !a.isAllDay && /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5 w-full mt-1", children: [
320
- /* @__PURE__ */ t(
321
- Z,
200
+ !t.isAllDay && /* @__PURE__ */ s("div", { className: "flex items-center gap-1.5 w-full mt-1", children: [
201
+ /* @__PURE__ */ a(
202
+ j,
322
203
  {
323
204
  variant: "docked",
324
205
  inputVariant: "filled",
325
206
  size: "sm",
326
207
  shape: "full",
327
- value: a.start,
328
- onChange: (e) => m({ start: e })
208
+ value: t.start,
209
+ onChange: (e) => o({ start: e })
329
210
  }
330
211
  ),
331
- /* @__PURE__ */ t("span", { className: "text-on-surface-variant shrink-0", children: "-" }),
332
- /* @__PURE__ */ t(
333
- Z,
212
+ /* @__PURE__ */ a("span", { className: "text-on-surface-variant shrink-0", children: "-" }),
213
+ /* @__PURE__ */ a(
214
+ j,
334
215
  {
335
216
  variant: "docked",
336
217
  inputVariant: "filled",
337
218
  size: "sm",
338
219
  shape: "full",
339
- value: a.end,
340
- onChange: (e) => m({ end: e })
220
+ value: t.end,
221
+ onChange: (e) => o({ end: e })
341
222
  }
342
223
  )
343
224
  ] })
344
225
  ] })
345
226
  ] }),
346
- !re && /* @__PURE__ */ r("div", { className: "flex items-center gap-4 mt-2", children: [
347
- /* @__PURE__ */ t(pe, { className: "w-5 h-5 text-on-surface-variant shrink-0" }),
348
- /* @__PURE__ */ t("div", { className: "w-full", children: /* @__PURE__ */ t(
349
- ee,
227
+ !B && /* @__PURE__ */ s("div", { className: "flex items-center gap-4 mt-2", children: [
228
+ /* @__PURE__ */ a(K, { className: "w-5 h-5 text-on-surface-variant shrink-0" }),
229
+ /* @__PURE__ */ a("div", { className: "w-full", children: /* @__PURE__ */ a(
230
+ oe,
350
231
  {
351
232
  variant: "filled",
352
233
  size: "sm",
353
234
  shape: "full",
354
- value: h,
355
- onValueChange: ce,
356
- items: F
235
+ value: t.recurrence,
236
+ onChange: (e) => o({ recurrence: e }),
237
+ startDate: t.start
357
238
  }
358
239
  ) })
359
240
  ] }),
360
- V && /* @__PURE__ */ t("div", { className: "mt-2 border-t border-outline-variant/30 pt-4 flex flex-col gap-4", children: V(a, T) }),
361
- Y && /* @__PURE__ */ t("div", { className: "mt-2 border-t border-outline-variant/30 pt-4 flex flex-col gap-4", children: Y(a, T) })
362
- ] }), I = /* @__PURE__ */ t(Q, { children: ie && /* @__PURE__ */ r("div", { className: "fixed inset-0 z-[100] flex items-center justify-center px-4 pointer-events-auto", children: [
363
- /* @__PURE__ */ t(
364
- S.div,
365
- {
366
- initial: { opacity: 0 },
367
- animate: { opacity: 1 },
368
- exit: { opacity: 0 },
369
- transition: { duration: 0.2 },
370
- className: "absolute inset-0 bg-black/50",
371
- onClick: () => O(!1)
372
- }
373
- ),
374
- /* @__PURE__ */ r(
375
- S.div,
376
- {
377
- initial: { opacity: 0, scale: 0.95 },
378
- animate: { opacity: 1, scale: 1 },
379
- exit: { opacity: 0, scale: 0.95 },
380
- transition: { duration: 0.2 },
381
- className: "relative bg-surface-container-high rounded-3xl shadow-2xl p-6 w-full max-w-[420px] flex flex-col gap-6",
382
- children: [
383
- /* @__PURE__ */ t(b, { variant: "title-medium", className: "font-bold", children: "Custom recurrence" }),
384
- /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
385
- /* @__PURE__ */ t(
386
- b,
387
- {
388
- variant: "body-medium",
389
- className: "shrink-0 w-24 font-medium",
390
- children: "Repeat every"
391
- }
392
- ),
393
- /* @__PURE__ */ t("div", { className: "w-20", children: /* @__PURE__ */ t(
394
- te,
395
- {
396
- size: "sm",
397
- variant: "filled",
398
- value: c.interval,
399
- onValueChange: (e) => u((n) => ({ ...n, interval: Number(e) })),
400
- min: 1,
401
- classNames: {
402
- inputWrapper: "h-10 min-h-[40px] px-2",
403
- input: "text-center"
404
- }
405
- }
406
- ) }),
407
- /* @__PURE__ */ t("div", { className: "flex-1", children: /* @__PURE__ */ t(
408
- ee,
409
- {
410
- size: "sm",
411
- variant: "filled",
412
- value: c.frequency,
413
- onValueChange: (e) => u((n) => ({ ...n, frequency: e })),
414
- items: [
415
- {
416
- value: "daily",
417
- label: c.interval > 1 ? "days" : "day"
418
- },
419
- {
420
- value: "weekly",
421
- label: c.interval > 1 ? "weeks" : "week"
422
- },
423
- {
424
- value: "monthly",
425
- label: c.interval > 1 ? "months" : "month"
426
- },
427
- {
428
- value: "yearly",
429
- label: c.interval > 1 ? "years" : "year"
430
- }
431
- ],
432
- classNames: { trigger: "h-10 px-3" }
433
- }
434
- ) })
435
- ] }),
436
- c.frequency === "weekly" && /* @__PURE__ */ r("div", { className: "flex flex-col gap-2 mt-2", children: [
437
- /* @__PURE__ */ t(b, { variant: "body-medium", className: "font-medium", children: "Repeat on" }),
438
- /* @__PURE__ */ t("div", { className: "flex justify-between mt-1 w-full", children: /* @__PURE__ */ t(ge, { shape: "full", gap: "xs", className: "w-full flex", children: ["S", "M", "T", "W", "T", "F", "S"].map((e, n) => {
439
- const l = c.daysOfWeek?.includes(n);
440
- return /* @__PURE__ */ t(
441
- x,
442
- {
443
- variant: l ? "primary" : "secondary",
444
- isActive: l,
445
- onClick: () => {
446
- u((p) => {
447
- const f = p.daysOfWeek || [], G = f.includes(n) ? f.filter((me) => me !== n) : [...f, n];
448
- return {
449
- ...p,
450
- daysOfWeek: G.length ? G : [n]
451
- };
452
- });
453
- },
454
- className: "flex-1 !px-0 min-w-0",
455
- children: e
456
- },
457
- n
458
- );
459
- }) }) })
460
- ] }),
461
- /* @__PURE__ */ r("div", { className: "flex flex-col gap-3 mt-2", children: [
462
- /* @__PURE__ */ t(b, { variant: "body-medium", className: "font-medium mb-1", children: "Ends" }),
463
- /* @__PURE__ */ r("div", { className: "flex flex-col gap-4", children: [
464
- /* @__PURE__ */ t(
465
- A,
466
- {
467
- checked: c.endType === "never",
468
- onChange: () => u((e) => ({ ...e, endType: "never" })),
469
- label: "Never"
470
- }
471
- ),
472
- /* @__PURE__ */ t(
473
- A,
474
- {
475
- checked: c.endType === "on_date",
476
- onChange: () => u((e) => ({ ...e, endType: "on_date" })),
477
- label: "On",
478
- children: /* @__PURE__ */ t("div", { className: "w-[180px]", children: /* @__PURE__ */ t(
479
- z,
480
- {
481
- variant: "docked",
482
- inputVariant: "filled",
483
- size: "sm",
484
- disabled: c.endType !== "on_date",
485
- value: c.until,
486
- onChange: (e) => e && u((n) => ({ ...n, until: e })),
487
- classNames: { inputWrapper: "h-10 min-h-[40px]" }
488
- }
489
- ) })
490
- }
491
- ),
492
- /* @__PURE__ */ t(
493
- A,
494
- {
495
- checked: c.endType === "after_occurrences",
496
- onChange: () => u((e) => ({
497
- ...e,
498
- endType: "after_occurrences"
499
- })),
500
- label: "After",
501
- children: /* @__PURE__ */ r("div", { className: "w-[180px] flex items-center gap-3", children: [
502
- /* @__PURE__ */ t(
503
- te,
504
- {
505
- variant: "filled",
506
- size: "sm",
507
- disabled: c.endType !== "after_occurrences",
508
- value: c.count,
509
- onValueChange: (e) => u((n) => ({ ...n, count: Number(e) })),
510
- min: 1,
511
- classNames: {
512
- inputWrapper: "h-10 min-h-[40px] px-2",
513
- input: "text-center"
514
- }
515
- }
516
- ),
517
- /* @__PURE__ */ t(
518
- b,
519
- {
520
- variant: "body-medium",
521
- className: "whitespace-nowrap opacity-80 font-normal",
522
- children: "occurrences"
523
- }
524
- )
525
- ] })
526
- }
527
- )
528
- ] })
241
+ k && /* @__PURE__ */ a("div", { className: "mt-2 border-t border-outline-variant/30 pt-4 flex flex-col gap-4", children: k(t, x) }),
242
+ C && /* @__PURE__ */ a("div", { className: "mt-2 border-t border-outline-variant/30 pt-4 flex flex-col gap-4", children: C(t, x) })
243
+ ] });
244
+ return i.isOpen ? c ? /* @__PURE__ */ a(
245
+ te,
246
+ {
247
+ open: i.isOpen,
248
+ onOpenChange: (e) => !e && l(),
249
+ forceBottomSheet: !0,
250
+ snapPoints: [0.6, 1],
251
+ activeSnapPoint: X,
252
+ setActiveSnapPoint: G,
253
+ children: /* @__PURE__ */ s(ae, { className: "p-0 flex flex-col overflow-hidden h-full", children: [
254
+ /* @__PURE__ */ s(re, { className: "px-4 py-2 border-b border-outline-variant/20 shrink-0 flex-row justify-between items-center !space-y-0", children: [
255
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
256
+ /* @__PURE__ */ a(u, { variant: "ghost", onClick: l, children: /* @__PURE__ */ a(z, { className: "w-5 h-5" }) }),
257
+ /* @__PURE__ */ a(ne, { className: "text-base font-semibold m-0", children: i.mode === "create" ? "New Event" : "Edit Event" })
529
258
  ] }),
530
- /* @__PURE__ */ r("div", { className: "flex justify-end gap-2 pt-4", children: [
531
- /* @__PURE__ */ t(
532
- x,
533
- {
534
- variant: "ghost",
535
- onClick: () => O(!1),
536
- children: "Cancel"
537
- }
538
- ),
539
- /* @__PURE__ */ t(
540
- x,
541
- {
542
- variant: "primary",
543
- onClick: () => {
544
- m({ recurrence: c }), O(!1);
545
- },
546
- children: "Done"
547
- }
548
- )
549
- ] })
550
- ]
551
- }
552
- )
553
- ] }) });
554
- if (!i.isOpen) return null;
555
- if (v)
556
- return /* @__PURE__ */ r(R, { children: [
557
- /* @__PURE__ */ t(
558
- we,
559
- {
560
- open: i.isOpen,
561
- onOpenChange: (e) => !e && o(),
562
- forceBottomSheet: !0,
563
- snapPoints: [0.6, 1],
564
- activeSnapPoint: se,
565
- setActiveSnapPoint: oe,
566
- children: /* @__PURE__ */ r(be, { className: "p-0 flex flex-col overflow-hidden h-full", children: [
567
- /* @__PURE__ */ r(Ne, { className: "px-4 py-2 border-b border-outline-variant/20 shrink-0 flex-row justify-between items-center !space-y-0", children: [
568
- /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
569
- /* @__PURE__ */ t(w, { variant: "ghost", onClick: o, children: /* @__PURE__ */ t(U, { className: "w-5 h-5" }) }),
570
- /* @__PURE__ */ t(ke, { className: "text-base font-semibold m-0", children: i.mode === "create" ? "New Event" : "Edit Event" })
571
- ] }),
572
- i.mode === "edit" && /* @__PURE__ */ t(
573
- w,
574
- {
575
- variant: "ghost",
576
- size: "sm",
577
- onClick: j,
578
- className: "text-error hover:bg-error/10 hover:text-error",
579
- children: /* @__PURE__ */ t(J, { className: "w-5 h-5" })
580
- }
581
- )
582
- ] }),
583
- /* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto no-scrollbar", children: B }),
584
- /* @__PURE__ */ t("div", { className: "p-3 border-t border-outline-variant/20 bg-surface-container shrink-0 flex justify-end items-center pb-safe", children: /* @__PURE__ */ t(
585
- x,
586
- {
587
- variant: "primary",
588
- onClick: $,
589
- className: "px-8 rounded-full font-bold",
590
- children: "Save"
591
- }
592
- ) })
593
- ] })
594
- }
595
- ),
596
- typeof document < "u" && P(I, document.body)
597
- ] });
598
- const de = /* @__PURE__ */ t("div", { className: "fixed inset-0 pointer-events-none z-[50]", children: /* @__PURE__ */ t(Q, { children: i.isOpen && /* @__PURE__ */ r(
599
- S.div,
259
+ i.mode === "edit" && /* @__PURE__ */ a(
260
+ u,
261
+ {
262
+ variant: "ghost",
263
+ size: "sm",
264
+ onClick: M,
265
+ className: "text-error hover:bg-error/10 hover:text-error",
266
+ children: /* @__PURE__ */ a(H, { className: "w-5 h-5" })
267
+ }
268
+ )
269
+ ] }),
270
+ /* @__PURE__ */ a("div", { className: "flex-1 overflow-y-auto no-scrollbar", children: S }),
271
+ /* @__PURE__ */ a("div", { className: "p-3 border-t border-outline-variant/20 bg-surface-container shrink-0 flex justify-end items-center pb-safe", children: /* @__PURE__ */ a(
272
+ A,
273
+ {
274
+ variant: "primary",
275
+ onClick: P,
276
+ className: "px-8 rounded-full font-bold",
277
+ children: "Save"
278
+ }
279
+ ) })
280
+ ] })
281
+ }
282
+ ) : /* @__PURE__ */ a("div", { className: "fixed inset-0 pointer-events-none z-[50]", children: /* @__PURE__ */ a(_, { children: i.isOpen && /* @__PURE__ */ s(
283
+ q.div,
600
284
  {
601
- ref: E,
285
+ ref: g,
602
286
  drag: !0,
603
287
  dragMomentum: !1,
604
- dragControls: _,
288
+ dragControls: F,
605
289
  dragListener: !1,
606
290
  style: {
607
- x: D,
608
- y: C,
291
+ x: p,
292
+ y: v,
609
293
  width: "auto",
610
- minWidth: N,
294
+ minWidth: f,
611
295
  maxWidth: "calc(100vw - 32px)"
612
296
  },
613
297
  initial: { opacity: 0, scale: 0.95 },
@@ -616,66 +300,62 @@ const N = 380, Oe = (s, i) => {
616
300
  transition: { duration: 0.15 },
617
301
  className: "absolute bg-surface-container-high border border-outline-variant/50 rounded-2xl shadow-2xl pointer-events-auto flex flex-col h-auto max-h-[90vh]",
618
302
  children: [
619
- /* @__PURE__ */ r(
303
+ /* @__PURE__ */ s(
620
304
  "div",
621
305
  {
622
306
  onPointerDown: (e) => {
623
- e.stopPropagation(), _.start(e);
307
+ e.stopPropagation(), F.start(e);
624
308
  },
625
309
  className: "flex items-center justify-between px-2 py-1.5 bg-surface-container-high border-b border-outline-variant/20 drag-handle cursor-move rounded-t-2xl shrink-0",
626
310
  children: [
627
- /* @__PURE__ */ t(
628
- w,
311
+ /* @__PURE__ */ a(
312
+ u,
629
313
  {
630
314
  variant: "ghost",
631
315
  size: "sm",
632
316
  className: "pointer-events-none opacity-50",
633
- children: /* @__PURE__ */ t(ye, { className: "w-4 h-4" })
317
+ children: /* @__PURE__ */ a(Z, { className: "w-4 h-4" })
634
318
  }
635
319
  ),
636
- /* @__PURE__ */ r("div", { className: "flex items-center gap-1", children: [
637
- i.mode === "edit" && a && /* @__PURE__ */ t(
638
- w,
320
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-1", children: [
321
+ i.mode === "edit" && t && /* @__PURE__ */ a(
322
+ u,
639
323
  {
640
324
  variant: "ghost",
641
325
  size: "sm",
642
- onClick: j,
326
+ onClick: M,
643
327
  className: "text-error hover:bg-error/10 hover:text-error cursor-pointer pointer-events-auto",
644
- children: /* @__PURE__ */ t(J, { className: "w-4 h-4" })
328
+ children: /* @__PURE__ */ a(H, { className: "w-4 h-4" })
645
329
  }
646
330
  ),
647
- /* @__PURE__ */ t(
648
- w,
331
+ /* @__PURE__ */ a(
332
+ u,
649
333
  {
650
334
  variant: "ghost",
651
335
  size: "sm",
652
- onClick: o,
336
+ onClick: l,
653
337
  className: "pointer-events-auto hover:bg-surface-container-highest cursor-pointer",
654
- children: /* @__PURE__ */ t(U, { className: "w-4 h-4" })
338
+ children: /* @__PURE__ */ a(z, { className: "w-4 h-4" })
655
339
  }
656
340
  )
657
341
  ] })
658
342
  ]
659
343
  }
660
344
  ),
661
- /* @__PURE__ */ t("div", { className: "flex-1 max-h-[80vh] overflow-y-auto scrollbar-thin overflow-x-hidden min-h-0", children: B }),
662
- /* @__PURE__ */ t("div", { className: "flex items-center justify-end gap-2 p-4 border-t border-outline-variant/20 bg-surface-container-high shrink-0 rounded-b-2xl", children: /* @__PURE__ */ t(
663
- x,
345
+ /* @__PURE__ */ a("div", { className: "flex-1 max-h-[80vh] overflow-y-auto scrollbar-thin overflow-x-hidden min-h-0", children: S }),
346
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-end gap-2 p-4 border-t border-outline-variant/20 bg-surface-container-high shrink-0 rounded-b-2xl", children: /* @__PURE__ */ a(
347
+ A,
664
348
  {
665
349
  variant: "primary",
666
- onClick: $,
350
+ onClick: P,
667
351
  className: "px-6 rounded-full font-bold",
668
352
  children: "Save"
669
353
  }
670
354
  ) })
671
355
  ]
672
356
  }
673
- ) }) });
674
- return /* @__PURE__ */ r(R, { children: [
675
- typeof document < "u" && P(de, document.body),
676
- typeof document < "u" && P(I, document.body)
677
- ] });
357
+ ) }) }) : null;
678
358
  };
679
359
  export {
680
- Xe as EventPopover
360
+ ye as EventPopover
681
361
  };