@rusticarcade/palette 0.4.0 → 0.7.0

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.
@@ -13,29 +13,15 @@ type StateListener<Shape> = (state: Shape) => void;
13
13
  *
14
14
  * The State class wraps stateful data and provides an API for mutating the data
15
15
  * while listeners subscribe to meaningful updates.
16
- *
17
- * Modify state with setters, mutators, transactions, or proxied updates with
18
- * deep reactivity and array mutation support built in.
19
- *
20
- * @example
21
- *
22
- * ```typescript
23
- * const state = new State({count: 1});
24
- * state.addListener(data => console.log(data))
25
- *
26
- * state.set("count", 2); // Prints "2"
27
- * state.set("count", 2); // Nothing happens, no change
28
- * state.live.count = 3; // Prints "3"
29
- * ```
30
16
  */
31
17
  declare class State<Shape extends object> {
18
+ static isState<T extends object>(value: unknown): value is State<T>;
32
19
  private _data;
33
20
  private _listeners;
34
21
  private _proxy?;
35
22
  private _proxyCache;
36
23
  private _reverseProxyCache;
37
- private _isLocked;
38
- constructor(initialData: Shape, onChange?: StateListener<Shape>);
24
+ constructor(initialData: Shape, listener?: StateListener<Shape>);
39
25
  /**
40
26
  * Lazily create and cache proxies into the state for reactive updates on
41
27
  * nested values.
@@ -65,7 +51,7 @@ declare class State<Shape extends object> {
65
51
  * This is a direct reference to the internal state. It is marked as Readonly
66
52
  * to help prevent accidental changes. Never edit this value directly.
67
53
  */
68
- get current(): Readonly<Shape>;
54
+ get raw(): Readonly<Shape>;
69
55
  /**
70
56
  * Live reactive accessor for state data. Deeply nested changes trigger
71
57
  * automatic updates, including array, Map, and Set mutations.
@@ -76,10 +62,6 @@ declare class State<Shape extends object> {
76
62
  */
77
63
  get live(): Shape;
78
64
  /**
79
- * Indicates if this state is currently locked (true) or not (false)
80
- */
81
- get isLocked(): boolean;
82
- /**
83
65
  * Add a handler function for when this state changes.
84
66
  *
85
67
  * Listeners are invoked in the order they are registered and are passed a
@@ -98,14 +80,6 @@ declare class State<Shape extends object> {
98
80
  *
99
81
  * The value is returned as Readonly to prevent accidental state mutations.
100
82
  * To mutate stateful properties, use {@link set} or {@link patch} instead.
101
- *
102
- * @example
103
- *
104
- * ```typescript
105
- * const state = new State({ count: 1 });
106
- * console.log(state.get("count")); // 1
107
- * ```
108
- *
109
83
  */
110
84
  get: <K extends keyof Shape>(key: K) => Readonly<Shape[K]>;
111
85
  /**
@@ -114,13 +88,6 @@ declare class State<Shape extends object> {
114
88
  *
115
89
  * The object returned from this function can be edited without modifying the
116
90
  * actual internal state.
117
- *
118
- * @example
119
- *
120
- * ```typescript
121
- * const snap = state.snapshot();
122
- * snap.count += 1;
123
- * state.patch(snap);
124
91
  * ```
125
92
  */
126
93
  snapshot: () => Shape;
@@ -137,44 +104,17 @@ declare class State<Shape extends object> {
137
104
  * state.set("count", 2); // State is now { count: 2, color: "red" }
138
105
  * ```
139
106
  */
140
- set: <K extends keyof Shape>(key: K, value: Shape[K]) => void;
107
+ set: <K extends keyof Shape>(key: K, value: Shape[K]) => State<Shape>;
141
108
  /**
142
109
  * Set multiple stateful properties at once, leaving omitted properties
143
110
  * unchanged.
144
- *
145
- * @example
146
- *
147
- * Patch a partial state, updating all listed properties at once
148
- *
149
- * ```typescript
150
- * const state = new State({
151
- * weather: "sunny",
152
- * temperature: 30,
153
- * humidity: 70,
154
- * });
155
- *
156
- * // Leaves `temperature` unchanged
157
- * state.patch({
158
- * weather: "cloudy",
159
- * humidity: 50,
160
- * });
161
- * ```
162
111
  */
163
112
  patch: (patch: Partial<Shape>) => State<Shape>;
164
113
  /**
165
- * Fully replace the current state data and force listeners to receive the
166
- * updated data immediately.
114
+ * Fully replace the current state data and force an update
167
115
  */
168
116
  replace: (state: Shape) => State<Shape>;
169
117
  /**
170
- * Lock this State instance, preventing further external changes
171
- */
172
- lock: () => State<Shape>;
173
- /**
174
- * Unlock this State instance, allowing further external changes
175
- */
176
- unlock: () => State<Shape>;
177
- /**
178
118
  * Apply complex updates to the state using a mutator function.
179
119
  *
180
120
  * The mutator function takes one parameter which is a structuredClone copy of
@@ -182,87 +122,6 @@ declare class State<Shape extends object> {
182
122
  * patched in to the state.
183
123
  */
184
124
  mutate: (mutator: (current: Shape) => Shape) => State<Shape>;
185
- /**
186
- * Perform an async mutation of the state, optionally locking the state during
187
- * the process.
188
- * @param mutator A function to mutate and return the new state
189
- * @param lock If `true`, lock the state until the mutator completes
190
- */
191
- mutateAsync: (mutator: (current: Shape) => Promise<Shape>, lock?: boolean) => Promise<State<Shape>>;
192
- /**
193
- * Perform a transaction-style set of actions defined within a function.
194
- *
195
- * The provided function can do anything, beyond just setting state. Any
196
- * uncaught errors thrown from within the function will cause the transaction
197
- * to fail and the state to automatically roll back to the last valid state.
198
- *
199
- * During a transaction, this state instance will be locked, preventing other
200
- * changes.
201
- *
202
- * Transactions will always result in a state update when successful.
203
- *
204
- * @example
205
- *
206
- * Transactions with locking and rollback support
207
- *
208
- * ```typescript
209
- * const state = new State({count: 1});
210
- *
211
- * state.transaction(async (s) => {
212
- * // `s` is a full State object you can safely manipulate
213
- * s.set("count", 10);
214
- * });
215
- * state.get("count"); // => 10;
216
- *
217
- * // Errors inside the transaction roll back the state
218
- * state.transaction(async (s) => {
219
- * s.set("count", 100);
220
- * throw new Error();
221
- * });
222
- * state.get("count"); // => 10;
223
- */
224
- transaction: (fn: (state: State<Shape>) => void) => boolean;
225
- /**
226
- * Perform a transaction-style set of actions defined within an async function
227
- *
228
- * The provided function can do anything, beyond just setting state. Any
229
- * uncaught errors thrown from within the function will cause the transaction
230
- * to fail and the state to automatically roll back to the last valid state.
231
- *
232
- * During a transaction, this state instance will be locked, preventing other
233
- * changes.
234
- *
235
- * Transactions will always result in a state update when successful.
236
- *
237
- * @example
238
- *
239
- * Transactions with locking and rollback support
240
- *
241
- * ```typescript
242
- * const state = new State({count: 1});
243
- *
244
- * // Awaiting the result of a transaction
245
- * await state.transactionAsync(async (s) => {
246
- * // `s` is a full State object you can safely manipulate
247
- * s.set("count", 10);
248
- * });
249
- * state.get("count"); // => 10;
250
- *
251
- * // Errors inside the transaction roll back the state
252
- * await state.transactionAsync(async (s) => {
253
- * s.set("count", 100);
254
- * throw new Error();
255
- * });
256
- * state.get("count"); // => 10;
257
- *
258
- * // If you forget to await the transaction, its still locked
259
- * state.transactionAsync(async (s) => {
260
- * await waitSeconds(1);
261
- * });
262
- * state.set("count", 1); // Error: State is locked!
263
- * ```
264
- */
265
- transactionAsync: (fn: (state: State<Shape>) => Promise<void>) => Promise<boolean>;
266
125
  }
267
126
  type ParsedNotation = {
268
127
  /** The raw string representation of the parsed notation */
@@ -283,6 +142,13 @@ declare const enum Directive {
283
142
  ElseIf = "::else-if",
284
143
  Else = "::else"
285
144
  }
145
+ declare const enum UpdateType {
146
+ Conditional = "cond",
147
+ Tag = "tag",
148
+ Attribute = "attr",
149
+ List = "list",
150
+ Swap = "swap"
151
+ }
286
152
  type ConditionalRenderSchemeBranch = {
287
153
  type: Directive.If | Directive.ElseIf;
288
154
  notation: ParsedNotation;
@@ -294,27 +160,27 @@ type ConditionalRenderSchemeBranch = {
294
160
  branchTemplateHTML: string;
295
161
  };
296
162
  interface ConditionalRenderScheme {
297
- type: "cond";
163
+ type: UpdateType.Conditional;
298
164
  branches: ConditionalRenderSchemeBranch[];
299
165
  }
300
166
  interface AttributeUpdateScheme {
301
- type: "attr";
167
+ type: UpdateType.Attribute;
302
168
  notation: ParsedNotation;
303
169
  attribute: string;
304
170
  nodeRef: string;
305
171
  }
306
172
  interface TagChangeScheme {
307
- type: "tag";
173
+ type: UpdateType.Tag;
308
174
  notation: ParsedNotation;
309
175
  nodeRef: string;
310
176
  }
311
177
  interface ContentSwapScheme {
312
- type: "swap";
178
+ type: UpdateType.Swap;
313
179
  notation: ParsedNotation;
314
180
  nodeRef: string;
315
181
  }
316
182
  interface ListRenderScheme {
317
- type: "each";
183
+ type: UpdateType.List;
318
184
  notation: ParsedNotation;
319
185
  keyNotation: ParsedNotation;
320
186
  nodeRef: string;
@@ -344,20 +210,33 @@ type TemplateContext = {
344
210
  * Leverages a simple syntax to provide accessors to template data from one of
345
211
  * four categories, based on use case:
346
212
  *
347
- * ```
348
- * `@` -> The `attr` namespace (the host element's attributes)
349
- * `$` -> The `state` namespace (the host element's reactive state)
350
- * `*` -> The `data` namespace (the host element's computed data)
351
- * `#` -> The `item` namespace (list item access with ::each)
352
- * ```
213
+ * | Prefix | Namespace |
214
+ * | ------ | ------------------------------------------------ |
215
+ * | `@` | The `attr` namespace (host element attributes) |
216
+ * | `$` | The `state` namespace (component reactive state) |
217
+ * | `*` | The `data` namespace (component computed props) |
218
+ * | `#` | The `item` namespace (list item context) |
353
219
  *
354
220
  * Bind attributes to a value using the `:attribute` syntax:
355
221
  *
356
222
  * ```html
357
223
  * <div :id="$id" :class="@classname"></div>
358
224
  * ```
225
+ *
226
+ * Or use directives with notations for advanced templating:
227
+ *
228
+ * ```html
229
+ * <div ::if="*showList">
230
+ * <ul>
231
+ * <li ::each="$items" ::key="#id">
232
+ * <span ::swap="#content"></span>
233
+ * </li>
234
+ * </ul>
235
+ * </div>
236
+ * ```
359
237
  */
360
238
  declare class Template {
239
+ static isTemplate(value: unknown): value is Template;
361
240
  /**
362
241
  * Properties related to the global Template build cache.
363
242
  *
@@ -426,16 +305,6 @@ declare class Template {
426
305
  }
427
306
  type EventName = keyof GlobalEventHandlersEventMap;
428
307
  type EventHandler<K extends EventName = EventName> = (event: GlobalEventHandlersEventMap[K]) => void;
429
- interface LiveAttributes<State extends object = {}> {
430
- [name: string]: {
431
- onChange?: (this: Component<State>, current: string | null, previous: string | null) => void;
432
- reflect?: (this: Component<State>) => unknown;
433
- };
434
- }
435
- type ComputedProperties<StateShape extends object = {}> = Record<string, unknown> | ((this: Component<StateShape>) => Record<string, unknown>);
436
- type ComponentStyles = CSSStyleSheet | CSSStyleSheet[] | string;
437
- type AttributeMap = Map<string, string | null>;
438
- type StateInitializer<Shape extends object = {}> = Shape | State<Shape> | ((this: Component<Shape>) => Shape | State<Shape>);
439
308
  declare enum RootMode {
440
309
  Closed = "closed",
441
310
  Open = "open"
@@ -446,133 +315,57 @@ declare enum RootMode {
446
315
  * managed attributes, and dynamic templating.
447
316
  */
448
317
  declare abstract class Component<StateShape extends object = {}> extends HTMLElement {
449
- /** The HTML tag name to use for this Component */
450
- static tagName: string;
451
- /** An HTML Template element for this element to use. */
452
- static template: HTMLTemplateElement | Template;
453
318
  /**
454
- * Styles for this Component
319
+ * Check if a value is a Component instance
455
320
  */
456
- static styles: ComponentStyles;
321
+ static isComponent(value: unknown): value is Component;
457
322
  /**
458
- * A list of attribute names to track changes for
459
- *
460
- * @remarks
461
- * If you use the {@link define} factory helper, this value will be
462
- * automatically merged with a list of any defined {@link liveAttributes}.
323
+ * Check if a value is a Component class
463
324
  */
325
+ static isComponentClass(value: unknown): value is typeof Component;
326
+ static readComponentTagName(componentClass: typeof Component): string;
327
+ /** The HTML tag name to use for this Component */
328
+ static tagName: string;
329
+ /** An HTML Template element for this element to use. */
330
+ static template: HTMLTemplateElement | Template;
331
+ /** Styles to encapsulate to this component's root. */
332
+ static style: CSSStyleSheet | CSSStyleSheet[] | string;
333
+ /** Attributes to watch for changes for updates. */
464
334
  static observedAttributes: string[];
465
335
  /**
466
- * The mode for this Component's ShadowRoot. Must be a {@link RootMode}
336
+ * The mode for this Component's ShadowRoot.
337
+ *
338
+ * MDN: https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/mode
467
339
  */
468
340
  static rootMode: RootMode;
469
- /**
470
- * Initialization lifecycle method. Main scripting and event listeners.
471
- * @returns a function to handle cleanup tasks when the component unmounts
472
- */
473
- protected script?(): VoidFunction | void;
474
341
  /** Called immediately before each template update */
475
- protected beforeUpdate?(): void;
342
+ beforeUpdate?(changedAttributes: Record<string, string | null>): void;
476
343
  /** Called immediately after each template update */
477
- protected afterUpdate?(previousAttributes: AttributeMap): void;
344
+ afterUpdate?(previousAttributes: Record<string, string | null>): void;
478
345
  /** Final lifecycle method called at the end of the unmounting process. */
479
- protected finalize?(): void;
346
+ finalize?(): void;
480
347
  /**
481
- * When defined, catches any errors thrown during lifecycle mthods of this
482
- * component as well as any uncaught errors from child components.
483
- *
484
- * @example
485
- *
486
- * Recovering from errors or displaying a fallback
487
- *
488
- * ```typescript
489
- * onError(error) {
490
- * if (error.canRecover) {
491
- * this.recover();
492
- * return;
493
- * }
494
- *
495
- * this.replaceWith("Oh dear, an error happened real bad");
496
- * }
497
- * ```
348
+ * Handle errors thrown during lifecycle methods of this component or any
349
+ * unhandled errors from child components.
498
350
  */
499
- protected onError?(error: unknown): void;
500
- /**
501
- * The initial value for this Component's reactive internal state, if any.
502
- *
503
- * @remarks
504
- * If `initialState` is defined as a function, the function is evaluated at
505
- * mounting time and the return value is used as the initial state.
506
- */
507
- protected initialState?: StateInitializer<StateShape>;
351
+ onError?(error: unknown): void;
352
+ /** The initial state for this Component */
353
+ initialState?(): State<StateShape> | StateShape;
508
354
  /**
509
355
  * An object or function returning an object which populates the `data` values
510
356
  * in the templating engine. Such values are accessed using the `*` notation.
511
- *
512
- * @example
513
- *
514
- * ```typescript
515
- * host = {
516
- * avatarUrl: "http://...",
517
- * renderTime: () => new Date().toISOString(),
518
- * }
519
- * ```
520
- *
521
- * ```html
522
- * <img :src="*avatarUrl" />
523
- * <span>Rendered at ${"*renderTime"}</span>
524
- * ```
525
357
  */
526
- protected computedProperties?: ComputedProperties<StateShape>;
527
- /**
528
- * Define attribute update and reflection behaviors as a record of attribute
529
- * name keys to objects with optionally defined behaviors.
530
- *
531
- * @example
532
- *
533
- * ```typescript
534
- * liveAttributes = {
535
- * done: {
536
- * onChange(newValue) {
537
- * this.state.set("done", !!newValue);
538
- * },
539
- * reflect() { return this.state.current.done }
540
- * }
541
- * };
542
- * ```
543
- *
544
- * @remarks
545
- * The optional functions are:
546
- *
547
- * `onChange(newValue, oldValue): void`, a handler function for when the value
548
- * of this attribute has changed. Runs once per update cycle, *before* the
549
- * update occurs.
550
- *
551
- * `reflect(): unknown`, a function which returns a value to serialize and set
552
- * as this attribute *after* an update completes.
553
- *
554
- * If using the {@link define} helper, the keys of this property are
555
- * automatically merged with any defined {@link observedAttributes}.
556
- */
557
- protected liveAttributes?: LiveAttributes<StateShape>;
558
- private _template;
559
- private _root;
560
- private _state?;
561
- private _delegator?;
562
- private _ownListeners?;
563
- private _cleanupFn?;
564
- private _renderInternals;
358
+ computedProperties?(this: Component<StateShape>, attributes: Record<string, string | null>, state: StateShape): Record<string, unknown>;
359
+ readonly root: ShadowRoot;
360
+ readonly template: Template;
361
+ private _cmp;
565
362
  constructor();
566
363
  /** Produce the data object to pass to the template's render function */
567
364
  private _getRenderContext;
568
365
  private _escalateError;
569
366
  private _reportError;
570
- private _executeAttributeChangeHandlers;
571
- private _reflectLiveAttributes;
572
367
  /** The actual update behavior */
573
- private _performUpdate;
574
- /** Safely request for an update to run on the next frame */
575
- private _scheduleUpdate;
368
+ private _render;
576
369
  private _adoptState;
577
370
  /**
578
371
  * @deprecated Use {@link script} instead
@@ -583,14 +376,18 @@ declare abstract class Component<StateShape extends object = {}> extends HTMLEle
583
376
  */
584
377
  protected disconnectedCallback(): void;
585
378
  /**
586
- * @deprecated Use {@link liveAttributes} instead
379
+ * @deprecated Use {@link beforeUpdate} and {@link afterUpdate} instead
587
380
  */
588
381
  protected attributeChangedCallback(name: string, _: string | null, newValue: string | null): void;
382
+ get isMounted(): boolean;
589
383
  /**
590
- * The ShadowRoot node of this element
384
+ * Access the full {@link State} instance for this Component.
385
+ *
386
+ * @remarks
387
+ * Calling this method on a component which is not using reactive state
388
+ * will result in an error being thrown.
591
389
  */
592
- get root(): ShadowRoot;
593
- get isMounted(): boolean;
390
+ getState(): State<StateShape>;
594
391
  /**
595
392
  * Accessor for live reactive state.
596
393
  *
@@ -603,71 +400,85 @@ declare abstract class Component<StateShape extends object = {}> extends HTMLEle
603
400
  */
604
401
  set state(newState: StateShape | State<StateShape>);
605
402
  /**
606
- * Access the full {@link State} instance for this Component.
607
- *
608
- * @remarks
609
- * Calling this method on a component which is not using reactive state
610
- * will result in an error being thrown.
611
- */
612
- getState(): State<StateShape>;
613
- /**
614
403
  * Manually schedule a render to occur, optionally providing a callback to
615
404
  * invoke after the render completes.
616
405
  *
617
406
  * @remarks
618
- * Calling {@link requestRender} multiple times in the same event loop won't
407
+ * Calling {@link render} multiple times in the same event loop won't
619
408
  * schedule multiple renders. Renders are scheduled to occur on the next
620
409
  * animation frame.
621
410
  */
622
- requestRender(callback?: VoidFunction): void;
411
+ render: () => void;
623
412
  /**
624
- * Listen for events from within this Component.
413
+ * Listen for events on a child element based on the provided query
625
414
  *
626
- * Provide a query string to target specific element events, or use `:host`
627
- * to create listeners on the host element itself.
415
+ * @returns A function which removes the listener when called
628
416
  *
417
+ * @remarks
629
418
  * Event listeners created with this method are automatically cleaned up when
630
- * the component unmounts.
419
+ * the component unmounts. You can manually remove the listener during the
420
+ * component's lifecycle by calling the returned function if need be.
631
421
  */
632
- listen<E extends EventName>(targetDescriptor: string | typeof Component<any> | HTMLElement, eventName: E, eventHandler: EventHandler<E>): void;
633
- stopListening<E extends EventName>(targetDescriptor: string | typeof Component<any> | HTMLElement, eventName: E, eventHandler: EventHandler<E>): void;
634
- dispatchEvent(event: Event): boolean;
422
+ listen<E extends EventName>(target: string, eventName: E, eventHandler: EventHandler<E>): VoidFunction;
635
423
  /**
636
- * Dispatch a {@link CustomEvent} with the specified name and detail
424
+ * Listen for events on a child element based on the provided component's tag
425
+ *
426
+ * @returns A function which removes the listener when called
427
+ *
428
+ * @remarks
429
+ * Event listeners created with this method are automatically cleaned up when
430
+ * the component unmounts. You can manually remove the listener during the
431
+ * component's lifecycle by calling the returned function if need be.
637
432
  */
638
- dispatchEvent<T>(event: string, detail?: T, options?: {
639
- bubbles: boolean;
640
- cancelable: boolean;
641
- composed: boolean;
642
- }): boolean;
643
- querySelector<E extends HTMLElement>(query: string): E | null;
644
- querySelectorAll<E extends HTMLElement>(query: string): NodeListOf<E>;
645
- getElementById<E extends HTMLElement>(id: string): E | null;
646
- requireElementById<E extends HTMLElement>(id: string): E;
647
- setAttribute(name: string, value: string): void;
433
+ listen<E extends EventName>(target: typeof Component<any>, eventName: E, eventHandler: EventHandler<E>): VoidFunction;
648
434
  /**
649
- * Set a value as an attribute, serializing to a string or `null`.
435
+ * Listen for events on the host element
436
+ *
437
+ * @returns A function which removes the listener when called
650
438
  *
651
- * null values cause the attribute to be removed from this element
439
+ * @remarks
440
+ * Event listeners created with this method are automatically cleaned up when
441
+ * the component unmounts. You can manually remove the listener during the
442
+ * component's lifecycle by calling the returned function if need be.
652
443
  */
653
- setAttribute(name: string, value: unknown): void;
654
- getAttribute(name: string): string | null;
444
+ listen<E extends EventName>(target: typeof this, eventName: E, eventHandler: EventHandler<E>): VoidFunction;
655
445
  /**
656
- * Get an attribute as a number, falling back to a specified default.
446
+ * Listen for events on the host element
657
447
  *
658
- * `null` attributes are returned as `null`, while string attributes are
659
- * parsed using the `Number()` constructor. NaN is coerced to `null`.
448
+ * @returns A function which removes the listener when called
449
+ *
450
+ * @remarks
451
+ * Event listeners created with this method are automatically cleaned up when
452
+ * the component unmounts. You can manually remove the listener during the
453
+ * component's lifecycle by calling the returned function if need be.
660
454
  */
661
- getAttribute(name: string, defaultValue: number): number;
455
+ listen<E extends EventName>(target: ":host", eventName: E, eventHandler: EventHandler<E>): VoidFunction;
662
456
  /**
663
- * Get an attribute as a string, falling back to a specified default
457
+ * Publish a {@link CustomEvent} with the provided name and options.
458
+ *
459
+ * Default options are:
460
+ *
461
+ * ```typescript
462
+ * {
463
+ * bubbles: true,
464
+ * cancelable: true,
465
+ * composed: true,
466
+ * detail: undefined,
467
+ * }
468
+ * ```
469
+ *
470
+ * @param name The name of the custom event to publish
471
+ * @param options Options to configure the custom event
664
472
  */
665
- getAttribute(name: string, defaultValue: string): string;
473
+ dispatchEvent<T>(name: string, options: CustomEventInit<T>): boolean;
474
+ dispatchEvent(event: Event): boolean;
666
475
  /**
667
- * Set the value of an attribute on this element if the provided value
668
- * differs from the attribute when serialized
476
+ * Returns a reference to the HTML Element with the provided ID within the
477
+ * shadow root of this component.
478
+ *
479
+ * Throws an error if no element with the provided ID is found
669
480
  */
670
- reflectAttribute(name: string, value: unknown): void;
481
+ ref<E extends HTMLElement>(id: string): E;
671
482
  /**
672
483
  * Serialize this element to a string
673
484
  */
@@ -699,7 +510,7 @@ declare abstract class Component<StateShape extends object = {}> extends HTMLEle
699
510
  * @param attributes A record of attributes to apply
700
511
  * @returns A reference to the rendered Component
701
512
  */
702
- declare function renderTestComponent<E extends typeof Component<any>>(component: E, attributes?: Record<string, unknown>): Promise<InstanceType<E>>;
513
+ declare function renderTestComponent<E extends typeof Component<any>>(component: E, attributes?: Record<string, string | null>): Promise<InstanceType<E>>;
703
514
  /**
704
515
  * Force a render on the target element
705
516
  *