jj 2.4.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 (73) hide show
  1. package/README.md +37 -48
  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 +864 -848
  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 -2
  18. package/lib/bundle.min.js.map +1 -0
  19. package/package.json +14 -6
  20. package/lib/JJD.d.ts +0 -76
  21. package/lib/JJD.js +0 -91
  22. package/lib/JJD.js.map +0 -1
  23. package/lib/JJDF.d.ts +0 -60
  24. package/lib/JJDF.js +0 -68
  25. package/lib/JJDF.js.map +0 -1
  26. package/lib/JJE.d.ts +0 -313
  27. package/lib/JJE.js +0 -412
  28. package/lib/JJE.js.map +0 -1
  29. package/lib/JJHE.d.ts +0 -120
  30. package/lib/JJHE.js +0 -164
  31. package/lib/JJHE.js.map +0 -1
  32. package/lib/JJN.d.ts +0 -234
  33. package/lib/JJN.js +0 -323
  34. package/lib/JJN.js.map +0 -1
  35. package/lib/JJSE.d.ts +0 -148
  36. package/lib/JJSE.js +0 -190
  37. package/lib/JJSE.js.map +0 -1
  38. package/lib/JJSR.d.ts +0 -67
  39. package/lib/JJSR.js +0 -85
  40. package/lib/JJSR.js.map +0 -1
  41. package/lib/JJT.d.ts +0 -79
  42. package/lib/JJT.js +0 -108
  43. package/lib/JJT.js.map +0 -1
  44. package/lib/case.d.ts +0 -60
  45. package/lib/case.js +0 -92
  46. package/lib/case.js.map +0 -1
  47. package/lib/case.test.d.ts +0 -1
  48. package/lib/case.test.js +0 -79
  49. package/lib/case.test.js.map +0 -1
  50. package/lib/components.d.ts +0 -147
  51. package/lib/components.js +0 -286
  52. package/lib/components.js.map +0 -1
  53. package/lib/helpers.d.ts +0 -158
  54. package/lib/helpers.js +0 -231
  55. package/lib/helpers.js.map +0 -1
  56. package/lib/index.d.ts +0 -15
  57. package/lib/index.js +0 -16
  58. package/lib/index.js.map +0 -1
  59. package/lib/mixin-types.d.ts +0 -143
  60. package/lib/mixin-types.js +0 -2
  61. package/lib/mixin-types.js.map +0 -1
  62. package/lib/mixins.d.ts +0 -77
  63. package/lib/mixins.js +0 -336
  64. package/lib/mixins.js.map +0 -1
  65. package/lib/types.d.ts +0 -77
  66. package/lib/types.js +0 -2
  67. package/lib/types.js.map +0 -1
  68. package/lib/util.d.ts +0 -96
  69. package/lib/util.js +0 -122
  70. package/lib/util.js.map +0 -1
  71. package/lib/util.test.d.ts +0 -1
  72. package/lib/util.test.js +0 -46
  73. package/lib/util.test.js.map +0 -1
