native-document 1.0.93 → 1.0.94
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/elements.js +1 -0
- package/index.def.js +350 -0
- package/package.json +1 -1
- package/src/core/elements/content-formatter.js +138 -1
- package/src/core/elements/control/for-each-array.js +1 -1
- package/src/core/elements/control/for-each.js +1 -1
- package/src/core/elements/control/show-if.js +3 -3
- package/src/core/elements/control/show-when.js +2 -2
- package/src/core/elements/control/switch.js +1 -1
- package/src/core/elements/description-list.js +14 -0
- package/src/core/elements/form.js +188 -4
- package/src/core/elements/html5-semantics.js +44 -1
- package/src/core/elements/img.js +22 -10
- package/src/core/elements/index.js +5 -0
- package/src/core/elements/interactive.js +19 -1
- package/src/core/elements/list.js +28 -1
- package/src/core/elements/medias.js +29 -0
- package/src/core/elements/meta-data.js +34 -0
- package/src/core/elements/table.js +59 -0
- package/src/core/utils/helpers.js +7 -2
- package/src/core/utils/memoize.js +1 -1
- package/src/core/wrappers/HtmlElementWrapper.js +2 -2
- package/src/core/wrappers/NDElement.js +1 -1
- package/src/core/wrappers/TemplateCloner.js +1 -1
- package/types/elements.d.ts +495 -113
- package/types/forms.d.ts +85 -48
- package/types/images.d.ts +16 -9
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import HtmlElementWrapper from "../wrappers/HtmlElementWrapper";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Creates a `<form>` element.
|
|
6
|
+
* Extended with fluent methods: `.submit()`, `.post()`, `.get()`, `.multipartFormData()`.
|
|
7
|
+
* @type {function(FormAttributes=, NdChild|NdChild[]=): HTMLFormElement & {
|
|
8
|
+
* submit: (actionOrFn: string | ((e: SubmitEvent) => void)) => HTMLFormElement,
|
|
9
|
+
* post: (action: string) => HTMLFormElement,
|
|
10
|
+
* get: (action: string) => HTMLFormElement,
|
|
11
|
+
* multipartFormData: () => HTMLFormElement,
|
|
12
|
+
* }}
|
|
13
|
+
*/
|
|
4
14
|
export const Form = HtmlElementWrapper('form', function(el) {
|
|
5
15
|
|
|
6
16
|
el.submit = function(action) {
|
|
@@ -30,42 +40,216 @@ export const Form = HtmlElementWrapper('form', function(el) {
|
|
|
30
40
|
return el;
|
|
31
41
|
});
|
|
32
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Creates an `<input>` element.
|
|
45
|
+
* @type {function(InputAttributes=): HTMLInputElement}
|
|
46
|
+
*/
|
|
33
47
|
export const Input = HtmlElementWrapper('input');
|
|
34
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Creates a `<textarea>` element.
|
|
51
|
+
* @type {function(TextAreaAttributes=, NdChild|NdChild[]=): HTMLTextAreaElement}
|
|
52
|
+
*/
|
|
35
53
|
export const TextArea = HtmlElementWrapper('textarea');
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Alias for {@link TextArea}.
|
|
57
|
+
* @type {function(TextAreaAttributes=, NdChild|NdChild[]=): HTMLTextAreaElement}
|
|
58
|
+
*/
|
|
36
59
|
export const TextInput = TextArea;
|
|
37
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Creates a `<select>` element.
|
|
63
|
+
* @type {function(SelectAttributes=, NdChild|NdChild[]=): HTMLSelectElement}
|
|
64
|
+
*/
|
|
38
65
|
export const Select = HtmlElementWrapper('select');
|
|
39
|
-
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Creates a `<fieldset>` element.
|
|
69
|
+
* @type {function(GlobalAttributes & { disabled?: Observable<boolean>|boolean }=, NdChild|NdChild[]=): HTMLFieldSetElement}
|
|
70
|
+
*/
|
|
71
|
+
export const FieldSet = HtmlElementWrapper('fieldset');
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Creates an `<option>` element.
|
|
75
|
+
* @type {function(OptionAttributes=, NdChild|NdChild[]=): HTMLOptionElement}
|
|
76
|
+
*/
|
|
40
77
|
export const Option = HtmlElementWrapper('option');
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Creates a `<legend>` element.
|
|
81
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLLegendElement}
|
|
82
|
+
*/
|
|
41
83
|
export const Legend = HtmlElementWrapper('legend');
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Creates a `<datalist>` element.
|
|
87
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLDataListElement}
|
|
88
|
+
*/
|
|
42
89
|
export const Datalist = HtmlElementWrapper('datalist');
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Creates an `<output>` element.
|
|
93
|
+
* @type {function(OutputAttributes=, NdChild|NdChild[]=): HTMLOutputElement}
|
|
94
|
+
*/
|
|
43
95
|
export const Output = HtmlElementWrapper('output');
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Creates a `<progress>` element.
|
|
99
|
+
* @type {function(ProgressAttributes=, NdChild|NdChild[]=): HTMLProgressElement}
|
|
100
|
+
*/
|
|
44
101
|
export const Progress = HtmlElementWrapper('progress');
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Creates a `<meter>` element.
|
|
105
|
+
* @type {function(MeterAttributes=, NdChild|NdChild[]=): HTMLMeterElement}
|
|
106
|
+
*/
|
|
45
107
|
export const Meter = HtmlElementWrapper('meter');
|
|
46
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Creates an `<input readonly>` element.
|
|
111
|
+
* @param {Omit<InputAttributes, 'type'|'readonly'|'readOnly'>} [attributes]
|
|
112
|
+
* @returns {HTMLInputElement}
|
|
113
|
+
*/
|
|
47
114
|
export const ReadonlyInput = (attributes) => Input({ readonly: true, ...attributes });
|
|
48
|
-
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Creates an `<input type="hidden">` element.
|
|
118
|
+
* @param {Omit<InputAttributes, 'type'>} [attributes]
|
|
119
|
+
* @returns {HTMLInputElement}
|
|
120
|
+
*/
|
|
121
|
+
export const HiddenInput = (attributes) => Input({ type: 'hidden', ...attributes });
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Creates an `<input type="file">` element.
|
|
125
|
+
* @param {Omit<InputAttributes, 'type'>} [attributes]
|
|
126
|
+
* @returns {HTMLInputElement}
|
|
127
|
+
*/
|
|
49
128
|
export const FileInput = (attributes) => Input({ type: 'file', ...attributes });
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Creates an `<input type="password">` element.
|
|
132
|
+
* @param {Omit<InputAttributes, 'type'>} [attributes]
|
|
133
|
+
* @returns {HTMLInputElement}
|
|
134
|
+
*/
|
|
50
135
|
export const PasswordInput = (attributes) => Input({ type: 'password', ...attributes });
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Creates an `<input type="checkbox">` element.
|
|
139
|
+
* @param {Omit<InputAttributes, 'type'>} [attributes]
|
|
140
|
+
* @returns {HTMLInputElement}
|
|
141
|
+
*/
|
|
51
142
|
export const Checkbox = (attributes) => Input({ type: 'checkbox', ...attributes });
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Creates an `<input type="radio">` element.
|
|
146
|
+
* @param {Omit<InputAttributes, 'type'>} [attributes]
|
|
147
|
+
* @returns {HTMLInputElement}
|
|
148
|
+
*/
|
|
52
149
|
export const Radio = (attributes) => Input({ type: 'radio', ...attributes });
|
|
53
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Creates an `<input type="range">` element.
|
|
153
|
+
* @param {Omit<InputAttributes, 'type'>} [attributes]
|
|
154
|
+
* @returns {HTMLInputElement}
|
|
155
|
+
*/
|
|
54
156
|
export const RangeInput = (attributes) => Input({ type: 'range', ...attributes });
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Creates an `<input type="color">` element.
|
|
160
|
+
* @param {Omit<InputAttributes, 'type'>} [attributes]
|
|
161
|
+
* @returns {HTMLInputElement}
|
|
162
|
+
*/
|
|
55
163
|
export const ColorInput = (attributes) => Input({ type: 'color', ...attributes });
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Creates an `<input type="date">` element.
|
|
167
|
+
* @param {Omit<InputAttributes, 'type'>} [attributes]
|
|
168
|
+
* @returns {HTMLInputElement}
|
|
169
|
+
*/
|
|
56
170
|
export const DateInput = (attributes) => Input({ type: 'date', ...attributes });
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Creates an `<input type="time">` element.
|
|
174
|
+
* @param {Omit<InputAttributes, 'type'>} [attributes]
|
|
175
|
+
* @returns {HTMLInputElement}
|
|
176
|
+
*/
|
|
57
177
|
export const TimeInput = (attributes) => Input({ type: 'time', ...attributes });
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Creates an `<input type="datetime-local">` element.
|
|
181
|
+
* @param {Omit<InputAttributes, 'type'>} [attributes]
|
|
182
|
+
* @returns {HTMLInputElement}
|
|
183
|
+
*/
|
|
58
184
|
export const DateTimeInput = (attributes) => Input({ type: 'datetime-local', ...attributes });
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Creates an `<input type="week">` element.
|
|
188
|
+
* @param {Omit<InputAttributes, 'type'>} [attributes]
|
|
189
|
+
* @returns {HTMLInputElement}
|
|
190
|
+
*/
|
|
59
191
|
export const WeekInput = (attributes) => Input({ type: 'week', ...attributes });
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Creates an `<input type="month">` element.
|
|
195
|
+
* @param {Omit<InputAttributes, 'type'>} [attributes]
|
|
196
|
+
* @returns {HTMLInputElement}
|
|
197
|
+
*/
|
|
60
198
|
export const MonthInput = (attributes) => Input({ type: 'month', ...attributes });
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Creates an `<input type="search">` element.
|
|
202
|
+
* @param {Omit<InputAttributes, 'type'>} [attributes]
|
|
203
|
+
* @returns {HTMLInputElement}
|
|
204
|
+
*/
|
|
61
205
|
export const SearchInput = (attributes) => Input({ type: 'search', ...attributes });
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Creates an `<input type="tel">` element.
|
|
209
|
+
* @param {Omit<InputAttributes, 'type'>} [attributes]
|
|
210
|
+
* @returns {HTMLInputElement}
|
|
211
|
+
*/
|
|
62
212
|
export const TelInput = (attributes) => Input({ type: 'tel', ...attributes });
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Creates an `<input type="url">` element.
|
|
216
|
+
* @param {Omit<InputAttributes, 'type'>} [attributes]
|
|
217
|
+
* @returns {HTMLInputElement}
|
|
218
|
+
*/
|
|
63
219
|
export const UrlInput = (attributes) => Input({ type: 'url', ...attributes });
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Creates an `<input type="email">` element.
|
|
223
|
+
* @param {Omit<InputAttributes, 'type'>} [attributes]
|
|
224
|
+
* @returns {HTMLInputElement}
|
|
225
|
+
*/
|
|
64
226
|
export const EmailInput = (attributes) => Input({ type: 'email', ...attributes });
|
|
65
|
-
export const NumberInput = (attributes) => Input({ type: 'number', ...attributes });
|
|
66
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Creates an `<input type="number">` element.
|
|
230
|
+
* @param {Omit<InputAttributes, 'type'>} [attributes]
|
|
231
|
+
* @returns {HTMLInputElement}
|
|
232
|
+
*/
|
|
233
|
+
export const NumberInput = (attributes) => Input({ type: 'number', ...attributes });
|
|
67
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Creates a `<button>` element.
|
|
237
|
+
* @type {function(ButtonAttributes=, NdChild|NdChild[]=): HTMLButtonElement}
|
|
238
|
+
*/
|
|
68
239
|
export const Button = HtmlElementWrapper('button');
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Creates a `<button type="button">` element.
|
|
243
|
+
* @param {NdChild|NdChild[]} [child]
|
|
244
|
+
* @param {Omit<ButtonAttributes, 'type'>} [attributes]
|
|
245
|
+
* @returns {HTMLButtonElement}
|
|
246
|
+
*/
|
|
69
247
|
export const SimpleButton = (child, attributes) => Button(child, { type: 'button', ...attributes });
|
|
70
|
-
export const SubmitButton = (child, attributes) => Button(child, { type: 'submit', ...attributes });
|
|
71
248
|
|
|
249
|
+
/**
|
|
250
|
+
* Creates a `<button type="submit">` element.
|
|
251
|
+
* @param {NdChild|NdChild[]} [child]
|
|
252
|
+
* @param {Omit<ButtonAttributes, 'type'>} [attributes]
|
|
253
|
+
* @returns {HTMLButtonElement}
|
|
254
|
+
*/
|
|
255
|
+
export const SubmitButton = (child, attributes) => Button(child, { type: 'submit', ...attributes });
|
|
@@ -1,12 +1,55 @@
|
|
|
1
1
|
import HtmlElementWrapper from "../wrappers/HtmlElementWrapper";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Creates a `<main>` element.
|
|
5
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
|
|
6
|
+
*/
|
|
3
7
|
export const Main = HtmlElementWrapper('main');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creates a `<section>` element.
|
|
11
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
|
|
12
|
+
*/
|
|
4
13
|
export const Section = HtmlElementWrapper('section');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates an `<article>` element.
|
|
17
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
|
|
18
|
+
*/
|
|
5
19
|
export const Article = HtmlElementWrapper('article');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Creates an `<aside>` element.
|
|
23
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
|
|
24
|
+
*/
|
|
6
25
|
export const Aside = HtmlElementWrapper('aside');
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Creates a `<nav>` element.
|
|
29
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
|
|
30
|
+
*/
|
|
7
31
|
export const Nav = HtmlElementWrapper('nav');
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Creates a `<figure>` element.
|
|
35
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
|
|
36
|
+
*/
|
|
8
37
|
export const Figure = HtmlElementWrapper('figure');
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates a `<figcaption>` element.
|
|
41
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
|
|
42
|
+
*/
|
|
9
43
|
export const FigCaption = HtmlElementWrapper('figcaption');
|
|
10
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Creates a `<header>` element.
|
|
47
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
|
|
48
|
+
*/
|
|
11
49
|
export const Header = HtmlElementWrapper('header');
|
|
12
|
-
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Creates a `<footer>` element.
|
|
53
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
|
|
54
|
+
*/
|
|
55
|
+
export const Footer = HtmlElementWrapper('footer');
|
package/src/core/elements/img.js
CHANGED
|
@@ -2,18 +2,30 @@ import HtmlElementWrapper from "../wrappers/HtmlElementWrapper"
|
|
|
2
2
|
import Validator from "../utils/validator";
|
|
3
3
|
import NativeDocumentError from "../errors/NativeDocumentError";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Creates an `<img>` element.
|
|
7
|
+
* @type {function(ImgAttributes=): HTMLImageElement}
|
|
8
|
+
*/
|
|
5
9
|
export const BaseImage = HtmlElementWrapper('img');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates an `<img>` element.
|
|
13
|
+
* @param {Observable<string>|string} src
|
|
14
|
+
* @param {Omit<ImgAttributes, 'src'>} [attributes]
|
|
15
|
+
* @returns {HTMLImageElement}
|
|
16
|
+
*/
|
|
6
17
|
export const Img = function(src, attributes) {
|
|
7
18
|
return BaseImage({ src, ...attributes });
|
|
8
19
|
};
|
|
9
20
|
|
|
10
21
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @param {string
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {
|
|
16
|
-
* @
|
|
22
|
+
* Creates an `<img>` that loads asynchronously, showing a placeholder until the image is ready.
|
|
23
|
+
* Supports reactive `src` — automatically updates when the observable changes.
|
|
24
|
+
* @param {Observable<string>|string} src - Final image URL
|
|
25
|
+
* @param {string|null} defaultImage - Placeholder shown while loading
|
|
26
|
+
* @param {Omit<ImgAttributes, 'src'>} attributes
|
|
27
|
+
* @param {(error: NativeDocumentError|null, img: HTMLImageElement) => void} [callback]
|
|
28
|
+
* @returns {HTMLImageElement}
|
|
17
29
|
*/
|
|
18
30
|
export const AsyncImg = function(src, defaultImage, attributes, callback) {
|
|
19
31
|
const defaultSrc = Validator.isObservable(src) ? src.val() : src;
|
|
@@ -37,10 +49,10 @@ export const AsyncImg = function(src, defaultImage, attributes, callback) {
|
|
|
37
49
|
};
|
|
38
50
|
|
|
39
51
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @param {string}
|
|
42
|
-
* @param {
|
|
43
|
-
* @returns {
|
|
52
|
+
* Creates an `<img loading="lazy">` element.
|
|
53
|
+
* @param {Observable<string>|string} src
|
|
54
|
+
* @param {Omit<ImgAttributes, 'src'|'loading'>} [attributes]
|
|
55
|
+
* @returns {HTMLImageElement}
|
|
44
56
|
*/
|
|
45
57
|
export const LazyImg = function(src, attributes) {
|
|
46
58
|
return Img(src, { ...attributes, loading: 'lazy' });
|
|
@@ -16,6 +16,11 @@ export * from './medias';
|
|
|
16
16
|
export * from './meta-data';
|
|
17
17
|
export * from './table';
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Creates an empty `DocumentFragment` wrapper.
|
|
21
|
+
* Useful for grouping elements without adding a DOM node.
|
|
22
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): DocumentFragment}
|
|
23
|
+
*/
|
|
19
24
|
export const Fragment = HtmlElementWrapper('');
|
|
20
25
|
|
|
21
26
|
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import HtmlElementWrapper from "../wrappers/HtmlElementWrapper";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Creates a `<details>` element.
|
|
5
|
+
* @type {function(DetailsAttributes=, NdChild|NdChild[]=): HTMLDetailsElement}
|
|
6
|
+
*/
|
|
4
7
|
export const Details = HtmlElementWrapper('details');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creates a `<summary>` element.
|
|
11
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
|
|
12
|
+
*/
|
|
5
13
|
export const Summary = HtmlElementWrapper('summary');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates a `<dialog>` element.
|
|
17
|
+
* @type {function(DialogAttributes=, NdChild|NdChild[]=): HTMLDialogElement}
|
|
18
|
+
*/
|
|
6
19
|
export const Dialog = HtmlElementWrapper('dialog');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Creates a `<menu>` element.
|
|
23
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLMenuElement}
|
|
24
|
+
*/
|
|
7
25
|
export const Menu = HtmlElementWrapper('menu');
|
|
@@ -1,10 +1,37 @@
|
|
|
1
1
|
import HtmlElementWrapper from "../wrappers/HtmlElementWrapper";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Creates an `<ol>` element.
|
|
5
|
+
* @type {function(OlAttributes=, NdChild|NdChild[]=): HTMLOListElement}
|
|
6
|
+
*/
|
|
3
7
|
export const OrderedList = HtmlElementWrapper('ol');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creates a `<ul>` element.
|
|
11
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLUListElement}
|
|
12
|
+
*/
|
|
4
13
|
export const UnorderedList = HtmlElementWrapper('ul');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates a `<li>` element.
|
|
17
|
+
* @type {function(GlobalAttributes & { value?: number }=, NdChild|NdChild[]=): HTMLLIElement}
|
|
18
|
+
*/
|
|
5
19
|
export const ListItem = HtmlElementWrapper('li');
|
|
6
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Alias for {@link ListItem}.
|
|
23
|
+
* @type {typeof ListItem}
|
|
24
|
+
*/
|
|
7
25
|
export const Li = ListItem;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Alias for {@link OrderedList}.
|
|
29
|
+
* @type {typeof OrderedList}
|
|
30
|
+
*/
|
|
8
31
|
export const Ol = OrderedList;
|
|
9
|
-
export const Ul = UnorderedList;
|
|
10
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Alias for {@link UnorderedList}.
|
|
35
|
+
* @type {typeof UnorderedList}
|
|
36
|
+
*/
|
|
37
|
+
export const Ul = UnorderedList;
|
|
@@ -1,8 +1,37 @@
|
|
|
1
1
|
import HtmlElementWrapper from "../wrappers/HtmlElementWrapper";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Creates an `<audio>` element.
|
|
5
|
+
* @type {function(AudioAttributes=, NdChild|NdChild[]=): HTMLAudioElement}
|
|
6
|
+
*/
|
|
3
7
|
export const Audio = HtmlElementWrapper('audio');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creates a `<video>` element.
|
|
11
|
+
* @type {function(VideoAttributes=, NdChild|NdChild[]=): HTMLVideoElement}
|
|
12
|
+
*/
|
|
4
13
|
export const Video = HtmlElementWrapper('video');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates a `<source>` element.
|
|
17
|
+
* @type {function(SourceAttributes=): HTMLSourceElement}
|
|
18
|
+
*/
|
|
5
19
|
export const Source = HtmlElementWrapper('source');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Creates a `<track>` element.
|
|
23
|
+
* @type {function(TrackAttributes=): HTMLTrackElement}
|
|
24
|
+
*/
|
|
6
25
|
export const Track = HtmlElementWrapper('track');
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Creates a `<canvas>` element.
|
|
29
|
+
* @type {function(CanvasAttributes=, NdChild|NdChild[]=): HTMLCanvasElement}
|
|
30
|
+
*/
|
|
7
31
|
export const Canvas = HtmlElementWrapper('canvas');
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Creates an `<svg>` element.
|
|
35
|
+
* @type {function(SvgAttributes=, NdChild|NdChild[]=): SVGSVGElement}
|
|
36
|
+
*/
|
|
8
37
|
export const Svg = HtmlElementWrapper('svg');
|
|
@@ -1,9 +1,43 @@
|
|
|
1
1
|
import HtmlElementWrapper from "../wrappers/HtmlElementWrapper";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Creates a `<time>` element.
|
|
5
|
+
* @type {function(TimeAttributes=, NdChild|NdChild[]=): HTMLTimeElement}
|
|
6
|
+
*/
|
|
3
7
|
export const Time = HtmlElementWrapper('time');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creates a `<data>` element.
|
|
11
|
+
* @type {function(GlobalAttributes & { value?: Observable<string>|string }=, NdChild|NdChild[]=): HTMLDataElement}
|
|
12
|
+
*/
|
|
4
13
|
export const Data = HtmlElementWrapper('data');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates an `<address>` element.
|
|
17
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
|
|
18
|
+
*/
|
|
5
19
|
export const Address = HtmlElementWrapper('address');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Creates a `<kbd>` element.
|
|
23
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
|
|
24
|
+
*/
|
|
6
25
|
export const Kbd = HtmlElementWrapper('kbd');
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Creates a `<samp>` element.
|
|
29
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
|
|
30
|
+
*/
|
|
7
31
|
export const Samp = HtmlElementWrapper('samp');
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Creates a `<var>` element.
|
|
35
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
|
|
36
|
+
*/
|
|
8
37
|
export const Var = HtmlElementWrapper('var');
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates a `<wbr>` element.
|
|
41
|
+
* @type {function(GlobalAttributes=): HTMLElement}
|
|
42
|
+
*/
|
|
9
43
|
export const Wbr = HtmlElementWrapper('wbr');
|
|
@@ -1,14 +1,73 @@
|
|
|
1
1
|
import HtmlElementWrapper from "../wrappers/HtmlElementWrapper";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Creates a `<caption>` element.
|
|
5
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLTableCaptionElement}
|
|
6
|
+
*/
|
|
3
7
|
export const Caption = HtmlElementWrapper('caption');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creates a `<table>` element.
|
|
11
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLTableElement}
|
|
12
|
+
*/
|
|
4
13
|
export const Table = HtmlElementWrapper('table');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates a `<thead>` element.
|
|
17
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLTableSectionElement}
|
|
18
|
+
*/
|
|
5
19
|
export const THead = HtmlElementWrapper('thead');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Creates a `<tfoot>` element.
|
|
23
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLTableSectionElement}
|
|
24
|
+
*/
|
|
6
25
|
export const TFoot = HtmlElementWrapper('tfoot');
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Creates a `<tbody>` element.
|
|
29
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLTableSectionElement}
|
|
30
|
+
*/
|
|
7
31
|
export const TBody = HtmlElementWrapper('tbody');
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Creates a `<tr>` element.
|
|
35
|
+
* @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLTableRowElement}
|
|
36
|
+
*/
|
|
8
37
|
export const Tr = HtmlElementWrapper('tr');
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Alias for {@link Tr}.
|
|
41
|
+
* @type {typeof Tr}
|
|
42
|
+
*/
|
|
9
43
|
export const TRow = Tr;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Creates a `<th>` element.
|
|
47
|
+
* @type {function(ThAttributes=, NdChild|NdChild[]=): HTMLTableCellElement}
|
|
48
|
+
*/
|
|
10
49
|
export const Th = HtmlElementWrapper('th');
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Alias for {@link Th}.
|
|
53
|
+
* @type {typeof Th}
|
|
54
|
+
*/
|
|
11
55
|
export const THeadCell = Th;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Alias for {@link Th}.
|
|
59
|
+
* @type {typeof Th}
|
|
60
|
+
*/
|
|
12
61
|
export const TFootCell = Th;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Creates a `<td>` element.
|
|
65
|
+
* @type {function(TdAttributes=, NdChild|NdChild[]=): HTMLTableCellElement}
|
|
66
|
+
*/
|
|
13
67
|
export const Td = HtmlElementWrapper('td');
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Alias for {@link Td}.
|
|
71
|
+
* @type {typeof Td}
|
|
72
|
+
*/
|
|
14
73
|
export const TBodyCell = Td;
|
|
@@ -75,7 +75,12 @@ export const trim = function(str, char) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
export const deepClone = (value, onObservableFound) => {
|
|
78
|
-
|
|
78
|
+
try {
|
|
79
|
+
if(window.structuredClone !== undefined) {
|
|
80
|
+
return window.structuredClone(value);
|
|
81
|
+
}
|
|
82
|
+
} catch (e){}
|
|
83
|
+
|
|
79
84
|
if (value === null || typeof value !== 'object') {
|
|
80
85
|
return value;
|
|
81
86
|
}
|
|
@@ -99,7 +104,7 @@ export const deepClone = (value, onObservableFound) => {
|
|
|
99
104
|
// Objects
|
|
100
105
|
const cloned = {};
|
|
101
106
|
for (const key in value) {
|
|
102
|
-
if (
|
|
107
|
+
if (Object.hasOwn(value, key)) {
|
|
103
108
|
cloned[key] = deepClone(value[key]);
|
|
104
109
|
}
|
|
105
110
|
}
|
|
@@ -28,10 +28,10 @@ function createHtmlElement($tagName, customWrapper, _attributes, _children = nul
|
|
|
28
28
|
/**
|
|
29
29
|
*
|
|
30
30
|
* @param {string} name
|
|
31
|
-
* @param {?Function} customWrapper
|
|
31
|
+
* @param {?Function=} customWrapper
|
|
32
32
|
* @returns {Function}
|
|
33
33
|
*/
|
|
34
|
-
export default function HtmlElementWrapper(name, customWrapper) {
|
|
34
|
+
export default function HtmlElementWrapper(name, customWrapper = null) {
|
|
35
35
|
return createHtmlElement.bind(null, name, customWrapper);
|
|
36
36
|
};
|
|
37
37
|
|
|
@@ -51,7 +51,7 @@ const $hydrateFn = function(hydrateFunction, targetType, element, property) {
|
|
|
51
51
|
hydrationState[targetType][property] = hydrateFunction;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
const bindAttachMethods =
|
|
54
|
+
const bindAttachMethods = (node, bindDingData, data) => {
|
|
55
55
|
if(!bindDingData.attach) {
|
|
56
56
|
return null;
|
|
57
57
|
}
|