jj 2.5.0 → 2.6.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 (77) hide show
  1. package/README.md +29 -1
  2. package/SKILL.md +671 -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 +5 -5
  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/JJE.js DELETED
@@ -1,401 +0,0 @@
1
- import { isA, isArr, isObj, isStr } from 'jty';
2
- import { JJSR } from './JJSR.js';
3
- import { JJNx } from './JJNx.js';
4
- import { typeErr } from './internal.js';
5
- /**
6
- * Wraps a DOM Element (which is a descendant of Node).
7
- *
8
- * @remarks
9
- * This class provides a wrapper around the native `Element` interface, adding fluent API methods
10
- * for attribute manipulation, class handling, and event binding.
11
- *
12
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element | Element}
13
- */
14
- export class JJE extends JJNx {
15
- /**
16
- * Creates a JJE instance from an Element reference.
17
- *
18
- * @example
19
- * ```ts
20
- * const el = JJE.from(document.querySelector('.my-class'))
21
- * ```
22
- *
23
- * @param ref - The Element instance.
24
- * @returns A new JJE instance.
25
- */
26
- static from(ref) {
27
- return new JJE(ref);
28
- }
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) {
36
- if (!isA(ref, Element)) {
37
- throw new TypeError(`JJE expects an Element instance. Got ${ref} (${typeof ref}). ` +
38
- `Use JJE.from(element) with a DOM Element, or use the specific wrapper (JJHE for HTMLElement, JJSE for SVGElement).`);
39
- }
40
- super(ref);
41
- }
42
- /**
43
- * Gets the value of an attribute.
44
- *
45
- * @param name - The name of the attribute.
46
- * @returns The attribute value, or null if not present.
47
- * @throws {TypeError} If `name` is not a string.
48
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute | Element.getAttribute}
49
- */
50
- getAttr(name) {
51
- if (!isStr(name)) {
52
- throw typeErr('name', 'a string', name);
53
- }
54
- return this.ref.getAttribute(name);
55
- }
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
- * @throws {TypeError} If `name` is not a string.
62
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute | Element.hasAttribute}
63
- */
64
- hasAttr(name) {
65
- if (!isStr(name)) {
66
- throw typeErr('name', 'a string', name);
67
- }
68
- return this.ref.hasAttribute(name);
69
- }
70
- setAttr(nameOrObj, value) {
71
- if (typeof nameOrObj === 'string') {
72
- this.ref.setAttribute(nameOrObj, value);
73
- }
74
- else if (isObj(nameOrObj)) {
75
- for (const [k, v] of Object.entries(nameOrObj)) {
76
- this.ref.setAttribute(k, v);
77
- }
78
- }
79
- else {
80
- throw typeErr('nameOrObj', 'a string or object', nameOrObj);
81
- }
82
- return this;
83
- }
84
- /**
85
- * Removes one or more attributes from the Element.
86
- *
87
- * @example
88
- * ```ts
89
- * el.rmAttr('disabled') // Remove single
90
- * el.rmAttr('hidden', 'aria-hidden') // Remove multiple
91
- * ```
92
- *
93
- * @param names - The name(s) of the attribute(s) to remove.
94
- * @returns This instance for chaining.
95
- * @throws {TypeError} If any name is not a string.
96
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute | Element.removeAttribute}
97
- */
98
- rmAttr(...names) {
99
- for (const name of names) {
100
- if (!isStr(name)) {
101
- throw typeErr('name', 'a string', name);
102
- }
103
- this.ref.removeAttribute(name);
104
- }
105
- return this;
106
- }
107
- /**
108
- * Gets the value of an ARIA attribute.
109
- *
110
- * @remarks
111
- * Automatically prepends `aria-` to the name.
112
- *
113
- * @example
114
- * ```ts
115
- * el.getAria('label') // gets 'aria-label'
116
- * ```
117
- *
118
- * @param name - The ARIA attribute suffix (e.g., 'label' for 'aria-label').
119
- * @returns The attribute value, or null if not present.
120
- * @throws {TypeError} If `name` is not a string.
121
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes | ARIA Attributes}
122
- */
123
- getAria(name) {
124
- if (!isStr(name)) {
125
- throw typeErr('name', 'a string', name);
126
- }
127
- return this.ref.getAttribute(`aria-${name}`);
128
- }
129
- /**
130
- * Checks if an ARIA attribute exists.
131
- *
132
- * @param name - The ARIA attribute suffix.
133
- * @returns `true` if the attribute exists.
134
- * @throws {TypeError} If `name` is not a string.
135
- */
136
- hasAria(name) {
137
- if (!isStr(name)) {
138
- throw typeErr('name', 'a string', name);
139
- }
140
- return this.ref.hasAttribute(`aria-${name}`);
141
- }
142
- setAria(nameOrObj, value) {
143
- if (isStr(nameOrObj)) {
144
- this.ref.setAttribute(`aria-${nameOrObj}`, value);
145
- }
146
- else if (isObj(nameOrObj)) {
147
- for (const [k, v] of Object.entries(nameOrObj)) {
148
- this.ref.setAttribute(`aria-${k}`, v);
149
- }
150
- }
151
- else {
152
- throw typeErr('nameOrObj', 'a string or object', nameOrObj);
153
- }
154
- return this;
155
- }
156
- /**
157
- * Removes one or more ARIA attributes from the Element.
158
- *
159
- * @example
160
- * ```ts
161
- * el.rmAria('hidden') // Remove single
162
- * el.rmAria('label', 'hidden') // Remove multiple
163
- * ```
164
- *
165
- * @param names - The ARIA attribute suffix(es) to remove.
166
- * @returns This instance for chaining.
167
- * @throws {TypeError} If any name is not a string.
168
- */
169
- rmAria(...names) {
170
- for (const name of names) {
171
- if (!isStr(name)) {
172
- throw typeErr('name', 'a string', name);
173
- }
174
- this.ref.removeAttribute(`aria-${name}`);
175
- }
176
- return this;
177
- }
178
- /**
179
- * Gets the class attribute.
180
- *
181
- * @returns The class attribute value, or null if not present.
182
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/className | Element.className}
183
- */
184
- getClass() {
185
- return this.getAttr('class');
186
- }
187
- setClass(classNameOrMap) {
188
- if (typeof classNameOrMap === 'string') {
189
- return this.setAttr('class', classNameOrMap);
190
- }
191
- // Conditional class object (Vue.js style)
192
- for (const [className, condition] of Object.entries(classNameOrMap)) {
193
- if (condition) {
194
- this.ref.classList.add(className);
195
- }
196
- else {
197
- this.ref.classList.remove(className);
198
- }
199
- }
200
- return this;
201
- }
202
- /**
203
- * Adds one or more classes to the Element.
204
- *
205
- * @example
206
- * ```ts
207
- * el.addClass('btn', 'btn-primary')
208
- * ```
209
- *
210
- * @param classNames - The classes to add.
211
- * @returns This instance for chaining.
212
- * @throws {TypeError} If any class name is not a string.
213
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/classList | Element.classList}
214
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList/add | DOMTokenList.add}
215
- */
216
- addClass(...classNames) {
217
- for (const className of classNames) {
218
- if (!isStr(className)) {
219
- throw typeErr('className', 'a string', className);
220
- }
221
- }
222
- this.ref.classList.add(...classNames);
223
- return this;
224
- }
225
- /**
226
- * Removes one or more classes from the Element.
227
- *
228
- * @example
229
- * ```ts
230
- * el.rmClass('active') // Remove single
231
- * el.rmClass('btn', 'btn-primary') // Remove multiple
232
- * ```
233
- *
234
- * @param classNames - The classes to remove.
235
- * @returns This instance for chaining.
236
- * @throws {TypeError} If any class name is not a string.
237
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/classList | Element.classList}
238
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList/remove | DOMTokenList.remove}
239
- */
240
- rmClass(...classNames) {
241
- for (const className of classNames) {
242
- if (!isStr(className)) {
243
- throw typeErr('className', 'a string', className);
244
- }
245
- }
246
- this.ref.classList.remove(...classNames);
247
- return this;
248
- }
249
- /**
250
- * Checks if the Element has a specific class.
251
- *
252
- * @param className - The class to check for.
253
- * @returns `true` if the element has the class.
254
- * @throws {TypeError} If `className` is not a string.
255
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/classList | Element.classList}
256
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList/contains | DOMTokenList.contains}
257
- */
258
- hasClass(className) {
259
- if (!isStr(className)) {
260
- throw typeErr('className', 'a string', className);
261
- }
262
- return this.ref.classList.contains(className);
263
- }
264
- /**
265
- * Toggles a class on the Element.
266
- *
267
- * @param className - The class to toggle.
268
- * @returns This instance for chaining.
269
- * @throws {TypeError} If `className` is not a string.
270
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/classList | Element.classList}
271
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList/toggle | DOMTokenList.toggle}
272
- */
273
- toggleClass(className) {
274
- if (!isStr(className)) {
275
- throw typeErr('className', 'a string', className);
276
- }
277
- this.ref.classList.toggle(className);
278
- return this;
279
- }
280
- /**
281
- * Replaces a class with another one
282
- *
283
- * @remarks
284
- * If the `oldClassName` doesn't exist, the `newClassName` isn't added
285
- *
286
- * @param oldClassName - The class name to remove
287
- * @param newClassName - The class name to add
288
- * @throws {TypeError} If either className is not a string.
289
- */
290
- replaceClass(oldClassName, newClassName) {
291
- if (!isStr(oldClassName)) {
292
- throw typeErr('oldClassName', 'a string', oldClassName);
293
- }
294
- if (!isStr(newClassName)) {
295
- throw typeErr('newClassName', 'a string', newClassName);
296
- }
297
- this.ref.classList.replace(oldClassName, newClassName);
298
- return this;
299
- }
300
- /**
301
-
302
- * Hides the Element by setting the `hidden` attribute and `aria-hidden="true"`.
303
- *
304
- * @returns This instance for chaining.
305
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden | hidden attribute}
306
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-hidden | aria-hidden}
307
- */
308
- hide() {
309
- return this.setAttr('hidden', '').setAttr('aria-hidden', 'true');
310
- }
311
- /**
312
- * Shows the Element by removing the `hidden` and `aria-hidden` attributes.
313
- *
314
- * @returns This instance for chaining.
315
- */
316
- show() {
317
- return this.rmAttr('hidden', 'aria-hidden');
318
- }
319
- /**
320
- * Disables the Element by setting the `disabled` attribute and `aria-disabled="true"`.
321
- *
322
- * @returns This instance for chaining.
323
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled | disabled attribute}
324
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled | aria-disabled}
325
- */
326
- disable() {
327
- return this.setAttr('disabled', '').setAttr('aria-disabled', 'true');
328
- }
329
- /**
330
- * Enables the Element by removing the `disabled` and `aria-disabled` attributes.
331
- *
332
- * @returns This instance for chaining.
333
- */
334
- enable() {
335
- return this.rmAttr('disabled', 'aria-disabled');
336
- }
337
- /**
338
- * Gets the inner HTML of the Element.
339
- *
340
- * @remarks
341
- * This method operates on `innerHTML`. The method name is kept short for convenience.
342
- *
343
- * @returns The inner HTML string.
344
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML | Element.innerHTML}
345
- */
346
- getHTML() {
347
- return this.ref.innerHTML;
348
- }
349
- /**
350
- * Sets the inner HTML of the Element.
351
- *
352
- * @remarks
353
- * This method operates on `innerHTML`. The method name is kept short for convenience.
354
- * Pass an empty string, `null`, or `undefined` to clear the content.
355
- *
356
- * @param html - The HTML string to set, or null/undefined to clear.
357
- * @returns This instance for chaining.
358
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML | Element.innerHTML}
359
- */
360
- setHTML(html) {
361
- this.ref.innerHTML = html ?? '';
362
- return this;
363
- }
364
- /**
365
- * Attaches a Shadow DOM to the Element and optionally sets its content and styles.
366
- *
367
- * @remarks
368
- * We prevent FOUC by assigning the template and CSS in one go.
369
- * **Note:** You can't attach a shadow root to every type of element. There are some that can't have a
370
- * shadow DOM for security reasons (for example `<a>`).
371
- *
372
- * @param mode - The encapsulation mode ('open' or 'closed'). Defaults to 'open'.
373
- * @param config - Optional configuration object containing `template` (HTML string) and `styles` (array of CSSStyleSheet).
374
- * @returns This instance for chaining.
375
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/attachShadow | Element.attachShadow}
376
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets | ShadowRoot.adoptedStyleSheets}
377
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/adoptedStyleSheets | Document.adoptedStyleSheets}
378
- */
379
- initShadow(mode = 'open', config) {
380
- const shadowRoot = this.ref.shadowRoot ?? this.ref.attachShadow({ mode });
381
- if (isObj(config)) {
382
- const { template, styles } = config;
383
- if (template) {
384
- shadowRoot.innerHTML = template;
385
- }
386
- if (isArr(styles) && styles.length) {
387
- shadowRoot.adoptedStyleSheets.push(...styles);
388
- }
389
- }
390
- return this;
391
- }
392
- /**
393
- * Gets a wrapper around the Element's Shadow Root, if it exists.
394
- *
395
- * @returns A JJSR instance wrapping the shadow root, or null if no shadow root exists.
396
- */
397
- get shadow() {
398
- return this.ref.shadowRoot ? new JJSR(this.ref.shadowRoot) : null;
399
- }
400
- }
401
- //# sourceMappingURL=JJE.js.map
package/lib/JJE.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"JJE.js","sourceRoot":"","sources":["../src/JJ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;CACJ"}
package/lib/JJET.d.ts DELETED
@@ -1,79 +0,0 @@
1
- /**
2
- * Wraps a DOM EventTarget.
3
- *
4
- * @remarks
5
- * This is the base class for all JJ wrappers that wrap an EventTarget.
6
- *
7
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget | EventTarget}
8
- */
9
- export declare class JJET<T extends EventTarget = EventTarget> {
10
- #private;
11
- static from(ref: EventTarget): JJET<EventTarget>;
12
- /**
13
- * Creates a JJET instance.
14
- *
15
- * @param ref - The EventTarget to wrap.
16
- * @throws {TypeError} If `ref` is not an EventTarget.
17
- */
18
- constructor(ref: T);
19
- /**
20
- * Gets the underlying DOM object.
21
- */
22
- get ref(): T;
23
- /**
24
- * Adds an event listener.
25
- *
26
- * * @example
27
- * ```ts
28
- * JJET.from(window).on('resize', () => console.log('resized'))
29
- * ```
30
- * @param eventName - The name of the event.
31
- * @param handler - The event handler.
32
- * @param options - Optional event listener options.
33
- * @returns This instance for chaining.
34
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener | EventTarget.addEventListener}
35
- */
36
- on(eventName: string, handler: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions): this;
37
- /**
38
- * Removes an event listener.
39
- *
40
- * * @example
41
- * ```ts
42
- * JJET.from(window).off('resize', previouslyAttachedHandler)
43
- * ```
44
- * @param eventName - The name of the event.
45
- * @param handler - The event handler.
46
- * @param options - Optional event listener options or boolean.
47
- * @returns This instance for chaining.
48
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener | EventTarget.removeEventListener}
49
- */
50
- off(eventName: string, handler: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): this;
51
- /**
52
- * Dispatches an Event at the specified EventTarget.
53
- *
54
- * @param event - The Event object to dispatch.
55
- * @returns This instance for chaining.
56
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent | EventTarget.dispatchEvent}
57
- */
58
- trigger(event: Event): this;
59
- /**
60
- * Runs a function in the context of this JJET instance.
61
- *
62
- * @example
63
- * ```ts
64
- * node.run(function() {
65
- * console.log(this.ref)
66
- * })
67
- * ```
68
- * @remarks
69
- * If you want to access the current JJ* instance using `this` keyword, you SHOULD use a `function` not an arrow function.
70
- * If the function throws, `run()` doesn't swallow the exception.
71
- * So if you're expecting an error, make sure to wrap it in a `try..catch` block and handle the exception.
72
- * If the function returns a promise, you can `await` on the response.
73
- *
74
- * @param fn - The function to run. `this` inside the function will refer to this JJET instance.
75
- * @param args - Arguments to pass to the function.
76
- * @returns The return value of the function.
77
- */
78
- run<R, Args extends any[]>(fn: (this: this, ...args: Args) => R, ...args: Args): R;
79
- }
package/lib/JJET.js DELETED
@@ -1,114 +0,0 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _JJET_ref;
13
- import { isA } from 'jty';
14
- /**
15
- * Wraps a DOM EventTarget.
16
- *
17
- * @remarks
18
- * This is the base class for all JJ wrappers that wrap an EventTarget.
19
- *
20
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget | EventTarget}
21
- */
22
- export class JJET {
23
- static from(ref) {
24
- return new JJET(ref);
25
- }
26
- /**
27
- * Creates a JJET instance.
28
- *
29
- * @param ref - The EventTarget to wrap.
30
- * @throws {TypeError} If `ref` is not an EventTarget.
31
- */
32
- constructor(ref) {
33
- _JJET_ref.set(this, void 0);
34
- if (!isA(ref, EventTarget)) {
35
- throw new TypeError(`JJET expects an EventTarget instance. Got ${ref} (${typeof ref}). `);
36
- }
37
- __classPrivateFieldSet(this, _JJET_ref, ref, "f");
38
- }
39
- /**
40
- * Gets the underlying DOM object.
41
- */
42
- get ref() {
43
- return __classPrivateFieldGet(this, _JJET_ref, "f");
44
- }
45
- /**
46
- * Adds an event listener.
47
- *
48
- * * @example
49
- * ```ts
50
- * JJET.from(window).on('resize', () => console.log('resized'))
51
- * ```
52
- * @param eventName - The name of the event.
53
- * @param handler - The event handler.
54
- * @param options - Optional event listener options.
55
- * @returns This instance for chaining.
56
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener | EventTarget.addEventListener}
57
- */
58
- on(eventName, handler, options) {
59
- this.ref.addEventListener(eventName, handler, options);
60
- return this;
61
- }
62
- /**
63
- * Removes an event listener.
64
- *
65
- * * @example
66
- * ```ts
67
- * JJET.from(window).off('resize', previouslyAttachedHandler)
68
- * ```
69
- * @param eventName - The name of the event.
70
- * @param handler - The event handler.
71
- * @param options - Optional event listener options or boolean.
72
- * @returns This instance for chaining.
73
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener | EventTarget.removeEventListener}
74
- */
75
- off(eventName, handler, options) {
76
- this.ref.removeEventListener(eventName, handler, options);
77
- return this;
78
- }
79
- /**
80
- * Dispatches an Event at the specified EventTarget.
81
- *
82
- * @param event - The Event object to dispatch.
83
- * @returns This instance for chaining.
84
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent | EventTarget.dispatchEvent}
85
- */
86
- trigger(event) {
87
- this.ref.dispatchEvent(event);
88
- return this;
89
- }
90
- /**
91
- * Runs a function in the context of this JJET instance.
92
- *
93
- * @example
94
- * ```ts
95
- * node.run(function() {
96
- * console.log(this.ref)
97
- * })
98
- * ```
99
- * @remarks
100
- * If you want to access the current JJ* instance using `this` keyword, you SHOULD use a `function` not an arrow function.
101
- * If the function throws, `run()` doesn't swallow the exception.
102
- * So if you're expecting an error, make sure to wrap it in a `try..catch` block and handle the exception.
103
- * If the function returns a promise, you can `await` on the response.
104
- *
105
- * @param fn - The function to run. `this` inside the function will refer to this JJET instance.
106
- * @param args - Arguments to pass to the function.
107
- * @returns The return value of the function.
108
- */
109
- run(fn, ...args) {
110
- return fn.call(this, ...args);
111
- }
112
- }
113
- _JJET_ref = new WeakMap();
114
- //# sourceMappingURL=JJET.js.map
package/lib/JJET.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"JJET.js","sourceRoot":"","sources":["../src/JJET.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB;;;;;;;GAOG;AACH,MAAM,OAAO,IAAI;IACb,MAAM,CAAC,IAAI,CAAC,GAAgB;QACxB,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;IAID;;;;;OAKG;IACH,YAAY,GAAM;QARlB,4BAAQ;QASJ,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,SAAS,CAAC,6CAA6C,GAAG,KAAK,OAAO,GAAG,KAAK,CAAC,CAAA;QAC7F,CAAC;QACD,uBAAA,IAAI,aAAQ,GAAG,MAAA,CAAA;IACnB,CAAC;IAED;;OAEG;IACH,IAAI,GAAG;QACH,OAAO,uBAAA,IAAI,iBAAK,CAAA;IACpB,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,EAAE,CAAC,SAAiB,EAAE,OAAkD,EAAE,OAAiC;QACvG,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QACtD,OAAO,IAAI,CAAA;IACf,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,GAAG,CACC,SAAiB,EACjB,OAAkD,EAClD,OAAwC;QAExC,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QACzD,OAAO,IAAI,CAAA;IACf,CAAC;IAED;;;;;;OAMG;IACH,OAAO,CAAC,KAAY;QAChB,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;QAC7B,OAAO,IAAI,CAAA;IACf,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,GAAG,CAAwB,EAAoC,EAAE,GAAG,IAAU;QAC1E,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAA;IACjC,CAAC;CACJ"}
package/lib/JJEx.d.ts DELETED
@@ -1,63 +0,0 @@
1
- import { JJE } from './JJE.js';
2
- export declare abstract class JJEx<T extends HTMLElement | SVGElement> extends JJE<T> {
3
- /**
4
- * Gets a data attribute from the HTMLElement.
5
- *
6
- * @example
7
- * ```ts
8
- * const value = el.getData('my-key')
9
- * ```
10
- *
11
- * @param name - The data attribute name (in camelCase).
12
- * @returns The value of the attribute, or undefined if not set.
13
- * @throws {TypeError} If `name` is not a string.
14
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | HTMLElement.dataset}
15
- */
16
- getData(name: string): string | undefined;
17
- /**
18
- * Checks if a data attribute exists on the HTMLElement.
19
- *
20
- * @example
21
- * ```ts
22
- * if (el.hasData('my-key')) {
23
- * // ...
24
- * }
25
- * ```
26
- *
27
- * @param name - The data attribute name (in camelCase).
28
- * @returns True if the attribute exists, false otherwise.
29
- * @throws {TypeError} If `name` is not a string.
30
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | HTMLElement.dataset}
31
- */
32
- hasData(name: string): boolean;
33
- /**
34
- * Sets one or more data attributes on the HTMLElement.
35
- *
36
- * @example
37
- * ```ts
38
- * el.setData('myKey', 'myValue') // Single
39
- * el.setData({ myKey: 'myValue', otherKey: 'otherValue' }) // Multiple
40
- * el.setData('count', 42) // Numbers are automatically converted
41
- * ```
42
- *
43
- * @throws {TypeError} If arguments are invalid types.
44
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | HTMLElement.dataset}
45
- */
46
- setData(name: string, value: any): this;
47
- setData(obj: Record<string, any>): this;
48
- /**
49
- * Removes one or more data attributes from the HTMLElement.
50
- *
51
- * @example
52
- * ```ts
53
- * el.rmData('myKey') // Remove single
54
- * el.rmData('myKey', 'otherKey') // Remove multiple
55
- * ```
56
- *
57
- * @param names - The data attribute name(s) (in camelCase).
58
- * @returns This instance for chaining.
59
- * @throws {TypeError} If any name is not a string.
60
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | HTMLElement.dataset}
61
- */
62
- rmData(...names: string[]): this;
63
- }