@pure-ds/core 0.5.61 → 0.6.2
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.
- package/dist/types/packages/pds-configurator/src/pds-home-content.d.ts +375 -0
- package/dist/types/packages/pds-configurator/src/pds-home-content.d.ts.map +1 -0
- package/dist/types/packages/pds-configurator/src/pds-home.d.ts +2 -0
- package/dist/types/packages/pds-configurator/src/pds-home.d.ts.map +1 -0
- package/dist/types/pds.config.d.ts +2 -2
- package/dist/types/pds.config.d.ts.map +1 -1
- package/dist/types/pds.d.ts +3 -0
- package/dist/types/public/assets/js/pds-manager.d.ts +144 -429
- package/dist/types/public/assets/js/pds-manager.d.ts.map +1 -1
- package/dist/types/public/assets/js/pds.d.ts +3 -4
- package/dist/types/public/assets/js/pds.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-live-edit.d.ts +150 -0
- package/dist/types/public/assets/pds/components/pds-live-edit.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-omnibox.d.ts +2 -0
- package/dist/types/public/assets/pds/components/pds-omnibox.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-richtext.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-theme.d.ts +5 -10
- package/dist/types/public/assets/pds/components/pds-theme.d.ts.map +1 -1
- package/dist/types/src/js/pds-core/pds-config.d.ts +3 -0
- package/dist/types/src/js/pds-core/pds-config.d.ts.map +1 -1
- package/dist/types/src/js/pds-core/pds-enhancers.d.ts.map +1 -1
- package/dist/types/src/js/pds-core/pds-live.d.ts.map +1 -1
- package/dist/types/src/js/pds-core/pds-ontology.d.ts.map +1 -1
- package/dist/types/src/js/pds-core/pds-theme-utils.d.ts +6 -0
- package/dist/types/src/js/pds-core/pds-theme-utils.d.ts.map +1 -0
- package/dist/types/src/js/pds.d.ts.map +1 -1
- package/package.json +1 -4
- package/packages/pds-cli/bin/templates/bootstrap/pds.config.js +1 -1
- package/public/assets/js/app.js +106 -5636
- package/public/assets/js/pds-manager.js +137 -137
- package/public/assets/js/pds.js +7 -7
- package/public/assets/pds/components/pds-live-edit.js +1555 -0
- package/public/assets/pds/components/pds-omnibox.js +558 -369
- package/public/assets/pds/components/pds-richtext.js +57 -7
- package/public/assets/pds/components/pds-theme.js +59 -39
- package/readme.md +2 -2
- package/src/js/pds-core/pds-config.js +21 -3
- package/src/js/pds-core/pds-enhancers.js +61 -4
- package/src/js/pds-core/pds-live.js +180 -1
- package/src/js/pds-core/pds-ontology.js +8 -0
- package/src/js/pds-core/pds-theme-utils.js +33 -0
- package/src/js/pds.d.ts +3 -0
- package/src/js/pds.js +22 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const DEFAULT_THEMES = ["light", "dark"];
|
|
2
|
+
const VALID_THEMES = new Set(DEFAULT_THEMES);
|
|
3
|
+
|
|
4
|
+
export function normalizePresetThemes(preset) {
|
|
5
|
+
const themes = Array.isArray(preset?.themes)
|
|
6
|
+
? preset.themes.map((theme) => String(theme).toLowerCase())
|
|
7
|
+
: DEFAULT_THEMES;
|
|
8
|
+
const normalized = themes.filter((theme) => VALID_THEMES.has(theme));
|
|
9
|
+
return normalized.length ? normalized : DEFAULT_THEMES;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function resolveThemePreference(preference, { preferDocument = true } = {}) {
|
|
13
|
+
const normalized = String(preference || "").toLowerCase();
|
|
14
|
+
if (VALID_THEMES.has(normalized)) return normalized;
|
|
15
|
+
|
|
16
|
+
if (preferDocument && typeof document !== "undefined") {
|
|
17
|
+
const applied = document.documentElement?.getAttribute("data-theme");
|
|
18
|
+
if (VALID_THEMES.has(applied)) return applied;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (typeof window !== "undefined" && window.matchMedia) {
|
|
22
|
+
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
23
|
+
return prefersDark ? "dark" : "light";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return "light";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function isPresetThemeCompatible(preset, themePreference) {
|
|
30
|
+
const resolvedTheme = resolveThemePreference(themePreference);
|
|
31
|
+
const themes = normalizePresetThemes(preset);
|
|
32
|
+
return themes.includes(resolvedTheme);
|
|
33
|
+
}
|
package/src/js/pds.d.ts
CHANGED
|
@@ -104,6 +104,9 @@ export interface CompiledState {
|
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
/** Public config types for editor IntelliSense */
|
|
108
|
+
export type PDSInitConfig = import("./pds-core/pds-config.js").PDSInitConfig;
|
|
109
|
+
|
|
107
110
|
/**
|
|
108
111
|
* Generator - programmatic API to produce tokens, layered CSS and helper modules from a config.
|
|
109
112
|
* Typical usage:
|
package/src/js/pds.js
CHANGED
|
@@ -68,6 +68,10 @@ import {
|
|
|
68
68
|
setupAutoDefinerAndEnhancers,
|
|
69
69
|
stripFunctions,
|
|
70
70
|
} from "./pds-core/pds-start-helpers.js";
|
|
71
|
+
import {
|
|
72
|
+
isPresetThemeCompatible,
|
|
73
|
+
resolveThemePreference,
|
|
74
|
+
} from "./pds-core/pds-theme-utils.js";
|
|
71
75
|
|
|
72
76
|
const __slugifyPreset = (str = "") =>
|
|
73
77
|
String(str)
|
|
@@ -261,6 +265,24 @@ Object.defineProperty(PDS, "theme", {
|
|
|
261
265
|
set(value) {
|
|
262
266
|
try {
|
|
263
267
|
if (typeof window === "undefined") return;
|
|
268
|
+
const currentPreset = PDS.currentConfig?.design || null;
|
|
269
|
+
const resolvedTheme = resolveThemePreference(value);
|
|
270
|
+
if (currentPreset && !isPresetThemeCompatible(currentPreset, resolvedTheme)) {
|
|
271
|
+
const presetName =
|
|
272
|
+
currentPreset?.name ||
|
|
273
|
+
PDS.currentPreset?.name ||
|
|
274
|
+
PDS.currentConfig?.preset ||
|
|
275
|
+
"current preset";
|
|
276
|
+
console.warn(
|
|
277
|
+
`PDS theme "${resolvedTheme}" not supported by preset "${presetName}".`
|
|
278
|
+
);
|
|
279
|
+
PDS.dispatchEvent(
|
|
280
|
+
new CustomEvent("pds:theme:blocked", {
|
|
281
|
+
detail: { theme: value, resolvedTheme, preset: presetName },
|
|
282
|
+
})
|
|
283
|
+
);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
264
286
|
if (value === null || value === undefined) {
|
|
265
287
|
localStorage.removeItem(__themeStorageKey);
|
|
266
288
|
} else {
|