jj 2.5.0 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +29 -2
  2. package/SKILL.md +667 -0
  3. package/lib/bundle.cjs +2031 -0
  4. package/lib/bundle.cjs.map +1 -0
  5. package/lib/bundle.d.cts +1782 -0
  6. package/lib/bundle.d.ts +1782 -1
  7. package/lib/bundle.global.js +1953 -0
  8. package/lib/bundle.global.js.map +1 -0
  9. package/lib/bundle.js +232 -230
  10. package/lib/bundle.js.map +1 -7
  11. package/lib/bundle.min.cjs +2 -0
  12. package/lib/bundle.min.cjs.map +1 -0
  13. package/lib/bundle.min.d.cts +1782 -0
  14. package/lib/bundle.min.d.ts +1782 -1
  15. package/lib/bundle.min.global.js +2 -0
  16. package/lib/bundle.min.global.js.map +1 -0
  17. package/lib/bundle.min.js +2 -1
  18. package/lib/bundle.min.js.map +1 -0
  19. package/package.json +8 -17
  20. package/lib/JJD.d.ts +0 -87
  21. package/lib/JJD.js +0 -119
  22. package/lib/JJD.js.map +0 -1
  23. package/lib/JJDF.d.ts +0 -74
  24. package/lib/JJDF.js +0 -98
  25. package/lib/JJDF.js.map +0 -1
  26. package/lib/JJE.d.ts +0 -299
  27. package/lib/JJE.js +0 -401
  28. package/lib/JJE.js.map +0 -1
  29. package/lib/JJET.d.ts +0 -79
  30. package/lib/JJET.js +0 -114
  31. package/lib/JJET.js.map +0 -1
  32. package/lib/JJEx.d.ts +0 -63
  33. package/lib/JJEx.js +0 -83
  34. package/lib/JJEx.js.map +0 -1
  35. package/lib/JJHE.d.ts +0 -109
  36. package/lib/JJHE.js +0 -136
  37. package/lib/JJHE.js.map +0 -1
  38. package/lib/JJN-wrap.d.ts +0 -1
  39. package/lib/JJN-wrap.js +0 -46
  40. package/lib/JJN-wrap.js.map +0 -1
  41. package/lib/JJN.d.ts +0 -126
  42. package/lib/JJN.js +0 -166
  43. package/lib/JJN.js.map +0 -1
  44. package/lib/JJNx.d.ts +0 -126
  45. package/lib/JJNx.js +0 -157
  46. package/lib/JJNx.js.map +0 -1
  47. package/lib/JJSE.d.ts +0 -170
  48. package/lib/JJSE.js +0 -217
  49. package/lib/JJSE.js.map +0 -1
  50. package/lib/JJSR.d.ts +0 -71
  51. package/lib/JJSR.js +0 -90
  52. package/lib/JJSR.js.map +0 -1
  53. package/lib/JJT.d.ts +0 -92
  54. package/lib/JJT.js +0 -116
  55. package/lib/JJT.js.map +0 -1
  56. package/lib/case.d.ts +0 -60
  57. package/lib/case.js +0 -92
  58. package/lib/case.js.map +0 -1
  59. package/lib/components.d.ts +0 -147
  60. package/lib/components.js +0 -287
  61. package/lib/components.js.map +0 -1
  62. package/lib/helpers.d.ts +0 -159
  63. package/lib/helpers.js +0 -233
  64. package/lib/helpers.js.map +0 -1
  65. package/lib/index.d.ts +0 -33
  66. package/lib/index.js +0 -35
  67. package/lib/index.js.map +0 -1
  68. package/lib/internal.d.ts +0 -30
  69. package/lib/internal.js +0 -35
  70. package/lib/internal.js.map +0 -1
  71. package/lib/types.d.ts +0 -65
  72. package/lib/types.js +0 -2
  73. package/lib/types.js.map +0 -1
  74. package/lib/util.d.ts +0 -68
  75. package/lib/util.js +0 -90
  76. package/lib/util.js.map +0 -1
  77. package/llms.txt +0 -214
