jj 0.1.1 → 2.0.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 (89) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -7
  3. package/lib/ComponentFiles.d.ts +35 -0
  4. package/lib/ComponentFiles.js +116 -0
  5. package/lib/ComponentFiles.js.map +1 -0
  6. package/lib/WC.d.ts +33 -0
  7. package/lib/WC.js +160 -0
  8. package/lib/WC.js.map +1 -0
  9. package/lib/WDF.d.ts +11 -0
  10. package/lib/WDF.js +31 -0
  11. package/lib/WDF.js.map +1 -0
  12. package/lib/WE.d.ts +42 -0
  13. package/lib/WE.js +132 -0
  14. package/lib/WE.js.map +1 -0
  15. package/lib/WF.d.ts +14 -0
  16. package/lib/WF.js +44 -0
  17. package/lib/WF.js.map +1 -0
  18. package/lib/WHE.d.ts +21 -0
  19. package/lib/WHE.js +75 -0
  20. package/lib/WHE.js.map +1 -0
  21. package/lib/WN-mixin.d.ts +9 -0
  22. package/lib/WN-mixin.js +59 -0
  23. package/lib/WN-mixin.js.map +1 -0
  24. package/lib/WN.d.ts +34 -0
  25. package/lib/WN.js +145 -0
  26. package/lib/WN.js.map +1 -0
  27. package/lib/WS.d.ts +11 -0
  28. package/lib/WS.js +32 -0
  29. package/lib/WS.js.map +1 -0
  30. package/lib/WSH.d.ts +11 -0
  31. package/lib/WSH.js +29 -0
  32. package/lib/WSH.js.map +1 -0
  33. package/lib/WT.d.ts +12 -0
  34. package/lib/WT.js +39 -0
  35. package/lib/WT.js.map +1 -0
  36. package/lib/Welem.d.ts +49 -0
  37. package/lib/Welem.js +173 -0
  38. package/lib/Welem.js.map +1 -0
  39. package/lib/Wfrag.d.ts +15 -0
  40. package/lib/Wfrag.js +56 -0
  41. package/lib/Wfrag.js.map +1 -0
  42. package/lib/Whelem.d.ts +17 -0
  43. package/lib/Whelem.js +69 -0
  44. package/lib/Whelem.js.map +1 -0
  45. package/lib/Wnode.d.ts +6 -0
  46. package/lib/Wnode.js +33 -0
  47. package/lib/Wnode.js.map +1 -0
  48. package/lib/Wshad.d.ts +9 -0
  49. package/lib/Wshad.js +31 -0
  50. package/lib/Wshad.js.map +1 -0
  51. package/lib/bundle.js +737 -0
  52. package/lib/bundle.js.map +7 -0
  53. package/lib/bundle.min.js +3 -0
  54. package/lib/case.d.ts +3 -0
  55. package/lib/case.js +34 -0
  56. package/lib/case.js.map +1 -0
  57. package/lib/case.test.d.ts +1 -0
  58. package/lib/case.test.js +79 -0
  59. package/lib/case.test.js.map +1 -0
  60. package/lib/h.d.ts +3 -0
  61. package/lib/h.js +9 -0
  62. package/lib/h.js.map +1 -0
  63. package/lib/index.d.ts +11 -0
  64. package/lib/index.js +12 -0
  65. package/lib/index.js.map +1 -0
  66. package/lib/util.d.ts +5 -0
  67. package/lib/util.js +19 -0
  68. package/lib/util.js.map +1 -0
  69. package/lib/wrap-unwrap.d.ts +22 -0
  70. package/lib/wrap-unwrap.js +68 -0
  71. package/lib/wrap-unwrap.js.map +1 -0
  72. package/package.json +56 -26
  73. package/CSS.js +0 -145
  74. package/Router.js +0 -89
  75. package/Selector.js +0 -175
  76. package/Tag.js +0 -827
  77. package/control.js +0 -74
  78. package/dist/jj.js +0 -1580
  79. package/dist/jj.js.gz +0 -0
  80. package/dist/jj.min.js +0 -1
  81. package/dist/jj.min.js.gz +0 -0
  82. package/dist/jj.min.js.map +0 -1
  83. package/events.js +0 -16
  84. package/index.js +0 -26
  85. package/observer.js +0 -27
  86. package/rollup.config.js +0 -25
  87. package/unit.js +0 -78
  88. package/util.js +0 -153
  89. package/win.js +0 -11
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Alex Ewerlöf
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,20 +1,45 @@
1
1
  # Just JavaScript!
