jj 2.7.2 → 2.9.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/SKILL.md +20 -2
- package/lib/bundle.cjs +85 -17
- package/lib/bundle.cjs.map +1 -1
- package/lib/bundle.d.cts +69 -18
- package/lib/bundle.d.ts +69 -18
- package/lib/bundle.global.js +85 -17
- package/lib/bundle.global.js.map +1 -1
- package/lib/bundle.js +85 -17
- package/lib/bundle.js.map +1 -1
- package/lib/bundle.min.cjs +1 -1
- package/lib/bundle.min.cjs.map +1 -1
- package/lib/bundle.min.d.cts +69 -18
- package/lib/bundle.min.d.ts +69 -18
- package/lib/bundle.min.global.js +1 -1
- package/lib/bundle.min.global.js.map +1 -1
- package/lib/bundle.min.js +1 -1
- package/lib/bundle.min.js.map +1 -1
- package/package.json +12 -6
package/lib/bundle.min.d.cts
CHANGED
|
@@ -217,7 +217,7 @@ declare class JJET<T extends EventTarget = EventTarget> {
|
|
|
217
217
|
* @param args - Arguments to pass to the function.
|
|
218
218
|
* @returns The return value of the function.
|
|
219
219
|
*/
|
|
220
|
-
run<R, Args extends
|
|
220
|
+
run<R, Args extends unknown[]>(fn: (this: this, ...args: Args) => R, ...args: Args): R;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
/**
|
|
@@ -249,15 +249,16 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
|
|
|
249
249
|
* This is useful for filtering the array that is passed to `append()`, `prepend()` or `setChildren()`
|
|
250
250
|
*
|
|
251
251
|
* @param x an unknown value
|
|
252
|
-
* @returns true if `x` is a string, Node (or its
|
|
252
|
+
* @returns true if `x` is a string, Node (or its descendent), JJN (or its descendent)
|
|
253
253
|
*/
|
|
254
|
-
static
|
|
254
|
+
static isWrappable(x: unknown): x is Wrappable;
|
|
255
255
|
/**
|
|
256
256
|
* Wraps a native DOM node or string into the most specific JJ wrapper available.
|
|
257
257
|
*
|
|
258
258
|
* @remarks
|
|
259
259
|
* This function acts as a factory, inspecting the input type and returning the appropriate
|
|
260
260
|
* subclass of `JJN` (e.g., `JJHE` for `HTMLElement`, `JJT` for `Text`).
|
|
261
|
+
* JJN.ts overrides this method to a richer version that handles all subclasses of JJN.
|
|
261
262
|
*
|
|
262
263
|
* @example
|
|
263
264
|
* ```ts
|
|
@@ -318,6 +319,39 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
|
|
|
318
319
|
* @throws {TypeError} If `ref` is not a Node.
|
|
319
320
|
*/
|
|
320
321
|
constructor(ref: T);
|
|
322
|
+
/**
|
|
323
|
+
* Gets the parent node wrapped in the most specific JJ wrapper available.
|
|
324
|
+
*
|
|
325
|
+
* @remarks
|
|
326
|
+
* Returns `null` when this node is detached and therefore has no parent.
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```ts
|
|
330
|
+
* const text = JJT.fromStr('hello')
|
|
331
|
+
* JJHE.create('div').addChild(text)
|
|
332
|
+
* const parent = text.parent // JJHE
|
|
333
|
+
* ```
|
|
334
|
+
*
|
|
335
|
+
* @returns The wrapped parent node, or `null` if this node has no parent.
|
|
336
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/parentNode | Node.parentNode}
|
|
337
|
+
*/
|
|
338
|
+
get parent(): Wrapped | null;
|
|
339
|
+
/**
|
|
340
|
+
* Gets the child nodes wrapped in the most specific JJ wrappers available.
|
|
341
|
+
*
|
|
342
|
+
* @remarks
|
|
343
|
+
* Returns an empty array when this node has no children.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```ts
|
|
347
|
+
* const el = JJHE.create('div').addChild('hello', JJHE.create('span'))
|
|
348
|
+
* const children = el.children // [JJT, JJHE]
|
|
349
|
+
* ```
|
|
350
|
+
*
|
|
351
|
+
* @returns The wrapped child nodes.
|
|
352
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes | Node.childNodes}
|
|
353
|
+
*/
|
|
354
|
+
get children(): Wrapped[];
|
|
321
355
|
/**
|
|
322
356
|
* Clones the Node.
|
|
323
357
|
*
|
|
@@ -326,6 +360,23 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
|
|
|
326
360
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode | Node.cloneNode}
|
|
327
361
|
*/
|
|
328
362
|
clone(deep?: boolean): Wrapped;
|
|
363
|
+
/**
|
|
364
|
+
* Removes this node from its parent.
|
|
365
|
+
*
|
|
366
|
+
* @remarks
|
|
367
|
+
* If the node has no parent, this method does nothing.
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* ```ts
|
|
371
|
+
* const el = JJHE.create('div')
|
|
372
|
+
* doc.body.addChild(el)
|
|
373
|
+
* el.rm()
|
|
374
|
+
* ```
|
|
375
|
+
*
|
|
376
|
+
* @returns This instance for chaining.
|
|
377
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild | Node.removeChild}
|
|
378
|
+
*/
|
|
379
|
+
rm(): this;
|
|
329
380
|
/**
|
|
330
381
|
* Creates a Text node from a string and appends it to this Node.
|
|
331
382
|
*
|
|
@@ -342,7 +393,7 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
|
|
|
342
393
|
* @returns This instance for chaining.
|
|
343
394
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/createTextNode | document.createTextNode}
|
|
344
395
|
*/
|
|
345
|
-
addText(
|
|
396
|
+
addText(...textArr: unknown[]): this;
|
|
346
397
|
}
|
|
347
398
|
|
|
348
399
|
declare abstract class JJNx<T extends Element | Document | DocumentFragment> extends JJN<T> {
|
|
@@ -658,8 +709,8 @@ declare class JJE<T extends Element = Element> extends JJNx<T> {
|
|
|
658
709
|
* @throws {TypeError} If arguments are invalid types.
|
|
659
710
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute | Element.setAttribute}
|
|
660
711
|
*/
|
|
661
|
-
setAttr(name: string, value:
|
|
662
|
-
setAttr(obj: Record<string,
|
|
712
|
+
setAttr(name: string, value: unknown): this;
|
|
713
|
+
setAttr(obj: Record<string, unknown>): this;
|
|
663
714
|
/**
|
|
664
715
|
* Removes one or more attributes from the Element.
|
|
665
716
|
*
|
|
@@ -712,8 +763,8 @@ declare class JJE<T extends Element = Element> extends JJNx<T> {
|
|
|
712
763
|
*
|
|
713
764
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes | ARIA Attributes}
|
|
714
765
|
*/
|
|
715
|
-
setAria(name: string, value:
|
|
716
|
-
setAria(obj: Record<string,
|
|
766
|
+
setAria(name: string, value: unknown): this;
|
|
767
|
+
setAria(obj: Record<string, unknown>): this;
|
|
717
768
|
/**
|
|
718
769
|
* Removes one or more ARIA attributes from the Element.
|
|
719
770
|
*
|
|
@@ -955,14 +1006,14 @@ declare abstract class JJEx<T extends HTMLElement | SVGElement> extends JJE<T> {
|
|
|
955
1006
|
* ```ts
|
|
956
1007
|
* el.setData('myKey', 'myValue') // Single
|
|
957
1008
|
* el.setData({ myKey: 'myValue', otherKey: 'otherValue' }) // Multiple
|
|
958
|
-
* el.setData('count', 42) // Numbers are automatically converted
|
|
1009
|
+
* el.setData('count', 42) // Numbers are automatically converted to strings
|
|
959
1010
|
* ```
|
|
960
1011
|
*
|
|
961
1012
|
* @throws {TypeError} If arguments are invalid types.
|
|
962
1013
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | HTMLElement.dataset}
|
|
963
1014
|
*/
|
|
964
|
-
setData(name: string, value
|
|
965
|
-
setData(obj: Record<string,
|
|
1015
|
+
setData(name: string, value?: string): this;
|
|
1016
|
+
setData(obj: Record<string, string | undefined>): this;
|
|
966
1017
|
/**
|
|
967
1018
|
* Removes one or more data attributes from the HTMLElement.
|
|
968
1019
|
*
|
|
@@ -1049,7 +1100,7 @@ declare class JJHE<T extends HTMLElement = HTMLElement> extends JJEx<T> {
|
|
|
1049
1100
|
* @throws {Error} If the HTMLElement does not have a value property.
|
|
1050
1101
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/value | HTMLInputElement.value}
|
|
1051
1102
|
*/
|
|
1052
|
-
setValue(value:
|
|
1103
|
+
setValue(value: unknown): this;
|
|
1053
1104
|
/**
|
|
1054
1105
|
* Focuses the HTMLElement.
|
|
1055
1106
|
*
|
|
@@ -1086,7 +1137,7 @@ declare class JJHE<T extends HTMLElement = HTMLElement> extends JJEx<T> {
|
|
|
1086
1137
|
* @returns This instance for chaining.
|
|
1087
1138
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText | HTMLElement.innerText}
|
|
1088
1139
|
*/
|
|
1089
|
-
setText(text?:
|
|
1140
|
+
setText(text?: unknown): this;
|
|
1090
1141
|
}
|
|
1091
1142
|
|
|
1092
1143
|
/**
|
|
@@ -1229,7 +1280,7 @@ declare class JJSE<T extends SVGElement = SVGElement> extends JJEx<T> {
|
|
|
1229
1280
|
* @returns This instance for chaining.
|
|
1230
1281
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
|
|
1231
1282
|
*/
|
|
1232
|
-
setText(text?:
|
|
1283
|
+
setText(text?: unknown): this;
|
|
1233
1284
|
/**
|
|
1234
1285
|
* Sets the fill attribute.
|
|
1235
1286
|
*
|
|
@@ -1367,7 +1418,7 @@ declare class JJT<T extends Text = Text> extends JJN<Text> {
|
|
|
1367
1418
|
* @returns This instance for chaining.
|
|
1368
1419
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
|
|
1369
1420
|
*/
|
|
1370
|
-
setText(text?:
|
|
1421
|
+
setText(text?: unknown): this;
|
|
1371
1422
|
/**
|
|
1372
1423
|
* Appends text to the existing content.
|
|
1373
1424
|
*
|
|
@@ -1378,11 +1429,11 @@ declare class JJT<T extends Text = Text> extends JJN<Text> {
|
|
|
1378
1429
|
* console.log(text.getText()) // 'hello world'
|
|
1379
1430
|
* ```
|
|
1380
1431
|
*
|
|
1381
|
-
* @param
|
|
1432
|
+
* @param textArr - The string to add to the existing contents. If null or undefined, nothing is added.
|
|
1382
1433
|
* @returns This instance for chaining.
|
|
1383
1434
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
|
|
1384
1435
|
*/
|
|
1385
|
-
addText(
|
|
1436
|
+
addText(...textArr: unknown[]): this;
|
|
1386
1437
|
/**
|
|
1387
1438
|
* Clears the text content of the Text node.
|
|
1388
1439
|
*
|
|
@@ -1659,7 +1710,7 @@ declare function fetchStyle(url: URL | string): Promise<CSSStyleSheet>;
|
|
|
1659
1710
|
* @returns `true` if it tried to set the attribute; otherwise `false`.
|
|
1660
1711
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes | Responding to attribute changes}
|
|
1661
1712
|
*/
|
|
1662
|
-
declare function attr2prop(instance: HTMLElement, name: string, oldValue:
|
|
1713
|
+
declare function attr2prop(instance: HTMLElement, name: string, oldValue: unknown, newValue: unknown): boolean;
|
|
1663
1714
|
/**
|
|
1664
1715
|
* Registers the custom element with the browser and waits till it is defined.
|
|
1665
1716
|
*
|
package/lib/bundle.min.d.ts
CHANGED
|
@@ -217,7 +217,7 @@ declare class JJET<T extends EventTarget = EventTarget> {
|
|
|
217
217
|
* @param args - Arguments to pass to the function.
|
|
218
218
|
* @returns The return value of the function.
|
|
219
219
|
*/
|
|
220
|
-
run<R, Args extends
|
|
220
|
+
run<R, Args extends unknown[]>(fn: (this: this, ...args: Args) => R, ...args: Args): R;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
/**
|
|
@@ -249,15 +249,16 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
|
|
|
249
249
|
* This is useful for filtering the array that is passed to `append()`, `prepend()` or `setChildren()`
|
|
250
250
|
*
|
|
251
251
|
* @param x an unknown value
|
|
252
|
-
* @returns true if `x` is a string, Node (or its
|
|
252
|
+
* @returns true if `x` is a string, Node (or its descendent), JJN (or its descendent)
|
|
253
253
|
*/
|
|
254
|
-
static
|
|
254
|
+
static isWrappable(x: unknown): x is Wrappable;
|
|
255
255
|
/**
|
|
256
256
|
* Wraps a native DOM node or string into the most specific JJ wrapper available.
|
|
257
257
|
*
|
|
258
258
|
* @remarks
|
|
259
259
|
* This function acts as a factory, inspecting the input type and returning the appropriate
|
|
260
260
|
* subclass of `JJN` (e.g., `JJHE` for `HTMLElement`, `JJT` for `Text`).
|
|
261
|
+
* JJN.ts overrides this method to a richer version that handles all subclasses of JJN.
|
|
261
262
|
*
|
|
262
263
|
* @example
|
|
263
264
|
* ```ts
|
|
@@ -318,6 +319,39 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
|
|
|
318
319
|
* @throws {TypeError} If `ref` is not a Node.
|
|
319
320
|
*/
|
|
320
321
|
constructor(ref: T);
|
|
322
|
+
/**
|
|
323
|
+
* Gets the parent node wrapped in the most specific JJ wrapper available.
|
|
324
|
+
*
|
|
325
|
+
* @remarks
|
|
326
|
+
* Returns `null` when this node is detached and therefore has no parent.
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```ts
|
|
330
|
+
* const text = JJT.fromStr('hello')
|
|
331
|
+
* JJHE.create('div').addChild(text)
|
|
332
|
+
* const parent = text.parent // JJHE
|
|
333
|
+
* ```
|
|
334
|
+
*
|
|
335
|
+
* @returns The wrapped parent node, or `null` if this node has no parent.
|
|
336
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/parentNode | Node.parentNode}
|
|
337
|
+
*/
|
|
338
|
+
get parent(): Wrapped | null;
|
|
339
|
+
/**
|
|
340
|
+
* Gets the child nodes wrapped in the most specific JJ wrappers available.
|
|
341
|
+
*
|
|
342
|
+
* @remarks
|
|
343
|
+
* Returns an empty array when this node has no children.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```ts
|
|
347
|
+
* const el = JJHE.create('div').addChild('hello', JJHE.create('span'))
|
|
348
|
+
* const children = el.children // [JJT, JJHE]
|
|
349
|
+
* ```
|
|
350
|
+
*
|
|
351
|
+
* @returns The wrapped child nodes.
|
|
352
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes | Node.childNodes}
|
|
353
|
+
*/
|
|
354
|
+
get children(): Wrapped[];
|
|
321
355
|
/**
|
|
322
356
|
* Clones the Node.
|
|
323
357
|
*
|
|
@@ -326,6 +360,23 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
|
|
|
326
360
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode | Node.cloneNode}
|
|
327
361
|
*/
|
|
328
362
|
clone(deep?: boolean): Wrapped;
|
|
363
|
+
/**
|
|
364
|
+
* Removes this node from its parent.
|
|
365
|
+
*
|
|
366
|
+
* @remarks
|
|
367
|
+
* If the node has no parent, this method does nothing.
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* ```ts
|
|
371
|
+
* const el = JJHE.create('div')
|
|
372
|
+
* doc.body.addChild(el)
|
|
373
|
+
* el.rm()
|
|
374
|
+
* ```
|
|
375
|
+
*
|
|
376
|
+
* @returns This instance for chaining.
|
|
377
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild | Node.removeChild}
|
|
378
|
+
*/
|
|
379
|
+
rm(): this;
|
|
329
380
|
/**
|
|
330
381
|
* Creates a Text node from a string and appends it to this Node.
|
|
331
382
|
*
|
|
@@ -342,7 +393,7 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
|
|
|
342
393
|
* @returns This instance for chaining.
|
|
343
394
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/createTextNode | document.createTextNode}
|
|
344
395
|
*/
|
|
345
|
-
addText(
|
|
396
|
+
addText(...textArr: unknown[]): this;
|
|
346
397
|
}
|
|
347
398
|
|
|
348
399
|
declare abstract class JJNx<T extends Element | Document | DocumentFragment> extends JJN<T> {
|
|
@@ -658,8 +709,8 @@ declare class JJE<T extends Element = Element> extends JJNx<T> {
|
|
|
658
709
|
* @throws {TypeError} If arguments are invalid types.
|
|
659
710
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute | Element.setAttribute}
|
|
660
711
|
*/
|
|
661
|
-
setAttr(name: string, value:
|
|
662
|
-
setAttr(obj: Record<string,
|
|
712
|
+
setAttr(name: string, value: unknown): this;
|
|
713
|
+
setAttr(obj: Record<string, unknown>): this;
|
|
663
714
|
/**
|
|
664
715
|
* Removes one or more attributes from the Element.
|
|
665
716
|
*
|
|
@@ -712,8 +763,8 @@ declare class JJE<T extends Element = Element> extends JJNx<T> {
|
|
|
712
763
|
*
|
|
713
764
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes | ARIA Attributes}
|
|
714
765
|
*/
|
|
715
|
-
setAria(name: string, value:
|
|
716
|
-
setAria(obj: Record<string,
|
|
766
|
+
setAria(name: string, value: unknown): this;
|
|
767
|
+
setAria(obj: Record<string, unknown>): this;
|
|
717
768
|
/**
|
|
718
769
|
* Removes one or more ARIA attributes from the Element.
|
|
719
770
|
*
|
|
@@ -955,14 +1006,14 @@ declare abstract class JJEx<T extends HTMLElement | SVGElement> extends JJE<T> {
|
|
|
955
1006
|
* ```ts
|
|
956
1007
|
* el.setData('myKey', 'myValue') // Single
|
|
957
1008
|
* el.setData({ myKey: 'myValue', otherKey: 'otherValue' }) // Multiple
|
|
958
|
-
* el.setData('count', 42) // Numbers are automatically converted
|
|
1009
|
+
* el.setData('count', 42) // Numbers are automatically converted to strings
|
|
959
1010
|
* ```
|
|
960
1011
|
*
|
|
961
1012
|
* @throws {TypeError} If arguments are invalid types.
|
|
962
1013
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | HTMLElement.dataset}
|
|
963
1014
|
*/
|
|
964
|
-
setData(name: string, value
|
|
965
|
-
setData(obj: Record<string,
|
|
1015
|
+
setData(name: string, value?: string): this;
|
|
1016
|
+
setData(obj: Record<string, string | undefined>): this;
|
|
966
1017
|
/**
|
|
967
1018
|
* Removes one or more data attributes from the HTMLElement.
|
|
968
1019
|
*
|
|
@@ -1049,7 +1100,7 @@ declare class JJHE<T extends HTMLElement = HTMLElement> extends JJEx<T> {
|
|
|
1049
1100
|
* @throws {Error} If the HTMLElement does not have a value property.
|
|
1050
1101
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/value | HTMLInputElement.value}
|
|
1051
1102
|
*/
|
|
1052
|
-
setValue(value:
|
|
1103
|
+
setValue(value: unknown): this;
|
|
1053
1104
|
/**
|
|
1054
1105
|
* Focuses the HTMLElement.
|
|
1055
1106
|
*
|
|
@@ -1086,7 +1137,7 @@ declare class JJHE<T extends HTMLElement = HTMLElement> extends JJEx<T> {
|
|
|
1086
1137
|
* @returns This instance for chaining.
|
|
1087
1138
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText | HTMLElement.innerText}
|
|
1088
1139
|
*/
|
|
1089
|
-
setText(text?:
|
|
1140
|
+
setText(text?: unknown): this;
|
|
1090
1141
|
}
|
|
1091
1142
|
|
|
1092
1143
|
/**
|
|
@@ -1229,7 +1280,7 @@ declare class JJSE<T extends SVGElement = SVGElement> extends JJEx<T> {
|
|
|
1229
1280
|
* @returns This instance for chaining.
|
|
1230
1281
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
|
|
1231
1282
|
*/
|
|
1232
|
-
setText(text?:
|
|
1283
|
+
setText(text?: unknown): this;
|
|
1233
1284
|
/**
|
|
1234
1285
|
* Sets the fill attribute.
|
|
1235
1286
|
*
|
|
@@ -1367,7 +1418,7 @@ declare class JJT<T extends Text = Text> extends JJN<Text> {
|
|
|
1367
1418
|
* @returns This instance for chaining.
|
|
1368
1419
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
|
|
1369
1420
|
*/
|
|
1370
|
-
setText(text?:
|
|
1421
|
+
setText(text?: unknown): this;
|
|
1371
1422
|
/**
|
|
1372
1423
|
* Appends text to the existing content.
|
|
1373
1424
|
*
|
|
@@ -1378,11 +1429,11 @@ declare class JJT<T extends Text = Text> extends JJN<Text> {
|
|
|
1378
1429
|
* console.log(text.getText()) // 'hello world'
|
|
1379
1430
|
* ```
|
|
1380
1431
|
*
|
|
1381
|
-
* @param
|
|
1432
|
+
* @param textArr - The string to add to the existing contents. If null or undefined, nothing is added.
|
|
1382
1433
|
* @returns This instance for chaining.
|
|
1383
1434
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
|
|
1384
1435
|
*/
|
|
1385
|
-
addText(
|
|
1436
|
+
addText(...textArr: unknown[]): this;
|
|
1386
1437
|
/**
|
|
1387
1438
|
* Clears the text content of the Text node.
|
|
1388
1439
|
*
|
|
@@ -1659,7 +1710,7 @@ declare function fetchStyle(url: URL | string): Promise<CSSStyleSheet>;
|
|
|
1659
1710
|
* @returns `true` if it tried to set the attribute; otherwise `false`.
|
|
1660
1711
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes | Responding to attribute changes}
|
|
1661
1712
|
*/
|
|
1662
|
-
declare function attr2prop(instance: HTMLElement, name: string, oldValue:
|
|
1713
|
+
declare function attr2prop(instance: HTMLElement, name: string, oldValue: unknown, newValue: unknown): boolean;
|
|
1663
1714
|
/**
|
|
1664
1715
|
* Registers the custom element with the browser and waits till it is defined.
|
|
1665
1716
|
*
|
package/lib/bundle.min.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(()=>{var V=e=>{throw TypeError(e)};var P=(e,t,r)=>t.has(e)||V("Cannot "+r);var c=(e,t,r)=>(P(e,t,"read from private field"),r?r.call(e):t.get(e)),h=(e,t,r)=>t.has(e)?V("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),J=(e,t,r,o)=>(P(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r),G=(e,t,r)=>(P(e,t,"access private method"),r);function M(e){return e!==void 0}function g(e){return typeof e=="function"}var{isNaN:K,isFinite:at,isInteger:ut}=Number;function H(e){return typeof e=="number"&&!K(e)}function F(e,t,r){if(!H(e))throw new TypeError(`inRange(): "x" must be a number. Got ${e} (${typeof e})`);if(M(t)){if(!H(t))throw new TypeError(`inRange(): "min" must be a number. Got ${t} (${typeof t})`);if(M(r)){if(!H(r))throw new TypeError(`inRange(): "max" must be a number. Got ${r} (${typeof r})`);return t>r?r<=e&&e<=t:t<=e&&e<=r}return e>=t}else if(M(r)){if(!H(r))throw new TypeError(`inRange(): "max" must be a number. Got ${r} (${typeof r})`);return e<=r}throw new TypeError(`inRange(): expected at least min or max to be defined. Got min=${t} and max=${r}`)}var{isArray:Z}=Array;function N(e,t=0,r){return Z(e)&&F(e.length,t,r)}var{hasOwnProperty:lt}=Object;function f(e){return!!e&&typeof e=="object"}function s(e,t){if(!g(t))throw new TypeError(`Expected a constructor function. Got ${t} (${typeof t})`);return e instanceof t}function w(e,...t){if(!f(e))return!1;for(let r of t)if(!(r in e))return!1;return!0}function i(e){return typeof e=="string"}var{hasOwnProperty:Jt}=Object,{isArray:At}=Array;function y(e,t,r){return`Expected '${e}' to be ${t}. Got ${r} (${typeof r})`}function n(e,t,r){return new TypeError(y(e,t,r))}function I(e){if(!i(e))throw n("path","a string",e);let t=e.lastIndexOf(".");if(t===-1)return"";let r=e.slice(t+1);return r.indexOf("/")!==-1?"":r.toLowerCase().trim()}function Pt(){return new Promise(e=>requestAnimationFrame(e))}function Gt(e=0){return new Promise(t=>setTimeout(t,e))}async function C(e){return await new CSSStyleSheet().replace(e)}function Ut(e){if(!i(e))throw n("str","a string",e);if(/[^a-zA-Z0-9_]/.test(e))throw new SyntaxError(y("str","alphanumeric characters and underscores",e));return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function Vt(e){if(!i(e))throw n("str","a string",e);return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")||(e.length>0?e.charAt(0).toUpperCase()+e.slice(1):"")}function z(e){if(!i(e))throw n("str","a string",e);return e.replace(/^-+|-+$/g,"").replace(/-+([a-z])/g,(t,r)=>r.toUpperCase())}var A,$,L,O,j=class j{constructor(t){h(this,L);h(this,A);h(this,$,new WeakMap);if(!s(t,EventTarget))throw new TypeError(`JJET expects an EventTarget instance. Got ${t} (${typeof t}). `);J(this,A,t)}static from(t){return new j(t)}get ref(){return c(this,A)}on(t,r,o){let a=G(this,L,O).call(this,r);return this.ref.addEventListener(t,a,o),this}off(t,r,o){let a=G(this,L,O).call(this,r);return this.ref.removeEventListener(t,a,o),this}trigger(t){return this.ref.dispatchEvent(t),this}run(t,...r){return t.call(this,...r)}};A=new WeakMap,$=new WeakMap,L=new WeakSet,O=function(t){if(t===null)return null;let r=c(this,$).get(t);return r||(typeof t=="function"?r=t.bind(this):r={handleEvent:t.handleEvent.bind(this)},c(this,$).set(t,r)),r};var W=j;var u=class e extends W{static from(t){return new e(t)}static isWrapable(t){return i(t)||s(t,Node)||s(t,e)}static wrap(t){throw new ReferenceError("The mixin is supposed to override this method.")}static unwrap(t){if(i(t))return document.createTextNode(t);if(!f(t))throw new TypeError(`JJN.unwrap() expects a string, DOM Node, or JJ wrapper. Got ${t} (${typeof t}). `);if(s(t,Node))return t;if(s(t,e))return t.ref;throw new TypeError(`Could not unwrap ${t} (${typeof t}). Expected a string, Node, or JJ wrapper. Make sure you're passing a valid DOM element or JJ wrapper.`)}static wrapAll(t){return Array.from(t,e.wrap)}static unwrapAll(t){return Array.from(t,e.unwrap)}constructor(t){if(!s(t,Node))throw new TypeError(`JJN expects a Node instance. Got ${t} (${typeof t}). Use JJN.from(node) with a DOM Node, or check that you're passing a valid DOM element.`);super(t)}clone(t){return e.wrap(this.ref.cloneNode(t))}addText(t){return t&&this.ref.appendChild(document.createTextNode(t)),this}};var m=class extends u{find(t,r=!1){let o=this.ref.querySelector(t);if(o)return u.wrap(o);if(r)throw new TypeError(`No element matched query "${t}"`);return null}findAll(t){return u.wrapAll(this.ref.querySelectorAll(t))}addChild(...t){let r=u.unwrapAll(t.filter(u.isWrapable));return this.ref.append(...r),this}preChild(...t){let r=u.unwrapAll(t.filter(u.isWrapable));return this.ref.prepend(...r),this}addChildMap(t,r){return this.addChild(...t.map(r))}preChildMap(t,r){return this.preChild(...t.map(r))}setChildren(...t){let r=u.unwrapAll(t.filter(u.isWrapable));return this.ref.replaceChildren(...r),this}empty(){return this.setChildren(),this}};var l=class e extends m{static from(t){return new e(t)}static create(){return new e(document.createDocumentFragment())}constructor(t){if(!s(t,DocumentFragment))throw n("ref","a DocumentFragment",t);super(t)}};var E=class e extends l{static from(t){return new e(t)}constructor(t){if(!s(t,ShadowRoot))throw new TypeError(`JJSR expects a ShadowRoot instance. Got ${t} (${typeof t}). Access a shadow root using element.shadowRoot after calling element.attachShadow().`);super(t)}getHTML(){return this.ref.innerHTML}setHTML(t,r){if(t&&r!==!0)throw new Error("Setting innerHTML is unsafe. Pass true as the second argument to confirm you know what you are doing.");return this.ref.innerHTML=t??"",this}addStyleSheets(...t){return this.ref.adoptedStyleSheets.push(...t),this}};var T=class e extends m{static from(t){return new e(t)}constructor(t){if(!s(t,Element))throw new TypeError(`JJE expects an Element instance. Got ${t} (${typeof t}). Use JJE.from(element) with a DOM Element, or use the specific wrapper (JJHE for HTMLElement, JJSE for SVGElement).`);super(t)}getAttr(t){if(!i(t))throw n("name","a string",t);return this.ref.getAttribute(t)}hasAttr(t){if(!i(t))throw n("name","a string",t);return this.ref.hasAttribute(t)}setAttr(t,r){if(typeof t=="string")this.ref.setAttribute(t,r);else if(f(t))for(let[o,a]of Object.entries(t))this.ref.setAttribute(o,a);else throw n("nameOrObj","a string or object",t);return this}rmAttr(...t){for(let r of t){if(!i(r))throw n("name","a string",r);this.ref.removeAttribute(r)}return this}getAria(t){if(!i(t))throw n("name","a string",t);return this.ref.getAttribute(`aria-${t}`)}hasAria(t){if(!i(t))throw n("name","a string",t);return this.ref.hasAttribute(`aria-${t}`)}setAria(t,r){if(i(t))this.ref.setAttribute(`aria-${t}`,r);else if(f(t))for(let[o,a]of Object.entries(t))this.ref.setAttribute(`aria-${o}`,a);else throw n("nameOrObj","a string or object",t);return this}rmAria(...t){for(let r of t){if(!i(r))throw n("name","a string",r);this.ref.removeAttribute(`aria-${r}`)}return this}getClass(){return this.getAttr("class")}setClass(t){if(typeof t=="string")return this.setAttr("class",t);for(let[r,o]of Object.entries(t))o?this.ref.classList.add(r):this.ref.classList.remove(r);return this}addClass(...t){for(let r of t)if(!i(r))throw n("className","a string",r);return this.ref.classList.add(...t),this}rmClass(...t){for(let r of t)if(!i(r))throw n("className","a string",r);return this.ref.classList.remove(...t),this}hasClass(t){if(!i(t))throw n("className","a string",t);return this.ref.classList.contains(t)}toggleClass(t){if(!i(t))throw n("className","a string",t);return this.ref.classList.toggle(t),this}replaceClass(t,r){if(!i(t))throw n("oldClassName","a string",t);if(!i(r))throw n("newClassName","a string",r);return this.ref.classList.replace(t,r),this}closest(t){if(!i(t))throw n("selector","a string",t);let r=this.ref.closest(t);return r?u.wrap(r):null}hide(){return this.setAttr("hidden","").setAttr("aria-hidden","true")}show(){return this.rmAttr("hidden","aria-hidden")}disable(){return this.setAttr("disabled","").setAttr("aria-disabled","true")}enable(){return this.rmAttr("disabled","aria-disabled")}getHTML(){return this.ref.innerHTML}setHTML(t,r){if(t&&r!==!0)throw new Error("Setting innerHTML is unsafe. Pass true as the second argument to confirm you know what you are doing.");return this.ref.innerHTML=t??"",this}initShadow(t="open",r){let o=this.ref.shadowRoot??this.ref.attachShadow({mode:t});if(f(r)){let{template:a,styles:d}=r;a&&(i(a)?o.innerHTML=a:o.appendChild(a)),N(d)&&d.length&&o.adoptedStyleSheets.push(...d)}return this}get shadow(){return this.ref.shadowRoot?new E(this.ref.shadowRoot):null}};var S=class extends T{getData(t){if(!i(t))throw n("name","a string",t);return this.ref.dataset[t]}hasData(t){if(!i(t))throw n("name","a string",t);return w(this.ref.dataset,t)}setData(t,r){if(typeof t=="string")this.ref.dataset[t]=r;else if(f(t))for(let[o,a]of Object.entries(t))this.ref.dataset[o]=a;else throw n("nameOrObj","a string or object",t);return this}rmData(...t){for(let r of t){if(!i(r))throw n("name","a string",r);delete this.ref.dataset[r]}return this}};var p=class e extends S{static from(t){return new e(t)}static create(t,r){if(!i(t))throw n("tagName","a string like 'div' or 'button'",t);return new e(document.createElement(t,r))}constructor(t){if(!s(t,HTMLElement))throw n("ref","an HTMLElement",t);super(t)}getValue(){if(!w(this.ref,"value"))throw new ReferenceError(`${this.ref.tagName} has no value property.`);return this.ref.value}setValue(t){if(!w(this.ref,"value"))throw new ReferenceError(`${this.ref.tagName} has no value property.`);return this.ref.value=t,this}focus(){return this.ref.focus(),this}click(){return this.ref.click(),this}getText(){return this.ref.innerText}setText(t){return this.ref.innerText=t??"",this}};var D=class e extends u{static from(t){return new e(t)}static fromStr(t){return new e(document.createTextNode(t))}constructor(t){if(!s(t,Text))throw new TypeError(`JJT expects a Text node. Got ${t} (${typeof t}). Create a Text node with JJT.fromStr() or document.createTextNode('text').`);super(t)}getText(){return this.ref.textContent}setText(t){return this.ref.textContent=t??null,this}addText(t){return t!=null&&(this.ref.textContent+=t),this}empty(){return this.setText("")}};var x=class e extends m{static from(t){return new e(t)}constructor(t){if(!s(t,Document))throw new TypeError(`JJD expects a Document instance. Got ${t} (${typeof t}). `);super(t)}get head(){return p.from(this.ref.head)}get body(){return p.from(this.ref.body)}};var Q="http://www.w3.org/2000/svg",k=class e extends S{static from(t){return new e(t)}static create(t,r){if(!i(t))throw n("tagName",'a string like "circle" or "path"',t);let o=document.createElementNS(Q,t,r);return new e(o)}constructor(t){if(!s(t,SVGElement))throw n("ref","an SVGElement",t);super(t)}getText(){return this.ref.textContent??""}setText(t){return this.ref.textContent=t??"",this}setFill(t){return this.setAttr("fill",t)}setStroke(t){return this.setAttr("stroke",t)}setStrokeWidth(t){return this.setAttr("stroke-width",String(t))}setViewBox(t,r,o,a){if(typeof t=="number"&&r!==void 0&&o!==void 0&&a!==void 0)return this.setAttr("viewBox",`${t} ${r} ${o} ${a}`);let d=t;return this.setAttr("viewBox",Array.isArray(d)?d.join(" "):d)}setWidth(t){return this.setAttr("width",String(t))}setHeight(t){return this.setAttr("height",String(t))}setD(t){return this.setAttr("d",Array.isArray(t)?t.join(" "):t)}setTransform(t){return this.setAttr("transform",t)}};u.wrap=function(t){if(i(t))return D.fromStr(t);if(!f(t))throw n("raw","an object",t);if(s(t,u))return t;if(s(t,HTMLElement))return p.from(t);if(s(t,SVGElement))return k.from(t);if(s(t,Element))return T.from(t);if(s(t,ShadowRoot))return E.from(t);if(s(t,DocumentFragment))return l.from(t);if(s(t,Document))return x.from(t);if(s(t,Text))return D.from(t);if(s(t,Node))return u.from(t);throw n("raw","a Node",t)};function ir(e,t,...r){let o=p.create(e).addChild(...r);return t&&o.setAttr(t),o}function X(e){switch(I(e)){case"html":case"htm":case"md":return"fetch";case"css":return"style";case"js":case"mjs":case"cjs":return"script";default:throw new Error(`No 'as' attribute was specified and we failed to guess it from the URL: ${e}`)}}function Y(e,t,r){if(!i(e)){if(!s(e,URL))throw n("href","a string or URL",e);e=e.toString()}if(!["prefetch","preload"].includes(t))throw new RangeError(y("rel","'prefetch' or 'preload'",t));if(!r&&(r=X(e),!r))throw new Error(`Could not guess 'as' attribute from URL: ${e}`);if(!["fetch","style","script"].includes(r))throw new RangeError(y("as","'fetch', 'style', or 'script'",r));return p.create("link").setAttr({href:e,rel:t,as:r})}function sr(...e){let t=Y(...e);return document.head.append(t.ref),t}async function B(e,t="text/*"){if(!i(t))throw n("mime","a string",t);let r=await fetch(e,{headers:{Accept:t}});if(!r.ok)throw new Error(`GET ${e} failed: ${r.status} ${r.statusText}`);return r.text()}async function or(e){return await B(e,"text/html")}async function _(e){return await B(e,"text/css")}async function ar(e){return await C(await _(e))}function hr(e,t,r,o){if(!s(e,HTMLElement))throw n("instance","an HTMLElement",e);if(r!==o){let a=z(t);if(w(e,a))return e[a]=o,!0}return!1}async function mr(e,t,r){if(!i(e))throw n("name","a string",e);if(!g(t))throw n("constructor","a function",t);customElements.get(e)||(customElements.define(e,t,r),await customElements.whenDefined(e))}async function tt(e){if(e!==void 0){if(g(e)&&(e=await e()),e=await e,i(e))return e;if(s(e,l))return e.ref.cloneNode(!0);if(s(e,DocumentFragment))return e.cloneNode(!0);if(s(e,p))return e.ref instanceof HTMLTemplateElement?e.ref.content.cloneNode(!0):e.ref.outerHTML;if(s(e,HTMLElement))return e instanceof HTMLTemplateElement?e.content.cloneNode(!0):e.outerHTML;throw n("template","a string, JJHE, JJDF, HTMLElement, or DocumentFragment",e)}}async function et(e){if(g(e)&&(e=await e()),e=await e,s(e,CSSStyleSheet))return e;if(i(e))return await C(e);throw n("style","a CSS string or CSSStyleSheet",e)}function rt(e){return N(e)?e.map(et):[]}async function nt(e,t){let[r,...o]=await Promise.all([tt(e),...rt(t)]);return{template:r,styles:o}}var R,v,b,U=class U{constructor(){h(this,R);h(this,v,[]);h(this,b)}static create(){return new U}setTemplate(t){return J(this,R,t),this}addStyles(...t){return c(this,v).push(...t),this}async getResolved(){return c(this,b)||J(this,b,nt(c(this,R),c(this,v))),await c(this,b)}};R=new WeakMap,v=new WeakMap,b=new WeakMap;var q=U;var Ar=x.from(document);})();
|
|
1
|
+
"use strict";(()=>{var V=e=>{throw TypeError(e)};var P=(e,t,r)=>t.has(e)||V("Cannot "+r);var h=(e,t,r)=>(P(e,t,"read from private field"),r?r.call(e):t.get(e)),c=(e,t,r)=>t.has(e)?V("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),J=(e,t,r,o)=>(P(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r),G=(e,t,r)=>(P(e,t,"access private method"),r);function R(e){return e!==void 0}function g(e){return typeof e=="function"}var{isNaN:K,isFinite:at,isInteger:ut}=Number;function M(e){return typeof e=="number"&&!K(e)}function F(e,t,r){if(!M(e))throw new TypeError(`inRange(): "x" must be a number. Got ${e} (${typeof e})`);if(R(t)){if(!M(t))throw new TypeError(`inRange(): "min" must be a number. Got ${t} (${typeof t})`);if(R(r)){if(!M(r))throw new TypeError(`inRange(): "max" must be a number. Got ${r} (${typeof r})`);return t>r?r<=e&&e<=t:t<=e&&e<=r}return e>=t}else if(R(r)){if(!M(r))throw new TypeError(`inRange(): "max" must be a number. Got ${r} (${typeof r})`);return e<=r}throw new TypeError(`inRange(): expected at least min or max to be defined. Got min=${t} and max=${r}`)}var{isArray:Z}=Array;function N(e,t=0,r){return Z(e)&&F(e.length,t,r)}var{hasOwnProperty:lt}=Object;function f(e){return!!e&&typeof e=="object"}function i(e,t){if(!g(t))throw new TypeError(`Expected a constructor function. Got ${t} (${typeof t})`);return e instanceof t}function w(e,...t){if(!f(e))return!1;for(let r of t)if(!(r in e))return!1;return!0}function s(e){return typeof e=="string"}var{hasOwnProperty:Jt}=Object,{isArray:At}=Array;function E(e,t,r){return`Expected '${e}' to be ${t}. Got ${r} (${typeof r})`}function n(e,t,r){return new TypeError(E(e,t,r))}function I(e){if(!s(e))throw n("path","a string",e);let t=e.lastIndexOf(".");if(t===-1)return"";let r=e.slice(t+1);return r.indexOf("/")!==-1?"":r.toLowerCase().trim()}function Pt(){return new Promise(e=>requestAnimationFrame(e))}function Gt(e=0){return new Promise(t=>setTimeout(t,e))}async function H(e){return await new CSSStyleSheet().replace(e)}function Ut(e){if(!s(e))throw n("str","a string",e);if(/[^a-zA-Z0-9_]/.test(e))throw new SyntaxError(E("str","alphanumeric characters and underscores",e));return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function Vt(e){if(!s(e))throw n("str","a string",e);return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")||(e.length>0?e.charAt(0).toUpperCase()+e.slice(1):"")}function z(e){if(!s(e))throw n("str","a string",e);return e.replace(/^-+|-+$/g,"").replace(/-+([a-z])/g,(t,r)=>r.toUpperCase())}var A,$,L,O,j=class j{constructor(t){c(this,L);c(this,A);c(this,$,new WeakMap);if(!i(t,EventTarget))throw new TypeError(`JJET expects an EventTarget instance. Got ${t} (${typeof t}). `);J(this,A,t)}static from(t){return new j(t)}get ref(){return h(this,A)}on(t,r,o){let a=G(this,L,O).call(this,r);return this.ref.addEventListener(t,a,o),this}off(t,r,o){let a=G(this,L,O).call(this,r);return this.ref.removeEventListener(t,a,o),this}trigger(t){return this.ref.dispatchEvent(t),this}run(t,...r){return t.call(this,...r)}};A=new WeakMap,$=new WeakMap,L=new WeakSet,O=function(t){if(t===null)return null;let r=h(this,$).get(t);return r||(typeof t=="function"?r=t.bind(this):r={handleEvent:t.handleEvent.bind(this)},h(this,$).set(t,r)),r};var W=j;var u=class e extends W{static from(t){return new e(t)}static isWrappable(t){return s(t)||i(t,Node)||i(t,e)}static wrap(t){if(f(t)){if(i(t,e))return t;if(i(t,Node))return new e(t)}throw n("raw","a Node",t)}static unwrap(t){if(s(t))return document.createTextNode(t);if(!f(t))throw new TypeError(`JJN.unwrap() expects a string, DOM Node, or JJ wrapper. Got ${t} (${typeof t}). `);if(i(t,Node))return t;if(i(t,e))return t.ref;throw new TypeError(`Could not unwrap ${t} (${typeof t}). Expected a string, Node, or JJ wrapper. Make sure you're passing a valid DOM element or JJ wrapper.`)}static wrapAll(t){return Array.from(t,e.wrap)}static unwrapAll(t){return Array.from(t,e.unwrap)}constructor(t){if(!i(t,Node))throw new TypeError(`JJN expects a Node instance. Got ${t} (${typeof t}). Use JJN.from(node) with a DOM Node, or check that you're passing a valid DOM element.`);super(t)}get parent(){let{parentNode:t}=this.ref;return t?e.wrap(t):null}get children(){return e.wrapAll(this.ref.childNodes)}clone(t){return e.wrap(this.ref.cloneNode(t))}rm(){let{parentNode:t}=this.ref;return t&&t.removeChild(this.ref),this}addText(...t){return t&&this.ref.appendChild(document.createTextNode(t.join(""))),this}};var m=class extends u{find(t,r=!1){let o=this.ref.querySelector(t);if(o)return u.wrap(o);if(r)throw new TypeError(`No element matched query "${t}"`);return null}findAll(t){return u.wrapAll(this.ref.querySelectorAll(t))}addChild(...t){let r=u.unwrapAll(t.filter(u.isWrappable));return this.ref.append(...r),this}preChild(...t){let r=u.unwrapAll(t.filter(u.isWrappable));return this.ref.prepend(...r),this}addChildMap(t,r){return this.addChild(...t.map(r))}preChildMap(t,r){return this.preChild(...t.map(r))}setChildren(...t){let r=u.unwrapAll(t.filter(u.isWrappable));return this.ref.replaceChildren(...r),this}empty(){return this.setChildren(),this}};var l=class e extends m{static from(t){return new e(t)}static create(){return new e(document.createDocumentFragment())}constructor(t){if(!i(t,DocumentFragment))throw n("ref","a DocumentFragment",t);super(t)}};var y=class e extends l{static from(t){return new e(t)}constructor(t){if(!i(t,ShadowRoot))throw new TypeError(`JJSR expects a ShadowRoot instance. Got ${t} (${typeof t}). Access a shadow root using element.shadowRoot after calling element.attachShadow().`);super(t)}getHTML(){return this.ref.innerHTML}setHTML(t,r){if(t&&r!==!0)throw new Error("Setting innerHTML is unsafe. Pass true as the second argument to confirm you know what you are doing.");return this.ref.innerHTML=t??"",this}addStyleSheets(...t){return this.ref.adoptedStyleSheets.push(...t),this}};var T=class e extends m{static from(t){return new e(t)}constructor(t){if(!i(t,Element))throw new TypeError(`JJE expects an Element instance. Got ${t} (${typeof t}). Use JJE.from(element) with a DOM Element, or use the specific wrapper (JJHE for HTMLElement, JJSE for SVGElement).`);super(t)}getAttr(t){if(!s(t))throw n("name","a string",t);return this.ref.getAttribute(t)}hasAttr(t){if(!s(t))throw n("name","a string",t);return this.ref.hasAttribute(t)}setAttr(t,r){if(typeof t=="string")this.ref.setAttribute(t,r);else if(f(t))for(let[o,a]of Object.entries(t))this.ref.setAttribute(o,a);else throw n("nameOrObj","a string or object",t);return this}rmAttr(...t){for(let r of t){if(!s(r))throw n("name","a string",r);this.ref.removeAttribute(r)}return this}getAria(t){if(!s(t))throw n("name","a string",t);return this.ref.getAttribute(`aria-${t}`)}hasAria(t){if(!s(t))throw n("name","a string",t);return this.ref.hasAttribute(`aria-${t}`)}setAria(t,r){if(s(t))this.ref.setAttribute(`aria-${t}`,r);else if(f(t))for(let[o,a]of Object.entries(t))this.ref.setAttribute(`aria-${o}`,a);else throw n("nameOrObj","a string or object",t);return this}rmAria(...t){for(let r of t){if(!s(r))throw n("name","a string",r);this.ref.removeAttribute(`aria-${r}`)}return this}getClass(){return this.getAttr("class")}setClass(t){if(typeof t=="string")return this.setAttr("class",t);for(let[r,o]of Object.entries(t))o?this.ref.classList.add(r):this.ref.classList.remove(r);return this}addClass(...t){for(let r of t)if(!s(r))throw n("className","a string",r);return this.ref.classList.add(...t),this}rmClass(...t){for(let r of t)if(!s(r))throw n("className","a string",r);return this.ref.classList.remove(...t),this}hasClass(t){if(!s(t))throw n("className","a string",t);return this.ref.classList.contains(t)}toggleClass(t){if(!s(t))throw n("className","a string",t);return this.ref.classList.toggle(t),this}replaceClass(t,r){if(!s(t))throw n("oldClassName","a string",t);if(!s(r))throw n("newClassName","a string",r);return this.ref.classList.replace(t,r),this}closest(t){if(!s(t))throw n("selector","a string",t);let r=this.ref.closest(t);return r?u.wrap(r):null}hide(){return this.setAttr("hidden","").setAttr("aria-hidden","true")}show(){return this.rmAttr("hidden","aria-hidden")}disable(){return this.setAttr("disabled","").setAttr("aria-disabled","true")}enable(){return this.rmAttr("disabled","aria-disabled")}getHTML(){return this.ref.innerHTML}setHTML(t,r){if(t&&r!==!0)throw new Error("Setting innerHTML is unsafe. Pass true as the second argument to confirm you know what you are doing.");return this.ref.innerHTML=t??"",this}initShadow(t="open",r){let o=this.ref.shadowRoot??this.ref.attachShadow({mode:t});if(f(r)){let{template:a,styles:d}=r;a&&(s(a)?o.innerHTML=a:o.appendChild(a)),N(d)&&d.length&&o.adoptedStyleSheets.push(...d)}return this}get shadow(){return this.ref.shadowRoot?new y(this.ref.shadowRoot):null}};var S=class extends T{getData(t){if(!s(t))throw n("name","a string",t);return this.ref.dataset[t]}hasData(t){if(!s(t))throw n("name","a string",t);return w(this.ref.dataset,t)}setData(t,r){if(typeof t=="string")this.ref.dataset[t]=r;else if(f(t))for(let[o,a]of Object.entries(t))this.ref.dataset[o]=a;else throw n("nameOrObj","a string or object",t);return this}rmData(...t){for(let r of t){if(!s(r))throw n("name","a string",r);delete this.ref.dataset[r]}return this}};var p=class e extends S{static from(t){return new e(t)}static create(t,r){if(!s(t))throw n("tagName","a string like 'div' or 'button'",t);return new e(document.createElement(t,r))}constructor(t){if(!i(t,HTMLElement))throw n("ref","an HTMLElement",t);super(t)}getValue(){if(!w(this.ref,"value"))throw new ReferenceError(`${this.ref.tagName} has no value property.`);return this.ref.value}setValue(t){if(!w(this.ref,"value"))throw new ReferenceError(`${this.ref.tagName} has no value property.`);return this.ref.value=t,this}focus(){return this.ref.focus(),this}click(){return this.ref.click(),this}getText(){return this.ref.innerText}setText(t){return this.ref.innerText=t,this}};var k=class e extends u{static from(t){return new e(t)}static fromStr(t){return new e(document.createTextNode(t))}constructor(t){if(!i(t,Text))throw new TypeError(`JJT expects a Text node. Got ${t} (${typeof t}). Create a Text node with JJT.fromStr() or document.createTextNode('text').`);super(t)}getText(){return this.ref.textContent}setText(t){return this.ref.textContent=t,this}addText(...t){return this.setText(this.getText()+t.join("")),this}empty(){return this.setText("")}};var x=class e extends m{static from(t){return new e(t)}constructor(t){if(!i(t,Document))throw new TypeError(`JJD expects a Document instance. Got ${t} (${typeof t}). `);super(t)}get head(){return p.from(this.ref.head)}get body(){return p.from(this.ref.body)}};var Q="http://www.w3.org/2000/svg",C=class e extends S{static from(t){return new e(t)}static create(t,r){if(!s(t))throw n("tagName",'a string like "circle" or "path"',t);let o=document.createElementNS(Q,t,r);return new e(o)}constructor(t){if(!i(t,SVGElement))throw n("ref","an SVGElement",t);super(t)}getText(){return this.ref.textContent??""}setText(t){return this.ref.textContent=t,this}setFill(t){return this.setAttr("fill",t)}setStroke(t){return this.setAttr("stroke",t)}setStrokeWidth(t){return this.setAttr("stroke-width",String(t))}setViewBox(t,r,o,a){if(typeof t=="number"&&r!==void 0&&o!==void 0&&a!==void 0)return this.setAttr("viewBox",`${t} ${r} ${o} ${a}`);let d=t;return this.setAttr("viewBox",Array.isArray(d)?d.join(" "):d)}setWidth(t){return this.setAttr("width",String(t))}setHeight(t){return this.setAttr("height",String(t))}setD(t){return this.setAttr("d",Array.isArray(t)?t.join(" "):t)}setTransform(t){return this.setAttr("transform",t)}};u.wrap=function(t){if(s(t))return k.fromStr(t);if(!f(t))throw n("raw","an object",t);if(i(t,u))return t;if(i(t,HTMLElement))return p.from(t);if(i(t,SVGElement))return C.from(t);if(i(t,Element))return T.from(t);if(i(t,ShadowRoot))return y.from(t);if(i(t,DocumentFragment))return l.from(t);if(i(t,Document))return x.from(t);if(i(t,Text))return k.from(t);if(i(t,Node))return u.from(t);throw n("raw","a Node",t)};function sr(e,t,...r){let o=p.create(e).addChild(...r);return t&&o.setAttr(t),o}function X(e){switch(I(e)){case"html":case"htm":case"md":return"fetch";case"css":return"style";case"js":case"mjs":case"cjs":return"script";default:throw new Error(`No 'as' attribute was specified and we failed to guess it from the URL: ${e}`)}}function Y(e,t,r){if(!s(e)){if(!i(e,URL))throw n("href","a string or URL",e);e=e.toString()}if(!["prefetch","preload"].includes(t))throw new RangeError(E("rel","'prefetch' or 'preload'",t));if(!r&&(r=X(e),!r))throw new Error(`Could not guess 'as' attribute from URL: ${e}`);if(!["fetch","style","script"].includes(r))throw new RangeError(E("as","'fetch', 'style', or 'script'",r));return p.create("link").setAttr({href:e,rel:t,as:r})}function or(...e){let t=Y(...e);return document.head.append(t.ref),t}async function B(e,t="text/*"){if(!s(t))throw n("mime","a string",t);let r=await fetch(e,{headers:{Accept:t}});if(!r.ok)throw new Error(`GET ${e} failed: ${r.status} ${r.statusText}`);return r.text()}async function ar(e){return await B(e,"text/html")}async function _(e){return await B(e,"text/css")}async function ur(e){return await H(await _(e))}function mr(e,t,r,o){if(!i(e,HTMLElement))throw n("instance","an HTMLElement",e);if(r!==o){let a=z(t);if(w(e,a))return e[a]=o,!0}return!1}async function lr(e,t,r){if(!s(e))throw n("name","a string",e);if(!g(t))throw n("constructor","a function",t);customElements.get(e)||(customElements.define(e,t,r),await customElements.whenDefined(e))}async function tt(e){if(e!==void 0){if(g(e)&&(e=await e()),e=await e,s(e))return e;if(i(e,l))return e.ref.cloneNode(!0);if(i(e,DocumentFragment))return e.cloneNode(!0);if(i(e,p))return e.ref instanceof HTMLTemplateElement?e.ref.content.cloneNode(!0):e.ref.outerHTML;if(i(e,HTMLElement))return e instanceof HTMLTemplateElement?e.content.cloneNode(!0):e.outerHTML;throw n("template","a string, JJHE, JJDF, HTMLElement, or DocumentFragment",e)}}async function et(e){if(g(e)&&(e=await e()),e=await e,i(e,CSSStyleSheet))return e;if(s(e))return await H(e);throw n("style","a CSS string or CSSStyleSheet",e)}function rt(e){return N(e)?e.map(et):[]}async function nt(e,t){let[r,...o]=await Promise.all([tt(e),...rt(t)]);return{template:r,styles:o}}var D,v,b,U=class U{constructor(){c(this,D);c(this,v,[]);c(this,b)}static create(){return new U}setTemplate(t){return J(this,D,t),this}addStyles(...t){return h(this,v).push(...t),this}async getResolved(){return h(this,b)||J(this,b,nt(h(this,D),h(this,v))),await h(this,b)}};D=new WeakMap,v=new WeakMap,b=new WeakMap;var q=U;var $r=x.from(document);})();
|
|
2
2
|
//# sourceMappingURL=bundle.min.global.js.map
|