@schukai/monster 4.150.0 → 4.150.2

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 (67) hide show
  1. package/package.json +1 -1
  2. package/source/components/accessibility/locale-picker.mjs +22 -14
  3. package/source/components/accessibility/locale-select.mjs +2 -0
  4. package/source/components/content/stylesheet/camera-capture.mjs +1 -1
  5. package/source/components/content/stylesheet/copy.mjs +1 -1
  6. package/source/components/content/viewer/message.mjs +22 -0
  7. package/source/components/content/viewer/stylesheet/message.mjs +1 -1
  8. package/source/components/content/viewer.mjs +6 -6
  9. package/source/components/datatable/datatable.mjs +139 -7
  10. package/source/components/datatable/filter/date-range.mjs +168 -3
  11. package/source/components/datatable/filter/input.mjs +47 -3
  12. package/source/components/datatable/filter/range.mjs +91 -3
  13. package/source/components/datatable/filter-button.mjs +47 -3
  14. package/source/components/datatable/filter.mjs +11 -0
  15. package/source/components/datatable/save-button.mjs +47 -3
  16. package/source/components/datatable/style/datatable.pcss +8 -0
  17. package/source/components/datatable/stylesheet/datatable.mjs +1 -1
  18. package/source/components/datatable/stylesheet/filter-controls-defaults.mjs +1 -1
  19. package/source/components/files/file-manager.mjs +96 -13
  20. package/source/components/form/buy-box.mjs +87 -87
  21. package/source/components/form/cart-control.mjs +24 -24
  22. package/source/components/form/control-bar.mjs +26 -6
  23. package/source/components/form/credential-button.mjs +13 -0
  24. package/source/components/form/field-set.mjs +80 -3
  25. package/source/components/form/login.mjs +143 -96
  26. package/source/components/form/register-wizard.mjs +298 -298
  27. package/source/components/form/select.mjs +103 -79
  28. package/source/components/form/style/button-bar.pcss +17 -1
  29. package/source/components/form/style/control-bar.pcss +6 -0
  30. package/source/components/form/style/mixin/field-set-layout.pcss +2 -0
  31. package/source/components/form/style/toggle-switch.pcss +4 -0
  32. package/source/components/form/stylesheet/button-bar.mjs +6 -4
  33. package/source/components/form/stylesheet/confirm-button.mjs +1 -1
  34. package/source/components/form/stylesheet/context-error.mjs +1 -1
  35. package/source/components/form/stylesheet/context-help.mjs +1 -1
  36. package/source/components/form/stylesheet/control-bar.mjs +3 -3
  37. package/source/components/form/stylesheet/digits.mjs +1 -1
  38. package/source/components/form/stylesheet/field-set.mjs +2 -2
  39. package/source/components/form/stylesheet/login.mjs +1 -1
  40. package/source/components/form/stylesheet/popper-button.mjs +1 -1
  41. package/source/components/form/stylesheet/repeat-field-set-items.mjs +1 -1
  42. package/source/components/form/stylesheet/select.mjs +1 -1
  43. package/source/components/form/stylesheet/toggle-switch.mjs +2 -2
  44. package/source/components/form/variant-select.mjs +17 -17
  45. package/source/components/form/wizard.mjs +20 -20
  46. package/source/components/layout/details.mjs +47 -3
  47. package/source/components/layout/stylesheet/popper.mjs +1 -1
  48. package/source/components/layout/tabs.mjs +65 -10
  49. package/source/components/layout/vertical-tabs.mjs +65 -10
  50. package/source/components/style/floating-ui.css +13 -0
  51. package/source/components/style/floating-ui.pcss +4 -0
  52. package/source/components/stylesheet/floating-ui.mjs +1 -1
  53. package/source/components/time/month-calendar.mjs +75 -2
  54. package/source/i18n/internal.mjs +60 -18
  55. package/source/i18n/map/languages.mjs +2 -1
  56. package/source/i18n/time-ago.mjs +129 -0
  57. package/test/cases/components/datatable/datasource-rest-lifecycle.mjs +9 -1
  58. package/test/cases/components/datatable/mobile-layout.mjs +13 -0
  59. package/test/cases/components/form/button-bar.mjs +21 -0
  60. package/test/cases/components/form/control-bar.mjs +123 -0
  61. package/test/cases/components/form/field-set.mjs +11 -0
  62. package/test/cases/components/form/locale-defaults.mjs +58 -0
  63. package/test/cases/components/form/popper-button.mjs +12 -0
  64. package/test/cases/components/form/register-wizard.mjs +15 -0
  65. package/test/cases/components/form/toggle-switch.mjs +13 -0
  66. package/test/cases/i18n/built-in-locales.mjs +151 -0
  67. package/test/cases/i18n/time-ago.mjs +52 -32
