jj 2.2.0 → 2.4.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.
Files changed (93) hide show
  1. package/lib/JJD.d.ts +76 -0
  2. package/lib/JJD.js +91 -0
  3. package/lib/JJD.js.map +1 -0
  4. package/lib/JJDF.d.ts +60 -0
  5. package/lib/JJDF.js +68 -0
  6. package/lib/JJDF.js.map +1 -0
  7. package/lib/JJE.d.ts +313 -0
  8. package/lib/JJE.js +412 -0
  9. package/lib/JJE.js.map +1 -0
  10. package/lib/JJHE.d.ts +120 -0
  11. package/lib/JJHE.js +164 -0
  12. package/lib/JJHE.js.map +1 -0
  13. package/lib/JJN.d.ts +234 -0
  14. package/lib/JJN.js +323 -0
  15. package/lib/JJN.js.map +1 -0
  16. package/lib/JJSE.d.ts +148 -0
  17. package/lib/JJSE.js +190 -0
  18. package/lib/JJSE.js.map +1 -0
  19. package/lib/JJSR.d.ts +67 -0
  20. package/lib/JJSR.js +85 -0
  21. package/lib/JJSR.js.map +1 -0
  22. package/lib/JJT.d.ts +79 -0
  23. package/lib/JJT.js +108 -0
  24. package/lib/JJT.js.map +1 -0
  25. package/lib/bundle.d.ts +1 -0
  26. package/lib/bundle.js +1533 -442
  27. package/lib/bundle.js.map +3 -3
  28. package/lib/bundle.min.d.ts +1 -0
  29. package/lib/bundle.min.js +2 -2
  30. package/lib/case.d.ts +57 -0
  31. package/lib/case.js +61 -3
  32. package/lib/case.js.map +1 -1
  33. package/lib/components.d.ts +147 -0
  34. package/lib/components.js +286 -0
  35. package/lib/components.js.map +1 -0
  36. package/lib/helpers.d.ts +158 -0
  37. package/lib/helpers.js +231 -0
  38. package/lib/helpers.js.map +1 -0
  39. package/lib/index.d.ts +13 -12
  40. package/lib/index.js +13 -12
  41. package/lib/index.js.map +1 -1
  42. package/lib/mixin-types.d.ts +143 -0
  43. package/lib/mixin-types.js +2 -0
  44. package/lib/mixin-types.js.map +1 -0
  45. package/lib/mixins.d.ts +77 -0
  46. package/lib/mixins.js +336 -0
  47. package/lib/mixins.js.map +1 -0
  48. package/lib/types.d.ts +77 -0
  49. package/lib/types.js +2 -0
  50. package/lib/types.js.map +1 -0
  51. package/lib/util.d.ts +90 -2
  52. package/lib/util.js +106 -2
  53. package/lib/util.js.map +1 -1
  54. package/lib/util.test.d.ts +1 -0
  55. package/lib/util.test.js +46 -0
  56. package/lib/util.test.js.map +1 -0
  57. package/package.json +16 -7
  58. package/lib/WC.d.ts +0 -41
  59. package/lib/WC.js +0 -117
  60. package/lib/WC.js.map +0 -1
  61. package/lib/WD.d.ts +0 -8
  62. package/lib/WD.js +0 -17
  63. package/lib/WD.js.map +0 -1
  64. package/lib/WDF.d.ts +0 -9
  65. package/lib/WDF.js +0 -20
  66. package/lib/WDF.js.map +0 -1
  67. package/lib/WE.d.ts +0 -43
  68. package/lib/WE.js +0 -131
  69. package/lib/WE.js.map +0 -1
  70. package/lib/WHE.d.ts +0 -21
  71. package/lib/WHE.js +0 -75
  72. package/lib/WHE.js.map +0 -1
  73. package/lib/WN-mixin.d.ts +0 -9
  74. package/lib/WN-mixin.js +0 -59
  75. package/lib/WN-mixin.js.map +0 -1
  76. package/lib/WN.d.ts +0 -47
  77. package/lib/WN.js +0 -194
  78. package/lib/WN.js.map +0 -1
  79. package/lib/WSE.d.ts +0 -25
  80. package/lib/WSE.js +0 -84
  81. package/lib/WSE.js.map +0 -1
  82. package/lib/WSH.d.ts +0 -11
  83. package/lib/WSH.js +0 -29
  84. package/lib/WSH.js.map +0 -1
  85. package/lib/WT.d.ts +0 -12
  86. package/lib/WT.js +0 -39
  87. package/lib/WT.js.map +0 -1
  88. package/lib/fetch.d.ts +0 -31
  89. package/lib/fetch.js +0 -69
  90. package/lib/fetch.js.map +0 -1
  91. package/lib/h.d.ts +0 -3
  92. package/lib/h.js +0 -9
  93. package/lib/h.js.map +0 -1
