domelemjs 1.2.3 → 2.0.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/README.md CHANGED
@@ -1,182 +1,286 @@
1
- # DOMelemJS
2
-
3
- This lightweight, zero dependecy tool is allow you to render HTML elements dynamically form JavaScript!
4
-
5
- Installation:
6
-
7
- ```
8
- npm i domelemjs
9
- ```
10
-
11
- Usage:
12
-
13
- ```
14
- const DOMELemjs = require('domelemjs')
15
-
16
- domelemjs.createDOMElem({tag: "div", attrs: {class: "app"}}) // retunrs and create a <div class="app">...</div
17
- domelemjs.DOMElem.create({tag: "div", attrs: {class: "app"}}) // retunrs and create a <div class="app">...</div
18
- ```
19
-
20
- There is two approach and two to use it:
21
-
22
- 1. is the Object approach:
23
- This is a tiny object with name DOMElem!
24
-
25
- Whit this approach you can create HTML element as follows:
26
-
27
- ```
28
- Elem.Create({
29
- tag: "div",
30
- attrs: { class: "app" },
31
- });
32
- ```
33
-
34
- that gives you a div with a class: app:
35
-
36
- ```
37
- <div class="app"></div>
38
- ```
39
-
40
- 2 the second way is through a function that named: createDOMElem()
41
-
42
- With this approach you should use as follows:
43
-
44
- ```
45
- const app = createDOMElem({
46
- tag: "div",
47
- attrs: { id: "app" },
48
- });
49
- ```
50
-
51
- that gives you a div with a id: app:
52
-
53
- ```
54
- <div id="app"></div>
55
- ```
56
-
57
- With this renderer you will be able to add eventListeners and styles in the moment as the DOM is created!
58
- e.g.:
59
-
60
- ```
61
- createDOMElem({
62
- tag: "h2",
63
- text: "It's amazing",
64
- parent: app,
65
- style: { color: "red", "background-color": "green" },
66
- attrs: { id: "title" },
67
- handleEvent: {
68
- event: "click",
69
- cb: (e) => console.log(e.target.id),
70
- },
71
- });
72
- ```
73
-
74
- Handle event is an object or an array of object, that should be conain:
75
-
76
- - event, what will fire the event?
77
- - and a cb, that is the callback function
78
- - you can ad as many events as you want easily in an array!
79
-
80
- You can add the children of the element same time as the element is created:
81
-
82
- ```
83
- const select = createDOMElem({
84
- tag: "select",
85
- parent: app,
86
- attrs: { id: "selector" },
87
- children: [
88
- {
89
- tag: "option",
90
- text: "foo",
91
- attr: { value: "foo" },
92
- },
93
- {
94
- tag: "option",
95
- text: "bar",
96
- attr: { value: "bar" },
97
- },
98
- ],
99
- handleEvent: {
100
- event: "change",
101
- cb: (e) => console.log(e.target.value),
102
- },
103
- });
104
- ```
105
-
106
- Adding stye is also possible as:
107
-
108
- - a string, with a bunch of style properties, it can be:
109
- - CCS style (e.g. background-color) or
110
- - JS/camelCase (e.g. backgroundColor) style formatted version also.
111
- - or an object formatted (e.g. style: { backgroundColor: red })
112
- - or an array with multiple style strings with CSS or JS vesrion, or mixed
113
-
114
- And a complex structure semms like this here:
115
-
116
- ```
117
- dateFilterContainer = document.body.appendChild(
118
- Elem.Create({
119
- tag: "div",
120
- attrs: { class: "dateFilter-Container", id: "dateFilter-Container" },
121
- children: [
122
- Elem.Create({
123
- tag: "div",
124
- attrs: {
125
- class: "beginDate-container",
126
- id: "beginDate-container",
127
- },
128
- children: [
129
- Elem.Create({
130
- tag: "label",
131
- attrs: {
132
- class: "beginDate-lable",
133
- },
134
- content: "Kezdő dátum: ",
135
- }),
136
- Elem.Create({
137
- tag: "input",
138
- attrs: {
139
- type: "date",
140
- class: "beginDate",
141
- id: "beginDate",
142
- },
143
- eventStarter: "change",
144
- eventFunction: function (e) {
145
- e.preventDefault();
146
- console.log(this.value);
147
- },
148
- }),
149
- ],
150
- }),
151
- Elem.Create({
152
- tag: "div",
153
- attrs: { class: "endDate-container", id: "endDate-container" },
154
- children: [
155
- Elem.Create({
156
- tag: "label",
157
- attrs: {
158
- class: "endDate-lable",
159
- },
160
- content: "Befejező dátum: ",
161
- }),
162
- Elem.Create({
163
- tag: "input",
164
- attrs: {
165
- type: "date",
166
- class: "endDate",
167
- id: "endDate",
168
- },
169
- eventStarter: "change",
170
- eventFunction: function (e) {
171
- e.preventDefault();
172
- console.log(this.value);
173
- },
174
- }),
175
- ],
176
- }),
177
- ],
178
- })
179
- );
180
- ```
181
-
182
- Under MIT license.
1
+ # DOMelemJS
2
+
3
+ A lightweight, zero-dependency TypeScript library for dynamically creating HTML elements from JavaScript.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/domelemjs)](https://www.npmjs.com/package/domelemjs)
6
+ [![license](https://img.shields.io/npm/l/domelemjs)](https://github.com/exphoenee/DOMelemJS/blob/main/LICENSE)
7
+
8
+ [Magyar README](README-hu.md) | [English README](README.md)
9
+
10
+ ## Installation
11
+
12
+ ### npm
13
+
14
+ ```bash
15
+ npm install domelemjs
16
+ ```
17
+
18
+ ### CDN (unpkg)
19
+
20
+ No build tools needed include directly in your HTML:
21
+
22
+ ```html
23
+ <script src="https://unpkg.com/domelemjs/dist/index.browser.js"></script>
24
+ <script>
25
+ const { createDOMElem, DOMElem } = DOMElemJS;
26
+
27
+ const app = createDOMElem({
28
+ tag: "div",
29
+ attrs: { id: "app" },
30
+ text: "Hello from CDN!",
31
+ });
32
+ </script>
33
+ ```
34
+
35
+ Pin a specific version:
36
+
37
+ ```html
38
+ <script src="https://unpkg.com/domelemjs@2.0.0/dist/index.browser.js"></script>
39
+ ```
40
+
41
+ ## Quick Start
42
+
43
+ ```ts
44
+ import { createDOMElem } from "domelemjs";
45
+
46
+ const app = createDOMElem({
47
+ tag: "div",
48
+ attrs: { id: "app" },
49
+ });
50
+ ```
51
+
52
+ ## API
53
+
54
+ ### `createDOMElem(options)`
55
+
56
+ The core function. Creates a DOM element and returns the `HTMLElement`.
57
+
58
+ ```ts
59
+ const el = createDOMElem({
60
+ tag: "h1",
61
+ text: "Hello World",
62
+ attrs: { class: "title" },
63
+ style: { color: "blue" },
64
+ parent: "#app",
65
+ });
66
+ ```
67
+
68
+ ### `new DOMElem(options)`
69
+
70
+ Class-based wrapper. The created element is available on `.elem`.
71
+
72
+ ```ts
73
+ import { DOMElem } from "domelemjs";
74
+
75
+ const div = new DOMElem({
76
+ tag: "div",
77
+ text: "Hello",
78
+ attrs: { class: "container" },
79
+ });
80
+
81
+ document.body.appendChild(div.elem);
82
+ ```
83
+
84
+ ## Options
85
+
86
+ | Option | Type | Description |
87
+ |---|---|---|
88
+ | `tag` | `string` | **Required.** HTML tag name (e.g. `"div"`, `"span"`, `"input"`). |
89
+ | `text` | `string` | Plain text content (`textContent`). |
90
+ | `content` | `string` | Raw HTML content (`innerHTML`). |
91
+ | `attrs` | `object \| object[]` | HTML attributes to set. Supports `class`, `id`, `data-*`, `checked`, etc. |
92
+ | `style` | `string \| object \| array` | Inline CSS styles (see [Styling](#styling)). |
93
+ | `children` | `array` | Child elements — either options objects or `HTMLElement`s. |
94
+ | `parent` | `HTMLElement \| string` | Parent to append to. Accepts an element or a CSS selector (`"#app"`, `".container"`, `"app"`). Defaults to `document.body`. |
95
+ | `handleEvent` | `object \| object[]` | Event listeners to attach (see [Events](#events)). |
96
+ | `append` | `boolean` | Whether to append the element to its parent. Defaults to `true`. |
97
+ | `stripDiacritics` | `boolean` | Whether to strip diacritics from `class` and `id` attributes. Defaults to `true`. Set to `false` to preserve Unicode characters. |
98
+
99
+ ## Styling
100
+
101
+ Styles can be provided in multiple formats:
102
+
103
+ ```ts
104
+ // CSS string
105
+ createDOMElem({
106
+ tag: "div",
107
+ style: "color: red; background-color: blue",
108
+ });
109
+
110
+ // Object
111
+ createDOMElem({
112
+ tag: "div",
113
+ style: { color: "red", backgroundColor: "blue" },
114
+ });
115
+
116
+ // Array (mixed)
117
+ createDOMElem({
118
+ tag: "div",
119
+ style: ["color: red", { backgroundColor: "blue" }],
120
+ });
121
+ ```
122
+
123
+ ## Events
124
+
125
+ Attach event listeners via `handleEvent`:
126
+
127
+ ```ts
128
+ createDOMElem({
129
+ tag: "button",
130
+ text: "Click me",
131
+ handleEvent: {
132
+ event: "click",
133
+ cb: (e) => console.log("clicked!"),
134
+ },
135
+ });
136
+ ```
137
+
138
+ Multiple events can be passed as an array:
139
+
140
+ ```ts
141
+ createDOMElem({
142
+ tag: "input",
143
+ handleEvent: [
144
+ { event: "focus", cb: () => console.log("focused") },
145
+ { event: "blur", cb: () => console.log("blurred") },
146
+ ],
147
+ });
148
+ ```
149
+
150
+ ## Attributes
151
+
152
+ Attributes can be a single object or an array:
153
+
154
+ ```ts
155
+ createDOMElem({
156
+ tag: "input",
157
+ attrs: [
158
+ { id: "myInput", type: "text" },
159
+ { class: "form-control" },
160
+ ],
161
+ });
162
+ ```
163
+
164
+ Special attribute handling:
165
+ - **`checked`** — sets the checked property on inputs
166
+ - **`dataset`** — merges `data-*` attributes (e.g. `{ dataset: { id: "foo" } }` becomes `data-id="foo"`)
167
+ - **`class` / `id`** — special characters (diacritics) are automatically stripped by default. Set `stripDiacritics: false` to preserve them.
168
+
169
+ > **Note:** If both `text` and `content` are provided, `text` takes precedence and a warning is logged.
170
+
171
+ ## Managing Event Listeners
172
+
173
+ The `DOMElem` class tracks event listeners and supports removal:
174
+
175
+ ```ts
176
+ import { DOMElem } from "domelemjs";
177
+
178
+ const btn = new DOMElem({
179
+ tag: "button",
180
+ text: "Click me",
181
+ });
182
+
183
+ const handler = () => console.log("clicked!");
184
+ btn.addEventListener("click", handler);
185
+ btn.removeEventListener("click", handler);
186
+
187
+ // Remove all tracked listeners at once
188
+ btn.removeAllListeners();
189
+ ```
190
+
191
+ ## HTML Tags
192
+
193
+ DOMelemJS exports a list of valid HTML tag names:
194
+
195
+ ```ts
196
+ import { HTML_TAGS } from "domelemjs";
197
+
198
+ if (HTML_TAGS.includes(tag)) {
199
+ // valid HTML tag
200
+ }
201
+ ```
202
+
203
+ ## Children
204
+
205
+ Children can be nested options objects or existing `HTMLElement`s:
206
+
207
+ ```ts
208
+ createDOMElem({
209
+ tag: "select",
210
+ attrs: { id: "selector" },
211
+ children: [
212
+ { tag: "option", text: "Foo", attrs: { value: "foo" } },
213
+ { tag: "option", text: "Bar", attrs: { value: "bar" } },
214
+ ],
215
+ });
216
+ ```
217
+
218
+ ## Complex Example
219
+
220
+ ```ts
221
+ import { createDOMElem } from "domelemjs";
222
+
223
+ const container = createDOMElem({
224
+ tag: "div",
225
+ attrs: { class: "date-filter" },
226
+ children: [
227
+ {
228
+ tag: "div",
229
+ attrs: { class: "date-group" },
230
+ children: [
231
+ {
232
+ tag: "label",
233
+ text: "Start date:",
234
+ attrs: { for: "startDate" },
235
+ },
236
+ {
237
+ tag: "input",
238
+ attrs: { type: "date", id: "startDate" },
239
+ handleEvent: {
240
+ event: "change",
241
+ cb: (e) => console.log("Start:", (e.target as HTMLInputElement).value),
242
+ },
243
+ },
244
+ ],
245
+ },
246
+ {
247
+ tag: "div",
248
+ attrs: { class: "date-group" },
249
+ children: [
250
+ {
251
+ tag: "label",
252
+ text: "End date:",
253
+ attrs: { for: "endDate" },
254
+ },
255
+ {
256
+ tag: "input",
257
+ attrs: { type: "date", id: "endDate" },
258
+ handleEvent: {
259
+ event: "change",
260
+ cb: (e) => console.log("End:", (e.target as HTMLInputElement).value),
261
+ },
262
+ },
263
+ ],
264
+ },
265
+ ],
266
+ });
267
+ ```
268
+
269
+ ## TypeScript
270
+
271
+ DOMelemJS is written in TypeScript and ships with full type definitions.
272
+
273
+ ```ts
274
+ import { createDOMElem, type CreateDOMElemOptions } from "domelemjs";
275
+
276
+ const options: CreateDOMElemOptions = {
277
+ tag: "div",
278
+ text: "Typed!",
279
+ };
280
+
281
+ const el = createDOMElem(options);
282
+ ```
283
+
284
+ ## License
285
+
286
+ MIT
@@ -0,0 +1,2 @@
1
+ "use strict";var DOMElemJS=(()=>{var u=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var O=(t,e)=>{for(var n in e)u(t,n,{get:e[n],enumerable:!0})},L=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of b(e))!M.call(t,o)&&o!==n&&u(t,o,{get:()=>e[o],enumerable:!(r=g(e,o))||r.enumerable});return t};var T=t=>L(u({},"__esModule",{value:!0}),t);var x={};O(x,{DOMElem:()=>p,HTML_TAGS:()=>E,createDOMElem:()=>l});function f(t){return t.split("-").map((e,n)=>n>0?e.charAt(0).toUpperCase()+e.slice(1):e).join("")}function m(t){return t==null?[]:Array.isArray(t)?t:[t]}function h(t,e=!1){let n={\u00E1:"a",\u00E9:"e",\u00ED:"i",\u00F3:"o",\u00F6:"o",\u0151:"o",\u00FA:"u",\u00FC:"u",\u0171:"u",\u00C1:"A",\u00C9:"E",\u00CD:"I",\u00D3:"O",\u00D6:"O",\u0150:"O",\u00DA:"U",\u00DC:"U",\u0170:"U",\u00E0:"a",\u00E8:"e",\u00EC:"i",\u00F2:"o",\u00F9:"u",\u00E2:"a",\u00EA:"e",\u00EE:"i",\u00F4:"o",\u00FB:"u",\u0103:"a",\u0115:"e",\u012D:"i",\u014F:"o",\u016D:"u",\u0101:"a",\u0113:"e",\u012B:"i",\u014D:"o",\u016B:"u",\u01CE:"a",\u011B:"e",\u01D0:"i",\u01D2:"o",\u01D4:"u",\u00E4:"a",\u00EB:"e",\u00EF:"i",\u00E5:"a",\u00F8:"o",\u00E3:"a",\u00F5:"o",\u00E6:"ae",\u00E7:"c",\u011F:"g",\u0142:"l",\u00F1:"n",\u0111:"d",\u00DF:"ss",\u010F:"d",\u0165:"t",\u0148:"n",\u0159:"r",\u0161:"s",\u017E:"z",\u0158:"R",\u0160:"S",\u017D:"Z",\u00C7:"C",\u015E:"S",\u011E:"G",\u0141:"L",\u00D1:"N",\u0110:"D",\u013E:"l",\u0155:"r",\u013A:"l"},r=t;for(let[o,i]of Object.entries(n))r=r.split(o).join(i);return e?r.toLowerCase():r}var A=["class","id"];function S(t){if(t instanceof HTMLElement)return t;let e=null;return t.charAt(0)==="#"||t.charAt(0)==="."?e=document.querySelector(t):e=document.querySelector(`#${t}`)||document.querySelector(`.${t}`)||document.querySelector(t),e||(console.warn(`[DOMElemJS] Parent element not found for selector: "${t}". Falling back to document.body.`),document.body)}function C(t,e,n){for(let r of m(e))for(let[o,i]of Object.entries(r))if(i!=null)if(o==="checked")t.checked=!!i;else if(o==="dataset"&&typeof i=="object"&&!Array.isArray(i))Object.assign(t.dataset,i);else{let a=(Array.isArray(i)?i:[i]).map(d=>n&&A.includes(o)?h(String(d)):String(d));t.setAttribute(o,a.join(" "))}}function H(t,e){m(e).map(r=>typeof r=="object"&&r!==null?Object.entries(r).map(([o,i])=>`${o}: ${i}`).join("; "):m(r).join("; ")).join("; ").split(";").filter(Boolean).forEach(r=>{let o=r.indexOf(":");if(o===-1)return;let i=r.slice(0,o).trim(),c=r.slice(o+1).trim();if(i){let a=f(i);t.style[a]=c}})}function k(t,e){for(let n of e)n instanceof HTMLElement?t.appendChild(n):t.appendChild(l(n))}function _(t,e){for(let n of m(e))n?.event&&n?.cb&&t.addEventListener(n.event,n.cb)}function l(t){let{tag:e,content:n,text:r,attrs:o,style:i,children:c,parent:a,handleEvent:d,append:v=!0,stripDiacritics:y=!0}=t;n&&r&&console.warn(`[DOMElemJS] Both "content" and "text" provided for <${e}>. "text" takes precedence \u2014 "content" will be ignored.`);let s=document.createElement(e);return r?s.textContent=r:n&&(s.innerHTML=n),o&&C(s,o,y),i&&H(s,i),c&&k(s,c),d&&_(s,d),v&&(a?S(a):document.body).appendChild(s),s}var p=class{constructor(e){this._listeners=new Map;if(this.options=e,this.elem=l(e),e.handleEvent){let n=Array.isArray(e.handleEvent)?e.handleEvent:[e.handleEvent];for(let r of n)this._trackListener(r.event,r.cb)}}addEventListener(e,n){return this.elem.addEventListener(e,n),this._trackListener(e,n),this}removeEventListener(e,n){return this.elem.removeEventListener(e,n),this._untrackListener(e,n),this}removeAllListeners(){for(let[e,n]of this._listeners)for(let r of n)this.elem.removeEventListener(e,r);this._listeners.clear()}_trackListener(e,n){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(n)}_untrackListener(e,n){this._listeners.get(e)?.delete(n)}};var E=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","video","wbr"];return T(x);})();
2
+ //# sourceMappingURL=index.browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/utils.ts","../src/createDOMElem.ts","../src/DOMElem.ts","../src/htmlTags.ts"],"sourcesContent":["/**\n * DOMelemJS — a lightweight, zero-dependency library for creating\n * DOM elements from JavaScript/TypeScript.\n *\n * @example\n * ```ts\n * import { createDOMElem, DOMElem } from \"domelemjs\";\n *\n * // Functional API\n * const el = createDOMElem({\n * tag: \"div\",\n * text: \"Hello\",\n * attrs: { id: \"app\" },\n * });\n *\n * // Class API\n * const div = new DOMElem({ tag: \"div\", text: \"World\" });\n * ```\n *\n * @packageDocumentation\n */\n\nexport { default as DOMElem } from \"./DOMElem\";\nexport { default as createDOMElem } from \"./createDOMElem\";\nexport { HTML_TAGS } from \"./htmlTags\";\nexport type {\n CreateDOMElemOptions,\n DOMElemOptions,\n EventHandler,\n StyleInput,\n AttrsInput,\n ParentInput,\n HtmlTag,\n} from \"./types\";\nexport type { HtmlTagConst } from \"./htmlTags\";\n","/**\n * Converts a kebab-case string to camelCase.\n *\n * @example\n * makeCamelCase(\"background-color\") // \"backgroundColor\"\n * makeCamelCase(\"font-size\") // \"fontSize\"\n *\n * @param s - The kebab-case string to convert.\n * @returns The camelCase version of the input.\n */\nexport function makeCamelCase(s: string): string {\n return s\n .split(\"-\")\n .map((part, i) => (i > 0 ? part.charAt(0).toUpperCase() + part.slice(1) : part))\n .join(\"\");\n}\n\n/**\n * Ensures the given value is wrapped in an array.\n * Returns an empty array for `null` / `undefined`.\n *\n * @example\n * toArray(\"hello\") // [\"hello\"]\n * toArray([\"a\", \"b\"]) // [\"a\", \"b\"]\n * toArray(null) // []\n *\n * @param value - The value to normalize.\n * @returns An array containing the value, or an empty array if falsy.\n */\nexport function toArray<T>(value: T | T[] | undefined | null): T[] {\n if (value == null) return [];\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Replaces accented / special characters with their ASCII equivalents.\n *\n * Supports Hungarian, Czech, Polish, Turkish, and other Latin-script diacritics.\n *\n * @example\n * noSpecChars(\"árvíztűrő\") // \"arviztuoro\"\n * noSpecChars(\"Árvíz\", true) // \"arviz\"\n *\n * @param text - The input string containing special characters.\n * @param lowercase - If `true`, the result is lowercased after replacement.\n * @returns The string with special characters replaced.\n */\nexport function noSpecChars(text: string, lowercase = false): string {\n const map: Record<string, string> = {\n á: \"a\", é: \"e\", í: \"i\", ó: \"o\", ö: \"o\", ő: \"o\",\n ú: \"u\", ü: \"u\", ű: \"u\",\n Á: \"A\", É: \"E\", Í: \"I\", Ó: \"O\", Ö: \"O\", Ő: \"O\",\n Ú: \"U\", Ü: \"U\", Ű: \"U\",\n à: \"a\", è: \"e\", ì: \"i\", ò: \"o\", ù: \"u\",\n â: \"a\", ê: \"e\", î: \"i\", ô: \"o\", û: \"u\",\n ă: \"a\", ĕ: \"e\", ĭ: \"i\", ŏ: \"o\", ŭ: \"u\",\n ā: \"a\", ē: \"e\", ī: \"i\", ō: \"o\", ū: \"u\",\n ǎ: \"a\", ě: \"e\", ǐ: \"i\", ǒ: \"o\", ǔ: \"u\",\n ä: \"a\", ë: \"e\", ï: \"i\",\n å: \"a\", ø: \"o\",\n ã: \"a\", õ: \"o\",\n æ: \"ae\",\n ç: \"c\", ğ: \"g\",\n ł: \"l\",\n ñ: \"n\",\n đ: \"d\",\n ß: \"ss\",\n ď: \"d\", ť: \"t\", ň: \"n\",\n ř: \"r\", š: \"s\", ž: \"z\",\n Ř: \"R\", Š: \"S\", Ž: \"Z\",\n Ç: \"C\", Ş: \"S\", Ğ: \"G\",\n Ł: \"L\", Ñ: \"N\", Đ: \"D\",\n ľ: \"l\", ŕ: \"r\", ĺ: \"l\",\n };\n\n let result = text;\n for (const [char, replacement] of Object.entries(map)) {\n result = result.split(char).join(replacement);\n }\n\n return lowercase ? result.toLowerCase() : result;\n}\n","import { makeCamelCase, toArray, noSpecChars } from \"./utils\";\nimport type { CreateDOMElemOptions, AttrsInput, StyleInput } from \"./types\";\n\n/** Attributes that have special characters stripped automatically. */\nconst NO_SPEC_CHARS_ATTRS = [\"class\", \"id\"];\n\n/**\n * Resolves a parent element from a string selector or HTMLElement reference.\n *\n * If the string starts with `#` or `.`, it is used directly as a querySelector\n * argument. Otherwise, it is tried first as `#<selector>` then as `.<selector>`.\n *\n * @param parent - An HTMLElement or a CSS selector string.\n * @returns The resolved HTMLElement.\n * @throws Will console.warn if the selector does not match any element.\n */\nfunction resolveParent(parent: HTMLElement | string): HTMLElement {\n if (parent instanceof HTMLElement) return parent;\n\n let el: Element | null = null;\n\n if (parent.charAt(0) === \"#\" || parent.charAt(0) === \".\") {\n el = document.querySelector(parent);\n } else {\n el =\n document.querySelector(`#${parent}`) ||\n document.querySelector(`.${parent}`) ||\n document.querySelector(parent);\n }\n\n if (!el) {\n console.warn(\n `[DOMElemJS] Parent element not found for selector: \"${parent}\". ` +\n `Falling back to document.body.`\n );\n return document.body;\n }\n\n return el as HTMLElement;\n}\n\n/**\n * Applies HTML attributes to an element from an {@link AttrsInput}.\n *\n * Handles special cases:\n * - `\"checked\"` — sets the checked property on the element.\n * - `\"dataset\"` — merges data-* attributes via `elem.dataset`.\n * - Other attributes — joined with spaces, with special characters stripped\n * for `\"class\"` and `\"id\"` when `stripDiacritics` is enabled.\n *\n * @param elem - The target element.\n * @param attrs - Attributes to apply.\n * @param stripDiacritics - Whether to strip diacritics from class/id.\n */\nfunction applyAttrs(\n elem: HTMLElement,\n attrs: AttrsInput,\n stripDiacritics: boolean\n): void {\n for (const attrObj of toArray(attrs)) {\n for (const [key, value] of Object.entries(attrObj)) {\n if (value == null) continue;\n\n if (key === \"checked\") {\n (elem as HTMLInputElement).checked = !!value;\n } else if (\n key === \"dataset\" &&\n typeof value === \"object\" &&\n !Array.isArray(value)\n ) {\n Object.assign(elem.dataset, value);\n } else {\n const rawValues = Array.isArray(value) ? value : [value];\n const values = rawValues.map((v) =>\n stripDiacritics && NO_SPEC_CHARS_ATTRS.includes(key)\n ? noSpecChars(String(v))\n : String(v)\n );\n elem.setAttribute(key, values.join(\" \"));\n }\n }\n }\n}\n\n/**\n * Applies inline CSS styles to an element from a {@link StyleInput}.\n *\n * Accepts:\n * - A CSS string: `\"color: red; font-size: 14px\"`\n * - An object: `{ color: \"red\", fontSize: \"14px\" }`\n * - An array mixing both formats\n *\n * @param elem - The target element.\n * @param style - Style input to apply.\n */\nfunction applyStyle(elem: HTMLElement, style: StyleInput): void {\n const styleParts = toArray(style)\n .map((s) => {\n if (typeof s === \"object\" && s !== null) {\n return Object.entries(s)\n .map(([k, v]) => `${k}: ${v}`)\n .join(\"; \");\n }\n return toArray(s).join(\"; \");\n })\n .join(\"; \");\n\n styleParts\n .split(\";\")\n .filter(Boolean)\n .forEach((styleText) => {\n const colonIndex = styleText.indexOf(\":\");\n if (colonIndex === -1) return;\n const prop = styleText.slice(0, colonIndex).trim();\n const val = styleText.slice(colonIndex + 1).trim();\n if (prop) {\n const camelProp = makeCamelCase(prop);\n (elem.style as unknown as Record<string, string>)[camelProp] = val;\n }\n });\n}\n\n/**\n * Appends child elements to a parent element.\n *\n * Each child can be either an {@link HTMLElement} or a\n * {@link CreateDOMElemOptions} object that will be recursively created.\n *\n * @param elem - The parent element to append children to.\n * @param children - Array of child elements or options.\n */\nfunction applyChildren(\n elem: HTMLElement,\n children: Array<CreateDOMElemOptions | HTMLElement>\n): void {\n for (const child of children) {\n if (child instanceof HTMLElement) {\n elem.appendChild(child);\n } else {\n elem.appendChild(createDOMElem(child));\n }\n }\n}\n\n/**\n * Attaches event listeners to an element.\n *\n * @param elem - The target element.\n * @param handleEvent - One or more {@link EventHandler} descriptors.\n */\nfunction applyEvents(\n elem: HTMLElement,\n handleEvent: CreateDOMElemOptions[\"handleEvent\"]\n): void {\n for (const evt of toArray(handleEvent)) {\n if (evt?.event && evt?.cb) {\n elem.addEventListener(evt.event, evt.cb);\n }\n }\n}\n\n/**\n * Creates a DOM element with the given configuration.\n *\n * This is the core function of DOMelemJS. It creates an HTML element,\n * applies attributes, styles, children, and event listeners, then\n * appends it to a parent element.\n *\n * @example\n * ```ts\n * const el = createDOMElem({\n * tag: \"div\",\n * text: \"Hello\",\n * attrs: { class: \"greeting\" },\n * style: { color: \"blue\" },\n * parent: \"#app\",\n * handleEvent: {\n * event: \"click\",\n * cb: () => console.log(\"clicked\"),\n * },\n * });\n * ```\n *\n * @param options - Element creation options.\n * @returns The created HTMLElement.\n */\nexport default function createDOMElem(options: CreateDOMElemOptions): HTMLElement {\n const {\n tag,\n content,\n text,\n attrs,\n style,\n children,\n parent,\n handleEvent,\n append = true,\n stripDiacritics = true,\n } = options;\n\n if (content && text) {\n console.warn(\n `[DOMElemJS] Both \"content\" and \"text\" provided for <${tag}>. ` +\n `\"text\" takes precedence — \"content\" will be ignored.`\n );\n }\n\n const elem = document.createElement(tag);\n\n if (text) {\n elem.textContent = text;\n } else if (content) {\n elem.innerHTML = content;\n }\n\n if (attrs) applyAttrs(elem, attrs, stripDiacritics);\n if (style) applyStyle(elem, style);\n if (children) applyChildren(elem, children);\n if (handleEvent) applyEvents(elem, handleEvent);\n\n if (append) {\n const target = parent ? resolveParent(parent) : document.body;\n target.appendChild(elem);\n }\n\n return elem;\n}\n","import createDOMElem from \"./createDOMElem\";\nimport type { DOMElemOptions, EventHandler } from \"./types\";\n\n/**\n * Wrapper class around {@link createDOMElem}.\n *\n * Provides an object-oriented API for creating DOM elements.\n * The created element is available via the `.elem` property.\n * Event listeners can be added and removed via `addEventListener` /\n * `removeEventListener`.\n *\n * @example\n * ```ts\n * const div = new DOMElem({\n * tag: \"div\",\n * attrs: { class: \"container\" },\n * text: \"Hello World\",\n * });\n *\n * div.addEventListener(\"click\", () => console.log(\"clicked\"));\n * div.removeEventListener(\"click\", handler);\n * ```\n */\nexport default class DOMElem {\n /** The created HTMLElement. */\n readonly elem: HTMLElement;\n\n /** The options used to create the element. */\n readonly options: DOMElemOptions;\n\n private _listeners: Map<string, Set<(e: Event) => void>> = new Map();\n\n /**\n * Creates a new DOMElem instance.\n *\n * @param options - Element creation options.\n */\n constructor(options: DOMElemOptions) {\n this.options = options;\n this.elem = createDOMElem(options);\n\n if (options.handleEvent) {\n const events = Array.isArray(options.handleEvent)\n ? options.handleEvent\n : [options.handleEvent];\n for (const evt of events) {\n this._trackListener(evt.event, evt.cb);\n }\n }\n }\n\n /**\n * Adds an event listener to the element and tracks it for later removal.\n *\n * @param event - The DOM event name.\n * @param cb - The callback function.\n * @returns This instance for chaining.\n */\n addEventListener(event: string, cb: (e: Event) => void): this {\n this.elem.addEventListener(event, cb);\n this._trackListener(event, cb);\n return this;\n }\n\n /**\n * Removes a previously added event listener.\n *\n * @param event - The DOM event name.\n * @param cb - The callback function to remove.\n * @returns This instance for chaining.\n */\n removeEventListener(event: string, cb: (e: Event) => void): this {\n this.elem.removeEventListener(event, cb);\n this._untrackListener(event, cb);\n return this;\n }\n\n /**\n * Removes all tracked event listeners from the element.\n */\n removeAllListeners(): void {\n for (const [event, cbs] of this._listeners) {\n for (const cb of cbs) {\n this.elem.removeEventListener(event, cb);\n }\n }\n this._listeners.clear();\n }\n\n private _trackListener(event: string, cb: (e: Event) => void): void {\n if (!this._listeners.has(event)) {\n this._listeners.set(event, new Set());\n }\n this._listeners.get(event)!.add(cb);\n }\n\n private _untrackListener(event: string, cb: (e: Event) => void): void {\n this._listeners.get(event)?.delete(cb);\n }\n}\n","/**\n * List of standard HTML tag names.\n *\n * Provided as a `const` tuple so TypeScript can infer literal types\n * (e.g. `\"div\"` instead of `string`).\n *\n * @example\n * import { HTML_TAGS } from \"domelemjs\";\n * if (HTML_TAGS.includes(tag as HtmlTagConst)) { ... }\n */\nexport const HTML_TAGS = [\n \"a\", \"abbr\", \"address\", \"area\", \"article\", \"aside\", \"audio\",\n \"b\", \"base\", \"bdi\", \"bdo\", \"blockquote\", \"body\", \"br\", \"button\",\n \"canvas\", \"caption\", \"cite\", \"code\", \"col\", \"colgroup\",\n \"data\", \"datalist\", \"dd\", \"del\", \"details\", \"dfn\", \"dialog\", \"div\", \"dl\", \"dt\",\n \"em\", \"embed\",\n \"fieldset\", \"figcaption\", \"figure\", \"footer\", \"form\",\n \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"head\", \"header\", \"hr\", \"html\",\n \"i\", \"iframe\", \"img\", \"input\", \"ins\",\n \"kbd\",\n \"label\", \"legend\", \"li\", \"link\",\n \"main\", \"map\", \"mark\", \"meta\", \"meter\",\n \"nav\", \"noscript\",\n \"object\", \"ol\", \"optgroup\", \"option\", \"output\",\n \"p\", \"param\", \"picture\", \"pre\", \"progress\",\n \"q\",\n \"rp\", \"rt\", \"ruby\",\n \"s\", \"samp\", \"script\", \"section\", \"select\", \"small\", \"source\", \"span\",\n \"strong\", \"style\", \"sub\", \"summary\", \"sup\", \"svg\",\n \"table\", \"tbody\", \"td\", \"template\", \"textarea\", \"tfoot\", \"th\", \"thead\",\n \"time\", \"title\", \"tr\", \"track\",\n \"u\", \"ul\",\n \"video\",\n \"wbr\",\n] as const;\n\n/** Union type of all valid HTML tag name literals. */\nexport type HtmlTagConst = (typeof HTML_TAGS)[number];\n"],"mappings":"6bAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,cAAAC,EAAA,kBAAAC,ICUO,SAASC,EAAcC,EAAmB,CAC/C,OAAOA,EACJ,MAAM,GAAG,EACT,IAAI,CAACC,EAAMC,IAAOA,EAAI,EAAID,EAAK,OAAO,CAAC,EAAE,YAAY,EAAIA,EAAK,MAAM,CAAC,EAAIA,CAAK,EAC9E,KAAK,EAAE,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M,KAAM,KAAM,KAAM,OAAQ,SAAU,KAAM,OAC5D,IAAK,SAAU,MAAO,QAAS,MAC/B,MACA,QAAS,SAAU,KAAM,OACzB,OAAQ,MAAO,OAAQ,OAAQ,QAC/B,MAAO,WACP,SAAU,KAAM,WAAY,SAAU,SACtC,IAAK,QAAS,UAAW,MAAO,WAChC,IACA,KAAM,KAAM,OACZ,IAAK,OAAQ,SAAU,UAAW,SAAU,QAAS,SAAU,OAC/D,SAAU,QAAS,MAAO,UAAW,MAAO,MAC5C,QAAS,QAAS,KAAM,WAAY,WAAY,QAAS,KAAM,QAC/D,OAAQ,QAAS,KAAM,QACvB,IAAK,KACL,QACA,KACF","names":["index_exports","__export","DOMElem","HTML_TAGS","createDOMElem","makeCamelCase","s","part","i","toArray","value","noSpecChars","text","lowercase","map","result","char","replacement","NO_SPEC_CHARS_ATTRS","resolveParent","parent","el","applyAttrs","elem","attrs","stripDiacritics","attrObj","toArray","key","value","values","v","noSpecChars","applyStyle","style","s","k","styleText","colonIndex","prop","val","camelProp","makeCamelCase","applyChildren","children","child","createDOMElem","applyEvents","handleEvent","evt","options","tag","content","text","append","DOMElem","options","createDOMElem","events","evt","event","cb","cbs","HTML_TAGS"]}
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";var u=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var O=(t,e)=>{for(var n in e)u(t,n,{get:e[n],enumerable:!0})},L=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of b(e))!M.call(t,o)&&o!==n&&u(t,o,{get:()=>e[o],enumerable:!(r=g(e,o))||r.enumerable});return t};var T=t=>L(u({},"__esModule",{value:!0}),t);var x={};O(x,{DOMElem:()=>p,HTML_TAGS:()=>E,createDOMElem:()=>l});module.exports=T(x);function f(t){return t.split("-").map((e,n)=>n>0?e.charAt(0).toUpperCase()+e.slice(1):e).join("")}function m(t){return t==null?[]:Array.isArray(t)?t:[t]}function h(t,e=!1){let n={\u00E1:"a",\u00E9:"e",\u00ED:"i",\u00F3:"o",\u00F6:"o",\u0151:"o",\u00FA:"u",\u00FC:"u",\u0171:"u",\u00C1:"A",\u00C9:"E",\u00CD:"I",\u00D3:"O",\u00D6:"O",\u0150:"O",\u00DA:"U",\u00DC:"U",\u0170:"U",\u00E0:"a",\u00E8:"e",\u00EC:"i",\u00F2:"o",\u00F9:"u",\u00E2:"a",\u00EA:"e",\u00EE:"i",\u00F4:"o",\u00FB:"u",\u0103:"a",\u0115:"e",\u012D:"i",\u014F:"o",\u016D:"u",\u0101:"a",\u0113:"e",\u012B:"i",\u014D:"o",\u016B:"u",\u01CE:"a",\u011B:"e",\u01D0:"i",\u01D2:"o",\u01D4:"u",\u00E4:"a",\u00EB:"e",\u00EF:"i",\u00E5:"a",\u00F8:"o",\u00E3:"a",\u00F5:"o",\u00E6:"ae",\u00E7:"c",\u011F:"g",\u0142:"l",\u00F1:"n",\u0111:"d",\u00DF:"ss",\u010F:"d",\u0165:"t",\u0148:"n",\u0159:"r",\u0161:"s",\u017E:"z",\u0158:"R",\u0160:"S",\u017D:"Z",\u00C7:"C",\u015E:"S",\u011E:"G",\u0141:"L",\u00D1:"N",\u0110:"D",\u013E:"l",\u0155:"r",\u013A:"l"},r=t;for(let[o,i]of Object.entries(n))r=r.split(o).join(i);return e?r.toLowerCase():r}var A=["class","id"];function S(t){if(t instanceof HTMLElement)return t;let e=null;return t.charAt(0)==="#"||t.charAt(0)==="."?e=document.querySelector(t):e=document.querySelector(`#${t}`)||document.querySelector(`.${t}`)||document.querySelector(t),e||(console.warn(`[DOMElemJS] Parent element not found for selector: "${t}". Falling back to document.body.`),document.body)}function C(t,e,n){for(let r of m(e))for(let[o,i]of Object.entries(r))if(i!=null)if(o==="checked")t.checked=!!i;else if(o==="dataset"&&typeof i=="object"&&!Array.isArray(i))Object.assign(t.dataset,i);else{let a=(Array.isArray(i)?i:[i]).map(d=>n&&A.includes(o)?h(String(d)):String(d));t.setAttribute(o,a.join(" "))}}function H(t,e){m(e).map(r=>typeof r=="object"&&r!==null?Object.entries(r).map(([o,i])=>`${o}: ${i}`).join("; "):m(r).join("; ")).join("; ").split(";").filter(Boolean).forEach(r=>{let o=r.indexOf(":");if(o===-1)return;let i=r.slice(0,o).trim(),c=r.slice(o+1).trim();if(i){let a=f(i);t.style[a]=c}})}function k(t,e){for(let n of e)n instanceof HTMLElement?t.appendChild(n):t.appendChild(l(n))}function _(t,e){for(let n of m(e))n?.event&&n?.cb&&t.addEventListener(n.event,n.cb)}function l(t){let{tag:e,content:n,text:r,attrs:o,style:i,children:c,parent:a,handleEvent:d,append:v=!0,stripDiacritics:y=!0}=t;n&&r&&console.warn(`[DOMElemJS] Both "content" and "text" provided for <${e}>. "text" takes precedence \u2014 "content" will be ignored.`);let s=document.createElement(e);return r?s.textContent=r:n&&(s.innerHTML=n),o&&C(s,o,y),i&&H(s,i),c&&k(s,c),d&&_(s,d),v&&(a?S(a):document.body).appendChild(s),s}var p=class{constructor(e){this._listeners=new Map;if(this.options=e,this.elem=l(e),e.handleEvent){let n=Array.isArray(e.handleEvent)?e.handleEvent:[e.handleEvent];for(let r of n)this._trackListener(r.event,r.cb)}}addEventListener(e,n){return this.elem.addEventListener(e,n),this._trackListener(e,n),this}removeEventListener(e,n){return this.elem.removeEventListener(e,n),this._untrackListener(e,n),this}removeAllListeners(){for(let[e,n]of this._listeners)for(let r of n)this.elem.removeEventListener(e,r);this._listeners.clear()}_trackListener(e,n){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(n)}_untrackListener(e,n){this._listeners.get(e)?.delete(n)}};var E=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","video","wbr"];0&&(module.exports={DOMElem,HTML_TAGS,createDOMElem});
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/utils.ts","../src/createDOMElem.ts","../src/DOMElem.ts","../src/htmlTags.ts"],"sourcesContent":["/**\n * DOMelemJS — a lightweight, zero-dependency library for creating\n * DOM elements from JavaScript/TypeScript.\n *\n * @example\n * ```ts\n * import { createDOMElem, DOMElem } from \"domelemjs\";\n *\n * // Functional API\n * const el = createDOMElem({\n * tag: \"div\",\n * text: \"Hello\",\n * attrs: { id: \"app\" },\n * });\n *\n * // Class API\n * const div = new DOMElem({ tag: \"div\", text: \"World\" });\n * ```\n *\n * @packageDocumentation\n */\n\nexport { default as DOMElem } from \"./DOMElem\";\nexport { default as createDOMElem } from \"./createDOMElem\";\nexport { HTML_TAGS } from \"./htmlTags\";\nexport type {\n CreateDOMElemOptions,\n DOMElemOptions,\n EventHandler,\n StyleInput,\n AttrsInput,\n ParentInput,\n HtmlTag,\n} from \"./types\";\nexport type { HtmlTagConst } from \"./htmlTags\";\n","/**\n * Converts a kebab-case string to camelCase.\n *\n * @example\n * makeCamelCase(\"background-color\") // \"backgroundColor\"\n * makeCamelCase(\"font-size\") // \"fontSize\"\n *\n * @param s - The kebab-case string to convert.\n * @returns The camelCase version of the input.\n */\nexport function makeCamelCase(s: string): string {\n return s\n .split(\"-\")\n .map((part, i) => (i > 0 ? part.charAt(0).toUpperCase() + part.slice(1) : part))\n .join(\"\");\n}\n\n/**\n * Ensures the given value is wrapped in an array.\n * Returns an empty array for `null` / `undefined`.\n *\n * @example\n * toArray(\"hello\") // [\"hello\"]\n * toArray([\"a\", \"b\"]) // [\"a\", \"b\"]\n * toArray(null) // []\n *\n * @param value - The value to normalize.\n * @returns An array containing the value, or an empty array if falsy.\n */\nexport function toArray<T>(value: T | T[] | undefined | null): T[] {\n if (value == null) return [];\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Replaces accented / special characters with their ASCII equivalents.\n *\n * Supports Hungarian, Czech, Polish, Turkish, and other Latin-script diacritics.\n *\n * @example\n * noSpecChars(\"árvíztűrő\") // \"arviztuoro\"\n * noSpecChars(\"Árvíz\", true) // \"arviz\"\n *\n * @param text - The input string containing special characters.\n * @param lowercase - If `true`, the result is lowercased after replacement.\n * @returns The string with special characters replaced.\n */\nexport function noSpecChars(text: string, lowercase = false): string {\n const map: Record<string, string> = {\n á: \"a\", é: \"e\", í: \"i\", ó: \"o\", ö: \"o\", ő: \"o\",\n ú: \"u\", ü: \"u\", ű: \"u\",\n Á: \"A\", É: \"E\", Í: \"I\", Ó: \"O\", Ö: \"O\", Ő: \"O\",\n Ú: \"U\", Ü: \"U\", Ű: \"U\",\n à: \"a\", è: \"e\", ì: \"i\", ò: \"o\", ù: \"u\",\n â: \"a\", ê: \"e\", î: \"i\", ô: \"o\", û: \"u\",\n ă: \"a\", ĕ: \"e\", ĭ: \"i\", ŏ: \"o\", ŭ: \"u\",\n ā: \"a\", ē: \"e\", ī: \"i\", ō: \"o\", ū: \"u\",\n ǎ: \"a\", ě: \"e\", ǐ: \"i\", ǒ: \"o\", ǔ: \"u\",\n ä: \"a\", ë: \"e\", ï: \"i\",\n å: \"a\", ø: \"o\",\n ã: \"a\", õ: \"o\",\n æ: \"ae\",\n ç: \"c\", ğ: \"g\",\n ł: \"l\",\n ñ: \"n\",\n đ: \"d\",\n ß: \"ss\",\n ď: \"d\", ť: \"t\", ň: \"n\",\n ř: \"r\", š: \"s\", ž: \"z\",\n Ř: \"R\", Š: \"S\", Ž: \"Z\",\n Ç: \"C\", Ş: \"S\", Ğ: \"G\",\n Ł: \"L\", Ñ: \"N\", Đ: \"D\",\n ľ: \"l\", ŕ: \"r\", ĺ: \"l\",\n };\n\n let result = text;\n for (const [char, replacement] of Object.entries(map)) {\n result = result.split(char).join(replacement);\n }\n\n return lowercase ? result.toLowerCase() : result;\n}\n","import { makeCamelCase, toArray, noSpecChars } from \"./utils\";\nimport type { CreateDOMElemOptions, AttrsInput, StyleInput } from \"./types\";\n\n/** Attributes that have special characters stripped automatically. */\nconst NO_SPEC_CHARS_ATTRS = [\"class\", \"id\"];\n\n/**\n * Resolves a parent element from a string selector or HTMLElement reference.\n *\n * If the string starts with `#` or `.`, it is used directly as a querySelector\n * argument. Otherwise, it is tried first as `#<selector>` then as `.<selector>`.\n *\n * @param parent - An HTMLElement or a CSS selector string.\n * @returns The resolved HTMLElement.\n * @throws Will console.warn if the selector does not match any element.\n */\nfunction resolveParent(parent: HTMLElement | string): HTMLElement {\n if (parent instanceof HTMLElement) return parent;\n\n let el: Element | null = null;\n\n if (parent.charAt(0) === \"#\" || parent.charAt(0) === \".\") {\n el = document.querySelector(parent);\n } else {\n el =\n document.querySelector(`#${parent}`) ||\n document.querySelector(`.${parent}`) ||\n document.querySelector(parent);\n }\n\n if (!el) {\n console.warn(\n `[DOMElemJS] Parent element not found for selector: \"${parent}\". ` +\n `Falling back to document.body.`\n );\n return document.body;\n }\n\n return el as HTMLElement;\n}\n\n/**\n * Applies HTML attributes to an element from an {@link AttrsInput}.\n *\n * Handles special cases:\n * - `\"checked\"` — sets the checked property on the element.\n * - `\"dataset\"` — merges data-* attributes via `elem.dataset`.\n * - Other attributes — joined with spaces, with special characters stripped\n * for `\"class\"` and `\"id\"` when `stripDiacritics` is enabled.\n *\n * @param elem - The target element.\n * @param attrs - Attributes to apply.\n * @param stripDiacritics - Whether to strip diacritics from class/id.\n */\nfunction applyAttrs(\n elem: HTMLElement,\n attrs: AttrsInput,\n stripDiacritics: boolean\n): void {\n for (const attrObj of toArray(attrs)) {\n for (const [key, value] of Object.entries(attrObj)) {\n if (value == null) continue;\n\n if (key === \"checked\") {\n (elem as HTMLInputElement).checked = !!value;\n } else if (\n key === \"dataset\" &&\n typeof value === \"object\" &&\n !Array.isArray(value)\n ) {\n Object.assign(elem.dataset, value);\n } else {\n const rawValues = Array.isArray(value) ? value : [value];\n const values = rawValues.map((v) =>\n stripDiacritics && NO_SPEC_CHARS_ATTRS.includes(key)\n ? noSpecChars(String(v))\n : String(v)\n );\n elem.setAttribute(key, values.join(\" \"));\n }\n }\n }\n}\n\n/**\n * Applies inline CSS styles to an element from a {@link StyleInput}.\n *\n * Accepts:\n * - A CSS string: `\"color: red; font-size: 14px\"`\n * - An object: `{ color: \"red\", fontSize: \"14px\" }`\n * - An array mixing both formats\n *\n * @param elem - The target element.\n * @param style - Style input to apply.\n */\nfunction applyStyle(elem: HTMLElement, style: StyleInput): void {\n const styleParts = toArray(style)\n .map((s) => {\n if (typeof s === \"object\" && s !== null) {\n return Object.entries(s)\n .map(([k, v]) => `${k}: ${v}`)\n .join(\"; \");\n }\n return toArray(s).join(\"; \");\n })\n .join(\"; \");\n\n styleParts\n .split(\";\")\n .filter(Boolean)\n .forEach((styleText) => {\n const colonIndex = styleText.indexOf(\":\");\n if (colonIndex === -1) return;\n const prop = styleText.slice(0, colonIndex).trim();\n const val = styleText.slice(colonIndex + 1).trim();\n if (prop) {\n const camelProp = makeCamelCase(prop);\n (elem.style as unknown as Record<string, string>)[camelProp] = val;\n }\n });\n}\n\n/**\n * Appends child elements to a parent element.\n *\n * Each child can be either an {@link HTMLElement} or a\n * {@link CreateDOMElemOptions} object that will be recursively created.\n *\n * @param elem - The parent element to append children to.\n * @param children - Array of child elements or options.\n */\nfunction applyChildren(\n elem: HTMLElement,\n children: Array<CreateDOMElemOptions | HTMLElement>\n): void {\n for (const child of children) {\n if (child instanceof HTMLElement) {\n elem.appendChild(child);\n } else {\n elem.appendChild(createDOMElem(child));\n }\n }\n}\n\n/**\n * Attaches event listeners to an element.\n *\n * @param elem - The target element.\n * @param handleEvent - One or more {@link EventHandler} descriptors.\n */\nfunction applyEvents(\n elem: HTMLElement,\n handleEvent: CreateDOMElemOptions[\"handleEvent\"]\n): void {\n for (const evt of toArray(handleEvent)) {\n if (evt?.event && evt?.cb) {\n elem.addEventListener(evt.event, evt.cb);\n }\n }\n}\n\n/**\n * Creates a DOM element with the given configuration.\n *\n * This is the core function of DOMelemJS. It creates an HTML element,\n * applies attributes, styles, children, and event listeners, then\n * appends it to a parent element.\n *\n * @example\n * ```ts\n * const el = createDOMElem({\n * tag: \"div\",\n * text: \"Hello\",\n * attrs: { class: \"greeting\" },\n * style: { color: \"blue\" },\n * parent: \"#app\",\n * handleEvent: {\n * event: \"click\",\n * cb: () => console.log(\"clicked\"),\n * },\n * });\n * ```\n *\n * @param options - Element creation options.\n * @returns The created HTMLElement.\n */\nexport default function createDOMElem(options: CreateDOMElemOptions): HTMLElement {\n const {\n tag,\n content,\n text,\n attrs,\n style,\n children,\n parent,\n handleEvent,\n append = true,\n stripDiacritics = true,\n } = options;\n\n if (content && text) {\n console.warn(\n `[DOMElemJS] Both \"content\" and \"text\" provided for <${tag}>. ` +\n `\"text\" takes precedence — \"content\" will be ignored.`\n );\n }\n\n const elem = document.createElement(tag);\n\n if (text) {\n elem.textContent = text;\n } else if (content) {\n elem.innerHTML = content;\n }\n\n if (attrs) applyAttrs(elem, attrs, stripDiacritics);\n if (style) applyStyle(elem, style);\n if (children) applyChildren(elem, children);\n if (handleEvent) applyEvents(elem, handleEvent);\n\n if (append) {\n const target = parent ? resolveParent(parent) : document.body;\n target.appendChild(elem);\n }\n\n return elem;\n}\n","import createDOMElem from \"./createDOMElem\";\nimport type { DOMElemOptions, EventHandler } from \"./types\";\n\n/**\n * Wrapper class around {@link createDOMElem}.\n *\n * Provides an object-oriented API for creating DOM elements.\n * The created element is available via the `.elem` property.\n * Event listeners can be added and removed via `addEventListener` /\n * `removeEventListener`.\n *\n * @example\n * ```ts\n * const div = new DOMElem({\n * tag: \"div\",\n * attrs: { class: \"container\" },\n * text: \"Hello World\",\n * });\n *\n * div.addEventListener(\"click\", () => console.log(\"clicked\"));\n * div.removeEventListener(\"click\", handler);\n * ```\n */\nexport default class DOMElem {\n /** The created HTMLElement. */\n readonly elem: HTMLElement;\n\n /** The options used to create the element. */\n readonly options: DOMElemOptions;\n\n private _listeners: Map<string, Set<(e: Event) => void>> = new Map();\n\n /**\n * Creates a new DOMElem instance.\n *\n * @param options - Element creation options.\n */\n constructor(options: DOMElemOptions) {\n this.options = options;\n this.elem = createDOMElem(options);\n\n if (options.handleEvent) {\n const events = Array.isArray(options.handleEvent)\n ? options.handleEvent\n : [options.handleEvent];\n for (const evt of events) {\n this._trackListener(evt.event, evt.cb);\n }\n }\n }\n\n /**\n * Adds an event listener to the element and tracks it for later removal.\n *\n * @param event - The DOM event name.\n * @param cb - The callback function.\n * @returns This instance for chaining.\n */\n addEventListener(event: string, cb: (e: Event) => void): this {\n this.elem.addEventListener(event, cb);\n this._trackListener(event, cb);\n return this;\n }\n\n /**\n * Removes a previously added event listener.\n *\n * @param event - The DOM event name.\n * @param cb - The callback function to remove.\n * @returns This instance for chaining.\n */\n removeEventListener(event: string, cb: (e: Event) => void): this {\n this.elem.removeEventListener(event, cb);\n this._untrackListener(event, cb);\n return this;\n }\n\n /**\n * Removes all tracked event listeners from the element.\n */\n removeAllListeners(): void {\n for (const [event, cbs] of this._listeners) {\n for (const cb of cbs) {\n this.elem.removeEventListener(event, cb);\n }\n }\n this._listeners.clear();\n }\n\n private _trackListener(event: string, cb: (e: Event) => void): void {\n if (!this._listeners.has(event)) {\n this._listeners.set(event, new Set());\n }\n this._listeners.get(event)!.add(cb);\n }\n\n private _untrackListener(event: string, cb: (e: Event) => void): void {\n this._listeners.get(event)?.delete(cb);\n }\n}\n","/**\n * List of standard HTML tag names.\n *\n * Provided as a `const` tuple so TypeScript can infer literal types\n * (e.g. `\"div\"` instead of `string`).\n *\n * @example\n * import { HTML_TAGS } from \"domelemjs\";\n * if (HTML_TAGS.includes(tag as HtmlTagConst)) { ... }\n */\nexport const HTML_TAGS = [\n \"a\", \"abbr\", \"address\", \"area\", \"article\", \"aside\", \"audio\",\n \"b\", \"base\", \"bdi\", \"bdo\", \"blockquote\", \"body\", \"br\", \"button\",\n \"canvas\", \"caption\", \"cite\", \"code\", \"col\", \"colgroup\",\n \"data\", \"datalist\", \"dd\", \"del\", \"details\", \"dfn\", \"dialog\", \"div\", \"dl\", \"dt\",\n \"em\", \"embed\",\n \"fieldset\", \"figcaption\", \"figure\", \"footer\", \"form\",\n \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"head\", \"header\", \"hr\", \"html\",\n \"i\", \"iframe\", \"img\", \"input\", \"ins\",\n \"kbd\",\n \"label\", \"legend\", \"li\", \"link\",\n \"main\", \"map\", \"mark\", \"meta\", \"meter\",\n \"nav\", \"noscript\",\n \"object\", \"ol\", \"optgroup\", \"option\", \"output\",\n \"p\", \"param\", \"picture\", \"pre\", \"progress\",\n \"q\",\n \"rp\", \"rt\", \"ruby\",\n \"s\", \"samp\", \"script\", \"section\", \"select\", \"small\", \"source\", \"span\",\n \"strong\", \"style\", \"sub\", \"summary\", \"sup\", \"svg\",\n \"table\", \"tbody\", \"td\", \"template\", \"textarea\", \"tfoot\", \"th\", \"thead\",\n \"time\", \"title\", \"tr\", \"track\",\n \"u\", \"ul\",\n \"video\",\n \"wbr\",\n] as const;\n\n/** Union type of all valid HTML tag name literals. */\nexport type HtmlTagConst = (typeof HTML_TAGS)[number];\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,cAAAC,EAAA,kBAAAC,IAAA,eAAAC,EAAAL,GCUO,SAASM,EAAcC,EAAmB,CAC/C,OAAOA,EACJ,MAAM,GAAG,EACT,IAAI,CAACC,EAAMC,IAAOA,EAAI,EAAID,EAAK,OAAO,CAAC,EAAE,YAAY,EAAIA,EAAK,MAAM,CAAC,EAAIA,CAAK,EAC9E,KAAK,EAAE,CACZ,CAcO,SAASE,EAAWC,EAAwC,CACjE,OAAIA,GAAS,KAAa,CAAC,EAC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AAS,MAC/B,MACA,QAAS,SAAU,KAAM,OACzB,OAAQ,MAAO,OAAQ,OAAQ,QAC/B,MAAO,WACP,SAAU,KAAM,WAAY,SAAU,SACtC,IAAK,QAAS,UAAW,MAAO,WAChC,IACA,KAAM,KAAM,OACZ,IAAK,OAAQ,SAAU,UAAW,SAAU,QAAS,SAAU,OAC/D,SAAU,QAAS,MAAO,UAAW,MAAO,MAC5C,QAAS,QAAS,KAAM,WAAY,WAAY,QAAS,KAAM,QAC/D,OAAQ,QAAS,KAAM,QACvB,IAAK,KACL,QACA,KACF","names":["index_exports","__export","DOMElem","HTML_TAGS","createDOMElem","__toCommonJS","makeCamelCase","s","part","i","toArray","value","noSpecChars","text","lowercase","map","result","char","replacement","NO_SPEC_CHARS_ATTRS","resolveParent","parent","el","applyAttrs","elem","attrs","stripDiacritics","attrObj","toArray","key","value","values","v","noSpecChars","applyStyle","style","s","k","styleText","colonIndex","prop","val","camelProp","makeCamelCase","applyChildren","children","child","createDOMElem","applyEvents","handleEvent","evt","options","tag","content","text","append","DOMElem","options","createDOMElem","events","evt","event","cb","cbs","HTML_TAGS"]}