@esportsplus/template 0.12.12 → 0.14.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.

Potentially problematic release.


This version of @esportsplus/template might be problematic. Click here for more details.

package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ReactiveArray } from '@esportsplus/reactivity';
2
- import { RENDERABLE, RENDERABLE_REACTIVE, RENDERABLE_TEMPLATE } from './constants';
2
+ import { RENDERABLE, RENDERABLE_REACTIVE, RENDERABLE_TEMPLATE, SLOT_CLEANUP } from './constants';
3
3
  import { firstChild } from './utilities';
4
4
  import attributes from './attributes';
5
5
  import event from './event';
@@ -14,13 +14,19 @@ type Attributes = {
14
14
  } & {
15
15
  [key: `aria-${string}`]: string | number | boolean | undefined;
16
16
  [key: `data-${string}`]: string | undefined;
17
+ // Element is mounted to DOM
18
+ // - Trigger animations, etc.
19
+ onmount?: (element: Element) => void;
20
+ // Element is rendered in fragment
21
+ // - Used to retrieve reference to the element
22
+ onrender?: (element: Element) => void;
17
23
  } & Record<PropertyKey, unknown>;
18
24
 
19
25
  type Effect<T> = () => EffectResponse<T>;
20
26
 
21
27
  type EffectResponse<T> = T extends [] ? EffectResponse<T[number]>[] : Primitive | Renderable<T>;
22
28
 
23
- type Element = HTMLElement & Attributes & Record<PropertyKey, unknown>;
29
+ type Element = HTMLElement & Attributes & { [SLOT_CLEANUP]?: VoidFunction[] } & Record<PropertyKey, unknown>;
24
30
 
25
31
  type Elements = Element[];
26
32
 
@@ -51,8 +57,7 @@ type Template = {
51
57
  html: string;
52
58
  literals: TemplateStringsArray;
53
59
  slots: {
54
- fn: typeof attributes.set | typeof attributes.spread | typeof event | typeof slot;
55
- name: PropertyKey | null;
60
+ fn: typeof attributes.spread | typeof event | typeof slot;
56
61
  path: typeof firstChild[];
57
62
  slot: number;
58
63
  }[] | null;