chesai-ui 0.16.12 → 0.16.13

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,4 +1,4 @@
1
- import { jsxs as y, jsx as i } from "react/jsx-runtime";
1
+ import { jsxs as y, jsx as s } from "react/jsx-runtime";
2
2
  import { useVirtualizer as N } from "@tanstack/react-virtual";
3
3
  import { clsx as x } from "clsx";
4
4
  import { startOfMonth as D, isBefore as M, addMonths as I, endOfMonth as T, eachDayOfInterval as k, getDay as S, format as b, isSameDay as u, isAfter as z, isToday as j } from "date-fns";
@@ -17,7 +17,7 @@ const v = C(
17
17
  return k({ start: n, end: o });
18
18
  }, [r]), h = g(() => S(d[0]), [d]);
19
19
  return /* @__PURE__ */ y("div", { className: "mb-4 px-4", children: [
20
- /* @__PURE__ */ i(
20
+ /* @__PURE__ */ s(
21
21
  A,
22
22
  {
23
23
  variant: "label-large",
@@ -26,27 +26,27 @@ const v = C(
26
26
  }
27
27
  ),
28
28
  /* @__PURE__ */ y("div", { className: "grid grid-cols-7 gap-y-2", children: [
29
- Array.from({ length: h }).map((n, o) => /* @__PURE__ */ i("div", {}, `empty-${o}`)),
29
+ Array.from({ length: h }).map((n, o) => /* @__PURE__ */ s("div", {}, `empty-${o}`)),
30
30
  d.map((n) => {
31
31
  const o = n.toISOString();
32
- let l = !1, s = !1, f = !1, p = !1;
32
+ let l = !1, i = !1, f = !1, p = !1;
33
33
  if (c === "single" && a instanceof Date)
34
34
  l = u(n, a);
35
35
  else if (c === "range") {
36
36
  const e = a;
37
- e?.from && (s = u(n, e.from)), e?.to && (f = u(n, e.to)), e?.from && e?.to && (p = z(n, e.from) && M(n, e.to));
37
+ e?.from && (i = u(n, e.from)), e?.to && (f = u(n, e.to)), e?.from && e?.to && (p = z(n, e.from) && M(n, e.to));
38
38
  }
39
39
  const t = j(n);
40
- return /* @__PURE__ */ i(
40
+ return /* @__PURE__ */ s(
41
41
  "div",
42
42
  {
43
43
  className: x(
44
44
  "relative flex aspect-square items-center justify-center p-0",
45
45
  p && "bg-secondary-container/30",
46
- s && "bg-gradient-to-r from-transparent to-secondary-container/30",
47
- f && "bg-gradient-to-l from-transparent to-secondary-container/30"
46
+ i && "bg-gradient-to-r rtl:bg-gradient-to-l from-transparent to-secondary-container/30",
47
+ f && "bg-gradient-to-l rtl:bg-gradient-to-r from-transparent to-secondary-container/30"
48
48
  ),
49
- children: /* @__PURE__ */ i(
49
+ children: /* @__PURE__ */ s(
50
50
  "button",
51
51
  {
52
52
  type: "button",
@@ -54,11 +54,11 @@ const v = C(
54
54
  className: x(
55
55
  "relative z-10 flex h-9 w-9 items-center justify-center rounded-full text-sm font-medium transition-colors",
56
56
  // Selected State
57
- l || s || f ? "bg-primary text-on-primary shadow-sm" : "text-on-surface",
57
+ l || i || f ? "bg-primary text-on-primary shadow-sm" : "text-on-surface",
58
58
  // Today State
59
- !l && !s && !f && t && "border border-primary text-primary font-bold",
60
- // Hover State (only if not selected)
61
- !l && !s && !f && "hover:bg-surface-container-highest"
59
+ !l && !i && !f && t && "border border-primary text-primary font-bold",
60
+ // Hover State
61
+ !l && !i && !f && "hover:bg-surface-container-highest"
62
62
  ),
63
63
  children: b(n, "d")
64
64
  }
@@ -70,7 +70,6 @@ const v = C(
70
70
  ] })
71
71
  ] });
72
72
  },
73
- // Custom comparison function for React.memo to strictly prevent re-renders
74
73
  (r, a) => r.monthDate.getTime() === a.monthDate.getTime() && r.value === a.value && r.mode === a.mode
75
74
  );
76
75
  v.displayName = "MonthGrid";
@@ -94,17 +93,15 @@ const W = ({
94
93
  return o.findIndex(
95
94
  (e) => e.getFullYear() === (t || /* @__PURE__ */ new Date()).getFullYear() && e.getMonth() === (t || /* @__PURE__ */ new Date()).getMonth()
96
95
  );
97
- }, [o, r, m]), s = N({
96
+ }, [o, r, m]), i = N({
98
97
  count: o.length,
99
98
  getScrollElement: () => n.current,
100
99
  estimateSize: () => 340,
101
- // Consistent height estimate
102
100
  overscan: 1,
103
- // Reduced overscan for performance (renders fewer invisible items)
104
101
  initialOffset: l !== -1 ? l * 340 : 0
105
102
  });
106
103
  O(() => {
107
- l !== -1 && n.current && s.scrollToIndex(l, { align: "start" });
104
+ l !== -1 && n.current && i.scrollToIndex(l, { align: "start" });
108
105
  }, []);
109
106
  const f = (t) => {
110
107
  if (m === "single")
@@ -115,7 +112,7 @@ const W = ({
115
112
  }
116
113
  };
117
114
  return /* @__PURE__ */ y("div", { className: "flex h-full w-full flex-col bg-surface-container", children: [
118
- /* @__PURE__ */ i("div", { className: "grid shrink-0 grid-cols-7 border-b border-outline-variant/50 bg-surface-container-high px-4 py-2 z-20", children: ["S", "M", "T", "W", "T", "F", "S"].map((t, e) => /* @__PURE__ */ i(
115
+ /* @__PURE__ */ s("div", { className: "grid shrink-0 grid-cols-7 border-b border-outline-variant/50 bg-surface-container-high px-4 py-2 z-20", children: ["S", "M", "T", "W", "T", "F", "S"].map((t, e) => /* @__PURE__ */ s(
119
116
  "div",
120
117
  {
121
118
  className: "flex h-8 items-center justify-center text-xs font-bold text-on-surface-variant",
@@ -123,29 +120,29 @@ const W = ({
123
120
  },
124
121
  e
125
122
  )) }),
126
- /* @__PURE__ */ i(
123
+ /* @__PURE__ */ s(
127
124
  F,
128
125
  {
129
126
  ref: n,
130
127
  className: "flex-1 overflow-y-auto pt-2 contain-strict",
131
- children: /* @__PURE__ */ i(
128
+ children: /* @__PURE__ */ s(
132
129
  "div",
133
130
  {
134
131
  style: {
135
- height: `${s.getTotalSize()}px`,
132
+ height: `${i.getTotalSize()}px`,
136
133
  width: "100%",
137
134
  position: "relative"
138
135
  },
139
- children: s.getVirtualItems().map((t) => /* @__PURE__ */ i(
136
+ children: i.getVirtualItems().map((t) => /* @__PURE__ */ s(
140
137
  "div",
141
138
  {
142
139
  "data-index": t.index,
143
- ref: s.measureElement,
140
+ ref: i.measureElement,
144
141
  className: "absolute top-0 left-0 w-full",
145
142
  style: {
146
143
  transform: `translateY(${t.start}px)`
147
144
  },
148
- children: /* @__PURE__ */ i(
145
+ children: /* @__PURE__ */ s(
149
146
  v,
150
147
  {
151
148
  monthDate: o[t.index],
@@ -1,9 +1,9 @@
1
- import { jsxs as w, Fragment as M, jsx as m } from "react/jsx-runtime";
1
+ import { jsxs as M, Fragment as p, jsx as m } from "react/jsx-runtime";
2
2
  import { format as f } from "date-fns";
3
- import { useState as v, useMemo as h } from "react";
4
- import { Select as W } from "../select/index.mjs";
5
- import { RecurrenceDialog as $ } from "./recurrence-dialog.mjs";
6
- const O = (e, a) => {
3
+ import { useState as W, useMemo as h } from "react";
4
+ import { Select as $ } from "../select/index.mjs";
5
+ import { RecurrenceDialog as v } from "./recurrence-dialog.mjs";
6
+ const O = (e, l) => {
7
7
  const n = e.frequency, t = e.interval;
8
8
  let o = "";
9
9
  if (t > 1 ? o = `Every ${t} ${n === "daily" ? "days" : n === "weekly" ? "weeks" : n === "monthly" ? "months" : "years"}` : o = n === "daily" ? "Daily" : n === "weekly" ? "Weekly" : n === "monthly" ? "Monthly" : "Annually", n === "weekly" && e.daysOfWeek && e.daysOfWeek.length > 0) {
@@ -16,7 +16,7 @@ const O = (e, a) => {
16
16
  "Friday",
17
17
  "Saturday"
18
18
  ];
19
- e.daysOfWeek.length === 7 ? o = t > 1 ? `Every ${t} weeks on all days` : "Every day" : e.daysOfWeek.length === 5 && [1, 2, 3, 4, 5].every((l) => e.daysOfWeek.includes(l)) ? o = t > 1 ? `Every ${t} weeks on weekdays` : "Every weekday (Monday to Friday)" : o += ` on ${e.daysOfWeek.map((l) => s[l]).join(", ")}`;
19
+ e.daysOfWeek.length === 7 ? o = t > 1 ? `Every ${t} weeks on all days` : "Every day" : e.daysOfWeek.length === 5 && [1, 2, 3, 4, 5].every((a) => e.daysOfWeek.includes(a)) ? o = t > 1 ? `Every ${t} weeks on weekdays` : "Every weekday (Monday to Friday)" : o += ` on ${e.daysOfWeek.map((a) => s[a]).join(", ")}`;
20
20
  } else if (n === "monthly")
21
21
  if (e.monthDay)
22
22
  o += ` on day ${e.monthDay}`;
@@ -29,29 +29,29 @@ const O = (e, a) => {
29
29
  "Thursday",
30
30
  "Friday",
31
31
  "Saturday"
32
- ], l = ["", "first", "second", "third", "fourth", "fifth"], { dayOfWeek: r, nth: i } = e.nthDayOfWeek;
33
- o += ` on ${i === -1 ? "the last" : `the ${l[i]}`} ${s[r]}`;
32
+ ], a = ["", "first", "second", "third", "fourth", "fifth"], { dayOfWeek: c, nth: i } = e.nthDayOfWeek;
33
+ o += ` on ${i === -1 ? "the last" : `the ${a[i]}`} ${s[c]}`;
34
34
  } else
35
- o += ` on day ${a.getDate()}`;
36
- else n === "yearly" && (o += ` on ${f(a, "MMM d")}`);
35
+ o += ` on day ${l.getDate()}`;
36
+ else n === "yearly" && (o += ` on ${f(l, "MMM d")}`);
37
37
  return e.endType === "on_date" && e.until ? o += `, until ${f(e.until, "MMM d, yyyy")}` : e.endType === "after_occurrences" && e.count && (o += `, for ${e.count} occurrences`), o;
38
- }, F = ({
38
+ }, _ = ({
39
39
  value: e,
40
- onChange: a,
40
+ onChange: l,
41
41
  startDate: n,
42
42
  variant: t = "filled",
43
43
  size: o = "sm",
44
44
  shape: s = "full",
45
- className: l
45
+ className: a
46
46
  }) => {
47
- const [r, i] = v(!1), c = h(() => {
47
+ const [c, i] = W(!1), d = h(() => {
48
48
  if (!e) return "none";
49
- const { frequency: y, interval: k, endType: g, daysOfWeek: d } = e;
50
- if (k === 1 && g === "never") {
49
+ const { frequency: y, interval: k, endType: w, daysOfWeek: r } = e;
50
+ if (k === 1 && w === "never") {
51
51
  if (y === "daily") return "daily";
52
- if (y === "weekly" && d?.length === 1 && d[0] === n.getDay())
52
+ if (y === "weekly" && r?.length === 1 && r[0] === n.getDay())
53
53
  return "weekly";
54
- if (y === "weekly" && d?.length === 5 && [1, 2, 3, 4, 5].every((p) => d.includes(p)))
54
+ if (y === "weekly" && r?.length === 5 && [1, 2, 3, 4, 5].every((g) => r.includes(g)))
55
55
  return "weekdays";
56
56
  if (y === "monthly" && e.monthDay === n.getDate())
57
57
  return "monthly";
@@ -63,64 +63,56 @@ const O = (e, a) => {
63
63
  const y = [
64
64
  { value: "none", label: "Does not repeat" },
65
65
  { value: "daily", label: "Daily" },
66
- {
67
- value: "weekly",
68
- label: `Weekly on ${f(n, "EEEE")}`
69
- },
70
- {
71
- value: "monthly",
72
- label: `Monthly on the ${n.getDate()}`
73
- },
74
- {
75
- value: "yearly",
76
- label: `Annually on ${f(n, "MMM d")}`
77
- },
78
- { value: "weekdays", label: "Every weekday (Monday to Friday)" }
66
+ { value: "weekly", label: `Weekly on ${f(n, "EEEE")}` },
67
+ { value: "monthly", label: `Monthly on the ${n.getDate()}` },
68
+ { value: "yearly", label: `Annually on ${f(n, "MMM d")}` },
69
+ { value: "weekdays", label: "Every weekday (Monday to Friday)" },
70
+ { value: "custom", label: "Custom..." }
79
71
  ];
80
- return c === "custom_active" && e && y.push({
72
+ return d === "custom_active" && e && y.push({
81
73
  value: "custom_active",
82
74
  label: O(e, n)
83
- }), y.push({ value: "custom", label: "Custom..." }), y;
84
- }, [n, c, e]);
85
- return /* @__PURE__ */ w(M, { children: [
75
+ }), y;
76
+ }, [n, d, e]);
77
+ return /* @__PURE__ */ M(p, { children: [
86
78
  /* @__PURE__ */ m(
87
- W,
79
+ $,
88
80
  {
89
81
  variant: t,
90
82
  size: o,
91
83
  shape: s,
92
- value: c,
84
+ value: d,
93
85
  onValueChange: (y) => {
94
- y === "none" ? a(void 0) : y === "custom" ? i(!0) : y === "weekdays" ? a({
86
+ y !== d && (y === "none" ? l(void 0) : y === "custom" ? i(!0) : y === "weekdays" ? l({
95
87
  frequency: "weekly",
96
88
  interval: 1,
97
89
  endType: "never",
98
90
  daysOfWeek: [1, 2, 3, 4, 5]
99
- }) : y !== "custom_active" && a({
91
+ }) : ["daily", "weekly", "monthly", "yearly"].includes(y) && l({
100
92
  frequency: y,
101
93
  interval: 1,
102
94
  endType: "never",
103
95
  daysOfWeek: y === "weekly" ? [n.getDay()] : void 0,
104
96
  monthDay: y === "monthly" ? n.getDate() : void 0,
105
97
  month: y === "yearly" ? n.getMonth() + 1 : void 0
106
- });
98
+ }));
107
99
  },
108
100
  items: u,
109
- className: l
101
+ className: a
110
102
  }
111
103
  ),
112
104
  /* @__PURE__ */ m(
113
- $,
105
+ v,
114
106
  {
115
- isOpen: r,
107
+ isOpen: c,
116
108
  onClose: () => i(!1),
117
109
  value: e,
118
- onChange: a,
110
+ onChange: l,
119
111
  startDate: n
120
112
  }
121
113
  )
122
114
  ] });
123
115
  };
124
116
  export {
125
- F as RecurrenceSelect
117
+ _ as RecurrenceSelect
126
118
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "chesai-ui",
3
3
  "private": false,
4
- "version": "0.16.12",
4
+ "version": "0.16.13",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/ayhamdev/chesai-ui"