@pure-ds/core 0.5.60 → 0.6.1

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 (43) hide show
  1. package/dist/types/packages/pds-configurator/src/pds-home-content.d.ts +375 -0
  2. package/dist/types/packages/pds-configurator/src/pds-home-content.d.ts.map +1 -0
  3. package/dist/types/packages/pds-configurator/src/pds-home.d.ts +2 -0
  4. package/dist/types/packages/pds-configurator/src/pds-home.d.ts.map +1 -0
  5. package/dist/types/pds.config.d.ts +4 -8
  6. package/dist/types/pds.config.d.ts.map +1 -1
  7. package/dist/types/pds.d.ts +3 -1
  8. package/dist/types/public/assets/js/pds-manager.d.ts.map +1 -1
  9. package/dist/types/public/assets/js/pds.d.ts.map +1 -1
  10. package/dist/types/public/assets/pds/components/pds-live-edit.d.ts +150 -0
  11. package/dist/types/public/assets/pds/components/pds-live-edit.d.ts.map +1 -0
  12. package/dist/types/public/assets/pds/components/pds-omnibox.d.ts +2 -0
  13. package/dist/types/public/assets/pds/components/pds-omnibox.d.ts.map +1 -1
  14. package/dist/types/public/assets/pds/components/pds-richtext.d.ts.map +1 -1
  15. package/dist/types/public/assets/pds/components/pds-theme.d.ts +5 -0
  16. package/dist/types/public/assets/pds/components/pds-theme.d.ts.map +1 -1
  17. package/dist/types/src/js/pds-core/pds-config.d.ts +457 -0
  18. package/dist/types/src/js/pds-core/pds-config.d.ts.map +1 -1
  19. package/dist/types/src/js/pds-core/pds-enhancers.d.ts.map +1 -1
  20. package/dist/types/src/js/pds-core/pds-live.d.ts.map +1 -1
  21. package/dist/types/src/js/pds-core/pds-ontology.d.ts.map +1 -1
  22. package/dist/types/src/js/pds-core/pds-start-helpers.d.ts.map +1 -1
  23. package/dist/types/src/js/pds-core/pds-theme-utils.d.ts +6 -0
  24. package/dist/types/src/js/pds-core/pds-theme-utils.d.ts.map +1 -0
  25. package/dist/types/src/js/pds.d.ts.map +1 -1
  26. package/package.json +1 -4
  27. package/packages/pds-cli/bin/templates/bootstrap/pds.config.js +9 -2
  28. package/public/assets/js/app.js +106 -5636
  29. package/public/assets/js/pds-manager.js +156 -156
  30. package/public/assets/js/pds.js +7 -7
  31. package/public/assets/pds/components/pds-live-edit.js +1555 -0
  32. package/public/assets/pds/components/pds-omnibox.js +558 -369
  33. package/public/assets/pds/components/pds-richtext.js +57 -7
  34. package/public/assets/pds/components/pds-theme.js +58 -0
  35. package/readme.md +2 -2
  36. package/src/js/pds-core/pds-config.js +705 -1
  37. package/src/js/pds-core/pds-enhancers.js +61 -4
  38. package/src/js/pds-core/pds-live.js +545 -437
  39. package/src/js/pds-core/pds-ontology.js +8 -0
  40. package/src/js/pds-core/pds-start-helpers.js +15 -0
  41. package/src/js/pds-core/pds-theme-utils.js +33 -0
  42. package/src/js/pds.d.ts +3 -1
  43. package/src/js/pds.js +22 -0
@@ -246,6 +246,14 @@ export const ontology = {
246
246
  tags: ["form", "schema", "auto-generate"],
247
247
  category: "form"
248
248
  },
249
+ {
250
+ id: "pds-live-edit",
251
+ name: "Live Edit",
252
+ description: "Contextual live editing for PDS design settings",
253
+ selectors: ["pds-live-edit"],
254
+ tags: ["editor", "live", "config", "tooling"],
255
+ category: "tooling"
256
+ },
249
257
  {
250
258
  id: "pds-splitpanel",
251
259
  name: "Split Panel",
@@ -3,6 +3,8 @@
3
3
  * Kept separate to avoid pulling live-only logic into the base runtime bundle.
4
4
  */
5
5
 
6
+ import { validateDesignConfig, validateInitConfig } from "./pds-config.js";
7
+
6
8
  const __ABSOLUTE_URL_PATTERN__ = /^[a-z][a-z0-9+\-.]*:\/\//i;
7
9
  const __MODULE_URL__ = (() => {
8
10
  try {
@@ -130,6 +132,11 @@ export function stripFunctions(obj) {
130
132
 
131
133
  // Internal: normalize first-arg config to a full generator config and extract enhancers if provided inline
132
134
  export function normalizeInitConfig(inputConfig = {}, options = {}, { presets, defaultLog }) {
135
+ const logFn =
136
+ inputConfig && typeof inputConfig.log === "function"
137
+ ? inputConfig.log
138
+ : defaultLog;
139
+
133
140
  // If caller passed a plain design config (legacy), keep as-is
134
141
  const hasDesignKeys =
135
142
  typeof inputConfig === "object" &&
@@ -167,10 +174,17 @@ export function normalizeInitConfig(inputConfig = {}, options = {}, { presets, d
167
174
  "design" in (inputConfig || {}) ||
168
175
  "enhancers" in (inputConfig || {});
169
176
 
177
+ if (inputConfig && typeof inputConfig === "object") {
178
+ validateInitConfig(inputConfig, { log: logFn, context: "PDS.start" });
179
+ }
180
+
170
181
  let generatorConfig;
171
182
  let presetInfo = null;
172
183
 
173
184
  if (hasNewShape) {
185
+ if (designOverrides && typeof designOverrides === "object") {
186
+ validateDesignConfig(designOverrides, { log: logFn, context: "PDS.start" });
187
+ }
174
188
  // Always resolve a preset; default if none provided
175
189
  const effectivePreset = String(presetId || "default").toLowerCase();
176
190
  const found =
@@ -228,6 +242,7 @@ export function normalizeInitConfig(inputConfig = {}, options = {}, { presets, d
228
242
  log: userLog || defaultLog,
229
243
  };
230
244
  } else if (hasDesignKeys) {
245
+ validateDesignConfig(inputConfig, { log: logFn, context: "PDS.start" });
231
246
  // Back-compat: treat the provided object as the full design, wrap it
232
247
  const { log: userLog, ...designConfig } = inputConfig;
233
248
  generatorConfig = {
@@ -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:
@@ -286,7 +289,6 @@ export class PDS extends EventTarget {
286
289
  // live-only
287
290
  preloadStyles?: boolean;
288
291
  criticalLayers?: string[];
289
- applyConfiguratorStyles?: boolean;
290
292
  managerURL?: string;
291
293
  // static-only
292
294
  staticPaths?: Record<string, string>;
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 {