@camstack/ui-library 1.2.289 → 1.2.291

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.
@@ -1,4 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_theme_to_root_css = require("../theme-to-root-css-CIqt8k0j.cjs");
2
3
  let react = require("react");
3
4
  let react_jsx_runtime = require("react/jsx-runtime");
4
5
  //#region src/theme/theme-provider.tsx
@@ -72,148 +73,6 @@ function useThemeMode() {
72
73
  return context;
73
74
  }
74
75
  //#endregion
75
- //#region src/theme/defaults.ts
76
- var providerColors = {
77
- onvif: "#3b82f6",
78
- hikvision: "#a855f7",
79
- reolink: "#06b6d4",
80
- homeAssistant: "#22d3ee",
81
- rtsp: "#78716c"
82
- };
83
- var darkColors = {
84
- primary: "#f59e42",
85
- primaryForeground: "#0c0a09",
86
- background: "#0c0a09",
87
- backgroundElevated: "#1c1917",
88
- surface: "#1c1917",
89
- surfaceHover: "#292524",
90
- border: "#292524",
91
- borderSubtle: "#1c1917",
92
- foreground: "#fafaf9",
93
- foregroundMuted: "#a8a29e",
94
- foregroundSubtle: "#78716c",
95
- foregroundDisabled: "#57534e",
96
- success: "#4ade80",
97
- warning: "#fbbf24",
98
- danger: "#f87171",
99
- info: "#60a5fa",
100
- successFill: "#4ade80",
101
- successOn: "#0c0a09",
102
- warningFill: "#fbbf24",
103
- warningOn: "#0c0a09",
104
- dangerFill: "#f87171",
105
- dangerOn: "#0c0a09",
106
- infoFill: "#60a5fa",
107
- infoOn: "#0c0a09",
108
- primaryFill: "#f59e42",
109
- primaryOn: "#0c0a09",
110
- neutralFill: "#44403c",
111
- neutralOn: "#fafaf9",
112
- provider: providerColors
113
- };
114
- var lightColors = {
115
- primary: "#e67e22",
116
- primaryForeground: "#ffffff",
117
- background: "#fafaf9",
118
- backgroundElevated: "#ffffff",
119
- surface: "#f5f5f4",
120
- surfaceHover: "#e7e5e4",
121
- border: "#d6d3d1",
122
- borderSubtle: "#e7e5e4",
123
- foreground: "#1c1917",
124
- foregroundMuted: "#57534e",
125
- foregroundSubtle: "#78716c",
126
- foregroundDisabled: "#a8a29e",
127
- success: "#16a34a",
128
- warning: "#d97706",
129
- danger: "#dc2626",
130
- info: "#2563eb",
131
- successFill: "#15803d",
132
- successOn: "#ffffff",
133
- warningFill: "#b45309",
134
- warningOn: "#ffffff",
135
- dangerFill: "#dc2626",
136
- dangerOn: "#ffffff",
137
- infoFill: "#2563eb",
138
- infoOn: "#ffffff",
139
- primaryFill: "#c2410c",
140
- primaryOn: "#ffffff",
141
- neutralFill: "#57534e",
142
- neutralOn: "#ffffff",
143
- provider: providerColors
144
- };
145
- var defaultTheme = {
146
- colors: {
147
- dark: darkColors,
148
- light: lightColors
149
- },
150
- spacing: {
151
- xs: 2,
152
- sm: 4,
153
- md: 8,
154
- lg: 12,
155
- xl: 16,
156
- "2xl": 24,
157
- "3xl": 32
158
- },
159
- radius: {
160
- sm: 4,
161
- md: 6,
162
- lg: 8,
163
- xl: 12
164
- },
165
- typography: {
166
- fontFamily: "-apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif",
167
- sizes: {
168
- xs: {
169
- fontSize: 10,
170
- lineHeight: 14
171
- },
172
- sm: {
173
- fontSize: 11,
174
- lineHeight: 16
175
- },
176
- base: {
177
- fontSize: 12,
178
- lineHeight: 18
179
- },
180
- lg: {
181
- fontSize: 13,
182
- lineHeight: 18
183
- },
184
- xl: {
185
- fontSize: 14,
186
- lineHeight: 20
187
- },
188
- "2xl": {
189
- fontSize: 16,
190
- lineHeight: 22
191
- },
192
- "3xl": {
193
- fontSize: 20,
194
- lineHeight: 28
195
- }
196
- },
197
- weights: {
198
- regular: 400,
199
- medium: 500,
200
- semibold: 600,
201
- bold: 700
202
- }
203
- },
204
- table: {
205
- rowHeight: 28,
206
- headerHeight: 24,
207
- cellPaddingX: 8,
208
- cellPaddingY: 6
209
- },
210
- sidebar: {
211
- width: 176,
212
- itemHeight: 28,
213
- iconSize: 14
214
- }
215
- };
216
- //#endregion
217
76
  //#region src/theme/create-theme.ts
