@schukai/monster 3.112.4 → 3.114.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/CHANGELOG.md +25 -0
- package/package.json +1 -1
- package/source/components/form/digits.mjs +372 -0
- package/source/components/form/field-set.mjs +2 -1
- package/source/components/form/form.mjs +4 -2
- package/source/components/form/login.mjs +1565 -0
- package/source/components/form/password.mjs +21 -8
- package/source/components/form/style/digits.pcss +38 -0
- package/source/components/form/style/field-set.pcss +12 -1
- package/source/components/form/style/invalid.pcss +25 -0
- package/source/components/form/style/login.pcss +112 -0
- package/source/components/form/style/password.pcss +2 -0
- package/source/components/form/stylesheet/digits.mjs +38 -0
- package/source/components/form/stylesheet/field-set.mjs +1 -1
- package/source/components/form/stylesheet/invalid.mjs +38 -0
- package/source/components/form/stylesheet/login.mjs +38 -0
- package/source/components/form/stylesheet/password.mjs +1 -1
- package/source/components/form/toggle-switch.mjs +5 -2
- package/source/components/layout/slider.mjs +96 -15
- package/source/components/time/day.mjs +318 -302
- package/source/components/time/stylesheet/day.mjs +13 -6
- package/source/dom/customelement.mjs +8 -6
- package/source/monster.mjs +3 -0
- package/source/types/proxyobserver.mjs +2 -4
- package/source/types/version.mjs +1 -1
- package/test/cases/monster.mjs +1 -1
- package/test/web/test.html +2 -2
- package/test/web/tests.js +19 -18
@@ -10,21 +10,20 @@
|
|
10
10
|
* For more information about purchasing a commercial license, please contact schukai GmbH.
|
11
11
|
*/
|
12
12
|
|
13
|
-
import {instanceSymbol} from "../../constants.mjs";
|
13
|
+
import { instanceSymbol } from "../../constants.mjs";
|
14
|
+
import { ATTRIBUTE_ROLE } from "../../dom/constants.mjs";
|
15
|
+
import { CustomElement } from "../../dom/customelement.mjs";
|
14
16
|
import {
|
15
|
-
|
16
|
-
|
17
|
-
import {CustomElement} from "../../dom/customelement.mjs";
|
18
|
-
import {
|
19
|
-
assembleMethodSymbol, registerCustomElement,
|
17
|
+
assembleMethodSymbol,
|
18
|
+
registerCustomElement,
|
20
19
|
} from "../../dom/customelement.mjs";
|
21
|
-
import {DayStyleSheet} from "./stylesheet/day.mjs";
|
22
|
-
import {isString} from "../../types/is.mjs"
|
23
|
-
import {getLocaleOfDocument} from "../../dom/locale.mjs";
|
24
|
-
import {Observer} from "../../types/observer.mjs";
|
25
|
-
import {Processing} from "../../util/processing.mjs";
|
20
|
+
import { DayStyleSheet } from "./stylesheet/day.mjs";
|
21
|
+
import { isString } from "../../types/is.mjs";
|
22
|
+
import { getLocaleOfDocument } from "../../dom/locale.mjs";
|
23
|
+
import { Observer } from "../../types/observer.mjs";
|
24
|
+
import { Processing } from "../../util/processing.mjs";
|
26
25
|
|
27
|
-
export {Day};
|
26
|
+
export { Day };
|
28
27
|
|
29
28
|
/**
|
30
29
|
* @private
|
@@ -66,296 +65,302 @@ const dayLabelElementSymbol = Symbol("dayLabelElement");
|
|
66
65
|
* @summary A day control that displays the day, month, weekday and a label.
|
67
66
|
*/
|
68
67
|
class Day extends CustomElement {
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
68
|
+
/**
|
69
|
+
*
|
70
|
+
*/
|
71
|
+
constructor() {
|
72
|
+
super();
|
73
|
+
initOptionObserver.call(this);
|
74
|
+
}
|
75
|
+
|
76
|
+
/**
|
77
|
+
* This method is called by the `instanceof` operator.
|
78
|
+
* @returns {symbol}
|
79
|
+
*/
|
80
|
+
static get [instanceSymbol]() {
|
81
|
+
return Symbol.for("@schukai/monster/components/time/day@@instance");
|
82
|
+
}
|
83
|
+
|
84
|
+
/**
|
85
|
+
*
|
86
|
+
* @return {Components.Time.Day
|
87
|
+
*/
|
88
|
+
[assembleMethodSymbol]() {
|
89
|
+
super[assembleMethodSymbol]();
|
90
|
+
initControlReferences.call(this);
|
91
|
+
updateDate.call(this);
|
92
|
+
return this;
|
93
|
+
}
|
94
|
+
|
95
|
+
/**
|
96
|
+
* To set the options via the HTML Tag, the attribute `data-monster-options` must be used.
|
97
|
+
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
98
|
+
*
|
99
|
+
* The individual configuration values can be found in the table.
|
100
|
+
*
|
101
|
+
* @property {Object} templates Template definitions
|
102
|
+
* @property {string} templates.main Main template
|
103
|
+
* @property {string} date The date of the day
|
104
|
+
*/
|
105
|
+
get defaults() {
|
106
|
+
return Object.assign({}, super.defaults, {
|
107
|
+
templates: {
|
108
|
+
main: getTemplate(),
|
109
|
+
},
|
110
|
+
|
111
|
+
date: null,
|
112
|
+
|
113
|
+
day: null,
|
114
|
+
month: null,
|
115
|
+
weekday: null,
|
116
|
+
label: null,
|
117
|
+
|
118
|
+
disabled: false,
|
119
|
+
});
|
120
|
+
}
|
121
|
+
|
122
|
+
/**
|
123
|
+
* @return {string}
|
124
|
+
*/
|
125
|
+
static getTag() {
|
126
|
+
return "monster-day";
|
127
|
+
}
|
128
|
+
|
129
|
+
/**
|
130
|
+
* @return {CSSStyleSheet[]}
|
131
|
+
*/
|
132
|
+
static getCSSStyleSheet() {
|
133
|
+
return [DayStyleSheet];
|
134
|
+
}
|
135
|
+
|
136
|
+
/**
|
137
|
+
* @return {string[]}
|
138
|
+
* @since 1.15.0
|
139
|
+
*/
|
140
|
+
static get observedAttributes() {
|
141
|
+
return ["data-monster-option-date"];
|
142
|
+
}
|
144
143
|
}
|
145
144
|
|
146
145
|
/**
|
147
146
|
* @private
|
148
147
|
*/
|
149
148
|
function initOptionObserver() {
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
);
|
149
|
+
const self = this;
|
150
|
+
|
151
|
+
let lastDate = this.getOption("date");
|
152
|
+
|
153
|
+
self.attachObserver(
|
154
|
+
new Observer(function () {
|
155
|
+
new Processing(() => {
|
156
|
+
if (lastDate !== self.getOption("date")) {
|
157
|
+
lastDate = self.getOption("date");
|
158
|
+
updateDate.call(self);
|
159
|
+
}
|
160
|
+
}).run();
|
161
|
+
}),
|
162
|
+
);
|
165
163
|
}
|
166
164
|
|
167
165
|
/**
|
168
166
|
* @private
|
169
167
|
*/
|
170
168
|
function updateDate() {
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
169
|
+
const labels = getLabels.call(this);
|
170
|
+
|
171
|
+
let date = this.getOption("date");
|
172
|
+
|
173
|
+
let day = null;
|
174
|
+
let label = null;
|
175
|
+
|
176
|
+
if (date === null) {
|
177
|
+
date = new Date();
|
178
|
+
} else if (isString(date)) {
|
179
|
+
date = new Date(date);
|
180
|
+
}
|
181
|
+
|
182
|
+
if (!(date instanceof Date)) {
|
183
|
+
return;
|
184
|
+
}
|
185
|
+
|
186
|
+
day = date.getDate();
|
187
|
+
|
188
|
+
const locale = getLocaleOfDocument();
|
189
|
+
|
190
|
+
this.setOption("day", day);
|
191
|
+
this.setOption(
|
192
|
+
"month",
|
193
|
+
new Intl.DateTimeFormat(locale.toString(), {
|
194
|
+
month: "short",
|
195
|
+
}).format(date),
|
196
|
+
);
|
197
|
+
|
198
|
+
this.setOption(
|
199
|
+
"weekday",
|
200
|
+
new Intl.DateTimeFormat(locale.toString(), {
|
201
|
+
weekday: "long",
|
202
|
+
}).format(date),
|
203
|
+
);
|
204
|
+
|
205
|
+
if (date.toDateString() === new Date().toDateString()) {
|
206
|
+
label = labels.today;
|
207
|
+
} else if (
|
208
|
+
date.toDateString() ===
|
209
|
+
new Date(new Date().setDate(new Date().getDate() - 1)).toDateString()
|
210
|
+
) {
|
211
|
+
label = labels.yesterday;
|
212
|
+
} else if (
|
213
|
+
date.toDateString() ===
|
214
|
+
new Date(new Date().setDate(new Date().getDate() + 1)).toDateString()
|
215
|
+
) {
|
216
|
+
label = labels.tomorrow;
|
217
|
+
}
|
218
|
+
|
219
|
+
this.setOption("label", label);
|
215
220
|
}
|
216
221
|
|
217
222
|
function getLabels() {
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
223
|
+
switch (getLocaleOfDocument().language) {
|
224
|
+
case "de": // German
|
225
|
+
return {
|
226
|
+
today: "Heute",
|
227
|
+
tomorrow: "Morgen",
|
228
|
+
yesterday: "Gestern",
|
229
|
+
};
|
230
|
+
|
231
|
+
case "es": // Spanish
|
232
|
+
return {
|
233
|
+
today: "Hoy",
|
234
|
+
tomorrow: "Mañana",
|
235
|
+
yesterday: "Ayer",
|
236
|
+
};
|
237
|
+
|
238
|
+
case "zh": // Mandarin
|
239
|
+
return {
|
240
|
+
today: "今天",
|
241
|
+
tomorrow: "明天",
|
242
|
+
yesterday: "昨天",
|
243
|
+
};
|
244
|
+
|
245
|
+
case "hi": // Hindi
|
246
|
+
return {
|
247
|
+
today: "आज",
|
248
|
+
tomorrow: "कल",
|
249
|
+
yesterday: "बीता कल",
|
250
|
+
};
|
251
|
+
|
252
|
+
case "bn": // Bengali
|
253
|
+
return {
|
254
|
+
today: "আজ",
|
255
|
+
tomorrow: "আগামীকাল",
|
256
|
+
yesterday: "গতকাল",
|
257
|
+
};
|
258
|
+
|
259
|
+
case "pt": // Portuguese
|
260
|
+
return {
|
261
|
+
today: "Hoje",
|
262
|
+
tomorrow: "Amanhã",
|
263
|
+
yesterday: "Ontem",
|
264
|
+
};
|
265
|
+
|
266
|
+
case "ru": // Russian
|
267
|
+
return {
|
268
|
+
today: "Сегодня",
|
269
|
+
tomorrow: "Завтра",
|
270
|
+
yesterday: "Вчера",
|
271
|
+
};
|
272
|
+
|
273
|
+
case "ja": // Japanese
|
274
|
+
return {
|
275
|
+
today: "今日",
|
276
|
+
tomorrow: "明日",
|
277
|
+
yesterday: "昨日",
|
278
|
+
};
|
279
|
+
|
280
|
+
case "pa": // Western Punjabi
|
281
|
+
return {
|
282
|
+
today: "ਅਜ",
|
283
|
+
tomorrow: "ਕਲ",
|
284
|
+
yesterday: "ਬੀਤੇ ਕਲ",
|
285
|
+
};
|
286
|
+
|
287
|
+
case "mr": // Marathi
|
288
|
+
return {
|
289
|
+
today: "आज",
|
290
|
+
tomorrow: "उद्या",
|
291
|
+
yesterday: "काल",
|
292
|
+
};
|
293
|
+
|
294
|
+
case "fr": // French
|
295
|
+
return {
|
296
|
+
today: "Aujourd'hui",
|
297
|
+
tomorrow: "Demain",
|
298
|
+
yesterday: "Hier",
|
299
|
+
};
|
300
|
+
|
301
|
+
case "it": // Italian
|
302
|
+
return {
|
303
|
+
today: "Oggi",
|
304
|
+
tomorrow: "Domani",
|
305
|
+
yesterday: "Ieri",
|
306
|
+
};
|
307
|
+
|
308
|
+
case "nl": // Dutch
|
309
|
+
return {
|
310
|
+
today: "Vandaag",
|
311
|
+
tomorrow: "Morgen",
|
312
|
+
yesterday: "Gisteren",
|
313
|
+
};
|
314
|
+
|
315
|
+
case "sv": // Swedish
|
316
|
+
return {
|
317
|
+
today: "Idag",
|
318
|
+
tomorrow: "Imorgon",
|
319
|
+
yesterday: "Igår",
|
320
|
+
};
|
321
|
+
|
322
|
+
case "pl": // Polish
|
323
|
+
return {
|
324
|
+
today: "Dziś",
|
325
|
+
tomorrow: "Jutro",
|
326
|
+
yesterday: "Wczoraj",
|
327
|
+
};
|
328
|
+
|
329
|
+
case "da": // Danish
|
330
|
+
return {
|
331
|
+
today: "I dag",
|
332
|
+
tomorrow: "I morgen",
|
333
|
+
yesterday: "I går",
|
334
|
+
};
|
335
|
+
|
336
|
+
case "fi": // Finnish
|
337
|
+
return {
|
338
|
+
today: "Tänään",
|
339
|
+
tomorrow: "Huomenna",
|
340
|
+
yesterday: "Eilen",
|
341
|
+
};
|
342
|
+
|
343
|
+
case "no": // Norwegian
|
344
|
+
return {
|
345
|
+
today: "I dag",
|
346
|
+
tomorrow: "I morgen",
|
347
|
+
yesterday: "I går",
|
348
|
+
};
|
349
|
+
|
350
|
+
case "cs": // Czech
|
351
|
+
return {
|
352
|
+
today: "Dnes",
|
353
|
+
tomorrow: "Zítra",
|
354
|
+
yesterday: "Včera",
|
355
|
+
};
|
356
|
+
|
357
|
+
default:
|
358
|
+
return {
|
359
|
+
today: "Today",
|
360
|
+
tomorrow: "Tomorrow",
|
361
|
+
yesterday: "Yesterday",
|
362
|
+
};
|
363
|
+
}
|
359
364
|
}
|
360
365
|
|
361
366
|
/**
|
@@ -364,15 +369,17 @@ function getLabels() {
|
|
364
369
|
* @returns {*[]}
|
365
370
|
*/
|
366
371
|
function getWeekdays(format = "long") {
|
367
|
-
|
372
|
+
const locale = getLocaleOfDocument();
|
368
373
|
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
+
const weekdays = [];
|
375
|
+
for (let i = 1; i < 8; i++) {
|
376
|
+
const date = new Date(1970, 0, 4 + i); // 4. Jan. 1970 = Sonntag
|
377
|
+
weekdays.push(
|
378
|
+
new Intl.DateTimeFormat(locale, { weekday: format }).format(date),
|
379
|
+
);
|
380
|
+
}
|
374
381
|
|
375
|
-
|
382
|
+
return weekdays;
|
376
383
|
}
|
377
384
|
|
378
385
|
/**
|
@@ -380,11 +387,21 @@ function getWeekdays(format = "long") {
|
|
380
387
|
* @return {void}
|
381
388
|
*/
|
382
389
|
function initControlReferences() {
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
390
|
+
this[dayElementSymbol] = this.shadowRoot.querySelector(
|
391
|
+
`[${ATTRIBUTE_ROLE}="control"]`,
|
392
|
+
);
|
393
|
+
this[dayMonthElementSymbol] = this.shadowRoot.querySelector(
|
394
|
+
`[${ATTRIBUTE_ROLE}="month"]`,
|
395
|
+
);
|
396
|
+
this[dayDayElementSymbol] = this.shadowRoot.querySelector(
|
397
|
+
`[${ATTRIBUTE_ROLE}="day"]`,
|
398
|
+
);
|
399
|
+
this[dayWeekdayElementSymbol] = this.shadowRoot.querySelector(
|
400
|
+
`[${ATTRIBUTE_ROLE}="weekday"]`,
|
401
|
+
);
|
402
|
+
this[dayLabelElementSymbol] = this.shadowRoot.querySelector(
|
403
|
+
`[${ATTRIBUTE_ROLE}="label"]`,
|
404
|
+
);
|
388
405
|
}
|
389
406
|
|
390
407
|
/**
|
@@ -392,8 +409,8 @@ function initControlReferences() {
|
|
392
409
|
* @return {string}
|
393
410
|
*/
|
394
411
|
function getTemplate() {
|
395
|
-
|
396
|
-
|
412
|
+
// language=HTML
|
413
|
+
return `
|
397
414
|
<div data-monster-role="control" part="control">
|
398
415
|
<div class="month" data-monster-role="month" part="month" data-monster-replace="path:month"></div>
|
399
416
|
<div data-monster-role="day" part="day" data-monster-replace="path:day">12</div>
|
@@ -403,5 +420,4 @@ function getTemplate() {
|
|
403
420
|
</div>`;
|
404
421
|
}
|
405
422
|
|
406
|
-
|
407
423
|
registerCustomElement(Day);
|