@schukai/monster 3.112.2 → 3.112.4

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