@pure-ds/core 0.7.52 → 0.7.54

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/src/js/pds.d.ts CHANGED
@@ -283,6 +283,13 @@ export interface AskOptions {
283
283
  [key: string]: any;
284
284
  }
285
285
 
286
+ export type PDSParseTemplateLike = TemplateStringsArray | {
287
+ strings: string[];
288
+ values: unknown[];
289
+ };
290
+
291
+ export type PDSParseInput = string | PDSParseTemplateLike;
292
+
286
293
  export class PDS extends EventTarget {
287
294
  // Static surface
288
295
  static registry: PDSRegistry;
@@ -332,7 +339,8 @@ export class PDS extends EventTarget {
332
339
  static ontology?: any;
333
340
  static enums?: Record<string, any>;
334
341
  static common?: Record<string, any>;
335
- static parse?: (html: string) => Element[];
342
+ static parse?: (html: PDSParseInput, ...values: unknown[]) => NodeListOf<ChildNode>;
343
+ static html?: (html: PDSParseInput, ...values: unknown[]) => DocumentFragment;
336
344
  static msg: (template: string | PDSStrResult, options?: Record<string, any>) => string;
337
345
  static str: (strings: TemplateStringsArray, ...values: any[]) => PDSStrResult;
338
346
  static configureLocalization: (config?: PDSLocalizationConfig | null) => {
@@ -395,7 +403,8 @@ export class PDS extends EventTarget {
395
403
  * @param options.duration - Duration in milliseconds (auto-calculated if not provided)
396
404
  * @param options.closable - Whether toast can be manually closed (default: true)
397
405
  * @param options.persistent - If true, toast won't auto-dismiss (default: false)
398
- * @returns Toast ID (can be used to dismiss programmatically)
406
+ * @param options.returnToastElement - If true, returns the live toast element instead of the toast ID
407
+ * @returns Toast ID (default), or live toast element when returnToastElement is true
399
408
  *
400
409
  * @example
401
410
  * await PDS.toast('Changes saved!', { type: 'success' });
@@ -411,6 +420,7 @@ export class PDS extends EventTarget {
411
420
  duration?: number;
412
421
  closable?: boolean;
413
422
  persistent?: boolean;
423
+ returnToastElement?: false;
414
424
  }
415
425
  ): Promise<string>;
416
426
 
@@ -425,11 +435,12 @@ export class PDS extends EventTarget {
425
435
  * await PDS.toast.success('Profile updated!');
426
436
  */
427
437
  static toast: {
428
- (message: string, options?: { type?: 'information' | 'success' | 'warning' | 'error'; title?: string; duration?: number; closable?: boolean; persistent?: boolean }): Promise<string>;
429
- success(message: string, options?: { title?: string; duration?: number; closable?: boolean; persistent?: boolean }): Promise<string>;
430
- error(message: string, options?: { title?: string; duration?: number; closable?: boolean; persistent?: boolean }): Promise<string>;
431
- warning(message: string, options?: { title?: string; duration?: number; closable?: boolean; persistent?: boolean }): Promise<string>;
432
- info(message: string, options?: { title?: string; duration?: number; closable?: boolean; persistent?: boolean }): Promise<string>;
438
+ (message: string, options: { type?: 'information' | 'success' | 'warning' | 'error'; title?: string; duration?: number; closable?: boolean; persistent?: boolean; returnToastElement: true }): Promise<HTMLElement | null>;
439
+ (message: string, options?: { type?: 'information' | 'success' | 'warning' | 'error'; title?: string; duration?: number; closable?: boolean; persistent?: boolean; returnToastElement?: false }): Promise<string>;
440
+ success(message: string, options?: { title?: string; duration?: number; closable?: boolean; persistent?: boolean; returnToastElement?: boolean }): Promise<string | HTMLElement | null>;
441
+ error(message: string, options?: { title?: string; duration?: number; closable?: boolean; persistent?: boolean; returnToastElement?: boolean }): Promise<string | HTMLElement | null>;
442
+ warning(message: string, options?: { title?: string; duration?: number; closable?: boolean; persistent?: boolean; returnToastElement?: boolean }): Promise<string | HTMLElement | null>;
443
+ info(message: string, options?: { title?: string; duration?: number; closable?: boolean; persistent?: boolean; returnToastElement?: boolean }): Promise<string | HTMLElement | null>;
433
444
  };
434
445
 
435
446
  /**
@@ -740,3 +751,6 @@ export class SchemaForm extends HTMLElement {
740
751
  options?: boolean | EventListenerOptions
741
752
  ): void;
742
753
  }
754
+
755
+ export function parse(html: PDSParseInput, ...values: unknown[]): NodeListOf<ChildNode>;
756
+ export function html(html: PDSParseInput, ...values: unknown[]): DocumentFragment;
package/src/js/pds.js CHANGED
@@ -638,8 +638,13 @@ PDS.adoptLayers = adoptLayers;
638
638
  /** Convenience to adopt only primitives into a ShadowRoot */
639
639
  PDS.adoptPrimitives = adoptPrimitives;
640
640
 
641
- /** Parse an HTML string into a NodeList */
642
- PDS.parse = common.parseHTML;
641
+ /** Parse HTML strings or tagged templates into a NodeList */
642
+ export const parse = common.parseHTML;
643
+ PDS.parse = parse;
644
+
645
+ /** Parse HTML or tagged templates into a DocumentFragment */
646
+ export const html = common.parseFragment;
647
+ PDS.html = html;
643
648
 
644
649
  /** Create a constructable CSSStyleSheet from a CSS string */
645
650
  PDS.createStylesheet = createStylesheet;