@tempots/dom 31.4.0 → 31.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempots/dom",
3
- "version": "31.4.0",
3
+ "version": "31.6.0",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -119,6 +119,7 @@ export declare const attr: {
119
119
  popovertargetaction: (value: SplitNValue<"toggle" | "hide" | "show">) => Renderable;
120
120
  poster: (value: SplitNValue<string>) => Renderable;
121
121
  preload: (value: SplitNValue<string>) => Renderable;
122
+ property: (value: SplitNValue<string>) => Renderable;
122
123
  radiogroup: (value: SplitNValue<string>) => Renderable;
123
124
  readonly: (value: SplitNValue<boolean>) => Renderable;
124
125
  referrerpolicy: (value: SplitNValue<"no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url">) => Renderable;
@@ -161,6 +162,8 @@ export declare const attr: {
161
162
  innerText: (value: SplitNValue<string>) => Renderable;
162
163
  innerHTML: (value: SplitNValue<string>) => Renderable;
163
164
  outerHTML: (value: SplitNValue<string>) => Renderable;
165
+ } & {
166
+ set: (name: string, value: SplitNValue<string>) => Renderable;
164
167
  };
165
168
  /**
166
169
  * The `data` object allows to create any `data-` attributes. Either a literal value
@@ -176,6 +179,8 @@ export declare const attr: {
176
179
  */
177
180
  export declare const dataAttr: {
178
181
  [x: string]: (value: Value<string>) => Renderable;
182
+ } & {
183
+ set: (name: string, value: Value<string>) => Renderable;
179
184
  };
180
185
  /**
181
186
  * An object that provides a convenient way to create mountable attributes for ARIA properties.
@@ -246,6 +251,8 @@ export declare const aria: {
246
251
  valuemin: (value: SplitNValue<number>) => Renderable;
247
252
  valuenow: (value: SplitNValue<number>) => Renderable;
248
253
  valuetext: (value: SplitNValue<string>) => Renderable;
254
+ } & {
255
+ set: (name: string, value: Value<string>) => Renderable;
249
256
  };
250
257
  /**
251
258
  * An object that provides a convenient way to create mountable attributes for
@@ -535,6 +542,8 @@ export declare const svgAttr: {
535
542
  yChannelSelector: (value: SplitNValue<"R" | "G" | "B" | "A">) => Renderable;
536
543
  z: (value: SplitNValue<string | number>) => Renderable;
537
544
  zoomAndPan: (value: SplitNValue<"disable" | "magnify">) => Renderable;
545
+ } & {
546
+ set: (name: string, value: Value<string>) => Renderable;
538
547
  };
539
548
  /**
540
549
  * An object that provides attribute functions for MathML tags.
@@ -0,0 +1,30 @@
1
+ import { Clear, TNode } from '../types/domain';
2
+ import { DOMContext } from '../dom/dom-context';
3
+ import { Signal } from '../std/signal';
4
+ import { Value } from '../std/value';
5
+ /**
6
+ * Helper function to handle a value that could be either a Signal or a static value.
7
+ * Delegates to the appropriate handler based on whether the value is a Signal.
8
+ *
9
+ * @param value - The value to check (could be Signal<T> or T)
10
+ * @param onSignal - Handler function to call if value is a Signal
11
+ * @param onStatic - Handler function to call if value is static
12
+ * @returns The result from the appropriate handler
13
+ * @internal
14
+ */
15
+ export declare const handleValueOrSignal: <T, R>(value: Value<T>, onSignal: (signal: Signal<T>) => R, onStatic: (literal: T) => R) => R;
16
+ /**
17
+ * Creates a reactive renderable that updates when a signal changes.
18
+ * This helper consolidates the common pattern of:
19
+ * - Creating a new context reference
20
+ * - Setting up a signal listener that re-renders on changes
21
+ * - Properly cleaning up the old render before creating a new one
22
+ * - Disposing the signal listener and context on cleanup
23
+ *
24
+ * @param ctx - The parent DOM context
25
+ * @param signal - The signal to watch for changes
26
+ * @param render - Function that takes the signal value and returns content to render
27
+ * @returns A Clear function that cleans up the reactive renderable
28
+ * @internal
29
+ */
30
+ export declare const createReactiveRenderable: <T>(ctx: DOMContext, signal: Signal<T>, render: (value: T) => TNode) => Clear;
@@ -30,8 +30,9 @@ export declare class MemoryStore {
30
30
  export type StoredPropOptions<T> = {
31
31
  /**
32
32
  * The key to use for storing and retrieving the value.
33
+ * Can be a static string or a reactive signal that changes over time.
33
34
  */
34
- key: string;
35
+ key: Value<string>;
35
36
  /**
36
37
  * The default value to use if the value is not found in the store.
37
38
  * This can be a value of type `T` or a function that returns a value of type `T`.
@@ -79,6 +80,13 @@ export type StoredPropOptions<T> = {
79
80
  * Whether to sync the value across tabs. Defaults to `true`.
80
81
  */
81
82
  syncTabs?: boolean;
83
+ /**
84
+ * Strategy for handling key changes when using a reactive key.
85
+ * - 'load' (default): Load value from new key, the current state is already stored at this point
86
+ * - 'migrate': Move current value to new key and continue with current value
87
+ * - 'keep': Keep current value without loading from new key
88
+ */
89
+ onKeyChange?: 'load' | 'migrate' | 'keep';
82
90
  };
83
91
  /**
84
92
  * Creates a stored property that persists its value in a storage mechanism.
@@ -88,7 +96,7 @@ export type StoredPropOptions<T> = {
88
96
  * @returns - The created stored property.
89
97
  * @public
90
98
  */
91
- export declare const storedProp: <T>({ key, defaultValue, store, serialize, deserialize, equals, onLoad, syncTabs, }: StoredPropOptions<T>) => Prop<T>;
99
+ export declare const storedProp: <T>({ key, defaultValue, store, serialize, deserialize, equals, onLoad, syncTabs, onKeyChange, }: StoredPropOptions<T>) => Prop<T>;
92
100
  /**
93
101
  * Represents the properties required for storing and retrieving a value of type `T`.
94
102
  *
@@ -98,8 +106,9 @@ export declare const storedProp: <T>({ key, defaultValue, store, serialize, dese
98
106
  export type StorageOptions<T> = {
99
107
  /**
100
108
  * The key to use for storing and retrieving the value.
109
+ * Can be a static string or a reactive signal that changes over time.
101
110
  */
102
- key: string;
111
+ key: Value<string>;
103
112
  /**
104
113
  * The default value to use if the value is not found in the store.
105
114
  * This can be a value of type `T` or a function that returns a value of type `T`.
@@ -130,6 +139,13 @@ export type StorageOptions<T> = {
130
139
  * Whether to sync the value across tabs. Defaults to `true`.
131
140
  */
132
141
  syncTabs?: boolean;
142
+ /**
143
+ * Strategy for handling key changes when using a reactive key.
144
+ * - 'load' (default): Load value from new key, the current state is already stored at this point
145
+ * - 'migrate': Move current value to new key and continue with current value
146
+ * - 'keep': Keep current value without loading from new key
147
+ */
148
+ onKeyChange?: 'load' | 'migrate' | 'keep';
133
149
  };
134
150
  /**
135
151
  * Creates a prop that is backed by the localStorage or a MemoryStore.
@@ -107,6 +107,7 @@ export type HTMLAttributes = {
107
107
  popovertargetaction: 'hide' | 'show' | 'toggle';
108
108
  poster: string;
109
109
  preload: string;
110
+ property: string;
110
111
  radiogroup: string;
111
112
  readonly: boolean;
112
113
  referrerpolicy: 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';