@tempots/dom 32.0.0 → 33.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempots/dom",
3
- "version": "32.0.0",
3
+ "version": "33.0.0",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -1,5 +1,30 @@
1
1
  import { Renderable, SplitNValue } from '../types/domain';
2
2
  import { Value } from '../std/value';
3
+ /**
4
+ * Creates a renderable for an HTML attribute with the specified name and value.
5
+ *
6
+ * This is the functional equivalent of using `attr[name](value)` with a dynamic attribute name.
7
+ *
8
+ * The `class` attribute is special and can be used multiple times on the same element.
9
+ * Multiple class values will be merged together.
10
+ *
11
+ * @param name - The name of the attribute.
12
+ * @param value - The value of the attribute (can be a literal or Signal).
13
+ * @returns A renderable that sets the attribute.
14
+ * @example
15
+ * ```ts
16
+ * const button = html.button(
17
+ * Attr('type', 'button'),
18
+ * Attr('disabled', disabledSignal),
19
+ * // Multiple class attributes
20
+ * Attr('class', 'btn btn-primary'),
21
+ * Attr('class', 'active'), // Both classes will be applied
22
+ * // ...
23
+ * )
24
+ * ```
25
+ * @public
26
+ */
27
+ export declare const Attr: (name: string, value: unknown) => Renderable;
3
28
  /**
4
29
  * The `attr` object allows to create any HTML attribute. Either a literal value
5
30
  * or `Signal<?>` can be passed as a value. The type of the value is inferred
@@ -162,9 +187,24 @@ export declare const attr: {
162
187
  innerText: (value: SplitNValue<string>) => Renderable;
163
188
  innerHTML: (value: SplitNValue<string>) => Renderable;
164
189
  outerHTML: (value: SplitNValue<string>) => Renderable;
165
- } & {
166
- set: (name: string, value: SplitNValue<string>) => Renderable;
167
190
  };
191
+ /**
192
+ * Creates a renderable for a data attribute with the specified name and value.
193
+ *
194
+ * This is the functional equivalent of using `dataAttr[name](value)` with a dynamic attribute name.
195
+ *
196
+ * @param name - The name of the data attribute (without the 'data-' prefix).
197
+ * @param value - The value of the attribute (can be a literal or Signal).
198
+ * @returns A renderable that sets the data attribute.
199
+ * @example
200
+ * ```ts
201
+ * const button = html.button(
202
+ * DataAttr('myinfo', 'something'), // maps to the `data-myinfo` attribute
203
+ * )
204
+ * ```
205
+ * @public
206
+ */
207
+ export declare const DataAttr: (name: string, value: unknown) => Renderable;
168
208
  /**
169
209
  * The `data` object allows to create any `data-` attributes. Either a literal value
170
210
  * or `Signal<string>` can be passed as a value.
@@ -179,9 +219,25 @@ export declare const attr: {
179
219
  */
180
220
  export declare const dataAttr: {
181
221
  [x: string]: (value: Value<string>) => Renderable;
182
- } & {
183
- set: (name: string, value: Value<string>) => Renderable;
184
222
  };
