@appcorp/shadcn 1.1.25 → 1.1.28
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.
|
@@ -24,12 +24,7 @@ var EnhancedTableHeaderAction = function (_a) {
|
|
|
24
24
|
return (react_1.default.createElement("div", { key: action.id || action.key || index, className: "relative" },
|
|
25
25
|
react_1.default.createElement(button_1.Button, { variant: action.variant || "default", "data-testid": testIdActionPrefix
|
|
26
26
|
? "".concat(testIdActionPrefix, "-").concat(index)
|
|
27
|
-
: undefined, onClick: function () {
|
|
28
|
-
if (action.onClick)
|
|
29
|
-
action.onClick();
|
|
30
|
-
if (action.handleOnClick)
|
|
31
|
-
action.handleOnClick();
|
|
32
|
-
} }, action.label),
|
|
27
|
+
: undefined, onClick: function () { var _a; return (_a = action.handleOnClick) === null || _a === void 0 ? void 0 : _a.call(action, undefined); } }, action.label),
|
|
33
28
|
showFilterIndicators && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
34
29
|
react_1.default.createElement("div", { className: "absolute -top-2 -left-2 group" },
|
|
35
30
|
react_1.default.createElement(badge_1.Badge, { variant: "secondary", className: (0, utils_1.cn)("h-5 w-5 flex items-center justify-center p-0 text-xs rounded-full transition-all relative", onClearFilters && "cursor-pointer"), "data-testid": testIdFilterBadge, onClick: onClearFilters
|
|
@@ -26,9 +26,8 @@ export interface RowAction {
|
|
|
26
26
|
enabled?: boolean;
|
|
27
27
|
order?: number;
|
|
28
28
|
variant?: "default" | "destructive";
|
|
29
|
-
|
|
30
|
-
handleOnClick?: (row
|
|
31
|
-
handleAction?: (id: string) => void;
|
|
29
|
+
/** Preferred handler for row and header actions. Receives the full `row` when invoked from a row. */
|
|
30
|
+
handleOnClick?: (row?: TableRow) => void;
|
|
32
31
|
}
|
|
33
32
|
export interface HeaderAction {
|
|
34
33
|
id?: string;
|
|
@@ -37,8 +36,8 @@ export interface HeaderAction {
|
|
|
37
36
|
enabled?: boolean;
|
|
38
37
|
order?: number;
|
|
39
38
|
variant?: "default" | "outline" | "secondary";
|
|
40
|
-
|
|
41
|
-
handleOnClick?: () => void;
|
|
39
|
+
/** Preferred handler — will receive a `row` when invoked from row actions. */
|
|
40
|
+
handleOnClick?: (row?: TableRow) => void;
|
|
42
41
|
}
|
|
43
42
|
export interface PageLimitOption {
|
|
44
43
|
option: string;
|
|
@@ -185,14 +185,7 @@ var EnhancedTable = function (_a) {
|
|
|
185
185
|
.map(function (action, index) { return (react_1.default.createElement(dropdown_menu_1.DropdownMenuItem, { key: action.id || action.key || index, "data-testid": _testIdRowActionPrefix
|
|
186
186
|
? "".concat(_testIdRowActionPrefix, "-").concat(rowIndex, "-").concat(index)
|
|
187
187
|
: undefined, className: (0, utils_1.cn)(action.variant === "destructive" &&
|
|
188
|
-
"text-destructive focus:text-destructive"), onClick: function () {
|
|
189
|
-
if (action.onClick)
|
|
190
|
-
action.onClick(row);
|
|
191
|
-
if (action.handleOnClick)
|
|
192
|
-
action.handleOnClick(row);
|
|
193
|
-
if (action.handleAction && row.id)
|
|
194
|
-
action.handleAction(row.id);
|
|
195
|
-
} }, action.label)); }))));
|
|
188
|
+
"text-destructive focus:text-destructive"), onClick: function () { var _a; return (_a = action.handleOnClick) === null || _a === void 0 ? void 0 : _a.call(action, row); } }, action.label)); }))));
|
|
196
189
|
}
|
|
197
190
|
if (normalizedType === COMPONENT_TYPE.ID) {
|
|
198
191
|
return (react_1.default.createElement(popover_1.Popover, null,
|
|
@@ -65,58 +65,96 @@ function ThemeApplier(_a) {
|
|
|
65
65
|
var children = _a.children;
|
|
66
66
|
var _b = (0, next_themes_1.useTheme)(), theme = _b.theme, resolvedTheme = _b.resolvedTheme;
|
|
67
67
|
(0, react_1.useEffect)(function () {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
return;
|
|
68
|
+
// Manage CSS classes on the root element instead of setting inline styles.
|
|
69
|
+
// This allows the stylesheet (which defines .theme-<name> and .dark
|
|
70
|
+
// blocks) to control CSS variable values and ensures consistent
|
|
71
|
+
// application across the entire UI (sidebar and main body).
|
|
72
|
+
var root = document.documentElement;
|
|
73
|
+
// Prefer a persisted color theme stored in localStorage so user color
|
|
74
|
+
// preferences survive across sessions and apply before any JS-driven
|
|
75
|
+
// hydration updates. Fall back to the `theme` provided by next-themes.
|
|
76
|
+
var persistedColor = (function () {
|
|
77
|
+
try {
|
|
78
|
+
return window.localStorage.getItem("ui-theme-color");
|
|
82
79
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
|
|
80
|
+
catch (e) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
})();
|
|
84
|
+
var colorTheme = persistedColor || theme || "light";
|
|
85
|
+
var mode = resolvedTheme || "light";
|
|
86
|
+
// Remove any existing theme-* classes
|
|
87
|
+
Array.from(root.classList)
|
|
88
|
+
.filter(function (c) { return c.startsWith("theme-"); })
|
|
89
|
+
.forEach(function (c) { return root.classList.remove(c); });
|
|
90
|
+
// Add theme class for the selected color theme (skip adding for "light")
|
|
91
|
+
if (colorTheme && colorTheme !== "light") {
|
|
92
|
+
root.classList.add("theme-".concat(colorTheme));
|
|
93
|
+
}
|
|
94
|
+
// Toggle `dark` class based on resolved mode so `.dark` and
|
|
95
|
+
// `.theme-<name>.dark` selectors take effect from the stylesheet.
|
|
96
|
+
if (mode === "dark") {
|
|
97
|
+
root.classList.add("dark");
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
root.classList.remove("dark");
|
|
101
|
+
}
|
|
102
|
+
// Update data-theme attribute for components that rely on it.
|
|
103
|
+
root.setAttribute("data-theme", colorTheme);
|
|
100
104
|
}, [theme, resolvedTheme]);
|
|
101
105
|
// Apply default theme on mount
|
|
102
106
|
(0, react_1.useEffect)(function () {
|
|
103
|
-
//
|
|
104
|
-
var
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
applyDefaultTheme();
|
|
107
|
+
// Ensure default classes/attributes are present on first mount.
|
|
108
|
+
var root = document.documentElement;
|
|
109
|
+
// Remove theme-* classes and add no extra class for default light theme.
|
|
110
|
+
Array.from(root.classList)
|
|
111
|
+
.filter(function (c) { return c.startsWith("theme-"); })
|
|
112
|
+
.forEach(function (c) { return root.classList.remove(c); });
|
|
113
|
+
root.classList.remove("dark");
|
|
114
|
+
root.setAttribute("data-theme", "light");
|
|
115
115
|
}, []); // Run only once on mount
|
|
116
116
|
return react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
117
117
|
}
|
|
118
118
|
function ThemeProvider(_a) {
|
|
119
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
|
-
|
|
120
|
+
// Read persisted theme and color from localStorage synchronously so
|
|
121
|
+
// we can apply them as the initial values before children render.
|
|
122
|
+
var persistedTheme = null;
|
|
123
|
+
var persistedColor = null;
|
|
124
|
+
try {
|
|
125
|
+
persistedTheme = window.localStorage.getItem(storageKey);
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
persistedTheme = null;
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
persistedColor = window.localStorage.getItem("ui-theme-color");
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
persistedColor = null;
|
|
135
|
+
}
|
|
136
|
+
var initialTheme = persistedTheme || defaultTheme;
|
|
137
|
+
// Apply persisted classes immediately to avoid flash of incorrect theme.
|
|
138
|
+
try {
|
|
139
|
+
var root_1 = document.documentElement;
|
|
140
|
+
// Remove existing theme-* classes
|
|
141
|
+
Array.from(root_1.classList)
|
|
142
|
+
.filter(function (c) { return c.startsWith("theme-"); })
|
|
143
|
+
.forEach(function (c) { return root_1.classList.remove(c); });
|
|
144
|
+
if (persistedColor && persistedColor !== "default") {
|
|
145
|
+
root_1.classList.add("theme-".concat(persistedColor));
|
|
146
|
+
}
|
|
147
|
+
if (initialTheme === "dark") {
|
|
148
|
+
root_1.classList.add("dark");
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
root_1.classList.remove("dark");
|
|
152
|
+
}
|
|
153
|
+
root_1.setAttribute("data-theme", initialTheme);
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
// ignore DOM errors
|
|
157
|
+
}
|
|
158
|
+
return (react_1.default.createElement(next_themes_1.ThemeProvider, __assign({ attribute: "data-theme", defaultTheme: initialTheme, storageKey: storageKey, enableSystem: enableSystem, themes: Object.keys(themes_1.themes) }, props),
|
|
121
159
|
react_1.default.createElement(ThemeApplier, null, children)));
|
|
122
160
|
}
|
|
@@ -82,8 +82,23 @@ var ThemeSwitcher = function (_a) {
|
|
|
82
82
|
var isDark = resolvedTheme === "dark" || theme === "dark";
|
|
83
83
|
React.useEffect(function () {
|
|
84
84
|
setMounted(true);
|
|
85
|
-
//
|
|
85
|
+
// Initialize color theme from localStorage first (persisted preference),
|
|
86
|
+
// otherwise fall back to any existing class on the document element.
|
|
86
87
|
var root = document.documentElement;
|
|
88
|
+
try {
|
|
89
|
+
var persisted = window.localStorage.getItem("ui-theme-color");
|
|
90
|
+
if (persisted) {
|
|
91
|
+
setColorTheme(persisted);
|
|
92
|
+
// Apply persisted theme class
|
|
93
|
+
colorThemes.forEach(function (t) { return root.classList.remove("theme-".concat(t.name)); });
|
|
94
|
+
if (persisted !== "default")
|
|
95
|
+
root.classList.add("theme-".concat(persisted));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (e) {
|
|
100
|
+
// ignore
|
|
101
|
+
}
|
|
87
102
|
var currentColorTheme = colorThemes.find(function (t) {
|
|
88
103
|
return root.classList.contains("theme-".concat(t.name));
|
|
89
104
|
});
|
|
@@ -104,6 +119,12 @@ var ThemeSwitcher = function (_a) {
|
|
|
104
119
|
if (newColorTheme !== "default") {
|
|
105
120
|
root.classList.add("theme-".concat(newColorTheme));
|
|
106
121
|
}
|
|
122
|
+
try {
|
|
123
|
+
window.localStorage.setItem("ui-theme-color", newColorTheme);
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
// ignore storage errors
|
|
127
|
+
}
|
|
107
128
|
setColorTheme(newColorTheme);
|
|
108
129
|
};
|
|
109
130
|
if (!mounted) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appcorp/shadcn",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.28",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build:next": "next build",
|
|
6
6
|
"build:storybook": "storybook build -c .storybook -o .out",
|
|
@@ -63,9 +63,11 @@
|
|
|
63
63
|
"@radix-ui/react-switch": "^1.2.6",
|
|
64
64
|
"@radix-ui/react-tabs": "^1.1.13",
|
|
65
65
|
"@radix-ui/react-toggle": "^1.1.10",
|
|
66
|
+
"@react-pakistan/util-functions": "^1.25.16",
|
|
66
67
|
"@storybook/addon-docs": "^10.1.0",
|
|
67
68
|
"@storybook/addon-onboarding": "^10.1.0",
|
|
68
69
|
"@storybook/nextjs": "^10.1.0",
|
|
70
|
+
"@tabler/icons-react": "^3.36.1",
|
|
69
71
|
"@tailwindcss/postcss": "^4.1.17",
|
|
70
72
|
"@tanstack/react-table": "^8.21.3",
|
|
71
73
|
"@testing-library/dom": "^10.4.1",
|
|
@@ -85,6 +87,7 @@
|
|
|
85
87
|
"cmdk": "^1.1.1",
|
|
86
88
|
"color": "^5.0.2",
|
|
87
89
|
"date-fns": "^4.1.0",
|
|
90
|
+
"dayjs": "^1.11.19",
|
|
88
91
|
"embla-carousel-react": "^8.6.0",
|
|
89
92
|
"eslint": "^9.37.0",
|
|
90
93
|
"eslint-config-next": "^15.5.5",
|
|
@@ -95,6 +98,7 @@
|
|
|
95
98
|
"jest": "^30.2.0",
|
|
96
99
|
"jest-environment-jsdom": "^30.2.0",
|
|
97
100
|
"jotai": "^2.15.0",
|
|
101
|
+
"libphonenumber-js": "^1.12.35",
|
|
98
102
|
"lint-staged": "^16.2.4",
|
|
99
103
|
"lodash.throttle": "^4.1.1",
|
|
100
104
|
"lucide-react": "^0.556.0",
|
|
@@ -108,6 +112,7 @@
|
|
|
108
112
|
"react-day-picker": "^9.11.1",
|
|
109
113
|
"react-dom": "^19.2.0",
|
|
110
114
|
"react-dropzone": "^14.3.8",
|
|
115
|
+
"react-easy-crop": "^5.5.6",
|
|
111
116
|
"react-hook-form": "^7.66.1",
|
|
112
117
|
"react-resizable-panels": "^3.0.6",
|
|
113
118
|
"recharts": "3.5.1",
|
|
@@ -118,12 +123,9 @@
|
|
|
118
123
|
"tailwindcss": "^4.1.17",
|
|
119
124
|
"ts-node": "^10.9.2",
|
|
120
125
|
"typescript": "^5.9.3",
|
|
126
|
+
"uuid": "^13.0.0",
|
|
121
127
|
"vaul": "^1.1.2",
|
|
122
128
|
"zod": "^4.1.12"
|
|
123
129
|
},
|
|
124
|
-
"packageManager": "yarn@4.12.0"
|
|
125
|
-
"dependencies": {
|
|
126
|
-
"@tabler/icons-react": "^3.36.1",
|
|
127
|
-
"react-easy-crop": "^5.5.6"
|
|
128
|
-
}
|
|
130
|
+
"packageManager": "yarn@4.12.0"
|
|
129
131
|
}
|