jj 2.2.0 → 2.3.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/lib/JJD.d.ts +76 -0
- package/lib/JJD.js +91 -0
- package/lib/JJD.js.map +1 -0
- package/lib/JJDF.d.ts +60 -0
- package/lib/JJDF.js +68 -0
- package/lib/JJDF.js.map +1 -0
- package/lib/JJE.d.ts +313 -0
- package/lib/JJE.js +412 -0
- package/lib/JJE.js.map +1 -0
- package/lib/JJHE.d.ts +120 -0
- package/lib/JJHE.js +164 -0
- package/lib/JJHE.js.map +1 -0
- package/lib/JJN.d.ts +211 -0
- package/lib/JJN.js +286 -0
- package/lib/JJN.js.map +1 -0
- package/lib/JJSE.d.ts +148 -0
- package/lib/JJSE.js +190 -0
- package/lib/JJSE.js.map +1 -0
- package/lib/JJSR.d.ts +67 -0
- package/lib/JJSR.js +85 -0
- package/lib/JJSR.js.map +1 -0
- package/lib/JJT.d.ts +79 -0
- package/lib/JJT.js +108 -0
- package/lib/JJT.js.map +1 -0
- package/lib/bundle.d.ts +1 -0
- package/lib/bundle.js +1505 -445
- package/lib/bundle.js.map +3 -3
- package/lib/bundle.min.d.ts +1 -0
- package/lib/bundle.min.js +2 -2
- package/lib/case.d.ts +57 -0
- package/lib/case.js +61 -3
- package/lib/case.js.map +1 -1
- package/lib/components.d.ts +147 -0
- package/lib/components.js +286 -0
- package/lib/components.js.map +1 -0
- package/lib/helpers.d.ts +158 -0
- package/lib/helpers.js +231 -0
- package/lib/helpers.js.map +1 -0
- package/lib/index.d.ts +13 -12
- package/lib/index.js +13 -12
- package/lib/index.js.map +1 -1
- package/lib/mixin-types.d.ts +143 -0
- package/lib/mixin-types.js +2 -0
- package/lib/mixin-types.js.map +1 -0
- package/lib/mixins.d.ts +94 -0
- package/lib/mixins.js +359 -0
- package/lib/mixins.js.map +1 -0
- package/lib/types.d.ts +77 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/util.d.ts +90 -2
- package/lib/util.js +106 -2
- package/lib/util.js.map +1 -1
- package/lib/util.test.d.ts +1 -0
- package/lib/util.test.js +46 -0
- package/lib/util.test.js.map +1 -0
- package/package.json +16 -7
- package/lib/WC.d.ts +0 -41
- package/lib/WC.js +0 -117
- package/lib/WC.js.map +0 -1
- package/lib/WD.d.ts +0 -8
- package/lib/WD.js +0 -17
- package/lib/WD.js.map +0 -1
- package/lib/WDF.d.ts +0 -9
- package/lib/WDF.js +0 -20
- package/lib/WDF.js.map +0 -1
- package/lib/WE.d.ts +0 -43
- package/lib/WE.js +0 -131
- package/lib/WE.js.map +0 -1
- package/lib/WHE.d.ts +0 -21
- package/lib/WHE.js +0 -75
- package/lib/WHE.js.map +0 -1
- package/lib/WN-mixin.d.ts +0 -9
- package/lib/WN-mixin.js +0 -59
- package/lib/WN-mixin.js.map +0 -1
- package/lib/WN.d.ts +0 -47
- package/lib/WN.js +0 -194
- package/lib/WN.js.map +0 -1
- package/lib/WSE.d.ts +0 -25
- package/lib/WSE.js +0 -84
- package/lib/WSE.js.map +0 -1
- package/lib/WSH.d.ts +0 -11
- package/lib/WSH.js +0 -29
- package/lib/WSH.js.map +0 -1
- package/lib/WT.d.ts +0 -12
- package/lib/WT.js +0 -39
- package/lib/WT.js.map +0 -1
- package/lib/fetch.d.ts +0 -31
- package/lib/fetch.js +0 -69
- package/lib/fetch.js.map +0 -1
- package/lib/h.d.ts +0 -3
- package/lib/h.js +0 -9
- package/lib/h.js.map +0 -1
package/lib/JJD.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { JJN } from './JJN.js';
|
|
2
|
+
import { IAppendPrepend, IById, IQuery } from './mixin-types.js';
|
|
3
|
+
export interface JJD<T extends Document> extends IById, IQuery, IAppendPrepend {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Wraps a Document (which is a descendant of Node).
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* This class provides a wrapper around the native `Document` interface, inheriting
|
|
10
|
+
* the fluent API capabilities of `JJN`.
|
|
11
|
+
* It also supports querying (`byId`, `query`) and manipulation (`append`, `prepend`) methods.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const doc = JJD.from(document)
|
|
16
|
+
* doc.on('DOMContentLoaded', () => console.log('Ready'))
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document | Document}
|
|
20
|
+
*/
|
|
21
|
+
export declare class JJD<T extends Document = Document> extends JJN<T> {
|
|
22
|
+
/**
|
|
23
|
+
* Creates a JJD instance from a Document reference.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const doc = JJD.from(document)
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @param ref - The Document instance.
|
|
31
|
+
* @returns A new JJD instance.
|
|
32
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document | Document}
|
|
33
|
+
*/
|
|
34
|
+
static from(ref: Document): JJD;
|
|
35
|
+
/**
|
|
36
|
+
* Creates an instance of JJD.
|
|
37
|
+
*
|
|
38
|
+
* @param ref - The Document instance to wrap.
|
|
39
|
+
* @throws {TypeError} If `ref` is not a Document.
|
|
40
|
+
*/
|
|
41
|
+
constructor(ref: T);
|
|
42
|
+
/**
|
|
43
|
+
* Gets the `<head>` element of the document wrapped in a `JJHE` instance.
|
|
44
|
+
*
|
|
45
|
+
* @returns The wrapped head element.
|
|
46
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/head | Document.head}
|
|
47
|
+
*/
|
|
48
|
+
get head(): import("./types.js").Wrapped;
|
|
49
|
+
/**
|
|
50
|
+
* Gets the `<body>` element of the document wrapped in a `JJHE` instance.
|
|
51
|
+
*
|
|
52
|
+
* @returns The wrapped body element.
|
|
53
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/body | Document.body}
|
|
54
|
+
*/
|
|
55
|
+
get body(): import("./types.js").Wrapped;
|
|
56
|
+
/**
|
|
57
|
+
* Sets the document title.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* JJD.from(document).setTitle('New Page Title')
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @param title - The new title string.
|
|
65
|
+
* @returns This instance for chaining.
|
|
66
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/title | Document.title}
|
|
67
|
+
*/
|
|
68
|
+
setTitle(title: string): this;
|
|
69
|
+
/**
|
|
70
|
+
* Gets the document title.
|
|
71
|
+
*
|
|
72
|
+
* @returns The current title of the document.
|
|
73
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/title | Document.title}
|
|
74
|
+
*/
|
|
75
|
+
getTitle(): string;
|
|
76
|
+
}
|
package/lib/JJD.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { isA } from 'jty';
|
|
2
|
+
import { JJN } from './JJN.js';
|
|
3
|
+
/**
|
|
4
|
+
* Wraps a Document (which is a descendant of Node).
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This class provides a wrapper around the native `Document` interface, inheriting
|
|
8
|
+
* the fluent API capabilities of `JJN`.
|
|
9
|
+
* It also supports querying (`byId`, `query`) and manipulation (`append`, `prepend`) methods.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const doc = JJD.from(document)
|
|
14
|
+
* doc.on('DOMContentLoaded', () => console.log('Ready'))
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document | Document}
|
|
18
|
+
*/
|
|
19
|
+
export class JJD extends JJN {
|
|
20
|
+
/**
|
|
21
|
+
* Creates a JJD instance from a Document reference.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const doc = JJD.from(document)
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param ref - The Document instance.
|
|
29
|
+
* @returns A new JJD instance.
|
|
30
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document | Document}
|
|
31
|
+
*/
|
|
32
|
+
static from(ref) {
|
|
33
|
+
return new JJD(ref);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates an instance of JJD.
|
|
37
|
+
*
|
|
38
|
+
* @param ref - The Document instance to wrap.
|
|
39
|
+
* @throws {TypeError} If `ref` is not a Document.
|
|
40
|
+
*/
|
|
41
|
+
constructor(ref) {
|
|
42
|
+
if (!isA(ref, Document)) {
|
|
43
|
+
throw new TypeError(`Expected a Document. Got ${ref} (${typeof ref})`);
|
|
44
|
+
}
|
|
45
|
+
super(ref);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Gets the `<head>` element of the document wrapped in a `JJHE` instance.
|
|
49
|
+
*
|
|
50
|
+
* @returns The wrapped head element.
|
|
51
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/head | Document.head}
|
|
52
|
+
*/
|
|
53
|
+
get head() {
|
|
54
|
+
return JJN.wrap(this.ref.head);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Gets the `<body>` element of the document wrapped in a `JJHE` instance.
|
|
58
|
+
*
|
|
59
|
+
* @returns The wrapped body element.
|
|
60
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/body | Document.body}
|
|
61
|
+
*/
|
|
62
|
+
get body() {
|
|
63
|
+
return JJN.wrap(this.ref.body);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Sets the document title.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* JJD.from(document).setTitle('New Page Title')
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @param title - The new title string.
|
|
74
|
+
* @returns This instance for chaining.
|
|
75
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/title | Document.title}
|
|
76
|
+
*/
|
|
77
|
+
setTitle(title) {
|
|
78
|
+
this.ref.title = title;
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Gets the document title.
|
|
83
|
+
*
|
|
84
|
+
* @returns The current title of the document.
|
|
85
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/title | Document.title}
|
|
86
|
+
*/
|
|
87
|
+
getTitle() {
|
|
88
|
+
return this.ref.title;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=JJD.js.map
|
package/lib/JJD.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JJD.js","sourceRoot":"","sources":["../src/JJD.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACzB,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAK9B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,GAAmC,SAAQ,GAAM;IAC1D;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAAI,CAAC,GAAa;QACrB,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;IAED;;;;;OAKG;IACH,YAAY,GAAM;QACd,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,SAAS,CAAC,4BAA4B,GAAG,KAAK,OAAO,GAAG,GAAG,CAAC,CAAA;QAC1E,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,CAAA;IACd,CAAC;IAED;;;;;OAKG;IACH,IAAI,IAAI;QACJ,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;IAED;;;;;OAKG;IACH,IAAI,IAAI;QACJ,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;IAED;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,KAAa;QAClB,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,KAAK,CAAA;QACtB,OAAO,IAAI,CAAA;IACf,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAA;IACzB,CAAC;CACJ"}
|
package/lib/JJDF.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { JJN } from './JJN.js';
|
|
2
|
+
import { IAppendPrepend, IById, IQuery } from './mixin-types.js';
|
|
3
|
+
export interface JJDF<T extends DocumentFragment> extends IById, IQuery, IAppendPrepend {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Wraps a DocumentFragment (which is a descendant of Node).
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* DocumentFragments are lightweight versions of Document that store a segment of a document structure
|
|
10
|
+
* comprised of nodes just like a standard document. The key difference is that because the document fragment
|
|
11
|
+
* isn't part of the active document tree structure, changes made to the fragment don't affect the document,
|
|
12
|
+
* cause reflow, or incur any performance impact that can occur when changes are made.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const frag = JJDF.create()
|
|
17
|
+
* frag.append(
|
|
18
|
+
* h('div', null, 'Item 1'),
|
|
19
|
+
* h('div', null, 'Item 2'),
|
|
20
|
+
* )
|
|
21
|
+
* document.body.appendChild(frag.ref)
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment | DocumentFragment}
|
|
25
|
+
*/
|
|
26
|
+
export declare class JJDF<T extends DocumentFragment = DocumentFragment> extends JJN<T> {
|
|
27
|
+
/**
|
|
28
|
+
* Creates a JJDF instance from a DocumentFragment reference.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const frag = JJDF.from(myFrag)
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
*
|
|
36
|
+
* @param ref - The DocumentFragment instance.
|
|
37
|
+
* @returns A new JJDF instance.
|
|
38
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment | DocumentFragment}
|
|
39
|
+
*/
|
|
40
|
+
static from(ref: DocumentFragment): JJDF;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new empty JJDF instance (wraps a new DocumentFragment).
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const frag = JJDF.create()
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @returns A new JJDF instance.
|
|
50
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/createDocumentFragment | document.createDocumentFragment}
|
|
51
|
+
*/
|
|
52
|
+
static create(): JJDF<DocumentFragment>;
|
|
53
|
+
/**
|
|
54
|
+
* Creates an instance of JJDF.
|
|
55
|
+
*
|
|
56
|
+
* @param ref - The DocumentFragment instance to wrap.
|
|
57
|
+
* @throws {TypeError} If `ref` is not a DocumentFragment.
|
|
58
|
+
*/
|
|
59
|
+
constructor(ref: T);
|
|
60
|
+
}
|
package/lib/JJDF.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { isA } from 'jty';
|
|
2
|
+
import { JJN } from './JJN.js';
|
|
3
|
+
/**
|
|
4
|
+
* Wraps a DocumentFragment (which is a descendant of Node).
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* DocumentFragments are lightweight versions of Document that store a segment of a document structure
|
|
8
|
+
* comprised of nodes just like a standard document. The key difference is that because the document fragment
|
|
9
|
+
* isn't part of the active document tree structure, changes made to the fragment don't affect the document,
|
|
10
|
+
* cause reflow, or incur any performance impact that can occur when changes are made.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const frag = JJDF.create()
|
|
15
|
+
* frag.append(
|
|
16
|
+
* h('div', null, 'Item 1'),
|
|
17
|
+
* h('div', null, 'Item 2'),
|
|
18
|
+
* )
|
|
19
|
+
* document.body.appendChild(frag.ref)
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment | DocumentFragment}
|
|
23
|
+
*/
|
|
24
|
+
export class JJDF extends JJN {
|
|
25
|
+
/**
|
|
26
|
+
* Creates a JJDF instance from a DocumentFragment reference.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const frag = JJDF.from(myFrag)
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
*
|
|
34
|
+
* @param ref - The DocumentFragment instance.
|
|
35
|
+
* @returns A new JJDF instance.
|
|
36
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment | DocumentFragment}
|
|
37
|
+
*/
|
|
38
|
+
static from(ref) {
|
|
39
|
+
return new JJDF(ref);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new empty JJDF instance (wraps a new DocumentFragment).
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const frag = JJDF.create()
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @returns A new JJDF instance.
|
|
50
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/createDocumentFragment | document.createDocumentFragment}
|
|
51
|
+
*/
|
|
52
|
+
static create() {
|
|
53
|
+
return new JJDF(document.createDocumentFragment());
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Creates an instance of JJDF.
|
|
57
|
+
*
|
|
58
|
+
* @param ref - The DocumentFragment instance to wrap.
|
|
59
|
+
* @throws {TypeError} If `ref` is not a DocumentFragment.
|
|
60
|
+
*/
|
|
61
|
+
constructor(ref) {
|
|
62
|
+
if (!isA(ref, DocumentFragment)) {
|
|
63
|
+
throw new TypeError(`Expected a DocumentFragment. Got ${ref} (${typeof ref})`);
|
|
64
|
+
}
|
|
65
|
+
super(ref);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=JJDF.js.map
|
package/lib/JJDF.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JJDF.js","sourceRoot":"","sources":["../src/JJDF.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACzB,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAK9B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,IAAoD,SAAQ,GAAM;IAC3E;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,IAAI,CAAC,GAAqB;QAC7B,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,MAAM;QACT,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,sBAAsB,EAAE,CAAC,CAAA;IACtD,CAAC;IAED;;;;;OAKG;IACH,YAAY,GAAM;QACd,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,gBAAgB,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,SAAS,CAAC,oCAAoC,GAAG,KAAK,OAAO,GAAG,GAAG,CAAC,CAAA;QAClF,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,CAAA;IACd,CAAC;CACJ"}
|
package/lib/JJE.d.ts
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { JJN } from './JJN.js';
|
|
2
|
+
import { JJSR } from './JJSR.js';
|
|
3
|
+
import { IAppendPrepend, IById, IQuery } from './mixin-types.js';
|
|
4
|
+
import { ShadowConfig, Wrapped } from './types.js';
|
|
5
|
+
export interface JJE<T extends Element> extends IQuery, IAppendPrepend {
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Wraps a DOM Element (which is a descendant of Node).
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* This class provides a wrapper around the native `Element` interface, adding fluent API methods
|
|
12
|
+
* for attribute manipulation, class handling, and event binding.
|
|
13
|
+
*
|
|
14
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element | Element}
|
|
15
|
+
*/
|
|
16
|
+
export declare class JJE<T extends Element = Element> extends JJN<T> implements IById {
|
|
17
|
+
/**
|
|
18
|
+
* Creates a JJE instance from an Element reference.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const el = JJE.from(document.querySelector('.my-class'))
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @param ref - The Element instance.
|
|
26
|
+
* @returns A new JJE instance.
|
|
27
|
+
*/
|
|
28
|
+
static from(ref: Element): JJE;
|
|
29
|
+
/**
|
|
30
|
+
* Creates an instance of JJE.
|
|
31
|
+
*
|
|
32
|
+
* @param ref - The Element to wrap.
|
|
33
|
+
* @throws {TypeError} If `ref` is not an Element.
|
|
34
|
+
*/
|
|
35
|
+
constructor(ref: T);
|
|
36
|
+
/**
|
|
37
|
+
* Finds an element by ID within this element's context
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* This method uses `Element.querySelector()` under the hood.
|
|
41
|
+
*
|
|
42
|
+
* @param id - The ID to search for.
|
|
43
|
+
* @param throwIfNotFound - Whether to throw an error if not found. Defaults to true.
|
|
44
|
+
* @returns The wrapped element, or null if not found and throwIfNotFound is false.
|
|
45
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector | Element.querySelector}
|
|
46
|
+
*/
|
|
47
|
+
byId(id: string, throwIfNotFound?: boolean): Wrapped | null;
|
|
48
|
+
/**
|
|
49
|
+
* Gets the value of an attribute.
|
|
50
|
+
*
|
|
51
|
+
* @param name - The name of the attribute.
|
|
52
|
+
* @returns The attribute value, or null if not present.
|
|
53
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute | Element.getAttribute}
|
|
54
|
+
*/
|
|
55
|
+
getAttr(name: string): string | null;
|
|
56
|
+
/**
|
|
57
|
+
* Checks if an attribute exists.
|
|
58
|
+
*
|
|
59
|
+
* @param name - The name of the attribute.
|
|
60
|
+
* @returns `true` if the attribute exists, otherwise `false`.
|
|
61
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute | Element.hasAttribute}
|
|
62
|
+
*/
|
|
63
|
+
hasAttr(name: string): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Sets the value of an attribute.
|
|
66
|
+
*
|
|
67
|
+
* @param name - The name of the attribute.
|
|
68
|
+
* @param value - The value to set.
|
|
69
|
+
* @returns This instance for chaining.
|
|
70
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute | Element.setAttribute}
|
|
71
|
+
*/
|
|
72
|
+
setAttr(name: string, value: string): this;
|
|
73
|
+
/**
|
|
74
|
+
* Sets multiple attributes at once.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* el.setAttrs({ id: 'my-id', class: 'my-class' })
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @param obj - An object where keys are attribute names and values are attribute values.
|
|
82
|
+
* @returns This instance for chaining.
|
|
83
|
+
* @throws {TypeError} If `obj` is not an object.
|
|
84
|
+
*/
|
|
85
|
+
setAttrs(obj: Record<string, string>): this;
|
|
86
|
+
/**
|
|
87
|
+
* Removes an attribute.
|
|
88
|
+
*
|
|
89
|
+
* @param name - The name of the attribute to remove.
|
|
90
|
+
* @returns This instance for chaining.
|
|
91
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute | Element.removeAttribute}
|
|
92
|
+
*/
|
|
93
|
+
rmAttr(name: string): this;
|
|
94
|
+
/**
|
|
95
|
+
* Removes multiple attributes.
|
|
96
|
+
*
|
|
97
|
+
* @param names - The names of the attributes to remove.
|
|
98
|
+
* @returns This instance for chaining.
|
|
99
|
+
*/
|
|
100
|
+
rmAttrs(...names: string[]): this;
|
|
101
|
+
/**
|
|
102
|
+
* Gets the value of an ARIA attribute.
|
|
103
|
+
*
|
|
104
|
+
* @remarks
|
|
105
|
+
* Automatically prepends `aria-` to the name.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* el.getAria('label') // gets 'aria-label'
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @param name - The ARIA attribute suffix (e.g., 'label' for 'aria-label').
|
|
113
|
+
* @returns The attribute value, or null if not present.
|
|
114
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes | ARIA Attributes}
|
|
115
|
+
*/
|
|
116
|
+
getAria(name: string): string | null;
|
|
117
|
+
/**
|
|
118
|
+
* Checks if an ARIA attribute exists.
|
|
119
|
+
*
|
|
120
|
+
* @param name - The ARIA attribute suffix.
|
|
121
|
+
* @returns `true` if the attribute exists.
|
|
122
|
+
*/
|
|
123
|
+
hasAria(name: string): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Sets an ARIA attribute.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* el.setAria('hidden', 'true') // sets aria-hidden="true"
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* @param name - The ARIA attribute suffix.
|
|
133
|
+
* @param value - The value to set.
|
|
134
|
+
* @returns This instance for chaining.
|
|
135
|
+
*/
|
|
136
|
+
setAria(name: string, value: string): this;
|
|
137
|
+
/**
|
|
138
|
+
* Removes an ARIA attribute.
|
|
139
|
+
*
|
|
140
|
+
* @param name - The ARIA attribute suffix.
|
|
141
|
+
* @returns This instance for chaining.
|
|
142
|
+
*/
|
|
143
|
+
rmAria(name: string): this;
|
|
144
|
+
/**
|
|
145
|
+
* Gets the class attribute.
|
|
146
|
+
*
|
|
147
|
+
* @returns The class attribute value, or null if not present.
|
|
148
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/className | Element.className}
|
|
149
|
+
*/
|
|
150
|
+
getClass(): string | null;
|
|
151
|
+
/**
|
|
152
|
+
* Sets the class attribute.
|
|
153
|
+
*
|
|
154
|
+
* @param className - The class string to set.
|
|
155
|
+
* @returns This instance for chaining.
|
|
156
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/className | Element.className}
|
|
157
|
+
*/
|
|
158
|
+
setClass(className: string): this;
|
|
159
|
+
/**
|
|
160
|
+
* Removes the `class` attribute of the element.
|
|
161
|
+
*
|
|
162
|
+
* @remarks
|
|
163
|
+
* If you want to remove a few specific class instead of all, use `rmClasses`
|
|
164
|
+
*
|
|
165
|
+
* @returns This instance for chaining.
|
|
166
|
+
*/
|
|
167
|
+
rmClass(): this;
|
|
168
|
+
/**
|
|
169
|
+
* Adds one or more classes to the element.
|
|
170
|
+
*
|
|
171
|
+
* @param classNames - The classes to add.
|
|
172
|
+
* @returns This instance for chaining.
|
|
173
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/classList | Element.classList}
|
|
174
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList/add | DOMTokenList.add}
|
|
175
|
+
*/
|
|
176
|
+
addClass(...classNames: string[]): this;
|
|
177
|
+
/**
|
|
178
|
+
* Removes one or more classes from the element.
|
|
179
|
+
*
|
|
180
|
+
* @param classNames - The classes to remove.
|
|
181
|
+
* @returns This instance for chaining.
|
|
182
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/classList | Element.classList}
|
|
183
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList/remove | DOMTokenList.remove}
|
|
184
|
+
*/
|
|
185
|
+
rmClasses(...classNames: string[]): this;
|
|
186
|
+
/**
|
|
187
|
+
* Checks if the element has a specific class.
|
|
188
|
+
*
|
|
189
|
+
* @param className - The class to check for.
|
|
190
|
+
* @returns `true` if the element has the class.
|
|
191
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/classList | Element.classList}
|
|
192
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList/contains | DOMTokenList.contains}
|
|
193
|
+
*/
|
|
194
|
+
hasClass(className: string): boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Toggles a class on the element.
|
|
197
|
+
*
|
|
198
|
+
* @param className - The class to toggle.
|
|
199
|
+
* @returns This instance for chaining.
|
|
200
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/classList | Element.classList}
|
|
201
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList/toggle | DOMTokenList.toggle}
|
|
202
|
+
*/
|
|
203
|
+
toggleClass(className: string): this;
|
|
204
|
+
/**
|
|
205
|
+
* Replaces a class with another one
|
|
206
|
+
*
|
|
207
|
+
* @remarks
|
|
208
|
+
* If the `oldClassName` doesn't exist, the `newClassName` isn't added
|
|
209
|
+
*
|
|
210
|
+
* @param oldClassName - The class name to remove
|
|
211
|
+
* @param newClassName - The class name to add
|
|
212
|
+
*/
|
|
213
|
+
replaceClass(oldClassName: string, newClassName: string): this;
|
|
214
|
+
/**
|
|
215
|
+
* Adds a click event listener.
|
|
216
|
+
*
|
|
217
|
+
* @param handler - The event handler.
|
|
218
|
+
* @returns This instance for chaining.
|
|
219
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener | EventTarget.addEventListener}
|
|
220
|
+
*/
|
|
221
|
+
onClick(handler: EventListenerOrEventListenerObject): this;
|
|
222
|
+
/**
|
|
223
|
+
* Hides the element by setting the `hidden` attribute and `aria-hidden="true"`.
|
|
224
|
+
*
|
|
225
|
+
* @returns This instance for chaining.
|
|
226
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden | hidden attribute}
|
|
227
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-hidden | aria-hidden}
|
|
228
|
+
*/
|
|
229
|
+
hide(): this;
|
|
230
|
+
/**
|
|
231
|
+
* Shows the element by removing the `hidden` and `aria-hidden` attributes.
|
|
232
|
+
*
|
|
233
|
+
* @returns This instance for chaining.
|
|
234
|
+
*/
|
|
235
|
+
show(): this;
|
|
236
|
+
/**
|
|
237
|
+
* Disables the element by setting the `disabled` attribute and `aria-disabled="true"`.
|
|
238
|
+
*
|
|
239
|
+
* @returns This instance for chaining.
|
|
240
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled | disabled attribute}
|
|
241
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled | aria-disabled}
|
|
242
|
+
*/
|
|
243
|
+
disable(): this;
|
|
244
|
+
/**
|
|
245
|
+
* Enables the element by removing the `disabled` and `aria-disabled` attributes.
|
|
246
|
+
*
|
|
247
|
+
* @returns This instance for chaining.
|
|
248
|
+
*/
|
|
249
|
+
enable(): this;
|
|
250
|
+
/**
|
|
251
|
+
* Gets the title attribute.
|
|
252
|
+
*
|
|
253
|
+
* @returns The title, or null if not set.
|
|
254
|
+
*/
|
|
255
|
+
getTitle(): string | null;
|
|
256
|
+
/**
|
|
257
|
+
* Sets the title attribute.
|
|
258
|
+
*
|
|
259
|
+
* @param title - The title to set.
|
|
260
|
+
* @returns This instance for chaining.
|
|
261
|
+
*/
|
|
262
|
+
setTitle(title: string): this;
|
|
263
|
+
/**
|
|
264
|
+
* Sets the id attribute.
|
|
265
|
+
*
|
|
266
|
+
* @param id - The id to set.
|
|
267
|
+
* @returns This instance for chaining.
|
|
268
|
+
*/
|
|
269
|
+
setId(id: string): this;
|
|
270
|
+
/**
|
|
271
|
+
* Gets the id attribute.
|
|
272
|
+
*
|
|
273
|
+
* @returns The id, or null if not set.
|
|
274
|
+
*/
|
|
275
|
+
getId(): string | null;
|
|
276
|
+
/**
|
|
277
|
+
* Gets the inner HTML of the element.
|
|
278
|
+
*
|
|
279
|
+
* @returns The inner HTML string.
|
|
280
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML | Element.innerHTML}
|
|
281
|
+
*/
|
|
282
|
+
getHTML(): string;
|
|
283
|
+
/**
|
|
284
|
+
* Sets the inner HTML of the element.
|
|
285
|
+
*
|
|
286
|
+
* @param html - The HTML string to set.
|
|
287
|
+
* @returns This instance for chaining.
|
|
288
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML | Element.innerHTML}
|
|
289
|
+
*/
|
|
290
|
+
setHTML(html: string): this;
|
|
291
|
+
/**
|
|
292
|
+
* Attaches a Shadow DOM to the element and optionally sets its content and styles.
|
|
293
|
+
*
|
|
294
|
+
* @remarks
|
|
295
|
+
* We prevent FOUC by assigning the template and CSS in one go.
|
|
296
|
+
* **Note:** You can't attach a shadow root to every type of element. There are some that can't have a
|
|
297
|
+
* shadow DOM for security reasons (for example `<a>`).
|
|
298
|
+
*
|
|
299
|
+
* @param mode - The encapsulation mode ('open' or 'closed'). Defaults to 'open'.
|
|
300
|
+
* @param config - Optional configuration object containing `template` (HTML string) and `styles` (array of CSSStyleSheet).
|
|
301
|
+
* @returns This instance for chaining.
|
|
302
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/attachShadow | Element.attachShadow}
|
|
303
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets | ShadowRoot.adoptedStyleSheets}
|
|
304
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/adoptedStyleSheets | Document.adoptedStyleSheets}
|
|
305
|
+
*/
|
|
306
|
+
initShadow(mode?: ShadowRootMode, config?: ShadowConfig): this;
|
|
307
|
+
/**
|
|
308
|
+
* Gets a wrapper around the element's Shadow Root, if it exists.
|
|
309
|
+
*
|
|
310
|
+
* @returns A JJSR instance wrapping the shadow root, or null if no shadow root exists.
|
|
311
|
+
*/
|
|
312
|
+
get shadow(): JJSR<ShadowRoot> | null;
|
|
313
|
+
}
|