223
+ /**
224
+ * Creates a renderable for an ARIA attribute with the specified name and value.
225
+ *
226
+ * This is the functional equivalent of using `aria[name](value)` with a dynamic attribute name.
227
+ *
228
+ * @param name - The name of the ARIA attribute (without the 'aria-' prefix).
229
+ * @param value - The value of the attribute (can be a literal or Signal).
230
+ * @returns A renderable that sets the ARIA attribute.
231
+ * @example
232
+ * ```ts
233
+ * const button = html.button(
234
+ * Aria('label', 'Click me!'), // maps to the `aria-label` attribute
235
+ * Aria('pressed', pressedSignal), // maps to the `aria-pressed` attribute
236
+ * )
237
+ * ```
238
+ * @public
239
+ */
240
+ export declare const Aria: (name: string, value: unknown) => Renderable;
185
241
  /**
186
242
  * An object that provides a convenient way to create mountable attributes for ARIA properties.
187
243
  *
@@ -251,9 +307,26 @@ export declare const aria: {
251
307
  valuemin: (value: SplitNValue<number>) => Renderable;
252
308
  valuenow: (value: SplitNValue<number>) => Renderable;
253
309
  valuetext: (value: SplitNValue<string>) => Renderable;
254
- } & {
255
- set: (name: string, value: Value<string>) => Renderable;
256
310
  };
311
+ /**
312
+ * Creates a renderable for an SVG attribute with the specified name and value.
313
+ *
314
+ * This is the functional equivalent of using `svgAttr[name](value)` with a dynamic attribute name.
315
+ *
316
+ * @param name - The name of the SVG attribute.
317
+ * @param value - The value of the attribute (can be a literal or Signal).
318
+ * @returns A renderable that sets the SVG attribute.
319
+ * @example
320
+ * ```ts
321
+ * const circle = svg.circle(
322
+ * SVGAttr('cx', 50),
323
+ * SVGAttr('cy', 50),
324
+ * SVGAttr('r', radiusSignal),
325
+ * )
326
+ * ```
327
+ * @public
328
+ */
329
+ export declare const SVGAttr: (name: string, value: unknown) => Renderable;
257
330
  /**
258
331
  * An object that provides a convenient way to create mountable attributes for
259
332
  * SVG elements.
@@ -542,9 +615,25 @@ export declare const svgAttr: {
542
615
  yChannelSelector: (value: SplitNValue<"R" | "G" | "B" | "A">) => Renderable;
543
616
  z: (value: SplitNValue<string | number>) => Renderable;
544
617
  zoomAndPan: (value: SplitNValue<"disable" | "magnify">) => Renderable;
545
- } & {
546
- set: (name: string, value: Value<string>) => Renderable;
547
618
  };
619
+ /**
620
+ * Creates a renderable for a MathML attribute with the specified name and value.
621
+ *
622
+ * This is the functional equivalent of using `mathAttr[name](value)`.
623
+ *
624
+ * @param name - The name of the MathML attribute.
625
+ * @param value - The value of the attribute (can be a literal or Signal).
626
+ * @returns A renderable that sets the MathML attribute.
627
+ * @example
628
+ * ```ts
629
+ * const mi = math.mi(
630
+ * MathAttr('mathvariant', 'bold'),
631
+ * MathAttr('mathsize', sizeSignal),
632
+ * )
633
+ * ```
634
+ * @public
635
+ */
636
+ export declare const MathAttr: (name: string, value: unknown) => Renderable;
548
637
  /**
549
638
  * An object that provides attribute functions for MathML tags.
550
639
  *
@@ -183,6 +183,15 @@ export declare const input: {
183
183
  week: (...children: TNode[]) => Renderable;
184
184
  "datetime-local": (...children: TNode[]) => Renderable;
185
185
  };
186
+ /**
187
+ * Creates a Renderable that represents an SVG element.
188
+ *
189
+ * @param tagName - The tag name of the SVG element.
190
+ * @param children - The child nodes of the SVG element.
191
+ * @returns A renderable function that creates and appends the SVG element to the DOM.
192
+ * @public
193
+ */
194
+ export declare const SVGEl: (tagName: string, ...children: TNode[]) => Renderable;
186
195
  /**
187
196
  * A convenience object to create Renderables for SVG elements.
188
197
  * @public
@@ -252,6 +261,15 @@ export declare const svg: {
252
261
  use: (...children: TNode[]) => Renderable;
253
262
  view: (...children: TNode[]) => Renderable;
254
263
  };
264
+ /**
265
+ * Creates a Renderable that represents a MathML element.
266
+ *
267
+ * @param tagName - The tag name of the MathML element.
268
+ * @param children - The child nodes of the MathML element.
269
+ * @returns A renderable function that creates and appends the MathML element to the DOM.
270
+ * @public
271
+ */
272
+ export declare const MathEl: (tagName: string, ...children: TNode[]) => Renderable;
255
273
  /**
256
274
  * A convenience object to create Renderables for MATH elements.
257
275
  * @public