@appcorp/shadcn 1.0.11 → 1.0.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.
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ interface CustomThemeProviderProps {
3
+ children: React.ReactNode;
4
+ defaultTheme?: string;
5
+ storageKey?: string;
6
+ enableSystem?: boolean;
7
+ }
8
+ export declare function ThemeProvider({ children, defaultTheme, storageKey, enableSystem, ...props }: CustomThemeProviderProps): React.JSX.Element;
9
+ export {};
@@ -0,0 +1,122 @@
1
+ "use client";
2
+ "use strict";
3
+ var __assign = (this && this.__assign) || function () {
4
+ __assign = Object.assign || function(t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
+ t[p] = s[p];
9
+ }
10
+ return t;
11
+ };
12
+ return __assign.apply(this, arguments);
13
+ };
14
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ var desc = Object.getOwnPropertyDescriptor(m, k);
17
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
+ desc = { enumerable: true, get: function() { return m[k]; } };
19
+ }
20
+ Object.defineProperty(o, k2, desc);
21
+ }) : (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ }));
25
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
26
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
27
+ }) : function(o, v) {
28
+ o["default"] = v;
29
+ });
30
+ var __importStar = (this && this.__importStar) || (function () {
31
+ var ownKeys = function(o) {
32
+ ownKeys = Object.getOwnPropertyNames || function (o) {
33
+ var ar = [];
34
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
35
+ return ar;
36
+ };
37
+ return ownKeys(o);
38
+ };
39
+ return function (mod) {
40
+ if (mod && mod.__esModule) return mod;
41
+ var result = {};
42
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
43
+ __setModuleDefault(result, mod);
44
+ return result;
45
+ };
46
+ })();
47
+ var __rest = (this && this.__rest) || function (s, e) {
48
+ var t = {};
49
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
50
+ t[p] = s[p];
51
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
52
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
53
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
54
+ t[p[i]] = s[p[i]];
55
+ }
56
+ return t;
57
+ };
58
+ Object.defineProperty(exports, "__esModule", { value: true });
59
+ exports.ThemeProvider = ThemeProvider;
60
+ var react_1 = __importStar(require("react"));
61
+ var next_themes_1 = require("next-themes");
62
+ var themes_1 = require("../lib/themes");
63
+ // Component that applies theme variables when theme changes
64
+ function ThemeApplier(_a) {
65
+ var children = _a.children;
66
+ var _b = (0, next_themes_1.useTheme)(), theme = _b.theme, resolvedTheme = _b.resolvedTheme;
67
+ (0, react_1.useEffect)(function () {
68
+ var applyTheme = function (themeName) {
69
+ var themeConfig = themes_1.themes[themeName];
70
+ if (!themeConfig) {
71
+ console.warn("Theme \"".concat(themeName, "\" not found, falling back to light theme"));
72
+ // Fallback to light theme
73
+ var lightTheme = themes_1.themes.light;
74
+ if (lightTheme) {
75
+ var root_1 = document.documentElement;
76
+ Object.entries(lightTheme.colors).forEach(function (_a) {
77
+ var key = _a[0], value = _a[1];
78
+ root_1.style.setProperty("--".concat(key), value);
79
+ });
80
+ }
81
+ return;
82
+ }
83
+ var root = document.documentElement;
84
+ // Apply theme colors as CSS variables
85
+ Object.entries(themeConfig.colors).forEach(function (_a) {
86
+ var key = _a[0], value = _a[1];
87
+ root.style.setProperty("--".concat(key), value);
88
+ });
89
+ // Add theme class to root element for CSS selectors
90
+ root.className = root.className.replace(/theme-\w+/g, "");
91
+ root.classList.add("theme-".concat(themeName));
92
+ // Also set data-theme attribute for CSS selectors
93
+ root.setAttribute("data-theme", themeName);
94
+ };
95
+ // Apply theme on mount and when theme changes
96
+ var activeTheme = resolvedTheme || theme || "light";
97
+ // Always apply theme, even if it's "system" - fallback to light
98
+ var themeToApply = activeTheme === "system" ? "light" : activeTheme;
99
+ applyTheme(themeToApply);
100
+ }, [theme, resolvedTheme]);
101
+ // Apply default theme on mount
102
+ (0, react_1.useEffect)(function () {
103
+ // Apply light theme as default on first mount
104
+ var applyDefaultTheme = function () {
105
+ var lightTheme = themes_1.themes.light;
106
+ if (lightTheme) {
107
+ var root_2 = document.documentElement;
108
+ Object.entries(lightTheme.colors).forEach(function (_a) {
109
+ var key = _a[0], value = _a[1];
110
+ root_2.style.setProperty("--".concat(key), value);
111
+ });
112
+ }
113
+ };
114
+ applyDefaultTheme();
115
+ }, []); // Run only once on mount
116
+ return react_1.default.createElement(react_1.default.Fragment, null, children);
117
+ }
118
+ function ThemeProvider(_a) {
119
+ var children = _a.children, _b = _a.defaultTheme, defaultTheme = _b === void 0 ? "light" : _b, _c = _a.storageKey, storageKey = _c === void 0 ? "ui-theme" : _c, _d = _a.enableSystem, enableSystem = _d === void 0 ? false : _d, props = __rest(_a, ["children", "defaultTheme", "storageKey", "enableSystem"]);
120
+ return (react_1.default.createElement(next_themes_1.ThemeProvider, __assign({ attribute: "data-theme", defaultTheme: defaultTheme, storageKey: storageKey, enableSystem: enableSystem, themes: Object.keys(themes_1.themes) }, props),
121
+ react_1.default.createElement(ThemeApplier, null, children)));
122
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/shadcn",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "scripts": {
5
5
  "build:next": "next build",
6
6
  "build:storybook": "storybook build -c .storybook -o .out",