@tempots/dom 18.0.0 → 19.1.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.
- package/dom/animatable.d.ts +12 -12
- package/dom/attr.d.ts +14 -7
- package/dom/dom-context.d.ts +47 -2
- package/dom/dom-utils.d.ts +6 -3
- package/dom/handle-anchor-click.d.ts +13 -2
- package/dom/ssr.d.ts +48 -16
- package/index.cjs +1 -1
- package/index.js +1000 -755
- package/package.json +1 -1
- package/renderable/async.d.ts +33 -3
- package/renderable/attribute.d.ts +24 -7
- package/renderable/bind.d.ts +43 -13
- package/renderable/conjunction.d.ts +23 -4
- package/renderable/consumers.d.ts +54 -1
- package/renderable/domnode.d.ts +10 -2
- package/renderable/element.d.ts +50 -3
- package/renderable/empty.d.ts +5 -0
- package/renderable/ensure.d.ts +10 -0
- package/renderable/foreach.d.ts +12 -2
- package/renderable/fragment.d.ts +11 -0
- package/renderable/handler.d.ts +64 -10
- package/renderable/map-signal.d.ts +15 -0
- package/renderable/not-empty.d.ts +13 -1
- package/renderable/onctx.d.ts +9 -2
- package/renderable/oneof.d.ts +138 -16
- package/renderable/onmount.d.ts +8 -0
- package/renderable/onunmount.d.ts +6 -0
- package/renderable/portal.d.ts +12 -3
- package/renderable/providers.d.ts +39 -6
- package/renderable/render.d.ts +39 -3
- package/renderable/repeat.d.ts +11 -2
- package/renderable/style.d.ts +4 -0
- package/renderable/task.d.ts +18 -2
- package/renderable/text.d.ts +16 -3
- package/renderable/when.d.ts +21 -3
- package/std/interpolate.d.ts +56 -5
- package/std/position.d.ts +46 -2
- package/std/signal-utils.d.ts +195 -19
- package/std/signal.d.ts +401 -30
- package/types/aria-attributes.d.ts +5 -0
- package/types/css-styles.d.ts +11 -0
- package/types/domain.d.ts +62 -2
- package/types/html-attributes.d.ts +10 -0
- package/types/html-events.d.ts +5 -0
- package/types/html-tags.d.ts +5 -0
- package/types/mathml-attributes.d.ts +5 -0
- package/types/mathml-tags.d.ts +4 -0
- package/types/svg-attributes.d.ts +5 -0
- package/types/svg-tags.d.ts +5 -0
package/renderable/oneof.d.ts
CHANGED
|
@@ -1,22 +1,144 @@
|
|
|
1
1
|
import { Signal } from '../std/signal';
|
|
2
2
|
import { Renderable, TNode } from '../types/domain';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Represents a set of options for a one-of type.
|
|
6
|
+
* @typeParam T - The type of the options.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export type OneOfOptions<T extends Record<string, unknown>> = {
|
|
10
|
+
[KK in keyof T]: (value: Signal<T[KK]>) => TNode;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Creates a renderable function that renders different components based on the value of a signal.
|
|
14
|
+
*
|
|
15
|
+
* The signal value should be an object with a single key that matches one of the keys in the `cases` object.
|
|
16
|
+
*
|
|
17
|
+
* @typeParam T - The type of the signal value.
|
|
18
|
+
* @param match - The signal to match against.
|
|
19
|
+
* @param cases - An object containing the different cases to render based on the signal value.
|
|
20
|
+
* @returns A renderable function that renders the appropriate component based on the signal value.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare const OneOf: <T extends Record<string, unknown>>(match: Signal<T>, cases: OneOfOptions<T>) => Renderable;
|
|
24
|
+
/**
|
|
25
|
+
* Represents the options for a one-of field.
|
|
26
|
+
*
|
|
27
|
+
* @typeParam T - The type containing the one-of field.
|
|
28
|
+
* @typeParam K - The key of the one-of field in the type.
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export type OneOfFieldOptions<T extends {
|
|
32
|
+
[_ in K]: string;
|
|
33
|
+
}, K extends string> = {
|
|
34
|
+
[KK in T[K]]: (value: Signal<T extends {
|
|
35
|
+
[_ in K]: KK;
|
|
36
|
+
} ? T : never>) => TNode;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Creates a renderable that renders different components based on the value of the specified field.
|
|
40
|
+
*
|
|
41
|
+
* @typeParam T - The type containing the one-of field.
|
|
42
|
+
* @typeParam K - The type of the one-of field key.
|
|
43
|
+
* @param match - The signal that emits the object containing the one-of field.
|
|
44
|
+
* @param field - The key of the one-of field.
|
|
45
|
+
* @param cases - The options for the different cases of rendering based on the one-of field value.
|
|
46
|
+
* @returns - The renderable field representing the one-of field.
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export declare const OneOfField: <T extends { [_ in K]: string; }, K extends string>(match: Signal<T>, field: K, cases: OneOfFieldOptions<T, K>) => Renderable;
|
|
50
|
+
/**
|
|
51
|
+
* The options for a one-of kind field.
|
|
52
|
+
*
|
|
53
|
+
* @typeParam T - The type that contains the `kind` property.
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export type OneOfKindOptions<T extends {
|
|
57
|
+
kind: string;
|
|
58
|
+
}> = {
|
|
59
|
+
[KK in T['kind']]: (value: Signal<T extends {
|
|
13
60
|
kind: KK;
|
|
14
|
-
} ? T : never>) => TNode;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
61
|
+
} ? T : never>) => TNode;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Creates a renderable field that matches the value of the `kind` property in the provided `match` signal.
|
|
65
|
+
*
|
|
66
|
+
* It uses the `cases` object to determine the appropriate field to render based on the value of `kind`.
|
|
67
|
+
*
|
|
68
|
+
* @typeParam T - The type of the object with a `kind` property.
|
|
69
|
+
* @param match - The signal containing the object to match against.
|
|
70
|
+
* @param cases - The object containing the cases to match against.
|
|
71
|
+
* @returns - The renderable field that matches the value of `kind`.
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
export declare const OneOfKind: <T extends {
|
|
75
|
+
kind: string;
|
|
76
|
+
}>(match: Signal<T>, cases: OneOfKindOptions<T>) => Renderable;
|
|
77
|
+
/**
|
|
78
|
+
* Represents a mapping of keys to functions that accept a value of type `Signal<V>`
|
|
79
|
+
* and return a `TNode`.
|
|
80
|
+
*
|
|
81
|
+
* @typeParam T - The union type of keys.
|
|
82
|
+
* @typeParam V - The type of the value accepted by the functions.
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
export type OneOfTupleOptions<T extends string, V> = {
|
|
86
|
+
[KK in T]: (value: Signal<V>) => TNode;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Creates a tuple-based one-of component that matches a signal value with a set of cases.
|
|
90
|
+
*
|
|
91
|
+
* The signal value should be a tuple with the first element being the key to match against.
|
|
92
|
+
*
|
|
93
|
+
* @param match - The signal containing the value to match.
|
|
94
|
+
* @param cases - The options for the one-of component.
|
|
95
|
+
* @returns The result of matching the signal value with the cases.
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
export declare const OneOfTuple: <T extends string, V>(match: Signal<[T, V]>, cases: OneOfTupleOptions<T, V>) => Renderable;
|
|
99
|
+
/**
|
|
100
|
+
* Represents a mapping of types to rendering functions.
|
|
101
|
+
* @typeParam T - The type that contains a `type` property.
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
export type OneOfTypeOptions<T extends {
|
|
105
|
+
type: string;
|
|
106
|
+
}> = {
|
|
107
|
+
[KK in T['type']]: (value: Signal<T extends {
|
|
19
108
|
type: KK;
|
|
20
|
-
} ? T : never>) => TNode;
|
|
21
|
-
|
|
109
|
+
} ? T : never>) => TNode;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Creates a field that renders one of the provided cases based on the value of the `type` property.
|
|
113
|
+
*
|
|
114
|
+
* It uses the `cases` object to determine the appropriate field to render based on the value of `type`.
|
|
115
|
+
*
|
|
116
|
+
* @typeParam T - The type of the object with a `type` property.
|
|
117
|
+
* @param match - The signal that contains the object with the `type` property.
|
|
118
|
+
* @param cases - The options for rendering each case based on the `type` property.
|
|
119
|
+
* @returns - The rendered field.
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
export declare const OneOfType: <T extends {
|
|
123
|
+
type: string;
|
|
124
|
+
}>(match: Signal<T>, cases: OneOfTypeOptions<T>) => Renderable;
|
|
125
|
+
/**
|
|
126
|
+
* Represents a set of options for a one-of value.
|
|
127
|
+
* @typeParam T - The type of the one-of value.
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
export type OneOfValueOptions<T extends symbol | number | string> = {
|
|
131
|
+
[KK in T]: () => TNode;
|
|
22
132
|
};
|
|
133
|
+
/**
|
|
134
|
+
* Creates a renderable value that represents one of the provided cases based on the given match signal.
|
|
135
|
+
*
|
|
136
|
+
* The match signal should emit a value that matches one of the keys in the `cases` object.
|
|
137
|
+
*
|
|
138
|
+
* @typeParam T - The type of the match signal value.
|
|
139
|
+
* @param match - The match signal.
|
|
140
|
+
* @param cases - The options for the one-of value.
|
|
141
|
+
* @returns - The renderable value representing one of the cases.
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
|
+
export declare const OneOfValue: <T extends symbol | number | string>(match: Signal<T>, cases: OneOfValueOptions<T>) => Renderable;
|
package/renderable/onmount.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import { Clear, Renderable } from '../types/domain';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Executes a callback function when the parent element is mounted in the DOM.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam T - The type of the element.
|
|
7
|
+
* @param fn - The callback function to be executed.
|
|
8
|
+
* @returns - The renderable function.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
3
11
|
export declare const OnMount: <T extends Element>(fn: (element: T) => Clear | undefined | void) => Renderable;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { Renderable } from '../types/domain';
|
|
2
2
|
import { DOMContext } from '../dom/dom-context';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Creates a renderable function that will be called when the component is unmounted.
|
|
6
|
+
* @param fn - The function to be called when the component is unmounted.
|
|
7
|
+
* @returns A renderable function that takes a DOMContext and returns a function that takes a boolean indicating whether to remove the tree.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
4
10
|
export declare const OnUnmount: (fn: (removeTree: boolean, ctx: DOMContext) => void) => Renderable;
|
package/renderable/portal.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TNode } from '../types/domain';
|
|
1
|
+
import { Renderable, TNode } from '../types/domain';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Renders the given `node` into a DOM element selected by the provided `selector`.
|
|
5
|
+
* Throws an error if the element cannot be found.
|
|
6
|
+
*
|
|
7
|
+
* @param selector - The CSS selector for the target DOM element.
|
|
8
|
+
* @param node - The node to be rendered.
|
|
9
|
+
* @param ctx - The DOM context.
|
|
10
|
+
* @returns The result of rendering the `node` into the selected DOM element.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare const Portal: (selector: string, node: TNode) => Renderable;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { TNode, Renderable, ProviderMark } from '../types/domain';
|
|
2
|
-
import { DOMContext } from '../dom/dom-context';
|
|
3
|
-
import { renderableOfTNode } from './element';
|
|
4
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Represents a provider function that takes a `TNode` and returns a `Renderable`.
|
|
5
|
+
* @param node - The node to be rendered.
|
|
6
|
+
* @returns The rendered output.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
5
9
|
export type Provider = (node: TNode) => Renderable;
|
|
6
10
|
/**
|
|
7
11
|
* Creates a unique symbol that can be used as a provider mark for a specific type `T`.
|
|
@@ -9,8 +13,37 @@ export type Provider = (node: TNode) => Renderable;
|
|
|
9
13
|
*
|
|
10
14
|
* @param identifier - A string that uniquely identifies the provider.
|
|
11
15
|
* @returns A unique symbol that can be used as a provider mark.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export declare const makeProviderMark: <T>(identifier: string) => ProviderMark<T>;
|
|
19
|
+
/**
|
|
20
|
+
* Higher-order function that composes multiple provider functions into a single provider function.
|
|
21
|
+
*
|
|
22
|
+
* @param providerFns - The provider functions to be composed.
|
|
23
|
+
* @returns A new provider function that applies the composed providers in reverse order.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export declare const Provide: <T extends Provider[]>(...providerFns: T) => Provider;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a renderable with a provider mark and value.
|
|
29
|
+
*
|
|
30
|
+
* The value will be available to any consumers that request the provider mark.
|
|
31
|
+
*
|
|
32
|
+
* @typeParam T - The type of the provider value.
|
|
33
|
+
* @param mark - The provider mark.
|
|
34
|
+
* @param value - The provider value.
|
|
35
|
+
* @param child - The child TNode.
|
|
36
|
+
* @returns - The renderable with the provider.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare const WithProvider: <T>(mark: ProviderMark<T>, value: T, child: TNode) => Renderable;
|
|
40
|
+
/**
|
|
41
|
+
* Renders the given child with the specified providers.
|
|
42
|
+
*
|
|
43
|
+
* @typeParam T - The types of the provider values.
|
|
44
|
+
* @param providers - An object containing the providers.
|
|
45
|
+
* @param child - The child to render.
|
|
46
|
+
* @returns The rendered result.
|
|
47
|
+
* @public
|
|
12
48
|
*/
|
|
13
|
-
export declare
|
|
14
|
-
export declare const Provide: <T extends Provider[]>(...providerFns: T) => typeof renderableOfTNode;
|
|
15
|
-
export declare const WithProvider: <T>(mark: ProviderMark<T>, value: T, child: TNode) => (ctx: DOMContext) => import('../types/domain').Clear;
|
|
16
|
-
export declare const WithProviders: <T extends unknown[]>(providers: { [K in ProviderMark<T[number]>]: T[number]; }, child: TNode) => (ctx: DOMContext) => import('../types/domain').Clear;
|
|
49
|
+
export declare const WithProviders: <T extends unknown[]>(providers: { [K in ProviderMark<T[number]>]: T[number]; }, child: TNode) => Renderable;
|
package/renderable/render.d.ts
CHANGED
|
@@ -1,8 +1,44 @@
|
|
|
1
1
|
import { Renderable } from '../types/domain';
|
|
2
2
|
import { DOMContext } from '../dom/dom-context';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Renders the given `renderable` with the provided `ctx` DOM context.
|
|
6
|
+
*
|
|
7
|
+
* @param renderable - The renderable node to be rendered.
|
|
8
|
+
* @param ctx - The DOM context to be used for rendering.
|
|
9
|
+
* @returns A function that can be called to clear the rendered node.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare const renderWithContext: (renderable: Renderable, ctx: DOMContext) => () => void;
|
|
13
|
+
/**
|
|
14
|
+
* Options for rendering.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export type RenderOptions = {
|
|
18
|
+
/**
|
|
19
|
+
* The document to render to. It is inferred from the parent element if not provided.
|
|
20
|
+
*/
|
|
6
21
|
doc?: Document;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to clear the document before rendering. This is useful when the page has been pre-rendered on the server.
|
|
24
|
+
*/
|
|
7
25
|
clear?: boolean;
|
|
8
|
-
}
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Renders a `Renderable` node into a specified parent element or selector.
|
|
29
|
+
*
|
|
30
|
+
* @param node - The `Renderable` node to render.
|
|
31
|
+
* @param parent - The parent element or selector where the node should be rendered.
|
|
32
|
+
* @param options - Optional rendering options.
|
|
33
|
+
* @returns The result of rendering the `Renderable` node.
|
|
34
|
+
* @throws Throws a `RenderingError` if the parent element cannot be found by the provided selector.
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export declare const render: (node: Renderable, parent: Node | string, { doc, clear }?: RenderOptions) => () => void;
|
|
38
|
+
/**
|
|
39
|
+
* Represents an error that occurs during rendering.
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export declare class RenderingError extends Error {
|
|
43
|
+
constructor(message: string);
|
|
44
|
+
}
|
package/renderable/repeat.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ElementPosition } from '../std/position';
|
|
2
2
|
import { Signal } from '../std/signal';
|
|
3
3
|
import { TNode, Renderable } from '../types/domain';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Creates a renderable function that repeats a given element a specified number of times.
|
|
7
|
+
*
|
|
8
|
+
* @param times - A signal representing the number of times the element should be repeated.
|
|
9
|
+
* @param element - A function that returns the element to be repeated, based on the current index.
|
|
10
|
+
* @param separator - (Optional) A function that returns the separator element to be inserted between repeated elements.
|
|
11
|
+
* @returns A renderable function that renders the repeated elements.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare const Repeat: (times: Signal<number>, element: (index: Signal<ElementPosition>) => TNode, separator?: (pos: Signal<ElementPosition>) => TNode) => Renderable;
|
package/renderable/style.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { NValue, Renderable } from '../types/domain';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A collection of functions to create style renderables.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
3
7
|
export declare const style: {
|
|
4
8
|
all: (value: NValue<string>) => Renderable;
|
|
5
9
|
[Symbol.iterator]: (value: NValue<string>) => Renderable;
|
package/renderable/task.d.ts
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
import { TNode, Renderable } from '../types/domain';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Represents the options for a task.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam T - The type of the task value.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export type TaskOptions<T> = {
|
|
4
10
|
pending?: TNode;
|
|
5
11
|
then: (value: T) => TNode;
|
|
6
12
|
error?: (error: unknown) => TNode;
|
|
7
|
-
}
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Represents a renderable task that can be executed asynchronously.
|
|
16
|
+
*
|
|
17
|
+
* @typeParam T - The type of the value returned by the task.
|
|
18
|
+
* @param task - The asynchronous task to be executed.
|
|
19
|
+
* @param options - The options for the task or a function that transforms the task result into a renderable node.
|
|
20
|
+
* @returns - A function that renders the task and returns a cleanup function.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare const Task: <T>(task: () => Promise<T>, options: TaskOptions<T> | ((value: T) => TNode)) => Renderable;
|
package/renderable/text.d.ts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { Renderable, Value } from '../types/domain';
|
|
2
2
|
import { Signal } from '../std/signal';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare const _staticText: (text: string) => Renderable;
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare const _signalText: (signal: Signal<string>) => Renderable;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a renderable text node.
|
|
14
|
+
*
|
|
15
|
+
* @param value - The value of the text node.
|
|
16
|
+
* @returns A renderable text node.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare const TextNode: (value: Value<string>) => Renderable;
|
package/renderable/when.d.ts
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
import { TNode } from '../types/domain';
|
|
1
|
+
import { Renderable, TNode } from '../types/domain';
|
|
2
2
|
import { Signal } from '../std/signal';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Renders the `then` node if the `condition` is true, otherwise renders the `otherwise` node.
|
|
6
|
+
*
|
|
7
|
+
* @param condition - The condition to evaluate.
|
|
8
|
+
* @param then - The node to render if the condition is true.
|
|
9
|
+
* @param otherwise - The node to render if the condition is false.
|
|
10
|
+
* @returns The rendered node.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare const When: (condition: Signal<boolean>, then: TNode, otherwise?: TNode) => Renderable;
|
|
14
|
+
/**
|
|
15
|
+
* Executes the `then` TNode if the `condition` Signal evaluates to `false`, otherwise executes the `otherwise` TNode.
|
|
16
|
+
*
|
|
17
|
+
* @param condition - The Signal representing the condition to evaluate.
|
|
18
|
+
* @param then - The TNode to execute if the condition is `false`.
|
|
19
|
+
* @param otherwise - The optional TNode to execute if the condition is `true`.
|
|
20
|
+
* @returns The result of executing the `then` or `otherwise` TNode based on the condition.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare const Unless: (condition: Signal<boolean>, then: TNode, otherwise?: TNode) => Renderable;
|
package/std/interpolate.d.ts
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Represents a function that interpolates between two values.
|
|
3
|
+
*
|
|
4
|
+
* @typeParam T - The type of the values being interpolated.
|
|
5
|
+
* @param start - The starting value.
|
|
6
|
+
* @param end - The ending value.
|
|
7
|
+
* @param delta - The interpolation factor between 0 and 1.
|
|
8
|
+
* @returns The interpolated value.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export type Interpolate<T> = (start: T, end: T, delta: number) => T;
|
|
12
|
+
/**
|
|
13
|
+
* Interpolates a number between a start and end value based on a delta.
|
|
14
|
+
*
|
|
15
|
+
* @param start - The starting value.
|
|
16
|
+
* @param end - The ending value.
|
|
17
|
+
* @param delta - The delta value between 0 and 1.
|
|
18
|
+
* @returns The interpolated number.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare const interpolateNumber: Interpolate<number>;
|
|
22
|
+
/**
|
|
23
|
+
* Interpolates between two strings based on a delta value.
|
|
24
|
+
*
|
|
25
|
+
* @param start - The starting string.
|
|
26
|
+
* @param end - The ending string.
|
|
27
|
+
* @param delta - The delta value between 0 and 1.
|
|
28
|
+
* @returns The interpolated string.
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export declare const interpolateString: Interpolate<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Interpolates between two dates based on a delta value.
|
|
34
|
+
*
|
|
35
|
+
* @param start - The starting date.
|
|
36
|
+
* @param end - The ending date.
|
|
37
|
+
* @param delta - The delta value between 0 and 1.
|
|
38
|
+
* @returns The interpolated date.
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export declare const interpolateDate: Interpolate<Date>;
|
|
42
|
+
/**
|
|
43
|
+
* A fake interpolate function that always returns the end value.
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export declare const endInterpolate: <T>(_start: T, end: T) => T;
|
|
48
|
+
/**
|
|
49
|
+
* Returns an interpolation function based on the type of the value.
|
|
50
|
+
*
|
|
51
|
+
* @typeParam T - The type of the value.
|
|
52
|
+
* @param value - The value to be interpolated.
|
|
53
|
+
* @returns An interpolation function that takes a start value, an end value, and a delta, and returns an interpolated value.
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export declare const guessInterpolate: <T>(value: T) => Interpolate<T>;
|
package/std/position.d.ts
CHANGED
|
@@ -1,9 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Represents the position of an element in a collection.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare class ElementPosition {
|
|
7
|
+
/**
|
|
8
|
+
* The index of the element.
|
|
9
|
+
*/
|
|
2
10
|
readonly index: number;
|
|
11
|
+
/**
|
|
12
|
+
* The total number of elements in the collection.
|
|
13
|
+
*/
|
|
3
14
|
readonly total: number;
|
|
4
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new instance of `ElementPosition`.
|
|
17
|
+
* @param index - The index of the element.
|
|
18
|
+
* @param total - The total number of elements in the collection.
|
|
19
|
+
*/
|
|
20
|
+
constructor(
|
|
21
|
+
/**
|
|
22
|
+
* The index of the element.
|
|
23
|
+
*/
|
|
24
|
+
index: number,
|
|
25
|
+
/**
|
|
26
|
+
* The total number of elements in the collection.
|
|
27
|
+
*/
|
|
28
|
+
total: number);
|
|
29
|
+
/**
|
|
30
|
+
* Gets the counter of the element.
|
|
31
|
+
*/
|
|
32
|
+
get counter(): number;
|
|
33
|
+
/**
|
|
34
|
+
* Checks if the element is the first element in the collection.
|
|
35
|
+
* @returns `true` if the element is the first element, `false` otherwise.
|
|
36
|
+
*/
|
|
5
37
|
get isFirst(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Checks if the element is the last element in the collection.
|
|
40
|
+
* @returns `true` if the element is the last element, `false` otherwise.
|
|
41
|
+
*/
|
|
6
42
|
get isLast(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Checks if the index of the element is even.
|
|
45
|
+
* @returns `true` if the index is even, `false` otherwise.
|
|
46
|
+
*/
|
|
7
47
|
get isEven(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Checks if the index of the element is odd.
|
|
50
|
+
* @returns `true` if the index is odd, `false` otherwise.
|
|
51
|
+
*/
|
|
8
52
|
get isOdd(): boolean;
|
|
9
53
|
}
|