@tempots/dom 17.0.0 → 19.0.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.
Files changed (50) hide show
  1. package/dom/animatable.d.ts +12 -12
  2. package/dom/attr.d.ts +14 -7
  3. package/dom/dom-context.d.ts +47 -2
  4. package/dom/dom-utils.d.ts +6 -3
  5. package/dom/handle-anchor-click.d.ts +13 -2
  6. package/dom/ssr.d.ts +48 -16
  7. package/index.cjs +1 -1
  8. package/index.d.ts +1 -1
  9. package/index.js +1050 -931
  10. package/package.json +1 -1
  11. package/renderable/async.d.ts +33 -3
  12. package/renderable/attribute.d.ts +28 -9
  13. package/renderable/bind.d.ts +43 -13
  14. package/renderable/conjunction.d.ts +23 -4
  15. package/renderable/consumers.d.ts +54 -1
  16. package/renderable/domnode.d.ts +10 -2
  17. package/renderable/element.d.ts +50 -3
  18. package/renderable/empty.d.ts +5 -0
  19. package/renderable/ensure.d.ts +10 -0
  20. package/renderable/foreach.d.ts +12 -2
  21. package/renderable/fragment.d.ts +11 -0
  22. package/renderable/handler.d.ts +67 -10
  23. package/renderable/map-signal.d.ts +15 -0
  24. package/renderable/not-empty.d.ts +13 -1
  25. package/renderable/onctx.d.ts +9 -2
  26. package/renderable/oneof.d.ts +138 -16
  27. package/renderable/onmount.d.ts +8 -0
  28. package/renderable/onunmount.d.ts +6 -0
  29. package/renderable/portal.d.ts +12 -3
  30. package/renderable/providers.d.ts +39 -6
  31. package/renderable/render.d.ts +39 -3
  32. package/renderable/repeat.d.ts +11 -2
  33. package/renderable/style.d.ts +5 -2
  34. package/renderable/task.d.ts +18 -2
  35. package/renderable/text.d.ts +18 -5
  36. package/renderable/when.d.ts +21 -3
  37. package/std/interpolate.d.ts +56 -5
  38. package/std/position.d.ts +42 -2
  39. package/std/signal-utils.d.ts +226 -0
  40. package/std/signal.d.ts +397 -85
  41. package/types/aria-attributes.d.ts +5 -0
  42. package/types/css-styles.d.ts +11 -0
  43. package/types/domain.d.ts +69 -3
  44. package/types/html-attributes.d.ts +10 -0
  45. package/types/html-events.d.ts +5 -0
  46. package/types/html-tags.d.ts +5 -0
  47. package/types/mathml-attributes.d.ts +5 -0
  48. package/types/mathml-tags.d.ts +4 -0
  49. package/types/svg-attributes.d.ts +5 -0
  50. package/types/svg-tags.d.ts +5 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempots/dom",
3
- "version": "17.0.0",
3
+ "version": "19.0.0",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -1,7 +1,37 @@
1
- import { TNode } from '../types/domain';
1
+ import { Renderable, TNode } from '../types/domain';
2
2
 
3
- export declare const Async: <T>(promise: Promise<T>, options: {
3
+ /**
4
+ * Options for the `Async` component.
5
+ * @typeParam T - The type of the value.
6
+ * @public
7
+ */
8
+ export type AsyncOptions<T> = {
9
+ /**
10
+ * The node to render while the promise is pending.
11
+ */
4
12
  pending?: TNode;
13
+ /**
14
+ * The node to render when the promise is resolved.
15
+ *
16
+ * @param value - The value returned by the promise.
17
+ * @returns The node to render.
18
+ */
5
19
  then: (value: T) => TNode;
20
+ /**
21
+ * The node to render when the promise is rejected.
22
+ *
23
+ * @param error - The error returned by the promise.
24
+ * @returns The node to render.
25
+ */
6
26
  error?: (error: unknown) => TNode;
7
- } | ((value: T) => TNode)) => import('../types/domain').Renderable;
27
+ };
28
+ /**
29
+ * Creates a renderable asynchronous task that wraps a promise.
30
+ *
31
+ * @typeParam T - The type of the value returned by the promise.
32
+ * @param promise - The promise to wrap.
33
+ * @param options - The options for the asynchronous task.
34
+ * @returns The renderable asynchronous task.
35
+ * @public
36
+ */
37
+ export declare const Async: <T>(promise: Promise<T>, options: AsyncOptions<T> | ((value: T) => TNode)) => Renderable;
@@ -1,12 +1,11 @@
1
- import { Renderable } from '../types/domain';
2
- import { Value, NValue } from '../std/signal';
1
+ import { NValue, Renderable, Value } from '../types/domain';
3
2
 
