jj 2.1.0 → 2.3.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.
- package/lib/JJD.d.ts +76 -0
- package/lib/JJD.js +91 -0
- package/lib/JJD.js.map +1 -0
- package/lib/JJDF.d.ts +60 -0
- package/lib/JJDF.js +68 -0
- package/lib/JJDF.js.map +1 -0
- package/lib/JJE.d.ts +313 -0
- package/lib/JJE.js +412 -0
- package/lib/JJE.js.map +1 -0
- package/lib/JJHE.d.ts +120 -0
- package/lib/JJHE.js +164 -0
- package/lib/JJHE.js.map +1 -0
- package/lib/JJN.d.ts +211 -0
- package/lib/JJN.js +286 -0
- package/lib/JJN.js.map +1 -0
- package/lib/JJSE.d.ts +148 -0
- package/lib/JJSE.js +190 -0
- package/lib/JJSE.js.map +1 -0
- package/lib/JJSR.d.ts +67 -0
- package/lib/JJSR.js +85 -0
- package/lib/JJSR.js.map +1 -0
- package/lib/JJT.d.ts +79 -0
- package/lib/JJT.js +108 -0
- package/lib/JJT.js.map +1 -0
- package/lib/bundle.d.ts +1 -0
- package/lib/bundle.js +1533 -307
- package/lib/bundle.js.map +3 -3
- package/lib/bundle.min.d.ts +1 -0
- package/lib/bundle.min.js +2 -2
- package/lib/case.d.ts +57 -0
- package/lib/case.js +61 -3
- package/lib/case.js.map +1 -1
- package/lib/components.d.ts +147 -0
- package/lib/components.js +286 -0
- package/lib/components.js.map +1 -0
- package/lib/helpers.d.ts +158 -0
- package/lib/helpers.js +231 -0
- package/lib/helpers.js.map +1 -0
- package/lib/index.d.ts +13 -9
- package/lib/index.js +13 -9
- package/lib/index.js.map +1 -1
- package/lib/mixin-types.d.ts +143 -0
- package/lib/mixin-types.js +2 -0
- package/lib/mixin-types.js.map +1 -0
- package/lib/mixins.d.ts +94 -0
- package/lib/mixins.js +359 -0
- package/lib/mixins.js.map +1 -0
- package/lib/types.d.ts +77 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/util.d.ts +93 -1
- package/lib/util.js +112 -1
- package/lib/util.js.map +1 -1
- package/lib/util.test.d.ts +1 -0
- package/lib/util.test.js +46 -0
- package/lib/util.test.js.map +1 -0
- package/package.json +16 -7
- package/lib/WC.d.ts +0 -45
- package/lib/WC.js +0 -118
- package/lib/WC.js.map +0 -1
- package/lib/WDF.d.ts +0 -11
- package/lib/WDF.js +0 -31
- package/lib/WDF.js.map +0 -1
- package/lib/WE.d.ts +0 -43
- package/lib/WE.js +0 -133
- package/lib/WE.js.map +0 -1
- package/lib/WHE.d.ts +0 -21
- package/lib/WHE.js +0 -75
- package/lib/WHE.js.map +0 -1
- package/lib/WN-mixin.d.ts +0 -9
- package/lib/WN-mixin.js +0 -59
- package/lib/WN-mixin.js.map +0 -1
- package/lib/WN.d.ts +0 -34
- package/lib/WN.js +0 -145
- package/lib/WN.js.map +0 -1
- package/lib/WSH.d.ts +0 -11
- package/lib/WSH.js +0 -29
- package/lib/WSH.js.map +0 -1
- package/lib/WT.d.ts +0 -12
- package/lib/WT.js +0 -39
- package/lib/WT.js.map +0 -1
- package/lib/h.d.ts +0 -3
- package/lib/h.js +0 -9
- package/lib/h.js.map +0 -1
package/lib/util.test.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
import { fileExt } from './util.js';
|
|
4
|
+
describe('fileExt()', () => {
|
|
5
|
+
it('throws for input that is not a string or URL', () => {
|
|
6
|
+
assert.throws(() => fileExt(123), TypeError, 'Should throw for a number');
|
|
7
|
+
assert.throws(() => fileExt(true), TypeError, 'Should throw for a boolean');
|
|
8
|
+
assert.throws(() => fileExt(null), TypeError, 'Should throw for null');
|
|
9
|
+
assert.throws(() => fileExt(undefined), TypeError, 'Should throw for undefined');
|
|
10
|
+
assert.throws(() => fileExt(new URL('file.txt')), TypeError, 'Should throw for an object');
|
|
11
|
+
});
|
|
12
|
+
it('returns the extension of a file path', () => {
|
|
13
|
+
assert.strictEqual(fileExt('file.txt'), 'txt');
|
|
14
|
+
assert.strictEqual(fileExt('./file.txt'), 'txt');
|
|
15
|
+
assert.strictEqual(fileExt('./path/to/file.txt'), 'txt');
|
|
16
|
+
assert.strictEqual(fileExt('/path/to/file.txt'), 'txt');
|
|
17
|
+
});
|
|
18
|
+
it('always returns lowercase', () => {
|
|
19
|
+
assert.strictEqual(fileExt('FILE.TXT'), 'txt');
|
|
20
|
+
assert.strictEqual(fileExt('./FILE.TxT'), 'txt');
|
|
21
|
+
assert.strictEqual(fileExt('./path/to/FILE.Txt'), 'txt');
|
|
22
|
+
assert.strictEqual(fileExt('/path/to/FILE.tXT'), 'txt');
|
|
23
|
+
});
|
|
24
|
+
it('returns an empty string for non-file paths', () => {
|
|
25
|
+
assert.strictEqual(fileExt('/path/to/directory'), '');
|
|
26
|
+
assert.strictEqual(fileExt('https://www.alexewerlof.com/path/to/directory'), '');
|
|
27
|
+
});
|
|
28
|
+
it('returns empty strings if there is no extension', () => {
|
|
29
|
+
assert.strictEqual(fileExt(''), '');
|
|
30
|
+
assert.strictEqual(fileExt('.'), '');
|
|
31
|
+
assert.strictEqual(fileExt('..'), '');
|
|
32
|
+
assert.strictEqual(fileExt('file'), '');
|
|
33
|
+
assert.strictEqual(fileExt('./dir'), '');
|
|
34
|
+
assert.strictEqual(fileExt('/path/to/file.'), '');
|
|
35
|
+
});
|
|
36
|
+
it('handles edge cases for dotfiles and paths', () => {
|
|
37
|
+
// Note: This implementation differs from Node.js path.extname for dotfiles (which returns '')
|
|
38
|
+
assert.strictEqual(fileExt('.env'), 'env');
|
|
39
|
+
assert.strictEqual(fileExt('.gitignore'), 'gitignore');
|
|
40
|
+
// Directories with dots should not be confused for extensions
|
|
41
|
+
assert.strictEqual(fileExt('folder.v1/file'), '');
|
|
42
|
+
// Current behavior includes query parameters
|
|
43
|
+
assert.strictEqual(fileExt('script.js?v=1'), 'js?v=1');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
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,EAAE,EAAE,CAAC,CAAA;IACrD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACjD,8FAA8F;QAC9F,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAA;QAC1C,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,WAAW,CAAC,CAAA;QAEtD,8DAA8D;QAC9D,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAAA;QAEjD,6CAA6C;QAC7C,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,QAAQ,CAAC,CAAA;IAC1D,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jj",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "A minimal DOM manipulation library with web components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript",
|
|
@@ -13,8 +13,18 @@
|
|
|
13
13
|
"main": "./lib/index.js",
|
|
14
14
|
"unpkg": "./lib/bundle.js",
|
|
15
15
|
"exports": {
|
|
16
|
-
"
|
|
17
|
-
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./lib/index.d.ts",
|
|
18
|
+
"import": "./lib/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./lib/bundle.js": {
|
|
21
|
+
"types": "./lib/index.d.ts",
|
|
22
|
+
"import": "./lib/bundle.js"
|
|
23
|
+
},
|
|
24
|
+
"./lib/bundle.min.js": {
|
|
25
|
+
"types": "./lib/index.d.ts",
|
|
26
|
+
"import": "./lib/bundle.min.js"
|
|
27
|
+
}
|
|
18
28
|
},
|
|
19
29
|
"directories": {
|
|
20
30
|
"lib": "lib",
|
|
@@ -26,16 +36,15 @@
|
|
|
26
36
|
],
|
|
27
37
|
"scripts": {
|
|
28
38
|
"doc": "typedoc src/index.ts",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"bundle:min": "esbuild src/index.ts --bundle --outfile=lib/bundle.min.js --format=esm --minify",
|
|
39
|
+
"prebuild": "rm -rf lib docs",
|
|
40
|
+
"build": "tsc && node bundle.js && npm run doc",
|
|
32
41
|
"typecheck": "tsc --noEmit",
|
|
33
42
|
"fmt": "prettier --write .",
|
|
34
43
|
"test": "npm run typecheck && node --import tsx --test",
|
|
35
44
|
"test:watch": "npm run typecheck && node --import tsx --test --watch",
|
|
36
45
|
"test:coverage": "npm run typecheck && node --import tsx --test --experimental-test-coverage",
|
|
37
46
|
"preversion": "npm run fmt && npm t",
|
|
38
|
-
"prepublishOnly": "
|
|
47
|
+
"prepublishOnly": "npm run build",
|
|
39
48
|
"postversion": "git push && git push --tags"
|
|
40
49
|
},
|
|
41
50
|
"repository": {
|
package/lib/WC.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { WHE } from './WHE.js';
|
|
2
|
-
export declare function fetchText(url: URL | string, mime?: string): Promise<string>;
|
|
3
|
-
export declare function fetchHtml(url: URL | string): Promise<string>;
|
|
4
|
-
export declare function fetchCss(url: URL | string): Promise<string>;
|
|
5
|
-
export declare function cssToStyle(css: string): Promise<CSSStyleSheet>;
|
|
6
|
-
export declare function fetchStyle(url: URL | string): Promise<CSSStyleSheet>;
|
|
7
|
-
export declare function addLinkPre(href: string, rel: 'prefetch' | 'preload', as?: 'fetch' | 'style' | 'script'): WHE<HTMLElement>;
|
|
8
|
-
export type JJResource<T> = T | Promise<T> | (() => T | Promise<T>);
|
|
9
|
-
export type JJTemplateConfig = JJResource<string>;
|
|
10
|
-
export type JJStylesConfig = JJResource<string | CSSStyleSheet> | JJResource<string | CSSStyleSheet>[];
|
|
11
|
-
export interface JJConfig {
|
|
12
|
-
name: string;
|
|
13
|
-
template?: JJTemplateConfig;
|
|
14
|
-
styles?: JJStylesConfig;
|
|
15
|
-
templateMode?: 'open' | 'closed';
|
|
16
|
-
}
|
|
17
|
-
interface JJProcessedConfig {
|
|
18
|
-
template?: string;
|
|
19
|
-
styles: CSSStyleSheet[];
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Parent class for custom components.
|
|
23
|
-
* It adds a few pragmatic functionalities
|
|
24
|
-
* - `setTemplate` sets the template for the custom component body
|
|
25
|
-
* - `addStyle` adds a stylesheet to be used by the shadowRoot
|
|
26
|
-
* - `connectedCallback` assigns the templates to shadowRoot and attaches any styles
|
|
27
|
-
* - `attributeChangedCallback` sets any props that corresponds to attributes defined in `static observedAttributes`
|
|
28
|
-
*/
|
|
29
|
-
export declare class WC extends HTMLElement {
|
|
30
|
-
static _jjCache: Promise<JJProcessedConfig> | JJProcessedConfig | undefined;
|
|
31
|
-
static jj: JJConfig;
|
|
32
|
-
static observedAttributes?: string[];
|
|
33
|
-
static register(): Promise<void>;
|
|
34
|
-
connectedCallback(): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* The class that extends this one should define
|
|
37
|
-
* `static observedAttributes[]` containing kebab-based attribute names (all lower case)
|
|
38
|
-
* @param name kebab-case and in lower case exactly as it appears in `observedAttributes`
|
|
39
|
-
* @param oldValue
|
|
40
|
-
* @param newValue
|
|
41
|
-
* @returns true if it tried to set the attribute; otherwise false
|
|
42
|
-
*/
|
|
43
|
-
attributeChangedCallback(name: string, oldValue: any, newValue: any): boolean;
|
|
44
|
-
}
|
|
45
|
-
export {};
|
package/lib/WC.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { keb2cam } from './case.js';
|
|
2
|
-
import { WHE } from './WHE.js';
|
|
3
|
-
import { hasProp, isArr, isStr, isObj, isFn, isA, isDef } from 'jty';
|
|
4
|
-
export async function fetchText(url, mime = 'text/*') {
|
|
5
|
-
if (!isStr(mime)) {
|
|
6
|
-
throw new TypeError(`Expected a string mime like 'text/html' or 'text/css'. Got ${mime} (${typeof mime})`);
|
|
7
|
-
}
|
|
8
|
-
const response = await fetch(url, { headers: { Accept: mime } });
|
|
9
|
-
if (!response.ok) {
|
|
10
|
-
throw new Error(`GET ${url} failed: ${response.status} ${response.statusText}`);
|
|
11
|
-
}
|
|
12
|
-
return response.text();
|
|
13
|
-
}
|
|
14
|
-
export async function fetchHtml(url) {
|
|
15
|
-
return await fetchText(url, 'text/html');
|
|
16
|
-
}
|
|
17
|
-
export async function fetchCss(url) {
|
|
18
|
-
return await fetchText(url, 'text/css');
|
|
19
|
-
}
|
|
20
|
-
export async function cssToStyle(css) {
|
|
21
|
-
const sheet = new CSSStyleSheet();
|
|
22
|
-
return await sheet.replace(css);
|
|
23
|
-
}
|
|
24
|
-
export async function fetchStyle(url) {
|
|
25
|
-
return await cssToStyle(await fetchCss(url));
|
|
26
|
-
}
|
|
27
|
-
export function addLinkPre(href, rel, as = 'fetch') {
|
|
28
|
-
const link = WHE.fromTag('link').setAttrs({
|
|
29
|
-
rel,
|
|
30
|
-
href,
|
|
31
|
-
as,
|
|
32
|
-
});
|
|
33
|
-
document.head.append(link.ref);
|
|
34
|
-
return link;
|
|
35
|
-
}
|
|
36
|
-
async function processStyleConfig(style) {
|
|
37
|
-
if (isFn(style)) {
|
|
38
|
-
style = await style();
|
|
39
|
-
}
|
|
40
|
-
style = await style;
|
|
41
|
-
if (isA(style, CSSStyleSheet)) {
|
|
42
|
-
return style;
|
|
43
|
-
}
|
|
44
|
-
if (isStr(style)) {
|
|
45
|
-
return await cssToStyle(style);
|
|
46
|
-
}
|
|
47
|
-
throw new TypeError(`Expected a css string or CSSStyleSheet. Got ${style} (${typeof style})`);
|
|
48
|
-
}
|
|
49
|
-
async function processConfig(templateResource, styleResources) {
|
|
50
|
-
const templatePromise = isFn(templateResource) ? templateResource() : Promise.resolve(templateResource);
|
|
51
|
-
if (!isDef(styleResources)) {
|
|
52
|
-
styleResources = [];
|
|
53
|
-
}
|
|
54
|
-
if (!isArr(styleResources)) {
|
|
55
|
-
styleResources = [styleResources];
|
|
56
|
-
}
|
|
57
|
-
const [template, ...styles] = await Promise.all([templatePromise, ...styleResources.map(processStyleConfig)]);
|
|
58
|
-
return { template, styles };
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Parent class for custom components.
|
|
62
|
-
* It adds a few pragmatic functionalities
|
|
63
|
-
* - `setTemplate` sets the template for the custom component body
|
|
64
|
-
* - `addStyle` adds a stylesheet to be used by the shadowRoot
|
|
65
|
-
* - `connectedCallback` assigns the templates to shadowRoot and attaches any styles
|
|
66
|
-
* - `attributeChangedCallback` sets any props that corresponds to attributes defined in `static observedAttributes`
|
|
67
|
-
*/
|
|
68
|
-
export class WC extends HTMLElement {
|
|
69
|
-
static async register() {
|
|
70
|
-
if (!isObj(this.jj)) {
|
|
71
|
-
throw new Error(`static jj object is missing from the extending class. Got ${this.jj} (${typeof this.jj})`);
|
|
72
|
-
}
|
|
73
|
-
const { name } = this.jj;
|
|
74
|
-
if (!isStr(name)) {
|
|
75
|
-
throw new TypeError(`Expected a string name. Got ${name} (${typeof name})`);
|
|
76
|
-
}
|
|
77
|
-
if (!customElements.get(name)) {
|
|
78
|
-
customElements.define(name, this);
|
|
79
|
-
await customElements.whenDefined(name);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
async connectedCallback() {
|
|
83
|
-
const classRef = this.constructor;
|
|
84
|
-
const jj = classRef.jj;
|
|
85
|
-
if (!isObj(jj)) {
|
|
86
|
-
throw new TypeError(`static jj object is missing from the extending class. Got ${jj} (${typeof jj})`);
|
|
87
|
-
}
|
|
88
|
-
if (!classRef._jjCache) {
|
|
89
|
-
classRef._jjCache = processConfig(classRef.jj.template, classRef.jj.styles);
|
|
90
|
-
}
|
|
91
|
-
const { template, styles } = await classRef._jjCache;
|
|
92
|
-
const { templateMode } = jj;
|
|
93
|
-
WHE.from(this).setShadow(templateMode, template, ...styles);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* The class that extends this one should define
|
|
97
|
-
* `static observedAttributes[]` containing kebab-based attribute names (all lower case)
|
|
98
|
-
* @param name kebab-case and in lower case exactly as it appears in `observedAttributes`
|
|
99
|
-
* @param oldValue
|
|
100
|
-
* @param newValue
|
|
101
|
-
* @returns true if it tried to set the attribute; otherwise false
|
|
102
|
-
*/
|
|
103
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
104
|
-
// Called when observed attributes change.
|
|
105
|
-
if (oldValue !== newValue) {
|
|
106
|
-
const observedAttributes = this.constructor.observedAttributes;
|
|
107
|
-
if (isArr(observedAttributes) && observedAttributes.includes(name)) {
|
|
108
|
-
const kebabName = keb2cam(name);
|
|
109
|
-
if (hasProp(this, kebabName)) {
|
|
110
|
-
this[kebabName] = newValue;
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
//# sourceMappingURL=WC.js.map
|
package/lib/WC.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAEpE,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAiB,EAAE,OAAe,QAAQ;IACtE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACf,MAAM,IAAI,SAAS,CAAC,8DAA8D,IAAI,KAAK,OAAO,IAAI,GAAG,CAAC,CAAA;IAC9G,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,EA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;QAC/D,0CAA0C;QAC1C,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACxB,MAAM,kBAAkB,GAAI,IAAI,CAAC,WAAyB,CAAC,kBAAkB,CAAA;YAC7E,IAAI,KAAK,CAAC,kBAAkB,CAAC,IAAI,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBACjE,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;gBAC/B,IAAI,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC;oBAC3B,IAAI,CAAC,SAAuB,CAAC,GAAG,QAAQ,CAAA;oBACxC,OAAO,IAAI,CAAA;gBACf,CAAC;YACL,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAA;IAChB,CAAC;CACJ"}
|
package/lib/WDF.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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
DELETED
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
* We prevent FOUC by assigning the template and CSS in one go
|
|
37
|
-
* @remarks
|
|
38
|
-
* **Note:** You can't attach a shadow root to every type of element. There are some that can't have a
|
|
39
|
-
* shadow DOM for security reasons (for example `<a>`).
|
|
40
|
-
*/
|
|
41
|
-
setShadow(mode?: ShadowRootMode, html?: string, ...styleSheets: CSSStyleSheet[]): this;
|
|
42
|
-
getShadow(): WSH;
|
|
43
|
-
}
|
package/lib/WE.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { isA, isObj } from 'jty';
|
|
2
|
-
import { WN } from './WN.js';
|
|
3
|
-
import { WSH } from './WSH.js';
|
|
4
|
-
/**
|
|
5
|
-
* Wraps a DOM Element (which is a descendant of Node)
|
|
6
|
-
*/
|
|
7
|
-
export class WE extends WN {
|
|
8
|
-
static from(ref) {
|
|
9
|
-
return new WE(ref);
|
|
10
|
-
}
|
|
11
|
-
constructor(ref) {
|
|
12
|
-
if (!isA(ref, Element)) {
|
|
13
|
-
throw new TypeError(`Expected a Element. Got: ${ref} (${typeof ref})`);
|
|
14
|
-
}
|
|
15
|
-
super(ref);
|
|
16
|
-
}
|
|
17
|
-
getAttr(name) {
|
|
18
|
-
return this.ref.getAttribute(name);
|
|
19
|
-
}
|
|
20
|
-
hasAttr(name) {
|
|
21
|
-
return this.ref.hasAttribute(name);
|
|
22
|
-
}
|
|
23
|
-
setAttr(name, value) {
|
|
24
|
-
this.ref.setAttribute(name, value);
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
setAttrs(obj) {
|
|
28
|
-
if (!isObj(obj)) {
|
|
29
|
-
throw new TypeError(`Expected an object. Got: ${obj} (${typeof obj})`);
|
|
30
|
-
}
|
|
31
|
-
for (const [name, value] of Object.entries(obj)) {
|
|
32
|
-
this.setAttr(name, value);
|
|
33
|
-
}
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
rmAttr(name) {
|
|
37
|
-
return this.rmAttrs(name);
|
|
38
|
-
}
|
|
39
|
-
rmAttrs(...names) {
|
|
40
|
-
for (const name of names) {
|
|
41
|
-
this.ref.removeAttribute(name);
|
|
42
|
-
}
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
getAria(name) {
|
|
46
|
-
return this.ref.getAttribute(`aria-${name}`);
|
|
47
|
-
}
|
|
48
|
-
hasAria(name) {
|
|
49
|
-
return this.ref.hasAttribute(`aria-${name}`);
|
|
50
|
-
}
|
|
51
|
-
setAria(name, value) {
|
|
52
|
-
this.ref.setAttribute(`aria-${name}`, value);
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
rmAria(name) {
|
|
56
|
-
this.ref.removeAttribute(`aria-${name}`);
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
addClass(...classNames) {
|
|
60
|
-
this.ref.classList.add(...classNames);
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
rmClasses(...classNames) {
|
|
64
|
-
this.ref.classList.remove(...classNames);
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
rmClass(className) {
|
|
68
|
-
return this.rmClasses(className);
|
|
69
|
-
}
|
|
70
|
-
hasClass(className) {
|
|
71
|
-
return this.ref.classList.contains(className);
|
|
72
|
-
}
|
|
73
|
-
toggleClass(className) {
|
|
74
|
-
this.ref.classList.toggle(className);
|
|
75
|
-
return this;
|
|
76
|
-
}
|
|
77
|
-
onClick(handler) {
|
|
78
|
-
return this.on('click', handler);
|
|
79
|
-
}
|
|
80
|
-
hide() {
|
|
81
|
-
return this.setAttr('hidden', '').setAttr('aria-hidden', 'true');
|
|
82
|
-
}
|
|
83
|
-
show() {
|
|
84
|
-
return this.rmAttrs('hidden', 'aria-hidden');
|
|
85
|
-
}
|
|
86
|
-
disable() {
|
|
87
|
-
return this.setAttr('disabled', '').setAttr('aria-disabled', 'true');
|
|
88
|
-
}
|
|
89
|
-
enable() {
|
|
90
|
-
return this.rmAttrs('disabled', 'aria-disabled');
|
|
91
|
-
}
|
|
92
|
-
getTitle() {
|
|
93
|
-
return this.getAttr('title');
|
|
94
|
-
}
|
|
95
|
-
setTitle(title) {
|
|
96
|
-
return this.setAttr('title', title);
|
|
97
|
-
}
|
|
98
|
-
setId(id) {
|
|
99
|
-
return this.setAttr('id', id);
|
|
100
|
-
}
|
|
101
|
-
getId() {
|
|
102
|
-
return this.getAttr('id');
|
|
103
|
-
}
|
|
104
|
-
getHtml() {
|
|
105
|
-
return this.ref.innerHTML;
|
|
106
|
-
}
|
|
107
|
-
setHtml(html) {
|
|
108
|
-
this.ref.innerHTML = html;
|
|
109
|
-
return this;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* We prevent FOUC by assigning the template and CSS in one go
|
|
113
|
-
* @remarks
|
|
114
|
-
* **Note:** You can't attach a shadow root to every type of element. There are some that can't have a
|
|
115
|
-
* shadow DOM for security reasons (for example `<a>`).
|
|
116
|
-
*/
|
|
117
|
-
setShadow(mode = 'open', html, ...styleSheets) {
|
|
118
|
-
const shadowRoot = this.ref.shadowRoot ?? this.ref.attachShadow({ mode });
|
|
119
|
-
if (html) {
|
|
120
|
-
shadowRoot.innerHTML = html;
|
|
121
|
-
}
|
|
122
|
-
if (styleSheets.length) {
|
|
123
|
-
shadowRoot.adoptedStyleSheets.push(...styleSheets);
|
|
124
|
-
}
|
|
125
|
-
return this;
|
|
126
|
-
}
|
|
127
|
-
getShadow() {
|
|
128
|
-
if (!this.ref.shadowRoot)
|
|
129
|
-
throw new Error('No shadow root');
|
|
130
|
-
return new WSH(this.ref.shadowRoot);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
//# sourceMappingURL=WE.js.map
|
package/lib/WE.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WE.js","sourceRoot":"","sources":["../src/WE.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA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ED;;;;;OAKG;IACH,SAAS,CAAC,OAAuB,MAAM,EAAE,IAAa,EAAE,GAAG,WAA4B;QACnF,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;QACzE,IAAI,IAAI,EAAE,CAAC;YACP,UAAU,CAAC,SAAS,GAAG,IAAI,CAAA;QAC/B,CAAC;QACD,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;YACrB,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAA;QACtD,CAAC;QACD,OAAO,IAAI,CAAA;IACf,CAAC;IAED,SAAS;QACL,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU;YAAE,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAA;QAC3D,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IACvC,CAAC;CACJ"}
|
package/lib/WHE.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { WE } from './WE.js';
|
|
2
|
-
/**
|
|
3
|
-
* Wraps a DOM HTMLElement (which is a descendant of Element)
|
|
4
|
-
*/
|
|
5
|
-
export declare class WHE<T extends HTMLElement = HTMLElement> extends WE<T> {
|
|
6
|
-
static from(ref: HTMLElement): WHE;
|
|
7
|
-
static fromTag(tagName: string, options?: ElementCreationOptions): WHE;
|
|
8
|
-
constructor(ref: T);
|
|
9
|
-
getValue(): unknown;
|
|
10
|
-
setValue(value: string): this;
|
|
11
|
-
getData(name: string): string | undefined;
|
|
12
|
-
hasData(name: string): boolean;
|
|
13
|
-
setData(name: string, value: string): this;
|
|
14
|
-
setDataObj(obj: Record<string, string>): this;
|
|
15
|
-
rmData(name: string): this;
|
|
16
|
-
focus(): this;
|
|
17
|
-
click(): this;
|
|
18
|
-
empty(): this;
|
|
19
|
-
getText(): string;
|
|
20
|
-
setText(text: string): this;
|
|
21
|
-
}
|
package/lib/WHE.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { hasProp, isA, isStr } from 'jty';
|
|
2
|
-
import { WE } from './WE.js';
|
|
3
|
-
/**
|
|
4
|
-
* Wraps a DOM HTMLElement (which is a descendant of Element)
|
|
5
|
-
*/
|
|
6
|
-
export class WHE extends WE {
|
|
7
|
-
static from(ref) {
|
|
8
|
-
return new WHE(ref);
|
|
9
|
-
}
|
|
10
|
-
static fromTag(tagName, options) {
|
|
11
|
-
if (!isStr(tagName)) {
|
|
12
|
-
throw new TypeError(`Expected a string for tagName. Got: ${tagName} (${typeof tagName})`);
|
|
13
|
-
}
|
|
14
|
-
return new WHE(document.createElement(tagName, options));
|
|
15
|
-
}
|
|
16
|
-
constructor(ref) {
|
|
17
|
-
if (!isA(ref, HTMLElement)) {
|
|
18
|
-
throw new TypeError(`Expected a HTMLElement. Got ${ref} (${typeof ref})`);
|
|
19
|
-
}
|
|
20
|
-
super(ref);
|
|
21
|
-
}
|
|
22
|
-
getValue() {
|
|
23
|
-
if (!hasProp(this.ref, 'value')) {
|
|
24
|
-
throw new Error('Element does not have a value property');
|
|
25
|
-
}
|
|
26
|
-
return this.ref.value;
|
|
27
|
-
}
|
|
28
|
-
setValue(value) {
|
|
29
|
-
if (!hasProp(this.ref, 'value')) {
|
|
30
|
-
throw new Error('Element does not have a value property');
|
|
31
|
-
}
|
|
32
|
-
this.ref.value = value;
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
getData(name) {
|
|
36
|
-
return this.ref.dataset[name];
|
|
37
|
-
}
|
|
38
|
-
hasData(name) {
|
|
39
|
-
return hasProp(this.ref.dataset, name);
|
|
40
|
-
}
|
|
41
|
-
setData(name, value) {
|
|
42
|
-
this.ref.dataset[name] = value;
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
setDataObj(obj) {
|
|
46
|
-
for (const [name, value] of Object.entries(obj)) {
|
|
47
|
-
this.setData(name, value);
|
|
48
|
-
}
|
|
49
|
-
return this;
|
|
50
|
-
}
|
|
51
|
-
rmData(name) {
|
|
52
|
-
delete this.ref.dataset[name];
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
focus() {
|
|
56
|
-
this.ref.focus();
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
click() {
|
|
60
|
-
this.ref.click();
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
empty() {
|
|
64
|
-
this.ref.innerText = '';
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
getText() {
|
|
68
|
-
return this.ref.innerText;
|
|
69
|
-
}
|
|
70
|
-
setText(text) {
|
|
71
|
-
this.ref.innerText = text;
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=WHE.js.map
|
package/lib/WHE.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WHE.js","sourceRoot":"","sources":["../src/WHE.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAE5B;;GAEG;AACH,MAAM,OAAO,GAAyC,SAAQ,EAAK;IAC/D,MAAM,CAAC,IAAI,CAAC,GAAgB;QACxB,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,OAAe,EAAE,OAAgC;QAC5D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,SAAS,CAAC,uCAAuC,OAAO,KAAK,OAAO,OAAO,GAAG,CAAC,CAAA;QAC7F,CAAC;QACD,OAAO,IAAI,GAAG,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;I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KAAK,CAAC,CAAA;QAC7B,CAAC;QACD,OAAO,IAAI,CAAA;IACf,CAAC;IAED,MAAM,CAAC,IAAY;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAC7B,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK;QACD,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAA;QAChB,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK;QACD,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAA;QAChB,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK;QACD,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,EAAE,CAAA;QACvB,OAAO,IAAI,CAAA;IACf,CAAC;IAED,OAAO;QACH,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAA;IAC7B,CAAC;IAED,OAAO,CAAC,IAAY;QAChB,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,CAAA;QACzB,OAAO,IAAI,CAAA;IACf,CAAC;CACJ"}
|
package/lib/WN-mixin.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { WHE } from './WHE.js';
|
|
2
|
-
import { WE } from './WE.js';
|
|
3
|
-
import { WDF } from './WDF.js';
|
|
4
|
-
import { WSH } from './WSH.js';
|
|
5
|
-
import { WT } from './WT.js';
|
|
6
|
-
import { WN } from './WN.js';
|
|
7
|
-
export type Wrappable = WN | Node | string;
|
|
8
|
-
export type Wrapped = WHE | WE | WDF | WSH | WDF | WT | WN;
|
|
9
|
-
export type Unwrapped = HTMLElement | Element | ShadowRoot | DocumentFragment | Text | Node;
|