@dbcdk/react-components 0.0.175 → 0.0.177

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.
Files changed (35) hide show
  1. package/README.md +17 -18
  2. package/dist/components/menu/Menu.module.css +2 -4
  3. package/dist/components/theme-button/ThemeButton.cjs +4 -15
  4. package/dist/components/theme-button/ThemeButton.d.ts +3 -4
  5. package/dist/components/theme-button/ThemeButton.js +4 -15
  6. package/dist/components/theme-script/ThemeScript.cjs +23 -16
  7. package/dist/components/theme-script/ThemeScript.d.ts +2 -6
  8. package/dist/components/theme-script/ThemeScript.js +24 -17
  9. package/dist/hooks/usePersistentState.cjs +6 -1
  10. package/dist/hooks/usePersistentState.d.ts +1 -1
  11. package/dist/hooks/usePersistentState.js +6 -1
  12. package/dist/hooks/useTheme.cjs +33 -96
  13. package/dist/hooks/useTheme.d.ts +3 -10
  14. package/dist/hooks/useTheme.js +34 -97
  15. package/dist/styles/themes/apply-product-theme.cjs +20 -0
  16. package/dist/styles/themes/apply-product-theme.d.ts +3 -0
  17. package/dist/styles/themes/apply-product-theme.js +18 -0
  18. package/dist/styles/themes/dbc/colors.css +1 -1
  19. package/dist/styles/themes/product-theme-tokens.cjs +39 -0
  20. package/dist/styles/themes/product-theme-tokens.d.ts +3 -0
  21. package/dist/styles/themes/product-theme-tokens.js +37 -0
  22. package/dist/styles/themes/product-themes.cjs +143 -0
  23. package/dist/styles/themes/product-themes.d.ts +11 -0
  24. package/dist/styles/themes/product-themes.js +140 -0
  25. package/dist/styles/themes/types.cjs +3 -2
  26. package/dist/styles/themes/types.d.ts +1 -13
  27. package/dist/styles/themes/types.js +3 -2
  28. package/dist/utils/sessionStorage.utils.cjs +53 -0
  29. package/dist/utils/sessionStorage.utils.d.ts +19 -0
  30. package/dist/utils/sessionStorage.utils.js +49 -0
  31. package/package.json +1 -1
  32. package/dist/styles/themes/filmstriben/theme.css +0 -108
  33. package/dist/themes/filmstriben.css +0 -4
  34. package/dist/types/assets.d.cjs +0 -2
  35. package/dist/types/assets.d.js +0 -1
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ function isBrowser() {
4
+ return typeof window !== "undefined" && typeof window.sessionStorage !== "undefined";
5
+ }
6
+ function readSessionStorage(key) {
7
+ if (!isBrowser()) return void 0;
8
+ try {
9
+ const raw = window.sessionStorage.getItem(key);
10
+ if (raw == null) return void 0;
11
+ try {
12
+ const parsed = JSON.parse(raw);
13
+ if (typeof parsed === "string") {
14
+ try {
15
+ return JSON.parse(parsed);
16
+ } catch {
17
+ return parsed;
18
+ }
19
+ }
20
+ return parsed;
21
+ } catch {
22
+ return raw;
23
+ }
24
+ } catch {
25
+ return void 0;
26
+ }
27
+ }
28
+ function writeSessionStorage(key, value) {
29
+ if (!isBrowser()) return;
30
+ try {
31
+ if (value === void 0) {
32
+ window.sessionStorage.removeItem(key);
33
+ return;
34
+ }
35
+ if (typeof value === "string") {
36
+ window.sessionStorage.setItem(key, value);
37
+ } else {
38
+ window.sessionStorage.setItem(key, JSON.stringify(value));
39
+ }
40
+ } catch {
41
+ }
42
+ }
43
+ function removeSessionStorage(key) {
44
+ if (!isBrowser()) return;
45
+ try {
46
+ window.sessionStorage.removeItem(key);
47
+ } catch {
48
+ }
49
+ }
50
+
51
+ exports.readSessionStorage = readSessionStorage;
52
+ exports.removeSessionStorage = removeSessionStorage;
53
+ exports.writeSessionStorage = writeSessionStorage;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Safely read from sessionStorage.
3
+ * - Returns undefined if not in browser
4
+ * - Returns parsed JSON if value is JSON
5
+ * - Returns plain string if not JSON
6
+ * - Never throws
7
+ */
8
+ export declare function readSessionStorage<T = unknown>(key: string): T | string | undefined;
9
+ /**
10
+ * Safely write to sessionStorage.
11
+ * - Automatically JSON.stringifies objects/arrays
12
+ * - Stores plain strings as-is
13
+ * - Never throws
14
+ */
15
+ export declare function writeSessionStorage(key: string, value: unknown): void;
16
+ /**
17
+ * Remove key safely
18
+ */
19
+ export declare function removeSessionStorage(key: string): void;
@@ -0,0 +1,49 @@
1
+ function isBrowser() {
2
+ return typeof window !== "undefined" && typeof window.sessionStorage !== "undefined";
3
+ }
4
+ function readSessionStorage(key) {
5
+ if (!isBrowser()) return void 0;
6
+ try {
7
+ const raw = window.sessionStorage.getItem(key);
8
+ if (raw == null) return void 0;
9
+ try {
10
+ const parsed = JSON.parse(raw);
11
+ if (typeof parsed === "string") {
12
+ try {
13
+ return JSON.parse(parsed);
14
+ } catch {
15
+ return parsed;
16
+ }
17
+ }
18
+ return parsed;
19
+ } catch {
20
+ return raw;
21
+ }
22
+ } catch {
23
+ return void 0;
24
+ }
25
+ }
26
+ function writeSessionStorage(key, value) {
27
+ if (!isBrowser()) return;
28
+ try {
29
+ if (value === void 0) {
30
+ window.sessionStorage.removeItem(key);
31
+ return;
32
+ }
33
+ if (typeof value === "string") {
34
+ window.sessionStorage.setItem(key, value);
35
+ } else {
36
+ window.sessionStorage.setItem(key, JSON.stringify(value));
37
+ }
38
+ } catch {
39
+ }
40
+ }
41
+ function removeSessionStorage(key) {
42
+ if (!isBrowser()) return;
43
+ try {
44
+ window.sessionStorage.removeItem(key);
45
+ } catch {
46
+ }
47
+ }
48
+
49
+ export { readSessionStorage, removeSessionStorage, writeSessionStorage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbcdk/react-components",
3
- "version": "0.0.175",
3
+ "version": "0.0.177",
4
4
  "description": "Reusable React components for DBC projects",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -1,108 +0,0 @@
1
- /* Filmstriben theme entrypoint.
2
- *
3
- * Usage in the consuming app:
4
- * - Simplest: import the convenience bundle instead of this file directly —
5
- * @import '@dbcdk/react-components/themes/filmstriben.css';
6
- * (bundles dbc/base.css + dbc/colors.css + this file + the shared index.css)
7
- * - Or, for runtime theme switching (see useTheme/ThemeScript), import
8
- * dbc's base + colors as your permanent foundation, then load this
9
- * file — just the delta below — only when this theme is actually active:
10
- * @import '@dbcdk/react-components/styles/themes/dbc/base.css';
11
- * @import '@dbcdk/react-components/styles/themes/dbc/colors.css';
12
- * @import '@dbcdk/react-components/styles/themes/filmstriben/theme.css';
13
- *
14
- * This file deliberately does NOT import dbc/colors.css itself (unlike a
15
- * typical single-theme entrypoint) and scopes every override behind
16
- * [data-product-theme='filmstriben'] instead of a bare :root — both are what
17
- * let it be safely loaded *alongside* dbc's palette and toggled at runtime by
18
- * flipping that attribute, without re-declaring or clobbering the whole dbc
19
- * palette a second time.
20
- *
21
- * Uses a split brand strategy:
22
- * - light theme: semantic UI primary stays on blue for contrast and clarity
23
- * - dark theme: the real Filmstriben yellow, which has enough contrast there
24
- *
25
- * Navbar/header identity still uses the raw yellow directly because it always
26
- * sits on its own guaranteed dark background.
27
- */
28
-
29
- :root[data-product-theme='filmstriben'] {
30
- --filmstriben-yellow: #ffc107;
31
- --filmstriben-black: #212529;
32
-
33
- /* Navbar — fixed dark bar regardless of light/dark color-scheme */
34
- --color-navbar-bg: var(--filmstriben-black);
35
- --color-navbar-fg: #ffffff;
36
- --color-navbar-fg-muted: rgba(255, 255, 255, 0.9);
37
- /* Softer than full navbar-fg at rest — header components escalate to full
38
- strength on hover/focus (see Button/Input/FormSelect's .header variant) */
39
- --color-navbar-border: color-mix(in srgb, var(--color-navbar-fg) 25%, transparent);
40
- /* Active nav-link accent — the raw vivid yellow is safe here specifically
41
- because it always sits on this fixed dark bar, unlike --color-brand
42
- (which follows light-dark() for the page's own background) */
43
- --color-navbar-brand: var(--filmstriben-yellow);
44
-
45
- /* Logo lockup — sits on the light page surface (via --color-logo-bg's
46
- tint) or the dark navbar, never as flat text on a plain white bg, so
47
- the raw vivid yellow is safe here unlike a general --color-brand value */
48
- --color-logo: var(--filmstriben-yellow);
49
- --color-logo-bg: color-mix(in srgb, var(--color-logo) 10%, var(--color-bg-surface));
50
- --color-logo-fg: var(--filmstriben-black);
51
-
52
- /* Light-theme UI primary stays semantic and high-contrast; Filmstriben's
53
- real yellow remains available for identity-bearing accents instead. */
54
- --color-brand: var(--dbc-blue-500);
55
- --color-brand-hover: var(--dbc-blue-600);
56
- --color-brand-strong: var(--dbc-blue-600);
57
- --color-fg-on-brand: #ffffff;
58
- --color-border-selected: var(--color-brand);
59
- --color-field-focus: var(--dbc-blue-500);
60
- --color-focus-ring: var(--dbc-blue-300);
61
- --focus-ring: 0 0 0 3px rgba(12, 62, 227, 0.25);
62
- --color-link: var(--dbc-blue-500);
63
- --color-link-hover: var(--dbc-blue-600);
64
- --color-bg-selected: var(--dbc-blue-100);
65
- --color-bg-selected-hover: var(--dbc-blue-150);
66
- --color-chart-primary: color-mix(in srgb, var(--color-brand) 75%, rgb(255 255 255 / 0));
67
- }
68
-
69
- :root[data-product-theme='filmstriben'][data-theme='dark'] {
70
- /* Dark surfaces tuned to the navbar's grey-black identity instead of dbc's cooler blue darks. */
71
- --filmstriben-surface-page: #212529;
72
- --filmstriben-surface-subtle: #2a2f34;
73
- --filmstriben-surface-strong: #161a1d;
74
- --filmstriben-surface-hover: #343a40;
75
- --filmstriben-surface-inverse: #34393f;
76
- --filmstriben-table-row-alt: #1c2024;
77
- --filmstriben-yellow-hover: #ffca2c;
78
- --filmstriben-yellow-strong: #ffcd39;
79
- --filmstriben-yellow-soft: #4a3a06;
80
- --filmstriben-yellow-soft-hover: #5b4707;
81
-
82
- --color-bg-page: var(--filmstriben-surface-page);
83
- --color-bg-surface: var(--filmstriben-surface-page);
84
- --color-bg-surface-subtle: var(--filmstriben-surface-subtle);
85
- --color-bg-surface-strong: var(--filmstriben-surface-strong);
86
- --color-bg-inverse: var(--filmstriben-surface-inverse);
87
- --color-bg-toolbar: var(--filmstriben-surface-subtle);
88
- --color-bg-toolbar-hover: var(--filmstriben-surface-hover);
89
-
90
- --table-header-bg: var(--filmstriben-surface-subtle);
91
- --table-row-bg: var(--filmstriben-surface-page);
92
- --table-row-bg-alt: var(--filmstriben-table-row-alt);
93
- --table-row-bg-hover: var(--filmstriben-surface-subtle);
94
-
95
- /* In dark mode the Filmstriben yellow has enough contrast to become the primary brand color. */
96
- --color-brand: var(--filmstriben-yellow);
97
- --color-brand-hover: var(--filmstriben-yellow-hover);
98
- --color-brand-strong: var(--filmstriben-yellow-strong);
99
- --color-fg-on-brand: var(--filmstriben-black);
100
- --color-border-selected: var(--color-brand);
101
- --color-field-focus: var(--dbc-blue-300);
102
- --color-focus-ring: var(--filmstriben-yellow);
103
- --focus-ring: 0 0 0 3px color-mix(in srgb, var(--filmstriben-yellow) 35%, transparent);
104
-
105
- --color-bg-selected: var(--filmstriben-yellow-soft);
106
- --color-bg-selected-hover: var(--filmstriben-yellow-soft-hover);
107
- --color-chart-primary: color-mix(in srgb, var(--color-brand) 75%, rgb(255 255 255 / 0));
108
- }
@@ -1,4 +0,0 @@
1
- @import '../styles/themes/dbc/base.css';
2
- @import '../styles/themes/dbc/colors.css';
3
- @import '../styles/themes/filmstriben/theme.css';
4
- @import '../index.css';
@@ -1,2 +0,0 @@
1
- 'use strict';
2
-
@@ -1 +0,0 @@
1
-