@camstack/ui-library 1.2.288 → 1.2.290

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,256 @@
1
+ //#region src/theme/defaults.ts
2
+ var providerColors = {
3
+ onvif: "#3b82f6",
4
+ hikvision: "#a855f7",
5
+ reolink: "#06b6d4",
6
+ homeAssistant: "#22d3ee",
7
+ rtsp: "#78716c"
8
+ };
9
+ var darkColors = {
10
+ primary: "#f59e42",
11
+ primaryForeground: "#0c0a09",
12
+ background: "#0c0a09",
13
+ backgroundElevated: "#1c1917",
14
+ surface: "#1c1917",
15
+ surfaceHover: "#292524",
16
+ border: "#292524",
17
+ borderSubtle: "#1c1917",
18
+ foreground: "#fafaf9",
19
+ foregroundMuted: "#a8a29e",
20
+ foregroundSubtle: "#78716c",
21
+ foregroundDisabled: "#57534e",
22
+ success: "#4ade80",
23
+ warning: "#fbbf24",
24
+ danger: "#f87171",
25
+ info: "#60a5fa",
26
+ successFill: "#4ade80",
27
+ successOn: "#0c0a09",
28
+ warningFill: "#fbbf24",
29
+ warningOn: "#0c0a09",
30
+ dangerFill: "#f87171",
31
+ dangerOn: "#0c0a09",
32
+ infoFill: "#60a5fa",
33
+ infoOn: "#0c0a09",
34
+ primaryFill: "#f59e42",
35
+ primaryOn: "#0c0a09",
36
+ neutralFill: "#44403c",
37
+ neutralOn: "#fafaf9",
38
+ provider: providerColors
39
+ };
40
+ var lightColors = {
41
+ primary: "#e67e22",
42
+ primaryForeground: "#ffffff",
43
+ background: "#fafaf9",
44
+ backgroundElevated: "#ffffff",
45
+ surface: "#f5f5f4",
46
+ surfaceHover: "#e7e5e4",
47
+ border: "#d6d3d1",
48
+ borderSubtle: "#e7e5e4",
49
+ foreground: "#1c1917",
50
+ foregroundMuted: "#57534e",
51
+ foregroundSubtle: "#78716c",
52
+ foregroundDisabled: "#a8a29e",
53
+ success: "#16a34a",
54
+ warning: "#d97706",
55
+ danger: "#dc2626",
56
+ info: "#2563eb",
57
+ successFill: "#15803d",
58
+ successOn: "#ffffff",
59
+ warningFill: "#b45309",
60
+ warningOn: "#ffffff",
61
+ dangerFill: "#dc2626",
62
+ dangerOn: "#ffffff",
63
+ infoFill: "#2563eb",
64
+ infoOn: "#ffffff",
65
+ primaryFill: "#c2410c",
66
+ primaryOn: "#ffffff",
67
+ neutralFill: "#57534e",
68
+ neutralOn: "#ffffff",
69
+ provider: providerColors
70
+ };
71
+ var defaultTheme = {
72
+ colors: {
73
+ dark: darkColors,
74
+ light: lightColors
75
+ },
76
+ spacing: {
77
+ xs: 2,
78
+ sm: 4,
79
+ md: 8,
80
+ lg: 12,
81
+ xl: 16,
82
+ "2xl": 24,
83
+ "3xl": 32
84
+ },
85
+ radius: {
86
+ sm: 4,
87
+ md: 6,
88
+ lg: 8,
89
+ xl: 12
90
+ },
91
+ typography: {
92
+ fontFamily: "-apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif",
93
+ sizes: {
94
+ xs: {
95
+ fontSize: 10,
96
+ lineHeight: 14
97
+ },
98
+ sm: {
99
+ fontSize: 11,
100
+ lineHeight: 16
101
+ },
102
+ base: {
103
+ fontSize: 12,
104
+ lineHeight: 18
105
+ },
106
+ lg: {
107
+ fontSize: 13,
108
+ lineHeight: 18
109
+ },
110
+ xl: {
111
+ fontSize: 14,
112
+ lineHeight: 20
113
+ },
114
+ "2xl": {
115
+ fontSize: 16,
116
+ lineHeight: 22
117
+ },
118
+ "3xl": {
119
+ fontSize: 20,
120
+ lineHeight: 28
121
+ }
122
+ },
123
+ weights: {
124
+ regular: 400,
125
+ medium: 500,
126
+ semibold: 600,
127
+ bold: 700
128
+ }
129
+ },
130
+ table: {
131
+ rowHeight: 28,
132
+ headerHeight: 24,
133
+ cellPaddingX: 8,
134
+ cellPaddingY: 6
135
+ },
136
+ sidebar: {
137
+ width: 176,
138
+ itemHeight: 28,
139
+ iconSize: 14
140
+ }
141
+ };
142
+ //#endregion
143
+ //#region src/theme/theme-to-css.ts
144
+ function camelToKebab(str) {
145
+ return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
146
+ }
147
+ function colorTokenToCssVar(key) {
148
+ return `--color-${camelToKebab(key)}`;
149
+ }
150
+ function generateColorBlock(colors) {
151
+ const lines = [];
152
+ for (const [key, value] of Object.entries(colors)) {
153
+ if (key === "provider") continue;
154
+ lines.push(` ${colorTokenToCssVar(key)}: ${value};`);
155
+ }
156
+ return lines.join("\n");
157
+ }
158
+ function generateProviderColors(provider) {
159
+ const lines = [];
160
+ for (const [key, value] of Object.entries(provider)) lines.push(` --color-provider-${camelToKebab(key)}: ${value};`);
161
+ return lines.join("\n");
162
+ }
163
+ function generateSpacingTokens(spacing) {
164
+ const lines = [];
165
+ for (const [key, value] of Object.entries(spacing)) lines.push(` --spacing-${key}: ${value}px;`);
166
+ return lines.join("\n");
167
+ }
168
+ function generateRadiusTokens(radius) {
169
+ const lines = [];
170
+ for (const [key, value] of Object.entries(radius)) lines.push(` --radius-${key}: ${value}px;`);
171
+ return lines.join("\n");
172
+ }
173
+ function themeToCss(theme) {
174
+ const darkColorBlock = generateColorBlock(theme.colors.dark);
175
+ const lightColorBlock = generateColorBlock(theme.colors.light);
176
+ return `@theme {
177
+ ${generateProviderColors(theme.colors.dark.provider)}
178
+ ${generateSpacingTokens(theme.spacing)}
179
+ ${generateRadiusTokens(theme.radius)}
180
+ }
181
+
182
+ .dark {
183
+ ${darkColorBlock}
184
+ }
185
+
186
+ .light {
187
+ ${lightColorBlock}
188
+ }
189
+
190
+ @media (prefers-color-scheme: dark) {
191
+ :root {
192
+ ${darkColorBlock.replace(/^ {2}/gm, " ")}
193
+ }
194
+ }
195
+
196
+ @media (prefers-color-scheme: light) {
197
+ :root {
198
+ ${lightColorBlock.replace(/^ {2}/gm, " ")}
199
+ }
200
+ }
201
+ `;
202
+ }
203
+ //#endregion
204
+ //#region src/theme/theme-to-root-css.ts
205
+ function colorDeclarations(colors) {
206
+ return Object.entries(colors).filter(([key]) => key !== "provider").map(([key, value]) => `--color-${camelToKebab(key)}:${String(value)}`).join(";");
207
+ }
208
+ function scaleDeclarations(prefix, scale) {
209
+ return Object.entries(scale).map(([key, value]) => `--${prefix}-${key}:${value}px`).join(";");
210
+ }
211
+ /**
212
+ * The theme as plain CSS custom properties on `:root`, with no Tailwind
213
+ * directive: light colours by default, dark inside `prefers-color-scheme`.
214
+ * Variable names are the ones {@link themeToCss} emits (`--color-primary`,
215
+ * `--spacing-lg`, `--radius-xl`), so a stylesheet written against the admin
216
+ * UI's tokens reads the same names. For pages with no CSS toolchain, such as
217
+ * the hub's standalone server-rendered pages.
218
+ */
219
+ function themeToRootCss(theme) {
220
+ return [`:root{color-scheme:light dark;${[
221
+ scaleDeclarations("spacing", theme.spacing),
222
+ scaleDeclarations("radius", theme.radius),
223
+ `--font-family:${theme.typography.fontFamily}`
224
+ ].join(";")};${colorDeclarations(theme.colors.light)}}`, `@media (prefers-color-scheme:dark){:root{${colorDeclarations(theme.colors.dark)}}}`].join("");
225
+ }
226
+ //#endregion
227
+ Object.defineProperty(exports, "darkColors", {
228
+ enumerable: true,
229
+ get: function() {
230
+ return darkColors;
231
+ }
232
+ });
233
+ Object.defineProperty(exports, "defaultTheme", {
234
+ enumerable: true,
235
+ get: function() {
236
+ return defaultTheme;
237
+ }
238
+ });
239
+ Object.defineProperty(exports, "lightColors", {
240
+ enumerable: true,
241
+ get: function() {
242
+ return lightColors;
243
+ }
244
+ });
245
+ Object.defineProperty(exports, "themeToCss", {
246
+ enumerable: true,
247
+ get: function() {
248
+ return themeToCss;
249
+ }
250
+ });
251
+ Object.defineProperty(exports, "themeToRootCss", {
252
+ enumerable: true,
253
+ get: function() {
254
+ return themeToRootCss;
255
+ }
256
+ });
@@ -0,0 +1,227 @@
1
+ //#region src/theme/defaults.ts
2
+ var providerColors = {
3
+ onvif: "#3b82f6",
4
+ hikvision: "#a855f7",
5
+ reolink: "#06b6d4",
6
+ homeAssistant: "#22d3ee",
7
+ rtsp: "#78716c"
8
+ };
9
+ var darkColors = {
10
+ primary: "#f59e42",
11
+ primaryForeground: "#0c0a09",
12
+ background: "#0c0a09",
13
+ backgroundElevated: "#1c1917",
14
+ surface: "#1c1917",
15
+ surfaceHover: "#292524",
16
+ border: "#292524",
17
+ borderSubtle: "#1c1917",
18
+ foreground: "#fafaf9",
19
+ foregroundMuted: "#a8a29e",
20
+ foregroundSubtle: "#78716c",
21
+ foregroundDisabled: "#57534e",
22
+ success: "#4ade80",
23
+ warning: "#fbbf24",
24
+ danger: "#f87171",
25
+ info: "#60a5fa",
26
+ successFill: "#4ade80",
27
+ successOn: "#0c0a09",
28
+ warningFill: "#fbbf24",
29
+ warningOn: "#0c0a09",
30
+ dangerFill: "#f87171",
31
+ dangerOn: "#0c0a09",
32
+ infoFill: "#60a5fa",
33
+ infoOn: "#0c0a09",
34
+ primaryFill: "#f59e42",
35
+ primaryOn: "#0c0a09",
36
+ neutralFill: "#44403c",
37
+ neutralOn: "#fafaf9",
38
+ provider: providerColors
39
+ };
40
+ var lightColors = {
41
+ primary: "#e67e22",
42
+ primaryForeground: "#ffffff",
43
+ background: "#fafaf9",
44
+ backgroundElevated: "#ffffff",
45
+ surface: "#f5f5f4",
46
+ surfaceHover: "#e7e5e4",
47
+ border: "#d6d3d1",
48
+ borderSubtle: "#e7e5e4",
49
+ foreground: "#1c1917",
50
+ foregroundMuted: "#57534e",
51
+ foregroundSubtle: "#78716c",
52
+ foregroundDisabled: "#a8a29e",
53
+ success: "#16a34a",
54
+ warning: "#d97706",
55
+ danger: "#dc2626",
56
+ info: "#2563eb",
57
+ successFill: "#15803d",
58
+ successOn: "#ffffff",
59
+ warningFill: "#b45309",
60
+ warningOn: "#ffffff",
61
+ dangerFill: "#dc2626",
62
+ dangerOn: "#ffffff",
63
+ infoFill: "#2563eb",
64
+ infoOn: "#ffffff",
65
+ primaryFill: "#c2410c",
66
+ primaryOn: "#ffffff",
67
+ neutralFill: "#57534e",
68
+ neutralOn: "#ffffff",
69
+ provider: providerColors
70
+ };
71
+ var defaultTheme = {
72
+ colors: {
73
+ dark: darkColors,
74
+ light: lightColors
75
+ },
76
+ spacing: {
77
+ xs: 2,
78
+ sm: 4,
79
+ md: 8,
80
+ lg: 12,
81
+ xl: 16,
82
+ "2xl": 24,
83
+ "3xl": 32
84
+ },
85
+ radius: {
86
+ sm: 4,
87
+ md: 6,
88
+ lg: 8,
89
+ xl: 12
90
+ },
91
+ typography: {
92
+ fontFamily: "-apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif",
93
+ sizes: {
94
+ xs: {
95
+ fontSize: 10,
96
+ lineHeight: 14
97
+ },
98
+ sm: {
99
+ fontSize: 11,
100
+ lineHeight: 16
101
+ },
102
+ base: {
103
+ fontSize: 12,
104
+ lineHeight: 18
105
+ },
106
+ lg: {
107
+ fontSize: 13,
108
+ lineHeight: 18
109
+ },
110
+ xl: {
111
+ fontSize: 14,
112
+ lineHeight: 20
113
+ },
114
+ "2xl": {
115
+ fontSize: 16,
116
+ lineHeight: 22
117
+ },
118
+ "3xl": {
119
+ fontSize: 20,
120
+ lineHeight: 28
121
+ }
122
+ },
123
+ weights: {
124
+ regular: 400,
125
+ medium: 500,
126
+ semibold: 600,
127
+ bold: 700
128
+ }
129
+ },
130
+ table: {
131
+ rowHeight: 28,
132
+ headerHeight: 24,
133
+ cellPaddingX: 8,
134
+ cellPaddingY: 6
135
+ },
136
+ sidebar: {
137
+ width: 176,
138
+ itemHeight: 28,
139
+ iconSize: 14
140
+ }
141
+ };
142
+ //#endregion
143
+ //#region src/theme/theme-to-css.ts
144
+ function camelToKebab(str) {
145
+ return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
146
+ }
147
+ function colorTokenToCssVar(key) {
148
+ return `--color-${camelToKebab(key)}`;
149
+ }
150
+ function generateColorBlock(colors) {
151
+ const lines = [];
152
+ for (const [key, value] of Object.entries(colors)) {
153
+ if (key === "provider") continue;
154
+ lines.push(` ${colorTokenToCssVar(key)}: ${value};`);
155
+ }
156
+ return lines.join("\n");
157
+ }
158
+ function generateProviderColors(provider) {
159
+ const lines = [];
160
+ for (const [key, value] of Object.entries(provider)) lines.push(` --color-provider-${camelToKebab(key)}: ${value};`);
161
+ return lines.join("\n");
162
+ }
163
+ function generateSpacingTokens(spacing) {
164
+ const lines = [];
165
+ for (const [key, value] of Object.entries(spacing)) lines.push(` --spacing-${key}: ${value}px;`);
166
+ return lines.join("\n");
167
+ }
168
+ function generateRadiusTokens(radius) {
169
+ const lines = [];
170
+ for (const [key, value] of Object.entries(radius)) lines.push(` --radius-${key}: ${value}px;`);
171
+ return lines.join("\n");
172
+ }
173
+ function themeToCss(theme) {
174
+ const darkColorBlock = generateColorBlock(theme.colors.dark);
175
+ const lightColorBlock = generateColorBlock(theme.colors.light);
176
+ return `@theme {
177
+ ${generateProviderColors(theme.colors.dark.provider)}
178
+ ${generateSpacingTokens(theme.spacing)}
179
+ ${generateRadiusTokens(theme.radius)}
180
+ }
181
+
182
+ .dark {
183
+ ${darkColorBlock}
184
+ }
185
+
186
+ .light {
187
+ ${lightColorBlock}
188
+ }
189
+
190
+ @media (prefers-color-scheme: dark) {
191
+ :root {
192
+ ${darkColorBlock.replace(/^ {2}/gm, " ")}
193
+ }
194
+ }
195
+
196
+ @media (prefers-color-scheme: light) {
197
+ :root {
198
+ ${lightColorBlock.replace(/^ {2}/gm, " ")}
199
+ }
200
+ }
201
+ `;
202
+ }
203
+ //#endregion
204
+ //#region src/theme/theme-to-root-css.ts
205
+ function colorDeclarations(colors) {
206
+ return Object.entries(colors).filter(([key]) => key !== "provider").map(([key, value]) => `--color-${camelToKebab(key)}:${String(value)}`).join(";");
207
+ }
208
+ function scaleDeclarations(prefix, scale) {
209
+ return Object.entries(scale).map(([key, value]) => `--${prefix}-${key}:${value}px`).join(";");
210
+ }
211
+ /**
212
+ * The theme as plain CSS custom properties on `:root`, with no Tailwind
213
+ * directive: light colours by default, dark inside `prefers-color-scheme`.
214
+ * Variable names are the ones {@link themeToCss} emits (`--color-primary`,
215
+ * `--spacing-lg`, `--radius-xl`), so a stylesheet written against the admin
216
+ * UI's tokens reads the same names. For pages with no CSS toolchain, such as
217
+ * the hub's standalone server-rendered pages.
218
+ */
219
+ function themeToRootCss(theme) {
220
+ return [`:root{color-scheme:light dark;${[
221
+ scaleDeclarations("spacing", theme.spacing),
222
+ scaleDeclarations("radius", theme.radius),
223
+ `--font-family:${theme.typography.fontFamily}`
224
+ ].join(";")};${colorDeclarations(theme.colors.light)}}`, `@media (prefers-color-scheme:dark){:root{${colorDeclarations(theme.colors.dark)}}}`].join("");
225
+ }
226
+ //#endregion
227
+ export { lightColors as a, defaultTheme as i, themeToCss as n, darkColors as r, themeToRootCss as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/ui-library",
3
- "version": "1.2.288",
3
+ "version": "1.2.290",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -16,6 +16,11 @@
16
16
  "import": "./dist/theme/index.js",
17
17
  "require": "./dist/theme/index.cjs"
18
18
  },
19
+ "./theme/tokens": {
20
+ "types": "./dist/theme/tokens.d.ts",
21
+ "import": "./dist/theme/tokens.js",
22
+ "require": "./dist/theme/tokens.cjs"
23
+ },
19
24
  "./tailwind/*": "./src/tailwind/*"
20
25
  },
21
26
  "camstack": {