2
2
 
3
+ **Do you know what runs faster than VDOM? No VDOM!**
4
+
3
5
  **JJ** A human readable WYWIWIR (what you write is what is run) DSL for creating and manipulating HTML and CSS for modern browsers.
4
6
 
5
- > Do you know what is faster than VDOM? No VDOM!
7
+ Modern browsers are very powerful out of the box and get you pretty far without having to "compile" (transpile) an interpreted language (`.jsx`, `.vue`, etc.) to an earlier version of it (ES5). This is a proof of concept to show how far we can go without having to compile the code.
8
+
9
+ ## Install
6
10
 
7
- Modern browsers are pretty awesome out of the box and get you pretty far without having to "compile" (transpile) an interpreted language (JavaScript) to an earlier version of it (ES5). This is a proof of concept to show how far we can go without having to compile the code.
11
+ ```bash
12
+ npm i jj
13
+ ```
14
+
15
+ # Usage
16
+
17
+ CDN:
18
+
19
+ ```js
20
+ import { nextAnimationFrame, on } from 'https://unpkg.com/browse/jj/dist/bundle.js'
21
+ ```
22
+
23
+ From NPM:
24
+
25
+ ```js
26
+ import { nextAnimationFrame, on } from 'jj'
27
+ ```
8
28
 
9
29
  ## Design principals
10
30
 
11
- * Modern: take full advantage of ever-green browser features. No support for legacy browsers
12
- * Sugar but not magic: it'll let you write shorter code but it won't do much logic behind the scene
13
- * Excplicit: make the code more readable and easier to follow
14
- * Basic: use plain old javascript objects (POJOs) for describing HTML and CSS
31
+ - Modern: take full advantage of ever-green browser features. No support for legacy browsers
32
+ - Sugar but not magic: it'll let you write shorter code but it won't do much logic behind the scene
33
+ - Excplicit: make the code more readable and easier to follow
34
+ - Basic: use plain old javascript objects (POJOs) for describing HTML and CSS
15
35
 
16
36
  # Install
17
37
 
38
+ One of the main points of using this library is to avoid compiling your code.
39
+ You can directly import it from UNPKG at https://unpkg.com/browse/jj/dist/jj.js
40
+
41
+ But if you prefer to install it via NPM:
42
+
18
43
  ```
19
44
  npm i jj
20
45
  ```
@@ -30,7 +55,10 @@ npm i jj
30
55
  ```
31
56
 
32
57
  ```javascript
58
+ // If you installed via NPM
33
59
  import { ready, html } from '/node_modules/jj/dist/jj.js'
60
+ // Is you want to directly use it via UNPKG
61
+ import { ready, html } from 'https://unpkg.com/browse/jj/dist/jj.js'
34
62
 
