@duckafire/html.js 0.3.0-2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +56 -243
- package/index.min.js +1 -0
- package/package.json +21 -6
- package/html.js +0 -413
- package/html.min.js +0 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Zlib License
|
|
2
2
|
|
|
3
|
-
Copyright (C) 2025 DuckAfire <duckafire.
|
|
3
|
+
Copyright (C) 2025-2026 DuckAfire <https://duckafire.gitlab.io>
|
|
4
4
|
|
|
5
5
|
This software is provided 'as-is', without any express or implied
|
|
6
6
|
warranty. In no event will the authors be held liable for any damages
|
package/README.md
CHANGED
|
@@ -1,270 +1,83 @@
|
|
|
1
|
-
[
|
|
2
|
-
[
|
|
3
|
-
[data-
|
|
4
|
-
[
|
|
5
|
-
[
|
|
6
|
-
[
|
|
7
|
-
[camel-case]: https://en.wikipedia.org/wiki/Camel_case "Understanding the camelCase"
|
|
8
|
-
[window-api]: https://developer.mozilla.org/en-US/docs/Web/API/Window "Window: API and environment"
|
|
1
|
+
[code-eg]: ./example.html "It does not work in NPM Registry"
|
|
2
|
+
[aria-attr]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA "Mozilla docs: Accessible Rich Internet Applications"
|
|
3
|
+
[data-attr]: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/data-* "Mozilla docs: HTML attributes data-*"
|
|
4
|
+
[event-list]: https://www.w3schools.com/js/js_htmldom_eventlistener.asp "W3 docs: DOM Event Listeners"
|
|
5
|
+
[style-attr]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style "Mozilla docs: The HTML `style` attrbute"
|
|
6
|
+
[css-var]: https://www.w3schools.com/css/css3_variables.asp "W3 docs: CSS variables"
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
## html.js
|
|
11
9
|
|
|
12
|
-
This is a
|
|
10
|
+
This is a WEB component library thought to be:
|
|
13
11
|
|
|
14
|
-
* Light
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
12
|
+
* Light;
|
|
13
|
+
* minimalist;
|
|
14
|
+
* easy to use;
|
|
15
|
+
* simple to understand;
|
|
16
|
+
* similar to HTML; and
|
|
17
|
+
* independent.
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* [Installing](#installing)
|
|
24
|
-
* [How to use](#how-to-use)
|
|
25
|
-
* [Start library](#start-library)
|
|
26
|
-
* [Create an element](#create-an-element)
|
|
27
|
-
* [Closing the element creation](#closing-the-element-creation)
|
|
28
|
-
* [Adding your self tags](#adding-your-self-tags)
|
|
29
|
-
* [Special properties](#special-properties)
|
|
30
|
-
* [Managing default values to properties](#managing-default-values-to-properties)
|
|
31
|
-
* [Set default values](#set-default-values)
|
|
32
|
-
* [Unset default values](#unset-default-values)
|
|
33
|
-
|
|
34
|
-
## Installing
|
|
35
|
-
|
|
36
|
-
Just copy and paste this code chunk in your HTML file:
|
|
19
|
+
> [TIP]
|
|
20
|
+
> See an **example** [here][code-eg].
|
|
37
21
|
|
|
38
22
|
``` html
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
<!-- CDN URL -->
|
|
24
|
+
<script src="https://cdn.jsdelivr.net/npm/@duckafire/html.js@1/html.min.js"></script>
|
|
41
25
|
```
|
|
42
26
|
|
|
43
|
-
|
|
44
|
-
> Put it in the `<head>`.
|
|
45
|
-
|
|
46
|
-
After this, run the JavaScript code below:
|
|
47
|
-
|
|
48
|
-
``` html
|
|
49
|
-
<script>
|
|
50
|
-
declare_htmljs();
|
|
51
|
-
</script>
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
> [!NOTE] \
|
|
55
|
-
> See more about `declare_htmljs` [here](#start-library).
|
|
56
|
-
|
|
57
|
-
> [!TIP] \
|
|
58
|
-
> Put it after the request tag (presented above), in the `<head>`.
|
|
59
|
-
|
|
60
|
-
## How to use
|
|
61
|
-
|
|
62
|
-
### Start library
|
|
63
|
-
|
|
64
|
-
As mentioned earlier on, it is necessary call the functions bellow to
|
|
65
|
-
start the library:
|
|
27
|
+
## FAQ
|
|
66
28
|
|
|
67
|
-
|
|
68
|
-
* `{} declare_htmljs( [ args: object = {[prefix: string = ""], [createObject: boolean = false], [useUpperCase: boolean = false]} ] )`
|
|
69
|
-
* `prefix`: prefixs the name of the *Creation Functions*. They are used to create
|
|
70
|
-
the elements.
|
|
71
|
-
* `createObject`: specifics that the methods have to be declared in a new object,
|
|
72
|
-
that it will be created by the function.
|
|
73
|
-
* `useUpperCase`: specifics that the *Creation Functions* names have to be formated
|
|
74
|
-
with upper case characters, instead lower case characteres.
|
|
75
|
-
* `args`: an object containing the wanted options (these above).
|
|
29
|
+
### What are the parameters of the *Element Constructors*?
|
|
76
30
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
> error.
|
|
31
|
+
``` typescript
|
|
32
|
+
INPUT( attributes: {} ): Element;
|
|
80
33
|
|
|
81
|
-
|
|
82
|
-
> If `!createObject` the *Creation Functions* will be declared in
|
|
83
|
-
> [`window`][window-api], that it also will be returned.
|
|
84
|
-
|
|
85
|
-
> [!TIP] \
|
|
86
|
-
> Try `declare_htmljs({useUpperCase: true})` instead `declare_html(null, false, true)`.
|
|
87
|
-
|
|
88
|
-
### Create an element
|
|
89
|
-
|
|
90
|
-
To create a HTML element, you need to call its respective *Creation Function* like
|
|
91
|
-
shown below (their names are defined by [`declare_htmljs`][start-library]):
|
|
92
|
-
|
|
93
|
-
``` js
|
|
94
|
-
// create a <div> that it contains:
|
|
95
|
-
// * one text node
|
|
96
|
-
// * one `<br/>`
|
|
97
|
-
// * one `<span>` (that it contains one text node)
|
|
98
|
-
// * one `<input/>`
|
|
99
|
-
|
|
100
|
-
div( {className: "foo"},
|
|
101
|
-
"Lorem ipsum",
|
|
102
|
-
br(),
|
|
103
|
-
span( null,
|
|
104
|
-
"Lorem ipsum",
|
|
105
|
-
span),
|
|
106
|
-
input( {type: "text", value: "foobar", readOnly: "~"}),
|
|
107
|
-
div);
|
|
34
|
+
DIV( attributes: {}, ...children: Element[] ): Element;
|
|
108
35
|
```
|
|
109
36
|
|
|
110
|
-
> [!
|
|
111
|
-
>
|
|
112
|
-
>
|
|
113
|
-
|
|
114
|
-
All these *Creation Functions* have the same parameter structure, the only difference
|
|
115
|
-
it is their names/identifiers, because of this, I will not to list all them here, I will
|
|
116
|
-
only explain their structure (of generic way):
|
|
117
|
-
|
|
118
|
-
* `{} CreationFunction( [htmlProperties: object = undefined, [...children: HTMLElement | string = undefined, [closeTag: any = undefined]]] )`
|
|
119
|
-
* `htmlProperties`: all the HTML properties that will be implemented in the created
|
|
120
|
-
element.
|
|
121
|
-
* `children`: all elements that will be appended in the created element. If it is a
|
|
122
|
-
string, a *text node* will added to the element.
|
|
123
|
-
* `closeTag`: an optional stuff, to explicit the end of the element creation. I
|
|
124
|
-
recommend that it to be equal the itself function (like the previous
|
|
125
|
-
example). See [this](#closing-the-element-creation) to learn how to
|
|
126
|
-
disable this optional parameter.
|
|
127
|
-
|
|
128
|
-
> [!WARNING] \
|
|
129
|
-
> Unlike HTML and CSS, the JavaScript syntax do not support the use of the hyphen (`-`)
|
|
130
|
-
> in identifiers name. So *compound properties* only can be declared:
|
|
131
|
-
> * Between single/double quotes: `"padding-top"`; `"background-color"`; `"font-size"`.
|
|
132
|
-
> * In [camelCase][camel-case]: `paddingTop`; `backgroundColor`; `fontSize`.
|
|
133
|
-
|
|
134
|
-
> [!IMPORTANT] \
|
|
135
|
-
> Deprecated tags are not available.
|
|
136
|
-
|
|
137
|
-
### Closing the element creation
|
|
138
|
-
|
|
139
|
-
To disable the parameter `closeTag` of the *Creation Functions* it is necessary call the
|
|
140
|
-
functions below:
|
|
141
|
-
|
|
142
|
-
* `void htmljs_set_ignore_last( [ignore: boolean = false] )`
|
|
143
|
-
* `ignore`: sets if `closeTag` is required by *Creation Functions*.
|
|
37
|
+
> [!NOTE]
|
|
38
|
+
> This is a simplified version; see the source code to more get tecnical
|
|
39
|
+
> information about the typing of the parameters of *Element Constructors*.
|
|
144
40
|
|
|
145
|
-
|
|
146
|
-
> `closeTag` is required by default. Its value is global, it affects all the
|
|
147
|
-
> *Creation Functions* call that occur after that it is called.
|
|
41
|
+
### What are *special attributes*?
|
|
148
42
|
|
|
149
|
-
|
|
150
|
-
|
|
43
|
+
They are keys, from `attributes` (parameter), which purpose is easily the
|
|
44
|
+
attribution of specific *things* to the element (like events). They does not
|
|
45
|
+
exist in HTML Standard, and will not be attributed to the element. They are:
|
|
151
46
|
|
|
152
|
-
|
|
47
|
+
* `_aria`: declares [ARIA attributes][aria-attr].
|
|
48
|
+
* `_data`: declares [*Data attributes*][data-attr].
|
|
49
|
+
* `_event`: adds [events listeners][event-list] to the element.
|
|
50
|
+
* `_style`: increments the [*inline style*][style-attr] of the element.
|
|
51
|
+
* `_var`: declares [CSS variables][css-var] in the element scope.
|
|
153
52
|
|
|
154
|
-
|
|
155
|
-
necessary to use this function:
|
|
53
|
+
### Who are attributes formated?
|
|
156
54
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
55
|
+
| Type of attribute | Formatting |
|
|
56
|
+
| :-- | :-- |
|
|
57
|
+
| ARIA attributes | `fooBar -> aria-foo-bar` |
|
|
58
|
+
| Data attributes | `fooBar -> data-foo-bar` |
|
|
59
|
+
| CSS rules | `fontSize -> font-size` |
|
|
60
|
+
| CSS variables | `foo -> --foo` |
|
|
61
|
+
| Standard attributes | `readOnly -> readonly` |
|
|
162
62
|
|
|
163
|
-
> [!NOTE]
|
|
164
|
-
>
|
|
63
|
+
> [!NOTE]
|
|
64
|
+
> Attributes started with `'-'` are not formated; values also are not.
|
|
165
65
|
|
|
166
|
-
|
|
167
|
-
what it avoid that the using of the customized tag throw an error.
|
|
66
|
+
### How to define default attributes?
|
|
168
67
|
|
|
169
|
-
|
|
68
|
+
Use the methods of `HJDefaultAttributes`.
|
|
170
69
|
|
|
171
|
-
|
|
172
|
-
|
|
70
|
+
``` typescript
|
|
71
|
+
HJDefaultAttributes.get( tagName: string ): {};
|
|
173
72
|
|
|
174
|
-
|
|
73
|
+
HJDefaultAttributes.unset( list: Record<string, {}> ): void;
|
|
175
74
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
``` js
|
|
179
|
-
SPAN({ dataSets: { property: "value" } });
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
* `ariaAttributes`: a list of properties that will be prefixed by `aria-`.
|
|
185
|
-
|
|
186
|
-
``` js
|
|
187
|
-
SPAN({ ariaProperties: { property: "value" } });
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
---
|
|
191
|
-
|
|
192
|
-
* `eventListeners`: a list of events that will be added to the created element.
|
|
193
|
-
|
|
194
|
-
``` js
|
|
195
|
-
SPAN({ eventListeners: { event: action } });
|
|
196
|
-
SPAN({ eventListeners: { event: [action0, actionN] } });
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
---
|
|
200
|
-
|
|
201
|
-
* `cssRules`: a list of CSS style rules and variables that will be added to the created
|
|
202
|
-
element.
|
|
203
|
-
|
|
204
|
-
``` js
|
|
205
|
-
SPAN({ cssRules: { rule: value } });
|
|
206
|
-
SPAN({ cssRules: { "--variable": value } });
|
|
75
|
+
HJDefaultAttributes.set( list: Record<string, string[]> ): void;
|
|
207
76
|
```
|
|
208
77
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
>
|
|
212
|
-
> These *compound properties* follow the same writing rules of the ***common***
|
|
213
|
-
> *compound properties*. See [Create an element](#create-an-element) to more
|
|
214
|
-
> information about.
|
|
215
|
-
|
|
216
|
-
> [!NOTE] \
|
|
217
|
-
> See more about these concepts bellow:
|
|
218
|
-
>
|
|
219
|
-
> * [data-][data-property]
|
|
220
|
-
> * [aria-][aria-property]
|
|
221
|
-
> * [Event Listeners][event-listeners]
|
|
222
|
-
> * [The `style` property][style-property]
|
|
223
|
-
|
|
224
|
-
### Setting default values to properties
|
|
225
|
-
|
|
226
|
-
It is possible (un)set default values to elements properties. They are based in tags,
|
|
227
|
-
so if you define a default value (e.g.) to `href`, from `<a>`, all tags (`<a>`)
|
|
228
|
-
create after this will receive this default value automatically. But if during the
|
|
229
|
-
call of the *Creation Function* (of `<a>`) the `href` is defined, the default value
|
|
230
|
-
will be overrided.
|
|
231
|
-
|
|
232
|
-
#### Set default values
|
|
233
|
-
|
|
234
|
-
* `void htmljs_set_default_properties_values(tag: string[, validateTag: boolean = false], htmlProperties: object)`
|
|
235
|
-
* `void htmljs_set_default_properties_values( [validateTag: boolean = false ,] args: object )`
|
|
236
|
-
* `tag`: element whose properties will receive a, or more, default value(s).
|
|
237
|
-
* `validateTag`: specifics if `tag` have to be validated (check if it exists or not).
|
|
238
|
-
* `htmlProperties`: all tags, and their default values, that will receive a default
|
|
239
|
-
value.
|
|
240
|
-
* `args`: an object containing a list of tags, with their HTML properties.
|
|
241
|
-
|
|
242
|
-
> [!NOTE] \
|
|
243
|
-
> These values are global, they affects all the *Creation Functions* call that occur
|
|
244
|
-
> after that it is called. *Special Properties* are included too, but their
|
|
245
|
-
> *subproperties* cannot receive a default value individually.
|
|
246
|
-
|
|
247
|
-
> [!TIP] \
|
|
248
|
-
> This is a example of value to `args`: `{a: {href: "#"}, div: {className: "div"}}`.
|
|
249
|
-
|
|
250
|
-
#### Unset default values
|
|
251
|
-
|
|
252
|
-
* `void htmljs_unset_default_properties_values(tag: string[, validateTag: boolean = false], htmlProperties: array)`
|
|
253
|
-
* `void htmljs_unset_default_properties_values( [validateTag: boolean = false ,] args: object )`
|
|
254
|
-
* `tag`: element whose properties will lose a, or more, default value(s).
|
|
255
|
-
* `validateTag`: specifics if `tag` have to be validated (check if it exists or not).
|
|
256
|
-
* `htmlProperties`: a list of properties that will lose their default values.
|
|
257
|
-
* `args`: an object containing a list of tags, with their HTML properties.
|
|
258
|
-
|
|
259
|
-
> [!IMPORTANT]
|
|
260
|
-
> The properties names used in this function must be equal the named used in
|
|
261
|
-
> `htmljs_set_default_properties_values`. Therefore, if `fontSize` was set this
|
|
262
|
-
> function only will recognize it - so `"font-size"` will not work.
|
|
263
|
-
|
|
264
|
-
> [!NOTE] \
|
|
265
|
-
> These values are global, they affects all the *Creation Functions* call that occur
|
|
266
|
-
> after that it is called. *Special Properties* are included too, but their
|
|
267
|
-
> *subproperties* cannot receive a default value individually.
|
|
78
|
+
> [!NOTE]
|
|
79
|
+
> This is a simplified version; see the source code to more tecnical information
|
|
80
|
+
> about the typing of the parameters of methods from `HJDefaultAttributes`.
|
|
268
81
|
|
|
269
|
-
> [
|
|
270
|
-
>
|
|
82
|
+
> [TIP]
|
|
83
|
+
> See an **example** [here][code-eg].
|
package/index.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
for(var __extends=this&&this.__extends||function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__spreadArray=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var n,_=0,o=e.length;_<o;_++)!n&&_ in e||(n||(n=Array.prototype.slice.call(e,0,_)),n[_]=e[_]);return t.concat(n||Array.prototype.slice.call(e))},__hj_formatAttributeName__=function(t,e){if(void 0===e&&(e=null),"-"===t.charAt(0))return t;if(null===e)return t.toLowerCase();for(var r,n=t.charAt(0),_=1;_<t.length;_++)(r=t.charAt(_))===r.toUpperCase()?n+="-"+r.toLowerCase():n+=r;return null!==e?e+n:n},HJDefaultAttributes=function(){function t(){}return t.set=function(t){if(null===t||"object"!=typeof t)throw new TypeError("Expecting: OBJECT.");for(var e in t)for(var r in void 0===this.__list__[e]&&(this.__list__[e]={}),t[e])this.__list__[e][__hj_formatAttributeName__(r)]=t[e][r]},t.get=function(e){var r;return null!==(r=t.__list__[e.toUpperCase()])&&void 0!==r?r:{}},t.unset=function(e){if(null===e||"object"!=typeof e)throw new TypeError("Expecting: OBJECT.");for(var r in e)for(var n=0,_=e[r];n<_.length;n++){var o=_[n];delete t.__list__[r][__hj_formatAttributeName__(o)]}},t.__list__={},t}(),__HJ_AttributesManager__=function(){function t(){}return t.prototype.__setSpecialAttributes__=function(t,e,r){var n,_;if("_"!==e.charAt(0))return!1;switch(e){case"_aria":case"_data":for(var o in _=e.slice(1)+"-",r)t.setAttribute(__hj_formatAttributeName__(o,_),r[o]);break;case"_event":for(var i in r)if(Array.isArray(r[i]))for(var a=0,u=r[i];a<u.length;a++){var l=u[a];t.addEventListener(i,l)}else t.addEventListener(i,r[i]);break;case"_style":case"_var":var c="";for(var o in _="_var"===e?"--":"",r)c+="".concat(__hj_formatAttributeName__(o,_),":").concat(r[o],";");t.setAttribute("style",(null!==(n=t.getAttribute("style"))&&void 0!==n?n:"")+c);break;default:return!1}return!0},t.prototype.__setAttributes=function(t,e){var r=HJDefaultAttributes.get(t.tagName);for(var n in r)t.setAttribute(n,r[n]);for(var n in e)this.__setSpecialAttributes__(t,n,e[n])||t.setAttribute(__hj_formatAttributeName__(n),e[n])},t}(),__HJ_InlineElement__=function(t){function e(){return t.call(this)||this}return __extends(e,t),e.prototype.createElement=function(t,e){void 0===e&&(e={});var r=document.createElement(t);return this.__setAttributes(r,e),r},e}(__HJ_AttributesManager__),__HJ_BlockElement__=function(t){function e(){return t.call(this)||this}return __extends(e,t),e.prototype.__insertChildren__=function(t,e){if(0!==e.length){for(var r="",n=e.length-1,_=0;_<n;_++)"string"!=typeof e[_]?(""!==r&&(t.appendChild(document.createTextNode(r)),r=""),t.appendChild(e[_])):r+=(""===r?"":" ")+e[_];""!==r&&t.appendChild(document.createTextNode(r))}},e.prototype.createElement=function(t,e){void 0===e&&(e={});for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var _=document.createElement(t);return this.__setAttributes(_,e),this.__insertChildren__(_,r),_},e}(__HJ_AttributesManager__),_loop_1=function(t){window[t]=function(e){return __HJ_InlineElement__.prototype.createElement(t,e)}},_i=0,_a=["AREA","BASE","BR","COL","HR","IMG","INPUT","LINK","META","SOURCE","TRACK","WBR"];_i<_a.length;_i++){_loop_1(TAG=_a[_i])}for(var _loop_2=function(t){window[t]=function(e){for(var r,n=[],_=1;_<arguments.length;_++)n[_-1]=arguments[_];return(r=__HJ_BlockElement__.prototype).createElement.apply(r,__spreadArray([t,e],n,!1))}},_b=0,_c=["A","ABBR","ADDRESS","ARTICLE","AUDIO","B","BDI","BDO","BLOCKQUOTE","BODY","BUTTON","CANVAS","CAPTION","CITE","CODE","COLGROUP","DATA","DATALIST","DD","DEL","DETAILS","DFN","DIALOG","DIV","DL","DT","EM","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEAD","HEADER","HGROUP","HTML","I","IFRAME","INS","KBD","LABEL","LEGEND","LI","MAIN","MAP","MARK","METER","NAV","NOSCRIPT","OBJECT","OL","OPTGROUP","OPTION","OUTPUT","P","PICTURE","PRE","PROGRESS","Q","RP","RT","RUBY","SAMP","SCRIPT","SECTION","SELECT","SMALL","SPAN","STRONG","SUB","SUMMARY","SUP","TABLE","TBODY","TD","TEMPLATE","TEXTAREA","TFOOT","TH","THEAD","TIME","TITLE","TR","UL","VARI","VIDEO"];_b<_c.length;_b++){var TAG;_loop_2(TAG=_c[_b])}
|
package/package.json
CHANGED
|
@@ -1,25 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duckafire/html.js",
|
|
3
3
|
"author": "duckafire",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"license": "Zlib",
|
|
6
|
+
"main": "index.min.js",
|
|
6
7
|
"description": "Just a very simple components library.",
|
|
7
|
-
"keywords": [
|
|
8
|
+
"keywords": [
|
|
9
|
+
"front-end",
|
|
10
|
+
"client",
|
|
11
|
+
"html",
|
|
12
|
+
"dom",
|
|
13
|
+
"light",
|
|
14
|
+
"components",
|
|
15
|
+
"web",
|
|
16
|
+
"simple",
|
|
17
|
+
"minimalist",
|
|
18
|
+
"easy"
|
|
19
|
+
],
|
|
8
20
|
"devDependencies": {
|
|
9
|
-
"terser": "^5.43.1"
|
|
21
|
+
"terser": "^5.43.1",
|
|
22
|
+
"typescript": "^4.9.5"
|
|
10
23
|
},
|
|
11
24
|
"repository": {
|
|
12
25
|
"type": "git",
|
|
13
26
|
"url": "git+https://github.com/duckafire/html.js.git"
|
|
14
27
|
},
|
|
15
28
|
"scripts": {
|
|
16
|
-
"
|
|
29
|
+
"compile": "npx tsc",
|
|
30
|
+
"compress": "npx terser index.js -o index.min.js --compress --mangle",
|
|
31
|
+
"build": "npm run compile && npm run compress"
|
|
17
32
|
},
|
|
18
33
|
"files": [
|
|
19
34
|
"LICENSE",
|
|
20
35
|
"README.md",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
36
|
+
"index.d.ts",
|
|
37
|
+
"index.min.js"
|
|
23
38
|
],
|
|
24
39
|
"custom-fields": {
|
|
25
40
|
"cloud-repostories": [
|
package/html.js
DELETED
|
@@ -1,413 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// Zlib License
|
|
4
|
-
//
|
|
5
|
-
// Copyright (C) 2025 DuckAfire <duckafire.github.io/nest>
|
|
6
|
-
//
|
|
7
|
-
// This software is provided 'as-is', without any express or implied
|
|
8
|
-
// warranty. In no event will the authors be held liable for any damages
|
|
9
|
-
// arising from the use of this software.
|
|
10
|
-
//
|
|
11
|
-
// Permission is granted to anyone to use this software for any purpose,
|
|
12
|
-
// including commercial applications, and to alter it and redistribute it
|
|
13
|
-
// freely, subject to the following restrictions:
|
|
14
|
-
//
|
|
15
|
-
// 1. The origin of this software must not be misrepresented; you must not
|
|
16
|
-
// claim that you wrote the original software. If you use this software
|
|
17
|
-
// in a product, an acknowledgment in the product documentation would be
|
|
18
|
-
// appreciated but is not required.
|
|
19
|
-
// 2. Altered source versions must be plainly marked as such, and must not be
|
|
20
|
-
// misrepresented as being the original software.
|
|
21
|
-
// 3. This notice may not be removed or altered from any source distribution.
|
|
22
|
-
|
|
23
|
-
let __htmljs_ignore_last__ = 1;
|
|
24
|
-
let __htmljs_debug_func__ = console.warn;
|
|
25
|
-
|
|
26
|
-
const __htmljs_default_properties_values__ = {};
|
|
27
|
-
|
|
28
|
-
const __htmljs_is_not_object__ = (thing) =>
|
|
29
|
-
{
|
|
30
|
-
return typeof thing != "object" || Array.isArray(thing);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const __htmljs_is_object__ = (thing) =>
|
|
34
|
-
{
|
|
35
|
-
return thing !== null && typeof thing == "object" && !Array.isArray(thing);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const __htmljs_is_empty_object__ = (object) =>
|
|
39
|
-
{
|
|
40
|
-
return Object.keys(object).length === 0;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const __htmljs_element_tags__ = {
|
|
44
|
-
noContainers: [
|
|
45
|
-
"area", "base", "br", "col", "hr", "img", "input", "link",
|
|
46
|
-
"meta", "source", "track", "wbr",
|
|
47
|
-
],
|
|
48
|
-
|
|
49
|
-
containers: [
|
|
50
|
-
"a", "abbr", "address", "article", "audio", "b", "bdi", "bdo",
|
|
51
|
-
"blockquote", "body", "button", "canvas", "caption", "cite",
|
|
52
|
-
"code", "colgroup", "data", "datalist", "dd", "del", "details",
|
|
53
|
-
"dfn", "dialog", "div", "dl", "dt", "em", "fieldset", "figcaption",
|
|
54
|
-
"figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6",
|
|
55
|
-
"head", "header", "hgroup", "html", "i", "iframe", "ins", "kbd",
|
|
56
|
-
"label", "legend", "li", "main", "map", "mark", "meter", "nav",
|
|
57
|
-
"noscript", "object", "ol", "optgroup", "option", "output", "p",
|
|
58
|
-
"picture", "pre", "progress", "q", "rp", "rt", "ruby", "samp",
|
|
59
|
-
"script", "section", "select", "small", "span", "strong", "sub",
|
|
60
|
-
"summary", "sup", "table", "tbody", "td", "template", "textarea",
|
|
61
|
-
"tfoot", "th", "thead", "time", "title", "tr", "ul", "vari", "video",
|
|
62
|
-
]
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const __htmljs_set_prefixed_property__ = (prefix, elem, field, value) =>
|
|
66
|
-
{
|
|
67
|
-
elem.setAttribute(prefix + "-" + field, value);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const __htmljs_data_sets__ = (elem, property, value) =>
|
|
71
|
-
{
|
|
72
|
-
__htmljs_set_prefixed_property__("data", elem, property, value);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const __htmljs_aria_attributes__ = (elem, property, value) =>
|
|
76
|
-
{
|
|
77
|
-
__htmljs_set_prefixed_property__("aria", elem, property, value);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const __htmljs_event_listeners__ = (elem, event, action) =>
|
|
81
|
-
{
|
|
82
|
-
if(Array.isArray(action))
|
|
83
|
-
for(const ACTION of action)
|
|
84
|
-
elem.addEventListener(event, ACTION);
|
|
85
|
-
else
|
|
86
|
-
elem.addEventListener(event, action);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const __htmljs_css_rules__ = (elem, rule, value) =>
|
|
90
|
-
{
|
|
91
|
-
if(rule.charAt(0) == "-") // it is a variable
|
|
92
|
-
elem.style.setProperty(rule, value);
|
|
93
|
-
else
|
|
94
|
-
elem.style[rule] = value;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const __htmljs_treat_special_properties__ = (elem, property, htmlProperties) =>
|
|
98
|
-
{
|
|
99
|
-
let behavior;
|
|
100
|
-
|
|
101
|
-
switch(property)
|
|
102
|
-
{
|
|
103
|
-
case "dataSets": behavior = __htmljs_data_sets__; break;
|
|
104
|
-
case "ariaAttributes": behavior = __htmljs_aria_attributes__; break;
|
|
105
|
-
case "eventListeners": behavior = __htmljs_event_listeners__; break;
|
|
106
|
-
case "cssRules": behavior = __htmljs_css_rules__; break;
|
|
107
|
-
default: return false;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if(__htmljs_is_not_object__( htmlProperties[property] ))
|
|
111
|
-
{
|
|
112
|
-
__htmljs_debug_func__(new TypeError(`Invalid value attributed to \`${property}\`, expecting an object.`));
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
for(const PROPERTY in htmlProperties[property])
|
|
117
|
-
behavior(elem, PROPERTY, htmlProperties[property][PROPERTY]);
|
|
118
|
-
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const __htmljs_set_element_properties__ = (elem, htmlProperties) =>
|
|
123
|
-
{
|
|
124
|
-
for(const PROPERTY in htmlProperties)
|
|
125
|
-
{
|
|
126
|
-
if(__htmljs_treat_special_properties__(elem, PROPERTY, htmlProperties))
|
|
127
|
-
continue;
|
|
128
|
-
|
|
129
|
-
const VALUE = (htmlProperties[PROPERTY] == "~" ? PROPERTY.toLowerCase() : htmlProperties[PROPERTY]);
|
|
130
|
-
|
|
131
|
-
if(elem[PROPERTY] !== undefined || PROPERTY == "className")
|
|
132
|
-
elem[PROPERTY] = VALUE;
|
|
133
|
-
else
|
|
134
|
-
elem.setAttribute(PROPERTY, VALUE);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const __htmljs_core__ = (elementTag, htmlProperties, ...children) =>
|
|
140
|
-
{
|
|
141
|
-
const ELEM = document.createElement(elementTag);
|
|
142
|
-
|
|
143
|
-
if(__htmljs_default_properties_values__[elementTag] != undefined)
|
|
144
|
-
{
|
|
145
|
-
let ref = __htmljs_default_properties_values__[elementTag];
|
|
146
|
-
|
|
147
|
-
if(__htmljs_is_not_object__(ref))
|
|
148
|
-
{
|
|
149
|
-
__htmljs_debug_func__(new TypeError(`Excepting object to \`htmlProperties\`, instead "${typeof htmlProperties}".`));
|
|
150
|
-
|
|
151
|
-
// this allows to jump the for-loop below,
|
|
152
|
-
// if the Debug Mode is != 2
|
|
153
|
-
ref = {};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
__htmljs_set_element_properties__(ELEM, ref);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if(htmlProperties !== undefined)
|
|
160
|
-
{
|
|
161
|
-
let textnode = "";
|
|
162
|
-
const ARGS_MAX = children.length - __htmljs_ignore_last__;
|
|
163
|
-
|
|
164
|
-
if(htmlProperties !== null)
|
|
165
|
-
{
|
|
166
|
-
if(__htmljs_is_not_object__( htmlProperties ))
|
|
167
|
-
{
|
|
168
|
-
__htmljs_debug_func__(new TypeError(`Excepting object to \`htmlProperties\`, instead "${typeof htmlProperties}".`));
|
|
169
|
-
|
|
170
|
-
// this allows to jump the for-loop below,
|
|
171
|
-
// if the Debug Mode is != 2
|
|
172
|
-
htmlProperties = {};
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
__htmljs_set_element_properties__(ELEM, htmlProperties);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
for(let i = 0; i < ARGS_MAX; i++)
|
|
179
|
-
{
|
|
180
|
-
if(typeof children[i] == "string")
|
|
181
|
-
{
|
|
182
|
-
textnode += (textnode == "" ? "" : " ") + children[i];
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if(!(children[i] instanceof HTMLElement))
|
|
187
|
-
{
|
|
188
|
-
__htmljs_debug_func__(new TypeError(`Excepting object or String to \`children[${i}]\`, instead "${typeof children[i]}".`));
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if(textnode != "")
|
|
193
|
-
{
|
|
194
|
-
ELEM.appendChild(document.createTextNode( textnode ));
|
|
195
|
-
textnode = "";
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
try
|
|
199
|
-
{
|
|
200
|
-
ELEM.appendChild( children[i] );
|
|
201
|
-
}
|
|
202
|
-
catch(ex)
|
|
203
|
-
{
|
|
204
|
-
__htmljs_debug_func__(ex);
|
|
205
|
-
break;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if(textnode != "")
|
|
210
|
-
ELEM.appendChild(document.createTextNode( textnode ));
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return ELEM;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
const htmljs_set_ignore_last = (ignore) =>
|
|
217
|
-
{
|
|
218
|
-
__htmljs_ignore_last__ = ignore ? 1 : 0;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
const htmljs_set_debug_mode = (mode) =>
|
|
222
|
-
{
|
|
223
|
-
const TYPE = typeof mode;
|
|
224
|
-
|
|
225
|
-
if(TYPE != "number")
|
|
226
|
-
throw new TypeError(`Invalid mode type: "${TYPE}". Use only integer numbers.`);
|
|
227
|
-
|
|
228
|
-
if(mode > 2)
|
|
229
|
-
throw new RangeError(`Invalid mode value: "${mode}". Use only 0, 1, or 2.`);
|
|
230
|
-
|
|
231
|
-
__htmljs_debug_func__ = [
|
|
232
|
-
() => {},
|
|
233
|
-
console.warn,
|
|
234
|
-
(exception) => { throw exception; }
|
|
235
|
-
][ Math.floor(mode) ];
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
const declare_htmljs = (...args) =>
|
|
239
|
-
{
|
|
240
|
-
let prefix, createObject, useUpperCase;
|
|
241
|
-
|
|
242
|
-
if(args[0] !== null && typeof args[0] == "object")
|
|
243
|
-
({prefix, createObject, useUpperCase} = args[0]);
|
|
244
|
-
else
|
|
245
|
-
[prefix, createObject, useUpperCase] = args;
|
|
246
|
-
|
|
247
|
-
const DEST = createObject ? {} : window;
|
|
248
|
-
const PREF = prefix || "";
|
|
249
|
-
let tag;
|
|
250
|
-
|
|
251
|
-
for(const FIELD in __htmljs_element_tags__)
|
|
252
|
-
{
|
|
253
|
-
__htmljs_element_tags__[FIELD].forEach((elementTag, id) =>
|
|
254
|
-
{
|
|
255
|
-
tag = PREF + elementTag;
|
|
256
|
-
|
|
257
|
-
if(elementTag == "vari")
|
|
258
|
-
elementTag = "var";
|
|
259
|
-
|
|
260
|
-
DEST[ (useUpperCase ? tag.toUpperCase() : tag) ] =
|
|
261
|
-
(FIELD == "noContainers")
|
|
262
|
-
? (properties) => __htmljs_core__(elementTag, properties)
|
|
263
|
-
: (properties, ...children) => __htmljs_core__(elementTag, properties, ...children);
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
return DEST;
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
const __htmljs_save_custom_tag__ = (dest, tag, force) =>
|
|
271
|
-
{
|
|
272
|
-
if(typeof tag != "string")
|
|
273
|
-
{
|
|
274
|
-
__htmljs_debug_func__(new TypeError(`Expecting a string, instead a "${typeof tag}".`));
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
if(force)
|
|
279
|
-
{
|
|
280
|
-
for(const TAG of dest)
|
|
281
|
-
{
|
|
282
|
-
if(tag == TAG)
|
|
283
|
-
{
|
|
284
|
-
console.warn(new Error(`"${tag}" already was added.`));
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
dest.push(tag);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
const htmljs_add_custom_tag = (tag, isNoContainer, force) =>
|
|
294
|
-
{
|
|
295
|
-
const DEST = __htmljs_element_tags__[ (isNoContainer ? "noC" : "c") + "ontainers" ];
|
|
296
|
-
|
|
297
|
-
if(!Array.isArray(tag))
|
|
298
|
-
{
|
|
299
|
-
__htmljs_save_custom_tag__(DEST, tag, force);
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
for(const TAG of tag)
|
|
304
|
-
__htmljs_save_custom_tag__(DEST, TAG, force);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
const __htmljs_validate_tags__ = (tag) =>
|
|
308
|
-
{
|
|
309
|
-
for(const ELEMENT_TYPE in __htmljs_element_tags__)
|
|
310
|
-
for(const TAG of __htmljs_element_tags__[ ELEMENT_TYPE ])
|
|
311
|
-
if(tag == TAG)
|
|
312
|
-
return true;
|
|
313
|
-
|
|
314
|
-
__htmljs_debug_func__(new TypeError(`Invalid HTML tag: "${tag}".`));
|
|
315
|
-
return false;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
const __htmljs_manager_default_properties_values__ = (userFunc, ...args) =>
|
|
319
|
-
{
|
|
320
|
-
let validateTags, tagsList;
|
|
321
|
-
|
|
322
|
-
if(__htmljs_is_object__(args[0]))
|
|
323
|
-
{
|
|
324
|
-
validateTags = false;
|
|
325
|
-
tagsList = args[0];
|
|
326
|
-
}
|
|
327
|
-
else if(typeof args[0] == "boolean" && __htmljs_is_object__(args[1]))
|
|
328
|
-
{
|
|
329
|
-
validateTags = args[0];
|
|
330
|
-
tagsList = args[1];
|
|
331
|
-
}
|
|
332
|
-
else
|
|
333
|
-
{
|
|
334
|
-
validateTags = (typeof args[1] == "boolean" && args[1]);
|
|
335
|
-
tagsList = null;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
if(tagsList !== null)
|
|
339
|
-
{
|
|
340
|
-
for(const TAG in tagsList)
|
|
341
|
-
userFunc(TAG, validateTags, tagsList[ TAG ]);
|
|
342
|
-
|
|
343
|
-
return null;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
const ARG_TAG = args[0].toLowerCase();
|
|
347
|
-
|
|
348
|
-
// TAG == args[0]
|
|
349
|
-
if(typeof ARG_TAG != "string")
|
|
350
|
-
throw new TypeError(`Expecting a string, instead a "${typeof args[0]}".`);
|
|
351
|
-
|
|
352
|
-
if(validateTags)
|
|
353
|
-
{
|
|
354
|
-
if(__htmljs_validate_tags__(ARG_TAG))
|
|
355
|
-
return ARG_TAG;
|
|
356
|
-
|
|
357
|
-
return null;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
return ARG_TAG;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
const htmljs_set_default_properties_values = (...args) =>
|
|
364
|
-
{
|
|
365
|
-
const TAG = __htmljs_manager_default_properties_values__(htmljs_set_default_properties_values, ...args);
|
|
366
|
-
|
|
367
|
-
if(TAG === null)
|
|
368
|
-
return;
|
|
369
|
-
|
|
370
|
-
const VALIDATE_TAGS = args[1];
|
|
371
|
-
const HTML_PROPERTIES = args[2];
|
|
372
|
-
|
|
373
|
-
if(!__htmljs_is_object__(HTML_PROPERTIES))
|
|
374
|
-
throw new TypeError("Invalid type to `htmlProperties`. Expecting an object.");
|
|
375
|
-
|
|
376
|
-
if(VALIDATE_TAGS)
|
|
377
|
-
__htmljs_validate_tags__(TAG);
|
|
378
|
-
|
|
379
|
-
if(__htmljs_default_properties_values__[TAG] === undefined)
|
|
380
|
-
__htmljs_default_properties_values__[TAG] = {};
|
|
381
|
-
|
|
382
|
-
for(const PROPERTY in HTML_PROPERTIES)
|
|
383
|
-
__htmljs_default_properties_values__[TAG][PROPERTY] = HTML_PROPERTIES[ PROPERTY ];
|
|
384
|
-
|
|
385
|
-
if(__htmljs_is_empty_object__(__htmljs_default_properties_values__[TAG]))
|
|
386
|
-
delete __htmljs_default_properties_values__[TAG];
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
const htmljs_unset_default_properties_values = (...args) =>
|
|
390
|
-
{
|
|
391
|
-
const TAG = __htmljs_manager_default_properties_values__(htmljs_unset_default_properties_values, ...args);
|
|
392
|
-
|
|
393
|
-
if(TAG === null)
|
|
394
|
-
return;
|
|
395
|
-
|
|
396
|
-
const VALIDATE_TAGS = args[1];
|
|
397
|
-
const HTML_PROPERTIES = args[2];
|
|
398
|
-
|
|
399
|
-
if(!Array.isArray(HTML_PROPERTIES))
|
|
400
|
-
throw new TypeError("Invalid type to `htmlProperties`. Expecting an object.");
|
|
401
|
-
|
|
402
|
-
if(VALIDATE_TAGS)
|
|
403
|
-
__htmljs_validate_tags__(TAG);
|
|
404
|
-
|
|
405
|
-
if(__htmljs_default_properties_values__[TAG] === undefined)
|
|
406
|
-
return;
|
|
407
|
-
|
|
408
|
-
for(const PROPERTY of HTML_PROPERTIES)
|
|
409
|
-
delete __htmljs_default_properties_values__[TAG][PROPERTY];
|
|
410
|
-
|
|
411
|
-
if(__htmljs_is_empty_object__(__htmljs_default_properties_values__[TAG]))
|
|
412
|
-
delete __htmljs_default_properties_values__[TAG];
|
|
413
|
-
}
|
package/html.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";let __htmljs_ignore_last__=1,__htmljs_debug_func__=console.warn;const __htmljs_default_properties_values__={},__htmljs_is_not_object__=_=>"object"!=typeof _||Array.isArray(_),__htmljs_is_object__=_=>null!==_&&"object"==typeof _&&!Array.isArray(_),__htmljs_is_empty_object__=_=>0===Object.keys(_).length,__htmljs_element_tags__={noContainers:["area","base","br","col","hr","img","input","link","meta","source","track","wbr"],containers:["a","abbr","address","article","audio","b","bdi","bdo","blockquote","body","button","canvas","caption","cite","code","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","html","i","iframe","ins","kbd","label","legend","li","main","map","mark","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","samp","script","section","select","small","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","ul","vari","video"]},__htmljs_set_prefixed_property__=(_,e,t,s)=>{e.setAttribute(_+"-"+t,s)},__htmljs_data_sets__=(_,e,t)=>{__htmljs_set_prefixed_property__("data",_,e,t)},__htmljs_aria_attributes__=(_,e,t)=>{__htmljs_set_prefixed_property__("aria",_,e,t)},__htmljs_event_listeners__=(_,e,t)=>{if(Array.isArray(t))for(const s of t)_.addEventListener(e,s);else _.addEventListener(e,t)},__htmljs_css_rules__=(_,e,t)=>{"-"==e.charAt(0)?_.style.setProperty(e,t):_.style[e]=t},__htmljs_treat_special_properties__=(_,e,t)=>{let s;switch(e){case"dataSets":s=__htmljs_data_sets__;break;case"ariaAttributes":s=__htmljs_aria_attributes__;break;case"eventListeners":s=__htmljs_event_listeners__;break;case"cssRules":s=__htmljs_css_rules__;break;default:return!1}if(__htmljs_is_not_object__(t[e]))return __htmljs_debug_func__(new TypeError(`Invalid value attributed to \`${e}\`, expecting an object.`)),!1;for(const r in t[e])s(_,r,t[e][r]);return!0},__htmljs_set_element_properties__=(_,e)=>{for(const t in e){if(__htmljs_treat_special_properties__(_,t,e))continue;const s="~"==e[t]?t.toLowerCase():e[t];void 0!==_[t]||"className"==t?_[t]=s:_.setAttribute(t,s)}},__htmljs_core__=(_,e,...t)=>{const s=document.createElement(_);if(null!=__htmljs_default_properties_values__[_]){let t=__htmljs_default_properties_values__[_];__htmljs_is_not_object__(t)&&(__htmljs_debug_func__(new TypeError(`Excepting object to \`htmlProperties\`, instead "${typeof e}".`)),t={}),__htmljs_set_element_properties__(s,t)}if(void 0!==e){let _="";const r=t.length-__htmljs_ignore_last__;null!==e&&(__htmljs_is_not_object__(e)&&(__htmljs_debug_func__(new TypeError(`Excepting object to \`htmlProperties\`, instead "${typeof e}".`)),e={}),__htmljs_set_element_properties__(s,e));for(let e=0;e<r;e++)if("string"!=typeof t[e])if(t[e]instanceof HTMLElement){""!=_&&(s.appendChild(document.createTextNode(_)),_="");try{s.appendChild(t[e])}catch(_){__htmljs_debug_func__(_);break}}else __htmljs_debug_func__(new TypeError(`Excepting object or String to \`children[${e}]\`, instead "${typeof t[e]}".`));else _+=(""==_?"":" ")+t[e];""!=_&&s.appendChild(document.createTextNode(_))}return s},htmljs_set_ignore_last=_=>{__htmljs_ignore_last__=_?1:0},htmljs_set_debug_mode=_=>{const e=typeof _;if("number"!=e)throw new TypeError(`Invalid mode type: "${e}". Use only integer numbers.`);if(_>2)throw new RangeError(`Invalid mode value: "${_}". Use only 0, 1, or 2.`);__htmljs_debug_func__=[()=>{},console.warn,_=>{throw _}][Math.floor(_)]},declare_htmljs=(..._)=>{let e,t,s;null!==_[0]&&"object"==typeof _[0]?({prefix:e,createObject:t,useUpperCase:s}=_[0]):[e,t,s]=_;const r=t?{}:window,l=e||"";let o;for(const _ in __htmljs_element_tags__)__htmljs_element_tags__[_].forEach((e,t)=>{o=l+e,"vari"==e&&(e="var"),r[s?o.toUpperCase():o]="noContainers"==_?_=>__htmljs_core__(e,_):(_,...t)=>__htmljs_core__(e,_,...t)});return r},__htmljs_save_custom_tag__=(_,e,t)=>{if("string"==typeof e){if(t)for(const t of _)if(e==t)return void console.warn(new Error(`"${e}" already was added.`));_.push(e)}else __htmljs_debug_func__(new TypeError(`Expecting a string, instead a "${typeof e}".`))},htmljs_add_custom_tag=(_,e,t)=>{const s=__htmljs_element_tags__[(e?"noC":"c")+"ontainers"];if(Array.isArray(_))for(const e of _)__htmljs_save_custom_tag__(s,e,t);else __htmljs_save_custom_tag__(s,_,t)},__htmljs_validate_tags__=_=>{for(const e in __htmljs_element_tags__)for(const t of __htmljs_element_tags__[e])if(_==t)return!0;return __htmljs_debug_func__(new TypeError(`Invalid HTML tag: "${_}".`)),!1},__htmljs_manager_default_properties_values__=(_,...e)=>{let t,s;if(__htmljs_is_object__(e[0])?(t=!1,s=e[0]):"boolean"==typeof e[0]&&__htmljs_is_object__(e[1])?(t=e[0],s=e[1]):(t="boolean"==typeof e[1]&&e[1],s=null),null!==s){for(const e in s)_(e,t,s[e]);return null}const r=e[0].toLowerCase();if("string"!=typeof r)throw new TypeError(`Expecting a string, instead a "${typeof e[0]}".`);return t?__htmljs_validate_tags__(r)?r:null:r},htmljs_set_default_properties_values=(..._)=>{const e=__htmljs_manager_default_properties_values__(htmljs_set_default_properties_values,..._);if(null===e)return;const t=_[1],s=_[2];if(!__htmljs_is_object__(s))throw new TypeError("Invalid type to `htmlProperties`. Expecting an object.");t&&__htmljs_validate_tags__(e),void 0===__htmljs_default_properties_values__[e]&&(__htmljs_default_properties_values__[e]={});for(const _ in s)__htmljs_default_properties_values__[e][_]=s[_];__htmljs_is_empty_object__(__htmljs_default_properties_values__[e])&&delete __htmljs_default_properties_values__[e]},htmljs_unset_default_properties_values=(..._)=>{const e=__htmljs_manager_default_properties_values__(htmljs_unset_default_properties_values,..._);if(null===e)return;const t=_[1],s=_[2];if(!Array.isArray(s))throw new TypeError("Invalid type to `htmlProperties`. Expecting an object.");if(t&&__htmljs_validate_tags__(e),void 0!==__htmljs_default_properties_values__[e]){for(const _ of s)delete __htmljs_default_properties_values__[e][_];__htmljs_is_empty_object__(__htmljs_default_properties_values__[e])&&delete __htmljs_default_properties_values__[e]}};
|