ts-dom-utils 2.3.0 → 2.3.1
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/dist/DOMisReady.cjs +1 -1
- package/dist/DOMisReady.d.cts +2 -2
- package/dist/DOMisReady.d.ts +3 -2
- package/dist/DOMisReady.js +1 -1
- package/dist/createElement.cjs +1 -1
- package/dist/createElement.d.cts +11 -12
- package/dist/createElement.d.ts +11 -12
- package/dist/createElement.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1 -1
- package/dist/qs.cjs +1 -1
- package/dist/qs.d.cts +2 -2
- package/dist/qs.d.ts +3 -2
- package/dist/qs.js +1 -1
- package/dist/qsa.cjs +1 -1
- package/dist/qsa.d.cts +2 -2
- package/dist/qsa.d.ts +3 -2
- package/dist/qsa.js +1 -1
- package/package.json +21 -4
- package/CHANGELOG.md +0 -25
- package/dist/chunk-5W33F22V.js +0 -1
- package/dist/chunk-CU3R3LAS.js +0 -1
- package/dist/chunk-QYTVIVCC.js +0 -1
- package/dist/chunk-YC4DGQBN.js +0 -1
package/dist/DOMisReady.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e=document){return new Promise(t=>{if(e.readyState!==`loading`)return t();e.addEventListener(`DOMContentLoaded`,()=>t())})}module.exports=e;
|
package/dist/DOMisReady.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/DOMisReady.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* This Promise resolves when the provided DOM is ready.
|
|
3
4
|
* This can be used to delay script execution until the DOM is fully constructed and can be safely manipulated.
|
|
@@ -29,5 +30,4 @@
|
|
|
29
30
|
* });
|
|
30
31
|
*/
|
|
31
32
|
declare function DOMisReady(doc?: Document): Promise<void>;
|
|
32
|
-
|
|
33
|
-
export { DOMisReady as default };
|
|
33
|
+
export = DOMisReady;
|
package/dist/DOMisReady.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/DOMisReady.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* This Promise resolves when the provided DOM is ready.
|
|
3
4
|
* This can be used to delay script execution until the DOM is fully constructed and can be safely manipulated.
|
|
@@ -29,5 +30,5 @@
|
|
|
29
30
|
* });
|
|
30
31
|
*/
|
|
31
32
|
declare function DOMisReady(doc?: Document): Promise<void>;
|
|
32
|
-
|
|
33
|
-
export { DOMisReady as default };
|
|
33
|
+
//#endregion
|
|
34
|
+
export { DOMisReady as default };
|
package/dist/DOMisReady.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e=document){return new Promise(t=>{if(e.readyState!==`loading`)return t();e.addEventListener(`DOMContentLoaded`,()=>t())})}export{e as default};
|
package/dist/createElement.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e,t={},n=document){let r=n.createElement(e);return Object.entries(t).forEach(([e,t])=>{t!=null&&(e===`class`?Array.isArray(t)?r.classList.add(...t):typeof t==`string`&&r.classList.add(t):e===`text`?r.textContent=t:e===`on`?Object.entries(t).forEach(([e,t])=>{typeof t==`function`?r.addEventListener(e,t):t&&typeof t==`object`&&r.addEventListener(e,t.handler,t.options)}):e in r?typeof t==`object`&&!Array.isArray(t)?Object.entries(t).forEach(([t,n])=>{r[e][t]=n}):r[e]=t:r.setAttribute(e,t))}),r}module.exports=e;
|
package/dist/createElement.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/createElement.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Create a new element with the provided options.
|
|
3
4
|
* @param tagName - The name of the element type to create.
|
|
@@ -31,21 +32,19 @@
|
|
|
31
32
|
*/
|
|
32
33
|
declare function createElement<K extends keyof HTMLElementTagNameMap>(tagName: K, options?: CreateElementOptions<K>, target?: Document): HTMLElementTagNameMap[K];
|
|
33
34
|
type EventHandler<K extends keyof HTMLElementTagNameMap, E extends keyof HTMLElementEventMap> = ((this: HTMLElementTagNameMap[K], event: HTMLElementEventMap[E]) => void) | {
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
handler: (this: HTMLElementTagNameMap[K], event: HTMLElementEventMap[E]) => void;
|
|
36
|
+
options: AddEventListenerOptions;
|
|
36
37
|
};
|
|
37
38
|
type SpecialAttributes<K extends keyof HTMLElementTagNameMap> = {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
[E in keyof HTMLElementEventMap]?: EventHandler<K, E>;
|
|
43
|
-
};
|
|
39
|
+
class?: string | string[];
|
|
40
|
+
text?: string;
|
|
41
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
42
|
+
on?: { [E in keyof HTMLElementEventMap]?: EventHandler<K, E> };
|
|
44
43
|
};
|
|
45
44
|
type CustomAttributes = {
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
[key: `aria-${string}`]: string;
|
|
46
|
+
[key: `data-${string}`]: string;
|
|
48
47
|
};
|
|
49
48
|
type CreateElementOptions<K extends keyof HTMLElementTagNameMap> = Partial<Omit<HTMLElementTagNameMap[K], keyof SpecialAttributes<K>>> & SpecialAttributes<K> & CustomAttributes;
|
|
50
|
-
|
|
51
|
-
export {
|
|
49
|
+
//#endregion
|
|
50
|
+
export { CreateElementOptions, createElement as default };
|
package/dist/createElement.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/createElement.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Create a new element with the provided options.
|
|
3
4
|
* @param tagName - The name of the element type to create.
|
|
@@ -31,21 +32,19 @@
|
|
|
31
32
|
*/
|
|
32
33
|
declare function createElement<K extends keyof HTMLElementTagNameMap>(tagName: K, options?: CreateElementOptions<K>, target?: Document): HTMLElementTagNameMap[K];
|
|
33
34
|
type EventHandler<K extends keyof HTMLElementTagNameMap, E extends keyof HTMLElementEventMap> = ((this: HTMLElementTagNameMap[K], event: HTMLElementEventMap[E]) => void) | {
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
handler: (this: HTMLElementTagNameMap[K], event: HTMLElementEventMap[E]) => void;
|
|
36
|
+
options: AddEventListenerOptions;
|
|
36
37
|
};
|
|
37
38
|
type SpecialAttributes<K extends keyof HTMLElementTagNameMap> = {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
[E in keyof HTMLElementEventMap]?: EventHandler<K, E>;
|
|
43
|
-
};
|
|
39
|
+
class?: string | string[];
|
|
40
|
+
text?: string;
|
|
41
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
42
|
+
on?: { [E in keyof HTMLElementEventMap]?: EventHandler<K, E> };
|
|
44
43
|
};
|
|
45
44
|
type CustomAttributes = {
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
[key: `aria-${string}`]: string;
|
|
46
|
+
[key: `data-${string}`]: string;
|
|
48
47
|
};
|
|
49
48
|
type CreateElementOptions<K extends keyof HTMLElementTagNameMap> = Partial<Omit<HTMLElementTagNameMap[K], keyof SpecialAttributes<K>>> & SpecialAttributes<K> & CustomAttributes;
|
|
50
|
-
|
|
51
|
-
export {
|
|
49
|
+
//#endregion
|
|
50
|
+
export { CreateElementOptions, createElement as default };
|
package/dist/createElement.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e,t={},n=document){let r=n.createElement(e);return Object.entries(t).forEach(([e,t])=>{t!=null&&(e===`class`?Array.isArray(t)?r.classList.add(...t):typeof t==`string`&&r.classList.add(t):e===`text`?r.textContent=t:e===`on`?Object.entries(t).forEach(([e,t])=>{typeof t==`function`?r.addEventListener(e,t):t&&typeof t==`object`&&r.addEventListener(e,t.handler,t.options)}):e in r?typeof t==`object`&&!Array.isArray(t)?Object.entries(t).forEach(([t,n])=>{r[e][t]=n}):r[e]=t:r.setAttribute(e,t))}),r}export{e as default};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./DOMisReady.cjs`),t=require(`./createElement.cjs`),n=require(`./qs.cjs`),r=require(`./qsa.cjs`);exports.DOMisReady=e,exports.createElement=t,exports.qs=n,exports.qsa=r;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import DOMisReady from "./DOMisReady.cjs";
|
|
2
|
+
import createElement from "./createElement.cjs";
|
|
3
|
+
import qs from "./qs.cjs";
|
|
4
|
+
import qsa from "./qsa.cjs";
|
|
5
|
+
export { DOMisReady, createElement, qs, qsa };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import DOMisReady from "./DOMisReady.js";
|
|
2
|
+
import createElement from "./createElement.js";
|
|
3
|
+
import qs from "./qs.js";
|
|
4
|
+
import qsa from "./qsa.js";
|
|
5
|
+
export { DOMisReady, createElement, qs, qsa };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"./DOMisReady.js";import t from"./createElement.js";import n from"./qs.js";import r from"./qsa.js";export{e as DOMisReady,t as createElement,n as qs,r as qsa};
|
package/dist/qs.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e,t=document){return t.querySelector(e)}module.exports=e;
|
package/dist/qs.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/qs.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* QuerySelector wrapper function.
|
|
3
4
|
* @param selector - The selector to match against.
|
|
@@ -12,5 +13,4 @@ declare function qs<K extends keyof HTMLElementTagNameMap>(selector: K, parent?:
|
|
|
12
13
|
declare function qs<K extends keyof SVGElementTagNameMap>(selector: K, parent?: ParentNode): SVGElementTagNameMap[K] | null;
|
|
13
14
|
declare function qs<K extends keyof MathMLElementTagNameMap>(selector: K, parent?: ParentNode): MathMLElementTagNameMap[K] | null;
|
|
14
15
|
declare function qs<E extends Element = Element>(selector: string, parent?: ParentNode): E | null;
|
|
15
|
-
|
|
16
|
-
export { qs as default };
|
|
16
|
+
export = qs;
|
package/dist/qs.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/qs.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* QuerySelector wrapper function.
|
|
3
4
|
* @param selector - The selector to match against.
|
|
@@ -12,5 +13,5 @@ declare function qs<K extends keyof HTMLElementTagNameMap>(selector: K, parent?:
|
|
|
12
13
|
declare function qs<K extends keyof SVGElementTagNameMap>(selector: K, parent?: ParentNode): SVGElementTagNameMap[K] | null;
|
|
13
14
|
declare function qs<K extends keyof MathMLElementTagNameMap>(selector: K, parent?: ParentNode): MathMLElementTagNameMap[K] | null;
|
|
14
15
|
declare function qs<E extends Element = Element>(selector: string, parent?: ParentNode): E | null;
|
|
15
|
-
|
|
16
|
-
export { qs as default };
|
|
16
|
+
//#endregion
|
|
17
|
+
export { qs as default };
|
package/dist/qs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e,t=document){return t.querySelector(e)}export{e as default};
|
package/dist/qsa.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e,t=document){return t.querySelectorAll(e)}module.exports=e;
|
package/dist/qsa.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/qsa.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* QuerySelectorAll wrapper function.
|
|
3
4
|
* @param selector - The selector to match against.
|
|
@@ -12,5 +13,4 @@ declare function qsa<K extends keyof HTMLElementTagNameMap>(selector: K, parent?
|
|
|
12
13
|
declare function qsa<K extends keyof SVGElementTagNameMap>(selector: K, parent?: ParentNode): NodeListOf<SVGElementTagNameMap[K]>;
|
|
13
14
|
declare function qsa<K extends keyof MathMLElementTagNameMap>(selector: K, parent?: ParentNode): NodeListOf<MathMLElementTagNameMap[K]>;
|
|
14
15
|
declare function qsa<E extends Element = Element>(selector: string, parent?: ParentNode): NodeListOf<E>;
|
|
15
|
-
|
|
16
|
-
export { qsa as default };
|
|
16
|
+
export = qsa;
|
package/dist/qsa.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/qsa.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* QuerySelectorAll wrapper function.
|
|
3
4
|
* @param selector - The selector to match against.
|
|
@@ -12,5 +13,5 @@ declare function qsa<K extends keyof HTMLElementTagNameMap>(selector: K, parent?
|
|
|
12
13
|
declare function qsa<K extends keyof SVGElementTagNameMap>(selector: K, parent?: ParentNode): NodeListOf<SVGElementTagNameMap[K]>;
|
|
13
14
|
declare function qsa<K extends keyof MathMLElementTagNameMap>(selector: K, parent?: ParentNode): NodeListOf<MathMLElementTagNameMap[K]>;
|
|
14
15
|
declare function qsa<E extends Element = Element>(selector: string, parent?: ParentNode): NodeListOf<E>;
|
|
15
|
-
|
|
16
|
-
export { qsa as default };
|
|
16
|
+
//#endregion
|
|
17
|
+
export { qsa as default };
|
package/dist/qsa.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e,t=document){return t.querySelectorAll(e)}export{e as default};
|
package/package.json
CHANGED
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-dom-utils",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "A simple utility library for DOM manipulation. Provides TypeScript typings for enhanced development experience in TS environments.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
|
-
"module": "dist/index.js",
|
|
7
6
|
"types": "dist/index.d.ts",
|
|
8
7
|
"type": "module",
|
|
9
8
|
"sideEffects": false,
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/index.d.cts",
|
|
20
|
+
"default": "./dist/index.cjs"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
10
24
|
"scripts": {
|
|
11
|
-
"build": "
|
|
25
|
+
"build": "tsdown",
|
|
26
|
+
"dev": "tsdown --watch",
|
|
12
27
|
"lint": "tsc",
|
|
13
28
|
"format": "prettier --write ./src",
|
|
14
29
|
"release": "npm run build && changeset publish"
|
|
@@ -30,9 +45,11 @@
|
|
|
30
45
|
"homepage": "https://github.com/rafaucau/ts-dom-utils#readme",
|
|
31
46
|
"funding": "https://github.com/rafaucau/ts-dom-utils?sponsor=1",
|
|
32
47
|
"devDependencies": {
|
|
48
|
+
"@arethetypeswrong/core": "^0.18.2",
|
|
33
49
|
"@changesets/cli": "^2.29.8",
|
|
34
50
|
"prettier": "^3.8.1",
|
|
35
|
-
"
|
|
51
|
+
"publint": "^0.3.17",
|
|
52
|
+
"tsdown": "^0.21.0-beta.2",
|
|
36
53
|
"typescript": "^5.9.3"
|
|
37
54
|
}
|
|
38
55
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# ts-dom-utils
|
|
2
|
-
|
|
3
|
-
## 2.3.0
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- 5880a7b: Add HTML, SVG, and MathML tag name overloads for `qs` and `qsa`, enabling automatic type inference for tag selectors (e.g. `qs('div')` returns `HTMLDivElement | null`)
|
|
8
|
-
- a0f525e: Add typed `aria-*` and `data-*` custom attribute support in `CreateElementOptions`
|
|
9
|
-
- c69b5e4: Added `on` option to `createElement` for attaching event listeners. Supports a plain handler or an object with `handler` and `options` (e.g. `once`, `passive`).
|
|
10
|
-
|
|
11
|
-
## 2.2.1
|
|
12
|
-
|
|
13
|
-
### Patch Changes
|
|
14
|
-
|
|
15
|
-
- 6cf9275: Fix typo in `aria-expanded` attribute in `createElement` example
|
|
16
|
-
- fc35c90: Update publish workflow to use OpenID Connect
|
|
17
|
-
- ad96903: Update dependencies
|
|
18
|
-
|
|
19
|
-
## 2.2.0
|
|
20
|
-
|
|
21
|
-
### Minor Changes
|
|
22
|
-
|
|
23
|
-
- 3f66d1e: - Simplified `createElement` to handle all object properties, including style.
|
|
24
|
-
- Fixed issue with styles not applying correctly.
|
|
25
|
-
- Updated style type in `SpecialAttributes` to `Partial<CSSStyleDeclaration>` for editor hints and flexibility.
|
package/dist/chunk-5W33F22V.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function E(a,r={},o=document){let t=o.createElement(a);return Object.entries(r).forEach(([s,e])=>{e!=null&&(s==="class"?Array.isArray(e)?t.classList.add(...e):typeof e=="string"&&t.classList.add(e):s==="text"?t.textContent=e:s==="on"?Object.entries(e).forEach(([i,n])=>{typeof n=="function"?t.addEventListener(i,n):n&&typeof n=="object"&&t.addEventListener(i,n.handler,n.options)}):s in t?typeof e=="object"&&!Array.isArray(e)?Object.entries(e).forEach(([i,n])=>{t[s][i]=n}):t[s]=e:t.setAttribute(s,e))}),t}export{E as a};
|
package/dist/chunk-CU3R3LAS.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function a(e,t=document){return t.querySelectorAll(e)}export{a};
|
package/dist/chunk-QYTVIVCC.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function n(e=document){return new Promise(t=>{if(e.readyState!=="loading")return t();e.addEventListener("DOMContentLoaded",()=>t())})}export{n as a};
|
package/dist/chunk-YC4DGQBN.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function n(e,t=document){return t.querySelector(e)}export{n as a};
|