4
3
  /**
5
4
  * The `attr` object allows to create any HTML attribute. Either a literal value
6
5
  * or `Signal<?>` can be passed as a value. The type of the value is inferred
7
6
  * from the attribute name.
8
7
  *
9
- * Example
8
+ * @example
10
9
  * ```ts
11
10
  * const button = html.button(
12
11
  * attr.type('button'),
@@ -14,6 +13,7 @@ import { Value, NValue } from '../std/signal';
14
13
  * // ...
15
14
  * )
16
15
  * ```
16
+ * @public
17
17
  */
18
18
  export declare const attr: {
19
19
  accept: (value: NValue<string>) => Renderable;
@@ -130,20 +130,35 @@ export declare const attr: {
130
130
  innerHTML: (value: NValue<string>) => Renderable;
131
131
  outerHTML: (value: NValue<string>) => Renderable;
132
132
  };
133
+ /**
134
+ * The `data` object allows to create any `data-` attributes. Either a literal value
135
+ * or `Signal<string>` can be passed as a value.
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * const button = html.button(
140
+ * dataAttr.myinfo('something'), // maps to the `data-myinfo` attribute
141
+ * )
142
+ * ```
143
+ * @public
144
+ */
133
145
  export declare const dataAttr: {
134
146
  [x: string]: (value: Value<string>) => Renderable;
135
147
  };
136
148
  /**
137
149
  * An object that provides a convenient way to create mountable attributes for ARIA properties.
138
150
  *
139
- * Example
151
+ * The type of the value is inferred from the attribute name.
152
+ *
153
+ * @example
140
154
  * ```ts
141
155
  * const button = html.button(
142
- * aria.label('Click me!'),
143
- * aria.pressed(pressed), // where pressed is a `Signal<boolean>`
144
- * // ...
156
+ * aria.label('Click me!'), // maps to the `aria-label` attribute
157
+ * // maps to the `aria-pressed` attribute where pressed is a `Signal<boolean>`
158
+ * aria.pressed(pressed)
145
159
  * )
146
160
  * ```
161
+ * @public
147
162
  */
148
163
  export declare const aria: {
149
164
  activedescendant: (value: NValue<string>) => Renderable;
@@ -199,13 +214,15 @@ export declare const aria: {
199
214
  * An object that provides a convenient way to create mountable attributes for
200
215
  * SVG elements.
201
216
  *
202
- * Example
217
+ * @example
203
218
  * ```ts
204
219
  * const svg = html.svg(
205
220
  * svgAttr.width(100),
206
221
  * svgAttr.height(height), // where height is a `Signal<number>`
207
222
  * // ...
208
223
  * )
224
+ * ```
225
+ * @public
209
226
  */
210
227
  export declare const svgAttr: {
211
228
  accentHeight: (value: NValue<number>) => Renderable;
@@ -453,13 +470,15 @@ export declare const svgAttr: {
453
470
  /**
454
471
  * An object that provides attribute functions for MathML tags.
455
472
  *
456
- * Example
473
+ * @example
457
474
  * ```ts
458
475
  * const math = html.math(
459
476
  * mathAttr.mathvariant('bold'),
460
477
  * mathAttr.mathsize(size), // where size is a `Signal<number>`
461
478
  * // ...
462
479
  * )
480
+ * ```
481
+ * @public
463
482
  */
464
483
  export declare const mathAttr: {
465
484
  maction: (value: NValue<MathMLElement>) => Renderable;
@@ -1,16 +1,46 @@
1
1
  import { Prop } from '../std/signal';
2
+ import { Renderable } from '../types/domain';
2
3
  import { on } from './handler';
3
4
 
4
- declare function bindDate(prop: Prop<Date>, handler?: keyof typeof on): import('..').Renderable;
5
- declare function bindDateTime(prop: Prop<Date>, handler?: keyof typeof on): import('..').Renderable;
6
- declare function bindNumber(prop: Prop<number>, handler?: keyof typeof on): import('..').Renderable;
7
- declare function bindText(prop: Prop<string>, handler?: keyof typeof on): import('..').Renderable;
8
- declare function bindChecked(prop: Prop<boolean>): import('..').Renderable;
9
- export declare const bind: {
10
- date: typeof bindDate;
11
- dateTime: typeof bindDateTime;
12
- number: typeof bindNumber;
13
- text: typeof bindText;
14
- checked: typeof bindChecked;
15
- };
16
- export {};
5
+ /**
6
+ * Binds a `Date` property to an input element. The binding is two-way.
7
+ * Changes to the input element will update the property but will only be
8
+ * affected by day changes and ignore time changes.
9
+ * @param prop - The `Date` property to bind.
10
+ * @param handler - The event handler to use (default: 'input').
11
+ * @returns A Renderable.
12
+ * @public
13
+ */
14
+ export declare const BindDate: (prop: Prop<Date>, handler?: keyof typeof on) => Renderable;
15
+ /**
16
+ * Binds a `Date` property to an input element. The binding is two-way.
17
+ * @param prop - The `Date` property to bind.
18
+ * @param handler - The event handler to use (default: 'input').
19
+ * @returns A Renderable.
20
+ * @public
21
+ */
22
+ export declare const BindDateTime: (prop: Prop<Date>, handler?: keyof typeof on) => Renderable;
23
+ /**
24
+ * Binds a `number` property to an input element. The binding is two-way.
25
+ * @param prop - The `number` property to bind.
26
+ * @param handler - The event handler to use (default: 'input').
27
+ * @returns A Renderable.
28
+ * @public
29
+ */
30
+ export declare const BindNumber: (prop: Prop<number>, handler?: keyof typeof on) => Renderable;
31
+ /**
32
+ * Binds a `string` property to an input element. The binding is two-way.
33
+ * @param prop - The `string` property to bind.
34
+ * @param handler - The event handler to use (default: 'input').
35
+ * @returns A Renderable.
36
+ * @public
37
+ */
38
+ export declare const BindText: (prop: Prop<string>, handler?: keyof typeof on) => Renderable;
39
+ /**
40
+ * Binds a `boolean` property to the checked value of an input element. The binding is two-way.
41
+ * @param prop - The `boolean` property to bind.
42
+ * @param handler - The event handler to use (default: 'input').
43
+ * @returns A Renderable.
44
+ * @public
45
+ */
46
+ export declare const BindChecked: (prop: Prop<boolean>) => Renderable;
@@ -1,8 +1,27 @@
1
1
  import { Signal } from '../std/signal';
2
- import { TNode } from '../types/domain';
3
- import { Position } from '../std/position';
2
+ import { Renderable, TNode } from '../types/domain';
3
+ import { ElementPosition } from '../std/position';
4
4
 
5
- export declare const Conjunction: (separator: TNode, options?: {
5
+ /**
6
+ * Options for configuring a conjunction.
7
+ * @public
8
+ */
9
+ export type ConjunctionOptions = {
10
+ /**
11
+ * The separator to use for the last element.
12
+ */
6
13
  lastSeparator?: TNode;
14
+ /**
15
+ * The separator to use for the first element.
16
+ */
7
17
  firstSeparator?: TNode;
8
- }) => (pos: Signal<Position>) => import('../types/domain').Renderable;
18
+ };
19
+ /**
20
+ * Creates a Renderable that returns the appropriate separator based on the element position.
21
+ *
22
+ * @param separator - The default separator to use.
23
+ * @param options - The options for configuring the conjunction.
24
+ * @returns A function that returns the appropriate separator based on the element position.
25
+ * @public
26
+ */
27
+ export declare const Conjunction: (separator: TNode, options?: ConjunctionOptions) => (pos: Signal<ElementPosition>) => Renderable;
@@ -1,12 +1,65 @@
1
1
  import { TNode, Renderable, ProviderMark } from '../types/domain';
2
2
 
3
+ /**
4
+ * Converts a tuple type `T` into an array of `ProviderMark` types.
5
+ * If `T` is an empty tuple, returns an empty array.
6
+ * If `T` has only one element, returns an array with a single `ProviderMark`.
7
+ * If `T` has more than one element, recursively converts each element into a `ProviderMark` and returns an array.
8
+ * @public
9
+ */
3
10
  export type ToArrayOfMarks<T extends unknown[]> = T extends [] ? [] : T extends [infer K] ? [ProviderMark<K>] : T extends [infer K, ...infer R] ? [ProviderMark<K>, ...ToArrayOfMarks<R>] : never;
11
+ /**
12
+ * Represents a type that transforms a tuple of values into an object where each value is associated with a provider mark.
13
+ * @typeParam T - The tuple of values.
14
+ * @returns An object where each value is associated with a provider mark.
15
+ * @public
16
+ */
4
17
  export type ToProviders<T extends unknown[]> = T extends [] ? object : T extends [infer K] ? {
5
18
  [_ in ProviderMark<K>]: K;
6
19
  } : T extends [infer K, ...infer R] ? {
7
20
  [_ in ProviderMark<K>]: K;
8
21
  } & ToProviders<R> : never;
22
+ /**
23
+ * Represents a consumer function that takes a callback function and returns a renderable object.
24
+ * The callback function takes a value of type T and returns a TNode.
25
+ *
26
+ * @typeParam T - The type of the value passed to the callback function.
27
+ * @public
28
+ */
9
29
  export type Consumer<T> = (fn: (value: T) => TNode) => Renderable;
10
- export declare const Use: <C extends Record<string, Consumer<unknown>>>(consumers: C, fn: (data: { [K in keyof C]: C[K] extends Consumer<infer V> ? V : never; }) => Renderable) => Renderable;
30
+ /**
31
+ * Represents a type that extracts the value types from a record of `Consumer` types.
32
+ * @typeParam C - The record of `Consumer` types.
33
+ * @public
34
+ */
35
+ export type UseMany<C extends Record<string, Consumer<unknown>>> = {
36
+ [K in keyof C]: C[K] extends Consumer<infer V> ? V : never;
37
+ };
38
+ /**
39
+ * Creates a renderable function that consumes data from multiple consumers and renders the result.
40
+ *
41
+ * @param consumers - An object containing consumer functions.
42
+ * @param fn - A function that receives the data from the consumers and returns a renderable function.
43
+ * @returns A renderable function that can be called with a DOMContext and returns a cleanup function.
44
+ * @public
45
+ */
46
+ export declare const Use: <C extends Record<string, Consumer<unknown>>>(consumers: C, fn: (data: UseMany<C>) => Renderable) => Renderable;
47
+ /**
48
+ * Creates a renderable function that consumes a provider value and renders a `TNode`.
49
+ *
50
+ * @typeParam T - The type of the provider value.
51
+ * @param mark - The provider mark.
52
+ * @param fn - The function that takes the provider value and returns a `TNode`.
53
+ * @returns A renderable function that consumes the provider value and renders a `TNode`.
54
+ * @public
55
+ */
11
56
  export declare const UseProvider: <T>(mark: ProviderMark<T>, fn: (value: T) => TNode) => Renderable;
57
+ /**
58
+ * Creates a renderable function that consumes providers and renders a TNode.
59
+ *
60
+ * @param marks - The marks to be converted to an array of marks.
61
+ * @param fn - The function that takes providers and returns a TNode.
62
+ * @returns A renderable function that consumes providers and renders a TNode.
63
+ * @public
64
+ */
12
65
  export declare const UseProviders: <T extends unknown[]>(marks: ToArrayOfMarks<T>, fn: (providers: ToProviders<T>) => TNode) => Renderable;
@@ -1,3 +1,11 @@
1
- import { DOMContext } from '../dom/dom-context';
1
+ import { Renderable } from '../types/domain';
2
2
 
3
- export declare const DOMNode: (node: Node) => (ctx: DOMContext) => (removeTree: boolean) => void;
3
+ /**
4
+ * Creates a renderable DOM node.
5
+ *
6
+ * @param node - The DOM node to render.
7
+ * @param ctx - The DOM context to render the node in.
8
+ * @returns A function that can be called to remove the rendered node from the DOM.
9
+ * @public
10
+ */
11
+ export declare const DOMNode: (node: Node) => Renderable;
@@ -1,8 +1,35 @@
1
1
  import { TNode, Renderable } from '../types/domain';
2
2
 
3
- export declare function renderableOfTNode(child: TNode): Renderable;
4
- export declare function El(tagName: string, ...children: TNode[]): Renderable;
5
- export declare function ElNS(tagName: string, namespace: string, ...children: TNode[]): Renderable;
3
+ /**
4
+ * Converts a TNode into a Renderable.
5
+ * @param child - The TNode to convert.
6
+ * @returns The corresponding Renderable.
7
+ * @public
8
+ */
9
+ export declare const renderableOfTNode: (child: TNode) => Renderable;
10
+ /**
11
+ * Creates a Renderable that represents an HTML element.
12
+ *
13
+ * @param tagName - The tag name of the HTML element.
14
+ * @param children - The child nodes of the HTML element.
15
+ * @returns A renderable function that creates and appends the HTML element to the DOM.
16
+ * @public
17
+ */
18
+ export declare const El: (tagName: string, ...children: TNode[]) => Renderable;
19
+ /**
20
+ * Creates a renderable function that represents an element in the DOM with a specified namespace.
21
+ *
22
+ * @param tagName - The name of the HTML tag for the element.
23
+ * @param namespace - The namespace of the element.
24
+ * @param children - The child nodes of the element.
25
+ * @returns A renderable function that creates and appends the element to the DOM.
26
+ * @public
27
+ */
28
+ export declare const ElNS: (tagName: string, namespace: string, ...children: TNode[]) => Renderable;
29
+ /**
30
+ * A convenience object to create Renderables for HTML elements.
31
+ * @public
32
+ */
6
33
  export declare const html: {
7
34
  a: (...children: TNode[]) => Renderable;
8
35
  abbr: (...children: TNode[]) => Renderable;
@@ -116,6 +143,18 @@ export declare const html: {
116
143
  video: (...children: TNode[]) => Renderable;
117
144
  wbr: (...children: TNode[]) => Renderable;
118
145
  };
146
+ /**
147
+ * A convenience object to create Renderables for HTMLInput elements.
148
+ *
149
+ * It automatically creates an attribute with the specified type
150
+ *
151
+ * @example
152
+ * ```ts
153
+ * input.text() // equivalent to html.input(attr.type('text'))
154
+ * ```
155
+ *
156
+ * @public
157
+ */
119
158
  export declare const input: {
120
159
  number: (...children: TNode[]) => Renderable;
121
160
  text: (...children: TNode[]) => Renderable;
@@ -140,6 +179,10 @@ export declare const input: {
140
179
  url: (...children: TNode[]) => Renderable;
141
180
  "datetime-local": (...children: TNode[]) => Renderable;
142
181
  };
182
+ /**
183
+ * A convenience object to create Renderables for SVG elements.
184
+ * @public
185
+ */
143
186
  export declare const svg: {
144
187
  a: (...children: TNode[]) => Renderable;
145
188
  animate: (...children: TNode[]) => Renderable;
@@ -204,6 +247,10 @@ export declare const svg: {
204
247
  tspan: (...children: TNode[]) => Renderable;
205
248
  use: (...children: TNode[]) => Renderable;
206
249
  };
250
+ /**
251
+ * A convenience object to create Renderables for MATH elements.
252
+ * @public
253
+ */
207
254
  export declare const math: {
208
255
  maction: (...children: TNode[]) => Renderable;
209
256
  math: (...children: TNode[]) => Renderable;
@@ -1,3 +1,8 @@
1
1
  import { Renderable } from '../types/domain';
2
2
 
3
+ /**
4
+ * Represents an empty renderable function.
5
+ * @returns A renderable function that does nothing.
6
+ * @public
7
+ */
3
8
  export declare const Empty: Renderable;
@@ -1,4 +1,14 @@
1
1
  import { TNode, Renderable } from '../types/domain';
2
2
  import { Signal } from '../std/signal';
3
3
 
4
+ /**
5
+ * Represents a function that ensures a signal has a value before rendering a TNode.
6
+ *
7
+ * @typeParam T - The type of the signal value.
8
+ * @param signal - The signal to ensure has a value.
9
+ * @param then - The function that returns a TNode when the signal has a value. It takes a signal of the non-nullable type of T.
10
+ * @param otherwise - The function that returns a TNode when the signal does not have a value.
11
+ * @returns A renderable function that ensures the signal has a value before rendering a TNode.
12
+ * @public
13
+ */
4
14
  export declare const Ensure: <T>(signal: Signal<T | null> | Signal<T | undefined> | Signal<T | null | undefined>, then: (value: Signal<NonNullable<T>>) => TNode, otherwise?: () => TNode) => Renderable;
@@ -1,5 +1,15 @@
1
1
  import { TNode, Renderable } from '../types/domain';
2
2
  import { Signal } from '../std/signal';
3
- import { Position } from '../std/position';
3
+ import { ElementPosition } from '../std/position';
4
4
 
5
- export declare const ForEach: <T>(signal: Signal<T[]>, item: (value: Signal<T>, position: Signal<Position>) => TNode, separator?: (pos: Signal<Position>) => TNode) => Renderable;
5
+ /**
6
+ * Renders a list of items based on a signal of arrays.
7
+ *
8
+ * @typeParam T - The type of items in the array.
9
+ * @param signal - The signal of arrays to iterate over.
10
+ * @param item - The function that renders each item in the array.
11
+ * @param separator - The function that renders the separator between items.
12
+ * @returns - The renderable function that renders the list of items.
13
+ * @public
14
+ */
15
+ export declare const ForEach: <T>(signal: Signal<T[]>, item: (value: Signal<T>, position: Signal<ElementPosition>) => TNode, separator?: (pos: Signal<ElementPosition>) => TNode) => Renderable;
@@ -1,3 +1,14 @@
1
1
  import { TNode, Renderable } from '../types/domain';
2
2
 
3
+ /**
4
+ * Creates a fragment renderable that represents a collection of child renderables.
5
+ *
6
+ * The Fragment itself does not render any DOM elements. Instead, it renders the child renderables in the given DOM context.
7
+ *
8
+ * It can be used any time a single Renderable/TNode is expected, but multiple renderables are needed.
9
+ *
10
+ * @param children - The child renderables to include in the fragment.
11
+ * @returns A renderable function that renders the child renderables in the given DOM context.
12
+ * @public
13
+ */
3
14
  export declare const Fragment: (...children: TNode[]) => Renderable;
@@ -1,6 +1,15 @@
1
1
  import { Renderable } from '../types/domain';
2
2
 
3
+ /**
4
+ * Attaches an event handler to the 'click' event that triggers when a checkbox is checked or unchecked.
5
+ * @param fn - The callback function to be executed when the checkbox is clicked.
6
+ * @alpha
7
+ */
3
8
  export declare const OnChecked: (fn: (event: boolean) => void) => Renderable;
9
+ /**
10
+ * Represents a collection of HTML event handlers that can be attached to an element.
11
+ * @public
12
+ */
4
13
  export declare const on: {
5
14
  abort: (handler: (event: Event) => void) => Renderable;
6
15
  animationcancel: (handler: (event: AnimationEvent) => void) => Renderable;
@@ -90,13 +99,61 @@ export declare const on: {
90
99
  volumechange: (handler: (event: Event) => void) => Renderable;
91
100
  waiting: (handler: (event: Event) => void) => Renderable;
92
101
  };
93
- export declare const emit: {
94
- value: (fn: (text: string) => void) => (event: Event) => void;
95
- valueAsNumber: (fn: (num: number) => void) => (event: Event) => void;
96
- valueAsDate: (fn: (date: Date) => void) => (event: Event) => void;
97
- valueAsDateTime: (fn: (date: Date) => void) => (event: Event) => void;
98
- checked: (fn: (checked: boolean) => void) => (event: Event) => void;
99
- preventDefault: (fn: () => void) => (event: Event) => void;
100
- stopPropagation: (fn: () => void) => (event: Event) => void;
101
- stopImmediatePropagation: (fn: () => void) => (event: Event) => void;
102
- };
102
+ /**
103
+ * Creates an event handler that emits the value of an HTMLInputElement.
104
+ *
105
+ * @param fn - The callback function that will receive the emitted value.
106
+ * @returns An event handler function that can be attached to an event listener.
107
+ * @public
108
+ */
109
+ export declare const EmitValue: (fn: (text: string) => void) => (event: Event) => void;
110
+ /**
111
+ * Calls the provided function with the value of an HTMLInputElement as a number.
112
+ *
113
+ * @param fn - The function to be called with the value as a number.
114
+ * @returns A function that can be used as an event handler.
115
+ * @public
116
+ */
117
+ export declare const EmitValueAsNumber: (fn: (num: number) => void) => (event: Event) => void;
118
+ /**
119
+ * Converts the value of an HTML input element to a Date object and emits it using the provided callback function.
120
+ * @param fn - The callback function to be called with the converted Date object.
121
+ * @returns A function that can be used as an event handler for input events.
122
+ * @public
123
+ */
124
+ export declare const EmitValueAsDate: (fn: (date: Date) => void) => (event: Event) => void;
125
+ /**
126
+ * Emits the value of an HTMLInputElement as a Date object.
127
+ * @param fn - The callback function to be called with the emitted Date object.
128
+ * @returns The event handler function.
129
+ * @public
130
+ */
131
+ export declare const EmitValueAsDateTime: (fn: (date: Date) => void) => (event: Event) => void;
132
+ /**
133
+ * Calls the provided function with the checked value of the event target.
134
+ * @param fn - The function to be called with the checked value.
135
+ * @returns A function that takes an event and calls the provided function with the checked value of the event target.
136
+ * @public
137
+ */
138
+ export declare const EmitChecked: (fn: (checked: boolean) => void) => (event: Event) => void;
139
+ /**
140
+ * Wraps a function to prevent the default behavior of an event before invoking it.
141
+ * @param fn - The function to be wrapped.
142
+ * @returns A new function that prevents the default behavior of the event and then invokes the original function.
143
+ * @public
144
+ */
145
+ export declare const EmitPreventDefault: (fn: () => void) => (event: Event) => void;
146
+ /**
147
+ * Creates a new event handler that stops event propagation and invokes the provided function.
148
+ * @param fn - The function to be invoked when the event is triggered.
149
+ * @returns A new event handler function.
150
+ * @public
151
+ */
152
+ export declare const EmitStopPropagation: (fn: () => void) => (event: Event) => void;
153
+ /**
154
+ * Creates an event handler that stops immediate propagation of the event and invokes the provided function.
155
+ * @param fn - The function to be invoked.
156
+ * @returns The event handler function.
157
+ * @public
158
+ */
159
+ export declare const EmitStopImmediatePropagation: (fn: () => void) => (event: Event) => void;
@@ -1,4 +1,19 @@
1
1
  import { Renderable } from '../types/domain';
2
2
  import { Signal } from '../std/signal';
3
3
 
4
+ /**
5
+ * Maps the values emitted by a signal to a renderable function and returns a new renderable function.
6
+ *
7
+ * While it is tempting to use MapSignal for its simplicity, it is important to remember that the
8
+ * renderable function returned by MapSignal will be re-rendered every time the signal emits a new value.
9
+ *
10
+ * In other contexts link `Ensure` or `OneOf`, the renderable function is only re-rendered when the signal
11
+ * changes to a state that requires a different renderable function.
12
+ *
13
+ * @typeParam T - The type of values emitted by the signal.
14
+ * @param signal - The signal to map.
15
+ * @param fn - The function to map the signal values to renderable functions.
16
+ * @returns - A new renderable function that represents the mapped signal.
17
+ * @public
18
+ */
4
19
  export declare const MapSignal: <T>(signal: Signal<T>, fn: (value: T) => Renderable) => Renderable;
@@ -1,4 +1,16 @@
1
1
  import { Signal } from '../std/signal';
2
2
  import { Renderable } from '../types/domain';
3
3
 
4
- export declare function NotEmpty<T>(signal: Signal<T[]>, display: Renderable, whenEmpty?: Renderable): Renderable;
4
+ /**
5
+ * Returns a renderable component that displays the given `display` component
6
+ * when the `signal` contains a non-empty array, and the `whenEmpty` component
7
+ * otherwise.
8
+ *
9
+ * @typeParam T - The type of elements in the array.
10
+ * @param signal - The signal containing the array.
11
+ * @param display - The component to display when the array is non-empty.
12
+ * @param whenEmpty- The component to display when the array is empty.
13
+ * @returns - The renderable component.
14
+ * @public
15
+ */
16
+ export declare const NotEmpty: <T>(signal: Signal<T[]>, display: Renderable, whenEmpty?: Renderable) => Renderable;
@@ -1,4 +1,11 @@
1
1
  import { DOMContext } from '../dom/dom-context';
2
- import { Clear } from '../types/domain';
2
+ import { Clear, Renderable } from '../types/domain';
3
3
 
4
- export declare const OnCtx: (fn: (ctx: DOMContext) => Clear) => (ctx: DOMContext) => Clear;
4
+ /**
5
+ * Returns a renderable function that executes the given function with the current DOMContext as argument.
6
+ *
7
+ * @param fn - The function to be executed with the DOMContext argument.
8
+ * @returns A Clear function that can be used to clean up any resources associated with the execution.
9
+ * @public
10
+ */
11
+ export declare const OnCtx: (fn: (ctx: DOMContext) => Clear) => Renderable;