package/lib/JJEx.js DELETED
@@ -1,83 +0,0 @@
1
- import { hasProp, isObj, isStr } from 'jty';
2
- import { JJE } from './JJE.js';
3
- import { typeErr } from './internal.js';
4
- export class JJEx extends JJE {
5
- /**
6
- * Gets a data attribute from the HTMLElement.
7
- *
8
- * @example
9
- * ```ts
10
- * const value = el.getData('my-key')
11
- * ```
12
- *
13
- * @param name - The data attribute name (in camelCase).
14
- * @returns The value of the attribute, or undefined if not set.
15
- * @throws {TypeError} If `name` is not a string.
16
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | HTMLElement.dataset}
17
- */
18
- getData(name) {
19
- if (!isStr(name)) {
20
- throw typeErr('name', 'a string', name);
21
- }
22
- return this.ref.dataset[name];
23
- }
24
- /**
25
- * Checks if a data attribute exists on the HTMLElement.
26
- *
27
- * @example
28
- * ```ts
29
- * if (el.hasData('my-key')) {
30
- * // ...
31
- * }
32
- * ```
33
- *
34
- * @param name - The data attribute name (in camelCase).
35
- * @returns True if the attribute exists, false otherwise.
36
- * @throws {TypeError} If `name` is not a string.
37
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | HTMLElement.dataset}
38
- */
39
- hasData(name) {
40
- if (!isStr(name)) {
41
- throw typeErr('name', 'a string', name);
42
- }
43
- return hasProp(this.ref.dataset, name);
44
- }
45
- setData(nameOrObj, value) {
46
- if (typeof nameOrObj === 'string') {
47
- this.ref.dataset[nameOrObj] = value;
48
- }
49
- else if (isObj(nameOrObj)) {
50
- for (const [k, v] of Object.entries(nameOrObj)) {
51
- this.ref.dataset[k] = v;
52
- }
53
- }
54
- else {
55
- throw typeErr('nameOrObj', 'a string or object', nameOrObj);
56
- }
57
- return this;
58
- }
59
- /**
60
- * Removes one or more data attributes from the HTMLElement.
61
- *
62
- * @example
63
- * ```ts
64
- * el.rmData('myKey') // Remove single
65
- * el.rmData('myKey', 'otherKey') // Remove multiple
66
- * ```
67
- *
68
- * @param names - The data attribute name(s) (in camelCase).
69
- * @returns This instance for chaining.
70
- * @throws {TypeError} If any name is not a string.
71
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | HTMLElement.dataset}
72
- */
73
- rmData(...names) {
74
- for (const name of names) {
75
- if (!isStr(name)) {
76
- throw typeErr('name', 'a string', name);
77
- }
78
- delete this.ref.dataset[name];
79
- }
80
- return this;
81
- }
82
- }
83
- //# sourceMappingURL=JJEx.js.map
package/lib/JJEx.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"JJEx.js","sourceRoot":"","sources":["../src/JJEx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,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CAAA;IACf,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,GAAG,KAAe;QACrB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACf,MAAM,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAAA;YAC3C,CAAC;YACD,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACjC,CAAC;QACD,OAAO,IAAI,CAAA;IACf,CAAC;CACJ"}
package/lib/JJHE.d.ts DELETED
@@ -1,109 +0,0 @@
1
- import { JJEx } from './JJEx.js';
2
- /**
3
- * Wraps a DOM HTMLElement (which is a descendant of Element).
4
- *
5
- * @remarks
6
- * This class extends `JJE` to provide specific functionality for HTML elements,
7
- * such as access to `dataset`, `innerText`, and form values.
8
- *
9
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement | HTMLElement}
10
- */
11
- export declare class JJHE<T extends HTMLElement = HTMLElement> extends JJEx<T> {
12
- /**
13
- * Creates a JJHE instance from an HTMLElement reference.
14
- *
15
- * @example
16
- * ```ts
17
- * const el = JJHE.from(document.getElementById('my-id')) // from an existing HTMLElement
18
- * const el = JJHE.from(new document.createElement('div')) // from a new HTMLElement
19
- * ```
20
- *
21
- * @param ref - The HTMLElement.
22
- * @returns A new JJHE instance.
23
- */
24
- static from<T extends HTMLElement>(ref: T): JJHE<T>;
25
- /**
26
- * Creates a JJHE instance from a tag name.
27
- *
28
- * @example
29
- * ```ts
30
- * const div = JJHE.fromTag('div')
31
- * const input = JJHE.fromTag('input', { is: 'custom-input' })
32
- * ```
33
- *
34
- * @param tagName - The tag name.
35
- * @param options - Element creation options.
36
- * @returns A new JJHE instance.
37
- * @throws {TypeError} If `tagName` is not a string.
38
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement | document.createElement}
39
- */
40
- static fromTag<K extends keyof HTMLElementTagNameMap>(tagName: K, options?: ElementCreationOptions): JJHE<HTMLElementTagNameMap[K]>;
41
- static fromTag(tagName: string, options?: ElementCreationOptions): JJHE;
42
- /**
43
- * Creates an instance of JJHE.
44
- *
45
- * @param ref - The HTMLElement to wrap.
46
- * @throws {TypeError} If `ref` is not an HTMLElement.
47
- */
48
- constructor(ref: T);
49
- /**
50
- * Gets the value property of the HTMLElement (e.g. for inputs).
51
- *
52
- * @returns The value.
53
- * @throws {Error} If the HTMLElement does not have a value property.
54
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/value | HTMLInputElement.value}
55
- */
56
- getValue(): unknown;
57
- /**
58
- * Sets the value property of the HTMLElement.
59
- *
60
- * @example
61
- * ```ts
62
- * input.setValue('new value')
63
- * input.setValue(42) // Numbers are automatically converted
64
- * ```
65
- *
66
- * @param value - The value to set.
67
- * @returns This instance for chaining.
68
- * @throws {Error} If the HTMLElement does not have a value property.
69
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/value | HTMLInputElement.value}
70
- */
71
- setValue(value: any): this;
72
- /**
73
- * Focuses the HTMLElement.
74
- *
75
- * @returns This instance for chaining.
76
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus | HTMLElement.focus}
77
- */
78
- focus(): this;
79
- /**
80
- * Clicks the HTMLElement.
81
- *
82
- * @returns This instance for chaining.
83
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click | HTMLElement.click}
84
- */
85
- click(): this;
86
- /**
87
- * Gets the inner text of the HTMLElement.
88
- *
89
- * @remarks
90
- * This method operates on `innerText`. The method name is kept short for convenience.
91
- *
92
- * @returns The inner text.
93
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText | HTMLElement.innerText}
94
- */
95
- getText(): string;
96
- /**
97
- * Sets the inner text of the HTMLElement.
98
- *
99
- * @remarks
100
- * This method operates on `innerText`. The method name is kept short for convenience.
101
- * Pass an empty string, `null`, or `undefined` to clear the content.
102
- * Numbers and booleans are automatically converted to strings.
103
- *
104
- * @param text - The text to set, or null/undefined to clear.
105
- * @returns This instance for chaining.
106
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText | HTMLElement.innerText}
107
- */
108
- setText(text?: any): this;
109
- }
package/lib/JJHE.js DELETED
@@ -1,136 +0,0 @@
1
- import { hasProp, isA, isStr } from 'jty';
2
- import { JJEx } from './JJEx.js';
3
- /**
4
- * Wraps a DOM HTMLElement (which is a descendant of Element).
5
- *
6
- * @remarks
7
- * This class extends `JJE` to provide specific functionality for HTML elements,
8
- * such as access to `dataset`, `innerText`, and form values.
9
- *
10
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement | HTMLElement}
11
- */
12
- export class JJHE extends JJEx {
13
- /**
14
- * Creates a JJHE instance from an HTMLElement reference.
15
- *
16
- * @example
17
- * ```ts
18
- * const el = JJHE.from(document.getElementById('my-id')) // from an existing HTMLElement
19
- * const el = JJHE.from(new document.createElement('div')) // from a new HTMLElement
20
- * ```
21
- *
22
- * @param ref - The HTMLElement.
23
- * @returns A new JJHE instance.
24
- */
25
- static from(ref) {
26
- return new JJHE(ref);
27
- }
28
- static fromTag(tagName, options) {
29
- if (!isStr(tagName)) {
30
- throw new TypeError(`JJHE.fromTag() expects tagName to be a string (e.g., 'div', 'button'). ` +
31
- `Got ${tagName} (${typeof tagName}). Did you mean to use a string literal like 'div'?`);
32
- }
33
- return new JJHE(document.createElement(tagName, options));
34
- }
35
- /**
36
- * Creates an instance of JJHE.
37
- *
38
- * @param ref - The HTMLElement to wrap.
39
- * @throws {TypeError} If `ref` is not an HTMLElement.
40
- */
41
- constructor(ref) {
42
- if (!isA(ref, HTMLElement)) {
43
- throw new TypeError(`JJHE expects an HTMLElement. Got ${ref} (${typeof ref}). ` +
44
- `If you have a DOM node, use JJHE.from(element). ` +
45
- `If creating a new element, use JJHE.fromTag('div').`);
46
- }
47
- super(ref);
48
- }
49
- /**
50
- * Gets the value property of the HTMLElement (e.g. for inputs).
51
- *
52
- * @returns The value.
53
- * @throws {Error} If the HTMLElement does not have a value property.
54
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/value | HTMLInputElement.value}
55
- */
56
- getValue() {
57
- if (!hasProp(this.ref, 'value')) {
58
- throw new Error(`Cannot get value from <${this.ref.tagName.toLowerCase()}>. ` +
59
- `The value property only exists on form elements (input, textarea, select). ` +
60
- `If you need text content, try .getText() instead.`);
61
- }
62
- return this.ref.value;
63
- }
64
- /**
65
- * Sets the value property of the HTMLElement.
66
- *
67
- * @example
68
- * ```ts
69
- * input.setValue('new value')
70
- * input.setValue(42) // Numbers are automatically converted
71
- * ```
72
- *
73
- * @param value - The value to set.
74
- * @returns This instance for chaining.
75
- * @throws {Error} If the HTMLElement does not have a value property.
76
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/value | HTMLInputElement.value}
77
- */
78
- setValue(value) {
79
- if (!hasProp(this.ref, 'value')) {
80
- throw new Error(`Cannot set value on <${this.ref.tagName.toLowerCase()}>. ` +
81
- `The value property only exists on form elements (input, textarea, select). ` +
82
- `If you need to set text content, try .setText() instead.`);
83
- }
84
- this.ref.value = value;
85
- return this;
86
- }
87
- /**
88
- * Focuses the HTMLElement.
89
- *
90
- * @returns This instance for chaining.
91
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus | HTMLElement.focus}
92
- */
93
- focus() {
94
- this.ref.focus();
95
- return this;
96
- }
97
- /**
98
- * Clicks the HTMLElement.
99
- *
100
- * @returns This instance for chaining.
101
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click | HTMLElement.click}
102
- */
103
- click() {
104
- this.ref.click();
105
- return this;
106
- }
107
- /**
108
- * Gets the inner text of the HTMLElement.
109
- *
110
- * @remarks
111
- * This method operates on `innerText`. The method name is kept short for convenience.
112
- *
113
- * @returns The inner text.
114
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText | HTMLElement.innerText}
115
- */
116
- getText() {
117
- return this.ref.innerText;
118
- }
119
- /**
120
- * Sets the inner text of the HTMLElement.
121
- *
122
- * @remarks
123
- * This method operates on `innerText`. The method name is kept short for convenience.
124
- * Pass an empty string, `null`, or `undefined` to clear the content.
125
- * Numbers and booleans are automatically converted to strings.
126
- *
127
- * @param text - The text to set, or null/undefined to clear.
128
- * @returns This instance for chaining.
129
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText | HTMLElement.innerText}
130
- */
131
- setText(text) {
132
- this.ref.innerText = text ?? '';
133
- return this;
134
- }
135
- }
136
- //# sourceMappingURL=JJHE.js.map
package/lib/JJHE.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"JJHE.js","sourceRoot":"","sources":["../src/JJHE.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAGzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAGhC;;;;;;;;GAQG;AACH,MAAM,OAAO,IAA0C,SAAQ,IAAO;IAClE;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAAI,CAAwB,GAAM;QACrC,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;IAsBD,MAAM,CAAC,OAAO,CAAC,OAAe,EAAE,OAAgC;QAC5D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,SAAS,CACf,yEAAyE;gBACrE,OAAO,OAAO,KAAK,OAAO,OAAO,qDAAqD,CAC7F,CAAA;QACL,CAAC;QACD,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IAC7D,CAAC;IAED;;;;;OAKG;IACH,YAAY,GAAM;QACd,IAAI,CAAC,GAAG,CAA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AAU;QACd,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAA;QAC/B,OAAO,IAAI,CAAA;IACf,CAAC;CACJ"}
package/lib/JJN-wrap.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/lib/JJN-wrap.js DELETED
@@ -1,46 +0,0 @@
1
- import { isA, isObj, isStr } from 'jty';
2
- import { JJHE } from './JJHE.js';
3
- import { JJE } from './JJE.js';
4
- import { JJDF } from './JJDF.js';
5
- import { JJSR } from './JJSR.js';
6
- import { JJT } from './JJT.js';
7
- import { JJN } from './JJN.js';
8
- import { JJD } from './JJD.js';
9
- import { JJSE } from './JJSE.js';
10
- JJN.wrap = function wrap(raw) {
11
- if (isStr(raw)) {
12
- return JJT.fromStr(raw);
13
- }
14
- if (!isObj(raw)) {
15
- throw new TypeError(`Expected an object to wrap. Got ${raw} (${typeof raw})`);
16
- }
17
- if (isA(raw, JJN)) {
18
- return raw;
19
- }
20
- if (isA(raw, HTMLElement)) {
21
- return JJHE.from(raw);
22
- }
23
- if (isA(raw, SVGElement)) {
24
- return JJSE.from(raw);
25
- }
26
- if (isA(raw, Element)) {
27
- return JJE.from(raw);
28
- }
29
- if (isA(raw, ShadowRoot)) {
30
- return JJSR.from(raw);
31
- }
32
- if (isA(raw, DocumentFragment)) {
33
- return JJDF.from(raw);
34
- }
35
- if (isA(raw, Document)) {
36
- return JJD.from(raw);
37
- }
38
- if (isA(raw, Text)) {
39
- return JJT.from(raw);
40
- }
41
- if (isA(raw, Node)) {
42
- return JJN.from(raw);
43
- }
44
- throw new TypeError(`Expected a Node to wrap. Got ${raw} (${typeof raw})`);
45
- };
46
- //# sourceMappingURL=JJN-wrap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"JJN-wrap.js","sourceRoot":"","sources":["../src/JJN-wrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AACvC,OAAO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,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;IACD,IAAI,GAAG,CAAC,GAAG,EAAE,gBAAgB,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;IACD,IAAI,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC;QACrB,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;IACD,IAAI,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC;QACjB,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;IACD,IAAI,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC;QACjB,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;IACD,MAAM,IAAI,SAAS,CAAC,gCAAgC,GAAG,KAAK,OAAO,GAAG,GAAG,CAAC,CAAA;AAC9E,CAAC,CAAA"}
package/lib/JJN.d.ts DELETED
@@ -1,126 +0,0 @@
1
- import { Unwrapped, Wrappable, Wrapped } from './types.js';
2
- import { JJET } from './JJET.js';
3
- /**
4
- * Wraps a DOM Node.
5
- *
6
- * @remarks
7
- * This is the base class for all JJ wrappers. It provides common functionality for DOM manipulation,
8
- * traversal, and event handling.
9
- *
10
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node | Node}
11
- */
12
- export declare class JJN<T extends Node = Node> extends JJET<T> {
13
- /**
14
- * Creates a JJN instance from a Node reference.
15
- *
16
- * @example
17
- * ```ts
18
- * const node = JJN.from(document.createTextNode('hello'))
19
- * ```
20
- *
21
- * @param node - The Node instance.
22
- * @returns A new JJN instance.
23
- */
24
- static from(node: Node): JJN;
25
- /**
26
- * Checks if a value can be passed to the `wrap()` or `unwrap()` function.
27
- *
28
- * @remarks
29
- * This is useful for filtering the array that is passed to `append()`, `prepend()` or `setChildren()`
30
- *
31
- * @param x an unknown value
32
- * @returns true if `x` is a string, Node (or its descendents), JJN (or its descendents)
33
- */
34
- static isWrapable(x: unknown): x is Wrappable;
35
- /**
36
- * Wraps a native DOM node or string into the most specific JJ wrapper available.
37
- *
38
- * @remarks
39
- * This function acts as a factory, inspecting the input type and returning the appropriate
40
- * subclass of `JJN` (e.g., `JJHE` for `HTMLElement`, `JJT` for `Text`).
41
- *
42
- * @example
43
- * ```ts
44
- * const bodyWrapper = JJN.wrap(document.body) // Returns JJHE
45
- * const textWrapper = JJN.wrap('Hello') // Returns JJT wrapping a new Text node
46
- * ```
47
- *
48
- * @param raw - The object to wrap. If it's already Wrapped, it'll be returned without any change. We don't double-wrap or clone it.
49
- * @returns The most granular Wrapped subclass instance. If the input is already wrapped, it'll be returned as is without cloning.
50
- * @throws {TypeError} If the input is not a Node, string, or JJ wrapper.
51
- */
52
- static wrap(raw: Wrappable): Wrapped;
53
- /**
54
- * Extracts the underlying native DOM node from a wrapper.
55
- *
56
- * @remarks
57
- * If the input is already a native Node, it is returned as is.
58
- * If the input is a string, a new Text node is created and returned.
59
- *
60
- * @example
61
- * ```ts
62
- * const rawElement = JJN.unwrap(myJJHE) // Returns HTMLElement
63
- * ```
64
- *
65
- * @param obj - The object to unwrap.
66
- * @returns The underlying DOM node.
67
- * @throws {TypeError} If the input cannot be unwrapped.
68
- */
69
- static unwrap(obj: Wrappable): Unwrapped;
70
- /**
71
- * Wraps an iterable object (e.g. an array of wrapped or DOM elements).
72
- *
73
- * @example
74
- * ```ts
75
- * const wrappedList = JJN.wrapAll(document.querySelectorAll('div'))
76
- * ```
77
- *
78
- * @param iterable - The iterable to wrap.
79
- * @returns An array of wrapped instances.
80
- */
81
- static wrapAll(iterable: Iterable<Wrappable>): Wrapped[];
82
- /**
83
- * Unwraps an iterable object (e.g. an array or HTMLCollection).
84
- *
85
- * @example
86
- * ```ts
87
- * const nodes = JJN.unwrapAll(wrappedList)
88
- * ```
89
- *
90
- * @param iterable - The iterable to unwrap.
91
- * @returns An array of native DOM nodes.
92
- */
93
- static unwrapAll(iterable: Iterable<Wrappable>): Unwrapped[];
94
- /**
95
- * Creates an instance of JJN.
96
- *
97
- * @param ref - The Node to wrap.
98
- * @throws {TypeError} If `ref` is not a Node.
99
- */
100
- constructor(ref: T);
101
- /**
102
- * Clones the Node.
103
- *
104
- * @param deep - If true, clones the subtree.
105
- * @returns A new wrapped instance of the clone.
106
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode | Node.cloneNode}
107
- */
108
- clone(deep?: boolean): Wrapped;
109
- /**
110
- * Creates a Text node from a string and appends it to this Node.
111
- *
112
- * @remarks
113
- * This method is overridden in JJT to append to the existing text content instead.
114
- *
115
- * @example
116
- * ```ts
117
- * el.addText('Hello ')
118
- * el.addText('World')
119
- * ```
120
- *
121
- * @param text - The text to add. If null or undefined, nothing is added.
122
- * @returns This instance for chaining.
123
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/createTextNode | document.createTextNode}
124
- */
125
- addText(text?: string | null): this;
126
- }
package/lib/JJN.js DELETED
@@ -1,166 +0,0 @@
1
- import { isA, isObj, isStr } from 'jty';
2
- import { JJET } from './JJET.js';
3
- /**
4
- * Wraps a DOM Node.
5
- *
6
- * @remarks
7
- * This is the base class for all JJ wrappers. It provides common functionality for DOM manipulation,
8
- * traversal, and event handling.
9
- *
10
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node | Node}
11
- */
12
- export class JJN extends JJET {
13
- /**
14
- * Creates a JJN instance from a Node reference.
15
- *
16
- * @example
17
- * ```ts
18
- * const node = JJN.from(document.createTextNode('hello'))
19
- * ```
20
- *
21
- * @param node - The Node instance.
22
- * @returns A new JJN instance.
23
- */
24
- static from(node) {
25
- return new JJN(node);
26
- }
27
- /**
28
- * Checks if a value can be passed to the `wrap()` or `unwrap()` function.
29
- *
30
- * @remarks
31
- * This is useful for filtering the array that is passed to `append()`, `prepend()` or `setChildren()`
32
- *
33
- * @param x an unknown value
34
- * @returns true if `x` is a string, Node (or its descendents), JJN (or its descendents)
35
- */
36
- static isWrapable(x) {
37
- return isStr(x) || isA(x, Node) || isA(x, JJN);
38
- }
39
- /**
40
- * Wraps a native DOM node or string into the most specific JJ wrapper available.
41
- *
42
- * @remarks
43
- * This function acts as a factory, inspecting the input type and returning the appropriate
44
- * subclass of `JJN` (e.g., `JJHE` for `HTMLElement`, `JJT` for `Text`).
45
- *
46
- * @example
47
- * ```ts
48
- * const bodyWrapper = JJN.wrap(document.body) // Returns JJHE
49
- * const textWrapper = JJN.wrap('Hello') // Returns JJT wrapping a new Text node
50
- * ```
51
- *
52
- * @param raw - The object to wrap. If it's already Wrapped, it'll be returned without any change. We don't double-wrap or clone it.
53
- * @returns The most granular Wrapped subclass instance. If the input is already wrapped, it'll be returned as is without cloning.
54
- * @throws {TypeError} If the input is not a Node, string, or JJ wrapper.
55
- */
56
- static wrap(raw) {
57
- throw new ReferenceError(`The mixin is supposed to override this method.`);
58
- }
59
- /**
60
- * Extracts the underlying native DOM node from a wrapper.
61
- *
62
- * @remarks
63
- * If the input is already a native Node, it is returned as is.
64
- * If the input is a string, a new Text node is created and returned.
65
- *
66
- * @example
67
- * ```ts
68
- * const rawElement = JJN.unwrap(myJJHE) // Returns HTMLElement
69
- * ```
70
- *
71
- * @param obj - The object to unwrap.
72
- * @returns The underlying DOM node.
73
- * @throws {TypeError} If the input cannot be unwrapped.
74
- */
75
- static unwrap(obj) {
76
- if (isStr(obj)) {
77
- return document.createTextNode(obj);
78
- }
79
- if (!isObj(obj)) {
80
- throw new TypeError(`JJN.unwrap() expects a string, DOM Node, or JJ wrapper. Got ${obj} (${typeof obj}). `);
81
- }
82
- if (isA(obj, Node)) {
83
- return obj;
84
- }
85
- if (isA(obj, JJN)) {
86
- return obj.ref;
87
- }
88
- throw new TypeError(`Could not unwrap ${obj} (${typeof obj}). ` +
89
- `Expected a string, Node, or JJ wrapper. ` +
90
- `Make sure you're passing a valid DOM element or JJ wrapper.`);
91
- }
92
- /**
93
- * Wraps an iterable object (e.g. an array of wrapped or DOM elements).
94
- *
95
- * @example
96
- * ```ts
97
- * const wrappedList = JJN.wrapAll(document.querySelectorAll('div'))
98
- * ```
99
- *
100
- * @param iterable - The iterable to wrap.
101
- * @returns An array of wrapped instances.
102
- */
103
- static wrapAll(iterable) {
104
- return Array.from(iterable, JJN.wrap);
105
- }
106
- /**
107
- * Unwraps an iterable object (e.g. an array or HTMLCollection).
108
- *
109
- * @example
110
- * ```ts
111
- * const nodes = JJN.unwrapAll(wrappedList)
112
- * ```
113
- *
114
- * @param iterable - The iterable to unwrap.
115
- * @returns An array of native DOM nodes.
116
- */
117
- static unwrapAll(iterable) {
118
- return Array.from(iterable, JJN.unwrap);
119
- }
120
- /**
121
- * Creates an instance of JJN.
122
- *
123
- * @param ref - The Node to wrap.
124
- * @throws {TypeError} If `ref` is not a Node.
125
- */
126
- constructor(ref) {
127
- if (!isA(ref, Node)) {
128
- throw new TypeError(`JJN expects a Node instance. Got ${ref} (${typeof ref}). ` +
129
- `Use JJN.from(node) with a DOM Node, or check that you're passing a valid DOM element.`);
130
- }
131
- super(ref);
132
- }
133
- /**
134
- * Clones the Node.
135
- *
136
- * @param deep - If true, clones the subtree.
137
- * @returns A new wrapped instance of the clone.
138
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode | Node.cloneNode}
139
- */
140
- clone(deep) {
141
- return JJN.wrap(this.ref.cloneNode(deep));
142
- }
143
- /**
144
- * Creates a Text node from a string and appends it to this Node.
145
- *
146
- * @remarks
147
- * This method is overridden in JJT to append to the existing text content instead.
148
- *
149
- * @example
150
- * ```ts
151
- * el.addText('Hello ')
152
- * el.addText('World')
153
- * ```
154
- *
155
- * @param text - The text to add. If null or undefined, nothing is added.
156
- * @returns This instance for chaining.
157
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/createTextNode | document.createTextNode}
158
- */
159
- addText(text) {
160
- if (text) {
161
- this.ref.appendChild(document.createTextNode(text));
162
- }
163
- return this;
164
- }
165
- }
166
- //# sourceMappingURL=JJN.js.map