@schukai/monster 1.24.0 → 1.27.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG +47 -0
- package/README.md +4 -4
- package/dist/modules/constants.js +2 -2
- package/dist/modules/constraints/abstract.js +1 -1
- package/dist/modules/constraints/abstractoperator.js +1 -1
- package/dist/modules/constraints/andoperator.js +1 -1
- package/dist/modules/constraints/invalid.js +1 -1
- package/dist/modules/constraints/isarray.js +1 -1
- package/dist/modules/constraints/isobject.js +1 -1
- package/dist/modules/constraints/namespace.js +1 -1
- package/dist/modules/constraints/oroperator.js +1 -1
- package/dist/modules/constraints/valid.js +1 -1
- package/dist/modules/data/buildmap.js +2 -2
- package/dist/modules/data/buildtree.js +2 -0
- package/dist/modules/data/datasource/namespace.js +1 -1
- package/dist/modules/data/datasource/restapi/writeerror.js +1 -1
- package/dist/modules/data/datasource/restapi.js +1 -1
- package/dist/modules/data/datasource/storage/localstorage.js +1 -1
- package/dist/modules/data/datasource/storage/namespace.js +1 -1
- package/dist/modules/data/datasource/storage/sessionstorage.js +1 -1
- package/dist/modules/data/datasource/storage.js +1 -1
- package/dist/modules/data/datasource.js +1 -1
- package/dist/modules/data/diff.js +1 -1
- package/dist/modules/data/extend.js +1 -1
- package/dist/modules/data/namespace.js +1 -1
- package/dist/modules/data/pathfinder.js +1 -1
- package/dist/modules/data/pipe.js +1 -1
- package/dist/modules/data/transformer.js +2 -2
- package/dist/modules/dom/assembler.js +1 -1
- package/dist/modules/dom/attributes.js +2 -2
- package/dist/modules/dom/constants.js +2 -2
- package/dist/modules/dom/customcontrol.js +1 -1
- package/dist/modules/dom/customelement.js +1 -1
- package/dist/modules/dom/events.js +1 -1
- package/dist/modules/dom/focusmanager.js +2 -0
- package/dist/modules/dom/locale.js +1 -1
- package/dist/modules/dom/namespace.js +1 -1
- package/dist/modules/dom/resource/data.js +2 -0
- package/dist/modules/dom/resource/link/stylesheet.js +2 -0
- package/dist/modules/dom/resource/link.js +2 -0
- package/dist/modules/dom/resource/script.js +2 -0
- package/dist/modules/dom/resource.js +2 -0
- package/dist/modules/dom/resourcemanager.js +2 -0
- package/dist/modules/dom/template.js +2 -2
- package/dist/modules/dom/theme.js +1 -1
- package/dist/modules/dom/updater.js +2 -2
- package/dist/modules/dom/util.js +1 -1
- package/dist/modules/dom/worker/factory.js +2 -0
- package/dist/modules/i18n/formatter.js +2 -0
- package/dist/modules/i18n/locale.js +1 -1
- package/dist/modules/i18n/namespace.js +1 -1
- package/dist/modules/i18n/provider.js +1 -1
- package/dist/modules/i18n/providers/fetch.js +1 -1
- package/dist/modules/i18n/providers/namespace.js +1 -1
- package/dist/modules/i18n/translations.js +1 -1
- package/dist/modules/logging/handler/console.js +1 -1
- package/dist/modules/logging/handler/namespace.js +1 -1
- package/dist/modules/logging/handler.js +1 -1
- package/dist/modules/logging/logentry.js +1 -1
- package/dist/modules/logging/logger.js +1 -1
- package/dist/modules/logging/namespace.js +1 -1
- package/dist/modules/math/namespace.js +1 -1
- package/dist/modules/math/random.js +2 -2
- package/dist/modules/monster.js +1 -1
- package/dist/modules/namespace.js +1 -1
- package/dist/modules/text/formatter.js +2 -2
- package/dist/modules/text/namespace.js +1 -1
- package/dist/modules/types/base.js +1 -1
- package/dist/modules/types/basewithoptions.js +1 -1
- package/dist/modules/types/binary.js +1 -1
- package/dist/modules/types/dataurl.js +1 -1
- package/dist/modules/types/global.js +1 -1
- package/dist/modules/types/id.js +1 -1
- package/dist/modules/types/is.js +2 -2
- package/dist/modules/types/mediatype.js +1 -1
- package/dist/modules/types/namespace.js +1 -1
- package/dist/modules/types/node.js +2 -0
- package/dist/modules/types/nodelist.js +2 -0
- package/dist/modules/types/noderecursiveiterator.js +2 -0
- package/dist/modules/types/observer.js +1 -1
- package/dist/modules/types/observerlist.js +1 -1
- package/dist/modules/types/proxyobserver.js +1 -1
- package/dist/modules/types/queue.js +1 -1
- package/dist/modules/types/randomid.js +1 -1
- package/dist/modules/types/regex.js +2 -0
- package/dist/modules/types/stack.js +1 -1
- package/dist/modules/types/tokenlist.js +1 -1
- package/dist/modules/types/typeof.js +1 -1
- package/dist/modules/types/uniquequeue.js +1 -1
- package/dist/modules/types/uuid.js +2 -0
- package/dist/modules/types/validate.js +1 -1
- package/dist/modules/types/version.js +2 -2
- package/dist/modules/util/clone.js +1 -1
- package/dist/modules/util/comparator.js +1 -1
- package/dist/modules/util/freeze.js +1 -1
- package/dist/modules/util/namespace.js +1 -1
- package/dist/modules/util/processing.js +1 -1
- package/dist/modules/util/trimspaces.js +1 -1
- package/dist/monster.dev.js +1528 -770
- package/dist/monster.dev.js.map +1 -1
- package/dist/monster.js +2 -2
- package/package.json +13 -2
- package/source/constants.js +11 -2
- package/source/constraints/abstract.js +5 -0
- package/source/constraints/abstractoperator.js +5 -0
- package/source/constraints/andoperator.js +10 -5
- package/source/constraints/invalid.js +8 -3
- package/source/constraints/isarray.js +9 -4
- package/source/constraints/isobject.js +8 -3
- package/source/constraints/oroperator.js +10 -5
- package/source/constraints/valid.js +8 -3
- package/source/data/buildmap.js +25 -9
- package/source/data/buildtree.js +95 -0
- package/source/data/datasource/restapi.js +3 -3
- package/source/data/datasource/storage/localstorage.js +2 -2
- package/source/data/datasource/storage/sessionstorage.js +2 -2
- package/source/data/datasource/storage.js +3 -3
- package/source/data/datasource.js +3 -3
- package/source/data/diff.js +3 -3
- package/source/data/extend.js +2 -2
- package/source/data/pathfinder.js +4 -4
- package/source/data/pipe.js +3 -3
- package/source/data/transformer.js +7 -5
- package/source/dom/assembler.js +2 -2
- package/source/dom/attributes.js +111 -28
- package/source/dom/constants.js +287 -10
- package/source/dom/customcontrol.js +1 -1
- package/source/dom/customelement.js +1 -1
- package/source/dom/events.js +6 -7
- package/source/dom/focusmanager.js +250 -0
- package/source/dom/locale.js +10 -5
- package/source/dom/resource/data.js +170 -0
- package/source/dom/resource/link/stylesheet.js +54 -0
- package/source/dom/resource/link.js +125 -0
- package/source/dom/resource/script.js +112 -0
- package/source/dom/resource.js +268 -0
- package/source/dom/resourcemanager.js +214 -0
- package/source/dom/template.js +86 -16
- package/source/dom/theme.js +3 -3
- package/source/dom/updater.js +138 -90
- package/source/dom/util.js +6 -6
- package/source/dom/worker/factory.js +134 -0
- package/source/i18n/formatter.js +140 -0
- package/source/i18n/locale.js +6 -4
- package/source/i18n/provider.js +2 -2
- package/source/i18n/providers/fetch.js +18 -3
- package/source/i18n/translations.js +18 -9
- package/source/logging/handler/console.js +2 -2
- package/source/logging/handler.js +2 -2
- package/source/logging/logentry.js +2 -2
- package/source/logging/logger.js +2 -2
- package/source/math/random.js +9 -5
- package/source/namespace.js +1 -1
- package/source/text/formatter.js +190 -48
- package/source/types/base.js +4 -4
- package/source/types/basewithoptions.js +2 -2
- package/source/types/binary.js +4 -4
- package/source/types/dataurl.js +4 -4
- package/source/types/global.js +4 -4
- package/source/types/id.js +6 -3
- package/source/types/is.js +103 -85
- package/source/types/mediatype.js +4 -4
- package/source/types/node.js +179 -0
- package/source/types/nodelist.js +125 -0
- package/source/types/noderecursiveiterator.js +126 -0
- package/source/types/observer.js +3 -3
- package/source/types/observerlist.js +2 -2
- package/source/types/proxyobserver.js +5 -5
- package/source/types/queue.js +4 -4
- package/source/types/randomid.js +2 -2
- package/source/types/regex.js +49 -0
- package/source/types/stack.js +2 -2
- package/source/types/tokenlist.js +2 -2
- package/source/types/typeof.js +3 -3
- package/source/types/uniquequeue.js +2 -2
- package/source/types/uuid.js +102 -0
- package/source/types/validate.js +20 -20
- package/source/types/version.js +6 -6
- package/source/util/clone.js +2 -2
- package/source/util/comparator.js +4 -4
- package/source/util/freeze.js +5 -5
- package/source/util/processing.js +3 -3
- package/source/util/trimspaces.js +3 -3
- package/test/cases/data/buildtree.js +149 -0
- package/test/cases/data/datasource/restapi.js +1 -1
- package/test/cases/data/transformer.js +2 -0
- package/test/cases/dom/attributes.js +46 -19
- package/test/cases/dom/customelement.js +0 -3
- package/test/cases/dom/focusmanager.js +111 -0
- package/test/cases/dom/locale.js +1 -4
- package/test/cases/dom/resource/data.js +129 -0
- package/test/cases/dom/resource/link/stylesheet.js +101 -0
- package/test/cases/dom/resource/link.js +101 -0
- package/test/cases/dom/resource/script.js +115 -0
- package/test/cases/dom/resourcemanager.js +118 -0
- package/test/cases/dom/template.js +72 -14
- package/test/cases/dom/updater.js +102 -75
- package/test/cases/dom/worker/factory.js +63 -0
- package/test/cases/i18n/formatter.js +66 -0
- package/test/cases/monster.js +1 -1
- package/test/cases/text/formatter.js +36 -5
- package/test/cases/types/node.js +196 -0
- package/test/cases/types/nodelist.js +64 -0
- package/test/cases/types/noderecursiveiterator.js +54 -0
- package/test/cases/types/regex.js +32 -0
- package/test/cases/types/uuid.js +42 -0
- package/test/cases/util/freeze.js +30 -4
- package/test/util/cleanupdom.js +48 -0
- package/test/util/jsdom.js +22 -9
- package/test/web/import.js +14 -0
- package/test/web/monster-dev.html +3 -3
- package/test/web/monster.html +2 -2
- package/test/web/test.html +3 -3
- package/test/web/tests.js +7 -7
package/source/dom/constants.js
CHANGED
@@ -5,29 +5,29 @@ import {Monster} from '../namespace.js';
|
|
5
5
|
* @author schukai GmbH
|
6
6
|
*/
|
7
7
|
|
8
|
+
|
8
9
|
/**
|
10
|
+
* default theme
|
9
11
|
* @memberOf Monster.DOM
|
10
|
-
* @since 1.8.0
|
11
12
|
* @type {string}
|
12
13
|
*/
|
13
|
-
const
|
14
|
+
const DEFAULT_THEME = 'monster';
|
14
15
|
|
15
16
|
/**
|
16
|
-
* This is the name of the attribute to pass options to a control
|
17
|
-
*
|
18
17
|
* @memberOf Monster.DOM
|
19
18
|
* @since 1.8.0
|
20
19
|
* @type {string}
|
21
20
|
*/
|
22
|
-
const
|
23
|
-
|
21
|
+
const ATTRIBUTE_PREFIX = 'data-monster-';
|
24
22
|
|
25
23
|
/**
|
26
|
-
*
|
24
|
+
* This is the name of the attribute to pass options to a control
|
25
|
+
*
|
27
26
|
* @memberOf Monster.DOM
|
27
|
+
* @since 1.8.0
|
28
28
|
* @type {string}
|
29
29
|
*/
|
30
|
-
const
|
30
|
+
const ATTRIBUTE_OPTIONS = ATTRIBUTE_PREFIX + 'options';
|
31
31
|
|
32
32
|
/**
|
33
33
|
* @memberOf Monster.DOM
|
@@ -84,6 +84,13 @@ const ATTRIBUTE_UPDATER_REMOVE = ATTRIBUTE_PREFIX + 'remove';
|
|
84
84
|
*/
|
85
85
|
const ATTRIBUTE_UPDATER_BIND = ATTRIBUTE_PREFIX + 'bind';
|
86
86
|
|
87
|
+
/**
|
88
|
+
* @memberOf Monster.DOM
|
89
|
+
* @type {string}
|
90
|
+
* @since 1.27.0
|
91
|
+
*/
|
92
|
+
const ATTRIBUTE_TEMPLATE_PREFIX = ATTRIBUTE_PREFIX + 'template-prefix';
|
93
|
+
|
87
94
|
/**
|
88
95
|
* @memberOf Monster.DOM
|
89
96
|
* @type {string}
|
@@ -126,9 +133,278 @@ const ATTRIBUTE_ERRORMESSAGE = ATTRIBUTE_PREFIX + 'error';
|
|
126
133
|
*/
|
127
134
|
const objectUpdaterLinkSymbol = Symbol('monsterUpdater');
|
128
135
|
|
136
|
+
/**
|
137
|
+
* @memberOf Monster.DOM
|
138
|
+
* @type {string}
|
139
|
+
* @since 1.25.0
|
140
|
+
*/
|
141
|
+
const TAG_SCRIPT = 'script';
|
142
|
+
|
143
|
+
/**
|
144
|
+
* @memberOf Monster.DOM
|
145
|
+
* @type {string}
|
146
|
+
* @since 1.25.0
|
147
|
+
*/
|
148
|
+
const TAG_STYLE = 'style';
|
149
|
+
|
150
|
+
/**
|
151
|
+
* @memberOf Monster.DOM
|
152
|
+
* @type {string}
|
153
|
+
* @since 1.25.0
|
154
|
+
*/
|
155
|
+
const TAG_LINK = 'link';
|
156
|
+
|
157
|
+
/**
|
158
|
+
* @memberOf Monster.DOM
|
159
|
+
* @type {string}
|
160
|
+
* @since 1.25.0
|
161
|
+
*/
|
162
|
+
|
163
|
+
const ATTRIBUTE_ID = 'id';
|
164
|
+
|
165
|
+
/**
|
166
|
+
* @memberOf Monster.DOM
|
167
|
+
* @type {string}
|
168
|
+
* @since 1.25.0
|
169
|
+
*/
|
170
|
+
|
171
|
+
const ATTRIBUTE_CLASS = 'class';
|
172
|
+
|
173
|
+
/**
|
174
|
+
* @memberOf Monster.DOM
|
175
|
+
* @type {string}
|
176
|
+
* @since 1.25.0
|
177
|
+
*/
|
178
|
+
const ATTRIBUTE_TITLE = 'title';
|
179
|
+
|
180
|
+
/**
|
181
|
+
* @memberOf Monster.DOM
|
182
|
+
* @type {string}
|
183
|
+
* @since 1.25.0
|
184
|
+
*/
|
185
|
+
const ATTRIBUTE_SRC = 'src';
|
186
|
+
/**
|
187
|
+
* @memberOf Monster.DOM
|
188
|
+
* @type {string}
|
189
|
+
* @since 1.25.0
|
190
|
+
*/
|
191
|
+
const ATTRIBUTE_HREF = 'href';
|
192
|
+
|
193
|
+
/**
|
194
|
+
* @memberOf Monster.DOM
|
195
|
+
* @type {string}
|
196
|
+
* @since 1.25.0
|
197
|
+
*/
|
198
|
+
const ATTRIBUTE_TYPE = 'type';
|
199
|
+
|
200
|
+
/**
|
201
|
+
* @memberOf Monster.DOM
|
202
|
+
* @type {string}
|
203
|
+
* @since 1.25.0
|
204
|
+
*/
|
205
|
+
const ATTRIBUTE_NONCE = 'nonce';
|
206
|
+
|
207
|
+
/**
|
208
|
+
* @memberOf Monster.DOM
|
209
|
+
* @type {string}
|
210
|
+
* @since 1.25.0
|
211
|
+
*/
|
212
|
+
const ATTRIBUTE_TRANSLATE = 'translate';
|
213
|
+
|
214
|
+
|
215
|
+
/**
|
216
|
+
* @memberOf Monster.DOM
|
217
|
+
* @type {string}
|
218
|
+
* @since 1.25.0
|
219
|
+
*/
|
220
|
+
const ATTRIBUTE_TABINDEX = 'tabindex';
|
221
|
+
|
222
|
+
|
223
|
+
/**
|
224
|
+
* @memberOf Monster.DOM
|
225
|
+
* @type {string}
|
226
|
+
* @since 1.25.0
|
227
|
+
*/
|
228
|
+
const ATTRIBUTE_SPELLCHECK = 'spellcheck';
|
229
|
+
|
230
|
+
|
231
|
+
/**
|
232
|
+
* @memberOf Monster.DOM
|
233
|
+
* @type {string}
|
234
|
+
* @since 1.25.0
|
235
|
+
*/
|
236
|
+
const ATTRIBUTE_SLOT = 'slot';
|
237
|
+
|
238
|
+
|
239
|
+
/**
|
240
|
+
* @memberOf Monster.DOM
|
241
|
+
* @type {string}
|
242
|
+
* @since 1.25.0
|
243
|
+
*/
|
244
|
+
const ATTRIBUTE_PART = 'part';
|
245
|
+
|
246
|
+
|
247
|
+
/**
|
248
|
+
* @memberOf Monster.DOM
|
249
|
+
* @type {string}
|
250
|
+
* @since 1.25.0
|
251
|
+
*/
|
252
|
+
const ATTRIBUTE_LANG = 'lang';
|
253
|
+
|
254
|
+
|
255
|
+
/**
|
256
|
+
* @memberOf Monster.DOM
|
257
|
+
* @type {string}
|
258
|
+
* @since 1.25.0
|
259
|
+
*/
|
260
|
+
const ATTRIBUTE_ITEMTYPE = 'itemtype';
|
261
|
+
|
262
|
+
|
263
|
+
/**
|
264
|
+
* @memberOf Monster.DOM
|
265
|
+
* @type {string}
|
266
|
+
* @since 1.25.0
|
267
|
+
*/
|
268
|
+
const ATTRIBUTE_ITEMSCOPE = 'itemscope';
|
269
|
+
|
270
|
+
|
271
|
+
/**
|
272
|
+
* @memberOf Monster.DOM
|
273
|
+
* @type {string}
|
274
|
+
* @since 1.25.0
|
275
|
+
*/
|
276
|
+
const ATTRIBUTE_ITEMREF = 'itemref';
|
277
|
+
|
278
|
+
|
279
|
+
/**
|
280
|
+
* @memberOf Monster.DOM
|
281
|
+
* @type {string}
|
282
|
+
* @since 1.25.0
|
283
|
+
*/
|
284
|
+
const ATTRIBUTE_ITEMID = 'itemid';
|
285
|
+
|
286
|
+
|
287
|
+
/**
|
288
|
+
* @memberOf Monster.DOM
|
289
|
+
* @type {string}
|
290
|
+
* @since 1.25.0
|
291
|
+
*/
|
292
|
+
const ATTRIBUTE_ITEMPROP = 'itemprop';
|
293
|
+
|
294
|
+
|
295
|
+
/**
|
296
|
+
* @memberOf Monster.DOM
|
297
|
+
* @type {string}
|
298
|
+
* @since 1.25.0
|
299
|
+
*/
|
300
|
+
const ATTRIBUTE_IS = 'is';
|
301
|
+
|
302
|
+
|
303
|
+
/**
|
304
|
+
* @memberOf Monster.DOM
|
305
|
+
* @type {string}
|
306
|
+
* @since 1.25.0
|
307
|
+
*/
|
308
|
+
const ATTRIBUTE_INPUTMODE = 'inputmode';
|
309
|
+
|
310
|
+
|
311
|
+
/**
|
312
|
+
* @memberOf Monster.DOM
|
313
|
+
* @type {string}
|
314
|
+
* @since 1.25.0
|
315
|
+
*/
|
316
|
+
const ATTRIBUTE_ACCESSKEY = 'accesskey';
|
317
|
+
|
318
|
+
/**
|
319
|
+
* @memberOf Monster.DOM
|
320
|
+
* @type {string}
|
321
|
+
* @since 1.25.0
|
322
|
+
*/
|
323
|
+
const ATTRIBUTE_AUTOCAPITALIZE = 'autocapitalize';
|
324
|
+
|
325
|
+
/**
|
326
|
+
* @memberOf Monster.DOM
|
327
|
+
* @type {string}
|
328
|
+
* @since 1.25.0
|
329
|
+
*/
|
330
|
+
const ATTRIBUTE_AUTOFOCUS = 'autofocus';
|
331
|
+
|
332
|
+
/**
|
333
|
+
* @memberOf Monster.DOM
|
334
|
+
* @type {string}
|
335
|
+
* @since 1.25.0
|
336
|
+
*/
|
337
|
+
const ATTRIBUTE_CONTENTEDITABLE = 'contenteditable';
|
338
|
+
|
339
|
+
/**
|
340
|
+
* @memberOf Monster.DOM
|
341
|
+
* @type {string}
|
342
|
+
* @since 1.25.0
|
343
|
+
*/
|
344
|
+
const ATTRIBUTE_DIR = 'dir';
|
345
|
+
|
346
|
+
/**
|
347
|
+
* @memberOf Monster.DOM
|
348
|
+
* @type {string}
|
349
|
+
* @since 1.25.0
|
350
|
+
*/
|
351
|
+
const ATTRIBUTE_DRAGGABLE = 'draggable';
|
352
|
+
|
353
|
+
|
354
|
+
/**
|
355
|
+
* @memberOf Monster.DOM
|
356
|
+
* @type {string}
|
357
|
+
* @since 1.25.0
|
358
|
+
*/
|
359
|
+
const ATTRIBUTE_ENTERKEYHINT = 'enterkeyhint';
|
360
|
+
/**
|
361
|
+
* @memberOf Monster.DOM
|
362
|
+
* @type {string}
|
363
|
+
* @since 1.25.0
|
364
|
+
*/
|
365
|
+
const ATTRIBUTE_EXPORTPARTS = 'exportparts';
|
366
|
+
/**
|
367
|
+
* @memberOf Monster.DOM
|
368
|
+
* @type {string}
|
369
|
+
* @since 1.25.0
|
370
|
+
*/
|
371
|
+
const ATTRIBUTE_HIDDEN = 'hidden';
|
372
|
+
|
129
373
|
|
130
374
|
export {
|
131
375
|
Monster,
|
376
|
+
ATTRIBUTE_HIDDEN,
|
377
|
+
ATTRIBUTE_EXPORTPARTS,
|
378
|
+
ATTRIBUTE_ENTERKEYHINT,
|
379
|
+
ATTRIBUTE_DRAGGABLE,
|
380
|
+
ATTRIBUTE_DIR,
|
381
|
+
ATTRIBUTE_CONTENTEDITABLE,
|
382
|
+
ATTRIBUTE_AUTOFOCUS,
|
383
|
+
ATTRIBUTE_AUTOCAPITALIZE,
|
384
|
+
ATTRIBUTE_ACCESSKEY,
|
385
|
+
TAG_SCRIPT,
|
386
|
+
TAG_LINK,
|
387
|
+
ATTRIBUTE_INPUTMODE,
|
388
|
+
ATTRIBUTE_IS,
|
389
|
+
ATTRIBUTE_ITEMPROP,
|
390
|
+
ATTRIBUTE_ITEMID,
|
391
|
+
ATTRIBUTE_ITEMREF,
|
392
|
+
ATTRIBUTE_ITEMSCOPE,
|
393
|
+
TAG_STYLE,
|
394
|
+
ATTRIBUTE_ITEMTYPE,
|
395
|
+
ATTRIBUTE_HREF,
|
396
|
+
ATTRIBUTE_LANG,
|
397
|
+
ATTRIBUTE_PART,
|
398
|
+
ATTRIBUTE_SLOT,
|
399
|
+
ATTRIBUTE_SPELLCHECK,
|
400
|
+
ATTRIBUTE_SRC,
|
401
|
+
ATTRIBUTE_TABINDEX,
|
402
|
+
ATTRIBUTE_TRANSLATE,
|
403
|
+
ATTRIBUTE_NONCE,
|
404
|
+
ATTRIBUTE_TYPE,
|
405
|
+
ATTRIBUTE_TITLE,
|
406
|
+
ATTRIBUTE_CLASS,
|
407
|
+
ATTRIBUTE_ID,
|
132
408
|
ATTRIBUTE_PREFIX,
|
133
409
|
ATTRIBUTE_OPTIONS,
|
134
410
|
DEFAULT_THEME,
|
@@ -145,5 +421,6 @@ export {
|
|
145
421
|
ATTRIBUTE_DISABLED,
|
146
422
|
ATTRIBUTE_ERRORMESSAGE,
|
147
423
|
ATTRIBUTE_VALUE,
|
148
|
-
objectUpdaterLinkSymbol
|
149
|
-
|
424
|
+
objectUpdaterLinkSymbol,
|
425
|
+
ATTRIBUTE_TEMPLATE_PREFIX
|
426
|
+
}
|
@@ -30,7 +30,7 @@ const attachedInternalSymbol = Symbol('attachedInternal');
|
|
30
30
|
*
|
31
31
|
* ```
|
32
32
|
* <script type="module">
|
33
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
33
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
|
34
34
|
* document.createElement('monster-')
|
35
35
|
* </script>
|
36
36
|
* ```
|
@@ -96,7 +96,7 @@ const attributeObserverSymbol = Symbol('attributeObserver');
|
|
96
96
|
*
|
97
97
|
* ```
|
98
98
|
* <script type="module">
|
99
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
99
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
|
100
100
|
* document.createElement('monster-')
|
101
101
|
* </script>
|
102
102
|
* ```
|
package/source/dom/events.js
CHANGED
@@ -13,7 +13,7 @@ import {getDocument} from "./util.js";
|
|
13
13
|
*
|
14
14
|
* ```
|
15
15
|
* <script type="module">
|
16
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
16
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
|
17
17
|
* console.log(new Monster.DOM.fireEvent())
|
18
18
|
* </script>
|
19
19
|
* ```
|
@@ -22,7 +22,7 @@ import {getDocument} from "./util.js";
|
|
22
22
|
*
|
23
23
|
* ```
|
24
24
|
* <script type="module">
|
25
|
-
* import {fireEvent} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
25
|
+
* import {fireEvent} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/modules/dom/events.js';
|
26
26
|
* console.log(fireEvent())
|
27
27
|
* </script>
|
28
28
|
* ```
|
@@ -73,8 +73,8 @@ function fireEvent(element, type) {
|
|
73
73
|
*
|
74
74
|
* ```
|
75
75
|
* <script type="module">
|
76
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
77
|
-
*
|
76
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
|
77
|
+
* new Monster.DOM.findTargetElementFromEvent()
|
78
78
|
* </script>
|
79
79
|
* ```
|
80
80
|
*
|
@@ -82,8 +82,8 @@ function fireEvent(element, type) {
|
|
82
82
|
*
|
83
83
|
* ```
|
84
84
|
* <script type="module">
|
85
|
-
* import {findTargetElementFromEvent} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
86
|
-
*
|
85
|
+
* import {findTargetElementFromEvent} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/modules/dom/events.js';
|
86
|
+
* findTargetElementFromEvent()
|
87
87
|
* </script>
|
88
88
|
* ```
|
89
89
|
*
|
@@ -105,7 +105,6 @@ function findTargetElementFromEvent(event, attributeName, attributeValue) {
|
|
105
105
|
}
|
106
106
|
|
107
107
|
const path = event.composedPath();
|
108
|
-
const element = path?.[0];
|
109
108
|
|
110
109
|
// closest cannot be used here, because closest is not correct for slotted elements
|
111
110
|
if (isArray(path)) {
|
@@ -0,0 +1,250 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
|
4
|
+
/**
|
5
|
+
* @author schukai GmbH
|
6
|
+
*/
|
7
|
+
|
8
|
+
|
9
|
+
import {extend} from "../data/extend.js";
|
10
|
+
import {assignToNamespace} from "../namespace.js";
|
11
|
+
import {BaseWithOptions} from "../types/basewithoptions.js";
|
12
|
+
import {getGlobalObject} from "../types/global.js";
|
13
|
+
import {isArray} from "../types/is.js";
|
14
|
+
import {Stack} from "../types/stack.js";
|
15
|
+
import {validateInstance, validateString} from "../types/validate.js";
|
16
|
+
|
17
|
+
/**
|
18
|
+
* @private
|
19
|
+
* @type {string}
|
20
|
+
*/
|
21
|
+
const KEY_DOCUMENT = 'document';
|
22
|
+
|
23
|
+
/**
|
24
|
+
* @private
|
25
|
+
* @type {string}
|
26
|
+
*/
|
27
|
+
const KEY_CONTEXT = 'context';
|
28
|
+
|
29
|
+
|
30
|
+
/**
|
31
|
+
* @private
|
32
|
+
* @type {Symbol}
|
33
|
+
*/
|
34
|
+
const stackSymbol = Symbol('stack');
|
35
|
+
|
36
|
+
|
37
|
+
/**
|
38
|
+
* With the focusmanager the focus can be stored in a document, recalled and moved.
|
39
|
+
*
|
40
|
+
* You can create the object via the monster namespace `new Monster.DOM.FocusManager()`.
|
41
|
+
*
|
42
|
+
* ```
|
43
|
+
* <script type="module">
|
44
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
|
45
|
+
* new Monster.DOM.FocusManager()
|
46
|
+
* </script>
|
47
|
+
* ```
|
48
|
+
*
|
49
|
+
* Alternatively, you can also integrate this object individually.
|
50
|
+
*
|
51
|
+
* ```
|
52
|
+
* <script type="module">
|
53
|
+
* import {FocusManager} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/modules/dom/focusmanager.js';
|
54
|
+
* new FocusManager()
|
55
|
+
* </script>
|
56
|
+
* ```
|
57
|
+
*
|
58
|
+
* @since 1.25.0
|
59
|
+
* @copyright schukai GmbH
|
60
|
+
* @memberOf Monster.DOM
|
61
|
+
* @throws {Error} unsupported locale
|
62
|
+
* @summary Handle the focus
|
63
|
+
*/
|
64
|
+
class FocusManager extends BaseWithOptions {
|
65
|
+
|
66
|
+
/**
|
67
|
+
*
|
68
|
+
* @param {Object|undefined} options
|
69
|
+
*/
|
70
|
+
constructor(options) {
|
71
|
+
super(options);
|
72
|
+
validateInstance(this.getOption(KEY_DOCUMENT), HTMLDocument);
|
73
|
+
|
74
|
+
this[stackSymbol] = new Stack();
|
75
|
+
}
|
76
|
+
|
77
|
+
/**
|
78
|
+
* @property {HTMLDocument} document the document object into which the node is to be appended
|
79
|
+
*/
|
80
|
+
get defaults() {
|
81
|
+
return extend({}, super.defaults, {
|
82
|
+
[KEY_DOCUMENT]: getGlobalObject('document'),
|
83
|
+
[KEY_CONTEXT]: undefined,
|
84
|
+
})
|
85
|
+
}
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Remembers the current focus on a stack.
|
89
|
+
* Several focus can be stored.
|
90
|
+
*
|
91
|
+
* @return {Monster.DOM.FocusManager}
|
92
|
+
*/
|
93
|
+
storeFocus() {
|
94
|
+
|
95
|
+
const active = this.getActive();
|
96
|
+
if (active instanceof Node) {
|
97
|
+
this[stackSymbol].push(active)
|
98
|
+
}
|
99
|
+
return this;
|
100
|
+
}
|
101
|
+
|
102
|
+
/**
|
103
|
+
* The last focus on the stack is set again
|
104
|
+
*
|
105
|
+
* @return {Monster.DOM.FocusManager}
|
106
|
+
*/
|
107
|
+
restoreFocus() {
|
108
|
+
|
109
|
+
const last = this[stackSymbol].pop();
|
110
|
+
if (last instanceof Node) {
|
111
|
+
this.focus(last);
|
112
|
+
}
|
113
|
+
|
114
|
+
return this;
|
115
|
+
}
|
116
|
+
|
117
|
+
/**
|
118
|
+
*
|
119
|
+
* @param {Node} element
|
120
|
+
* @param {boolean} preventScroll
|
121
|
+
* @throws {TypeError} value is not an instance of
|
122
|
+
* @return {Monster.DOM.FocusManager}
|
123
|
+
*/
|
124
|
+
focus(element, preventScroll) {
|
125
|
+
|
126
|
+
validateInstance(element, Node)
|
127
|
+
|
128
|
+
element.focus({
|
129
|
+
preventScroll: preventScroll ?? false
|
130
|
+
})
|
131
|
+
|
132
|
+
return this;
|
133
|
+
}
|
134
|
+
|
135
|
+
/**
|
136
|
+
*
|
137
|
+
* @return {Element}
|
138
|
+
*/
|
139
|
+
getActive() {
|
140
|
+
return this.getOption(KEY_DOCUMENT).activeElement;
|
141
|
+
}
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Select all elements that can be focused
|
145
|
+
*
|
146
|
+
* @param {string|undefined} query
|
147
|
+
* @return {array}
|
148
|
+
* @throws {TypeError} value is not an instance of
|
149
|
+
*/
|
150
|
+
getFocusable(query) {
|
151
|
+
|
152
|
+
let contextElement = this.getOption(KEY_CONTEXT);
|
153
|
+
if (contextElement === undefined) {
|
154
|
+
contextElement = this.getOption(KEY_DOCUMENT);
|
155
|
+
}
|
156
|
+
|
157
|
+
validateInstance(contextElement, Node)
|
158
|
+
|
159
|
+
if (query !== undefined) {
|
160
|
+
validateString(query);
|
161
|
+
}
|
162
|
+
|
163
|
+
return [...contextElement.querySelectorAll(
|
164
|
+
'details, button, input, [tabindex]:not([tabindex="-1"]), select, textarea, a[href], body'
|
165
|
+
)].filter((element) => {
|
166
|
+
|
167
|
+
if (query !== undefined && !element.matches(query)) {
|
168
|
+
return false;
|
169
|
+
}
|
170
|
+
|
171
|
+
if (element.hasAttribute('disabled')) return false;
|
172
|
+
if (element.getAttribute("aria-hidden") === 'true') return false;
|
173
|
+
|
174
|
+
const rect = element.getBoundingClientRect();
|
175
|
+
if(rect.width===0) return false;
|
176
|
+
if(rect.height===0) return false;
|
177
|
+
|
178
|
+
return true;
|
179
|
+
});
|
180
|
+
}
|
181
|
+
|
182
|
+
/**
|
183
|
+
* @param {string} query
|
184
|
+
* @return {Monster.DOM.FocusManager}
|
185
|
+
*/
|
186
|
+
focusNext(query) {
|
187
|
+
|
188
|
+
const current = this.getActive();
|
189
|
+
const focusable = this.getFocusable(query);
|
190
|
+
|
191
|
+
if (!isArray(focusable) || focusable.length === 0) {
|
192
|
+
return this;
|
193
|
+
}
|
194
|
+
|
195
|
+
if (current instanceof Node) {
|
196
|
+
let index = focusable.indexOf(current);
|
197
|
+
|
198
|
+
if (index > -1) {
|
199
|
+
this.focus(focusable[index + 1] || focusable[0]);
|
200
|
+
} else {
|
201
|
+
this.focus(focusable[0]);
|
202
|
+
}
|
203
|
+
} else {
|
204
|
+
this.focus(focusable[0])
|
205
|
+
}
|
206
|
+
|
207
|
+
return this;
|
208
|
+
}
|
209
|
+
|
210
|
+
/**
|
211
|
+
* @param {string} query
|
212
|
+
* @return {Monster.DOM.FocusManager}
|
213
|
+
*/
|
214
|
+
focusPrev(query) {
|
215
|
+
|
216
|
+
const current = this.getActive();
|
217
|
+
const focusable = this.getFocusable(query);
|
218
|
+
|
219
|
+
if (!isArray(focusable) || focusable.length === 0) {
|
220
|
+
return this;
|
221
|
+
}
|
222
|
+
|
223
|
+
if (current instanceof Node) {
|
224
|
+
let index = focusable.indexOf(current);
|
225
|
+
|
226
|
+
if (index > -1) {
|
227
|
+
this.focus(focusable[index - 1] || focusable[focusable.length - 1]);
|
228
|
+
} else {
|
229
|
+
this.focus(focusable[focusable.length - 1]);
|
230
|
+
}
|
231
|
+
} else {
|
232
|
+
this.focus(focusable[focusable.length - 1])
|
233
|
+
}
|
234
|
+
|
235
|
+
return this;
|
236
|
+
}
|
237
|
+
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
|
242
|
+
assignToNamespace('Monster.DOM', FocusManager);
|
243
|
+
export {FocusManager}
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
package/source/dom/locale.js
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
import {parseLocale} from "../i18n/locale.js";
|
4
3
|
/**
|
5
4
|
* @author schukai GmbH
|
6
5
|
*/
|
6
|
+
|
7
|
+
import {parseLocale} from "../i18n/locale.js";
|
7
8
|
import {assignToNamespace, Monster} from '../namespace.js';
|
8
9
|
import {getDocument} from "./util.js";
|
9
10
|
|
@@ -16,13 +17,17 @@ const DEFAULT_LANGUAGE = 'en';
|
|
16
17
|
/**
|
17
18
|
* With this function you can read the language version set by the document.
|
18
19
|
* For this the attribute `lang` in the html tag is read. If no attribute is set, `en` is used as default.
|
20
|
+
*
|
21
|
+
* ```html
|
22
|
+
* <html lang="en">
|
23
|
+
* ```
|
19
24
|
*
|
20
25
|
* You can call the function via the monster namespace `new Monster.DOM.getLocaleOfDocument()`.
|
21
26
|
*
|
22
27
|
* ```
|
23
28
|
* <script type="module">
|
24
|
-
* import {
|
25
|
-
*
|
29
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
|
30
|
+
* new Monster.DOM.getLocaleOfDocument()
|
26
31
|
* </script>
|
27
32
|
* ```
|
28
33
|
*
|
@@ -30,8 +35,8 @@ const DEFAULT_LANGUAGE = 'en';
|
|
30
35
|
*
|
31
36
|
* ```
|
32
37
|
* <script type="module">
|
33
|
-
* import {getLocaleOfDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
34
|
-
*
|
38
|
+
* import {getLocaleOfDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/modules/dom/locale.js';
|
39
|
+
* new getLocaleOfDocument()
|
35
40
|
* </script>
|
36
41
|
* ```
|
37
42
|
*
|