35
63
  ready(() => {
36
64
  html.div('Hello world!').appendToBody()
@@ -45,4 +73,4 @@ _Will be written when we reach a stable API._
45
73
 
46
74
  MIT
47
75
 
48
- _Made in Sweden 🇸🇪 by [@alexewerlof](https://mobile.twitter.com/alexewerlof)_
76
+ _Made in Sweden 🇸🇪 by [@alexewerlof](https://mobile.twitter.com/alexewerlof)_
@@ -0,0 +1,35 @@
1
+ import { WF } from './WF.js';
2
+ declare class ComponentFile {
3
+ protected href: string;
4
+ constructor(href: string);
5
+ protected _fetch(mimeSubtype: string): Promise<string>;
6
+ /**
7
+ * Creates a <lik re="preload|prefetch"> element and adds it to the document <head> element.
8
+ * @param as the link "as" attribute. Use 'fetch' for HTML, 'style' for CSS, and 'script' for JavaScript
9
+ * @param rel when set to a truthy value, a 'preload' link is created. Otherwise a 'prefetch' is created
10
+ * The difference lies in the priority of loading the resource to the browser cache where preload has higher prio.
11
+ */
12
+ protected addLinkPre(as: 'fetch' | 'style', rel: 'prefetch' | 'preload'): this;
13
+ }
14
+ export declare class TemplateFile extends ComponentFile {
15
+ #private;
16
+ constructor(href: string);
17
+ fetch(): Promise<string>;
18
+ get promise(): Promise<string>;
19
+ prefetch(): this;
20
+ preload(): this;
21
+ }
22
+ export declare class StyleFile extends ComponentFile {
23
+ #private;
24
+ constructor(href: string);
25
+ fetch(): Promise<CSSStyleSheet>;
26
+ get promise(): Promise<CSSStyleSheet>;
27
+ prefetch(): this;
28
+ preload(): this;
29
+ }
30
+ export declare class ComponentFiles {
31
+ #private;
32
+ constructor(template: TemplateFile, ...styles: StyleFile[]);
33
+ initShadow(el: HTMLElement, mode: ShadowRootMode): Promise<WF>;
34
+ }
35
+ export {};
@@ -0,0 +1,116 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ 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");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
+ if (kind === "m") throw new TypeError("Private method is not writable");
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
+ 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");
10
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
+ };
12
+ var _TemplateFile_promise, _StyleFile_promise, _ComponentFiles_template, _ComponentFiles_styles;
13
+ import { isA, isStr } from 'jty';
14
+ import { WF } from './WF.js';
15
+ import { WHE } from './WHE.js';
16
+ class ComponentFile {
17
+ constructor(href) {
18
+ this.href = href;
19
+ if (!isStr(href)) {
20
+ throw new TypeError(`Expected a string href. Got ${href} (${typeof href})`);
21
+ }
22
+ }
23
+ async _fetch(mimeSubtype) {
24
+ const response = await fetch(this.href, { headers: { Accept: `text/${mimeSubtype}` } });
25
+ if (!response.ok) {
26
+ throw new Error(`GET ${this.href} failed: ${response.status} ${response.statusText}`);
27
+ }
28
+ return response.text();
29
+ }
30
+ /**
31
+ * Creates a <lik re="preload|prefetch"> element and adds it to the document <head> element.
32
+ * @param as the link "as" attribute. Use 'fetch' for HTML, 'style' for CSS, and 'script' for JavaScript
33
+ * @param rel when set to a truthy value, a 'preload' link is created. Otherwise a 'prefetch' is created
34
+ * The difference lies in the priority of loading the resource to the browser cache where preload has higher prio.
35
+ */
36
+ addLinkPre(as, rel) {
37
+ const link = WHE.fromTag('link').setAttr('rel', rel).setAttr('href', this.href).setAttr('as', as);
38
+ document.head.append(link.ref);
39
+ return this;
40
+ }
41
+ }
42
+ export class TemplateFile extends ComponentFile {
43
+ constructor(href) {
44
+ super(href);
45
+ _TemplateFile_promise.set(this, void 0);
46
+ }
47
+ async fetch() {
48
+ return await this._fetch('html');
49
+ }
50
+ get promise() {
51
+ if (__classPrivateFieldGet(this, _TemplateFile_promise, "f") === undefined) {
52
+ __classPrivateFieldSet(this, _TemplateFile_promise, this.fetch(), "f");
53
+ }
54
+ return __classPrivateFieldGet(this, _TemplateFile_promise, "f");
55
+ }
56
+ prefetch() {
57
+ return this.addLinkPre('fetch', 'prefetch');
58
+ }
59
+ preload() {
60
+ return this.addLinkPre('fetch', 'preload');
61
+ }
62
+ }
63
+ _TemplateFile_promise = new WeakMap();
64
+ export class StyleFile extends ComponentFile {
65
+ constructor(href) {
66
+ super(href);
67
+ _StyleFile_promise.set(this, void 0);
68
+ }
69
+ async fetch() {
70
+ const cssString = await this._fetch('css');
71
+ const sheet = new CSSStyleSheet();
72
+ return await sheet.replace(`${cssString}\n/*# sourceURL=${this.href} */`);
73
+ }
74
+ get promise() {
75
+ if (__classPrivateFieldGet(this, _StyleFile_promise, "f") === undefined) {
76
+ __classPrivateFieldSet(this, _StyleFile_promise, this.fetch(), "f");
77
+ }
78
+ return __classPrivateFieldGet(this, _StyleFile_promise, "f");
79
+ }
80
+ prefetch() {
81
+ return this.addLinkPre('style', 'prefetch');
82
+ }
83
+ preload() {
84
+ return this.addLinkPre('style', 'preload');
85
+ }
86
+ }
87
+ _StyleFile_promise = new WeakMap();
88
+ export class ComponentFiles {
89
+ constructor(template, ...styles) {
90
+ _ComponentFiles_template.set(this, void 0);
91
+ _ComponentFiles_styles.set(this, void 0);
92
+ if (!isA(template, TemplateFile)) {
93
+ throw new TypeError(`Expected a ${TemplateFile.constructor.name}. Got ${template} (${typeof template})`);
94
+ }
95
+ __classPrivateFieldSet(this, _ComponentFiles_template, template, "f");
96
+ for (const style of styles) {
97
+ if (!isA(style, StyleFile)) {
98
+ throw new TypeError(`Expected a ${StyleFile.constructor.name}. Got ${style} (${typeof style})`);
99
+ }
100
+ }
101
+ __classPrivateFieldSet(this, _ComponentFiles_styles, styles, "f");
102
+ }
103
+ async initShadow(el, mode) {
104
+ // Prevent FOUC
105
+ const [template, ...styleSheets] = await Promise.all([
106
+ __classPrivateFieldGet(this, _ComponentFiles_template, "f").promise,
107
+ ...__classPrivateFieldGet(this, _ComponentFiles_styles, "f").map((style) => style.promise),
108
+ ]);
109
+ WHE.from(el).setShadow(mode, template, ...styleSheets);
110
+ if (!el.shadowRoot)
111
+ throw new Error('Shadow root not created!');
112
+ return new WF(el.shadowRoot);
113
+ }
114
+ }
115
+ _ComponentFiles_template = new WeakMap(), _ComponentFiles_styles = new WeakMap();
116
+ //# sourceMappingURL=ComponentFiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComponentFiles.js","sourceRoot":"","sources":["../src/ComponentFiles.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAChC,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,GA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 'eager' | 'lazy' | 'prefetch' | 'preload';
2
+ interface ComponentResource<T> {
3
+ get promise(): Promise<T>;
4
+ }
5
+ /**
6
+ * Parent class for custom components.
7
+ * It adds a few pragmatic functionalities
8
+ * - `setTemplate` sets the template for the custom component body
9
+ * - `addStyle` adds a stylesheet to be used by the shadowRoot
10
+ * - `connectedCallback` assigns the templates to shadowRoot and attaches any styles
11
+ * - `attributeChangedCallback` sets any props that corresponds to attributes defined in `static observedAttributes`
12
+ */
13
+ export declare class WC extends HTMLElement {
14
+ static jjTemplate?: ComponentResource<string>;
15
+ static jjStyle?: ComponentResource<CSSStyleSheet>[];
16
+ static closedShadow?: boolean;
17
+ static observedAttributes?: string[];
18
+ static setTemplateFile(href: string, loading?: LoadingStrategy): typeof WC;
19
+ static setTemplateHtml(html: string): typeof WC;
20
+ static addStyleFile(href: string, loading?: LoadingStrategy): typeof WC;
21
+ static addStyleCss(css: string): typeof WC;
22
+ connectedCallback(): Promise<void>;
23
+ /**
24
+ * The class that extends this one should define
25
+ * `static observedAttributes[]` containing kebab-based attribute names (all lower case)
26
+ * @param name kebab-case and in lower case exactly as it appears in `observedAttributes`
27
+ * @param oldValue
28
+ * @param newValue
29
+ * @returns true if it tried to set the attribute; otherwise false
30
+ */
31
+ attributeChangedCallback(name: string, oldValue: any, newValue: any): boolean;
32
+ }
33
+ export {};
package/lib/WC.js ADDED
@@ -0,0 +1,160 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ 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");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
+ if (kind === "m") throw new TypeError("Private method is not writable");
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
+ 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");
10
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
+ };
12
+ var _ComponentFile_promise;
13
+ import { keb2cam } from './case.js';
14
+ import { WHE } from './WHE.js';
15
+ import { hasProp, isArr, isStr } from 'jty';
16
+ class ComponentFile {
17
+ constructor(as, href, loading = 'lazy') {
18
+ this.as = as;
19
+ this.href = href;
20
+ _ComponentFile_promise.set(this, void 0);
21
+ if (!isStr(href)) {
22
+ throw new TypeError(`Expected a string href. Got ${href} (${typeof href})`);
23
+ }
24
+ switch (loading) {
25
+ case 'eager':
26
+ this.promise; // Trigger fetch
27
+ break;
28
+ case 'prefetch':
29
+ case 'preload':
30
+ this.addLinkPre(loading);
31
+ break;
32
+ case 'lazy':
33
+ break;
34
+ default:
35
+ throw new RangeError(`Expected a valid loading strategy. Got: ${loading} (${typeof loading})`);
36
+ }
37
+ }
38
+ /**
39
+ * Creates a <lik re="preload|prefetch"> element and adds it to the document <head> element.
40
+ * @param as the link "as" attribute. Use 'fetch' for HTML, 'style' for CSS, and 'script' for JavaScript
41
+ * @param rel when set to a truthy value, a 'preload' link is created. Otherwise a 'prefetch' is created
42
+ * The difference lies in the priority of loading the resource to the browser cache where preload has higher prio.
43
+ */
44
+ addLinkPre(rel) {
45
+ const link = WHE.fromTag('link').setAttr('rel', rel).setAttr('href', this.href).setAttr('as', this.as);
46
+ document.head.append(link.ref);
47
+ return this;
48
+ }
49
+ get promise() {
50
+ if (__classPrivateFieldGet(this, _ComponentFile_promise, "f") === undefined) {
51
+ __classPrivateFieldSet(this, _ComponentFile_promise, this.fetch(), "f");
52
+ }
53
+ return __classPrivateFieldGet(this, _ComponentFile_promise, "f");
54
+ }
55
+ }
56
+ _ComponentFile_promise = new WeakMap();
57
+ class TemplateFile extends ComponentFile {
58
+ constructor(href, loading) {
59
+ super('fetch', href, loading);
60
+ }
61
+ async fetch() {
62
+ const response = await fetch(this.href, { headers: { Accept: 'text/html' } });
63
+ if (!response.ok) {
64
+ throw new Error(`GET ${this.href} failed: ${response.status} ${response.statusText}`);
65
+ }
66
+ return response.text();
67
+ }
68
+ }
69
+ class StyleFile extends ComponentFile {
70
+ constructor(href, loading) {
71
+ super('style', href, loading);
72
+ }
73
+ async fetch() {
74
+ const response = await fetch(this.href, { headers: { Accept: 'text/css' } });
75
+ if (!response.ok) {
76
+ throw new Error(`GET ${this.href} failed: ${response.status} ${response.statusText}`);
77
+ }
78
+ const text = await response.text();
79
+ const sheet = new CSSStyleSheet();
80
+ return sheet.replace(`${text}\n/*# sourceURL=${this.href} */`);
81
+ }
82
+ }
83
+ class TemplateStr {
84
+ constructor(content) {
85
+ if (!isStr(content)) {
86
+ throw new TypeError(`Expected a HTML string. Got ${content} (${typeof content})`);
87
+ }
88
+ this.promise = Promise.resolve(content);
89
+ }
90
+ }
91
+ class StyleStr {
92
+ constructor(css) {
93
+ if (!isStr(css)) {
94
+ throw new TypeError(`Expected a CSS string. Got ${css} (${typeof css})`);
95
+ }
96
+ const sheet = new CSSStyleSheet();
97
+ this.promise = sheet.replace(css);
98
+ }
99
+ }
100
+ /**
101
+ * Parent class for custom components.
102
+ * It adds a few pragmatic functionalities
103
+ * - `setTemplate` sets the template for the custom component body
104
+ * - `addStyle` adds a stylesheet to be used by the shadowRoot
105
+ * - `connectedCallback` assigns the templates to shadowRoot and attaches any styles
106
+ * - `attributeChangedCallback` sets any props that corresponds to attributes defined in `static observedAttributes`
107
+ */
108
+ export class WC extends HTMLElement {
109
+ static setTemplateFile(href, loading) {
110
+ this.jjTemplate = new TemplateFile(href, loading);
111
+ return this;
112
+ }
113
+ static setTemplateHtml(html) {
114
+ this.jjTemplate = new TemplateStr(html);
115
+ return this;
116
+ }
117
+ static addStyleFile(href, loading) {
118
+ if (!isArr(this.jjStyle)) {
119
+ this.jjStyle = [];
120
+ }
121
+ this.jjStyle.push(new StyleFile(href, loading));
122
+ return this;
123
+ }
124
+ static addStyleCss(css) {
125
+ if (!isArr(this.jjStyle)) {
126
+ this.jjStyle = [];
127
+ }
128
+ this.jjStyle.push(new StyleStr(css));
129
+ return this;
130
+ }
131
+ async connectedCallback() {
132
+ const { jjTemplate: template, jjStyle: style = [], closedShadow } = this.constructor;
133
+ const [html, ...styleSheets] = await Promise.all([template?.promise, ...style.map((style) => style.promise)]);
134
+ // Prevent FOUC by assigning the template and CSS in one go
135
+ WHE.from(this).setShadow(closedShadow ? 'closed' : 'open', html, ...styleSheets);
136
+ }
137
+ /**
138
+ * The class that extends this one should define
139
+ * `static observedAttributes[]` containing kebab-based attribute names (all lower case)
140
+ * @param name kebab-case and in lower case exactly as it appears in `observedAttributes`
141
+ * @param oldValue
142
+ * @param newValue
143
+ * @returns true if it tried to set the attribute; otherwise false
144
+ */
145
+ attributeChangedCallback(name, oldValue, newValue) {
146
+ // Called when observed attributes change.
147
+ if (oldValue !== newValue) {
148
+ const observedAttributes = this.constructor.observedAttributes;
149
+ if (isArr(observedAttributes) && observedAttributes.includes(name)) {
150
+ const kebabName = keb2cam(name);
151
+ if (hasProp(this, kebabName)) {
152
+ this[kebabName] = newValue;
153
+ return true;
154
+ }
155
+ }
156
+ }
157
+ return false;
158
+ }
159
+ }
160
+ //# sourceMappingURL=WC.js.map
package/lib/WC.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WC.js","sourceRoot":"","sources":["../src/WC.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,OAAO,EAAO,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAUhD,MAAe,aAAa;IAGxB,YACc,EAAqB,EACrB,IAAY,EACtB,UAA2B,MAAM;QAFvB,OAAE,GAAF,EAAE,CAAmB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ACL,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAA;IAChB,CAAC;CACJ"}
package/lib/WDF.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { WN } from './WN.js';
2
+ import { Wrapped } from './WN-mixin.js';
3
+ /**
4
+ * Wraps a DocumentFragment (which is a descendant of Node)
5
+ */
6
+ export declare class WDF<T extends DocumentFragment = DocumentFragment> extends WN<T> {
7
+ static from(ref: DocumentFragment): WDF;
8
+ constructor(ref: T);
9
+ byId(id: string, throwIfNotFound?: boolean): Wrapped | null;
10
+ empty(): this;
11
+ }
package/lib/WDF.js ADDED
@@ -0,0 +1,31 @@
1
+ import { isA } from 'jty';
2
+ import { WN } from './WN.js';
3
+ /**
4
+ * Wraps a DocumentFragment (which is a descendant of Node)
5
+ */
6
+ export class WDF extends WN {
7
+ static from(ref) {
8
+ return new WDF(ref);
9
+ }
10
+ constructor(ref) {
11
+ if (!isA(ref, DocumentFragment)) {
12
+ throw new TypeError(`Expected a DocumentFragment. Got ${ref} (${typeof ref})`);
13
+ }
14
+ super(ref);
15
+ }
16
+ byId(id, throwIfNotFound = true) {
17
+ const el = this.ref.getElementById(id);
18
+ if (el) {
19
+ return WN.wrap(el);
20
+ }
21
+ if (throwIfNotFound) {
22
+ throw new TypeError(`Element with id ${id} not found`);
23
+ }
24
+ return null;
25
+ }
26
+ empty() {
27
+ this.ref.replaceChildren();
28
+ return this;
29
+ }
30
+ }
31
+ //# sourceMappingURL=WDF.js.map
package/lib/WDF.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WDF.js","sourceRoot":"","sources":["../src/WDF.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACzB,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAG5B;;GAEG;AACH,MAAM,OAAO,GAAmD,SAAQ,EAAK;IACzE,MAAM,CAAC,IAAI,CAAC,GAAqB;QAC7B,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;IAED,YAAY,GAAM;QACd,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,gBAAgB,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,SAAS,CAAC,oCAAoC,GAAG,KAAK,OAAO,GAAG,GAAG,CAAC,CAAA;QAClF,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,CAAA;IACd,CAAC;IAED,IAAI,CAAC,EAAU,EAAE,eAAe,GAAG,IAAI;QACnC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;QACtC,IAAI,EAAE,EAAE,CAAC;YACL,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACtB,CAAC;QACD,IAAI,eAAe,EAAE,CAAC;YAClB,MAAM,IAAI,SAAS,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAA;QAC1D,CAAC;QACD,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK;QACD,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,CAAA;QAC1B,OAAO,IAAI,CAAA;IACf,CAAC;CACJ"}
package/lib/WE.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ import { WN } from './WN.js';
2
+ import { WSH } from './WSH.js';
3
+ /**
4
+ * Wraps a DOM Element (which is a descendant of Node)
5
+ */
6
+ export declare class WE<T extends Element = Element> extends WN<T> {
7
+ static from(ref: Element): WE;
8
+ constructor(ref: T);
9
+ getAttr(name: string): string | null;
10
+ hasAttr(name: string): boolean;
11
+ setAttr(name: string, value: string): this;
12
+ setAttrs(obj: Record<string, string>): this;
13
+ rmAttr(name: string): this;
14
+ rmAttrs(...names: string[]): this;
15
+ getAria(name: string): string | null;
16
+ hasAria(name: string): boolean;
17
+ setAria(name: string, value: string): this;
18
+ rmAria(name: string): this;
19
+ addClass(...classNames: string[]): this;
20
+ rmClasses(...classNames: string[]): this;
21
+ rmClass(className: string): this;
22
+ hasClass(className: string): boolean;
23
+ toggleClass(className: string): this;
24
+ onClick(handler: EventListenerOrEventListenerObject): this;
25
+ hide(): this;
26
+ show(): this;
27
+ disable(): this;
28
+ enable(): this;
29
+ getTitle(): string | null;
30
+ setTitle(title: string): this;
31
+ setId(id: string): this;
32
+ getId(): string | null;
33
+ getHtml(): string;
34
+ setHtml(html: string): this;
35
+ /**
36
+ * @remarks
37
+ * **Note:** You can't attach a shadow root to every type of element. There are some that can't have a
38
+ * shadow DOM for security reasons (for example `<a>`).
39
+ */
40
+ setShadow(mode?: ShadowRootMode, html?: string, ...styleSheets: CSSStyleSheet[]): this;
41
+ getShadow(): WSH;
42
+ }