package/lib/helpers.js DELETED
@@ -1,231 +0,0 @@
1
- import { isA, isStr } from 'jty';
2
- import { JJHE } from './JJHE.js';
3
- import { cssToStyle, fileExt } from './util.js';
4
- /**
5
- * Hyperscript helper to create JJHE instances.
6
- * The `h` function provides a concise way to create DOM wrappers with attributes and children,
7
- * similar to hyperscript helpers found in other libraries.
8
- *
9
- *
10
- * @remarks
11
- * It returns a `JJHE` instance which wraps the native HTMLElement.
12
- *
13
- * You may recognize it from other libraries:
14
- * - [React](https://react.dev/reference/react/createElement)
15
- * - [Vue](https://vuejs.org/guide/extras/render-function)
16
- * - [Hyperscript](https://github.com/hyperhype/hyperscript)
17
- * - [Angular](https://angular.dev/guide/components/programmatic-rendering)
18
- * - [Lit](https://lit.dev/docs/components/rendering/)
19
- *
20
- * This is not exactly a replacement, but it roughly follows the same idea.
21
- *
22
- * @example
23
- * ```ts
24
- * // Create a simple div
25
- * h('div', { id: 'app' }, 'Hello World')
26
- *
27
- * // Create a nested structure
28
- * h('ul', { class: 'list' },
29
- * h('li', null, 'Item 1'),
30
- * h('li', null, 'Item 2')
31
- * )
32
- * ```
33
- *
34
- * @param tagName - The HTML tag name.
35
- * @param attributes - Attributes to set on the element. Can be null or undefined.
36
- * @param children - Children to append (strings, nodes, or other JJHE instances).
37
- * @returns The created JJHE instance.
38
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement | document.createElement}
39
- */
40
- export function h(tagName, attributes, ...children) {
41
- const ret = JJHE.fromTag(tagName).append(...children);
42
- if (attributes) {
43
- ret.setAttrs(attributes);
44
- }
45
- return ret;
46
- }
47
- /**
48
- * Tries to find the best match for the link.as attribute when it's omitted
49
- * @param href a relative, absolute, or URL resource
50
- * @returns a valid value for the link.as attribute
51
- * @throws {TypeError} if it cannot guess a valid value for the 'link.as' attribute
52
- */
53
- function linkAs(href) {
54
- switch (fileExt(href)) {
55
- case 'html':
56
- case 'htm':
57
- case 'md':
58
- return 'fetch';
59
- case 'css':
60
- return 'style';
61
- case 'js':
62
- case 'mjs':
63
- case 'cjs':
64
- return 'script';
65
- default:
66
- throw new Error(`No 'as' attribute was specified and we failed to guess it from the URL: ${href}`);
67
- }
68
- }
69
- /**
70
- * Creates a `<link>` element for prefetching or preloading resources.
71
- *
72
- * @remarks
73
- * This function validates the input arguments and returns a wrapped `JJHE` instance.
74
- * It does not append the element to the document.
75
- *
76
- * @param rel - The relationship of the linked resource ('prefetch' or 'preload').
77
- * @param href - The URL of the resource.
78
- * @param as - The type of content being loaded ('fetch' for HTML, 'style' for CSS, or 'script' for JavaScript files).
79
- * If it's not provided or set to a falsy value, it runs heuristics to find the best match from the href parameter.
80
- *
81
- * @returns The JJHE instance representing the link element. The `<link>` is accessible via `.ref`
82
- * @throws {TypeError} If `href` is not a string or URL.
83
- * @throws {RangeError} If `rel` or `as` are not valid values.
84
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/preload | Link types: preload}
85
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/prefetch | Link types: prefetch}
86
- */
87
- export function createLinkPre(rel, href, as) {
88
- if (!isStr(href)) {
89
- if (!isA(href, URL)) {
90
- throw new TypeError(`Expected a string or URL. Got ${href} (${typeof href})`);
91
- }
92
- href = href.toString();
93
- }
94
- if (!['prefetch', 'preload'].includes(rel)) {
95
- throw new RangeError(`rel should be one of 'prefetch' or 'preload'. Got ${rel} (${typeof rel})`);
96
- }
97
- if (!as) {
98
- as = linkAs(href);
99
- if (!as) {
100
- throw new Error(`No 'as' attribute was specified and we failed to guess it from the URL: ${href}`);
101
- }
102
- }
103
- if (!['fetch', 'style', 'script'].includes(as)) {
104
- throw new RangeError(`as should be one of 'fetch' or 'style'. Got ${as} (${typeof as})`);
105
- }
106
- return JJHE.fromTag('link').setAttrs({
107
- rel,
108
- href,
109
- as,
110
- });
111
- }
112
- /**
113
- * Adds a `<link>` tag to the document head for prefetching or preloading resources.
114
- *
115
- * @remarks
116
- * This function helps in optimizing performance by telling the browser to fetch resources
117
- * that might be needed later (prefetch) or are needed immediately (preload).
118
- *
119
- * Please refer to {@link createLinkPre} for more details.
120
- *
121
- * @example
122
- * ```ts
123
- * // Preload a script
124
- * addLinkPre('https://example.com/script.js', 'preload', 'script')
125
- *
126
- * // Prefetch a future page's CSS
127
- * addLinkPre('/next-page.css', 'prefetch', 'style')
128
- * ```
129
- *
130
- * @returns The JJHE instance representing the link element.
131
- * @throws {TypeError} If `href` is not a string or URL.
132
- * @throws {RangeError} If `rel` or `as` are not valid values.
133
- * @see {@link createLinkPre}
134
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/preload | Link types: preload}
135
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/prefetch | Link types: prefetch}
136
- */
137
- export function addLinkPre(...args) {
138
- const link = createLinkPre(...args);
139
- document.head.append(link.ref);
140
- return link;
141
- }
142
- /**
143
- * Fetches a file and returns its contents as string.
144
- *
145
- * @remarks
146
- * This is a wrapper around the native `fetch` API that handles the response status check
147
- * and text extraction. It sets the `Accept` header based on the provided mime type.
148
- *
149
- * @example
150
- * ```ts
151
- * const text = await fetchText('https://example.com/data.txt')
152
- * ```
153
- *
154
- * @param url - The file location.
155
- * @param mime - The HTTP Request Accept header. Defaults to 'text/*'.
156
- * @returns The file contents as a string.
157
- * @throws {TypeError} If `mime` is not a string.
158
- * @throws {Error} If the fetch fails or the response status is not OK (200-299).
159
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API | Fetch API}
160
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/text | Response.text()}
161
- */
162
- export async function fetchText(url, mime = 'text/*') {
163
- if (!isStr(mime)) {
164
- throw new TypeError(`Expected a string mime like 'text/html' or 'text/css'. Got ${mime} (${typeof mime})`);
165
- }
166
- const response = await fetch(url, { headers: { Accept: mime } });
167
- if (!response.ok) {
168
- throw new Error(`GET ${url} failed: ${response.status} ${response.statusText}`);
169
- }
170
- return response.text();
171
- }
172
- /**
173
- * Fetches the contents of a HTML file as string.
174
- *
175
- * @remarks
176
- * Useful for loading HTML templates dynamically.
177
- * You can use `import.meta.resolve('./relative-path-to.html')` to resolve paths relative to the current module.
178
- *
179
- * @example
180
- * ```ts
181
- * const template = await fetchHtml('./template.html')
182
- * ```
183
- *
184
- * @param url - The HTML file location.
185
- * @returns The file content as a string.
186
- * @throws {Error} If the response is not ok.
187
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types | MIME types}
188
- */
189
- export async function fetchHtml(url) {
190
- return await fetchText(url, 'text/html');
191
- }
192
- /**
193
- * Fetches the contents of a CSS file as string.
194
- *
195
- * @remarks
196
- * You can use `import.meta.resolve('./relative-path-to.css')` inside components to resolve relative paths.
197
- *
198
- * @example
199
- * ```ts
200
- * const css = await fetchCss('./style.css')
201
- * ```
202
- *
203
- * @param url - The CSS file location.
204
- * @returns The file content as a string.
205
- * @throws {Error} If the response is not ok.
206
- */
207
- export async function fetchCss(url) {
208
- return await fetchText(url, 'text/css');
209
- }
210
- /**
211
- * Fetches a CSS file and constructs a CSSStyleSheet.
212
- *
213
- * @remarks
214
- * This is particularly useful for Constructable Stylesheets, which can be shared across Shadow DOM boundaries.
215
- *
216
- * @example
217
- * ```ts
218
- * const sheet = await fetchStyle('./component.css')
219
- * shadowRoot.adoptedStyleSheets = [sheet]
220
- * ```
221
- *
222
- * @param url - The CSS file location.
223
- * @returns The CSSStyleSheet object constructed from the CSS contents.
224
- * @throws {Error} If the fetch fails.
225
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet | CSSStyleSheet}
226
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets | adoptedStyleSheets}
227
- */
228
- export async function fetchStyle(url) {
229
- return await cssToStyle(await fetchCss(url));
230
- }
231
- //# sourceMappingURL=helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,UAAU,CAAC,CAAC,OAAe,EAAE,UAA0C,EAAE,GAAG,QAAqB;IACnG,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAA;IACrD,IAAI,UAAU,EAAE,CAAC;QACb,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;IAC5B,CAAC;IACD,OAA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GAAG,EAAE,WAAW,CAAC,CAAA;AAC5C,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,GAAiB;IAC5C,OAAO,MAAM,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;AAC3C,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAiB;IAC9C,OAAO,MAAM,UAAU,CAAC,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA;AAChD,CAAC"}
package/lib/index.d.ts DELETED
@@ -1,15 +0,0 @@
1
- export * from './types.js';
2
- export * from './util.js';
3
- export * from './case.js';
4
- export * from './JJN.js';
5
- export * from './JJT.js';
6
- export * from './JJE.js';
7
- export * from './JJHE.js';
8
- export * from './JJSE.js';
9
- export * from './JJD.js';
10
- export * from './JJDF.js';
11
- export * from './JJSR.js';
12
- import './mixins.js';
13
- export * from './helpers.js';
14
- export * from './mixins.js';
15
- export * from './components.js';
package/lib/index.js DELETED
@@ -1,16 +0,0 @@
1
- export * from './types.js';
2
- export * from './util.js';
3
- export * from './case.js';
4
- export * from './JJN.js';
5
- export * from './JJT.js';
6
- export * from './JJE.js';
7
- export * from './JJHE.js';
8
- export * from './JJSE.js';
9
- export * from './JJD.js';
10
- export * from './JJDF.js';
11
- export * from './JJSR.js';
12
- import './mixins.js';
13
- export * from './helpers.js';
14
- export * from './mixins.js';
15
- export * from './components.js';
16
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,OAAO,aAAa,CAAA;AACpB,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA"}
@@ -1,143 +0,0 @@
1
- import { Wrappable, Wrapped } from './types.js';
2
- export interface IById {
3
- /**
4
- * Finds an element by ID within this context.
5
- *
6
- * @param id - The ID to search for.
7
- * @param throwIfNotFound - Whether to throw an error if not found. Defaults to true.
8
- * @returns The wrapped element, or null if not found and throwIfNotFound is false.
9
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector | Element.querySelector}
10
- */
11
- byId(id: string, throwIfNotFound?: boolean): Wrapped | null;
12
- }
13
- export interface IAppendPrepend {
14
- /**
15
- * Appends children to this node.
16
- *
17
- * @param children - The children to append (Nodes, strings, or Wrappers).
18
- * @returns This instance for chaining.
19
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/append | Element.append}
20
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/append | Document.append}
21
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment/append | DocumentFragment.append}
22
- */
23
- append(...children: Wrappable[]): this;
24
- /**
25
- * Prepends children to this node.
26
- *
27
- * @param children - The children to prepend.
28
- * @returns This instance for chaining.
29
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/prepend | Element.prepend}
30
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/prepend | Document.prepend}
31
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment/prepend | DocumentFragment.prepend}
32
- */
33
- prepend(...children: Wrappable[]): this;
34
- /**
35
- * Replaces the existing children of a node with a specified new set of children.
36
- *
37
- * @remarks
38
- * If no children are provided, it empties the node.
39
- *
40
- * @param this - The JJE, JJD or JJDF instance.
41
- * @param children - The children to replace with.
42
- * @returns This instance for chaining.
43
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren | Element.replaceChildren}
44
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/replaceChildren | Document.replaceChildren}
45
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment/replaceChildren | DocumentFragment.replaceChildren}
46
- */
47
- setChildren(...children: Wrappable[]): this;
48
- /**
49
- * Removes all children.
50
- *
51
- * @returns This instance for chaining.
52
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren | Element.replaceChildren}
53
- */
54
- empty(): this;
55
- }
56
- export interface IQuery {
57
- /**
58
- * Finds the first element matching a selector within this context.
59
- *
60
- * @param selector - The CSS selector.
61
- * @param throwIfNotFound - Whether to throw an error if not found. Defaults to true.
62
- * @returns The wrapped element, or null.
63
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector | Element.querySelector}
64
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector | Document.querySelector}
65
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment/querySelector | DocumentFragment.querySelector}
66
- */
67
- query(selector: string, throwIfNotFound?: boolean): Wrapped | null;
68
- /**
69
- * Finds all elements matching a selector within this context.
70
- *
71
- * @param selector - The CSS selector.
72
- * @returns An array of wrapped elements.
73
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll | Element.querySelectorAll}
74
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll | Document.querySelectorAll}
75
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment/querySelectorAll | DocumentFragment.querySelectorAll}
76
- */
77
- queryAll(selector: string): Wrapped[];
78
- }
79
- export interface IElementData {
80
- /**
81
- * Gets a data attribute value.
82
- *
83
- * @remarks
84
- * Accesses the `dataset` property. Keys should be in camelCase.
85
- *
86
- * @example
87
- * ```ts
88
- * // <div data-user-id="123"></div>
89
- * div.getData('userId') // '123'
90
- * ```
91
- *
92
- * @param name - The data attribute name (camelCase).
93
- * @returns The value or undefined.
94
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | HTMLElement.dataset}
95
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/SVGElement/dataset | SVGElement.dataset}
96
- */
97
- getData(name: string): string | undefined;
98
- /**
99
- * Checks if a data attribute exists.
100
- *
101
- * @param name - The data attribute name (camelCase).
102
- * @returns `true` if it exists.
103
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | HTMLElement.dataset}
104
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/SVGElement/dataset | SVGElement.dataset}
105
- */
106
- hasData(name: string): boolean;
107
- /**
108
- * Sets a data attribute.
109
- *
110
- * @example
111
- * ```ts
112
- * div.setData('userId', '123') // sets data-user-id="123"
113
- * ```
114
- *
115
- * @param name - The data attribute name (camelCase).
116
- * @param value - The value to set.
117
- * @returns This instance for chaining.
118
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | HTMLElement.dataset}
119
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/SVGElement/dataset | SVGElement.dataset}
120
- */
121
- setData(name: string, value: string): this;
122
- /**
123
- * Sets multiple data attributes.
124
- *
125
- * @example
126
- * ```ts
127
- * div.setDataObj({ userId: '123', role: 'admin' })
128
- * ```
129
- *
130
- * @param obj - An object of data keys and values.
131
- * @returns This instance for chaining.
132
- */
133
- setDataObj(obj: Record<string, string>): this;
134
- /**
135
- * Removes a data attribute.
136
- *
137
- * @param name - The data attribute name (camelCase).
138
- * @returns This instance for chaining.
139
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | HTMLElement.dataset}
140
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/SVGElement/dataset | SVGElement.dataset}
141
- */
142
- rmData(name: string): this;
143
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=mixin-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mixin-types.js","sourceRoot":"","sources":["../src/mixin-types.ts"],"names":[],"mappings":""}
package/lib/mixins.d.ts DELETED
@@ -1,77 +0,0 @@
1
- import { JJN } from './JJN.js';
2
- import { Wrappable, Wrapped } from './types.js';
3
- export declare const wrapAll: typeof JJN.wrapAll, unwrap: typeof JJN.unwrap, unwrapAll: typeof JJN.unwrapAll, isWrapable: typeof JJN.isWrapable;
4
- /**
5
- * Wraps a native DOM node or string into the most specific JJ wrapper available.
6
- *
7
- * @remarks
8
- * This function acts as a factory, inspecting the input type and returning the appropriate
9
- * subclass of `JJN` (e.g., `JJHE` for `HTMLElement`, `JJT` for `Text`).
10
- *
11
- * @example
12
- * ```ts
13
- * const bodyWrapper = JJN.wrap(document.body) // Returns JJHE
14
- * const textWrapper = JJN.wrap('Hello') // Returns JJT wrapping a new Text node
15
- * ```
16
- *
17
- * @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.
18
- * @returns The most granular Wrapped subclass instance. If the input is already wrapped, it'll be returned as is without cloning.
19
- * @throws {TypeError} If the input is not a Node, string, or JJ wrapper.
20
- */
21
- export declare function wrap(raw: Wrappable): Wrapped;
22
- /**
23
- * Finds an element by ID in the document.
24
- *
25
- * @example
26
- * ```ts
27
- * const el = byId('my-id')
28
- * ```
29
- *
30
- * @param id - The ID to search for.
31
- * @param throwIfNotFound - Whether to throw an error if not found. Defaults to true.
32
- * @returns The wrapped element, or null if not found and throwIfNotFound is false.
33
- * @throws {TypeError} If the element is not found and throwIfNotFound is true.
34
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById | Document.getElementById}
35
- */
36
- export declare function byId(id: string, throwIfNotFound?: boolean): Wrapped | null;
37
- /**
38
- * Finds elements by class name in the document.
39
- *
40
- * @example
41
- * ```ts
42
- * const items = byClass('list-item')
43
- * ```
44
- *
45
- * @param className - The class name to search for.
46
- * @returns An array of wrapped elements.
47
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName | Document.getElementsByClassName}
48
- */
49
- export declare function byClass(className: string): Wrapped[];
50
- /**
51
- * Finds the first element matching a selector in the document.
52
- *
53
- * @example
54
- * ```ts
55
- * const btn = query('.submit-btn')
56
- * ```
57
- *
58
- * @param selector - The CSS selector.
59
- * @param throwIfNotFound - Whether to throw an error if not found. Defaults to true.
60
- * @returns The wrapped element, or null.
61
- * @throws {TypeError} If not found and throwIfNotFound is true.
62
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector | Document.querySelector}
63
- */
64
- export declare function query(selector: string, throwIfNotFound?: boolean): Wrapped | null;
65
- /**
66
- * Finds all elements matching a selector in the document.
67
- *
68
- * @example
69
- * ```ts
70
- * const inputs = queryAll('input[type="text"]')
71
- * ```
72
- *
73
- * @param selector - The CSS selector.
74
- * @returns An array of wrapped elements.
75
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll | Document.querySelectorAll}
76
- */
77
- export declare function queryAll(selector: string): Wrapped[];