@pure-ds/core 0.4.24 → 0.4.26
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/.cursorrules +250 -2
- package/.github/copilot-instructions.md +391 -2
- package/dist/types/pds.d.ts +109 -408
- package/dist/types/src/js/common/toast.d.ts +93 -0
- package/dist/types/src/js/common/toast.d.ts.map +1 -0
- package/dist/types/src/js/pds.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/js/pds.d.ts +62 -0
- package/src/js/pds.js +2 -0
package/dist/types/pds.d.ts
CHANGED
|
@@ -1,408 +1,109 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
* const g = new PDS.Generator({ example: true });
|
|
111
|
-
* // tokens may be returned synchronously or via a Promise
|
|
112
|
-
* const tokens = await g.generateTokens?.();
|
|
113
|
-
* const css = await g.generateCSS?.();
|
|
114
|
-
*/
|
|
115
|
-
export class Generator {
|
|
116
|
-
constructor(options?: any);
|
|
117
|
-
/** runtime options / config passed to the generator */
|
|
118
|
-
options: any;
|
|
119
|
-
/** generated token object */
|
|
120
|
-
tokens: Record<string, any>;
|
|
121
|
-
/** concatenated CSS (layered) */
|
|
122
|
-
css: string;
|
|
123
|
-
/** Complete compiled representation of the design system state */
|
|
124
|
-
readonly compiled: CompiledState;
|
|
125
|
-
/** Generate the token map (may be async in some implementations) */
|
|
126
|
-
generateTokens?(): Record<string, any> | Promise<Record<string, any>>;
|
|
127
|
-
/** Generate the CSS string (may be async) */
|
|
128
|
-
generateCSS?(): string | Promise<string>;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/** Public runtime surface exported as `PDS` */
|
|
132
|
-
export interface PDSEventMap {
|
|
133
|
-
'pds:ready': CustomEvent<{ mode: 'live' | 'static'; generator?: Generator; config: any; theme: string; autoDefiner?: any }>;
|
|
134
|
-
'pds:error': CustomEvent<{ error: any }>;
|
|
135
|
-
'pds:theme:changed': CustomEvent<{ theme: string; requested?: string; source: 'system' | 'programmatic' }>;
|
|
136
|
-
'pds:design:updated': CustomEvent<{ config: any; designer?: any }>;
|
|
137
|
-
'pds:design:field:changed': CustomEvent<{ field: string; config: any }>;
|
|
138
|
-
'pds:inspector:mode:changed': CustomEvent<{ active: boolean }>;
|
|
139
|
-
'pds:inspector:deactivate': CustomEvent<{}>;
|
|
140
|
-
'pds:docs:view': CustomEvent<{ file: string }>;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export class PDS extends EventTarget {
|
|
144
|
-
// Static surface
|
|
145
|
-
static Generator: typeof Generator;
|
|
146
|
-
static registry: PDSRegistry;
|
|
147
|
-
static presets: Record<string, any>;
|
|
148
|
-
static ontology: any;
|
|
149
|
-
static adoptLayers: (shadowRoot: ShadowRoot, layers?: string[], additionalSheets?: CSSStyleSheet[]) => Promise<void>;
|
|
150
|
-
static adoptPrimitives: (shadowRoot: ShadowRoot, additionalSheets?: CSSStyleSheet[]) => Promise<void>;
|
|
151
|
-
static createStylesheet: (css: string) => CSSStyleSheet;
|
|
152
|
-
static isLiveMode: () => boolean;
|
|
153
|
-
static findComponentForElement: (el: Element) => ComponentDef | null;
|
|
154
|
-
static validateDesign: (designConfig: any, options?: { minContrast?: number }) => { ok: boolean; issues: Array<{ path: string; message: string; ratio: number; min: number; context?: string }> };
|
|
155
|
-
static validateDesigns: (designs: Array<any> | Record<string, any>, options?: { minContrast?: number }) => { ok: boolean; results: Array<{ name?: string; ok: boolean; issues: Array<{ path: string; message: string; ratio: number; min: number; context?: string }> }> };
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Current configuration after PDS.start() completes - read-only, frozen after initialization.
|
|
159
|
-
* Contains the complete configuration used to initialize PDS, including mode, design, preset, and theme.
|
|
160
|
-
*/
|
|
161
|
-
static readonly currentConfig: any;
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Compiled design system state - provides structured access to all generated tokens,
|
|
165
|
-
* layers, and metadata. Available in live mode when a generator is active.
|
|
166
|
-
* Returns null if not in live mode or if no generator is present.
|
|
167
|
-
*/
|
|
168
|
-
static readonly compiled: CompiledState | null;
|
|
169
|
-
|
|
170
|
-
// Static EventTarget-like facade for default instance
|
|
171
|
-
static addEventListener<K extends keyof PDSEventMap>(type: K, listener: (ev: PDSEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
172
|
-
static removeEventListener<K extends keyof PDSEventMap>(type: K, listener: (ev: PDSEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
173
|
-
static dispatchEvent(event: PDSEventMap[keyof PDSEventMap] | Event): boolean;
|
|
174
|
-
|
|
175
|
-
// Static entry point
|
|
176
|
-
static start(config?: {
|
|
177
|
-
mode?: 'live' | 'static';
|
|
178
|
-
preset?: string;
|
|
179
|
-
design?: any;
|
|
180
|
-
autoDefine?: {
|
|
181
|
-
baseURL?: string;
|
|
182
|
-
predefine?: string[];
|
|
183
|
-
mapper?: (tag: string) => string | undefined | null | false;
|
|
184
|
-
scanExisting?: boolean;
|
|
185
|
-
observeShadows?: boolean;
|
|
186
|
-
patchAttachShadow?: boolean;
|
|
187
|
-
debounceMs?: number;
|
|
188
|
-
onError?: (tag: string, err: any) => void;
|
|
189
|
-
};
|
|
190
|
-
applyGlobalStyles?: boolean;
|
|
191
|
-
manageTheme?: boolean;
|
|
192
|
-
themeStorageKey?: string;
|
|
193
|
-
public?: {
|
|
194
|
-
root?: string;
|
|
195
|
-
};
|
|
196
|
-
// live-only
|
|
197
|
-
preloadStyles?: boolean;
|
|
198
|
-
criticalLayers?: string[];
|
|
199
|
-
// static-only
|
|
200
|
-
staticPaths?: Record<string, string>;
|
|
201
|
-
enhancers?: Array<any>;
|
|
202
|
-
}): Promise<PDS>;
|
|
203
|
-
|
|
204
|
-
constructor();
|
|
205
|
-
|
|
206
|
-
// Instance state
|
|
207
|
-
readonly mode: 'live' | 'static';
|
|
208
|
-
readonly generator?: Generator;
|
|
209
|
-
readonly config: any;
|
|
210
|
-
readonly theme: string;
|
|
211
|
-
readonly autoDefiner?: any;
|
|
212
|
-
|
|
213
|
-
// Instance helpers
|
|
214
|
-
setTheme(theme: 'light' | 'dark' | 'system', options?: { storageKey?: string; persist?: boolean }): Promise<string>;
|
|
215
|
-
preloadCritical(config: any, options?: { theme?: string; layers?: string[] }): void;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
export { PDS as default };
|
|
219
|
-
|
|
220
|
-
// ===== pds-form Types =====
|
|
221
|
-
|
|
222
|
-
export interface JsonFormOptions {
|
|
223
|
-
widgets?: {
|
|
224
|
-
booleans?: 'toggle' | 'checkbox';
|
|
225
|
-
numbers?: 'input' | 'range';
|
|
226
|
-
selects?: 'standard' | 'dropdown';
|
|
227
|
-
};
|
|
228
|
-
layouts?: {
|
|
229
|
-
fieldsets?: 'default' | 'flex' | 'grid' | 'accordion' | 'tabs' | 'card';
|
|
230
|
-
arrays?: 'default' | 'compact';
|
|
231
|
-
};
|
|
232
|
-
enhancements?: {
|
|
233
|
-
icons?: boolean;
|
|
234
|
-
datalists?: boolean;
|
|
235
|
-
rangeOutput?: boolean;
|
|
236
|
-
};
|
|
237
|
-
validation?: {
|
|
238
|
-
showErrors?: boolean;
|
|
239
|
-
validateOnChange?: boolean;
|
|
240
|
-
};
|
|
241
|
-
// Path-specific options (JSON Pointer paths)
|
|
242
|
-
[path: string]: any;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
export interface UISchema {
|
|
246
|
-
// Field-level UI customization (JSON Pointer paths as keys)
|
|
247
|
-
[path: string]: {
|
|
248
|
-
'ui:widget'?: string;
|
|
249
|
-
'ui:layout'?: 'default' | 'flex' | 'grid' | 'accordion' | 'tabs';
|
|
250
|
-
'ui:columns'?: number | 'auto';
|
|
251
|
-
'ui:autoSize'?: 'sm' | 'md' | 'lg' | 'xl';
|
|
252
|
-
'ui:gap'?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
253
|
-
'ui:wrap'?: boolean;
|
|
254
|
-
'ui:direction'?: 'row' | 'column';
|
|
255
|
-
'ui:surface'?: 'card' | 'elevated' | 'dialog';
|
|
256
|
-
'ui:accordion'?: boolean;
|
|
257
|
-
'ui:tabs'?: boolean;
|
|
258
|
-
'ui:defaultOpen'?: number[];
|
|
259
|
-
'ui:dialog'?: boolean;
|
|
260
|
-
'ui:dialogButton'?: string;
|
|
261
|
-
'ui:dialogSize'?: 'sm' | 'lg' | 'xl' | 'full';
|
|
262
|
-
'ui:submitLabel'?: string;
|
|
263
|
-
'ui:cancelLabel'?: string;
|
|
264
|
-
'ui:help'?: string;
|
|
265
|
-
'ui:placeholder'?: string;
|
|
266
|
-
'ui:icon'?: string;
|
|
267
|
-
'ui:iconPosition'?: 'start' | 'end';
|
|
268
|
-
'ui:datalist'?: string[];
|
|
269
|
-
'ui:rows'?: number;
|
|
270
|
-
'ui:min'?: number;
|
|
271
|
-
'ui:max'?: number;
|
|
272
|
-
'ui:dropdown'?: boolean;
|
|
273
|
-
'ui:autocomplete'?: string;
|
|
274
|
-
'ui:accept'?: string;
|
|
275
|
-
'ui:multiple'?: boolean;
|
|
276
|
-
'ui:maxFiles'?: number;
|
|
277
|
-
'ui:maxSize'?: number;
|
|
278
|
-
'ui:submitOnEnter'?: boolean;
|
|
279
|
-
'ui:spellcheck'?: boolean;
|
|
280
|
-
'ui:order'?: string[];
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
export interface JsonFormEvent<T = any> extends CustomEvent {
|
|
285
|
-
detail: T;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
export interface JsonFormSubmitDetail {
|
|
289
|
-
json: any;
|
|
290
|
-
formData: FormData;
|
|
291
|
-
valid: boolean;
|
|
292
|
-
issues: Array<{ path?: string; message: string }>;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
export interface JsonFormValueChangeDetail {
|
|
296
|
-
name: string;
|
|
297
|
-
value: any;
|
|
298
|
-
validity: { valid: boolean };
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
export interface JsonFormArrayEventDetail {
|
|
302
|
-
path: string;
|
|
303
|
-
index?: number;
|
|
304
|
-
from?: number;
|
|
305
|
-
to?: number;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
export interface JsonFormDialogEventDetail {
|
|
309
|
-
path: string;
|
|
310
|
-
schema?: any;
|
|
311
|
-
value?: any;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
export interface JsonFormRendererContext {
|
|
315
|
-
id: string;
|
|
316
|
-
path: string;
|
|
317
|
-
label: string;
|
|
318
|
-
value: any;
|
|
319
|
-
required: boolean;
|
|
320
|
-
ui: any;
|
|
321
|
-
schema: any;
|
|
322
|
-
get: (path?: string) => any;
|
|
323
|
-
set: (value: any, path?: string) => void;
|
|
324
|
-
attrs: {
|
|
325
|
-
placeholder?: string;
|
|
326
|
-
minLength?: number;
|
|
327
|
-
maxLength?: number;
|
|
328
|
-
min?: number;
|
|
329
|
-
max?: number;
|
|
330
|
-
step?: number;
|
|
331
|
-
pattern?: string;
|
|
332
|
-
readOnly?: boolean;
|
|
333
|
-
required?: boolean;
|
|
334
|
-
autocomplete?: string;
|
|
335
|
-
list?: string;
|
|
336
|
-
};
|
|
337
|
-
host: any;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
export type JsonFormRenderer = (context: JsonFormRendererContext) => any;
|
|
341
|
-
|
|
342
|
-
export interface JsonFormEventMap {
|
|
343
|
-
'pw:schema-resolve': JsonFormEvent<{ schema: any }>;
|
|
344
|
-
'pw:compile-node': JsonFormEvent<{ path: string; schema: any; ui: any; node?: any }>;
|
|
345
|
-
'pw:choose-widget': JsonFormEvent<{ path: string; schema: any; ui: any; widget: string | null }>;
|
|
346
|
-
'pw:before-render-field': JsonFormEvent<{ path: string; schema: any; ui: any; mount?: any; render?: () => any }>;
|
|
347
|
-
'pw:render-field': JsonFormEvent<{ path: string; schema: any; node: any }>;
|
|
348
|
-
'pw:after-render-field': JsonFormEvent<{ path: string; schema: any }>;
|
|
349
|
-
'pw:value-change': JsonFormEvent<JsonFormValueChangeDetail>;
|
|
350
|
-
'pw:array-add': JsonFormEvent<JsonFormArrayEventDetail>;
|
|
351
|
-
'pw:array-remove': JsonFormEvent<JsonFormArrayEventDetail>;
|
|
352
|
-
'pw:array-reorder': JsonFormEvent<JsonFormArrayEventDetail>;
|
|
353
|
-
'pw:serialize': JsonFormEvent<JsonFormSubmitDetail>;
|
|
354
|
-
'pw:submit': JsonFormEvent<JsonFormSubmitDetail>;
|
|
355
|
-
'pw:dialog-open': JsonFormEvent<JsonFormDialogEventDetail>;
|
|
356
|
-
'pw:dialog-submit': JsonFormEvent<JsonFormDialogEventDetail>;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
declare global {
|
|
360
|
-
interface HTMLElementTagNameMap {
|
|
361
|
-
'pds-form': SchemaForm;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
export class SchemaForm extends HTMLElement {
|
|
366
|
-
// Properties
|
|
367
|
-
jsonSchema: any;
|
|
368
|
-
uiSchema: UISchema;
|
|
369
|
-
options: JsonFormOptions;
|
|
370
|
-
values: any;
|
|
371
|
-
action?: string;
|
|
372
|
-
method: 'get' | 'post' | 'dialog';
|
|
373
|
-
disabled: boolean;
|
|
374
|
-
hideActions: boolean;
|
|
375
|
-
submitLabel: string;
|
|
376
|
-
resetLabel: string;
|
|
377
|
-
hideReset: boolean;
|
|
378
|
-
hideSubmit: boolean;
|
|
379
|
-
|
|
380
|
-
// Methods
|
|
381
|
-
defineRenderer(widgetKey: string, renderer: JsonFormRenderer): void;
|
|
382
|
-
useValidator(validator: (data: any, schema: any) => Promise<{ valid: boolean; errors?: Array<{ path?: string; message: string }> }>): void;
|
|
383
|
-
getValuesFlat(): Record<string, any>;
|
|
384
|
-
serialize(): { json: any; formData: FormData };
|
|
385
|
-
submit(): Promise<JsonFormSubmitDetail>;
|
|
386
|
-
|
|
387
|
-
// Event listeners
|
|
388
|
-
addEventListener<K extends keyof JsonFormEventMap>(
|
|
389
|
-
type: K,
|
|
390
|
-
listener: (ev: JsonFormEventMap[K]) => any,
|
|
391
|
-
options?: boolean | AddEventListenerOptions
|
|
392
|
-
): void;
|
|
393
|
-
addEventListener(
|
|
394
|
-
type: string,
|
|
395
|
-
listener: EventListenerOrEventListenerObject,
|
|
396
|
-
options?: boolean | AddEventListenerOptions
|
|
397
|
-
): void;
|
|
398
|
-
removeEventListener<K extends keyof JsonFormEventMap>(
|
|
399
|
-
type: K,
|
|
400
|
-
listener: (ev: JsonFormEventMap[K]) => any,
|
|
401
|
-
options?: boolean | EventListenerOptions
|
|
402
|
-
): void;
|
|
403
|
-
removeEventListener(
|
|
404
|
-
type: string,
|
|
405
|
-
listener: EventListenerOrEventListenerObject,
|
|
406
|
-
options?: boolean | EventListenerOptions
|
|
407
|
-
): void;
|
|
408
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Public PDS runtime object exported to consumers.
|
|
3
|
+
*
|
|
4
|
+
* This object exposes the core runtime building blocks for the Pure Design System.
|
|
5
|
+
* It intentionally provides a small, stable surface area so consuming apps can:
|
|
6
|
+
* - programmatically generate design system artifacts (via `Generator`),
|
|
7
|
+
* - adopt styles into Shadow DOM (via `adoptLayers` / `adoptPrimitives`),
|
|
8
|
+
* - query runtime mode and obtain constructable stylesheets (via `registry`).
|
|
9
|
+
*
|
|
10
|
+
* Common events in the PDS ecosystem (emitted by other packages/components):
|
|
11
|
+
* - `design-updated` — emitted by the designer component when the in-memory design changes (detail: { config }).
|
|
12
|
+
* - `pds-generated` — emitted by the PDS configurator when generation completes (detail: { modules, meta }).
|
|
13
|
+
* - `pds-error` — emitted by the PDS configurator when generation fails (detail: Error).
|
|
14
|
+
*
|
|
15
|
+
* Error handling notes:
|
|
16
|
+
* - Methods that perform dynamic imports (e.g. `adoptLayers` via the registry) may log and return fallbacks
|
|
17
|
+
* rather than throwing; consumers should check return values (e.g. null) and listen for `pds-error` in UI flows.
|
|
18
|
+
* - `createStylesheet(css)` will throw synchronously if the provided CSS cannot be parsed by the browser's
|
|
19
|
+
* `CSSStyleSheet.replaceSync()` — callers should guard invalid input or wrap calls in try/catch.
|
|
20
|
+
*/
|
|
21
|
+
export type PDSAPI = {
|
|
22
|
+
/**
|
|
23
|
+
* - Generator class to produce design system assets
|
|
24
|
+
*/
|
|
25
|
+
Generator: typeof import("./pds-core/pds-generator.js").Generator;
|
|
26
|
+
/**
|
|
27
|
+
* - Singleton runtime registry for live/static mode
|
|
28
|
+
*/
|
|
29
|
+
registry: import("./pds-core/pds-registry.js").PDSRegistry;
|
|
30
|
+
/**
|
|
31
|
+
* - Ontology helpers and metadata for components
|
|
32
|
+
*/
|
|
33
|
+
ontology: any;
|
|
34
|
+
/**
|
|
35
|
+
* - Adopt multiple layers into a ShadowRoot. May log errors and fallback to additionalSheets when static imports fail.
|
|
36
|
+
*/
|
|
37
|
+
adoptLayers: (shadowRoot: ShadowRoot, layers?: string[], additionalSheets?: CSSStyleSheet[]) => Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* - Adopt primitives layer into a ShadowRoot. Designed as a convenience for components.
|
|
40
|
+
*/
|
|
41
|
+
adoptPrimitives: (shadowRoot: ShadowRoot, additionalSheets?: CSSStyleSheet[]) => Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* - Create a constructable stylesheet from CSS text.
|
|
44
|
+
*/
|
|
45
|
+
createStylesheet: (css: string) => CSSStyleSheet;
|
|
46
|
+
};
|
|
47
|
+
/** @type {PDSAPI & PDSBase} */
|
|
48
|
+
export const PDS: PDSAPI & PDSBase;
|
|
49
|
+
/**
|
|
50
|
+
* Validate a design configuration for accessibility sanity checks.
|
|
51
|
+
* Currently validates color contrast for primary buttons and base surface text
|
|
52
|
+
* in both light and dark themes.
|
|
53
|
+
*
|
|
54
|
+
* @param {object} designConfig - A full or partial PDS config object
|
|
55
|
+
* @param {object} [options]
|
|
56
|
+
* @param {number} [options.minContrast=4.5] - Minimum contrast ratio for normal text
|
|
57
|
+
* @returns {{ ok: boolean, issues: Array<{path:string, message:string, ratio:number, min:number, context?:string}> }}
|
|
58
|
+
*/
|
|
59
|
+
export function validateDesign(designConfig?: object, options?: {
|
|
60
|
+
minContrast?: number;
|
|
61
|
+
}): {
|
|
62
|
+
ok: boolean;
|
|
63
|
+
issues: Array<{
|
|
64
|
+
path: string;
|
|
65
|
+
message: string;
|
|
66
|
+
ratio: number;
|
|
67
|
+
min: number;
|
|
68
|
+
context?: string;
|
|
69
|
+
}>;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Public PDS runtime object exported to consumers.
|
|
73
|
+
*
|
|
74
|
+
* This object exposes the core runtime building blocks for the Pure Design System.
|
|
75
|
+
* It intentionally provides a small, stable surface area so consuming apps can:
|
|
76
|
+
* - programmatically generate design system artifacts (via `Generator`),
|
|
77
|
+
* - adopt styles into Shadow DOM (via `adoptLayers` / `adoptPrimitives`),
|
|
78
|
+
* - query runtime mode and obtain constructable stylesheets (via `registry`).
|
|
79
|
+
*
|
|
80
|
+
* Common events in the PDS ecosystem (emitted by other packages/components):
|
|
81
|
+
* - `design-updated` — emitted by the designer component when the in-memory design changes (detail: { config }).
|
|
82
|
+
* - `pds-generated` — emitted by the PDS configurator when generation completes (detail: { modules, meta }).
|
|
83
|
+
* - `pds-error` — emitted by the PDS configurator when generation fails (detail: Error).
|
|
84
|
+
*
|
|
85
|
+
* Error handling notes:
|
|
86
|
+
* - Methods that perform dynamic imports (e.g. `adoptLayers` via the registry) may log and return fallbacks
|
|
87
|
+
* rather than throwing; consumers should check return values (e.g. null) and listen for `pds-error` in UI flows.
|
|
88
|
+
* - `createStylesheet(css)` will throw synchronously if the provided CSS cannot be parsed by the browser's
|
|
89
|
+
* `CSSStyleSheet.replaceSync()` — callers should guard invalid input or wrap calls in try/catch.
|
|
90
|
+
*
|
|
91
|
+
* @typedef {Object} PDSAPI
|
|
92
|
+
* @property {typeof import("./pds-core/pds-generator.js").Generator} Generator - Generator class to produce design system assets
|
|
93
|
+
* @property {import("./pds-core/pds-registry.js").PDSRegistry} registry - Singleton runtime registry for live/static mode
|
|
94
|
+
* @property {any} ontology - Ontology helpers and metadata for components
|
|
95
|
+
* @property {(shadowRoot: ShadowRoot, layers?: string[], additionalSheets?: CSSStyleSheet[]) => Promise<void>} adoptLayers - Adopt multiple layers into a ShadowRoot. May log errors and fallback to additionalSheets when static imports fail.
|
|
96
|
+
* @property {(shadowRoot: ShadowRoot, additionalSheets?: CSSStyleSheet[]) => Promise<void>} adoptPrimitives - Adopt primitives layer into a ShadowRoot. Designed as a convenience for components.
|
|
97
|
+
* @property {(css:string) => CSSStyleSheet} createStylesheet - Create a constructable stylesheet from CSS text. @throws {DOMException} on invalid CSS in some browsers.
|
|
98
|
+
* @property {() => boolean} isLiveMode - Returns true when running in live/designer-backed mode
|
|
99
|
+
* @property {(el: Element) => import("./pds-core/pds-ontology.js").ComponentDef | null} findComponentForElement - Helper to find a component definition for a DOM element
|
|
100
|
+
*/
|
|
101
|
+
/**
|
|
102
|
+
* Workspace for the Pure Design System runtime API
|
|
103
|
+
* PDS is now an EventTarget so consumers can subscribe to a single, consistent
|
|
104
|
+
* event bus instead of listening on window/document or individual elements.
|
|
105
|
+
*/
|
|
106
|
+
declare class PDSBase extends EventTarget {
|
|
107
|
+
}
|
|
108
|
+
export {};
|
|
109
|
+
//# sourceMappingURL=pds.d.ts.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display a toast notification
|
|
3
|
+
*
|
|
4
|
+
* This method automatically ensures the pds-toaster component exists and is loaded
|
|
5
|
+
* before displaying the notification. The toaster element is appended to document.body
|
|
6
|
+
* if not already present.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} message - The message to display
|
|
9
|
+
* @param {Object} [options={}] - Toast configuration
|
|
10
|
+
* @param {"information"|"success"|"warning"|"error"} [options.type="information"] - Toast type/severity
|
|
11
|
+
* @param {number} [options.duration] - Duration in milliseconds (auto-calculated if not provided based on message length)
|
|
12
|
+
* @param {boolean} [options.closable=true] - Whether the toast can be manually closed
|
|
13
|
+
* @param {boolean} [options.persistent=false] - If true, toast won't auto-dismiss (requires manual close)
|
|
14
|
+
* @returns {Promise<string>} Toast ID (can be used to dismiss programmatically)
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Simple success toast
|
|
18
|
+
* await PDS.toast('Changes saved successfully!', { type: 'success' });
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Error with custom duration
|
|
22
|
+
* await PDS.toast('Failed to save changes', {
|
|
23
|
+
* type: 'error',
|
|
24
|
+
* duration: 8000
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Persistent warning (must be manually closed)
|
|
29
|
+
* await PDS.toast('This action cannot be undone', {
|
|
30
|
+
* type: 'warning',
|
|
31
|
+
* persistent: true
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Get toast ID to dismiss later
|
|
36
|
+
* const toastId = await PDS.toast('Processing...', { persistent: true });
|
|
37
|
+
* // ... later
|
|
38
|
+
* const toaster = document.querySelector('pds-toaster');
|
|
39
|
+
* toaster.dismissToast(toastId);
|
|
40
|
+
*/
|
|
41
|
+
export function toast(message: string, options?: {
|
|
42
|
+
type?: "information" | "success" | "warning" | "error";
|
|
43
|
+
duration?: number;
|
|
44
|
+
closable?: boolean;
|
|
45
|
+
persistent?: boolean;
|
|
46
|
+
}): Promise<string>;
|
|
47
|
+
export namespace toast {
|
|
48
|
+
/**
|
|
49
|
+
* Display a success toast (convenience method)
|
|
50
|
+
*
|
|
51
|
+
* @param {string} message - The success message
|
|
52
|
+
* @param {Object} [options={}] - Additional toast options (type is preset to 'success')
|
|
53
|
+
* @returns {Promise<string>} Toast ID
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* await PDS.toast.success('Profile updated!');
|
|
57
|
+
*/
|
|
58
|
+
function success(message: string, options?: any): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Display an error toast (convenience method)
|
|
61
|
+
*
|
|
62
|
+
* @param {string} message - The error message
|
|
63
|
+
* @param {Object} [options={}] - Additional toast options (type is preset to 'error')
|
|
64
|
+
* @returns {Promise<string>} Toast ID
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* await PDS.toast.error('Failed to connect to server');
|
|
68
|
+
*/
|
|
69
|
+
function error(message: string, options?: any): Promise<string>;
|
|
70
|
+
/**
|
|
71
|
+
* Display a warning toast (convenience method)
|
|
72
|
+
*
|
|
73
|
+
* @param {string} message - The warning message
|
|
74
|
+
* @param {Object} [options={}] - Additional toast options (type is preset to 'warning')
|
|
75
|
+
* @returns {Promise<string>} Toast ID
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* await PDS.toast.warning('Session will expire in 5 minutes');
|
|
79
|
+
*/
|
|
80
|
+
function warning(message: string, options?: any): Promise<string>;
|
|
81
|
+
/**
|
|
82
|
+
* Display an information toast (convenience method)
|
|
83
|
+
*
|
|
84
|
+
* @param {string} message - The information message
|
|
85
|
+
* @param {Object} [options={}] - Additional toast options (type is preset to 'information')
|
|
86
|
+
* @returns {Promise<string>} Toast ID
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* await PDS.toast.info('New features available!');
|
|
90
|
+
*/
|
|
91
|
+
function info(message: string, options?: any): Promise<string>;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=toast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast.d.ts","sourceRoot":"","sources":["../../../../../src/js/common/toast.js"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,+BAjCW,MAAM,YAEd;IAA4D,IAAI,GAAxD,aAAa,GAAC,SAAS,GAAC,SAAS,GAAC,OAAO;IACxB,QAAQ,GAAzB,MAAM;IACY,QAAQ,GAA1B,OAAO;IACW,UAAU,GAA5B,OAAO;CACf,GAAU,OAAO,CAAC,MAAM,CAAC,CA8B3B;;IAED;;;;;;;;;OASG;IACH,0BAPW,MAAM,kBAEJ,OAAO,CAAC,MAAM,CAAC,CAO3B;IAED;;;;;;;;;OASG;IACH,wBAPW,MAAM,kBAEJ,OAAO,CAAC,MAAM,CAAC,CAO3B;IAED;;;;;;;;;OASG;IACH,0BAPW,MAAM,kBAEJ,OAAO,CAAC,MAAM,CAAC,CAO3B;IAED;;;;;;;;;OASG;IACH,uBAPW,MAAM,kBAEJ,OAAO,CAAC,MAAM,CAAC,CAO3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pds.d.ts","sourceRoot":"","sources":["../../../../src/js/pds.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;eAuBc,cAAc,6BAA6B,EAAE,SAAS;;;;cACtD,OAAO,4BAA4B,EAAE,WAAW;;;;cAChD,GAAG;;;;iBACH,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,gBAAgB,CAAC,EAAE,aAAa,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC;;;;qBAChG,CAAC,UAAU,EAAE,UAAU,EAAE,gBAAgB,CAAC,EAAE,aAAa,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC;;;;sBAC7E,CAAC,GAAG,EAAC,MAAM,KAAK,aAAa;;AAW3C,+BAA+B;AAC/B,kBADW,MAAM,GAAG,OAAO,CACD;
|
|
1
|
+
{"version":3,"file":"pds.d.ts","sourceRoot":"","sources":["../../../../src/js/pds.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;eAuBc,cAAc,6BAA6B,EAAE,SAAS;;;;cACtD,OAAO,4BAA4B,EAAE,WAAW;;;;cAChD,GAAG;;;;iBACH,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,gBAAgB,CAAC,EAAE,aAAa,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC;;;;qBAChG,CAAC,UAAU,EAAE,UAAU,EAAE,gBAAgB,CAAC,EAAE,aAAa,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC;;;;sBAC7E,CAAC,GAAG,EAAC,MAAM,KAAK,aAAa;;AAW3C,+BAA+B;AAC/B,kBADW,MAAM,GAAG,OAAO,CACD;AA6R1B;;;;;;;;;GASG;AACH,8CALW,MAAM,YAEd;IAAyB,WAAW,GAA5B,MAAM;CACd,GAAU;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC;QAAC,IAAI,EAAC,MAAM,CAAC;QAAC,OAAO,EAAC,MAAM,CAAC;QAAC,KAAK,EAAC,MAAM,CAAC;QAAC,GAAG,EAAC,MAAM,CAAC;QAAC,OAAO,CAAC,EAAC,MAAM,CAAA;KAAC,CAAC,CAAA;CAAE,CAyIpH;AApdD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH;;;;GAIG;AACH;CAAoC"}
|