package/lib/JJHE.js ADDED
@@ -0,0 +1,164 @@
1
+ import { hasProp, isA, isStr } from 'jty';
2
+ import { JJE } from './JJE.js';
3
+ import { JJN } from './JJN.js';
4
+ /**
5
+ * Wraps a DOM HTMLElement (which is a descendant of Element).
6
+ *
7
+ * @remarks
8
+ * This class extends `JJE` to provide specific functionality for HTML elements,
9
+ * such as access to `dataset`, `innerText`, and form values.
10
+ *
11
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement | HTMLElement}
12
+ */
13
+ export class JJHE extends JJE {
14
+ /**
15
+ * Creates a JJHE instance from an HTMLElement reference.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const el = JJHE.from(document.getElementById('my-id'))
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
+ /**
29
+ * Creates a JJHE instance from a tag name.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const div = JJHE.fromTag('div')
34
+ * const input = JJHE.fromTag('input', { is: 'custom-input' })
35
+ * ```
36
+ *
37
+ * @param tagName - The tag name.
38
+ * @param options - Element creation options.
39
+ * @returns A new JJHE instance.
40
+ * @throws {TypeError} If `tagName` is not a string.
41
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement | document.createElement}
42
+ */
43
+ static fromTag(tagName, options) {
44
+ if (!isStr(tagName)) {
45
+ throw new TypeError(`Expected a string for tagName. Got: ${tagName} (${typeof tagName})`);
46
+ }
47
+ return new JJHE(document.createElement(tagName, options));
48
+ }
49
+ /**
50
+ * Creates an instance of JJHE.
51
+ *
52
+ * @param ref - The HTMLElement to wrap.
53
+ * @throws {TypeError} If `ref` is not an HTMLElement.
54
+ */
55
+ constructor(ref) {
56
+ if (!isA(ref, HTMLElement)) {
57
+ throw new TypeError(`Expected an HTMLElement. Got ${ref} (${typeof ref})`);
58
+ }
59
+ super(ref);
60
+ }
61
+ /**
62
+ * Gets the value property of the element (e.g. for inputs).
63
+ *
64
+ * @returns The value.
65
+ * @throws {Error} If the element does not have a value property.
66
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/value | HTMLInputElement.value}
67
+ */
68
+ getValue() {
69
+ if (!hasProp(this.ref, 'value')) {
70
+ throw new Error('Element does not have a value property');
71
+ }
72
+ return this.ref.value;
73
+ }
74
+ /**
75
+ * Sets the value property of the element.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * input.setValue('new value')
80
+ * ```
81
+ *
82
+ * @param value - The value to set.
83
+ * @returns This instance for chaining.
84
+ * @throws {Error} If the element does not have a value property.
85
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/value | HTMLInputElement.value}
86
+ */
87
+ setValue(value) {
88
+ if (!hasProp(this.ref, 'value')) {
89
+ throw new Error('Element does not have a value property');
90
+ }
91
+ this.ref.value = value;
92
+ return this;
93
+ }
94
+ /**
95
+ * Focuses the element.
96
+ *
97
+ * @returns This instance for chaining.
98
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus | HTMLElement.focus}
99
+ */
100
+ focus() {
101
+ this.ref.focus();
102
+ return this;
103
+ }
104
+ /**
105
+ * Clicks the element.
106
+ *
107
+ * @returns This instance for chaining.
108
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click | HTMLElement.click}
109
+ */
110
+ click() {
111
+ this.ref.click();
112
+ return this;
113
+ }
114
+ /**
115
+ * Gets the inner text of the element.
116
+ *
117
+ * @returns The inner text.
118
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText | HTMLElement.innerText}
119
+ */
120
+ getText() {
121
+ return this.ref.innerText;
122
+ }
123
+ /**
124
+ * Sets the inner text of the element.
125
+ *
126
+ * @param text - The text to set.
127
+ * @returns This instance for chaining.
128
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText | HTMLElement.innerText}
129
+ */
130
+ setText(text) {
131
+ this.ref.innerText = text;
132
+ return this;
133
+ }
134
+ /**
135
+ * Finds the first element matching a selector within this element's context.
136
+ *
137
+ * @param selector - The CSS selector.
138
+ * @param throwIfNotFound - Whether to throw an error if not found. Defaults to true.
139
+ * @returns The wrapped element, or null.
140
+ * @throws {TypeError} If the element is not found and `throwIfNotFound` is true.
141
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector | Element.querySelector}
142
+ */
143
+ query(selector, throwIfNotFound = true) {
144
+ const el = this.ref.querySelector(selector);
145
+ if (el) {
146
+ return JJN.wrap(el);
147
+ }
148
+ if (throwIfNotFound) {
149
+ throw new TypeError(`Element with selector ${selector} not found`);
150
+ }
151
+ return null;
152
+ }
153
+ /**
154
+ * Finds all elements matching a selector within this element's context.
155
+ *
156
+ * @param selector - The CSS selector.
157
+ * @returns An array of wrapped elements.
158
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll | Element.querySelectorAll}
159
+ */
160
+ queryAll(selector) {
161
+ return JJN.wrapAll(this.ref.querySelectorAll(selector));
162
+ }
163
+ }
164
+ //# sourceMappingURL=JJHE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JJHE.js","sourceRoot":"","sources":["../src/JJHE.ts"],"names":[],"mappings":"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"}
package/lib/JJN.d.ts ADDED
@@ -0,0 +1,234 @@
1
+ import { Unwrapped, Wrappable, Wrapped } from './types.js';
2
+ import { IAppendPrepend } from './mixin-types.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> implements IAppendPrepend {
13
+ #private;
14
+ /**
15
+ * Creates a JJN instance from a Node reference.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const node = JJN.from(document.createTextNode('hello'))
20
+ * ```
21
+ *
22
+ * @param node - The Node instance.
23
+ * @returns A new JJN instance.
24
+ */
25
+ static from(node: Node): JJN;
26
+ /**
27
+ * Checks if a value can be passed to the `wrap()` or `unwrap()` function.
28
+ *
29
+ * @remarks
30
+ * This is useful for filtering the array that is passed to `append()`, `prepend()` or `setChildren()`
31
+ *
32
+ * @param x an unknown value
33
+ * @returns true if `x` is a string, Node (or its descendents), JJN (or its descendents)
34
+ */
35
+ static isWrapable(x: unknown): x is Wrappable;
36
+ /**
37
+ * Wraps a native DOM node or string into the most specific JJ wrapper available.
38
+ *
39
+ * @remarks
40
+ * This function acts as a factory, inspecting the input type and returning the appropriate
41
+ * subclass of `JJN` (e.g., `JJHE` for `HTMLElement`, `JJT` for `Text`).
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const bodyWrapper = JJN.wrap(document.body) // Returns JJHE
46
+ * const textWrapper = JJN.wrap('Hello') // Returns JJT wrapping a new Text node
47
+ * ```
48
+ *
49
+ * @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.
50
+ * @returns The most granular Wrapped subclass instance. If the input is already wrapped, it'll be returned as is without cloning.
51
+ * @throws {TypeError} If the input is not a Node, string, or JJ wrapper.
52
+ */
53
+ static wrap(raw: Wrappable): Wrapped;
54
+ /**
55
+ * Extracts the underlying native DOM node from a wrapper.
56
+ *
57
+ * @remarks
58
+ * If the input is already a native Node, it is returned as is.
59
+ * If the input is a string, a new Text node is created and returned.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * const rawElement = JJN.unwrap(myJJHE) // Returns HTMLElement
64
+ * ```
65
+ *
66
+ * @param obj - The object to unwrap.
67
+ * @returns The underlying DOM node.
68
+ * @throws {TypeError} If the input cannot be unwrapped.
69
+ */
70
+ static unwrap(obj: Wrappable): Unwrapped;
71
+ /**
72
+ * Wraps an iterable object (e.g. an array of wrapped or DOM elements).
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * const wrappedList = JJN.wrapAll(document.querySelectorAll('div'))
77
+ * ```
78
+ *
79
+ * @param iterable - The iterable to wrap.
80
+ * @returns An array of wrapped instances.
81
+ */
82
+ static wrapAll(iterable: Iterable<Wrappable>): Wrapped[];
83
+ /**
84
+ * Unwraps an iterable object (e.g. an array or HTMLCollection).
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * const nodes = JJN.unwrapAll(wrappedList)
89
+ * ```
90
+ *
91
+ * @param iterable - The iterable to unwrap.
92
+ * @returns An array of native DOM nodes.
93
+ */
94
+ static unwrapAll(iterable: Iterable<Wrappable>): Unwrapped[];
95
+ /**
96
+ * Creates an instance of JJN.
97
+ *
98
+ * @param ref - The Node to wrap.
99
+ * @throws {TypeError} If `ref` is not a Node.
100
+ */
101
+ constructor(ref: T);
102
+ /**
103
+ * Gets the underlying DOM Node.
104
+ */
105
+ get ref(): T;
106
+ /**
107
+ * Clones the node.
108
+ *
109
+ * @param deep - If true, clones the subtree.
110
+ * @returns A new wrapped instance of the clone.
111
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode | Node.cloneNode}
112
+ */
113
+ clone(deep?: boolean): Wrapped;
114
+ /**
115
+ * Appends children to this node.
116
+ *
117
+ * @remarks
118
+ * To make template codes easier, this function ignores any child that is not possible to `wrap()` (e.g. undefined, null, false).
119
+ *
120
+ * @param children - The children to append (Nodes, strings, or Wrappers).
121
+ * @returns This instance for chaining.
122
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/append | Element.append}
123
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild | Node.appendChild}
124
+ */
125
+ append(...children: Wrappable[]): this;
126
+ /**
127
+ * Maps an array to children and appends them.
128
+ *
129
+ * @example
130
+ * ```ts
131
+ * list.mapAppend(['a', 'b'], item => h('li', null, item))
132
+ * ```
133
+ *
134
+ * @remarks
135
+ * To make template codes easier, this function ignores any child that is not possible to `wrap()` (e.g. undefined, null, false).
136
+ *
137
+ * @param array - The source array.
138
+ * @param mapFn - The mapping function returning a Wrappable.
139
+ * @returns This instance for chaining.
140
+ */
141
+ mapAppend(array: Wrappable[], mapFn: (item: Wrappable) => Wrappable): this;
142
+ /**
143
+ * Prepends children to this node.
144
+ *
145
+ * @remarks
146
+ * To make template codes easier, this function ignores any child that is not possible to `wrap()` (e.g. undefined, null, false).
147
+ *
148
+ * @param children - The children to prepend.
149
+ * @returns This instance for chaining.
150
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/prepend | Element.prepend}
151
+ */
152
+ prepend(...children: Wrappable[]): this;
153
+ /**
154
+ * Maps an array to children and prepends them.
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * list.mapPrepend(['a', 'b'], item => JJHE.fromTag('li').setText(item))
159
+ * ```
160
+ *
161
+ * @remarks
162
+ * To make template codes easier, this function ignores any child that is not possible to `wrap()` (e.g. undefined, null, false).
163
+ *
164
+ * @param array - The source array.
165
+ * @param mapFn - The mapping function.
166
+ * @returns This instance for chaining.
167
+ */
168
+ mapPrepend(array: Wrappable[], mapFn: (item: Wrappable) => Wrappable): this;
169
+ /**
170
+ * Replaces the existing children of this node with a specified new set of children.
171
+ *
172
+ * @remarks
173
+ * If no children are specified, it essentially empties the node
174
+ * To make template codes easier, this function ignores any child that is not possible to `wrap()` (e.g. undefined, null, false).
175
+ *
176
+ * @param children - The new children to set.
177
+ * @returns This instance for chaining.
178
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren | Element.replaceChildren}
179
+ */
180
+ setChildren(...children: Wrappable[]): this;
181
+ /**
182
+ * Adds an event listener.
183
+ *
184
+ * @param eventName - The event name.
185
+ * @param handler - The event handler.
186
+ * @returns This instance for chaining.
187
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener | EventTarget.addEventListener}
188
+ */
189
+ on(eventName: string, handler: EventListenerOrEventListenerObject): this;
190
+ /**
191
+ * Removes an event listener.
192
+ *
193
+ * @param eventName - The event name.
194
+ * @param handler - The event handler.
195
+ * @returns This instance for chaining.
196
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener | EventTarget.removeEventListener}
197
+ */
198
+ off(eventName: string, handler: EventListenerOrEventListenerObject): this;
199
+ /**
200
+ * Removes this node from the DOM.
201
+ *
202
+ * @returns This instance for chaining.
203
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild | Node.removeChild}
204
+ */
205
+ rm(): this;
206
+ /**
207
+ * Removes all children from this node.
208
+ *
209
+ * @returns This instance for chaining.
210
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren | Element.replaceChildren}
211
+ */
212
+ empty(): this;
213
+ /**
214
+ * Runs a function in the context of this JJN instance.
215
+ *
216
+ * @example
217
+ * ```ts
218
+ * div.run(function() {
219
+ * this.addClass('active')
220
+ * console.log(this.ref)
221
+ * })
222
+ * ```
223
+ * @remarks
224
+ * If you want to access the current JJ* instance using `this` keyword, you SHOULD use a `function` not an arrow function.
225
+ * If the function throws, `run()` doesn't swallow the exception.
226
+ * So if you're expecting an error, make sure to wrap it in a `try..catch` block and handle the exception.
227
+ * If the function returns a promise, you can `await` on the response.
228
+ *
229
+ * @param fn - The function to run. `this` inside the function will refer to this JJN instance.
230
+ * @param args - Arguments to pass to the function.
231
+ * @returns The return value of the function.
232
+ */
233
+ run<R, Args extends any[]>(fn: (this: this, ...args: Args) => R, ...args: Args): R;
234
+ }