@@ -18,6 +18,21 @@ describe("RegisterWizard", () => {
18
18
 
19
19
  afterEach(() => {
20
20
  document.getElementById("mocks").replaceChildren();
21
+ document.documentElement.lang = "en";
22
+ });
23
+
24
+ it("uses native localized defaults", () => {
25
+ for (const [locale, option, expected] of [
26
+ ["de", "labels.street", "Straße"],
27
+ ["hi", "labels.successTitle", "पंजीकरण पूरा हुआ"],
28
+ ["ru", "labels.stepAccount", "Учётная запись"],
29
+ ["ja", "labels.successTitle", "登録完了"],
30
+ ["fi", "labels.email", "Sähköposti"],
31
+ ]) {
32
+ document.documentElement.lang = locale;
33
+ const element = document.createElement("monster-register-wizard");
34
+ assert.equal(element.getOption(option), expected, `${locale}:${option}`);
35
+ }
21
36
  });
22
37
 
23
38
  it("keeps explicit labels inside nested field sets", async () => {
@@ -73,6 +73,19 @@ describe('ToggleSwitch', function () {
73
73
  it('should instance of monster-toggle-switch', function () {
74
74
  expect(document.createElement('monster-toggle-switch')).is.instanceof(ToggleSwitch);
75
75
  });
76
+
77
+ it('should center the visual switch within the themed control height', function () {
78
+ const cssText = ToggleSwitch.getCSSStyleSheet()
79
+ .flatMap((styleSheet) => Array.from(styleSheet.cssRules))
80
+ .map((rule) => rule.cssText)
81
+ .join("\n");
82
+
83
+ expect(cssText).to.contain("min-block-size: inherit");
84
+ expect(cssText).to.contain("align-items: center");
85
+ expect(cssText).to.match(
86
+ /:host\s*\{[^}]*min-block-size:\s*var\(--monster-control-min-block-size,\s*1\.8rem\)/u,
87
+ );
88
+ });
76
89
  });
77
90
 
78
91
  });
@@ -0,0 +1,151 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { expect } from "chai";
5
+ import * as espree from "espree";
6
+ import { globSync } from "glob";
7
+ import { currentSupportedLanguages } from "../../../source/i18n/map/languages.mjs";
8
+
9
+ const repositoryRoot = resolve(
10
+ dirname(fileURLToPath(import.meta.url)),
11
+ "../../..",
12
+ );
13
+ const sourceFiles = globSync("source/**/*.mjs", {
14
+ cwd: repositoryRoot,
15
+ absolute: true,
16
+ });
17
+
18
+ function walk(node, callback) {
19
+ if (!node || typeof node !== "object") {
20
+ return;
21
+ }
22
+
23
+ if (typeof node.type === "string") {
24
+ callback(node);
25
+ }
26
+
27
+ for (const [key, value] of Object.entries(node)) {
28
+ if (["comments", "loc", "range", "tokens"].includes(key)) {
29
+ continue;
30
+ }
31
+ if (Array.isArray(value)) {
32
+ for (const child of value) {
33
+ walk(child, callback);
34
+ }
35
+ } else {
36
+ walk(value, callback);
37
+ }
38
+ }
39
+ }
40
+
41
+ function getPropertyKey(property) {
42
+ if (property.computed || property.type !== "Property") {
43
+ return null;
44
+ }
45
+ return property.key.name ?? property.key.value ?? null;
46
+ }
47
+
48
+ function inspectLocaleTables() {
49
+ const localeSwitches = [];
50
+ const localeObjects = [];
51
+
52
+ for (const filename of sourceFiles) {
53
+ const source = readFileSync(filename, "utf8");
54
+ const ast = espree.parse(source, {
55
+ ecmaVersion: "latest",
56
+ loc: true,
57
+ range: true,
58
+ sourceType: "module",
59
+ });
60
+
61
+ walk(ast, (node) => {
62
+ if (node.type === "SwitchStatement") {
63
+ const discriminant = source.slice(
64
+ node.discriminant.start,
65
+ node.discriminant.end,
66
+ );
67
+ if (!/\.language\b/.test(discriminant)) {
68
+ return;
69
+ }
70
+
71
+ localeSwitches.push({
72
+ filename,
73
+ line: node.loc.start.line,
74
+ codes: node.cases
75
+ .map((entry) => entry.test?.value)
76
+ .filter((entry) => typeof entry === "string"),
77
+ hasDefault: node.cases.some((entry) => entry.test === null),
78
+ });
79
+ }
80
+
81
+ if (node.type === "ObjectExpression") {
82
+ const keys = node.properties
83
+ .map((property) => getPropertyKey(property))
84
+ .filter((key) => typeof key === "string");
85
+ const supportedKeys = keys.filter((key) =>
86
+ currentSupportedLanguages.includes(key),
87
+ );
88
+ if (supportedKeys.length >= 5) {
89
+ localeObjects.push({
90
+ filename,
91
+ line: node.loc.start.line,
92
+ keys,
93
+ });
94
+ }
95
+ }
96
+ });
97
+ }
98
+
99
+ return { localeSwitches, localeObjects };
100
+ }
101
+
102
+ describe("built-in locale coverage", () => {
103
+ const { localeSwitches, localeObjects } = inspectLocaleTables();
104
+
105
+ it("keeps the supported locale list unique", () => {
106
+ expect(new Set(currentSupportedLanguages).size).to.equal(
107
+ currentSupportedLanguages.length,
108
+ );
109
+ });
110
+
111
+ it("covers every supported locale in language switches", () => {
112
+ expect(localeSwitches.length).to.be.greaterThan(30);
113
+
114
+ for (const table of localeSwitches) {
115
+ const location = `${table.filename}:${table.line}`;
116
+ for (const language of currentSupportedLanguages) {
117
+ if (language === "en" && table.hasDefault) {
118
+ continue;
119
+ }
120
+ expect(table.codes, `${location} is missing ${language}`).to.include(
121
+ language,
122
+ );
123
+ }
124
+ expect(
125
+ table.codes,
126
+ `${location} uses an obsolete Spanish code`,
127
+ ).not.to.include("sp");
128
+ expect(
129
+ table.codes,
130
+ `${location} uses an obsolete Danish code`,
131
+ ).not.to.include("dk");
132
+ expect(
133
+ table.codes,
134
+ `${location} uses an obsolete Swedish code`,
135
+ ).not.to.include("sw");
136
+ }
137
+ });
138
+
139
+ it("covers every supported locale in language maps", () => {
140
+ expect(localeObjects.length).to.be.greaterThan(3);
141
+
142
+ for (const table of localeObjects) {
143
+ const location = `${table.filename}:${table.line}`;
144
+ for (const language of currentSupportedLanguages) {
145
+ expect(table.keys, `${location} is missing ${language}`).to.include(
146
+ language,
147
+ );
148
+ }
149
+ }
150
+ });
151
+ });
@@ -1,33 +1,53 @@
1
-
2
-
3
- import {expect} from "chai"
4
- import {formatTimeAgo} from "../../../source/i18n/time-ago.mjs";
5
-
6
- describe('formatTimeAgo', () => {
7
- it('returns "just now" for times less than a second ago', () => {
8
- const now = new Date();
9
- expect(formatTimeAgo(now, 'en')).to.equal('just now');
10
- });
11
-
12
- it('returns "in 1 second" for one second in the future', () => {
13
- const oneSecondFuture = new Date(Date.now() + 1000);
14
- expect(formatTimeAgo(oneSecondFuture, 'en')).to.equal('in 1 second');
15
- });
16
-
17
- it('returns "1 second ago" for one second in the past', () => {
18
- const oneSecondPast = new Date(Date.now() - 1000);
19
- expect(formatTimeAgo(oneSecondPast, 'en')).to.equal('1 second ago');
20
- });
21
-
22
- it('returns "in 1 minute, 30 seconds" for 90 seconds in the future', () => {
23
- const ninetySecondsFuture = new Date(Date.now() + 90000);
24
- expect(formatTimeAgo(ninetySecondsFuture, 'en')).to.equal('in 1 minute and 30 seconds');
25
- });
26
-
27
- it('returns "1 minute, 30 seconds ago" for 90 seconds in the past', () => {
28
- const ninetySecondsPast = new Date(Date.now() - 90000);
29
- expect(formatTimeAgo(ninetySecondsPast, 'en')).to.equal('1 minute and 30 seconds ago');
30
- });
31
-
32
- // Weitere Tests können hinzugefügt werden
1
+ import { expect } from "chai";
2
+ import { currentSupportedLanguages } from "../../../source/i18n/map/languages.mjs";
3
+ import { formatTimeAgo } from "../../../source/i18n/time-ago.mjs";
4
+
5
+ describe("formatTimeAgo", () => {
6
+ it('returns "just now" for times less than a second ago', () => {
7
+ const now = new Date();
8
+ expect(formatTimeAgo(now, "en")).to.equal("just now");
9
+ });
10
+
11
+ it('returns "in 1 second" for one second in the future', () => {
12
+ const oneSecondFuture = new Date(Date.now() + 1000);
13
+ expect(formatTimeAgo(oneSecondFuture, "en")).to.equal("in 1 second");
14
+ });
15
+
16
+ it('returns "1 second ago" for one second in the past', () => {
17
+ const oneSecondPast = new Date(Date.now() - 1000);
18
+ expect(formatTimeAgo(oneSecondPast, "en")).to.equal("1 second ago");
19
+ });
20
+
21
+ it('returns "in 1 minute, 30 seconds" for 90 seconds in the future', () => {
22
+ const ninetySecondsFuture = new Date(Date.now() + 90000);
23
+ expect(formatTimeAgo(ninetySecondsFuture, "en")).to.equal(
24
+ "in 1 minute and 30 seconds",
25
+ );
26
+ });
27
+
28
+ it('returns "1 minute, 30 seconds ago" for 90 seconds in the past', () => {
29
+ const ninetySecondsPast = new Date(Date.now() - 90000);
30
+ expect(formatTimeAgo(ninetySecondsPast, "en")).to.equal(
31
+ "1 minute and 30 seconds ago",
32
+ );
33
+ });
34
+
35
+ it("formats relative times for every supported South Asian locale", () => {
36
+ const oneHourFuture = new Date(Date.now() + 3600000);
37
+
38
+ expect(formatTimeAgo(oneHourFuture, "bn")).to.equal("1 ঘণ্টা পরে");
39
+ expect(formatTimeAgo(oneHourFuture, "pa")).to.equal("1 ਘੰਟਾ ਬਾਅਦ");
40
+ expect(formatTimeAgo(oneHourFuture, "mr")).to.equal("1 तास नंतर");
41
+ });
42
+
43
+ it("formats every supported locale without falling back to a missing table", () => {
44
+ const oneHourFuture = new Date(Date.now() + 3600000);
45
+
46
+ for (const locale of currentSupportedLanguages) {
47
+ expect(formatTimeAgo(oneHourFuture, locale), locale).to.be.a("string").and
48
+ .not.be.empty;
49
+ }
50
+ });
51
+
52
+ // Weitere Tests können hinzugefügt werden
33
53
  });