@esportsplus/template 0.20.1 → 0.20.3
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/build/html/index.d.ts +1 -1
- package/build/types.d.ts +9 -10
- package/package.json +1 -1
- package/src/html/index.ts +1 -1
- package/src/types.ts +9 -10
package/build/html/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactiveArray } from '@esportsplus/reactivity';
|
|
2
2
|
import { Attributes, Renderable, RenderableReactive } from '../types.js';
|
|
3
|
-
type Values<T> = Attributes
|
|
3
|
+
type Values<T> = Attributes<any> | Renderable<T>;
|
|
4
4
|
declare const html: {
|
|
5
5
|
<T>(literals: TemplateStringsArray, ...values: (Values<T> | Values<T>[])[]): Node;
|
|
6
6
|
reactive<T>(array: ReactiveArray<T>, template: RenderableReactive<T>["template"]): RenderableReactive<T>;
|
package/build/types.d.ts
CHANGED
|
@@ -5,21 +5,20 @@ import attributes from './attributes.js';
|
|
|
5
5
|
import slot from './slot/index.js';
|
|
6
6
|
import html from './html/index.js';
|
|
7
7
|
type Attribute = Effect<Primitive | Primitive[]> | Primitive;
|
|
8
|
-
type Attributes = {
|
|
8
|
+
type Attributes<T extends HTMLElement = Element> = {
|
|
9
|
+
[key: `aria-${string}`]: string | number | boolean | undefined;
|
|
10
|
+
[key: `data-${string}`]: string | undefined;
|
|
9
11
|
class?: Attribute | Attribute[];
|
|
12
|
+
onconnect?: (element: T) => void;
|
|
13
|
+
ondisconnect?: (element: T) => void;
|
|
14
|
+
onrender?: (element: T) => void;
|
|
15
|
+
ontick?: (element: T) => void;
|
|
10
16
|
style?: Attribute | Attribute[];
|
|
11
17
|
} & {
|
|
12
|
-
[K in keyof GlobalEventHandlersEventMap as `on${string & K}`]?: (this:
|
|
13
|
-
} & {
|
|
14
|
-
[key: `aria-${string}`]: string | number | boolean | undefined;
|
|
15
|
-
[key: `data-${string}`]: string | undefined;
|
|
16
|
-
onconnect?: <T = Element>(element: T) => void;
|
|
17
|
-
ondisconnect?: <T = Element>(element: T) => void;
|
|
18
|
-
onrender?: <T = Element>(element: T) => void;
|
|
19
|
-
ontick?: <T = Element>(element: T) => void;
|
|
18
|
+
[K in keyof GlobalEventHandlersEventMap as `on${string & K}`]?: (this: HTMLElement, event: GlobalEventHandlersEventMap[K]) => void;
|
|
20
19
|
} & Record<PropertyKey, unknown>;
|
|
21
20
|
type Effect<T> = () => T extends [] ? Renderable<T>[] : Renderable<T>;
|
|
22
|
-
type Element = HTMLElement & Attributes
|
|
21
|
+
type Element = HTMLElement & Attributes<any>;
|
|
23
22
|
type Primitive = bigint | boolean | null | number | string | undefined;
|
|
24
23
|
type Renderable<T> = DocumentFragment | Effect<T> | Node | NodeList | Primitive | RenderableReactive<T> | Renderable<T>[];
|
|
25
24
|
type RenderableReactive<T> = Readonly<{
|
package/package.json
CHANGED
package/src/html/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { cloneNode } from '~/utilities/node';
|
|
|
5
5
|
import parser from './parser';
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
type Values<T> = Attributes
|
|
8
|
+
type Values<T> = Attributes<any> | Renderable<T>;
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
const html = <T>(literals: TemplateStringsArray, ...values: (Values<T> | Values<T>[])[]) => {
|
package/src/types.ts
CHANGED
|
@@ -8,23 +8,22 @@ import html from './html';
|
|
|
8
8
|
|
|
9
9
|
type Attribute = Effect<Primitive | Primitive[]> | Primitive;
|
|
10
10
|
|
|
11
|
-
type Attributes = {
|
|
11
|
+
type Attributes<T extends HTMLElement = Element> = {
|
|
12
|
+
[key: `aria-${string}`]: string | number | boolean | undefined;
|
|
13
|
+
[key: `data-${string}`]: string | undefined;
|
|
12
14
|
class?: Attribute | Attribute[];
|
|
15
|
+
onconnect?: (element: T) => void;
|
|
16
|
+
ondisconnect?: (element: T) => void;
|
|
17
|
+
onrender?: (element: T) => void;
|
|
18
|
+
ontick?: (element: T) => void;
|
|
13
19
|
style?: Attribute | Attribute[];
|
|
14
20
|
} & {
|
|
15
|
-
[K in keyof GlobalEventHandlersEventMap as `on${string & K}`]?: (this:
|
|
16
|
-
} & {
|
|
17
|
-
[key: `aria-${string}`]: string | number | boolean | undefined;
|
|
18
|
-
[key: `data-${string}`]: string | undefined;
|
|
19
|
-
onconnect?: <T = Element>(element: T) => void;
|
|
20
|
-
ondisconnect?: <T = Element>(element: T) => void;
|
|
21
|
-
onrender?: <T = Element>(element: T) => void;
|
|
22
|
-
ontick?: <T = Element>(element: T) => void;
|
|
21
|
+
[K in keyof GlobalEventHandlersEventMap as `on${string & K}`]?: (this: HTMLElement, event: GlobalEventHandlersEventMap[K]) => void;
|
|
23
22
|
} & Record<PropertyKey, unknown>;
|
|
24
23
|
|
|
25
24
|
type Effect<T> = () => T extends [] ? Renderable<T>[] : Renderable<T>;
|
|
26
25
|
|
|
27
|
-
type Element = HTMLElement & Attributes
|
|
26
|
+
type Element = HTMLElement & Attributes<any>;
|
|
28
27
|
|
|
29
28
|
// Copied from '@esportsplus/utilities'
|
|
30
29
|
// - Importing from ^ causes 'cannot be named without a reference to...' error
|