@tempots/dom 21.0.0 → 22.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/index.cjs +1 -1
- package/index.d.ts +2 -2
- package/index.js +451 -435
- package/package.json +1 -1
- package/renderable/bind.d.ts +1 -1
- package/renderable/conjunction.d.ts +1 -1
- package/renderable/foreach.d.ts +2 -2
- package/renderable/repeat.d.ts +2 -3
- package/renderable/when.d.ts +28 -12
- package/std/{position.d.ts → element-position.d.ts} +25 -22
- package/std/value.d.ts +7 -0
- package/types/domain.d.ts +1 -2
- /package/renderable/{handler.d.ts → on.d.ts} +0 -0
package/package.json
CHANGED
package/renderable/bind.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Prop } from '../std/signal';
|
|
2
2
|
import { Renderable } from '../types/domain';
|
|
3
|
-
import { on } from './
|
|
3
|
+
import { on } from './on';
|
|
4
4
|
/**
|
|
5
5
|
* Binds a `Date` property to an input element. The binding is two-way.
|
|
6
6
|
* Changes to the input element will update the property but will only be
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Signal } from '../std/signal';
|
|
2
2
|
import { Renderable, TNode } from '../types/domain';
|
|
3
|
-
import { ElementPosition } from '../std/position';
|
|
3
|
+
import { ElementPosition } from '../std/element-position';
|
|
4
4
|
/**
|
|
5
5
|
* Options for configuring a conjunction.
|
|
6
6
|
* @public
|
package/renderable/foreach.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TNode, Renderable } from '../types/domain';
|
|
2
2
|
import { Signal } from '../std/signal';
|
|
3
|
-
import { ElementPosition } from '../std/position';
|
|
3
|
+
import { ElementPosition } from '../std/element-position';
|
|
4
4
|
import { Value } from '../std/value';
|
|
5
5
|
/**
|
|
6
6
|
* Renders a list of items based on a signal of arrays.
|
|
@@ -12,4 +12,4 @@ import { Value } from '../std/value';
|
|
|
12
12
|
* @returns - The renderable function that renders the list of items.
|
|
13
13
|
* @public
|
|
14
14
|
*/
|
|
15
|
-
export declare const ForEach: <T>(value: Value<T[]>, item: (value: Signal<T>, position:
|
|
15
|
+
export declare const ForEach: <T>(value: Value<T[]>, item: (value: Signal<T>, position: ElementPosition) => TNode, separator?: (pos: ElementPosition) => TNode) => Renderable;
|
package/renderable/repeat.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ElementPosition } from '../std/position';
|
|
2
|
-
import { Signal } from '../std/signal';
|
|
1
|
+
import { ElementPosition } from '../std/element-position';
|
|
3
2
|
import { Value } from '../std/value';
|
|
4
3
|
import { TNode, Renderable } from '../types/domain';
|
|
5
4
|
/**
|
|
@@ -11,4 +10,4 @@ import { TNode, Renderable } from '../types/domain';
|
|
|
11
10
|
* @returns A renderable function that renders the repeated elements.
|
|
12
11
|
* @public
|
|
13
12
|
*/
|
|
14
|
-
export declare const Repeat: (times: Value<number>, element: (index:
|
|
13
|
+
export declare const Repeat: (times: Value<number>, element: (index: ElementPosition) => TNode, separator?: (pos: ElementPosition) => TNode) => Renderable;
|
package/renderable/when.d.ts
CHANGED
|
@@ -1,22 +1,38 @@
|
|
|
1
1
|
import { Renderable, TNode } from '../types/domain';
|
|
2
2
|
import { Value } from '../std/value';
|
|
3
3
|
/**
|
|
4
|
-
* Renders
|
|
5
|
-
*
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @
|
|
9
|
-
* @returns The rendered node.
|
|
4
|
+
* Renders content conditionally based on a boolean value.
|
|
5
|
+
* @param condition - The condition to evaluate
|
|
6
|
+
* @param then - Content to render if condition is true
|
|
7
|
+
* @param otherwise - Optional content to render if condition is false
|
|
8
|
+
* @returns Renderable content
|
|
10
9
|
* @public
|
|
11
10
|
*/
|
|
12
11
|
export declare const When: (condition: Value<boolean>, then: TNode, otherwise?: TNode) => Renderable;
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
* @
|
|
19
|
-
* @
|
|
13
|
+
* Lazily renders content based on a boolean condition.
|
|
14
|
+
* @param condition - The condition to evaluate
|
|
15
|
+
* @param then - Function returning content to render if condition is true
|
|
16
|
+
* @param otherwise - Optional function returning content to render if condition is false
|
|
17
|
+
* @returns Renderable content
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export declare const LazyWhen: (condition: Value<boolean>, then: () => TNode, otherwise?: () => TNode) => Renderable;
|
|
21
|
+
/**
|
|
22
|
+
* Renders content when a condition is false.
|
|
23
|
+
* @param condition - The condition to evaluate
|
|
24
|
+
* @param then - Content to render if condition is false
|
|
25
|
+
* @param otherwise - Optional content to render if condition is true
|
|
26
|
+
* @returns Renderable content
|
|
20
27
|
* @public
|
|
21
28
|
*/
|
|
22
29
|
export declare const Unless: (condition: Value<boolean>, then: TNode, otherwise?: TNode) => Renderable;
|
|
30
|
+
/**
|
|
31
|
+
* Lazily renders content when a condition is false.
|
|
32
|
+
* @param condition - The condition to evaluate
|
|
33
|
+
* @param then - Function returning content to render if condition is false
|
|
34
|
+
* @param otherwise - Optional function returning content to render if condition is true
|
|
35
|
+
* @returns Renderable content
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export declare const LazyUnless: (condition: Value<boolean>, then: () => TNode, otherwise?: () => TNode) => Renderable;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { Signal } from './signal';
|
|
1
2
|
/**
|
|
2
3
|
* Represents the position of an element in a collection.
|
|
3
4
|
*
|
|
4
5
|
* @public
|
|
5
6
|
*/
|
|
6
7
|
export declare class ElementPosition {
|
|
8
|
+
#private;
|
|
7
9
|
/**
|
|
8
10
|
* The index of the element.
|
|
9
11
|
*/
|
|
@@ -11,7 +13,26 @@ export declare class ElementPosition {
|
|
|
11
13
|
/**
|
|
12
14
|
* The total number of elements in the collection.
|
|
13
15
|
*/
|
|
14
|
-
readonly total: number
|
|
16
|
+
readonly total: Signal<number>;
|
|
17
|
+
/**
|
|
18
|
+
* The counter of the element starting from 1.
|
|
19
|
+
*/
|
|
20
|
+
readonly counter: number;
|
|
21
|
+
/**
|
|
22
|
+
* Checks if the element is the first element in the collection.
|
|
23
|
+
* @returns `true` if the element is the first element, `false` otherwise.
|
|
24
|
+
*/
|
|
25
|
+
readonly isFirst: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if the counter of the element is even.
|
|
28
|
+
* @returns `true` if the counter is even, `false` otherwise.
|
|
29
|
+
*/
|
|
30
|
+
readonly isEven: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Checks if the counter of the element is odd.
|
|
33
|
+
* @returns `true` if the counter is odd, `false` otherwise.
|
|
34
|
+
*/
|
|
35
|
+
readonly isOdd: boolean;
|
|
15
36
|
/**
|
|
16
37
|
* Creates a new instance of `ElementPosition`.
|
|
17
38
|
* @param index - The index of the element.
|
|
@@ -25,29 +46,11 @@ export declare class ElementPosition {
|
|
|
25
46
|
/**
|
|
26
47
|
* The total number of elements in the collection.
|
|
27
48
|
*/
|
|
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
|
-
*/
|
|
37
|
-
get isFirst(): boolean;
|
|
49
|
+
total: Signal<number>);
|
|
38
50
|
/**
|
|
39
51
|
* Checks if the element is the last element in the collection.
|
|
40
52
|
* @returns `true` if the element is the last element, `false` otherwise.
|
|
41
53
|
*/
|
|
42
|
-
get isLast(): boolean
|
|
43
|
-
|
|
44
|
-
* Checks if the counter of the element is even.
|
|
45
|
-
* @returns `true` if the counter is even, `false` otherwise.
|
|
46
|
-
*/
|
|
47
|
-
get isEven(): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Checks if the counter of the element is odd.
|
|
50
|
-
* @returns `true` if the counter is odd, `false` otherwise.
|
|
51
|
-
*/
|
|
52
|
-
get isOdd(): boolean;
|
|
54
|
+
get isLast(): Signal<boolean>;
|
|
55
|
+
readonly dispose: () => void;
|
|
53
56
|
}
|
package/std/value.d.ts
CHANGED
|
@@ -50,6 +50,13 @@ export declare const Value: {
|
|
|
50
50
|
* @returns A function to remove the listener.
|
|
51
51
|
*/
|
|
52
52
|
on: <T>(value: Value<T>, listener: (value: T) => void) => (() => void);
|
|
53
|
+
/**
|
|
54
|
+
* Disposes of a value or a Signal.
|
|
55
|
+
* If the value is a Signal, it disposes of the Signal.
|
|
56
|
+
* If the value is not a Signal, it does nothing.
|
|
57
|
+
* @param value - The value or Signal instance to dispose of.
|
|
58
|
+
*/
|
|
59
|
+
dispose: <T>(value: Value<T>) => void;
|
|
53
60
|
};
|
|
54
61
|
/**
|
|
55
62
|
* Creates a computed signal that depends on other signals or literal values and updates when any of the dependencies change.
|
package/types/domain.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DOMContext } from '../dom/dom-context';
|
|
2
|
-
import { Signal } from '../std/signal';
|
|
3
2
|
import { Value } from '../std/value';
|
|
4
3
|
/**
|
|
5
4
|
* Represents a function that can be rendered in the DOM.
|
|
@@ -60,7 +59,7 @@ export type NValue<T> = Value<T> | Value<T | null> | Value<T | undefined> | Valu
|
|
|
60
59
|
* Otherwise, it returns the type itself.
|
|
61
60
|
* @public
|
|
62
61
|
*/
|
|
63
|
-
export type GetValueType<T> = T extends
|
|
62
|
+
export type GetValueType<T> = T extends Value<infer V> ? V : T;
|
|
64
63
|
/**
|
|
65
64
|
* Gets the value types of a given array of Value types.
|
|
66
65
|
* @public
|
|
File without changes
|