@esportsplus/template 0.19.3 → 0.19.5
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 +2 -2
- package/build/types.d.ts +5 -5
- package/package.json +2 -2
- package/src/html/index.ts +2 -2
- package/src/types.ts +6 -5
package/build/html/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ReactiveArray } from '@esportsplus/reactivity';
|
|
2
2
|
import { Attributes, Renderable, RenderableReactive } from '../types.js';
|
|
3
|
-
type Values<T
|
|
3
|
+
type Values<T> = Attributes | Attributes[] | Readonly<Attributes> | Readonly<Attributes[]> | Renderable<T>;
|
|
4
4
|
declare const html: {
|
|
5
|
-
(literals: TemplateStringsArray, ...values: (Values | Values[])[]): Node;
|
|
5
|
+
<T>(literals: TemplateStringsArray, ...values: (Values<T> | Values<T>[])[]): Node;
|
|
6
6
|
reactive<T>(array: ReactiveArray<T>, template: RenderableReactive<T>["template"]): RenderableReactive<T>;
|
|
7
7
|
};
|
|
8
8
|
export default html;
|
package/build/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { firstChild } from './utilities/node.js';
|
|
|
4
4
|
import attributes from './attributes.js';
|
|
5
5
|
import slot from './slot/index.js';
|
|
6
6
|
import html from './html/index.js';
|
|
7
|
-
type Attribute = Primitive |
|
|
7
|
+
type Attribute = Effect<Primitive | Primitive[]> | Primitive;
|
|
8
8
|
type Attributes = {
|
|
9
9
|
class?: Attribute | Attribute[];
|
|
10
10
|
style?: Attribute | Attribute[];
|
|
@@ -17,14 +17,14 @@ type Attributes = {
|
|
|
17
17
|
ondisconnect?: (element: Element) => void;
|
|
18
18
|
onrender?: (element: Element) => void;
|
|
19
19
|
} & Record<PropertyKey, unknown>;
|
|
20
|
-
type Effect<T> = () => T extends [] ? Renderable[] : Renderable
|
|
21
|
-
type Element = HTMLElement & Attributes
|
|
20
|
+
type Effect<T> = () => T extends [] ? Renderable<T>[] : Renderable<T>;
|
|
21
|
+
type Element = HTMLElement & Attributes;
|
|
22
22
|
type Primitive = bigint | boolean | null | number | string | undefined;
|
|
23
|
-
type Renderable<T
|
|
23
|
+
type Renderable<T> = DocumentFragment | Effect<T> | Node | NodeList | Primitive | RenderableReactive<T> | Renderable<T>[];
|
|
24
24
|
type RenderableReactive<T> = Readonly<{
|
|
25
25
|
[RENDERABLE]: typeof RENDERABLE_HTML_REACTIVE_ARRAY;
|
|
26
26
|
array: ReactiveArray<T>;
|
|
27
|
-
template: (this: ReactiveArray<T>,
|
|
27
|
+
template: (this: ReactiveArray<T>, value: T, i: number) => ReturnType<typeof html>;
|
|
28
28
|
}>;
|
|
29
29
|
type SlotGroup = {
|
|
30
30
|
head: Element;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"author": "ICJR",
|
|
3
3
|
"dependencies": {
|
|
4
4
|
"@esportsplus/queue": "^0.1.0",
|
|
5
|
-
"@esportsplus/reactivity": "^0.16.
|
|
5
|
+
"@esportsplus/reactivity": "^0.16.7",
|
|
6
6
|
"@esportsplus/tasks": "^0.2.1",
|
|
7
7
|
"@esportsplus/utilities": "^0.22.1"
|
|
8
8
|
},
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"private": false,
|
|
15
15
|
"type": "module",
|
|
16
16
|
"types": "./build/index.d.ts",
|
|
17
|
-
"version": "0.19.
|
|
17
|
+
"version": "0.19.5",
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "tsc && tsc-alias",
|
|
20
20
|
"-": "-"
|
package/src/html/index.ts
CHANGED
|
@@ -5,10 +5,10 @@ import { cloneNode } from '~/utilities/node';
|
|
|
5
5
|
import parser from './parser';
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
type Values<T
|
|
8
|
+
type Values<T> = Attributes | Attributes[] | Readonly<Attributes> | Readonly<Attributes[]> | Renderable<T>;
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
const html = (literals: TemplateStringsArray, ...values: (Values | Values[])[]) => {
|
|
11
|
+
const html = <T>(literals: TemplateStringsArray, ...values: (Values<T> | Values<T>[])[]) => {
|
|
12
12
|
let { fragment, slots } = parser.parse(literals),
|
|
13
13
|
clone = cloneNode.call(fragment, true);
|
|
14
14
|
|
package/src/types.ts
CHANGED
|
@@ -6,7 +6,7 @@ import slot from './slot';
|
|
|
6
6
|
import html from './html';
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
type Attribute = Primitive |
|
|
9
|
+
type Attribute = Effect<Primitive | Primitive[]> | Primitive;
|
|
10
10
|
|
|
11
11
|
type Attributes = {
|
|
12
12
|
class?: Attribute | Attribute[];
|
|
@@ -21,22 +21,23 @@ type Attributes = {
|
|
|
21
21
|
onrender?: (element: Element) => void;
|
|
22
22
|
} & Record<PropertyKey, unknown>;
|
|
23
23
|
|
|
24
|
-
type Effect<T> = () => T extends [] ? Renderable[] : Renderable
|
|
24
|
+
type Effect<T> = () => T extends [] ? Renderable<T>[] : Renderable<T>;
|
|
25
25
|
|
|
26
|
-
type Element = HTMLElement & Attributes
|
|
26
|
+
type Element = HTMLElement & Attributes;
|
|
27
27
|
|
|
28
28
|
// Copied from '@esportsplus/utilities'
|
|
29
29
|
// - Importing from ^ causes 'cannot be named without a reference to...' error
|
|
30
30
|
type Primitive = bigint | boolean | null | number | string | undefined;
|
|
31
31
|
|
|
32
|
-
type Renderable<T
|
|
32
|
+
type Renderable<T> = DocumentFragment | Effect<T> | Node | NodeList | Primitive | RenderableReactive<T> | Renderable<T>[];
|
|
33
33
|
|
|
34
34
|
type RenderableReactive<T> = Readonly<{
|
|
35
35
|
[RENDERABLE]: typeof RENDERABLE_HTML_REACTIVE_ARRAY;
|
|
36
36
|
array: ReactiveArray<T>;
|
|
37
37
|
template: (
|
|
38
38
|
this: ReactiveArray<T>,
|
|
39
|
-
|
|
39
|
+
value: T,
|
|
40
|
+
i: number
|
|
40
41
|
) => ReturnType<typeof html>;
|
|
41
42
|
}>;
|
|
42
43
|
|