218
77
  function deepMerge(target, source) {
219
78
  const result = { ...target };
@@ -226,82 +85,18 @@ function deepMerge(target, source) {
226
85
  return result;
227
86
  }
228
87
  function createTheme(overrides) {
229
- if (!overrides) return structuredClone(defaultTheme);
230
- return deepMerge(structuredClone(defaultTheme), overrides);
231
- }
232
- //#endregion
233
- //#region src/theme/theme-to-css.ts
234
- function camelToKebab(str) {
235
- return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
236
- }
237
- function colorTokenToCssVar(key) {
238
- return `--color-${camelToKebab(key)}`;
239
- }
240
- function generateColorBlock(colors) {
241
- const lines = [];
242
- for (const [key, value] of Object.entries(colors)) {
243
- if (key === "provider") continue;
244
- lines.push(` ${colorTokenToCssVar(key)}: ${value};`);
245
- }
246
- return lines.join("\n");
247
- }
248
- function generateProviderColors(provider) {
249
- const lines = [];
250
- for (const [key, value] of Object.entries(provider)) lines.push(` --color-provider-${camelToKebab(key)}: ${value};`);
251
- return lines.join("\n");
252
- }
253
- function generateSpacingTokens(spacing) {
254
- const lines = [];
255
- for (const [key, value] of Object.entries(spacing)) lines.push(` --spacing-${key}: ${value}px;`);
256
- return lines.join("\n");
257
- }
258
- function generateRadiusTokens(radius) {
259
- const lines = [];
260
- for (const [key, value] of Object.entries(radius)) lines.push(` --radius-${key}: ${value}px;`);
261
- return lines.join("\n");
262
- }
263
- function themeToCss(theme) {
264
- const darkColorBlock = generateColorBlock(theme.colors.dark);
265
- const lightColorBlock = generateColorBlock(theme.colors.light);
266
- return `@theme {
267
- ${generateProviderColors(theme.colors.dark.provider)}
268
- ${generateSpacingTokens(theme.spacing)}
269
- ${generateRadiusTokens(theme.radius)}
270
- }
271
-
272
- .dark {
273
- ${darkColorBlock}
274
- }
275
-
276
- .light {
277
- ${lightColorBlock}
278
- }
279
-
280
- @media (prefers-color-scheme: dark) {
281
- :root {
282
- ${darkColorBlock.replace(/^ {2}/gm, " ")}
283
- }
284
- }
285
-
286
- @media (prefers-color-scheme: light) {
287
- :root {
288
- ${lightColorBlock.replace(/^ {2}/gm, " ")}
289
- }
290
- }
291
- `;
88
+ if (!overrides) return structuredClone(require_theme_to_root_css.defaultTheme);
89
+ return deepMerge(structuredClone(require_theme_to_root_css.defaultTheme), overrides);
292
90
  }
293
91
  //#endregion
294
92
  exports.ThemeProvider = ThemeProvider;
295
93
  exports.ThemeProvider$1 = ThemeProvider;
296
94
  exports.createTheme = createTheme;
297
95
  exports.createTheme$1 = createTheme;
298
- exports.darkColors = darkColors;
299
- exports.darkColors$1 = darkColors;
300
- exports.defaultTheme = defaultTheme;
301
- exports.defaultTheme$1 = defaultTheme;
302
- exports.lightColors = lightColors;
303
- exports.lightColors$1 = lightColors;
304
- exports.themeToCss = themeToCss;
305
- exports.themeToCss$1 = themeToCss;
96
+ exports.darkColors = require_theme_to_root_css.darkColors;
97
+ exports.defaultTheme = require_theme_to_root_css.defaultTheme;
98
+ exports.lightColors = require_theme_to_root_css.lightColors;
99
+ exports.themeToCss = require_theme_to_root_css.themeToCss;
100
+ exports.themeToRootCss = require_theme_to_root_css.themeToRootCss;
306
101
  exports.useThemeMode = useThemeMode;
307
102
  exports.useThemeMode$1 = useThemeMode;
@@ -2,5 +2,6 @@ export type { CamStackColorTokens, CamStackTheme, ThemeMode, DeepPartial, UseThe
2
2
  export { darkColors, lightColors, defaultTheme } from "./defaults";
3
3
  export { createTheme } from "./create-theme";
4
4
  export { themeToCss } from "./theme-to-css";
5
+ export { themeToRootCss } from "./theme-to-root-css";
5
6
  export { ThemeProvider } from "./theme-provider";
6
7
  export { useThemeMode } from "./use-theme-mode";
@@ -1,3 +1,4 @@
1
+ import { a as lightColors, i as defaultTheme, n as themeToCss, r as darkColors, t as themeToRootCss } from "../theme-to-root-css-Ca6MGqO9.js";
1
2
  import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
2
3
  import { jsx } from "react/jsx-runtime";
3
4
  //#region src/theme/theme-provider.tsx
@@ -71,148 +72,6 @@ function useThemeMode() {
71
72
  return context;
72
73
  }
73
74
  //#endregion
74
- //#region src/theme/defaults.ts
75
- var providerColors = {
76
- onvif: "#3b82f6",
77
- hikvision: "#a855f7",
78
- reolink: "#06b6d4",
79
- homeAssistant: "#22d3ee",
80
- rtsp: "#78716c"
81
- };
82
- var darkColors = {
83
- primary: "#f59e42",
84
- primaryForeground: "#0c0a09",
85
- background: "#0c0a09",
86
- backgroundElevated: "#1c1917",
87
- surface: "#1c1917",
88
- surfaceHover: "#292524",
89
- border: "#292524",
90
- borderSubtle: "#1c1917",
91
- foreground: "#fafaf9",
92
- foregroundMuted: "#a8a29e",
93
- foregroundSubtle: "#78716c",
94
- foregroundDisabled: "#57534e",
95
- success: "#4ade80",
96
- warning: "#fbbf24",
97
- danger: "#f87171",
98
- info: "#60a5fa",
99
- successFill: "#4ade80",
100
- successOn: "#0c0a09",
101
- warningFill: "#fbbf24",
102
- warningOn: "#0c0a09",
103
- dangerFill: "#f87171",
104
- dangerOn: "#0c0a09",
105
- infoFill: "#60a5fa",
106
- infoOn: "#0c0a09",
107
- primaryFill: "#f59e42",
108
- primaryOn: "#0c0a09",
109
- neutralFill: "#44403c",
110
- neutralOn: "#fafaf9",
111
- provider: providerColors
112
- };
113
- var lightColors = {
114
- primary: "#e67e22",
115
- primaryForeground: "#ffffff",
116
- background: "#fafaf9",
117
- backgroundElevated: "#ffffff",
118
- surface: "#f5f5f4",
119
- surfaceHover: "#e7e5e4",
120
- border: "#d6d3d1",
121
- borderSubtle: "#e7e5e4",
122
- foreground: "#1c1917",
123
- foregroundMuted: "#57534e",
124
- foregroundSubtle: "#78716c",
125
- foregroundDisabled: "#a8a29e",
126
- success: "#16a34a",
127
- warning: "#d97706",
128
- danger: "#dc2626",
129
- info: "#2563eb",
130
- successFill: "#15803d",
131
- successOn: "#ffffff",
132
- warningFill: "#b45309",
133
- warningOn: "#ffffff",
134
- dangerFill: "#dc2626",
135
- dangerOn: "#ffffff",
136
- infoFill: "#2563eb",
137
- infoOn: "#ffffff",
138
- primaryFill: "#c2410c",
139
- primaryOn: "#ffffff",
140
- neutralFill: "#57534e",
141
- neutralOn: "#ffffff",
142
- provider: providerColors
143
- };
144
- var defaultTheme = {
145
- colors: {
146
- dark: darkColors,
147
- light: lightColors
148
- },
149
- spacing: {
150
- xs: 2,
151
- sm: 4,
152
- md: 8,
153
- lg: 12,
154
- xl: 16,
155
- "2xl": 24,
156
- "3xl": 32
157
- },
158
- radius: {
159
- sm: 4,
160
- md: 6,
161
- lg: 8,
162
- xl: 12
163
- },
164
- typography: {
165
- fontFamily: "-apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif",
166
- sizes: {
167
- xs: {
168
- fontSize: 10,
169
- lineHeight: 14
170
- },
171
- sm: {
172
- fontSize: 11,
173
- lineHeight: 16
174
- },
175
- base: {
176
- fontSize: 12,
177
- lineHeight: 18
178
- },
179
- lg: {
180
- fontSize: 13,
181
- lineHeight: 18
182
- },
183
- xl: {
184
- fontSize: 14,
185
- lineHeight: 20
186
- },
187
- "2xl": {
188
- fontSize: 16,
189
- lineHeight: 22
190
- },
191
- "3xl": {
192
- fontSize: 20,
193
- lineHeight: 28
194
- }
195
- },
196
- weights: {
197
- regular: 400,
198
- medium: 500,
199
- semibold: 600,
200
- bold: 700
201
- }
202
- },
203
- table: {
204
- rowHeight: 28,
205
- headerHeight: 24,
206
- cellPaddingX: 8,
207
- cellPaddingY: 6
208
- },
209
- sidebar: {
210
- width: 176,
211
- itemHeight: 28,
212
- iconSize: 14
213
- }
214
- };
215
- //#endregion
216
75
  //#region src/theme/create-theme.ts
217
76
  function deepMerge(target, source) {
218
77
  const result = { ...target };
@@ -229,65 +88,4 @@ function createTheme(overrides) {
229
88
  return deepMerge(structuredClone(defaultTheme), overrides);
230
89
  }
231
90
  //#endregion
232
- //#region src/theme/theme-to-css.ts
233
- function camelToKebab(str) {
234
- return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
235
- }
236
- function colorTokenToCssVar(key) {
237
- return `--color-${camelToKebab(key)}`;
238
- }
239
- function generateColorBlock(colors) {
240
- const lines = [];
241
- for (const [key, value] of Object.entries(colors)) {
242
- if (key === "provider") continue;
243
- lines.push(` ${colorTokenToCssVar(key)}: ${value};`);
244
- }
245
- return lines.join("\n");
246
- }
247
- function generateProviderColors(provider) {
248
- const lines = [];
249
- for (const [key, value] of Object.entries(provider)) lines.push(` --color-provider-${camelToKebab(key)}: ${value};`);
250
- return lines.join("\n");
251
- }
252
- function generateSpacingTokens(spacing) {
253
- const lines = [];
254
- for (const [key, value] of Object.entries(spacing)) lines.push(` --spacing-${key}: ${value}px;`);
255
- return lines.join("\n");
256
- }
257
- function generateRadiusTokens(radius) {
258
- const lines = [];
259
- for (const [key, value] of Object.entries(radius)) lines.push(` --radius-${key}: ${value}px;`);
260
- return lines.join("\n");
261
- }
262
- function themeToCss(theme) {
263
- const darkColorBlock = generateColorBlock(theme.colors.dark);
264
- const lightColorBlock = generateColorBlock(theme.colors.light);
265
- return `@theme {
266
- ${generateProviderColors(theme.colors.dark.provider)}
267
- ${generateSpacingTokens(theme.spacing)}
268
- ${generateRadiusTokens(theme.radius)}
269
- }
270
-
271
- .dark {
272
- ${darkColorBlock}
273
- }
274
-
275
- .light {
276
- ${lightColorBlock}
277
- }
278
-
279
- @media (prefers-color-scheme: dark) {
280
- :root {
281
- ${darkColorBlock.replace(/^ {2}/gm, " ")}
282
- }
283
- }
284
-
285
- @media (prefers-color-scheme: light) {
286
- :root {
287
- ${lightColorBlock.replace(/^ {2}/gm, " ")}
288
- }
289
- }
290
- `;
291
- }
292
- //#endregion
293
- export { ThemeProvider, createTheme, darkColors, defaultTheme, lightColors, themeToCss, useThemeMode };
91
+ export { ThemeProvider, createTheme, darkColors, defaultTheme, lightColors, themeToCss, themeToRootCss, useThemeMode };
@@ -1,2 +1,3 @@
1
1
  import type { CamStackTheme } from "./types";
2
+ export declare function camelToKebab(str: string): string;
2
3
  export declare function themeToCss(theme: CamStackTheme): string;
@@ -0,0 +1,10 @@
1
+ import type { CamStackTheme } from "./types";
2
+ /**
3
+ * The theme as plain CSS custom properties on `:root`, with no Tailwind
4
+ * directive: light colours by default, dark inside `prefers-color-scheme`.
5
+ * Variable names are the ones {@link themeToCss} emits (`--color-primary`,
6
+ * `--spacing-lg`, `--radius-xl`), so a stylesheet written against the admin
7
+ * UI's tokens reads the same names. For pages with no CSS toolchain, such as
8
+ * the hub's standalone server-rendered pages.
9
+ */
10
+ export declare function themeToRootCss(theme: CamStackTheme): string;
@@ -0,0 +1,7 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_theme_to_root_css = require("../theme-to-root-css-CIqt8k0j.cjs");
3
+ exports.darkColors = require_theme_to_root_css.darkColors;
4
+ exports.defaultTheme = require_theme_to_root_css.defaultTheme;
5
+ exports.lightColors = require_theme_to_root_css.lightColors;
6
+ exports.themeToCss = require_theme_to_root_css.themeToCss;
7
+ exports.themeToRootCss = require_theme_to_root_css.themeToRootCss;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The React-free slice of the theme: the token values and their plain-CSS
3
+ * form. A separate entry (`@camstack/ui-library/theme/tokens`) so a Node
4
+ * process can read the tokens without loading React.
5
+ */
6
+ export type { CamStackColorTokens, CamStackTheme } from "./types";
7
+ export { darkColors, lightColors, defaultTheme } from "./defaults";
8
+ export { themeToCss } from "./theme-to-css";
9
+ export { themeToRootCss } from "./theme-to-root-css";
@@ -0,0 +1,2 @@
1
+ import { a as lightColors, i as defaultTheme, n as themeToCss, r as darkColors, t as themeToRootCss } from "../theme-to-root-css-Ca6MGqO9.js";
2
+ export { darkColors, defaultTheme, lightColors, themeToCss, themeToRootCss };