chesai-ui 0.16.13 → 0.16.14

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,202 +1,250 @@
1
- import { startOfWeek as b, startOfMonth as W, endOfWeek as T, endOfMonth as H, addDays as w, startOfDay as d, isBefore as I, isAfter as x, differenceInDays as S, isSameDay as m, startOfYear as R, setMonth as Y, format as q } from "date-fns";
2
- import { RRule as p } from "rrule";
1
+ import { startOfWeek as S, startOfMonth as O, endOfWeek as W, endOfMonth as T, addDays as x, startOfDay as h, isBefore as H, isAfter as I, differenceInDays as k, isSameDay as b, startOfYear as C, setMonth as R, format as Y } from "date-fns";
2
+ import { RRule as w } from "rrule";
3
3
  const L = (t) => {
4
4
  switch (t) {
5
5
  case "primary":
6
- return "bg-surface-container-low";
6
+ return "bg-surface-container-low text-on-surface";
7
7
  case "secondary":
8
- return "bg-surface-container-high";
8
+ return "bg-surface-container-highest text-on-surface";
9
+ case "tertiary":
10
+ return "bg-tertiary-container text-on-tertiary-container";
11
+ case "high-contrast":
12
+ return "bg-inverse-surface text-inverse-on-surface";
9
13
  case "ghost":
10
- return "bg-transparent";
14
+ return "bg-transparent text-on-surface";
15
+ case "surface-container-lowest":
16
+ return "bg-surface-container-lowest text-on-surface";
17
+ case "surface-container-low":
18
+ return "bg-surface-container-low text-on-surface";
19
+ case "surface-container":
20
+ return "bg-surface-container text-on-surface";
21
+ case "surface-container-high":
22
+ return "bg-surface-container-high text-on-surface";
23
+ case "surface-container-highest":
24
+ return "bg-surface-container-highest text-on-surface";
11
25
  default:
12
- return "bg-surface";
26
+ return "bg-surface text-on-surface";
13
27
  }
14
28
  }, U = (t) => {
15
29
  switch (t) {
16
30
  case "primary":
17
- return "bg-surface-container-low";
31
+ return "bg-surface-container-low text-on-surface";
18
32
  case "secondary":
19
- return "bg-surface-container-high";
33
+ return "bg-surface-container-highest text-on-surface";
34
+ case "tertiary":
35
+ return "bg-tertiary-container text-on-tertiary-container";
36
+ case "high-contrast":
37
+ return "bg-inverse-surface text-inverse-on-surface";
20
38
  case "ghost":
21
- return "bg-surface/80 backdrop-blur-md";
39
+ return "bg-surface/80 backdrop-blur-md text-on-surface";
40
+ case "surface-container-lowest":
41
+ return "bg-surface-container-lowest text-on-surface";
42
+ case "surface-container-low":
43
+ return "bg-surface-container-low text-on-surface";
44
+ case "surface-container":
45
+ return "bg-surface-container text-on-surface";
46
+ case "surface-container-high":
47
+ return "bg-surface-container-high text-on-surface";
48
+ case "surface-container-highest":
49
+ return "bg-surface-container-highest text-on-surface";
22
50
  default:
23
- return "bg-surface";
51
+ return "bg-surface text-on-surface";
24
52
  }
25
- }, F = {
26
- daily: p.DAILY,
27
- weekly: p.WEEKLY,
28
- monthly: p.MONTHLY,
29
- yearly: p.YEARLY
30
- }, k = [
31
- p.SU,
53
+ }, _ = (t) => {
54
+ switch (t) {
55
+ case "ghost":
56
+ return "bg-transparent";
57
+ case "surface-container-lowest":
58
+ return "bg-surface-container-lowest";
59
+ case "surface-container-low":
60
+ return "bg-surface-container-low";
61
+ case "surface-container":
62
+ return "bg-surface-container-low/30";
63
+ case "surface-container-high":
64
+ return "bg-surface-container-low/50";
65
+ case "surface-container-highest":
66
+ return "bg-surface-container-low/70";
67
+ case "high-contrast":
68
+ return "bg-inverse-surface/5";
69
+ default:
70
+ return "bg-surface-container-low/30";
71
+ }
72
+ }, q = {
73
+ daily: w.DAILY,
74
+ weekly: w.WEEKLY,
75
+ monthly: w.MONTHLY,
76
+ yearly: w.YEARLY
77
+ }, M = [
78
+ w.SU,
32
79
  // 0
33
- p.MO,
80
+ w.MO,
34
81
  // 1
35
- p.TU,
82
+ w.TU,
36
83
  // 2
37
- p.WE,
84
+ w.WE,
38
85
  // 3
39
- p.TH,
86
+ w.TH,
40
87
  // 4
41
- p.FR,
88
+ w.FR,
42
89
  // 5
43
- p.SA
90
+ w.SA
44
91
  // 6
45
- ], _ = (t, l, i) => {
46
- const r = [];
47
- return t.forEach((o) => {
48
- if (!o.recurrence) {
49
- o.start <= i && o.end >= l && r.push(o);
92
+ ], K = (t, l, u) => {
93
+ const s = [];
94
+ return t.forEach((c) => {
95
+ if (!c.recurrence) {
96
+ c.start <= u && c.end >= l && s.push(c);
50
97
  return;
51
98
  }
52
99
  try {
53
- const s = o.recurrence, e = {
54
- freq: F[s.frequency],
55
- dtstart: o.start,
56
- interval: s.interval || 1
100
+ const e = c.recurrence, r = {
101
+ freq: q[e.frequency],
102
+ dtstart: c.start,
103
+ interval: e.interval || 1
57
104
  };
58
- if (s.endType === "on_date" && s.until ? e.until = s.until : s.endType === "after_occurrences" && s.count && (e.count = s.count), s.frequency === "weekly" && s.daysOfWeek && s.daysOfWeek.length > 0 && (e.byweekday = s.daysOfWeek.map((a) => k[a])), s.frequency === "monthly") {
59
- if (s.monthDay)
60
- e.bymonthday = s.monthDay;
61
- else if (s.nthDayOfWeek) {
62
- const { dayOfWeek: a, nth: h } = s.nthDayOfWeek;
63
- e.byweekday = k[a].nth(h);
105
+ if (e.endType === "on_date" && e.until ? r.until = e.until : e.endType === "after_occurrences" && e.count && (r.count = e.count), e.frequency === "weekly" && e.daysOfWeek && e.daysOfWeek.length > 0 && (r.byweekday = e.daysOfWeek.map((a) => M[a])), e.frequency === "monthly") {
106
+ if (e.monthDay)
107
+ r.bymonthday = e.monthDay;
108
+ else if (e.nthDayOfWeek) {
109
+ const { dayOfWeek: a, nth: g } = e.nthDayOfWeek;
110
+ r.byweekday = M[a].nth(g);
64
111
  }
65
112
  }
66
- if (s.frequency === "yearly") {
67
- if (s.month && (e.bymonth = s.month), s.monthDay)
68
- e.bymonthday = s.monthDay;
69
- else if (s.nthDayOfWeek) {
70
- const { dayOfWeek: a, nth: h } = s.nthDayOfWeek;
71
- e.byweekday = k[a].nth(h);
113
+ if (e.frequency === "yearly") {
114
+ if (e.month && (r.bymonth = e.month), e.monthDay)
115
+ r.bymonthday = e.monthDay;
116
+ else if (e.nthDayOfWeek) {
117
+ const { dayOfWeek: a, nth: g } = e.nthDayOfWeek;
118
+ r.byweekday = M[a].nth(g);
72
119
  }
73
120
  }
74
- const c = new p(e).between(l, i, !0), u = o.end.getTime() - o.start.getTime();
75
- c.forEach((a, h) => {
76
- r.push({
77
- ...o,
78
- id: `${o.id}-occ-${h}`,
121
+ const o = new w(r).between(l, u, !0), i = c.end.getTime() - c.start.getTime();
122
+ o.forEach((a, g) => {
123
+ s.push({
124
+ ...c,
125
+ id: `${c.id}-occ-${g}`,
79
126
  start: a,
80
- end: new Date(a.getTime() + u)
127
+ end: new Date(a.getTime() + i)
81
128
  });
82
129
  });
83
- } catch (s) {
84
- console.error("Failed to parse recurrence rule with rrule.js:", s), o.start <= i && o.end >= l && r.push(o);
130
+ } catch (e) {
131
+ console.error("Failed to parse recurrence rule with rrule.js:", e), c.start <= u && c.end >= l && s.push(c);
85
132
  }
86
- }), r;
87
- }, K = (t) => {
88
- const l = b(W(t));
89
- T(H(t));
90
- const i = [];
91
- let r = l;
92
- for (; i.length < 42; )
93
- i.push(r), r = w(r, 1);
94
- return i;
133
+ }), s;
134
+ }, P = (t) => {
135
+ const l = S(O(t));
136
+ W(T(t));
137
+ const u = [];
138
+ let s = l;
139
+ for (; u.length < 42; )
140
+ u.push(s), s = x(s, 1);
141
+ return u;
95
142
  }, V = (t) => {
96
- const l = b(t), i = [];
97
- let r = l;
98
- for (let o = 0; o < 7; o++)
99
- i.push(r), r = w(r, 1);
100
- return i;
143
+ const l = S(t), u = [];
144
+ let s = l;
145
+ for (let c = 0; c < 7; c++)
146
+ u.push(s), s = x(s, 1);
147
+ return u;
101
148
  }, $ = (t) => {
102
- const l = R(t), i = [];
103
- for (let r = 0; r < 12; r++)
104
- i.push(Y(l, r));
105
- return i;
149
+ const l = C(t), u = [];
150
+ for (let s = 0; s < 12; s++)
151
+ u.push(R(l, s));
152
+ return u;
106
153
  }, j = (t) => {
107
154
  const l = /* @__PURE__ */ new Set();
108
- return t.forEach((i) => {
109
- let r = d(i.start);
110
- const o = d(i.end);
111
- for (; r <= o; )
112
- l.add(q(r, "yyyy-MM-dd")), r = w(r, 1);
155
+ return t.forEach((u) => {
156
+ let s = h(u.start);
157
+ const c = h(u.end);
158
+ for (; s <= c; )
159
+ l.add(Y(s, "yyyy-MM-dd")), s = x(s, 1);
113
160
  }), l;
114
161
  }, A = (t, l) => {
115
162
  if (t.length === 0) return [];
116
- const i = d(t[0]), r = d(t[t.length - 1]), o = l.filter((e) => {
117
- const n = d(e.start), c = d(e.end);
118
- return I(n, w(r, 1)) && x(w(c, 1), i);
163
+ const u = h(t[0]), s = h(t[t.length - 1]), c = l.filter((r) => {
164
+ const n = h(r.start), o = h(r.end);
165
+ return H(n, x(s, 1)) && I(x(o, 1), u);
119
166
  });
120
- o.sort((e, n) => {
121
- const c = S(d(e.end), d(e.start)), u = S(d(n.end), d(n.start));
122
- return c !== u ? u - c : e.start.getTime() - n.start.getTime();
167
+ c.sort((r, n) => {
168
+ const o = k(h(r.end), h(r.start)), i = k(h(n.end), h(n.start));
169
+ return o !== i ? i - o : r.start.getTime() - n.start.getTime();
123
170
  });
124
- const s = [], g = {};
125
- for (let e = 0; e < t.length; e++) g[e] = /* @__PURE__ */ new Set();
126
- return o.forEach((e) => {
127
- const n = d(e.start), c = d(e.end);
128
- let u = t.findIndex((f) => m(f, n));
129
- u === -1 && (u = 0);
130
- let a = t.findIndex((f) => m(f, c));
171
+ const e = [], y = {};
172
+ for (let r = 0; r < t.length; r++) y[r] = /* @__PURE__ */ new Set();
173
+ return c.forEach((r) => {
174
+ const n = h(r.start), o = h(r.end);
175
+ let i = t.findIndex((f) => b(f, n));
176
+ i === -1 && (i = 0);
177
+ let a = t.findIndex((f) => b(f, o));
131
178
  a === -1 && (a = t.length - 1);
132
- const h = a - u + 1;
133
- let y = 1, E = !1;
134
- for (; !E; ) {
135
- E = !0;
136
- for (let f = u; f <= a; f++)
137
- if (g[f].has(y)) {
138
- E = !1, y++;
179
+ const g = a - i + 1;
180
+ let d = 1, p = !1;
181
+ for (; !p; ) {
182
+ p = !0;
183
+ for (let f = i; f <= a; f++)
184
+ if (y[f].has(d)) {
185
+ p = !1, d++;
139
186
  break;
140
187
  }
141
188
  }
142
- for (let f = u; f <= a; f++)
143
- g[f].add(y);
144
- s.push({
145
- event: e,
146
- colStart: u + 1,
147
- colSpan: h,
148
- row: y
189
+ for (let f = i; f <= a; f++)
190
+ y[f].add(d);
191
+ e.push({
192
+ event: r,
193
+ colStart: i + 1,
194
+ colSpan: g,
195
+ row: d
149
196
  });
150
- }), s;
197
+ }), e;
151
198
  }, N = (t, l) => {
152
- const i = d(t), r = l.filter((n) => {
199
+ const u = h(t), s = l.filter((n) => {
153
200
  if (n.isAllDay) return !1;
154
- const c = d(n.start), u = d(n.end);
155
- return i >= c && i <= u;
201
+ const o = h(n.start), i = h(n.end);
202
+ return u >= o && u <= i;
156
203
  });
157
- r.sort((n, c) => {
158
- const u = m(n.start, t) ? n.start.getHours() * 60 + n.start.getMinutes() : 0, a = m(c.start, t) ? c.start.getHours() * 60 + c.start.getMinutes() : 0;
159
- return u - a;
204
+ s.sort((n, o) => {
205
+ const i = b(n.start, t) ? n.start.getHours() * 60 + n.start.getMinutes() : 0, a = b(o.start, t) ? o.start.getHours() * 60 + o.start.getMinutes() : 0;
206
+ return i - a;
160
207
  });
161
- const o = [], s = [];
162
- let g = [], e = 0;
163
- return r.forEach((n) => {
164
- const c = m(n.start, t), u = m(n.end, t), a = c ? n.start.getHours() * 60 + n.start.getMinutes() : 0, h = u ? n.end.getHours() * 60 + n.end.getMinutes() : 1440;
165
- g.length === 0 ? (g.push(n), e = h) : a < e ? (g.push(n), e = Math.max(e, h)) : (s.push([...g]), g = [n], e = h);
166
- }), g.length > 0 && s.push(g), s.forEach((n) => {
167
- const c = [];
208
+ const c = [], e = [];
209
+ let y = [], r = 0;
210
+ return s.forEach((n) => {
211
+ const o = b(n.start, t), i = b(n.end, t), a = o ? n.start.getHours() * 60 + n.start.getMinutes() : 0, g = i ? n.end.getHours() * 60 + n.end.getMinutes() : 1440;
212
+ y.length === 0 ? (y.push(n), r = g) : a < r ? (y.push(n), r = Math.max(r, g)) : (e.push([...y]), y = [n], r = g);
213
+ }), y.length > 0 && e.push(y), e.forEach((n) => {
214
+ const o = [];
168
215
  n.forEach((a) => {
169
- const y = m(a.start, t) ? a.start.getHours() * 60 + a.start.getMinutes() : 0;
170
- let E = !1;
171
- for (let f = 0; f < c.length; f++) {
172
- const M = c[f][c[f].length - 1], D = m(M.end, t) ? M.end.getHours() * 60 + M.end.getMinutes() : 1440;
173
- if (y >= D) {
174
- c[f].push(a), E = !0;
216
+ const d = b(a.start, t) ? a.start.getHours() * 60 + a.start.getMinutes() : 0;
217
+ let p = !1;
218
+ for (let f = 0; f < o.length; f++) {
219
+ const m = o[f][o[f].length - 1], E = b(m.end, t) ? m.end.getHours() * 60 + m.end.getMinutes() : 1440;
220
+ if (d >= E) {
221
+ o[f].push(a), p = !0;
175
222
  break;
176
223
  }
177
224
  }
178
- E || c.push([a]);
225
+ p || o.push([a]);
179
226
  });
180
- const u = c.length;
181
- c.forEach((a, h) => {
182
- a.forEach((y) => {
183
- const E = m(y.start, t), f = m(y.end, t), M = E ? y.start.getHours() * 60 + y.start.getMinutes() : 0, O = f ? y.end.getHours() * 60 + y.end.getMinutes() : 1440, D = Math.max(O - M, 15);
184
- o.push({
185
- event: y,
186
- top: M / 1440 * 100,
187
- height: D / 1440 * 100,
188
- left: h / u * 100,
189
- width: 100 / u
227
+ const i = o.length;
228
+ o.forEach((a, g) => {
229
+ a.forEach((d) => {
230
+ const p = b(d.start, t), f = b(d.end, t), m = p ? d.start.getHours() * 60 + d.start.getMinutes() : 0, D = f ? d.end.getHours() * 60 + d.end.getMinutes() : 1440, E = Math.max(D - m, 15);
231
+ c.push({
232
+ event: d,
233
+ top: m / 1440 * 100,
234
+ height: E / 1440 * 100,
235
+ left: g / i * 100,
236
+ width: 100 / i
190
237
  });
191
238
  });
192
239
  });
193
- }), o;
240
+ }), c;
194
241
  };
195
242
  export {
196
- _ as expandEvents,
243
+ K as expandEvents,
197
244
  L as getCalendarBgClasses,
245
+ _ as getCalendarSidePanelBgClasses,
198
246
  U as getCalendarStickyBgClasses,
199
- K as getDaysForMonthView,
247
+ P as getDaysForMonthView,
200
248
  V as getDaysForWeekView,
201
249
  j as getEventDaysMap,
202
250
  A as getEventSegments,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "chesai-ui",
3
3
  "private": false,
4
- "version": "0.16.13",
4
+ "version": "0.16.14",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/ayhamdev/chesai-ui"