@nayhoo/ui 0.9.2 → 0.9.3
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.
- package/README.md +1 -1
- package/dist/{chunk-T3GW2EMR.mjs → chunk-2TMFRLMM.mjs} +1 -1
- package/dist/{chunk-T3GW2EMR.mjs.map → chunk-2TMFRLMM.mjs.map} +1 -1
- package/dist/{chunk-ZNKUE6YY.mjs → chunk-3STUDMUG.mjs} +1 -1
- package/dist/{chunk-ZNKUE6YY.mjs.map → chunk-3STUDMUG.mjs.map} +1 -1
- package/dist/{chunk-64TEKDKL.mjs → chunk-52RVZRC4.mjs} +2 -2
- package/dist/{chunk-MXFGBAZU.mjs → chunk-54ZBX4ZK.mjs} +1 -1
- package/dist/{chunk-MXFGBAZU.mjs.map → chunk-54ZBX4ZK.mjs.map} +1 -1
- package/dist/{chunk-G4YCF3A2.mjs → chunk-AIOSEM6O.mjs} +1 -1
- package/dist/{chunk-G4YCF3A2.mjs.map → chunk-AIOSEM6O.mjs.map} +1 -1
- package/dist/{chunk-QEBSZEY2.mjs → chunk-HFMY3EF3.mjs} +1 -1
- package/dist/{chunk-QEBSZEY2.mjs.map → chunk-HFMY3EF3.mjs.map} +1 -1
- package/dist/{chunk-SOIEM2O2.mjs → chunk-L3WLGNH2.mjs} +1 -1
- package/dist/{chunk-SOIEM2O2.mjs.map → chunk-L3WLGNH2.mjs.map} +1 -1
- package/dist/{chunk-DC6VQ7BG.mjs → chunk-LF6VSYRD.mjs} +2 -2
- package/dist/{chunk-IEZTYE5I.mjs → chunk-M6OYH5UA.mjs} +1 -1
- package/dist/{chunk-IEZTYE5I.mjs.map → chunk-M6OYH5UA.mjs.map} +1 -1
- package/dist/{chunk-5RLHLI27.mjs → chunk-MT2IF4CB.mjs} +3 -3
- package/dist/{chunk-GGJKRS5V.mjs → chunk-PIOIL3MF.mjs} +2 -2
- package/dist/{chunk-3HV65JYW.mjs → chunk-RD6HAWH5.mjs} +1 -1
- package/dist/{chunk-3HV65JYW.mjs.map → chunk-RD6HAWH5.mjs.map} +1 -1
- package/dist/{chunk-HRXZ3ELS.mjs → chunk-SC6WBBXG.mjs} +1 -1
- package/dist/{chunk-HRXZ3ELS.mjs.map → chunk-SC6WBBXG.mjs.map} +1 -1
- package/dist/{chunk-YO4LZRGU.mjs → chunk-SI36SYJ2.mjs} +1 -1
- package/dist/{chunk-YO4LZRGU.mjs.map → chunk-SI36SYJ2.mjs.map} +1 -1
- package/dist/{chunk-JI6FRWSC.mjs → chunk-TF5DXR26.mjs} +3 -3
- package/dist/{chunk-PGCB7RGD.mjs → chunk-TPPKQCXG.mjs} +1 -1
- package/dist/{chunk-PGCB7RGD.mjs.map → chunk-TPPKQCXG.mjs.map} +1 -1
- package/dist/{chunk-6UOQ737G.mjs → chunk-UVLWN6WJ.mjs} +1 -1
- package/dist/{chunk-6UOQ737G.mjs.map → chunk-UVLWN6WJ.mjs.map} +1 -1
- package/dist/{chunk-RYAY35UB.mjs → chunk-WUIQQ7C2.mjs} +2 -2
- package/dist/{chunk-DERDJR33.mjs → chunk-YCHYGF5R.mjs} +1 -1
- package/dist/{chunk-DERDJR33.mjs.map → chunk-YCHYGF5R.mjs.map} +1 -1
- package/dist/{chunk-6N652IDI.mjs → chunk-YFXFSV23.mjs} +1 -1
- package/dist/{chunk-6N652IDI.mjs.map → chunk-YFXFSV23.mjs.map} +1 -1
- package/dist/{chunk-IQLI5J2V.mjs → chunk-YZNF3EIN.mjs} +1 -1
- package/dist/{chunk-IQLI5J2V.mjs.map → chunk-YZNF3EIN.mjs.map} +1 -1
- package/dist/components/avatar.css +1 -1
- package/dist/components/avatar.css.map +1 -1
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/avatar.mjs +1 -1
- package/dist/components/badge.css +1 -1
- package/dist/components/badge.css.map +1 -1
- package/dist/components/badge.js.map +1 -1
- package/dist/components/badge.mjs +1 -1
- package/dist/components/button.css +2 -2
- package/dist/components/button.css.map +1 -1
- package/dist/components/button.js.map +1 -1
- package/dist/components/button.mjs +4 -4
- package/dist/components/checkbox.css +1 -1
- package/dist/components/checkbox.css.map +1 -1
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/checkbox.mjs +1 -1
- package/dist/components/dropdown-menu.css +2 -2
- package/dist/components/dropdown-menu.css.map +1 -1
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/dropdown-menu.mjs +3 -3
- package/dist/components/flex.css +1 -1
- package/dist/components/flex.css.map +1 -1
- package/dist/components/flex.js.map +1 -1
- package/dist/components/flex.mjs +2 -2
- package/dist/components/grid.css +1 -1
- package/dist/components/grid.css.map +1 -1
- package/dist/components/grid.js.map +1 -1
- package/dist/components/grid.mjs +1 -1
- package/dist/components/heading.css +1 -1
- package/dist/components/heading.css.map +1 -1
- package/dist/components/heading.js.map +1 -1
- package/dist/components/heading.mjs +2 -2
- package/dist/components/icon-button.css +2 -2
- package/dist/components/icon-button.css.map +1 -1
- package/dist/components/icon-button.js.map +1 -1
- package/dist/components/icon-button.mjs +4 -4
- package/dist/components/label.css +1 -1
- package/dist/components/label.css.map +1 -1
- package/dist/components/label.js.map +1 -1
- package/dist/components/label.mjs +1 -1
- package/dist/components/link.css +1 -1
- package/dist/components/link.css.map +1 -1
- package/dist/components/link.js.map +1 -1
- package/dist/components/link.mjs +1 -1
- package/dist/components/menu.css +2 -2
- package/dist/components/menu.css.map +1 -1
- package/dist/components/menu.js.map +1 -1
- package/dist/components/menu.mjs +3 -3
- package/dist/components/paragraph.css +1 -1
- package/dist/components/paragraph.css.map +1 -1
- package/dist/components/paragraph.js.map +1 -1
- package/dist/components/paragraph.mjs +1 -1
- package/dist/components/select.css +2 -2
- package/dist/components/select.css.map +1 -1
- package/dist/components/select.js.map +1 -1
- package/dist/components/select.mjs +2 -2
- package/dist/components/skeleton.css +1 -1
- package/dist/components/skeleton.css.map +1 -1
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/skeleton.mjs +1 -1
- package/dist/components/spinner.css +1 -1
- package/dist/components/spinner.css.map +1 -1
- package/dist/components/spinner.js.map +1 -1
- package/dist/components/spinner.mjs +2 -2
- package/dist/components/switch.css +1 -1
- package/dist/components/switch.css.map +1 -1
- package/dist/components/switch.js.map +1 -1
- package/dist/components/switch.mjs +1 -1
- package/dist/components/text-field.css +1 -1
- package/dist/components/text-field.css.map +1 -1
- package/dist/components/text-field.js.map +1 -1
- package/dist/components/text-field.mjs +1 -1
- package/dist/components/text.css +1 -1
- package/dist/components/text.css.map +1 -1
- package/dist/components/text.js.map +1 -1
- package/dist/components/text.mjs +2 -2
- package/dist/components/tooltip.css +1 -1
- package/dist/components/tooltip.css.map +1 -1
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/tooltip.mjs +2 -2
- package/dist/providers/index.css +8 -8
- package/dist/providers/index.css.map +1 -1
- package/dist/providers/index.d.mts +13 -11
- package/dist/providers/index.d.ts +13 -11
- package/dist/providers/index.js +71 -35
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/index.mjs +82 -46
- package/dist/providers/index.mjs.map +1 -1
- package/dist/theme/index.css +20 -20
- package/dist/theme/index.css.map +1 -1
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/index.mjs +15 -15
- package/dist/theme/index.mjs.map +1 -1
- package/package.json +1 -1
- /package/dist/{chunk-64TEKDKL.mjs.map → chunk-52RVZRC4.mjs.map} +0 -0
- /package/dist/{chunk-DC6VQ7BG.mjs.map → chunk-LF6VSYRD.mjs.map} +0 -0
- /package/dist/{chunk-5RLHLI27.mjs.map → chunk-MT2IF4CB.mjs.map} +0 -0
- /package/dist/{chunk-GGJKRS5V.mjs.map → chunk-PIOIL3MF.mjs.map} +0 -0
- /package/dist/{chunk-JI6FRWSC.mjs.map → chunk-TF5DXR26.mjs.map} +0 -0
- /package/dist/{chunk-RYAY35UB.mjs.map → chunk-WUIQQ7C2.mjs.map} +0 -0
|
@@ -3,25 +3,27 @@ import * as react from 'react';
|
|
|
3
3
|
import react__default from 'react';
|
|
4
4
|
import * as ToastPrimitives from '@radix-ui/react-toast';
|
|
5
5
|
|
|
6
|
-
type
|
|
6
|
+
type theme = "light" | "dark" | "system";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
type ThemeContextProps = {
|
|
9
|
+
theme: theme;
|
|
10
|
+
setTheme: react__default.Dispatch<react__default.SetStateAction<theme>>;
|
|
11
|
+
themes: theme[];
|
|
12
|
+
};
|
|
13
|
+
declare const ThemeContext: react__default.Context<ThemeContextProps>;
|
|
9
14
|
type ThemeProviderProps = {
|
|
10
15
|
children: react__default.ReactNode;
|
|
11
|
-
|
|
16
|
+
defaultTheme?: theme;
|
|
12
17
|
};
|
|
13
|
-
|
|
14
|
-
* This component applies the theme css. It should preferably be used at the root of your component tree.
|
|
15
|
-
*/
|
|
16
|
-
declare const ThemeProvider: ({ children, themeMode, }: ThemeProviderProps) => react_jsx_runtime.JSX.Element;
|
|
18
|
+
declare const ThemeProvider: ({ children }: ThemeProviderProps) => react_jsx_runtime.JSX.Element;
|
|
17
19
|
|
|
18
20
|
type AddToastPayload = Omit<Toast, "status">;
|
|
19
|
-
type
|
|
21
|
+
type ToastProviderContextProps = ((payload: AddToastPayload) => void) & {
|
|
20
22
|
error: (payload: AddToastPayload) => void;
|
|
21
23
|
success: (payload: AddToastPayload) => void;
|
|
22
24
|
};
|
|
23
|
-
declare const
|
|
24
|
-
declare const
|
|
25
|
+
declare const ToastProviderContext: react.Context<ToastProviderContextProps>;
|
|
26
|
+
declare const ToastProvider: ({ children, ...props }: ToastPrimitives.ToastProviderProps) => react_jsx_runtime.JSX.Element;
|
|
25
27
|
type Toast = {
|
|
26
28
|
title?: string;
|
|
27
29
|
description?: string;
|
|
@@ -33,4 +35,4 @@ declare const Toast: (props: ToastPrimitives.ToastProps & {
|
|
|
33
35
|
}) => react_jsx_runtime.JSX.Element;
|
|
34
36
|
declare const ToastAction: ({ ...props }: Omit<ToastPrimitives.ToastActionProps, "asChild">) => react_jsx_runtime.JSX.Element;
|
|
35
37
|
|
|
36
|
-
export { ThemeContext, ThemeProvider, ToastAction,
|
|
38
|
+
export { ThemeContext, ThemeProvider, ToastAction, ToastProvider, ToastProviderContext };
|
|
@@ -3,25 +3,27 @@ import * as react from 'react';
|
|
|
3
3
|
import react__default from 'react';
|
|
4
4
|
import * as ToastPrimitives from '@radix-ui/react-toast';
|
|
5
5
|
|
|
6
|
-
type
|
|
6
|
+
type theme = "light" | "dark" | "system";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
type ThemeContextProps = {
|
|
9
|
+
theme: theme;
|
|
10
|
+
setTheme: react__default.Dispatch<react__default.SetStateAction<theme>>;
|
|
11
|
+
themes: theme[];
|
|
12
|
+
};
|
|
13
|
+
declare const ThemeContext: react__default.Context<ThemeContextProps>;
|
|
9
14
|
type ThemeProviderProps = {
|
|
10
15
|
children: react__default.ReactNode;
|
|
11
|
-
|
|
16
|
+
defaultTheme?: theme;
|
|
12
17
|
};
|
|
13
|
-
|
|
14
|
-
* This component applies the theme css. It should preferably be used at the root of your component tree.
|
|
15
|
-
*/
|
|
16
|
-
declare const ThemeProvider: ({ children, themeMode, }: ThemeProviderProps) => react_jsx_runtime.JSX.Element;
|
|
18
|
+
declare const ThemeProvider: ({ children }: ThemeProviderProps) => react_jsx_runtime.JSX.Element;
|
|
17
19
|
|
|
18
20
|
type AddToastPayload = Omit<Toast, "status">;
|
|
19
|
-
type
|
|
21
|
+
type ToastProviderContextProps = ((payload: AddToastPayload) => void) & {
|
|
20
22
|
error: (payload: AddToastPayload) => void;
|
|
21
23
|
success: (payload: AddToastPayload) => void;
|
|
22
24
|
};
|
|
23
|
-
declare const
|
|
24
|
-
declare const
|
|
25
|
+
declare const ToastProviderContext: react.Context<ToastProviderContextProps>;
|
|
26
|
+
declare const ToastProvider: ({ children, ...props }: ToastPrimitives.ToastProviderProps) => react_jsx_runtime.JSX.Element;
|
|
25
27
|
type Toast = {
|
|
26
28
|
title?: string;
|
|
27
29
|
description?: string;
|
|
@@ -33,4 +35,4 @@ declare const Toast: (props: ToastPrimitives.ToastProps & {
|
|
|
33
35
|
}) => react_jsx_runtime.JSX.Element;
|
|
34
36
|
declare const ToastAction: ({ ...props }: Omit<ToastPrimitives.ToastActionProps, "asChild">) => react_jsx_runtime.JSX.Element;
|
|
35
37
|
|
|
36
|
-
export { ThemeContext, ThemeProvider, ToastAction,
|
|
38
|
+
export { ThemeContext, ThemeProvider, ToastAction, ToastProvider, ToastProviderContext };
|
package/dist/providers/index.js
CHANGED
|
@@ -33,27 +33,11 @@ __export(providers_exports, {
|
|
|
33
33
|
ThemeContext: () => ThemeContext,
|
|
34
34
|
ThemeProvider: () => ThemeProvider,
|
|
35
35
|
ToastAction: () => ToastAction,
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
ToastProvider: () => ToastProvider,
|
|
37
|
+
ToastProviderContext: () => ToastProviderContext
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(providers_exports);
|
|
40
40
|
|
|
41
|
-
// src/hooks/use-body-class-toggle.ts
|
|
42
|
-
var import_react = require("react");
|
|
43
|
-
var useBodyClassToggle = (className, condition) => {
|
|
44
|
-
(0, import_react.useEffect)(() => {
|
|
45
|
-
const { body } = document;
|
|
46
|
-
if (condition) {
|
|
47
|
-
body.classList.add(className);
|
|
48
|
-
} else {
|
|
49
|
-
body.classList.remove(className);
|
|
50
|
-
}
|
|
51
|
-
return () => {
|
|
52
|
-
body.classList.remove(className);
|
|
53
|
-
};
|
|
54
|
-
}, [className, condition]);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
41
|
// src/theme/themes/dark-theme.css.ts
|
|
58
42
|
var darkTheme = "dark-theme__1mh7hnp0";
|
|
59
43
|
|
|
@@ -61,17 +45,69 @@ var darkTheme = "dark-theme__1mh7hnp0";
|
|
|
61
45
|
var lightTheme = "light-theme__6in2mz0";
|
|
62
46
|
|
|
63
47
|
// src/providers/theme-provider.tsx
|
|
64
|
-
var
|
|
48
|
+
var import_react = require("react");
|
|
65
49
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
66
|
-
var
|
|
67
|
-
var
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
50
|
+
var themes = ["light", "dark", "system"];
|
|
51
|
+
var storageKey = "nayhoo-theme";
|
|
52
|
+
var ThemeContext = (0, import_react.createContext)({
|
|
53
|
+
theme: "system",
|
|
54
|
+
setTheme: () => {
|
|
55
|
+
},
|
|
56
|
+
themes
|
|
57
|
+
});
|
|
58
|
+
var defaultTheme = "system";
|
|
59
|
+
var ThemeProvider = ({ children }) => {
|
|
60
|
+
const [theme, setTheme] = (0, import_react.useState)(() => getTheme());
|
|
61
|
+
const applyTheme = (theme2) => {
|
|
62
|
+
var _a, _b, _c, _d;
|
|
63
|
+
const isDark = theme2 === "dark";
|
|
64
|
+
const isSystem = theme2 === "system";
|
|
65
|
+
if (isDark || (isSystem || !(storageKey in localStorage)) && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
66
|
+
(_a = document.querySelector("html")) == null ? void 0 : _a.classList.add(darkTheme);
|
|
67
|
+
(_b = document.querySelector("html")) == null ? void 0 : _b.classList.remove(lightTheme);
|
|
68
|
+
} else {
|
|
69
|
+
(_c = document.querySelector("html")) == null ? void 0 : _c.classList.add(lightTheme);
|
|
70
|
+
(_d = document.querySelector("html")) == null ? void 0 : _d.classList.remove(darkTheme);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
(0, import_react.useEffect)(() => {
|
|
74
|
+
applyTheme(theme);
|
|
75
|
+
try {
|
|
76
|
+
localStorage.setItem(storageKey, theme);
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
}, [theme]);
|
|
80
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ThemeContext, { value: { theme, setTheme, themes }, children: [
|
|
81
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("script", { children: `
|
|
82
|
+
const isDark = localStorage.getItem("${storageKey}") === "dark";
|
|
83
|
+
const isSystem = localStorage.getItem("${storageKey}") === "system";
|
|
84
|
+
|
|
85
|
+
if (
|
|
86
|
+
isDark ||
|
|
87
|
+
((isSystem || !("${storageKey}" in localStorage)) &&
|
|
88
|
+
window.matchMedia("(prefers-color-scheme: dark)").matches)
|
|
89
|
+
) {
|
|
90
|
+
document.querySelector("html")?.classList.add("${darkTheme}");
|
|
91
|
+
document.querySelector("html")?.classList.remove("${lightTheme}");
|
|
92
|
+
} else {
|
|
93
|
+
document.querySelector("html")?.classList.add("${lightTheme}");
|
|
94
|
+
document.querySelector("html")?.classList.remove("${darkTheme}");
|
|
95
|
+
}
|
|
96
|
+
` }),
|
|
97
|
+
children
|
|
98
|
+
] });
|
|
99
|
+
};
|
|
100
|
+
var getTheme = () => {
|
|
101
|
+
var _a;
|
|
102
|
+
if (typeof window === "undefined") {
|
|
103
|
+
return defaultTheme;
|
|
104
|
+
}
|
|
105
|
+
let theme;
|
|
106
|
+
try {
|
|
107
|
+
theme = localStorage.getItem(storageKey) || void 0;
|
|
108
|
+
} catch {
|
|
109
|
+
}
|
|
110
|
+
return (_a = themes.find((t) => t === theme)) != null ? _a : defaultTheme;
|
|
75
111
|
};
|
|
76
112
|
|
|
77
113
|
// src/theme/recipes/spinner.css.ts
|
|
@@ -210,19 +246,19 @@ var toastInner = "toaster_toastInner__3jyebm5";
|
|
|
210
246
|
var toastRoot = "toaster_toastRoot__3jyebm4";
|
|
211
247
|
var toastViewport = "toaster_toastViewport__3jyebm3";
|
|
212
248
|
|
|
213
|
-
// src/providers/
|
|
249
|
+
// src/providers/toast-provider.tsx
|
|
214
250
|
var import_react_icons = require("@radix-ui/react-icons");
|
|
215
251
|
var ToastPrimitives = __toESM(require("@radix-ui/react-toast"));
|
|
216
252
|
var React2 = __toESM(require("react"));
|
|
217
253
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
218
|
-
var
|
|
254
|
+
var defaultToast = Object.assign(() => {
|
|
219
255
|
}, {
|
|
220
256
|
success: () => {
|
|
221
257
|
},
|
|
222
258
|
error: () => {
|
|
223
259
|
}
|
|
224
260
|
});
|
|
225
|
-
var
|
|
261
|
+
var ToastProviderContext = React2.createContext(defaultToast);
|
|
226
262
|
var toastElementsMapRef = React2.createRef();
|
|
227
263
|
var defaultToastImpl = {
|
|
228
264
|
toastElementsMapRef,
|
|
@@ -231,7 +267,7 @@ var defaultToastImpl = {
|
|
|
231
267
|
};
|
|
232
268
|
var ToastContextImpl = React2.createContext(defaultToastImpl);
|
|
233
269
|
var ANIMATION_OUT_DURATION = 350;
|
|
234
|
-
var
|
|
270
|
+
var ToastProvider = ({
|
|
235
271
|
children,
|
|
236
272
|
...props
|
|
237
273
|
}) => {
|
|
@@ -320,7 +356,7 @@ var Toaster = ({
|
|
|
320
356
|
}),
|
|
321
357
|
[handleDispatchDefault, handleDispatchSuccess, handleDispatchError]
|
|
322
358
|
);
|
|
323
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
359
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ToastProviderContext.Provider, { value: toastApi, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
324
360
|
ToastContextImpl.Provider,
|
|
325
361
|
{
|
|
326
362
|
value: React2.useMemo(
|
|
@@ -434,7 +470,7 @@ var ToastAction = ({
|
|
|
434
470
|
ThemeContext,
|
|
435
471
|
ThemeProvider,
|
|
436
472
|
ToastAction,
|
|
437
|
-
|
|
438
|
-
|
|
473
|
+
ToastProvider,
|
|
474
|
+
ToastProviderContext
|
|
439
475
|
});
|
|
440
476
|
//# sourceMappingURL=index.js.map
|