saha-ui 1.21.0 → 1.22.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.
@@ -6,7 +6,7 @@ declare const aspectRatioVariants: (props?: ({
6
6
  * Overlay gradient variants
7
7
  */
8
8
  declare const overlayVariants: (props?: ({
9
- position?: "top" | "left" | "center" | "right" | "bottom" | null | undefined;
9
+ position?: "top" | "left" | "right" | "bottom" | "center" | null | undefined;
10
10
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
11
11
  export { aspectRatioVariants, overlayVariants };
12
12
  //# sourceMappingURL=AspectRatio.styles.d.ts.map
@@ -56,7 +56,7 @@ export declare const formSectionTitleVariants: (props?: ({
56
56
  * Form actions variants
57
57
  */
58
58
  export declare const formActionsVariants: (props?: ({
59
- align?: "left" | "center" | "right" | "between" | null | undefined;
59
+ align?: "left" | "right" | "center" | "between" | null | undefined;
60
60
  variant?: "error" | "primary" | "secondary" | "success" | "warning" | "info" | "default" | "glass" | "accent" | "outline" | null | undefined;
61
61
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
62
62
  //# sourceMappingURL=Form.styles.d.ts.map
@@ -10,7 +10,7 @@ declare const tableHeaderVariants: (props?: ({
10
10
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
11
11
  declare const tableCellVariants: (props?: ({
12
12
  density?: "normal" | "compact" | "comfortable" | null | undefined;
13
- align?: "left" | "center" | "right" | null | undefined;
13
+ align?: "left" | "right" | "center" | null | undefined;
14
14
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
15
15
  declare const tableRowVariants: (props?: ({
16
16
  hoverable?: boolean | null | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ThemeToggle/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAI3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAYvD,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAqUlD,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ThemeToggle/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAI3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAYvD,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAkZlD,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,177 +1,210 @@
1
- import { jsxs as g, jsx as t } from "react/jsx-runtime";
2
- import A, { useState as b, useRef as F, useEffect as h } from "react";
3
- import { createPortal as G } from "react-dom";
4
- import { Sun as J, Moon as K, Monitor as Q, ChevronDown as U } from "lucide-react";
5
- import { useTheme as Z } from "../ThemeProvider/ThemeProvider.js";
6
- import { cn as d } from "../../lib/utils.js";
7
- import { themeToggleIconVariants as ee, themeToggleIconWrap as te, themeLabelVariants as ne, themeToggleButtonVariants as oe, themeOptionVariants as S, themeDropdownVariants as j } from "./ThemeToggle.styles.js";
8
- const me = ({
9
- className: P = "",
10
- size: T = 20,
11
- variant: s = "icon",
12
- color: k = "primary",
13
- appearance: V = "default",
14
- menuBg: Y = "default",
1
+ import { jsxs as x, jsx as i } from "react/jsx-runtime";
2
+ import Q, { useState as w, useRef as U, useEffect as g } from "react";
3
+ import { createPortal as Z } from "react-dom";
4
+ import { Sun as ee, Moon as te, Monitor as ne, ChevronDown as oe } from "lucide-react";
5
+ import { useTheme as ie } from "../ThemeProvider/ThemeProvider.js";
6
+ import { cn as p } from "../../lib/utils.js";
7
+ import { themeToggleIconVariants as re, themeToggleIconWrap as le, themeLabelVariants as ae, themeToggleButtonVariants as se, themeOptionVariants as X, themeDropdownVariants as j } from "./ThemeToggle.styles.js";
8
+ const we = ({
9
+ className: V = "",
10
+ size: H = 20,
11
+ variant: m = "icon",
12
+ color: P = "primary",
13
+ appearance: $ = "default",
14
+ menuBg: D = "default",
15
15
  menuBorder: E = "default",
16
16
  menuText: z = "default",
17
- menuClassName: D
17
+ menuClassName: _
18
18
  }) => {
19
- const { theme: f, setTheme: X } = Z(), [r, x] = b(!1), [N, _] = b(!1), m = F(null), [M, $] = b(
19
+ const { theme: b, setTheme: q } = ie(), [a, N] = w(!1), [T, A] = w(!1), s = U(null), [h, F] = w(
20
20
  null
21
- ), [a, O] = b({
21
+ ), [u, y] = w({
22
22
  top: 0,
23
23
  left: 0
24
- }), y = A.useRef(null);
25
- h(() => {
26
- _(!0);
27
- }, []), h(() => {
28
- const e = (n) => {
29
- m.current && !m.current.contains(n.target) && x(!1);
24
+ }), [G, Y] = w("left top"), C = Q.useRef(null);
25
+ g(() => {
26
+ A(!0);
27
+ }, []), g(() => {
28
+ const e = (o) => {
29
+ const t = o.target, c = o.composedPath?.() || [], d = s.current && (c.length ? c.includes(s.current) : s.current.contains(t)), n = h && (c.length ? c.includes(h) : h.contains(t));
30
+ d || n || s.current && !s.current.contains(t) && N(!1);
30
31
  };
31
- return r && document.addEventListener("mousedown", e), () => {
32
+ return a && document.addEventListener("mousedown", e), () => {
32
33
  document.removeEventListener("mousedown", e);
33
34
  };
34
- }, [r]), h(() => {
35
+ }, [a, h]), g(() => {
35
36
  const e = document.createElement("div");
36
- return document.body.appendChild(e), $(e), () => {
37
+ return document.body.appendChild(e), F(e), () => {
37
38
  e.parentNode && e.parentNode.removeChild(e);
38
39
  };
39
40
  }, []);
40
- const W = 3;
41
- h(() => {
42
- if (r && m.current) {
43
- const e = m.current.getBoundingClientRect(), o = {
41
+ const O = 3;
42
+ g(() => {
43
+ if (a && s.current) {
44
+ const e = s.current.getBoundingClientRect(), t = {
44
45
  icon: 176,
45
46
  "icon-label": 208
46
- }[s] ?? 200, u = Math.min(
47
- W * 48 + 16,
47
+ }[m] ?? 200, d = Math.min(
48
+ O * 48 + 16,
48
49
  400
49
- ), l = 8;
50
- let i = e.left + window.scrollX;
51
- if (i + o > window.innerWidth - l) {
52
- const v = e.right + window.scrollX - o;
53
- i = Math.max(
54
- l,
55
- Math.min(v, window.innerWidth - o - l)
50
+ ), n = 8;
51
+ let r = e.left + window.scrollX;
52
+ if (r + t > window.innerWidth - n) {
53
+ const f = e.right + window.scrollX - t;
54
+ r = Math.max(
55
+ n,
56
+ Math.min(f, window.innerWidth - t - n)
56
57
  );
57
58
  }
58
- let c = e.bottom + window.scrollY;
59
- if (c + u > window.scrollY + window.innerHeight - l) {
60
- const v = e.top + window.scrollY - u;
61
- c = Math.max(l, v);
59
+ let l = e.bottom + window.scrollY;
60
+ if (l + d > window.scrollY + window.innerHeight - n) {
61
+ const f = e.top + window.scrollY - d;
62
+ l = Math.max(n, f);
62
63
  }
63
- O({ top: c, left: i });
64
+ y({ top: l, left: r });
65
+ const W = r <= e.left ? "left" : "right", v = l >= e.bottom ? "top" : "bottom";
66
+ Y(`${W} ${v}`);
64
67
  }
65
- }, [r, s, W]), h(() => {
66
- if (!r || !y.current) return;
67
- const e = y.current, n = 8, o = m.current?.getBoundingClientRect();
68
- if (!o) return;
69
- const w = e.offsetWidth, u = e.offsetHeight;
70
- let l = a.left;
71
- if (l + w > window.innerWidth - n) {
72
- const c = o.right + window.scrollX - w;
73
- l = Math.max(
68
+ }, [a, m, O]);
69
+ const J = () => {
70
+ if (!s.current) return;
71
+ const e = s.current.getBoundingClientRect(), t = {
72
+ icon: 176,
73
+ "icon-label": 208
74
+ }[m] ?? 200, d = Math.min(
75
+ O * 48 + 16,
76
+ 400
77
+ ), n = 8;
78
+ let r = e.left + window.scrollX;
79
+ if (r + t > window.innerWidth - n) {
80
+ const f = e.right + window.scrollX - t;
81
+ r = Math.max(
74
82
  n,
75
- Math.min(c, window.innerWidth - w - n)
83
+ Math.min(f, window.innerWidth - t - n)
76
84
  );
77
85
  }
78
- l < n && (l = n);
79
- let i = a.top;
80
- if (i + u > window.scrollY + window.innerHeight - n) {
81
- const c = o.top + window.scrollY - u;
82
- i = Math.max(n, c);
86
+ let l = e.bottom + window.scrollY;
87
+ if (l + d > window.scrollY + window.innerHeight - n) {
88
+ const f = e.top + window.scrollY - d;
89
+ l = Math.max(n, f);
83
90
  }
84
- (Math.abs(l - a.left) > 1 || Math.abs(i - a.top) > 1) && O({ left: l, top: i });
85
- }, [r, M, a.left, a.top]);
86
- const p = [
87
- { value: "light", label: "Light", icon: J },
88
- { value: "dark", label: "Dark", icon: K },
89
- { value: "system", label: "System", icon: Q }
90
- ], C = p.find((e) => e.value === f) || p[0], q = C.icon, R = (e) => {
91
- X(e), x(!1);
92
- }, B = {
91
+ y({ top: l, left: r });
92
+ const W = r <= e.left ? "left" : "right", v = l >= e.bottom ? "top" : "bottom";
93
+ Y(`${W} ${v}`);
94
+ };
95
+ g(() => {
96
+ if (!a || !C.current) return;
97
+ const e = C.current, o = 8, t = s.current?.getBoundingClientRect();
98
+ if (!t) return;
99
+ const c = e.offsetWidth, d = e.offsetHeight;
100
+ let n = u.left;
101
+ if (n + c > window.innerWidth - o) {
102
+ const l = t.right + window.scrollX - c;
103
+ n = Math.max(
104
+ o,
105
+ Math.min(l, window.innerWidth - c - o)
106
+ );
107
+ }
108
+ n < o && (n = o);
109
+ let r = u.top;
110
+ if (r + d > window.scrollY + window.innerHeight - o) {
111
+ const l = t.top + window.scrollY - d;
112
+ r = Math.max(o, l);
113
+ }
114
+ (Math.abs(n - u.left) > 1 || Math.abs(r - u.top) > 1) && y({ left: n, top: r });
115
+ }, [a, h, u.left, u.top]);
116
+ const M = [
117
+ { value: "light", label: "Light", icon: ee },
118
+ { value: "dark", label: "Dark", icon: te },
119
+ { value: "system", label: "System", icon: ne }
120
+ ], k = M.find((e) => e.value === b) || M[0], K = k.icon, I = (e) => {
121
+ q(e), N(!1);
122
+ }, R = {
93
123
  default: "bg-white dark:bg-black",
94
124
  white: "bg-white",
95
125
  primary: "bg-primary",
96
126
  neutral: "bg-foreground"
97
- }, H = {
127
+ }, B = {
98
128
  default: "border border-white/6 dark:border-black/6",
99
129
  none: "border-0",
100
130
  primary: "border border-primary",
101
131
  neutral: "border border-muted"
102
- }, I = {
132
+ }, L = {
103
133
  default: "text-foreground",
104
134
  primary: "text-primary",
105
135
  neutral: "text-foreground"
106
- }, L = D || [
107
- B[Y] ?? B.default,
108
- H[E] ?? H.default,
109
- I[z] ?? I.default
136
+ }, S = _ || [
137
+ R[D] ?? R.default,
138
+ B[E] ?? B.default,
139
+ L[z] ?? L.default
110
140
  ].filter(Boolean).join(" ");
111
- return /* @__PURE__ */ g("div", { ref: m, className: "relative", children: [
112
- /* @__PURE__ */ g(
141
+ return /* @__PURE__ */ x("div", { ref: s, className: "relative", children: [
142
+ /* @__PURE__ */ x(
113
143
  "button",
114
144
  {
115
- onClick: () => x(!r),
116
- className: d(
117
- oe({ variant: s, appearance: V }),
118
- P
145
+ onClick: () => {
146
+ a || J(), N(!a);
147
+ },
148
+ className: p(
149
+ se({ variant: m, appearance: $ }),
150
+ V
119
151
  ),
120
152
  "aria-label": "Toggle theme",
121
- "aria-expanded": r,
122
- title: N ? `Current theme: ${C.label}` : "Toggle theme",
153
+ "aria-expanded": a,
154
+ title: T ? `Current theme: ${k.label}` : "Toggle theme",
123
155
  children: [
124
- /* @__PURE__ */ t("span", { className: d(te({ size: "md" })), children: N ? /* @__PURE__ */ t(
125
- q,
156
+ /* @__PURE__ */ i("span", { className: p(le({ size: "md" })), children: T ? /* @__PURE__ */ i(
157
+ K,
126
158
  {
127
- size: T,
128
- className: ee({ theme: f, color: k })
159
+ size: H,
160
+ className: re({ theme: b, color: P })
129
161
  }
130
- ) : /* @__PURE__ */ t(
162
+ ) : /* @__PURE__ */ i(
131
163
  "span",
132
164
  {
133
165
  "aria-hidden": "true",
134
- className: d(
166
+ className: p(
135
167
  "inline-block",
136
- T === 20 ? "w-5 h-5" : "w-4 h-4"
168
+ H === 20 ? "w-5 h-5" : "w-4 h-4"
137
169
  )
138
170
  }
139
171
  ) }),
140
- s === "icon-label" && /* @__PURE__ */ t("span", { className: ne({ color: k }), children: N ? C.label : /* @__PURE__ */ t("span", { "aria-hidden": "true", className: "inline-block w-12 h-4" }) }),
141
- s === "icon-label" && /* @__PURE__ */ t(U, { size: 14, className: "ml-1 text-muted-foreground" })
172
+ m === "icon-label" && /* @__PURE__ */ i("span", { className: ae({ color: P }), children: T ? k.label : /* @__PURE__ */ i("span", { "aria-hidden": "true", className: "inline-block w-12 h-4" }) }),
173
+ m === "icon-label" && /* @__PURE__ */ i(oe, { size: 14, className: "ml-1 text-muted-foreground" })
142
174
  ]
143
175
  }
144
176
  ),
145
- r && M ? G(
146
- /* @__PURE__ */ t(
177
+ a && h ? Z(
178
+ /* @__PURE__ */ i(
147
179
  "div",
148
180
  {
149
- ref: y,
150
- className: d(
151
- // disable animation when rendering into portal so menu appears exactly at position
152
- j({ variant: s, animated: "off" }),
153
- L
181
+ ref: C,
182
+ className: p(
183
+ // allow animation for portal-mounted menu; we'll set transform origin
184
+ j({ variant: m, animated: "on" }),
185
+ S
154
186
  ),
155
187
  style: {
156
188
  position: "absolute",
157
- top: a.top,
158
- left: a.left
189
+ top: u.top,
190
+ left: u.left,
191
+ transformOrigin: G
159
192
  },
160
193
  role: "menu",
161
- children: p.map((e) => {
162
- const n = e.icon, o = f === e.value;
163
- return /* @__PURE__ */ g(
194
+ children: M.map((e) => {
195
+ const o = e.icon, t = b === e.value;
196
+ return /* @__PURE__ */ x(
164
197
  "button",
165
198
  {
166
- onClick: () => R(e.value),
199
+ onClick: () => I(e.value),
167
200
  role: "menuitem",
168
- className: d(
169
- S({ selected: o })
201
+ className: p(
202
+ X({ selected: t })
170
203
  ),
171
204
  children: [
172
- /* @__PURE__ */ t("span", { className: "inline-flex items-center justify-center w-8 h-8 rounded-full bg-white/5", children: /* @__PURE__ */ t(n, { size: 16 }) }),
173
- /* @__PURE__ */ t("span", { className: "text-sm font-medium", children: e.label }),
174
- o && /* @__PURE__ */ t("span", { className: "ml-auto text-primary", children: "✓" })
205
+ /* @__PURE__ */ i("span", { className: "inline-flex items-center justify-center w-8 h-8 rounded-full bg-white/5", children: /* @__PURE__ */ i(o, { size: 16 }) }),
206
+ /* @__PURE__ */ i("span", { className: "text-sm font-medium", children: e.label }),
207
+ t && /* @__PURE__ */ i("span", { className: "ml-auto text-primary", children: "✓" })
175
208
  ]
176
209
  },
177
210
  e.value
@@ -179,29 +212,29 @@ const me = ({
179
212
  })
180
213
  }
181
214
  ),
182
- M
183
- ) : r && /* @__PURE__ */ t(
215
+ h
216
+ ) : a && /* @__PURE__ */ i(
184
217
  "div",
185
218
  {
186
- className: d(
187
- j({ variant: s }),
188
- L
219
+ className: p(
220
+ j({ variant: m }),
221
+ S
189
222
  ),
190
223
  role: "menu",
191
- children: p.map((e) => {
192
- const n = e.icon, o = f === e.value;
193
- return /* @__PURE__ */ g(
224
+ children: M.map((e) => {
225
+ const o = e.icon, t = b === e.value;
226
+ return /* @__PURE__ */ x(
194
227
  "button",
195
228
  {
196
- onClick: () => R(e.value),
229
+ onClick: () => I(e.value),
197
230
  role: "menuitem",
198
- className: d(
199
- S({ selected: o })
231
+ className: p(
232
+ X({ selected: t })
200
233
  ),
201
234
  children: [
202
- /* @__PURE__ */ t("span", { className: "inline-flex items-center justify-center w-8 h-8 rounded-full bg-white/5", children: /* @__PURE__ */ t(n, { size: 16 }) }),
203
- /* @__PURE__ */ t("span", { className: "text-sm font-medium", children: e.label }),
204
- o && /* @__PURE__ */ t("span", { className: "ml-auto text-primary", children: "✓" })
235
+ /* @__PURE__ */ i("span", { className: "inline-flex items-center justify-center w-8 h-8 rounded-full bg-white/5", children: /* @__PURE__ */ i(o, { size: 16 }) }),
236
+ /* @__PURE__ */ i("span", { className: "text-sm font-medium", children: e.label }),
237
+ t && /* @__PURE__ */ i("span", { className: "ml-auto text-primary", children: "✓" })
205
238
  ]
206
239
  },
207
240
  e.value
@@ -212,6 +245,6 @@ const me = ({
212
245
  ] });
213
246
  };
214
247
  export {
215
- me as ThemeToggle,
216
- me as default
248
+ we as ThemeToggle,
249
+ we as default
217
250
  };
@@ -1,9 +1,9 @@
1
1
  declare const timelineVariants: (props?: ({
2
2
  variant?: "default" | "glass" | "gradient" | "outlined" | "minimal" | null | undefined;
3
- position?: "left" | "alternate" | "right" | null | undefined;
3
+ position?: "left" | "right" | "alternate" | null | undefined;
4
4
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
5
5
  declare const timelineItemVariants: (props?: ({
6
- position?: "left" | "alternate" | "right" | null | undefined;
6
+ position?: "left" | "right" | "alternate" | null | undefined;
7
7
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
8
8
  declare const timelineDotVariants: (props?: ({
9
9
  status?: "error" | "success" | "warning" | "info" | "default" | "pending" | null | undefined;
@@ -9,7 +9,7 @@ export declare const tourSpotlightVariants: (props?: ({
9
9
  maskStyle?: "default" | "rounded" | "rect" | null | undefined;
10
10
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
11
11
  export declare const tourPopoverVariants: (props?: ({
12
- placement?: "top" | "left" | "center" | "right" | "bottom" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end" | "right-start" | "right-end" | null | undefined;
12
+ placement?: "top" | "left" | "right" | "bottom" | "center" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end" | "right-start" | "right-end" | null | undefined;
13
13
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
14
14
  export declare const tourHeaderVariants: (props?: ({} & import('class-variance-authority/types').ClassProp) | undefined) => string;
15
15
  export declare const tourTitleVariants: (props?: ({} & import('class-variance-authority/types').ClassProp) | undefined) => string;
@@ -26,7 +26,7 @@ export declare const tourButtonVariants: (props?: ({
26
26
  variant?: "secondary" | "default" | "outline" | "ghost" | null | undefined;
27
27
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
28
28
  export declare const tourArrowVariants: (props?: ({
29
- placement?: "top" | "left" | "center" | "right" | "bottom" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end" | "right-start" | "right-end" | null | undefined;
29
+ placement?: "top" | "left" | "right" | "bottom" | "center" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end" | "right-start" | "right-end" | null | undefined;
30
30
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
31
31
  export declare const tourCloseButtonVariants: (props?: ({} & import('class-variance-authority/types').ClassProp) | undefined) => string;
32
32
  //# sourceMappingURL=Tour.styles.d.ts.map
@@ -1,7 +1,7 @@
1
1
  export declare const typographyVariants: (props?: ({
2
2
  variant?: "small" | "blockquote" | "code" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "list" | "large" | "muted" | "lead" | "inlineCode" | null | undefined;
3
3
  color?: "error" | "primary" | "secondary" | "success" | "warning" | "info" | "default" | "muted" | "accent" | null | undefined;
4
- align?: "left" | "center" | "right" | "justify" | null | undefined;
4
+ align?: "left" | "right" | "center" | "justify" | null | undefined;
5
5
  weight?: "light" | "bold" | "black" | "normal" | "medium" | "thin" | "extralight" | "semibold" | "extrabold" | null | undefined;
6
6
  transform?: "none" | "capitalize" | "lowercase" | "uppercase" | null | undefined;
7
7
  decoration?: "none" | "overline" | "underline" | "lineThrough" | null | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saha-ui",
3
- "version": "1.21.0",
3
+ "version": "1.22.0",
4
4
  "description": "Ultra-modern React component library built with TypeScript, Tailwind CSS v4, and OKLCH colors",
5
5
  "type": "module",
6
6
  "license": "MIT",