@pure-ds/core 0.7.5 → 0.7.6
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/public/assets/js/pds-ask.d.ts +1 -2
- package/dist/types/public/assets/js/pds-ask.d.ts.map +1 -1
- package/dist/types/public/assets/js/pds-autocomplete.d.ts +36 -25
- package/dist/types/public/assets/js/pds-autocomplete.d.ts.map +1 -1
- package/dist/types/public/assets/js/pds-enhancers.d.ts +4 -4
- package/dist/types/public/assets/js/pds-enhancers.d.ts.map +1 -1
- package/dist/types/public/assets/js/pds-manager.d.ts +159 -444
- package/dist/types/public/assets/js/pds-manager.d.ts.map +1 -1
- package/dist/types/public/assets/js/pds-toast.d.ts +6 -7
- package/dist/types/public/assets/js/pds-toast.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/package.json +1 -1
- package/public/assets/js/app.js +4 -1582
- package/public/assets/js/lit.js +3 -1078
- package/public/assets/js/pds-ask.js +9 -239
- package/public/assets/js/pds-autocomplete.js +7 -590
- package/public/assets/js/pds-enhancers.js +1 -689
- package/public/assets/js/pds-manager.js +3156 -16002
- package/public/assets/js/pds-toast.js +1 -30
- package/public/assets/js/pds.js +2 -1442
- package/public/assets/pds/core/pds-ask.js +9 -239
- package/public/assets/pds/core/pds-autocomplete.js +7 -590
- package/public/assets/pds/core/pds-enhancers.js +1 -689
- package/public/assets/pds/core/pds-manager.js +3156 -16002
- package/public/assets/pds/core/pds-toast.js +1 -30
- package/public/assets/pds/core.js +2 -1442
- package/public/assets/pds/external/lit.js +3 -1078
- package/public/assets/js/app.js.map +0 -7
- package/public/assets/js/lit.js.map +0 -7
- package/public/assets/js/pds-ask.js.map +0 -7
- package/public/assets/js/pds-autocomplete.js.map +0 -7
- package/public/assets/js/pds-enhancers.js.map +0 -7
- package/public/assets/js/pds-manager.js.map +0 -7
- package/public/assets/js/pds-toast.js.map +0 -7
- package/public/assets/js/pds.js.map +0 -7
package/public/assets/js/app.js
CHANGED
|
@@ -1,1590 +1,12 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __export = (target, all) => {
|
|
3
|
-
for (var name in all)
|
|
4
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
// src/js/pds-core/pds-registry.js
|
|
8
|
-
var PDSRegistry = class {
|
|
9
|
-
constructor() {
|
|
10
|
-
this._mode = "static";
|
|
11
|
-
this._staticPaths = {
|
|
12
|
-
tokens: "/assets/pds/styles/pds-tokens.css.js",
|
|
13
|
-
primitives: "/assets/pds/styles/pds-primitives.css.js",
|
|
14
|
-
components: "/assets/pds/styles/pds-components.css.js",
|
|
15
|
-
utilities: "/assets/pds/styles/pds-utilities.css.js",
|
|
16
|
-
styles: "/assets/pds/styles/pds-styles.css.js"
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Switch to live mode
|
|
21
|
-
*/
|
|
22
|
-
setLiveMode() {
|
|
23
|
-
this._mode = "live";
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Switch to static mode with custom paths
|
|
27
|
-
* Called by consumers who want to use static CSS files
|
|
28
|
-
*/
|
|
29
|
-
setStaticMode(paths = {}) {
|
|
30
|
-
this._mode = "static";
|
|
31
|
-
this._staticPaths = { ...this._staticPaths, ...paths };
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Get stylesheet for adoption in shadow DOM
|
|
35
|
-
* Returns CSSStyleSheet object (constructable stylesheet)
|
|
36
|
-
*/
|
|
37
|
-
async getStylesheet(layer) {
|
|
38
|
-
if (this._mode === "live") {
|
|
39
|
-
return null;
|
|
40
|
-
} else {
|
|
41
|
-
try {
|
|
42
|
-
const module = await import(
|
|
43
|
-
/* @vite-ignore */
|
|
44
|
-
this._staticPaths[layer]
|
|
45
|
-
);
|
|
46
|
-
return module[layer];
|
|
47
|
-
} catch (error) {
|
|
48
|
-
console.error(`[PDS Registry] Failed to load static ${layer}:`, error);
|
|
49
|
-
console.error(`[PDS Registry] Looking for: ${this._staticPaths[layer]}`);
|
|
50
|
-
console.error(`[PDS Registry] Make sure you've run 'npm run pds:build' and configured PDS.start() with the correct static.root path`);
|
|
51
|
-
const fallback = new CSSStyleSheet();
|
|
52
|
-
fallback.replaceSync("/* Failed to load " + layer + " */");
|
|
53
|
-
return fallback;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Get current mode
|
|
59
|
-
*/
|
|
60
|
-
get mode() {
|
|
61
|
-
return this._mode;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Check if in live mode
|
|
65
|
-
*/
|
|
66
|
-
get isLive() {
|
|
67
|
-
return this._mode === "live";
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
var registry = new PDSRegistry();
|
|
71
|
-
|
|
72
|
-
// src/js/pds-core/pds-runtime.js
|
|
73
|
-
async function adoptPrimitives(shadowRoot, additionalSheets = [], generator = null) {
|
|
74
|
-
try {
|
|
75
|
-
const primitives = generator?.primitivesStylesheet ? generator.primitivesStylesheet : await registry.getStylesheet("primitives");
|
|
76
|
-
shadowRoot.adoptedStyleSheets = [primitives, ...additionalSheets];
|
|
77
|
-
} catch (error) {
|
|
78
|
-
const componentName = shadowRoot.host?.tagName?.toLowerCase() || "unknown";
|
|
79
|
-
console.error(
|
|
80
|
-
`[PDS Adopter] <${componentName}> failed to adopt primitives:`,
|
|
81
|
-
error
|
|
82
|
-
);
|
|
83
|
-
shadowRoot.adoptedStyleSheets = additionalSheets;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
async function adoptLayers(shadowRoot, layers = ["primitives"], additionalSheets = [], generator = null) {
|
|
87
|
-
try {
|
|
88
|
-
const stylesheets = await Promise.all(
|
|
89
|
-
layers.map(async (layer) => {
|
|
90
|
-
if (generator) {
|
|
91
|
-
switch (layer) {
|
|
92
|
-
case "tokens":
|
|
93
|
-
return generator.tokensStylesheet;
|
|
94
|
-
case "primitives":
|
|
95
|
-
return generator.primitivesStylesheet;
|
|
96
|
-
case "components":
|
|
97
|
-
return generator.componentsStylesheet;
|
|
98
|
-
case "utilities":
|
|
99
|
-
return generator.utilitiesStylesheet;
|
|
100
|
-
default:
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return registry.getStylesheet(layer);
|
|
105
|
-
})
|
|
106
|
-
);
|
|
107
|
-
const validStylesheets = stylesheets.filter((sheet) => sheet !== null);
|
|
108
|
-
shadowRoot.adoptedStyleSheets = [...validStylesheets, ...additionalSheets];
|
|
109
|
-
} catch (error) {
|
|
110
|
-
const componentName = shadowRoot.host?.tagName?.toLowerCase() || "unknown";
|
|
111
|
-
console.error(
|
|
112
|
-
`[PDS Adopter] <${componentName}> failed to adopt layers:`,
|
|
113
|
-
error
|
|
114
|
-
);
|
|
115
|
-
shadowRoot.adoptedStyleSheets = additionalSheets;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
function createStylesheet(css) {
|
|
119
|
-
const sheet = new CSSStyleSheet();
|
|
120
|
-
sheet.replaceSync(css);
|
|
121
|
-
return sheet;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// src/js/pds-core/pds-enums.js
|
|
125
|
-
var enums = {
|
|
126
|
-
FontWeights: {
|
|
127
|
-
light: 300,
|
|
128
|
-
normal: 400,
|
|
129
|
-
medium: 500,
|
|
130
|
-
semibold: 600,
|
|
131
|
-
bold: 700
|
|
132
|
-
},
|
|
133
|
-
LineHeights: {
|
|
134
|
-
tight: 1.25,
|
|
135
|
-
normal: 1.5,
|
|
136
|
-
relaxed: 1.75
|
|
137
|
-
},
|
|
138
|
-
BorderWidths: {
|
|
139
|
-
hairline: 0.5,
|
|
140
|
-
thin: 1,
|
|
141
|
-
medium: 2,
|
|
142
|
-
thick: 3
|
|
143
|
-
},
|
|
144
|
-
RadiusSizes: {
|
|
145
|
-
none: 0,
|
|
146
|
-
small: 4,
|
|
147
|
-
medium: 8,
|
|
148
|
-
large: 16,
|
|
149
|
-
xlarge: 24,
|
|
150
|
-
xxlarge: 32
|
|
151
|
-
},
|
|
152
|
-
ShadowDepths: {
|
|
153
|
-
none: "none",
|
|
154
|
-
light: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
|
|
155
|
-
medium: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
|
|
156
|
-
deep: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",
|
|
157
|
-
extreme: "0 25px 50px -12px rgba(0, 0, 0, 0.25)"
|
|
158
|
-
},
|
|
159
|
-
TransitionSpeeds: {
|
|
160
|
-
fast: 150,
|
|
161
|
-
normal: 250,
|
|
162
|
-
slow: 350
|
|
163
|
-
},
|
|
164
|
-
AnimationEasings: {
|
|
165
|
-
linear: "linear",
|
|
166
|
-
ease: "ease",
|
|
167
|
-
"ease-in": "ease-in",
|
|
168
|
-
"ease-out": "ease-out",
|
|
169
|
-
"ease-in-out": "ease-in-out",
|
|
170
|
-
bounce: "cubic-bezier(0.68, -0.55, 0.265, 1.55)"
|
|
171
|
-
},
|
|
172
|
-
TouchTargetSizes: {
|
|
173
|
-
compact: 36,
|
|
174
|
-
standard: 44,
|
|
175
|
-
// iOS/Android accessibility standard
|
|
176
|
-
comfortable: 48,
|
|
177
|
-
spacious: 56
|
|
178
|
-
},
|
|
179
|
-
LinkStyles: {
|
|
180
|
-
inline: "inline",
|
|
181
|
-
// Normal inline text links
|
|
182
|
-
block: "block",
|
|
183
|
-
// Block-level links
|
|
184
|
-
button: "button"
|
|
185
|
-
// Button-like links (flex with touch target)
|
|
186
|
-
},
|
|
187
|
-
FocusStyles: {
|
|
188
|
-
ring: "ring",
|
|
189
|
-
// Box-shadow ring (default)
|
|
190
|
-
outline: "outline",
|
|
191
|
-
// Browser outline
|
|
192
|
-
border: "border",
|
|
193
|
-
// Border change
|
|
194
|
-
glow: "glow"
|
|
195
|
-
// Subtle glow effect
|
|
196
|
-
},
|
|
197
|
-
TabSizes: {
|
|
198
|
-
compact: 2,
|
|
199
|
-
standard: 4,
|
|
200
|
-
wide: 8
|
|
201
|
-
},
|
|
202
|
-
SelectIcons: {
|
|
203
|
-
chevron: "chevron",
|
|
204
|
-
// Standard chevron down
|
|
205
|
-
arrow: "arrow",
|
|
206
|
-
// Simple arrow
|
|
207
|
-
caret: "caret",
|
|
208
|
-
// Triangle caret
|
|
209
|
-
none: "none"
|
|
210
|
-
// No icon
|
|
211
|
-
},
|
|
212
|
-
IconSizes: {
|
|
213
|
-
xs: 16,
|
|
214
|
-
sm: 20,
|
|
215
|
-
md: 24,
|
|
216
|
-
lg: 32,
|
|
217
|
-
xl: 48,
|
|
218
|
-
"2xl": 64,
|
|
219
|
-
"3xl": 96
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
// src/js/common/common.js
|
|
224
|
-
var common_exports = {};
|
|
225
|
-
__export(common_exports, {
|
|
226
|
-
deepMerge: () => deepMerge,
|
|
227
|
-
fragmentFromTemplateLike: () => fragmentFromTemplateLike,
|
|
228
|
-
isObject: () => isObject,
|
|
229
|
-
parseHTML: () => parseHTML
|
|
230
|
-
});
|
|
231
|
-
function isObject(item) {
|
|
232
|
-
return item && typeof item === "object" && !Array.isArray(item);
|
|
233
|
-
}
|
|
234
|
-
function deepMerge(target, source) {
|
|
235
|
-
const output = { ...target };
|
|
236
|
-
if (isObject(target) && isObject(source)) {
|
|
237
|
-
Object.keys(source).forEach((key) => {
|
|
238
|
-
if (isObject(source[key])) {
|
|
239
|
-
if (!(key in target))
|
|
240
|
-
Object.assign(output, { [key]: source[key] });
|
|
241
|
-
else
|
|
242
|
-
output[key] = deepMerge(target[key], source[key]);
|
|
243
|
-
} else {
|
|
244
|
-
Object.assign(output, { [key]: source[key] });
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
return output;
|
|
249
|
-
}
|
|
250
|
-
function fragmentFromTemplateLike(templateLike) {
|
|
251
|
-
const strings = Array.isArray(templateLike?.strings) ? templateLike.strings : [];
|
|
252
|
-
const values = Array.isArray(templateLike?.values) ? templateLike.values : [];
|
|
253
|
-
const consumedValues = /* @__PURE__ */ new Set();
|
|
254
|
-
const htmlParts = [];
|
|
255
|
-
const propBindingPattern = /(\s)(\.[\w-]+)=\s*$/;
|
|
256
|
-
for (let i = 0; i < strings.length; i += 1) {
|
|
257
|
-
let chunk = strings[i] ?? "";
|
|
258
|
-
const match = chunk.match(propBindingPattern);
|
|
259
|
-
if (match && i < values.length) {
|
|
260
|
-
const propToken = match[2];
|
|
261
|
-
const propName = propToken.slice(1);
|
|
262
|
-
const marker = `pds-val-${i}`;
|
|
263
|
-
chunk = chunk.replace(
|
|
264
|
-
propBindingPattern,
|
|
265
|
-
`$1data-pds-prop="${propName}:${marker}"`
|
|
266
|
-
);
|
|
267
|
-
consumedValues.add(i);
|
|
268
|
-
}
|
|
269
|
-
htmlParts.push(chunk);
|
|
270
|
-
if (i < values.length && !consumedValues.has(i)) {
|
|
271
|
-
htmlParts.push(`<!--pds-val-${i}-->`);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
const tpl = document.createElement("template");
|
|
275
|
-
tpl.innerHTML = htmlParts.join("");
|
|
276
|
-
const replaceValueAtMarker = (markerNode, value) => {
|
|
277
|
-
const parent = markerNode.parentNode;
|
|
278
|
-
if (!parent)
|
|
279
|
-
return;
|
|
280
|
-
if (value == null) {
|
|
281
|
-
parent.removeChild(markerNode);
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
const insertValue = (val) => {
|
|
285
|
-
if (val == null)
|
|
286
|
-
return;
|
|
287
|
-
if (val instanceof Node) {
|
|
288
|
-
parent.insertBefore(val, markerNode);
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
if (Array.isArray(val)) {
|
|
292
|
-
val.forEach((item) => insertValue(item));
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
parent.insertBefore(document.createTextNode(String(val)), markerNode);
|
|
296
|
-
};
|
|
297
|
-
insertValue(value);
|
|
298
|
-
parent.removeChild(markerNode);
|
|
299
|
-
};
|
|
300
|
-
const walker = document.createTreeWalker(tpl.content, NodeFilter.SHOW_COMMENT);
|
|
301
|
-
const markers = [];
|
|
302
|
-
while (walker.nextNode()) {
|
|
303
|
-
const node = walker.currentNode;
|
|
304
|
-
if (node?.nodeValue?.startsWith("pds-val-")) {
|
|
305
|
-
markers.push(node);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
markers.forEach((node) => {
|
|
309
|
-
const index = Number(node.nodeValue.replace("pds-val-", ""));
|
|
310
|
-
replaceValueAtMarker(node, values[index]);
|
|
311
|
-
});
|
|
312
|
-
const elements = tpl.content.querySelectorAll("*");
|
|
313
|
-
elements.forEach((el) => {
|
|
314
|
-
const propAttr = el.getAttribute("data-pds-prop");
|
|
315
|
-
if (!propAttr)
|
|
316
|
-
return;
|
|
317
|
-
const [propName, markerValue] = propAttr.split(":");
|
|
318
|
-
const index = Number(String(markerValue).replace("pds-val-", ""));
|
|
319
|
-
if (propName && Number.isInteger(index)) {
|
|
320
|
-
el[propName] = values[index];
|
|
321
|
-
}
|
|
322
|
-
el.removeAttribute("data-pds-prop");
|
|
323
|
-
});
|
|
324
|
-
return tpl.content;
|
|
325
|
-
}
|
|
326
|
-
function parseHTML(html) {
|
|
327
|
-
return new DOMParser().parseFromString(html, "text/html").body.childNodes;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// src/js/pds-core/pds-paths.js
|
|
331
|
-
var DEFAULT_SEGMENT = "pds";
|
|
332
|
-
var URL_PATTERN = /^([a-z][a-z0-9+\-.]*:)?\/\//i;
|
|
333
|
-
var DRIVE_PATTERN = /^[a-z]:/i;
|
|
334
|
-
function ensureTrailingSlash(value = "") {
|
|
335
|
-
return value.endsWith("/") ? value : `${value}/`;
|
|
336
|
-
}
|
|
337
|
-
function appendSegmentIfMissing(input = "", segment = DEFAULT_SEGMENT) {
|
|
338
|
-
const trimmed = input.replace(/\/+$/, "");
|
|
339
|
-
const regex = new RegExp(`(?:^|/)${segment}$`, "i");
|
|
340
|
-
if (regex.test(trimmed)) {
|
|
341
|
-
return trimmed;
|
|
342
|
-
}
|
|
343
|
-
return `${trimmed}/${segment}`;
|
|
344
|
-
}
|
|
345
|
-
function stripLeadingDotSlash(value) {
|
|
346
|
-
return value.replace(/^\.\/+/, "");
|
|
347
|
-
}
|
|
348
|
-
function stripDriveLetter(value) {
|
|
349
|
-
if (DRIVE_PATTERN.test(value)) {
|
|
350
|
-
return value.replace(DRIVE_PATTERN, "").replace(/^\/+/, "");
|
|
351
|
-
}
|
|
352
|
-
return value;
|
|
353
|
-
}
|
|
354
|
-
function stripPublicPrefix(value) {
|
|
355
|
-
if (value.startsWith("public/")) {
|
|
356
|
-
return value.substring("public/".length);
|
|
357
|
-
}
|
|
358
|
-
return value;
|
|
359
|
-
}
|
|
360
|
-
function resolvePublicAssetURL(config2, options = {}) {
|
|
361
|
-
const segment = options.segment || DEFAULT_SEGMENT;
|
|
362
|
-
const defaultRoot = options.defaultRoot || `/assets/${segment}/`;
|
|
363
|
-
const candidate = config2?.public && config2.public?.root || config2?.static && config2.static?.root || null;
|
|
364
|
-
if (!candidate || typeof candidate !== "string") {
|
|
365
|
-
return ensureTrailingSlash(defaultRoot);
|
|
366
|
-
}
|
|
367
|
-
let normalized = candidate.trim();
|
|
368
|
-
if (!normalized) {
|
|
369
|
-
return ensureTrailingSlash(defaultRoot);
|
|
370
|
-
}
|
|
371
|
-
normalized = normalized.replace(/\\/g, "/");
|
|
372
|
-
normalized = appendSegmentIfMissing(normalized, segment);
|
|
373
|
-
normalized = ensureTrailingSlash(normalized);
|
|
374
|
-
if (URL_PATTERN.test(normalized)) {
|
|
375
|
-
return normalized;
|
|
376
|
-
}
|
|
377
|
-
normalized = stripLeadingDotSlash(normalized);
|
|
378
|
-
normalized = stripDriveLetter(normalized);
|
|
379
|
-
if (normalized.startsWith("/")) {
|
|
380
|
-
return ensureTrailingSlash(normalized);
|
|
381
|
-
}
|
|
382
|
-
normalized = stripPublicPrefix(normalized);
|
|
383
|
-
if (!normalized.startsWith("/")) {
|
|
384
|
-
normalized = `/${normalized}`;
|
|
385
|
-
}
|
|
386
|
-
normalized = normalized.replace(
|
|
387
|
-
/\/+/g,
|
|
388
|
-
(match, offset) => offset === 0 ? match : "/"
|
|
389
|
-
);
|
|
390
|
-
return ensureTrailingSlash(normalized);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// node_modules/pure-web/src/js/auto-definer.js
|
|
394
|
-
async function defineWebComponents(...args) {
|
|
395
|
-
let opts = {};
|
|
396
|
-
if (args.length && typeof args[args.length - 1] === "object") {
|
|
397
|
-
opts = args.pop() || {};
|
|
398
|
-
}
|
|
399
|
-
const tags = args;
|
|
400
|
-
const {
|
|
401
|
-
baseURL,
|
|
402
|
-
mapper = (tag) => `${tag}.js`,
|
|
403
|
-
onError = (tag, err) => console.error(`[defineWebComponents] ${tag}:`, err)
|
|
404
|
-
} = opts;
|
|
405
|
-
const base = baseURL ? new URL(
|
|
406
|
-
baseURL,
|
|
407
|
-
typeof location !== "undefined" ? location.href : import.meta.url
|
|
408
|
-
) : new URL("./", import.meta.url);
|
|
409
|
-
const toPascal = (tag) => tag.toLowerCase().replace(/(^|-)([a-z])/g, (_, __, c) => c.toUpperCase());
|
|
410
|
-
const loadOne = async (tag) => {
|
|
411
|
-
try {
|
|
412
|
-
if (customElements.get(tag))
|
|
413
|
-
return { tag, status: "already-defined" };
|
|
414
|
-
const spec = mapper(tag);
|
|
415
|
-
const href = spec instanceof URL ? spec.href : new URL(spec, base).href;
|
|
416
|
-
const mod = await import(href);
|
|
417
|
-
const Named = mod?.default ?? mod?.[toPascal(tag)];
|
|
418
|
-
if (!Named) {
|
|
419
|
-
if (customElements.get(tag))
|
|
420
|
-
return { tag, status: "self-defined" };
|
|
421
|
-
throw new Error(
|
|
422
|
-
`No export found for ${tag}. Expected default export or named export "${toPascal(
|
|
423
|
-
tag
|
|
424
|
-
)}".`
|
|
425
|
-
);
|
|
426
|
-
}
|
|
427
|
-
if (!customElements.get(tag)) {
|
|
428
|
-
customElements.define(tag, Named);
|
|
429
|
-
return { tag, status: "defined" };
|
|
430
|
-
}
|
|
431
|
-
return { tag, status: "race-already-defined" };
|
|
432
|
-
} catch (err) {
|
|
433
|
-
onError(tag, err);
|
|
434
|
-
throw err;
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
return Promise.all(tags.map(loadOne));
|
|
438
|
-
}
|
|
439
|
-
var AutoDefiner = class {
|
|
440
|
-
constructor(options = {}) {
|
|
441
|
-
const {
|
|
442
|
-
baseURL,
|
|
443
|
-
mapper,
|
|
444
|
-
onError,
|
|
445
|
-
predicate = () => true,
|
|
446
|
-
attributeModule = "data-module",
|
|
447
|
-
root = document,
|
|
448
|
-
scanExisting = true,
|
|
449
|
-
debounceMs = 16,
|
|
450
|
-
observeShadows = true,
|
|
451
|
-
enhancers = [],
|
|
452
|
-
// [{String selector, Function run(elem)}]
|
|
453
|
-
patchAttachShadow = true
|
|
454
|
-
} = options;
|
|
455
|
-
const pending = /* @__PURE__ */ new Set();
|
|
456
|
-
const inFlight = /* @__PURE__ */ new Set();
|
|
457
|
-
const knownMissing = /* @__PURE__ */ new Set();
|
|
458
|
-
const perTagModulePath = /* @__PURE__ */ new Map();
|
|
459
|
-
const shadowObservers = /* @__PURE__ */ new WeakMap();
|
|
460
|
-
const enhancerApplied = /* @__PURE__ */ new WeakMap();
|
|
461
|
-
let timer = 0;
|
|
462
|
-
let stopped = false;
|
|
463
|
-
let restoreAttachShadow = null;
|
|
464
|
-
const applyEnhancers = (element) => {
|
|
465
|
-
if (!element || !enhancers.length)
|
|
466
|
-
return;
|
|
467
|
-
let appliedEnhancers = enhancerApplied.get(element);
|
|
468
|
-
if (!appliedEnhancers) {
|
|
469
|
-
appliedEnhancers = /* @__PURE__ */ new Set();
|
|
470
|
-
enhancerApplied.set(element, appliedEnhancers);
|
|
471
|
-
}
|
|
472
|
-
for (const enhancer of enhancers) {
|
|
473
|
-
if (!enhancer.selector || !enhancer.run)
|
|
474
|
-
continue;
|
|
475
|
-
if (appliedEnhancers.has(enhancer.selector))
|
|
476
|
-
continue;
|
|
477
|
-
try {
|
|
478
|
-
if (element.matches && element.matches(enhancer.selector)) {
|
|
479
|
-
enhancer.run(element);
|
|
480
|
-
appliedEnhancers.add(enhancer.selector);
|
|
481
|
-
}
|
|
482
|
-
} catch (err) {
|
|
483
|
-
console.warn(
|
|
484
|
-
`[AutoDefiner] Error applying enhancer for selector "${enhancer.selector}":`,
|
|
485
|
-
err
|
|
486
|
-
);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
|
-
const queueTag = (tag, el) => {
|
|
491
|
-
if (stopped)
|
|
492
|
-
return;
|
|
493
|
-
if (!tag || !tag.includes("-"))
|
|
494
|
-
return;
|
|
495
|
-
if (customElements.get(tag))
|
|
496
|
-
return;
|
|
497
|
-
if (inFlight.has(tag))
|
|
498
|
-
return;
|
|
499
|
-
if (knownMissing.has(tag))
|
|
500
|
-
return;
|
|
501
|
-
if (el && el.getAttribute) {
|
|
502
|
-
const override = el.getAttribute(attributeModule);
|
|
503
|
-
if (override && !perTagModulePath.has(tag)) {
|
|
504
|
-
perTagModulePath.set(tag, override);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
pending.add(tag);
|
|
508
|
-
schedule();
|
|
509
|
-
};
|
|
510
|
-
const schedule = () => {
|
|
511
|
-
if (timer)
|
|
512
|
-
return;
|
|
513
|
-
timer = setTimeout(flush, debounceMs);
|
|
514
|
-
};
|
|
515
|
-
const crawlTree = (rootNode) => {
|
|
516
|
-
if (!rootNode)
|
|
517
|
-
return;
|
|
518
|
-
if (rootNode.nodeType === 1) {
|
|
519
|
-
const el = (
|
|
520
|
-
/** @type {Element} */
|
|
521
|
-
rootNode
|
|
522
|
-
);
|
|
523
|
-
const tag = el.tagName?.toLowerCase();
|
|
524
|
-
if (tag && tag.includes("-") && !customElements.get(tag) && predicate(tag, el)) {
|
|
525
|
-
queueTag(tag, el);
|
|
526
|
-
}
|
|
527
|
-
applyEnhancers(el);
|
|
528
|
-
if (observeShadows && el.shadowRoot) {
|
|
529
|
-
observeShadowRoot(el.shadowRoot);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
if (rootNode.querySelectorAll) {
|
|
533
|
-
rootNode.querySelectorAll("*").forEach((e) => {
|
|
534
|
-
const t = e.tagName?.toLowerCase();
|
|
535
|
-
if (t && t.includes("-") && !customElements.get(t) && predicate(t, e)) {
|
|
536
|
-
queueTag(t, e);
|
|
537
|
-
}
|
|
538
|
-
applyEnhancers(e);
|
|
539
|
-
if (observeShadows && e.shadowRoot) {
|
|
540
|
-
observeShadowRoot(e.shadowRoot);
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
const observeShadowRoot = (sr) => {
|
|
546
|
-
if (!sr || shadowObservers.has(sr))
|
|
547
|
-
return;
|
|
548
|
-
crawlTree(sr);
|
|
549
|
-
const mo = new MutationObserver((mutations) => {
|
|
550
|
-
for (const m of mutations) {
|
|
551
|
-
m.addedNodes?.forEach((n) => {
|
|
552
|
-
crawlTree(n);
|
|
553
|
-
});
|
|
554
|
-
if (m.type === "attributes" && m.target) {
|
|
555
|
-
crawlTree(m.target);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
});
|
|
559
|
-
mo.observe(sr, {
|
|
560
|
-
childList: true,
|
|
561
|
-
subtree: true,
|
|
562
|
-
attributes: true,
|
|
563
|
-
attributeFilter: [
|
|
564
|
-
attributeModule,
|
|
565
|
-
...enhancers.map((e) => e.selector).filter((s) => s.startsWith("data-"))
|
|
566
|
-
]
|
|
567
|
-
});
|
|
568
|
-
shadowObservers.set(sr, mo);
|
|
569
|
-
};
|
|
570
|
-
async function flush() {
|
|
571
|
-
clearTimeout(timer);
|
|
572
|
-
timer = 0;
|
|
573
|
-
if (!pending.size)
|
|
574
|
-
return;
|
|
575
|
-
const tags = Array.from(pending);
|
|
576
|
-
pending.clear();
|
|
577
|
-
tags.forEach((t) => inFlight.add(t));
|
|
578
|
-
try {
|
|
579
|
-
const effectiveMapper = (tag) => perTagModulePath.get(tag) ?? (mapper ? mapper(tag) : `${tag}.js`);
|
|
580
|
-
await defineWebComponents(...tags, {
|
|
581
|
-
baseURL,
|
|
582
|
-
mapper: effectiveMapper,
|
|
583
|
-
onError: (tag, err) => {
|
|
584
|
-
knownMissing.add(tag);
|
|
585
|
-
onError?.(tag, err);
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
} catch {
|
|
589
|
-
} finally {
|
|
590
|
-
tags.forEach((t) => inFlight.delete(t));
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
const mountNode = root === document ? document.documentElement : root;
|
|
594
|
-
const obs = new MutationObserver((mutations) => {
|
|
595
|
-
for (const m of mutations) {
|
|
596
|
-
m.addedNodes?.forEach((n) => {
|
|
597
|
-
crawlTree(n);
|
|
598
|
-
});
|
|
599
|
-
if (m.type === "attributes" && m.target) {
|
|
600
|
-
crawlTree(m.target);
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
});
|
|
604
|
-
obs.observe(mountNode, {
|
|
605
|
-
childList: true,
|
|
606
|
-
subtree: true,
|
|
607
|
-
attributes: true,
|
|
608
|
-
attributeFilter: [
|
|
609
|
-
attributeModule,
|
|
610
|
-
...enhancers.map((e) => e.selector).filter((s) => s.startsWith("data-"))
|
|
611
|
-
]
|
|
612
|
-
});
|
|
613
|
-
if (observeShadows && patchAttachShadow && Element.prototype.attachShadow) {
|
|
614
|
-
const orig = Element.prototype.attachShadow;
|
|
615
|
-
Element.prototype.attachShadow = function patchedAttachShadow(init) {
|
|
616
|
-
const sr = orig.call(this, init);
|
|
617
|
-
if (init && init.mode === "open") {
|
|
618
|
-
observeShadowRoot(sr);
|
|
619
|
-
const tag = this.tagName?.toLowerCase();
|
|
620
|
-
if (tag && tag.includes("-") && !customElements.get(tag)) {
|
|
621
|
-
queueTag(tag, this);
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
return sr;
|
|
625
|
-
};
|
|
626
|
-
restoreAttachShadow = () => Element.prototype.attachShadow = orig;
|
|
627
|
-
}
|
|
628
|
-
if (scanExisting) {
|
|
629
|
-
crawlTree(mountNode);
|
|
630
|
-
}
|
|
631
|
-
return {
|
|
632
|
-
stop() {
|
|
633
|
-
stopped = true;
|
|
634
|
-
obs.disconnect();
|
|
635
|
-
if (restoreAttachShadow)
|
|
636
|
-
restoreAttachShadow();
|
|
637
|
-
if (timer) {
|
|
638
|
-
clearTimeout(timer);
|
|
639
|
-
timer = 0;
|
|
640
|
-
}
|
|
641
|
-
shadowObservers.forEach((mo) => mo.disconnect());
|
|
642
|
-
},
|
|
643
|
-
flush
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
/**
|
|
647
|
-
* Dynamically load and (idempotently) define a set of web components by tag name.
|
|
648
|
-
*/
|
|
649
|
-
static async define(...args) {
|
|
650
|
-
let opts = {};
|
|
651
|
-
if (args.length && typeof args[args.length - 1] === "object") {
|
|
652
|
-
opts = args.pop() || {};
|
|
653
|
-
}
|
|
654
|
-
const tags = args;
|
|
655
|
-
const {
|
|
656
|
-
baseURL,
|
|
657
|
-
mapper = (tag) => `${tag}.js`,
|
|
658
|
-
onError = (tag, err) => console.error(`[defineWebComponents] ${tag}:`, err)
|
|
659
|
-
} = opts;
|
|
660
|
-
const base = baseURL ? new URL(
|
|
661
|
-
baseURL,
|
|
662
|
-
typeof location !== "undefined" ? location.href : import.meta.url
|
|
663
|
-
) : new URL("./", import.meta.url);
|
|
664
|
-
const toPascal = (tag) => tag.toLowerCase().replace(/(^|-)([a-z])/g, (_, __, c) => c.toUpperCase());
|
|
665
|
-
const loadOne = async (tag) => {
|
|
666
|
-
try {
|
|
667
|
-
if (customElements.get(tag))
|
|
668
|
-
return { tag, status: "already-defined" };
|
|
669
|
-
const spec = mapper(tag);
|
|
670
|
-
const href = spec instanceof URL ? spec.href : new URL(spec, base).href;
|
|
671
|
-
const mod = await import(href);
|
|
672
|
-
const Named = mod?.default ?? mod?.[toPascal(tag)];
|
|
673
|
-
if (!Named) {
|
|
674
|
-
if (customElements.get(tag))
|
|
675
|
-
return { tag, status: "self-defined" };
|
|
676
|
-
throw new Error(
|
|
677
|
-
`No export found for ${tag}. Expected default export or named export "${toPascal(
|
|
678
|
-
tag
|
|
679
|
-
)}".`
|
|
680
|
-
);
|
|
681
|
-
}
|
|
682
|
-
if (!customElements.get(tag)) {
|
|
683
|
-
customElements.define(tag, Named);
|
|
684
|
-
return { tag, status: "defined" };
|
|
685
|
-
}
|
|
686
|
-
return { tag, status: "race-already-defined" };
|
|
687
|
-
} catch (err) {
|
|
688
|
-
onError(tag, err);
|
|
689
|
-
throw err;
|
|
690
|
-
}
|
|
691
|
-
};
|
|
692
|
-
return Promise.all(tags.map(loadOne));
|
|
693
|
-
}
|
|
694
|
-
};
|
|
695
|
-
|
|
696
|
-
// src/js/pds-core/pds-start-helpers.js
|
|
697
|
-
var __ABSOLUTE_URL_PATTERN__ = /^[a-z][a-z0-9+\-.]*:\/\//i;
|
|
698
|
-
var __MODULE_URL__ = (() => {
|
|
699
|
-
try {
|
|
700
|
-
return import.meta.url;
|
|
701
|
-
} catch (e) {
|
|
702
|
-
return void 0;
|
|
703
|
-
}
|
|
704
|
-
})();
|
|
705
|
-
var ensureTrailingSlash2 = (value) => typeof value === "string" && value.length && !value.endsWith("/") ? `${value}/` : value;
|
|
706
|
-
function ensureAbsoluteAssetURL(value, options = {}) {
|
|
707
|
-
if (!value || __ABSOLUTE_URL_PATTERN__.test(value)) {
|
|
708
|
-
return value;
|
|
709
|
-
}
|
|
710
|
-
const { preferModule = true } = options;
|
|
711
|
-
const tryModule = () => {
|
|
712
|
-
if (!__MODULE_URL__)
|
|
713
|
-
return null;
|
|
714
|
-
try {
|
|
715
|
-
return new URL(value, __MODULE_URL__).href;
|
|
716
|
-
} catch (e) {
|
|
717
|
-
return null;
|
|
718
|
-
}
|
|
719
|
-
};
|
|
720
|
-
const tryWindow = () => {
|
|
721
|
-
if (typeof window === "undefined" || !window.location?.origin) {
|
|
722
|
-
return null;
|
|
723
|
-
}
|
|
724
|
-
try {
|
|
725
|
-
return new URL(value, window.location.origin).href;
|
|
726
|
-
} catch (e) {
|
|
727
|
-
return null;
|
|
728
|
-
}
|
|
729
|
-
};
|
|
730
|
-
const resolved = preferModule ? tryModule() || tryWindow() : tryWindow() || tryModule();
|
|
731
|
-
return resolved || value;
|
|
732
|
-
}
|
|
733
|
-
var __MODULE_DEFAULT_ASSET_ROOT__ = (() => {
|
|
734
|
-
if (!__MODULE_URL__)
|
|
735
|
-
return void 0;
|
|
736
|
-
try {
|
|
737
|
-
const parsed = new URL(__MODULE_URL__);
|
|
738
|
-
if (/\/public\/assets\/js\//.test(parsed.pathname)) {
|
|
739
|
-
return new URL("../pds/", __MODULE_URL__).href;
|
|
740
|
-
}
|
|
741
|
-
} catch (e) {
|
|
742
|
-
return void 0;
|
|
743
|
-
}
|
|
744
|
-
return void 0;
|
|
745
|
-
})();
|
|
746
|
-
var __foucListenerAttached = false;
|
|
747
|
-
function attachFoucListener(PDS2) {
|
|
748
|
-
if (__foucListenerAttached || typeof document === "undefined")
|
|
749
|
-
return;
|
|
750
|
-
__foucListenerAttached = true;
|
|
751
|
-
PDS2.addEventListener("pds:ready", (event) => {
|
|
752
|
-
const mode = event.detail?.mode;
|
|
753
|
-
if (mode) {
|
|
754
|
-
document.documentElement.classList.add(`pds-${mode}`, "pds-ready");
|
|
755
|
-
}
|
|
756
|
-
});
|
|
757
|
-
}
|
|
758
|
-
function resolveThemeAndApply({ manageTheme, themeStorageKey, applyResolvedTheme, setupSystemListenerIfNeeded }) {
|
|
759
|
-
let resolvedTheme = "light";
|
|
760
|
-
let storedTheme = null;
|
|
761
|
-
if (manageTheme && typeof window !== "undefined") {
|
|
762
|
-
try {
|
|
763
|
-
storedTheme = localStorage.getItem(themeStorageKey) || null;
|
|
764
|
-
} catch (e) {
|
|
765
|
-
storedTheme = null;
|
|
766
|
-
}
|
|
767
|
-
try {
|
|
768
|
-
applyResolvedTheme?.(storedTheme);
|
|
769
|
-
setupSystemListenerIfNeeded?.(storedTheme);
|
|
770
|
-
} catch (e) {
|
|
771
|
-
}
|
|
772
|
-
if (storedTheme) {
|
|
773
|
-
if (storedTheme === "system") {
|
|
774
|
-
const prefersDark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
775
|
-
resolvedTheme = prefersDark ? "dark" : "light";
|
|
776
|
-
} else {
|
|
777
|
-
resolvedTheme = storedTheme;
|
|
778
|
-
}
|
|
779
|
-
} else {
|
|
780
|
-
const prefersDark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
781
|
-
resolvedTheme = prefersDark ? "dark" : "light";
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
return { resolvedTheme, storedTheme };
|
|
785
|
-
}
|
|
786
|
-
function resolveRuntimeAssetRoot(config2, { resolvePublicAssetURL: resolvePublicAssetURL2 }) {
|
|
787
|
-
const hasCustomRoot = Boolean(config2?.public?.root || config2?.static?.root);
|
|
788
|
-
let candidate = resolvePublicAssetURL2(config2);
|
|
789
|
-
if (!hasCustomRoot && __MODULE_DEFAULT_ASSET_ROOT__) {
|
|
790
|
-
candidate = __MODULE_DEFAULT_ASSET_ROOT__;
|
|
791
|
-
}
|
|
792
|
-
return ensureTrailingSlash2(ensureAbsoluteAssetURL(candidate));
|
|
793
|
-
}
|
|
794
|
-
async function setupAutoDefinerAndEnhancers(options, { baseEnhancers = [] } = {}) {
|
|
795
|
-
const {
|
|
796
|
-
autoDefineBaseURL = "/auto-define/",
|
|
797
|
-
autoDefinePreload = [],
|
|
798
|
-
autoDefineMapper = null,
|
|
799
|
-
enhancers = [],
|
|
800
|
-
autoDefineOverrides = null,
|
|
801
|
-
autoDefinePreferModule = true
|
|
802
|
-
} = options;
|
|
803
|
-
const mergedEnhancers = (() => {
|
|
804
|
-
const map = /* @__PURE__ */ new Map();
|
|
805
|
-
(baseEnhancers || []).forEach((e) => map.set(e.selector, e));
|
|
806
|
-
(enhancers || []).forEach((e) => map.set(e.selector, e));
|
|
807
|
-
return Array.from(map.values());
|
|
808
|
-
})();
|
|
809
|
-
let autoDefiner = null;
|
|
810
|
-
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
811
|
-
const AutoDefinerCtor = AutoDefiner;
|
|
812
|
-
const defaultMapper = (tag) => {
|
|
813
|
-
switch (tag) {
|
|
814
|
-
case "pds-tabpanel":
|
|
815
|
-
return "pds-tabstrip.js";
|
|
816
|
-
default:
|
|
817
|
-
return `${tag}.js`;
|
|
818
|
-
}
|
|
819
|
-
};
|
|
820
|
-
const {
|
|
821
|
-
mapper: _overrideMapperIgnored,
|
|
822
|
-
enhancers: overrideEnhancers,
|
|
823
|
-
...restAutoDefineOverrides
|
|
824
|
-
} = autoDefineOverrides && typeof autoDefineOverrides === "object" ? autoDefineOverrides : {};
|
|
825
|
-
const normalizedOverrideEnhancers = (() => {
|
|
826
|
-
if (!overrideEnhancers)
|
|
827
|
-
return [];
|
|
828
|
-
if (Array.isArray(overrideEnhancers))
|
|
829
|
-
return overrideEnhancers;
|
|
830
|
-
if (typeof overrideEnhancers === "object") {
|
|
831
|
-
return Object.values(overrideEnhancers);
|
|
832
|
-
}
|
|
833
|
-
return [];
|
|
834
|
-
})();
|
|
835
|
-
const resolvedEnhancers = (() => {
|
|
836
|
-
const map = /* @__PURE__ */ new Map();
|
|
837
|
-
(mergedEnhancers || []).forEach((enhancer) => {
|
|
838
|
-
if (!enhancer?.selector)
|
|
839
|
-
return;
|
|
840
|
-
map.set(enhancer.selector, enhancer);
|
|
841
|
-
});
|
|
842
|
-
(normalizedOverrideEnhancers || []).forEach((enhancer) => {
|
|
843
|
-
if (!enhancer?.selector)
|
|
844
|
-
return;
|
|
845
|
-
const existing = map.get(enhancer.selector) || null;
|
|
846
|
-
map.set(enhancer.selector, {
|
|
847
|
-
...existing || {},
|
|
848
|
-
...enhancer,
|
|
849
|
-
run: typeof enhancer?.run === "function" ? enhancer.run : existing?.run
|
|
850
|
-
});
|
|
851
|
-
});
|
|
852
|
-
return Array.from(map.values());
|
|
853
|
-
})();
|
|
854
|
-
const normalizedBaseURL = autoDefineBaseURL ? ensureTrailingSlash2(
|
|
855
|
-
ensureAbsoluteAssetURL(autoDefineBaseURL, {
|
|
856
|
-
preferModule: autoDefinePreferModule
|
|
857
|
-
})
|
|
858
|
-
) : autoDefineBaseURL;
|
|
859
|
-
const autoDefineConfig = {
|
|
860
|
-
baseURL: normalizedBaseURL,
|
|
861
|
-
predefine: autoDefinePreload,
|
|
862
|
-
scanExisting: true,
|
|
863
|
-
observeShadows: true,
|
|
864
|
-
patchAttachShadow: true,
|
|
865
|
-
debounceMs: 16,
|
|
866
|
-
enhancers: resolvedEnhancers,
|
|
867
|
-
onError: (tag, err) => {
|
|
868
|
-
if (typeof tag === "string" && tag.startsWith("pds-")) {
|
|
869
|
-
const litDependentComponents = ["pds-form", "pds-drawer"];
|
|
870
|
-
const isLitComponent = litDependentComponents.includes(tag);
|
|
871
|
-
const isMissingLitError = err?.message?.includes("#pds/lit") || err?.message?.includes("Failed to resolve module specifier");
|
|
872
|
-
if (isLitComponent && isMissingLitError) {
|
|
873
|
-
console.error(
|
|
874
|
-
`\u274C PDS component <${tag}> requires Lit but #pds/lit is not in import map.
|
|
875
|
-
See: https://github.com/Pure-Web-Foundation/pure-ds/blob/main/readme.md#lit-components-not-working`
|
|
876
|
-
);
|
|
877
|
-
} else {
|
|
878
|
-
console.warn(
|
|
879
|
-
`\u26A0\uFE0F PDS component <${tag}> not found. Assets may not be installed.`
|
|
880
|
-
);
|
|
881
|
-
}
|
|
882
|
-
} else {
|
|
883
|
-
console.error(`\u274C Auto-define error for <${tag}>:`, err);
|
|
884
|
-
}
|
|
885
|
-
},
|
|
886
|
-
// Apply all user overrides except mapper so we can still wrap it
|
|
887
|
-
...restAutoDefineOverrides,
|
|
888
|
-
mapper: (tag) => {
|
|
889
|
-
if (customElements.get(tag))
|
|
890
|
-
return null;
|
|
891
|
-
if (typeof autoDefineMapper === "function") {
|
|
892
|
-
try {
|
|
893
|
-
const mapped = autoDefineMapper(tag);
|
|
894
|
-
if (mapped === void 0) {
|
|
895
|
-
return defaultMapper(tag);
|
|
896
|
-
}
|
|
897
|
-
return mapped;
|
|
898
|
-
} catch (e) {
|
|
899
|
-
console.warn(
|
|
900
|
-
"Custom autoDefine.mapper error; falling back to default:",
|
|
901
|
-
e?.message || e
|
|
902
|
-
);
|
|
903
|
-
return defaultMapper(tag);
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
return defaultMapper(tag);
|
|
907
|
-
}
|
|
908
|
-
};
|
|
909
|
-
autoDefiner = new AutoDefinerCtor(autoDefineConfig);
|
|
910
|
-
if (autoDefinePreload.length > 0 && typeof AutoDefinerCtor.define === "function") {
|
|
911
|
-
await AutoDefinerCtor.define(...autoDefinePreload, {
|
|
912
|
-
baseURL: autoDefineBaseURL,
|
|
913
|
-
mapper: autoDefineConfig.mapper,
|
|
914
|
-
onError: autoDefineConfig.onError
|
|
915
|
-
});
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
return { autoDefiner, mergedEnhancers };
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
// src/js/pds-core/pds-theme-utils.js
|
|
922
|
-
var DEFAULT_THEMES = ["light", "dark"];
|
|
923
|
-
var VALID_THEMES = new Set(DEFAULT_THEMES);
|
|
924
|
-
function normalizePresetThemes(preset) {
|
|
925
|
-
const themes = Array.isArray(preset?.themes) ? preset.themes.map((theme) => String(theme).toLowerCase()) : DEFAULT_THEMES;
|
|
926
|
-
const normalized = themes.filter((theme) => VALID_THEMES.has(theme));
|
|
927
|
-
return normalized.length ? normalized : DEFAULT_THEMES;
|
|
928
|
-
}
|
|
929
|
-
function resolveThemePreference(preference, { preferDocument = true } = {}) {
|
|
930
|
-
const normalized = String(preference || "").toLowerCase();
|
|
931
|
-
if (VALID_THEMES.has(normalized))
|
|
932
|
-
return normalized;
|
|
933
|
-
if (preferDocument && typeof document !== "undefined") {
|
|
934
|
-
const applied = document.documentElement?.getAttribute("data-theme");
|
|
935
|
-
if (VALID_THEMES.has(applied))
|
|
936
|
-
return applied;
|
|
937
|
-
}
|
|
938
|
-
if (typeof window !== "undefined" && window.matchMedia) {
|
|
939
|
-
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
940
|
-
return prefersDark ? "dark" : "light";
|
|
941
|
-
}
|
|
942
|
-
return "light";
|
|
943
|
-
}
|
|
944
|
-
function isPresetThemeCompatible(preset, themePreference) {
|
|
945
|
-
const resolvedTheme = resolveThemePreference(themePreference);
|
|
946
|
-
const themes = normalizePresetThemes(preset);
|
|
947
|
-
return themes.includes(resolvedTheme);
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
// src/js/pds.js
|
|
951
|
-
var PDSBase = class extends EventTarget {
|
|
952
|
-
};
|
|
953
|
-
var PDS = new PDSBase();
|
|
954
|
-
PDS.initializing = false;
|
|
955
|
-
PDS.currentPreset = null;
|
|
956
|
-
PDS.debug = false;
|
|
957
|
-
var __autoCompletePromise = null;
|
|
958
|
-
var __askPromise = null;
|
|
959
|
-
var __toastPromise = null;
|
|
960
|
-
var __defaultEnhancersPromise = null;
|
|
961
|
-
function __resolveExternalRuntimeModuleURL(filename, overrideURL) {
|
|
962
|
-
if (overrideURL && typeof overrideURL === "string") {
|
|
963
|
-
return overrideURL;
|
|
964
|
-
}
|
|
965
|
-
const assetRootURL = resolveRuntimeAssetRoot(PDS.currentConfig || {}, {
|
|
966
|
-
resolvePublicAssetURL
|
|
967
|
-
});
|
|
968
|
-
return `${assetRootURL}core/${filename}`;
|
|
969
|
-
}
|
|
970
|
-
async function __loadDefaultEnhancers() {
|
|
971
|
-
if (Array.isArray(PDS.defaultEnhancers) && PDS.defaultEnhancers.length > 0) {
|
|
972
|
-
return PDS.defaultEnhancers;
|
|
973
|
-
}
|
|
974
|
-
if (!__defaultEnhancersPromise) {
|
|
975
|
-
const enhancersModuleURL = __resolveExternalRuntimeModuleURL(
|
|
976
|
-
"pds-enhancers.js",
|
|
977
|
-
PDS.currentConfig?.enhancersURL
|
|
978
|
-
);
|
|
979
|
-
__defaultEnhancersPromise = import(enhancersModuleURL).then((mod) => {
|
|
980
|
-
const enhancers = Array.isArray(mod?.defaultPDSEnhancers) ? mod.defaultPDSEnhancers : [];
|
|
981
|
-
PDS.defaultEnhancers = enhancers;
|
|
982
|
-
return enhancers;
|
|
983
|
-
}).catch((error) => {
|
|
984
|
-
__defaultEnhancersPromise = null;
|
|
985
|
-
throw error;
|
|
986
|
-
});
|
|
987
|
-
}
|
|
988
|
-
return __defaultEnhancersPromise;
|
|
989
|
-
}
|
|
990
|
-
async function __loadAsk() {
|
|
991
|
-
if (typeof PDS.ask === "function" && PDS.ask !== __lazyAsk) {
|
|
992
|
-
return PDS.ask;
|
|
993
|
-
}
|
|
994
|
-
if (!__askPromise) {
|
|
995
|
-
const askModuleURL = __resolveExternalRuntimeModuleURL(
|
|
996
|
-
"pds-ask.js",
|
|
997
|
-
PDS.currentConfig?.askURL
|
|
998
|
-
);
|
|
999
|
-
__askPromise = import(askModuleURL).then((mod) => {
|
|
1000
|
-
const impl = mod?.ask;
|
|
1001
|
-
if (typeof impl !== "function") {
|
|
1002
|
-
throw new Error("Failed to load ask helper");
|
|
1003
|
-
}
|
|
1004
|
-
PDS.ask = impl;
|
|
1005
|
-
return impl;
|
|
1006
|
-
}).catch((error) => {
|
|
1007
|
-
__askPromise = null;
|
|
1008
|
-
throw error;
|
|
1009
|
-
});
|
|
1010
|
-
}
|
|
1011
|
-
return __askPromise;
|
|
1012
|
-
}
|
|
1013
|
-
async function __loadToast() {
|
|
1014
|
-
if (typeof PDS.toast === "function" && PDS.toast !== __lazyToast) {
|
|
1015
|
-
return PDS.toast;
|
|
1016
|
-
}
|
|
1017
|
-
if (!__toastPromise) {
|
|
1018
|
-
const toastModuleURL = __resolveExternalRuntimeModuleURL(
|
|
1019
|
-
"pds-toast.js",
|
|
1020
|
-
PDS.currentConfig?.toastURL
|
|
1021
|
-
);
|
|
1022
|
-
__toastPromise = import(toastModuleURL).then((mod) => {
|
|
1023
|
-
const impl = mod?.toast;
|
|
1024
|
-
if (typeof impl !== "function") {
|
|
1025
|
-
throw new Error("Failed to load toast helper");
|
|
1026
|
-
}
|
|
1027
|
-
PDS.toast = impl;
|
|
1028
|
-
return impl;
|
|
1029
|
-
}).catch((error) => {
|
|
1030
|
-
__toastPromise = null;
|
|
1031
|
-
throw error;
|
|
1032
|
-
});
|
|
1033
|
-
}
|
|
1034
|
-
return __toastPromise;
|
|
1035
|
-
}
|
|
1036
|
-
async function __lazyAsk(...args) {
|
|
1037
|
-
const askImpl = await __loadAsk();
|
|
1038
|
-
return askImpl(...args);
|
|
1039
|
-
}
|
|
1040
|
-
async function __lazyToast(...args) {
|
|
1041
|
-
const toastImpl = await __loadToast();
|
|
1042
|
-
return toastImpl(...args);
|
|
1043
|
-
}
|
|
1044
|
-
__lazyToast.success = async (...args) => {
|
|
1045
|
-
const toastImpl = await __loadToast();
|
|
1046
|
-
return toastImpl.success(...args);
|
|
1047
|
-
};
|
|
1048
|
-
__lazyToast.error = async (...args) => {
|
|
1049
|
-
const toastImpl = await __loadToast();
|
|
1050
|
-
return toastImpl.error(...args);
|
|
1051
|
-
};
|
|
1052
|
-
__lazyToast.warning = async (...args) => {
|
|
1053
|
-
const toastImpl = await __loadToast();
|
|
1054
|
-
return toastImpl.warning(...args);
|
|
1055
|
-
};
|
|
1056
|
-
__lazyToast.info = async (...args) => {
|
|
1057
|
-
const toastImpl = await __loadToast();
|
|
1058
|
-
return toastImpl.info(...args);
|
|
1059
|
-
};
|
|
1060
|
-
var __defaultLog = function(level = "log", message, ...data) {
|
|
1061
|
-
const isStaticMode = Boolean(PDS.registry && !PDS.registry.isLive);
|
|
1062
|
-
const debug = (this?.debug || this?.design?.debug || PDS.debug || false) === true;
|
|
1063
|
-
if (isStaticMode) {
|
|
1064
|
-
if (!PDS.debug)
|
|
1065
|
-
return;
|
|
1066
|
-
} else if (!debug && level !== "error" && level !== "warn") {
|
|
1067
|
-
return;
|
|
1068
|
-
}
|
|
1069
|
-
const method = console[level] || console.log;
|
|
1070
|
-
if (data.length > 0) {
|
|
1071
|
-
method(message, ...data);
|
|
1072
|
-
} else {
|
|
1073
|
-
method(message);
|
|
1074
|
-
}
|
|
1075
|
-
};
|
|
1076
|
-
function __stripFunctionsForClone(value) {
|
|
1077
|
-
if (value === null || value === void 0)
|
|
1078
|
-
return value;
|
|
1079
|
-
if (typeof value === "function")
|
|
1080
|
-
return void 0;
|
|
1081
|
-
if (typeof value !== "object")
|
|
1082
|
-
return value;
|
|
1083
|
-
if (Array.isArray(value)) {
|
|
1084
|
-
return value.map((item) => __stripFunctionsForClone(item)).filter((item) => item !== void 0);
|
|
1085
|
-
}
|
|
1086
|
-
const result = {};
|
|
1087
|
-
for (const [key, entry] of Object.entries(value)) {
|
|
1088
|
-
const stripped = __stripFunctionsForClone(entry);
|
|
1089
|
-
if (stripped !== void 0) {
|
|
1090
|
-
result[key] = stripped;
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
return result;
|
|
1094
|
-
}
|
|
1095
|
-
async function __loadRuntimeConfig(assetRootURL, config2 = {}) {
|
|
1096
|
-
if (config2?.runtimeConfig === false)
|
|
1097
|
-
return null;
|
|
1098
|
-
if (typeof fetch !== "function")
|
|
1099
|
-
return null;
|
|
1100
|
-
const runtimeUrl = config2?.runtimeConfigURL || `${assetRootURL}pds-runtime-config.json`;
|
|
1101
|
-
try {
|
|
1102
|
-
const res = await fetch(runtimeUrl, { cache: "no-store" });
|
|
1103
|
-
if (!res.ok)
|
|
1104
|
-
return null;
|
|
1105
|
-
return await res.json();
|
|
1106
|
-
} catch (e) {
|
|
1107
|
-
return null;
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
PDS.registry = registry;
|
|
1111
|
-
PDS.enums = enums;
|
|
1112
|
-
PDS.adoptLayers = adoptLayers;
|
|
1113
|
-
PDS.adoptPrimitives = adoptPrimitives;
|
|
1114
|
-
PDS.parse = parseHTML;
|
|
1115
|
-
PDS.createStylesheet = createStylesheet;
|
|
1116
|
-
PDS.isLiveMode = () => registry.isLive;
|
|
1117
|
-
PDS.ask = __lazyAsk;
|
|
1118
|
-
PDS.toast = __lazyToast;
|
|
1119
|
-
PDS.common = common_exports;
|
|
1120
|
-
PDS.AutoComplete = null;
|
|
1121
|
-
PDS.loadAutoComplete = async () => {
|
|
1122
|
-
if (PDS.AutoComplete && typeof PDS.AutoComplete.connect === "function") {
|
|
1123
|
-
return PDS.AutoComplete;
|
|
1124
|
-
}
|
|
1125
|
-
const autoCompleteModuleURL = __resolveExternalRuntimeModuleURL(
|
|
1126
|
-
"pds-autocomplete.js",
|
|
1127
|
-
PDS.currentConfig?.autoCompleteURL
|
|
1128
|
-
);
|
|
1129
|
-
if (!__autoCompletePromise) {
|
|
1130
|
-
__autoCompletePromise = import(autoCompleteModuleURL).then((mod) => {
|
|
1131
|
-
const autoCompleteCtor = mod?.AutoComplete || mod?.default?.AutoComplete || mod?.default || null;
|
|
1132
|
-
if (!autoCompleteCtor) {
|
|
1133
|
-
throw new Error("AutoComplete export not found in module");
|
|
1134
|
-
}
|
|
1135
|
-
PDS.AutoComplete = autoCompleteCtor;
|
|
1136
|
-
return autoCompleteCtor;
|
|
1137
|
-
}).catch((error) => {
|
|
1138
|
-
__autoCompletePromise = null;
|
|
1139
|
-
throw error;
|
|
1140
|
-
});
|
|
1141
|
-
}
|
|
1142
|
-
return __autoCompletePromise;
|
|
1143
|
-
};
|
|
1144
|
-
function __emitPDSReady(detail) {
|
|
1145
|
-
const hasCustomEvent = typeof CustomEvent === "function";
|
|
1146
|
-
try {
|
|
1147
|
-
const readyEvent = hasCustomEvent ? new CustomEvent("pds:ready", { detail }) : new Event("pds:ready");
|
|
1148
|
-
PDS.dispatchEvent(readyEvent);
|
|
1149
|
-
} catch (e) {
|
|
1150
|
-
}
|
|
1151
|
-
if (typeof document !== "undefined") {
|
|
1152
|
-
if (hasCustomEvent) {
|
|
1153
|
-
const eventOptions = { detail, bubbles: true, composed: true };
|
|
1154
|
-
try {
|
|
1155
|
-
document.dispatchEvent(new CustomEvent("pds:ready", eventOptions));
|
|
1156
|
-
} catch (e) {
|
|
1157
|
-
}
|
|
1158
|
-
try {
|
|
1159
|
-
document.dispatchEvent(new CustomEvent("pds-ready", eventOptions));
|
|
1160
|
-
} catch (e) {
|
|
1161
|
-
}
|
|
1162
|
-
} else {
|
|
1163
|
-
try {
|
|
1164
|
-
document.dispatchEvent(new Event("pds:ready"));
|
|
1165
|
-
} catch (e) {
|
|
1166
|
-
}
|
|
1167
|
-
try {
|
|
1168
|
-
document.dispatchEvent(new Event("pds-ready"));
|
|
1169
|
-
} catch (e) {
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
function __emitPDSConfigChanged(detail = {}) {
|
|
1175
|
-
const hasCustomEvent = typeof CustomEvent === "function";
|
|
1176
|
-
const payload = {
|
|
1177
|
-
at: Date.now(),
|
|
1178
|
-
...detail
|
|
1179
|
-
};
|
|
1180
|
-
try {
|
|
1181
|
-
const changedEvent = hasCustomEvent ? new CustomEvent("pds:config-changed", { detail: payload }) : new Event("pds:config-changed");
|
|
1182
|
-
PDS.dispatchEvent(changedEvent);
|
|
1183
|
-
} catch (e) {
|
|
1184
|
-
}
|
|
1185
|
-
if (typeof document !== "undefined") {
|
|
1186
|
-
if (hasCustomEvent) {
|
|
1187
|
-
const eventOptions = { detail: payload, bubbles: true, composed: true };
|
|
1188
|
-
try {
|
|
1189
|
-
document.dispatchEvent(
|
|
1190
|
-
new CustomEvent("pds:config-changed", eventOptions)
|
|
1191
|
-
);
|
|
1192
|
-
} catch (e) {
|
|
1193
|
-
}
|
|
1194
|
-
} else {
|
|
1195
|
-
try {
|
|
1196
|
-
document.dispatchEvent(new Event("pds:config-changed"));
|
|
1197
|
-
} catch (e) {
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
var __themeStorageKey = "pure-ds-theme";
|
|
1203
|
-
var __themeMQ = null;
|
|
1204
|
-
var __themeMQListener = null;
|
|
1205
|
-
function __applyResolvedTheme(raw) {
|
|
1206
|
-
try {
|
|
1207
|
-
if (typeof document === "undefined")
|
|
1208
|
-
return;
|
|
1209
|
-
let resolved = "light";
|
|
1210
|
-
if (!raw) {
|
|
1211
|
-
const prefersDark = typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
1212
|
-
resolved = prefersDark ? "dark" : "light";
|
|
1213
|
-
} else if (raw === "system") {
|
|
1214
|
-
const prefersDark = typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
1215
|
-
resolved = prefersDark ? "dark" : "light";
|
|
1216
|
-
} else {
|
|
1217
|
-
resolved = raw;
|
|
1218
|
-
}
|
|
1219
|
-
document.documentElement.setAttribute("data-theme", resolved);
|
|
1220
|
-
} catch (e) {
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
function __setupSystemListenerIfNeeded(raw) {
|
|
1224
|
-
try {
|
|
1225
|
-
if (__themeMQ && __themeMQListener) {
|
|
1226
|
-
try {
|
|
1227
|
-
if (typeof __themeMQ.removeEventListener === "function")
|
|
1228
|
-
__themeMQ.removeEventListener("change", __themeMQListener);
|
|
1229
|
-
else if (typeof __themeMQ.removeListener === "function")
|
|
1230
|
-
__themeMQ.removeListener(__themeMQListener);
|
|
1231
|
-
} catch (e) {
|
|
1232
|
-
}
|
|
1233
|
-
__themeMQ = null;
|
|
1234
|
-
__themeMQListener = null;
|
|
1235
|
-
}
|
|
1236
|
-
if (raw === "system" && typeof window !== "undefined" && window.matchMedia) {
|
|
1237
|
-
const mq = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1238
|
-
const listener = (e) => {
|
|
1239
|
-
const isDark = e?.matches === void 0 ? mq.matches : e.matches;
|
|
1240
|
-
try {
|
|
1241
|
-
const newTheme = isDark ? "dark" : "light";
|
|
1242
|
-
document.documentElement.setAttribute("data-theme", newTheme);
|
|
1243
|
-
PDS.dispatchEvent(
|
|
1244
|
-
new CustomEvent("pds:theme:changed", {
|
|
1245
|
-
detail: { theme: newTheme, source: "system" }
|
|
1246
|
-
})
|
|
1247
|
-
);
|
|
1248
|
-
} catch (ex) {
|
|
1249
|
-
}
|
|
1250
|
-
};
|
|
1251
|
-
__themeMQ = mq;
|
|
1252
|
-
__themeMQListener = listener;
|
|
1253
|
-
if (typeof mq.addEventListener === "function")
|
|
1254
|
-
mq.addEventListener("change", listener);
|
|
1255
|
-
else if (typeof mq.addListener === "function")
|
|
1256
|
-
mq.addListener(listener);
|
|
1257
|
-
}
|
|
1258
|
-
} catch (e) {
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
Object.defineProperty(PDS, "theme", {
|
|
1262
|
-
get() {
|
|
1263
|
-
try {
|
|
1264
|
-
if (typeof window === "undefined")
|
|
1265
|
-
return null;
|
|
1266
|
-
return localStorage.getItem(__themeStorageKey) || null;
|
|
1267
|
-
} catch (e) {
|
|
1268
|
-
return null;
|
|
1269
|
-
}
|
|
1270
|
-
},
|
|
1271
|
-
set(value) {
|
|
1272
|
-
try {
|
|
1273
|
-
if (typeof window === "undefined")
|
|
1274
|
-
return;
|
|
1275
|
-
const currentPreset = PDS.currentConfig?.design || null;
|
|
1276
|
-
const resolvedTheme = resolveThemePreference(value);
|
|
1277
|
-
if (currentPreset && !isPresetThemeCompatible(currentPreset, resolvedTheme)) {
|
|
1278
|
-
const presetName = currentPreset?.name || PDS.currentPreset?.name || PDS.currentConfig?.preset || "current preset";
|
|
1279
|
-
console.warn(
|
|
1280
|
-
`PDS theme "${resolvedTheme}" not supported by preset "${presetName}".`
|
|
1281
|
-
);
|
|
1282
|
-
PDS.dispatchEvent(
|
|
1283
|
-
new CustomEvent("pds:theme:blocked", {
|
|
1284
|
-
detail: { theme: value, resolvedTheme, preset: presetName }
|
|
1285
|
-
})
|
|
1286
|
-
);
|
|
1287
|
-
return;
|
|
1288
|
-
}
|
|
1289
|
-
if (value === null || value === void 0) {
|
|
1290
|
-
localStorage.removeItem(__themeStorageKey);
|
|
1291
|
-
} else {
|
|
1292
|
-
localStorage.setItem(__themeStorageKey, value);
|
|
1293
|
-
}
|
|
1294
|
-
__applyResolvedTheme(value);
|
|
1295
|
-
__setupSystemListenerIfNeeded(value);
|
|
1296
|
-
PDS.dispatchEvent(
|
|
1297
|
-
new CustomEvent("pds:theme:changed", {
|
|
1298
|
-
detail: { theme: value, source: "api" }
|
|
1299
|
-
})
|
|
1300
|
-
);
|
|
1301
|
-
} catch (e) {
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
});
|
|
1305
|
-
PDS.defaultEnhancers = [];
|
|
1306
|
-
async function start(config2) {
|
|
1307
|
-
const mode = config2 && config2.mode || "live";
|
|
1308
|
-
const { mode: _omit, ...rest } = config2 || {};
|
|
1309
|
-
if (mode === "static")
|
|
1310
|
-
return staticInit(rest);
|
|
1311
|
-
const assetRootURL = resolveRuntimeAssetRoot(rest, { resolvePublicAssetURL });
|
|
1312
|
-
const managerUrl = rest?.managerURL || rest?.public?.managerURL || rest?.manager?.url || new URL("core/pds-manager.js", assetRootURL).href || new URL("./pds-manager.js", import.meta.url).href;
|
|
1313
|
-
const { startLive } = await import(managerUrl);
|
|
1314
|
-
return startLive(PDS, rest, {
|
|
1315
|
-
emitReady: __emitPDSReady,
|
|
1316
|
-
emitConfigChanged: __emitPDSConfigChanged,
|
|
1317
|
-
applyResolvedTheme: __applyResolvedTheme,
|
|
1318
|
-
setupSystemListenerIfNeeded: __setupSystemListenerIfNeeded
|
|
1319
|
-
});
|
|
1320
|
-
}
|
|
1321
|
-
PDS.start = start;
|
|
1322
|
-
async function staticInit(config2) {
|
|
1323
|
-
if (!config2 || typeof config2 !== "object") {
|
|
1324
|
-
throw new Error(
|
|
1325
|
-
"PDS.start({ mode: 'static', ... }) requires a valid configuration object"
|
|
1326
|
-
);
|
|
1327
|
-
}
|
|
1328
|
-
const applyGlobalStyles = config2.applyGlobalStyles ?? true;
|
|
1329
|
-
const manageTheme = config2.manageTheme ?? true;
|
|
1330
|
-
const themeStorageKey = config2.themeStorageKey ?? "pure-ds-theme";
|
|
1331
|
-
let staticPaths = config2.staticPaths ?? {};
|
|
1332
|
-
const assetRootURL = resolveRuntimeAssetRoot(config2, { resolvePublicAssetURL });
|
|
1333
|
-
const cfgAuto = config2 && config2.autoDefine || null;
|
|
1334
|
-
let autoDefineBaseURL;
|
|
1335
|
-
if (cfgAuto && cfgAuto.baseURL) {
|
|
1336
|
-
autoDefineBaseURL = ensureTrailingSlash2(
|
|
1337
|
-
ensureAbsoluteAssetURL(cfgAuto.baseURL, { preferModule: false })
|
|
1338
|
-
);
|
|
1339
|
-
} else {
|
|
1340
|
-
autoDefineBaseURL = `${assetRootURL}components/`;
|
|
1341
|
-
}
|
|
1342
|
-
const autoDefinePreload = cfgAuto && Array.isArray(cfgAuto.predefine) && cfgAuto.predefine || [];
|
|
1343
|
-
const autoDefineMapper = cfgAuto && typeof cfgAuto.mapper === "function" && cfgAuto.mapper || null;
|
|
1344
|
-
try {
|
|
1345
|
-
attachFoucListener(PDS);
|
|
1346
|
-
const { resolvedTheme } = resolveThemeAndApply({
|
|
1347
|
-
manageTheme,
|
|
1348
|
-
themeStorageKey,
|
|
1349
|
-
applyResolvedTheme: __applyResolvedTheme,
|
|
1350
|
-
setupSystemListenerIfNeeded: __setupSystemListenerIfNeeded
|
|
1351
|
-
});
|
|
1352
|
-
const runtimeConfig = await __loadRuntimeConfig(assetRootURL, config2);
|
|
1353
|
-
const userEnhancers = Array.isArray(config2?.enhancers) ? config2.enhancers : config2?.enhancers && typeof config2.enhancers === "object" ? Object.values(config2.enhancers) : [];
|
|
1354
|
-
const resolvedConfig = runtimeConfig?.config ? {
|
|
1355
|
-
...runtimeConfig.config,
|
|
1356
|
-
...config2,
|
|
1357
|
-
design: config2?.design || runtimeConfig.config.design,
|
|
1358
|
-
preset: config2?.preset || runtimeConfig.config.preset
|
|
1359
|
-
} : { ...config2 };
|
|
1360
|
-
const baseStaticPaths = {
|
|
1361
|
-
tokens: `${assetRootURL}styles/pds-tokens.css.js`,
|
|
1362
|
-
primitives: `${assetRootURL}styles/pds-primitives.css.js`,
|
|
1363
|
-
components: `${assetRootURL}styles/pds-components.css.js`,
|
|
1364
|
-
utilities: `${assetRootURL}styles/pds-utilities.css.js`,
|
|
1365
|
-
styles: `${assetRootURL}styles/pds-styles.css.js`
|
|
1366
|
-
};
|
|
1367
|
-
const runtimePaths = runtimeConfig?.paths || {};
|
|
1368
|
-
staticPaths = { ...baseStaticPaths, ...runtimePaths, ...staticPaths };
|
|
1369
|
-
PDS.registry.setStaticMode(staticPaths);
|
|
1370
|
-
if (applyGlobalStyles && typeof document !== "undefined") {
|
|
1371
|
-
try {
|
|
1372
|
-
const stylesSheet = await PDS.registry.getStylesheet("styles");
|
|
1373
|
-
if (stylesSheet) {
|
|
1374
|
-
stylesSheet._pds = true;
|
|
1375
|
-
const others = (document.adoptedStyleSheets || []).filter(
|
|
1376
|
-
(s) => s._pds !== true
|
|
1377
|
-
);
|
|
1378
|
-
document.adoptedStyleSheets = [...others, stylesSheet];
|
|
1379
|
-
__emitPDSConfigChanged({
|
|
1380
|
-
mode: "static",
|
|
1381
|
-
source: "static:styles-applied"
|
|
1382
|
-
});
|
|
1383
|
-
}
|
|
1384
|
-
} catch (e) {
|
|
1385
|
-
__defaultLog.call(PDS, "warn", "Failed to apply static styles:", e);
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
let autoDefiner = null;
|
|
1389
|
-
let mergedEnhancers = [];
|
|
1390
|
-
try {
|
|
1391
|
-
const defaultPDSEnhancers = await __loadDefaultEnhancers();
|
|
1392
|
-
const res = await setupAutoDefinerAndEnhancers({
|
|
1393
|
-
autoDefineBaseURL,
|
|
1394
|
-
autoDefinePreload,
|
|
1395
|
-
autoDefineMapper,
|
|
1396
|
-
enhancers: userEnhancers,
|
|
1397
|
-
autoDefineOverrides: cfgAuto || null,
|
|
1398
|
-
autoDefinePreferModule: !(cfgAuto && cfgAuto.baseURL)
|
|
1399
|
-
}, { baseEnhancers: defaultPDSEnhancers });
|
|
1400
|
-
autoDefiner = res.autoDefiner;
|
|
1401
|
-
mergedEnhancers = res.mergedEnhancers || [];
|
|
1402
|
-
} catch (error) {
|
|
1403
|
-
__defaultLog.call(
|
|
1404
|
-
PDS,
|
|
1405
|
-
"error",
|
|
1406
|
-
"\u274C Failed to initialize AutoDefiner/Enhancers (static):",
|
|
1407
|
-
error
|
|
1408
|
-
);
|
|
1409
|
-
}
|
|
1410
|
-
const cloneableConfig = __stripFunctionsForClone(config2);
|
|
1411
|
-
PDS.currentConfig = Object.freeze({
|
|
1412
|
-
mode: "static",
|
|
1413
|
-
...structuredClone(cloneableConfig),
|
|
1414
|
-
design: structuredClone(resolvedConfig.design || {}),
|
|
1415
|
-
preset: resolvedConfig.preset,
|
|
1416
|
-
theme: resolvedTheme,
|
|
1417
|
-
enhancers: mergedEnhancers
|
|
1418
|
-
});
|
|
1419
|
-
__emitPDSReady({
|
|
1420
|
-
mode: "static",
|
|
1421
|
-
config: resolvedConfig,
|
|
1422
|
-
theme: resolvedTheme,
|
|
1423
|
-
autoDefiner
|
|
1424
|
-
});
|
|
1425
|
-
return {
|
|
1426
|
-
config: resolvedConfig,
|
|
1427
|
-
theme: resolvedTheme,
|
|
1428
|
-
autoDefiner
|
|
1429
|
-
};
|
|
1430
|
-
} catch (error) {
|
|
1431
|
-
PDS.dispatchEvent(new CustomEvent("pds:error", { detail: { error } }));
|
|
1432
|
-
throw error;
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
|
|
1436
|
-
// pds.config.js
|
|
1437
|
-
var config = {
|
|
1438
|
-
mode: "live",
|
|
1439
|
-
liveEdit: true,
|
|
1440
|
-
preset: "default",
|
|
1441
|
-
autoDefine: {
|
|
1442
|
-
predefine: ["pds-icon", "pds-drawer", "pds-toaster", "pds-form"]
|
|
1443
|
-
},
|
|
1444
|
-
log(level, message, ...data) {
|
|
1445
|
-
console[level](message, ...data);
|
|
1446
|
-
}
|
|
1447
|
-
};
|
|
1448
|
-
|
|
1449
|
-
// package.json
|
|
1450
|
-
var package_default = {
|
|
1451
|
-
name: "@pure-ds/core",
|
|
1452
|
-
shortname: "pds",
|
|
1453
|
-
version: "0.7.4",
|
|
1454
|
-
description: "Why develop a Design System when you can generate one?",
|
|
1455
|
-
repository: {
|
|
1456
|
-
type: "git",
|
|
1457
|
-
url: "git+https://github.com/Pure-Web-Foundation/pure-ds.git"
|
|
1458
|
-
},
|
|
1459
|
-
bugs: {
|
|
1460
|
-
url: "https://github.com/Pure-Web-Foundation/pure-ds/issues"
|
|
1461
|
-
},
|
|
1462
|
-
homepage: "https://puredesignsystem.z6.web.core.windows.net/",
|
|
1463
|
-
keywords: [
|
|
1464
|
-
"design-system",
|
|
1465
|
-
"css",
|
|
1466
|
-
"web-components",
|
|
1467
|
-
"lit",
|
|
1468
|
-
"constructable-stylesheets",
|
|
1469
|
-
"tokens",
|
|
1470
|
-
"utilities",
|
|
1471
|
-
"a11y"
|
|
1472
|
-
],
|
|
1473
|
-
type: "module",
|
|
1474
|
-
main: "./public/assets/pds/core.js",
|
|
1475
|
-
module: "./public/assets/pds/core.js",
|
|
1476
|
-
types: "./dist/types/pds.d.ts",
|
|
1477
|
-
bin: {
|
|
1478
|
-
"pds-build": "packages/pds-cli/bin/pds-static.js",
|
|
1479
|
-
"pds-sync-assets": "packages/pds-cli/bin/sync-assets.js",
|
|
1480
|
-
"pds-build-icons": "packages/pds-cli/bin/pds-build-icons.js",
|
|
1481
|
-
"pds-import": "packages/pds-cli/bin/pds-import.js",
|
|
1482
|
-
"pds-setup-copilot": "packages/pds-cli/bin/pds-setup-copilot.js",
|
|
1483
|
-
"pds-setup-mcp": "packages/pds-cli/bin/pds-setup-mcp.js",
|
|
1484
|
-
"pds-init-config": "packages/pds-cli/bin/pds-init-config.js",
|
|
1485
|
-
"pds-bootstrap": "packages/pds-cli/bin/pds-bootstrap.js",
|
|
1486
|
-
"pds-mcp-server": "packages/pds-cli/bin/pds-mcp-server.js",
|
|
1487
|
-
"pds-mcp-health": "packages/pds-cli/bin/pds-mcp-health.js",
|
|
1488
|
-
"pds-mcp-eval": "packages/pds-cli/bin/pds-mcp-eval.js"
|
|
1489
|
-
},
|
|
1490
|
-
exports: {
|
|
1491
|
-
".": {
|
|
1492
|
-
types: "./src/js/pds.d.ts",
|
|
1493
|
-
import: "./public/assets/pds/core.js"
|
|
1494
|
-
},
|
|
1495
|
-
"./pds-core": "./src/js/pds.js",
|
|
1496
|
-
"./auto-define/*": "./public/auto-define/*"
|
|
1497
|
-
},
|
|
1498
|
-
files: [
|
|
1499
|
-
".github/copilot-instructions.md",
|
|
1500
|
-
".cursorrules",
|
|
1501
|
-
"dist/types/",
|
|
1502
|
-
"public/assets/js/",
|
|
1503
|
-
"public/assets/pds/components/",
|
|
1504
|
-
"public/assets/pds/templates/",
|
|
1505
|
-
"public/assets/pds/core.js",
|
|
1506
|
-
"public/assets/pds/core/",
|
|
1507
|
-
"public/assets/pds/external/",
|
|
1508
|
-
"public/assets/pds/vscode-custom-data.json",
|
|
1509
|
-
"public/assets/pds/pds.css-data.json",
|
|
1510
|
-
"public/assets/pds/pds-css-complete.json",
|
|
1511
|
-
"public/auto-define/",
|
|
1512
|
-
"public/pds/components/",
|
|
1513
|
-
"public/assets/pds/icons/pds-icons.svg",
|
|
1514
|
-
"packages/pds-cli/bin/",
|
|
1515
|
-
"packages/pds-cli/lib/",
|
|
1516
|
-
"src/js/pds.d.ts",
|
|
1517
|
-
"src/js/pds.js",
|
|
1518
|
-
"src/js/pds-live-manager/",
|
|
1519
|
-
"src/js/pds-core/",
|
|
1520
|
-
"custom-elements.json",
|
|
1521
|
-
"custom-elements-manifest.config.js",
|
|
1522
|
-
"pds.html-data.json",
|
|
1523
|
-
"pds.css-data.json",
|
|
1524
|
-
"readme.md",
|
|
1525
|
-
"INTELLISENSE.md",
|
|
1526
|
-
"CSS-INTELLISENSE-LIMITATION.md",
|
|
1527
|
-
"CSS-INTELLISENSE-QUICK-REF.md"
|
|
1528
|
-
],
|
|
1529
|
-
scripts: {
|
|
1530
|
-
test: 'echo "Error: no test specified" && exit 1',
|
|
1531
|
-
dev: "node esbuild-dev.js",
|
|
1532
|
-
prebuild: "npm run types",
|
|
1533
|
-
build: "node esbuild-build.js",
|
|
1534
|
-
types: "tsc -p tsconfig.json && node scripts/sync-types.mjs",
|
|
1535
|
-
postinstall: "node packages/pds-cli/bin/postinstall.mjs",
|
|
1536
|
-
"prepds:build": "npm run types",
|
|
1537
|
-
"pds:build": "node packages/pds-cli/bin/pds-static.js",
|
|
1538
|
-
"pds:build-icons": "node packages/pds-cli/bin/pds-build-icons.js",
|
|
1539
|
-
"pds:bootstrap": "node packages/pds-cli/bin/pds-bootstrap.js",
|
|
1540
|
-
"pds:manifest": "node packages/pds-cli/bin/generate-manifest.js",
|
|
1541
|
-
"pds:css-data": "node packages/pds-cli/bin/generate-css-data.js",
|
|
1542
|
-
"pds:import": "node packages/pds-cli/bin/pds-import.js",
|
|
1543
|
-
"pds:dx": "node packages/pds-cli/bin/pds-dx.js",
|
|
1544
|
-
"pds:mcp:health": "node packages/pds-cli/bin/pds-mcp-health.js",
|
|
1545
|
-
"pds:mcp:eval": "node packages/pds-cli/bin/pds-mcp-eval.js",
|
|
1546
|
-
"storybook:generate": "cd packages/pds-storybook && npm run generate-stories",
|
|
1547
|
-
"storybook:dev": "cd packages/pds-storybook && npm run storybook:dev",
|
|
1548
|
-
"storybook:build": "cd packages/pds-storybook && npm run storybook:build"
|
|
1549
|
-
},
|
|
1550
|
-
author: "Marc van Neerven",
|
|
1551
|
-
license: "ISC",
|
|
1552
|
-
engines: {
|
|
1553
|
-
node: ">=18"
|
|
1554
|
-
},
|
|
1555
|
-
publishConfig: {
|
|
1556
|
-
access: "public"
|
|
1557
|
-
},
|
|
1558
|
-
devDependencies: {
|
|
1559
|
-
"@custom-elements-manifest/analyzer": "^0.9.9",
|
|
1560
|
-
esbuild: "^0.19.0",
|
|
1561
|
-
"fs-extra": "^11.1.1",
|
|
1562
|
-
typescript: "^5.6.3",
|
|
1563
|
-
"@types/node": "^22.10.2"
|
|
1564
|
-
},
|
|
1565
|
-
dependencies: {
|
|
1566
|
-
lit: "^3.3.1",
|
|
1567
|
-
"pure-web": "1.1.32"
|
|
1568
|
-
},
|
|
1569
|
-
customElements: "custom-elements.json"
|
|
1570
|
-
};
|
|
1571
|
-
|
|
1572
|
-
// src/js/app.js
|
|
1573
|
-
await PDS.start(config);
|
|
1574
|
-
var rawRepoUrl = typeof package_default.repository === "string" ? package_default.repository : package_default.repository?.url;
|
|
1575
|
-
var repoUrl = rawRepoUrl ? rawRepoUrl.replace(/^git\+/, "").replace(/\.git$/, "") : "";
|
|
1576
|
-
var homepageUrl = package_default.homepage || repoUrl;
|
|
1577
|
-
var issuesUrl = package_default.bugs?.url || "";
|
|
1578
|
-
document.body.innerHTML = /*html*/
|
|
1579
|
-
`
|
|
1
|
+
var Pe=Object.defineProperty;var Me=(e,t)=>{for(var s in t)Pe(e,s,{get:t[s],enumerable:!0})};var X=class{constructor(){this._mode="static",this._staticPaths={tokens:"/assets/pds/styles/pds-tokens.css.js",primitives:"/assets/pds/styles/pds-primitives.css.js",components:"/assets/pds/styles/pds-components.css.js",utilities:"/assets/pds/styles/pds-utilities.css.js",styles:"/assets/pds/styles/pds-styles.css.js"}}setLiveMode(){this._mode="live"}setStaticMode(t={}){this._mode="static",this._staticPaths={...this._staticPaths,...t}}async getStylesheet(t){if(this._mode==="live")return null;try{return(await import(this._staticPaths[t]))[t]}catch(s){console.error(`[PDS Registry] Failed to load static ${t}:`,s),console.error(`[PDS Registry] Looking for: ${this._staticPaths[t]}`),console.error("[PDS Registry] Make sure you've run 'npm run pds:build' and configured PDS.start() with the correct static.root path");let n=new CSSStyleSheet;return n.replaceSync("/* Failed to load "+t+" */"),n}}get mode(){return this._mode}get isLive(){return this._mode==="live"}},P=new X;async function pe(e,t=[],s=null){try{let n=s?.primitivesStylesheet?s.primitivesStylesheet:await P.getStylesheet("primitives");e.adoptedStyleSheets=[n,...t]}catch(n){let c=e.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${c}> failed to adopt primitives:`,n),e.adoptedStyleSheets=t}}async function ue(e,t=["primitives"],s=[],n=null){try{let r=(await Promise.all(t.map(async d=>{if(n)switch(d){case"tokens":return n.tokensStylesheet;case"primitives":return n.primitivesStylesheet;case"components":return n.componentsStylesheet;case"utilities":return n.utilitiesStylesheet;default:break}return P.getStylesheet(d)}))).filter(d=>d!==null);e.adoptedStyleSheets=[...r,...s]}catch(c){let r=e.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${r}> failed to adopt layers:`,c),e.adoptedStyleSheets=s}}function me(e){let t=new CSSStyleSheet;return t.replaceSync(e),t}var fe={FontWeights:{light:300,normal:400,medium:500,semibold:600,bold:700},LineHeights:{tight:1.25,normal:1.5,relaxed:1.75},BorderWidths:{hairline:.5,thin:1,medium:2,thick:3},RadiusSizes:{none:0,small:4,medium:8,large:16,xlarge:24,xxlarge:32},ShadowDepths:{none:"none",light:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",medium:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",deep:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",extreme:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"},TransitionSpeeds:{fast:150,normal:250,slow:350},AnimationEasings:{linear:"linear",ease:"ease","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out",bounce:"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},TouchTargetSizes:{compact:36,standard:44,comfortable:48,spacious:56},LinkStyles:{inline:"inline",block:"block",button:"button"},FocusStyles:{ring:"ring",outline:"outline",border:"border",glow:"glow"},TabSizes:{compact:2,standard:4,wide:8},SelectIcons:{chevron:"chevron",arrow:"arrow",caret:"caret",none:"none"},IconSizes:{xs:16,sm:20,md:24,lg:32,xl:48,"2xl":64,"3xl":96}};var Z={};Me(Z,{deepMerge:()=>he,fragmentFromTemplateLike:()=>Te,isObject:()=>O,parseHTML:()=>Y});function O(e){return e&&typeof e=="object"&&!Array.isArray(e)}function he(e,t){let s={...e};return O(e)&&O(t)&&Object.keys(t).forEach(n=>{O(t[n])?n in e?s[n]=he(e[n],t[n]):Object.assign(s,{[n]:t[n]}):Object.assign(s,{[n]:t[n]})}),s}function Te(e){let t=Array.isArray(e?.strings)?e.strings:[],s=Array.isArray(e?.values)?e.values:[],n=new Set,c=[],r=/(\s)(\.[\w-]+)=\s*$/;for(let i=0;i<t.length;i+=1){let b=t[i]??"",f=b.match(r);if(f&&i<s.length){let g=f[2].slice(1),v=`pds-val-${i}`;b=b.replace(r,`$1data-pds-prop="${g}:${v}"`),n.add(i)}c.push(b),i<s.length&&!n.has(i)&&c.push(`<!--pds-val-${i}-->`)}let d=document.createElement("template");d.innerHTML=c.join("");let w=(i,b)=>{let f=i.parentNode;if(!f)return;if(b==null){f.removeChild(i);return}let S=g=>{if(g!=null){if(g instanceof Node){f.insertBefore(g,i);return}if(Array.isArray(g)){g.forEach(v=>S(v));return}f.insertBefore(document.createTextNode(String(g)),i)}};S(b),f.removeChild(i)},E=document.createTreeWalker(d.content,NodeFilter.SHOW_COMMENT),h=[];for(;E.nextNode();){let i=E.currentNode;i?.nodeValue?.startsWith("pds-val-")&&h.push(i)}return h.forEach(i=>{let b=Number(i.nodeValue.replace("pds-val-",""));w(i,s[b])}),d.content.querySelectorAll("*").forEach(i=>{let b=i.getAttribute("data-pds-prop");if(!b)return;let[f,S]=b.split(":"),g=Number(String(S).replace("pds-val-",""));f&&Number.isInteger(g)&&(i[f]=s[g]),i.removeAttribute("data-pds-prop")}),d.content}function Y(e){return new DOMParser().parseFromString(e,"text/html").body.childNodes}var be="pds",Ue=/^([a-z][a-z0-9+\-.]*:)?\/\//i,ye=/^[a-z]:/i;function U(e=""){return e.endsWith("/")?e:`${e}/`}function Ce(e="",t=be){let s=e.replace(/\/+$/,"");return new RegExp(`(?:^|/)${t}$`,"i").test(s)?s:`${s}/${t}`}function $e(e){return e.replace(/^\.\/+/,"")}function Ie(e){return ye.test(e)?e.replace(ye,"").replace(/^\/+/,""):e}function Ne(e){return e.startsWith("public/")?e.substring(7):e}function z(e,t={}){let s=t.segment||be,n=t.defaultRoot||`/assets/${s}/`,c=e?.public&&e.public?.root||e?.static&&e.static?.root||null;if(!c||typeof c!="string")return U(n);let r=c.trim();return r?(r=r.replace(/\\/g,"/"),r=Ce(r,s),r=U(r),Ue.test(r)?r:(r=$e(r),r=Ie(r),r.startsWith("/")||(r=Ne(r),r.startsWith("/")||(r=`/${r}`),r=r.replace(/\/+/g,(d,w)=>w===0?d:"/")),U(r))):U(n)}async function Oe(...e){let t={};e.length&&typeof e[e.length-1]=="object"&&(t=e.pop()||{});let s=e,{baseURL:n,mapper:c=h=>`${h}.js`,onError:r=(h,a)=>console.error(`[defineWebComponents] ${h}:`,a)}=t,d=n?new URL(n,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),w=h=>h.toLowerCase().replace(/(^|-)([a-z])/g,(a,i,b)=>b.toUpperCase()),E=async h=>{try{if(customElements.get(h))return{tag:h,status:"already-defined"};let a=c(h),b=await import(a instanceof URL?a.href:new URL(a,d).href),f=b?.default??b?.[w(h)];if(!f){if(customElements.get(h))return{tag:h,status:"self-defined"};throw new Error(`No export found for ${h}. Expected default export or named export "${w(h)}".`)}return customElements.get(h)?{tag:h,status:"race-already-defined"}:(customElements.define(h,f),{tag:h,status:"defined"})}catch(a){throw r(h,a),a}};return Promise.all(s.map(E))}var F=class{constructor(t={}){let{baseURL:s,mapper:n,onError:c,predicate:r=()=>!0,attributeModule:d="data-module",root:w=document,scanExisting:E=!0,debounceMs:h=16,observeShadows:a=!0,enhancers:i=[],patchAttachShadow:b=!0}=t,f=new Set,S=new Set,g=new Set,v=new Map,x=new WeakMap,_=new WeakMap,u=0,y=!1,k=null,N=l=>{if(!l||!i.length)return;let m=_.get(l);m||(m=new Set,_.set(l,m));for(let p of i)if(!(!p.selector||!p.run)&&!m.has(p.selector))try{l.matches&&l.matches(p.selector)&&(p.run(l),m.add(p.selector))}catch(L){console.warn(`[AutoDefiner] Error applying enhancer for selector "${p.selector}":`,L)}},T=(l,m)=>{if(!y&&!(!l||!l.includes("-"))&&!customElements.get(l)&&!S.has(l)&&!g.has(l)){if(m&&m.getAttribute){let p=m.getAttribute(d);p&&!v.has(l)&&v.set(l,p)}f.add(l),De()}},De=()=>{u||(u=setTimeout(ce,h))},R=l=>{if(l){if(l.nodeType===1){let m=l,p=m.tagName?.toLowerCase();p&&p.includes("-")&&!customElements.get(p)&&r(p,m)&&T(p,m),N(m),a&&m.shadowRoot&&J(m.shadowRoot)}l.querySelectorAll&&l.querySelectorAll("*").forEach(m=>{let p=m.tagName?.toLowerCase();p&&p.includes("-")&&!customElements.get(p)&&r(p,m)&&T(p,m),N(m),a&&m.shadowRoot&&J(m.shadowRoot)})}},J=l=>{if(!l||x.has(l))return;R(l);let m=new MutationObserver(p=>{for(let L of p)L.addedNodes?.forEach(D=>{R(D)}),L.type==="attributes"&&L.target&&R(L.target)});m.observe(l,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[d,...i.map(p=>p.selector).filter(p=>p.startsWith("data-"))]}),x.set(l,m)};async function ce(){if(clearTimeout(u),u=0,!f.size)return;let l=Array.from(f);f.clear(),l.forEach(m=>S.add(m));try{let m=p=>v.get(p)??(n?n(p):`${p}.js`);await Oe(...l,{baseURL:s,mapper:m,onError:(p,L)=>{g.add(p),c?.(p,L)}})}catch{}finally{l.forEach(m=>S.delete(m))}}let de=w===document?document.documentElement:w,le=new MutationObserver(l=>{for(let m of l)m.addedNodes?.forEach(p=>{R(p)}),m.type==="attributes"&&m.target&&R(m.target)});if(le.observe(de,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[d,...i.map(l=>l.selector).filter(l=>l.startsWith("data-"))]}),a&&b&&Element.prototype.attachShadow){let l=Element.prototype.attachShadow;Element.prototype.attachShadow=function(p){let L=l.call(this,p);if(p&&p.mode==="open"){J(L);let D=this.tagName?.toLowerCase();D&&D.includes("-")&&!customElements.get(D)&&T(D,this)}return L},k=()=>Element.prototype.attachShadow=l}return E&&R(de),{stop(){y=!0,le.disconnect(),k&&k(),u&&(clearTimeout(u),u=0),x.forEach(l=>l.disconnect())},flush:ce}}static async define(...t){let s={};t.length&&typeof t[t.length-1]=="object"&&(s=t.pop()||{});let n=t,{baseURL:c,mapper:r=a=>`${a}.js`,onError:d=(a,i)=>console.error(`[defineWebComponents] ${a}:`,i)}=s,w=c?new URL(c,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),E=a=>a.toLowerCase().replace(/(^|-)([a-z])/g,(i,b,f)=>f.toUpperCase()),h=async a=>{try{if(customElements.get(a))return{tag:a,status:"already-defined"};let i=r(a),f=await import(i instanceof URL?i.href:new URL(i,w).href),S=f?.default??f?.[E(a)];if(!S){if(customElements.get(a))return{tag:a,status:"self-defined"};throw new Error(`No export found for ${a}. Expected default export or named export "${E(a)}".`)}return customElements.get(a)?{tag:a,status:"race-already-defined"}:(customElements.define(a,S),{tag:a,status:"defined"})}catch(i){throw d(a,i),i}};return Promise.all(n.map(h))}};var ze=/^[a-z][a-z0-9+\-.]*:\/\//i,C=(()=>{try{return import.meta.url}catch{return}})(),W=e=>typeof e=="string"&&e.length&&!e.endsWith("/")?`${e}/`:e;function B(e,t={}){if(!e||ze.test(e))return e;let{preferModule:s=!0}=t,n=()=>{if(!C)return null;try{return new URL(e,C).href}catch{return null}},c=()=>{if(typeof window>"u"||!window.location?.origin)return null;try{return new URL(e,window.location.origin).href}catch{return null}};return(s?n()||c():c()||n())||e}var ge=(()=>{if(C)try{let e=new URL(C);if(/\/public\/assets\/js\//.test(e.pathname))return new URL("../pds/",C).href}catch{return}})(),we=!1;function Se(e){we||typeof document>"u"||(we=!0,e.addEventListener("pds:ready",t=>{let s=t.detail?.mode;s&&document.documentElement.classList.add(`pds-${s}`,"pds-ready")}))}function Ee({manageTheme:e,themeStorageKey:t,applyResolvedTheme:s,setupSystemListenerIfNeeded:n}){let c="light",r=null;if(e&&typeof window<"u"){try{r=localStorage.getItem(t)||null}catch{r=null}try{s?.(r),n?.(r)}catch{}r?r==="system"?c=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":c=r:c=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return{resolvedTheme:c,storedTheme:r}}function q(e,{resolvePublicAssetURL:t}){let s=!!(e?.public?.root||e?.static?.root),n=t(e);return!s&&ge&&(n=ge),W(B(n))}async function ve(e,{baseEnhancers:t=[]}={}){let{autoDefineBaseURL:s="/auto-define/",autoDefinePreload:n=[],autoDefineMapper:c=null,enhancers:r=[],autoDefineOverrides:d=null,autoDefinePreferModule:w=!0}=e,E=(()=>{let a=new Map;return(t||[]).forEach(i=>a.set(i.selector,i)),(r||[]).forEach(i=>a.set(i.selector,i)),Array.from(a.values())})(),h=null;if(typeof window<"u"&&typeof document<"u"){let a=F,i=u=>{switch(u){case"pds-tabpanel":return"pds-tabstrip.js";default:return`${u}.js`}},{mapper:b,enhancers:f,...S}=d&&typeof d=="object"?d:{},g=f?Array.isArray(f)?f:typeof f=="object"?Object.values(f):[]:[],v=(()=>{let u=new Map;return(E||[]).forEach(y=>{y?.selector&&u.set(y.selector,y)}),(g||[]).forEach(y=>{if(!y?.selector)return;let k=u.get(y.selector)||null;u.set(y.selector,{...k||{},...y,run:typeof y?.run=="function"?y.run:k?.run})}),Array.from(u.values())})(),_={baseURL:s&&W(B(s,{preferModule:w})),predefine:n,scanExisting:!0,observeShadows:!0,patchAttachShadow:!0,debounceMs:16,enhancers:v,onError:(u,y)=>{if(typeof u=="string"&&u.startsWith("pds-")){let N=["pds-form","pds-drawer"].includes(u),T=y?.message?.includes("#pds/lit")||y?.message?.includes("Failed to resolve module specifier");N&&T?console.error(`\u274C PDS component <${u}> requires Lit but #pds/lit is not in import map.
|
|
2
|
+
See: https://github.com/Pure-Web-Foundation/pure-ds/blob/main/readme.md#lit-components-not-working`):console.warn(`\u26A0\uFE0F PDS component <${u}> not found. Assets may not be installed.`)}else console.error(`\u274C Auto-define error for <${u}>:`,y)},...S,mapper:u=>{if(customElements.get(u))return null;if(typeof c=="function")try{let y=c(u);return y===void 0?i(u):y}catch(y){return console.warn("Custom autoDefine.mapper error; falling back to default:",y?.message||y),i(u)}return i(u)}};h=new a(_),n.length>0&&typeof a.define=="function"&&await a.define(...n,{baseURL:s,mapper:_.mapper,onError:_.onError})}return{autoDefiner:h,mergedEnhancers:E}}var ee=["light","dark"],te=new Set(ee);function Fe(e){let s=(Array.isArray(e?.themes)?e.themes.map(n=>String(n).toLowerCase()):ee).filter(n=>te.has(n));return s.length?s:ee}function se(e,{preferDocument:t=!0}={}){let s=String(e||"").toLowerCase();if(te.has(s))return s;if(t&&typeof document<"u"){let n=document.documentElement?.getAttribute("data-theme");if(te.has(n))return n}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Le(e,t){let s=se(t);return Fe(e).includes(s)}var re=class extends EventTarget{},o=new re;o.initializing=!1;o.currentPreset=null;o.debug=!1;var H=null,V=null,K=null,G=null;function Q(e,t){return t&&typeof t=="string"?t:`${q(o.currentConfig||{},{resolvePublicAssetURL:z})}core/${e}`}async function We(){return Array.isArray(o.defaultEnhancers)&&o.defaultEnhancers.length>0?o.defaultEnhancers:(G||(G=import(Q("pds-enhancers.js",o.currentConfig?.enhancersURL)).then(t=>{let s=Array.isArray(t?.defaultPDSEnhancers)?t.defaultPDSEnhancers:[];return o.defaultEnhancers=s,s}).catch(t=>{throw G=null,t})),G)}async function Be(){return typeof o.ask=="function"&&o.ask!==Ae?o.ask:(V||(V=import(Q("pds-ask.js",o.currentConfig?.askURL)).then(t=>{let s=t?.ask;if(typeof s!="function")throw new Error("Failed to load ask helper");return o.ask=s,s}).catch(t=>{throw V=null,t})),V)}async function I(){return typeof o.toast=="function"&&o.toast!==M?o.toast:(K||(K=import(Q("pds-toast.js",o.currentConfig?.toastURL)).then(t=>{let s=t?.toast;if(typeof s!="function")throw new Error("Failed to load toast helper");return o.toast=s,s}).catch(t=>{throw K=null,t})),K)}async function Ae(...e){return(await Be())(...e)}async function M(...e){return(await I())(...e)}M.success=async(...e)=>(await I()).success(...e);M.error=async(...e)=>(await I()).error(...e);M.warning=async(...e)=>(await I()).warning(...e);M.info=async(...e)=>(await I()).info(...e);var ke=function(e="log",t,...s){let n=!!(o.registry&&!o.registry.isLive),c=(this?.debug||this?.design?.debug||o.debug||!1)===!0;if(n){if(!o.debug)return}else if(!c&&e!=="error"&&e!=="warn")return;let r=console[e]||console.log;s.length>0?r(t,...s):r(t)};function oe(e){if(e==null)return e;if(typeof e=="function")return;if(typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>oe(s)).filter(s=>s!==void 0);let t={};for(let[s,n]of Object.entries(e)){let c=oe(n);c!==void 0&&(t[s]=c)}return t}async function qe(e,t={}){if(t?.runtimeConfig===!1||typeof fetch!="function")return null;let s=t?.runtimeConfigURL||`${e}pds-runtime-config.json`;try{let n=await fetch(s,{cache:"no-store"});return n.ok?await n.json():null}catch{return null}}o.registry=P;o.enums=fe;o.adoptLayers=ue;o.adoptPrimitives=pe;o.parse=Y;o.createStylesheet=me;o.isLiveMode=()=>P.isLive;o.ask=Ae;o.toast=M;o.common=Z;o.AutoComplete=null;o.loadAutoComplete=async()=>{if(o.AutoComplete&&typeof o.AutoComplete.connect=="function")return o.AutoComplete;let e=Q("pds-autocomplete.js",o.currentConfig?.autoCompleteURL);return H||(H=import(e).then(t=>{let s=t?.AutoComplete||t?.default?.AutoComplete||t?.default||null;if(!s)throw new Error("AutoComplete export not found in module");return o.AutoComplete=s,s}).catch(t=>{throw H=null,t})),H};function _e(e){let t=typeof CustomEvent=="function";try{let s=t?new CustomEvent("pds:ready",{detail:e}):new Event("pds:ready");o.dispatchEvent(s)}catch{}if(typeof document<"u")if(t){let s={detail:e,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:ready",s))}catch{}try{document.dispatchEvent(new CustomEvent("pds-ready",s))}catch{}}else{try{document.dispatchEvent(new Event("pds:ready"))}catch{}try{document.dispatchEvent(new Event("pds-ready"))}catch{}}}function xe(e={}){let t=typeof CustomEvent=="function",s={at:Date.now(),...e};try{let n=t?new CustomEvent("pds:config-changed",{detail:s}):new Event("pds:config-changed");o.dispatchEvent(n)}catch{}if(typeof document<"u")if(t){let n={detail:s,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:config-changed",n))}catch{}}else try{document.dispatchEvent(new Event("pds:config-changed"))}catch{}}var ne="pure-ds-theme",j=null,$=null;function ie(e){try{if(typeof document>"u")return;let t="light";e?e==="system"?t=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t=e:t=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",document.documentElement.setAttribute("data-theme",t)}catch{}}function ae(e){try{if(j&&$){try{typeof j.removeEventListener=="function"?j.removeEventListener("change",$):typeof j.removeListener=="function"&&j.removeListener($)}catch{}j=null,$=null}if(e==="system"&&typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),s=n=>{let c=n?.matches===void 0?t.matches:n.matches;try{let r=c?"dark":"light";document.documentElement.setAttribute("data-theme",r),o.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:r,source:"system"}}))}catch{}};j=t,$=s,typeof t.addEventListener=="function"?t.addEventListener("change",s):typeof t.addListener=="function"&&t.addListener(s)}}catch{}}Object.defineProperty(o,"theme",{get(){try{return typeof window>"u"?null:localStorage.getItem(ne)||null}catch{return null}},set(e){try{if(typeof window>"u")return;let t=o.currentConfig?.design||null,s=se(e);if(t&&!Le(t,s)){let n=t?.name||o.currentPreset?.name||o.currentConfig?.preset||"current preset";console.warn(`PDS theme "${s}" not supported by preset "${n}".`),o.dispatchEvent(new CustomEvent("pds:theme:blocked",{detail:{theme:e,resolvedTheme:s,preset:n}}));return}e==null?localStorage.removeItem(ne):localStorage.setItem(ne,e),ie(e),ae(e),o.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:e,source:"api"}}))}catch{}}});o.defaultEnhancers=[];async function He(e){let t=e&&e.mode||"live",{mode:s,...n}=e||{};if(t==="static")return Ve(n);let c=q(n,{resolvePublicAssetURL:z}),r=n?.managerURL||n?.public?.managerURL||n?.manager?.url||new URL("core/pds-manager.js",c).href||new URL("./pds-manager.js",import.meta.url).href,{startLive:d}=await import(r);return d(o,n,{emitReady:_e,emitConfigChanged:xe,applyResolvedTheme:ie,setupSystemListenerIfNeeded:ae})}o.start=He;async function Ve(e){if(!e||typeof e!="object")throw new Error("PDS.start({ mode: 'static', ... }) requires a valid configuration object");let t=e.applyGlobalStyles??!0,s=e.manageTheme??!0,n=e.themeStorageKey??"pure-ds-theme",c=e.staticPaths??{},r=q(e,{resolvePublicAssetURL:z}),d=e&&e.autoDefine||null,w;d&&d.baseURL?w=W(B(d.baseURL,{preferModule:!1})):w=`${r}components/`;let E=d&&Array.isArray(d.predefine)&&d.predefine||[],h=d&&typeof d.mapper=="function"&&d.mapper||null;try{Se(o);let{resolvedTheme:a}=Ee({manageTheme:s,themeStorageKey:n,applyResolvedTheme:ie,setupSystemListenerIfNeeded:ae}),i=await qe(r,e),b=Array.isArray(e?.enhancers)?e.enhancers:e?.enhancers&&typeof e.enhancers=="object"?Object.values(e.enhancers):[],f=i?.config?{...i.config,...e,design:e?.design||i.config.design,preset:e?.preset||i.config.preset}:{...e},S={tokens:`${r}styles/pds-tokens.css.js`,primitives:`${r}styles/pds-primitives.css.js`,components:`${r}styles/pds-components.css.js`,utilities:`${r}styles/pds-utilities.css.js`,styles:`${r}styles/pds-styles.css.js`},g=i?.paths||{};if(c={...S,...g,...c},o.registry.setStaticMode(c),t&&typeof document<"u")try{let u=await o.registry.getStylesheet("styles");if(u){u._pds=!0;let y=(document.adoptedStyleSheets||[]).filter(k=>k._pds!==!0);document.adoptedStyleSheets=[...y,u],xe({mode:"static",source:"static:styles-applied"})}}catch(u){ke.call(o,"warn","Failed to apply static styles:",u)}let v=null,x=[];try{let u=await We(),y=await ve({autoDefineBaseURL:w,autoDefinePreload:E,autoDefineMapper:h,enhancers:b,autoDefineOverrides:d||null,autoDefinePreferModule:!(d&&d.baseURL)},{baseEnhancers:u});v=y.autoDefiner,x=y.mergedEnhancers||[]}catch(u){ke.call(o,"error","\u274C Failed to initialize AutoDefiner/Enhancers (static):",u)}let _=oe(e);return o.currentConfig=Object.freeze({mode:"static",...structuredClone(_),design:structuredClone(f.design||{}),preset:f.preset,theme:a,enhancers:x}),_e({mode:"static",config:f,theme:a,autoDefiner:v}),{config:f,theme:a,autoDefiner:v}}catch(a){throw o.dispatchEvent(new CustomEvent("pds:error",{detail:{error:a}})),a}}var je={mode:"live",liveEdit:!0,preset:"default",autoDefine:{predefine:["pds-icon","pds-drawer","pds-toaster","pds-form"]},log(e,t,...s){console[e](t,...s)}};var A={name:"@pure-ds/core",shortname:"pds",version:"0.7.6",description:"Why develop a Design System when you can generate one?",repository:{type:"git",url:"git+https://github.com/Pure-Web-Foundation/pure-ds.git"},bugs:{url:"https://github.com/Pure-Web-Foundation/pure-ds/issues"},homepage:"https://puredesignsystem.z6.web.core.windows.net/",keywords:["design-system","css","web-components","lit","constructable-stylesheets","tokens","utilities","a11y"],type:"module",main:"./public/assets/pds/core.js",module:"./public/assets/pds/core.js",types:"./dist/types/pds.d.ts",bin:{"pds-build":"packages/pds-cli/bin/pds-static.js","pds-sync-assets":"packages/pds-cli/bin/sync-assets.js","pds-build-icons":"packages/pds-cli/bin/pds-build-icons.js","pds-import":"packages/pds-cli/bin/pds-import.js","pds-setup-copilot":"packages/pds-cli/bin/pds-setup-copilot.js","pds-setup-mcp":"packages/pds-cli/bin/pds-setup-mcp.js","pds-init-config":"packages/pds-cli/bin/pds-init-config.js","pds-bootstrap":"packages/pds-cli/bin/pds-bootstrap.js","pds-mcp-server":"packages/pds-cli/bin/pds-mcp-server.js","pds-mcp-health":"packages/pds-cli/bin/pds-mcp-health.js","pds-mcp-eval":"packages/pds-cli/bin/pds-mcp-eval.js"},exports:{".":{types:"./src/js/pds.d.ts",import:"./public/assets/pds/core.js"},"./pds-core":"./src/js/pds.js","./auto-define/*":"./public/auto-define/*"},files:[".github/copilot-instructions.md",".cursorrules","dist/types/","public/assets/js/","public/assets/pds/components/","public/assets/pds/templates/","public/assets/pds/core.js","public/assets/pds/core/","public/assets/pds/external/","public/assets/pds/vscode-custom-data.json","public/assets/pds/pds.css-data.json","public/assets/pds/pds-css-complete.json","public/auto-define/","public/pds/components/","public/assets/pds/icons/pds-icons.svg","packages/pds-cli/bin/","packages/pds-cli/lib/","src/js/pds.d.ts","src/js/pds.js","src/js/pds-live-manager/","src/js/pds-core/","custom-elements.json","custom-elements-manifest.config.js","pds.html-data.json","pds.css-data.json","readme.md","INTELLISENSE.md","CSS-INTELLISENSE-LIMITATION.md","CSS-INTELLISENSE-QUICK-REF.md"],scripts:{test:'echo "Error: no test specified" && exit 1',dev:"node esbuild-dev.js",prebuild:"npm run types",build:"node esbuild-build.js",types:"tsc -p tsconfig.json && node scripts/sync-types.mjs",postinstall:"node packages/pds-cli/bin/postinstall.mjs","prepds:build":"npm run types","pds:build":"node packages/pds-cli/bin/pds-static.js","pds:build-icons":"node packages/pds-cli/bin/pds-build-icons.js","pds:bootstrap":"node packages/pds-cli/bin/pds-bootstrap.js","pds:manifest":"node packages/pds-cli/bin/generate-manifest.js","pds:css-data":"node packages/pds-cli/bin/generate-css-data.js","pds:import":"node packages/pds-cli/bin/pds-import.js","pds:dx":"node packages/pds-cli/bin/pds-dx.js","pds:mcp:health":"node packages/pds-cli/bin/pds-mcp-health.js","pds:mcp:eval":"node packages/pds-cli/bin/pds-mcp-eval.js","storybook:generate":"cd packages/pds-storybook && npm run generate-stories","storybook:dev":"cd packages/pds-storybook && npm run storybook:dev","storybook:build":"cd packages/pds-storybook && npm run storybook:build"},author:"Marc van Neerven",license:"ISC",engines:{node:">=18"},publishConfig:{access:"public"},devDependencies:{"@custom-elements-manifest/analyzer":"^0.9.9",esbuild:"^0.19.0","fs-extra":"^11.1.1",typescript:"^5.6.3","@types/node":"^22.10.2"},dependencies:{lit:"^3.3.1","pure-web":"1.1.32"},customElements:"custom-elements.json"};await o.start(je);var Re=typeof A.repository=="string"?A.repository:A.repository?.url,Ge=Re?Re.replace(/^git\+/,"").replace(/\.git$/,""):"",bt=A.homepage||Ge,gt=A.bugs?.url||"";document.body.innerHTML=`
|
|
1580
3
|
<pds-toaster id="global-toaster"></pds-toaster>
|
|
1581
4
|
|
|
1582
5
|
<div class="container text-center">
|
|
1583
6
|
<img src="/assets/img/pds-logo.svg" alt="PDS Logo" width="64" height="64" />
|
|
1584
7
|
<header class="container section">
|
|
1585
|
-
<h1>${
|
|
1586
|
-
<small class="text-muted">${
|
|
8
|
+
<h1>${A.name} ${A.version}</h1>
|
|
9
|
+
<small class="text-muted">${A.description}</small>
|
|
1587
10
|
</header>
|
|
1588
11
|
</div>
|
|
1589
12
|
`;
|
|
1590
|
-
//# sourceMappingURL=app.js.map
|