@aurodesignsystem/auro-library 5.14.0 → 5.14.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 (45) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/bin/generateDocs.mjs +4 -210
  3. package/bin/generateDocs_index.mjs +4 -210
  4. package/dist/_chunks/chunk-2MOEVVSZ.mjs +308 -0
  5. package/dist/_chunks/chunk-H7YO7ERJ.mjs +69 -0
  6. package/dist/_chunks/chunk-JLCAYVRX.mjs +84 -0
  7. package/dist/_chunks/chunk-RKBXVLA5.mjs +5983 -0
  8. package/dist/_chunks/chunk-TDFKN2EP.mjs +38 -0
  9. package/dist/_chunks/chunk-UY4SIQT6.mjs +201 -0
  10. package/dist/_chunks/chunk-V7YBXHAI.mjs +32379 -0
  11. package/dist/bin/generateDocs.mjs +152 -0
  12. package/dist/bin/generateDocs_index.mjs +152 -0
  13. package/dist/build/generateDocs.mjs +18 -0
  14. package/dist/build/generateReadme.mjs +49 -0
  15. package/dist/build/generateWcaComponent.mjs +6657 -0
  16. package/dist/build/processors/defaultDocsProcessor.mjs +16 -0
  17. package/dist/build/processors/defaultDotGithubSync.mjs +12 -0
  18. package/dist/build/syncGithubFiles.mjs +18 -0
  19. package/dist/utils/auroTemplateFiller.mjs +8 -0
  20. package/dist/utils/sharedFileProcessorUtils.mjs +31 -0
  21. package/package.json +10 -5
  22. package/scripts/build/generateDocs.mjs +4 -24
  23. package/scripts/build/generateReadme.mjs +4 -60
  24. package/scripts/build/generateWcaComponent.mjs +4 -43
  25. package/scripts/build/postinstall.mjs +10 -10
  26. package/scripts/build/pre-commit.mjs +13 -7
  27. package/scripts/build/processors/defaultDocsProcessor.mjs +4 -83
  28. package/scripts/build/processors/defaultDotGithubSync.mjs +4 -83
  29. package/scripts/build/syncGithubFiles.mjs +4 -25
  30. package/scripts/runtime/floatingUI.mjs +2 -1
  31. package/scripts/runtime/generateUUID/generateUUID.mjs +41 -0
  32. package/scripts/runtime/generateUUID/index.mjs +1 -0
  33. package/scripts/utils/ansiColors.mjs +119 -0
  34. package/scripts/utils/auroLibraryUtils.mjs +87 -51
  35. package/scripts/utils/auroTemplateFiller.mjs +4 -178
  36. package/scripts/utils/logger.mjs +27 -16
  37. package/scripts/utils/sharedFileProcessorUtils.mjs +4 -270
  38. package/scripts/build/deprecatedProseToFieldPlugin.spec.js +0 -188
  39. package/scripts/runtime/ClickTracker/test/ClickTracker.test.js +0 -424
  40. package/scripts/runtime/FocusTrap/test/FocusTrap.test.js +0 -168
  41. package/scripts/runtime/Focusables/test/Focusables.test.js +0 -185
  42. package/scripts/runtime/dateUtilities/dateFormatter.test.js +0 -284
  43. package/scripts/runtime/dateUtilities/dateUtilities.test.js +0 -80
  44. package/scripts/runtime/floatingUI/test/floatingUI.test.js +0 -189
  45. package/scripts/runtime/floatingUI.test.js +0 -478
@@ -1,185 +0,0 @@
1
- /* eslint-disable max-classes-per-file */
2
- import { expect, fixtureSync, html } from "@open-wc/testing";
3
-
4
- import { getFocusableElements, isFocusableComponent } from "../Focusables.mjs";
5
-
6
- describe("isFocusableComponent", () => {
7
- it("returns true for enabled custom focusable components", async () => {
8
- for (const tag of [
9
- "auro-checkbox",
10
- "auro-radio",
11
- "auro-dropdown",
12
- "auro-button",
13
- "auro-combobox",
14
- "auro-input",
15
- "auro-counter",
16
- "auro-select",
17
- "auro-datepicker",
18
- "auro-hyperlink",
19
- "auro-accordion",
20
- ]) {
21
- const el = document.createElement(tag);
22
- if (tag === "auro-hyperlink") {
23
- el.setAttribute("href", "#");
24
- }
25
- document.body.appendChild(el);
26
- expect(isFocusableComponent(el)).to.be.true;
27
- el.remove();
28
- }
29
- });
30
-
31
- it("returns false for custom components with disabled attribute", async () => {
32
- for (const tag of [
33
- "auro-checkbox",
34
- "auro-radio",
35
- "auro-dropdown",
36
- "auro-button",
37
- "auro-combobox",
38
- "auro-input",
39
- "auro-counter",
40
- "auro-select",
41
- "auro-datepicker",
42
- "auro-hyperlink",
43
- "auro-accordion",
44
- ]) {
45
- const el = document.createElement(tag);
46
- el.setAttribute("disabled", "");
47
- if (tag === "auro-hyperlink") {
48
- el.setAttribute("href", "#");
49
- }
50
- document.body.appendChild(el);
51
- expect(isFocusableComponent(el)).to.be.false;
52
- el.remove();
53
- }
54
- });
55
-
56
- it("returns false for auro-hyperlink without href", async () => {
57
- const el = document.createElement("auro-hyperlink");
58
- document.body.appendChild(el);
59
- expect(isFocusableComponent(el)).to.be.false;
60
- el.remove();
61
- });
62
-
63
- it("returns false for non-custom elements", async () => {
64
- const el = document.createElement("div");
65
- document.body.appendChild(el);
66
- expect(isFocusableComponent(el)).to.be.false;
67
- el.remove();
68
- });
69
- });
70
-
71
- // fixtureSync is used instead of fixture to avoid requestAnimationFrame, which Chrome
72
- // pauses in background tabs when multiple test files run concurrently under WTR.
73
- describe("getFocusableElements", () => {
74
- it("finds standard focusable elements", () => {
75
- const el = fixtureSync(html`
76
- <div>
77
- <button id="btn"></button>
78
- <input id="input">
79
- <a id="link" href="#"></a>
80
- <textarea id="ta"></textarea>
81
- <select id="sel"></select>
82
- </div>
83
- `);
84
- const focusables = getFocusableElements(el);
85
- expect(focusables.map((e) => e.id)).to.include.members([
86
- "btn",
87
- "input",
88
- "link",
89
- "ta",
90
- "sel",
91
- ]);
92
- });
93
-
94
- it("skips disabled elements", () => {
95
- const el = fixtureSync(html`
96
- <div>
97
- <button id="btn" disabled></button>
98
- <input id="input" disabled>
99
- <textarea id="ta" disabled></textarea>
100
- <select id="sel" disabled></select>
101
- </div>
102
- `);
103
- const focusables = getFocusableElements(el);
104
- expect(focusables.length).to.equal(0);
105
- });
106
-
107
- it("finds custom focusable components", () => {
108
- const el = fixtureSync(html`
109
- <div>
110
- <auro-checkbox id="cb"></auro-checkbox>
111
- <auro-hyperlink id="hl" href="#"></auro-hyperlink>
112
- <auro-button id="ab"></auro-button>
113
- </div>
114
- `);
115
- const focusables = getFocusableElements(el);
116
- expect(focusables.map((e) => e.id)).to.include.members(["cb", "hl", "ab"]);
117
- });
118
-
119
- it("skips disabled custom components", () => {
120
- const el = fixtureSync(html`
121
- <div>
122
- <auro-checkbox id="cb" disabled></auro-checkbox>
123
- <auro-hyperlink id="hl" disabled href="#"></auro-hyperlink>
124
- </div>
125
- `);
126
- const focusables = getFocusableElements(el);
127
- expect(focusables.length).to.equal(0);
128
- });
129
-
130
- it("finds elements in shadow DOM", () => {
131
- class ShadowEl extends HTMLElement {
132
- constructor() {
133
- super();
134
- this.attachShadow({ mode: "open" });
135
- }
136
- connectedCallback() {
137
- const btn = document.createElement("button");
138
- btn.id = "shadowBtn";
139
- this.shadowRoot.appendChild(btn);
140
- }
141
- }
142
- customElements.define("shadow-el", ShadowEl);
143
- const el = fixtureSync(html`
144
- <div>
145
- <shadow-el id="host"></shadow-el>
146
- </div>
147
- `);
148
- const focusables = getFocusableElements(el);
149
- const shadowBtn = el
150
- .querySelector("shadow-el")
151
- .shadowRoot.getElementById("shadowBtn");
152
- expect(focusables).to.include(shadowBtn);
153
- });
154
-
155
- it("finds elements assigned to slots", () => {
156
- class SlotEl extends HTMLElement {
157
- constructor() {
158
- super();
159
- this.attachShadow({ mode: "open" });
160
- }
161
- connectedCallback() {
162
- this.shadowRoot.appendChild(document.createElement("slot"));
163
- }
164
- }
165
- customElements.define("slot-el", SlotEl);
166
- const el = fixtureSync(html`
167
- <slot-el>
168
- <button id="slottedBtn"></button>
169
- </slot-el>
170
- `);
171
- const focusables = getFocusableElements(el);
172
- const slottedBtn = el.querySelector("#slottedBtn");
173
- expect(focusables).to.include(slottedBtn);
174
- });
175
-
176
- it("does not return duplicates", () => {
177
- const el = fixtureSync(html`
178
- <div>
179
- <button id="btn"></button>
180
- </div>
181
- `);
182
- const focusables = getFocusableElements(el);
183
- expect(focusables.filter((e) => e.id === "btn").length).to.equal(1);
184
- });
185
- });
@@ -1,284 +0,0 @@
1
- import { expect } from "@open-wc/testing";
2
- import { dateFormatter } from "./dateFormatter.mjs";
3
-
4
- describe("dateFormatter.parseDate", () => {
5
- describe("null / undefined / empty input", () => {
6
- it("returns undefined for null", () => {
7
- expect(dateFormatter.parseDate(null)).to.be.undefined;
8
- });
9
-
10
- it("returns undefined for undefined", () => {
11
- expect(dateFormatter.parseDate(undefined)).to.be.undefined;
12
- });
13
-
14
- it("returns undefined for empty string", () => {
15
- expect(dateFormatter.parseDate("")).to.be.undefined;
16
- });
17
- });
18
- });
19
-
20
- describe("dateFormatter.toNorthAmericanFormat", () => {
21
- it("returns the string unchanged for mm/dd/yyyy", () => {
22
- expect(
23
- dateFormatter.toNorthAmericanFormat("01/15/2024", "mm/dd/yyyy"),
24
- ).to.equal("01/15/2024");
25
- });
26
-
27
- it("reorders dd/mm/yyyy to mm/dd/yyyy", () => {
28
- expect(
29
- dateFormatter.toNorthAmericanFormat("15/01/2024", "dd/mm/yyyy"),
30
- ).to.equal("01/15/2024");
31
- });
32
-
33
- it("reorders yyyy-mm-dd to mm/dd/yyyy", () => {
34
- expect(
35
- dateFormatter.toNorthAmericanFormat("2024-01-15", "yyyy-mm-dd"),
36
- ).to.equal("01/15/2024");
37
- });
38
-
39
- it("throws when the date string cannot be parsed", () => {
40
- expect(() =>
41
- dateFormatter.toNorthAmericanFormat(null, "dd/mm/yyyy"),
42
- ).to.throw(Error);
43
- });
44
- });
45
-
46
- describe("dateFormatter.stringToDateInstance", () => {
47
- describe("ISO input", () => {
48
- const isoCases = [
49
- { input: "2024-01-15", description: "typical ISO date" },
50
- { input: "1999-12-31", description: "end of year ISO date" },
51
- ];
52
-
53
- isoCases.forEach(({ input, description }) => {
54
- it(`creates Date directly from ISO string for: ${description}`, () => {
55
- const result = dateFormatter.stringToDateInstance(input);
56
-
57
- expect(result).to.be.instanceOf(Date);
58
- expect(result.toISOString().slice(0, 10)).to.equal(input);
59
- });
60
- });
61
- });
62
-
63
- describe("non-ISO input with explicit format", () => {
64
- it("returns a Date using parseDate result for dd/mm/yyyy format", () => {
65
- const inputStr = "15/01/2024";
66
- const expectedYear = 2024;
67
- const expectedMonth = 1; // January (1-based)
68
- const expectedDay = 15;
69
-
70
- const result = dateFormatter.stringToDateInstance(inputStr, "dd/mm/yyyy");
71
-
72
- expect(result).to.be.instanceOf(Date);
73
- expect(result.getFullYear()).to.equal(expectedYear);
74
- expect(result.getMonth()).to.equal(expectedMonth - 1);
75
- expect(result.getDate()).to.equal(expectedDay);
76
- });
77
- });
78
-
79
- describe("default format behaviour", () => {
80
- it("uses default format parameter when format is not provided", () => {
81
- const inputStr = "2024-02-29";
82
-
83
- const result = dateFormatter.stringToDateInstance(inputStr);
84
-
85
- expect(result).to.be.instanceOf(Date);
86
- expect(result.getFullYear()).to.equal(2024);
87
- expect(result.getMonth()).to.equal(1);
88
- expect(result.getDate()).to.equal(29);
89
- });
90
- });
91
-
92
- describe("month adjustment", () => {
93
- it("correctly adjusts month from 1-based to 0-based when creating Date", () => {
94
- const inputStr = "2024-12-31";
95
-
96
- const result = dateFormatter.stringToDateInstance(inputStr);
97
-
98
- expect(result.getFullYear()).to.equal(2024);
99
- expect(result.getMonth()).to.equal(11);
100
- expect(result.getDate()).to.equal(31);
101
- });
102
- });
103
- });
104
-
105
- describe("dateFormatter.isValidDate", () => {
106
- describe("valid date inputs", () => {
107
- const validCases = [
108
- {
109
- args: ["2024-02-29"],
110
- description: "valid leap day ISO (default format)",
111
- },
112
- {
113
- args: ["1999-12-31", "yyyy-mm-dd"],
114
- description: "valid ISO with explicit format",
115
- },
116
- {
117
- args: ["12/31/1999", "mm/dd/yyyy"],
118
- description: "valid mm/dd/yyyy",
119
- },
120
- {
121
- args: ["31-01-2020", "dd-mm-yyyy"],
122
- description: "valid dd-mm-yyyy",
123
- },
124
- {
125
- args: ["01/15/01", "mm/dd/yy"],
126
- description: "2-digit year below 50 normalizes to 20xx (01 → 2001)",
127
- },
128
- {
129
- args: ["12/31/99", "mm/dd/yy"],
130
- description: "2-digit year >= 50 normalizes to 19xx (99 → 1999)",
131
- },
132
- ];
133
-
134
- validCases.forEach(({ args, description }) => {
135
- it(`returns true for: ${description}`, () => {
136
- const result = dateFormatter.isValidDate(...args);
137
- expect(result, `Expected ${JSON.stringify(args)} to be a valid date`).to
138
- .be.true;
139
- });
140
- });
141
- });
142
-
143
- describe("invalid date inputs", () => {
144
- const invalidCases = [
145
- {
146
- args: ["02/2024", "mm/yyyy"],
147
- description: "short format mm/yyyy",
148
- },
149
- {
150
- args: ["2024/02", "yyyy/mm"],
151
- description: "short format yyyy/mm",
152
- },
153
- {
154
- args: ["2024", "yyyy"],
155
- description: "short format yyyy",
156
- },
157
- { args: ["2024-02-30"], description: "invalid ISO day" },
158
- {
159
- args: ["12/31/1999", "yyyy-mm-dd"],
160
- description: "non-ISO string with yyyy-mm-dd format",
161
- },
162
- {
163
- args: ["02/30/2024", "mm/dd/yyyy"],
164
- description: "invalid mm/dd/yyyy with impossible day",
165
- },
166
- {
167
- args: [null, "mm/dd/yyyy"],
168
- description: "non-string date value",
169
- },
170
- {
171
- args: ["13/2024", "mm/yyyy"],
172
- description: "invalid mm/yyyy with month out of range",
173
- },
174
- {
175
- args: ["00/24", "mm/yy"],
176
- description: "invalid mm/yy with month below range",
177
- },
178
- {
179
- args: ["02/24", "mm/yy"],
180
- description: "invalid mm/yy",
181
- },
182
- {
183
- args: ["2024/13", "yyyy/mm"],
184
- description: "invalid yyyy/mm with month out of range",
185
- },
186
- {
187
- args: ["ab24", "yyyy"],
188
- description: "invalid yyyy with non-numeric value",
189
- },
190
- {
191
- args: ["2a", "yy"],
192
- description: "invalid yy with non-numeric value",
193
- },
194
- {
195
- args: ["24", "yy"],
196
- description: "invalid yy",
197
- },
198
- {
199
- args: ["00", "mm"],
200
- description: "invalid mm below range",
201
- },
202
- {
203
- args: ["12", "mm"],
204
- description: "invalid mm",
205
- },
206
- {
207
- args: ["00", "dd"],
208
- description: "invalid dd below range",
209
- },
210
- {
211
- args: ["31", "dd"],
212
- description: "invalid dd",
213
- },
214
- {
215
- args: ["32", "dd"],
216
- description: "invalid dd above range",
217
- },
218
- ];
219
-
220
- invalidCases.forEach(({ args, description }) => {
221
- it(`returns false for: ${description}`, () => {
222
- const result = dateFormatter.isValidDate(...args);
223
- expect(result, `Expected ${JSON.stringify(args)} to be an invalid date`)
224
- .to.be.false;
225
- });
226
- });
227
- });
228
- });
229
-
230
- describe("dateFormatter.toISOFormatString", () => {
231
- describe("valid Date inputs", () => {
232
- const validCases = [
233
- {
234
- input: new Date("2024/01/15"),
235
- expected: "2024-01-15",
236
- description: "typical date",
237
- },
238
- {
239
- input: new Date("1999/12/31"),
240
- expected: "1999-12-31",
241
- description: "end of year",
242
- },
243
- {
244
- input: new Date("2024/02/29"),
245
- expected: "2024-02-29",
246
- description: "leap day",
247
- },
248
- {
249
- input: new Date("2000/01/01"),
250
- expected: "2000-01-01",
251
- description: "first day of millennium",
252
- },
253
- {
254
- input: new Date("2024/12/31"),
255
- expected: "2024-12-31",
256
- description: "last day of year",
257
- },
258
- ];
259
-
260
- validCases.forEach(({ input, expected, description }) => {
261
- it(`returns "${expected}" for: ${description}`, () => {
262
- const result = dateFormatter.toISOFormatString(input);
263
- expect(result).to.equal(expected);
264
- });
265
- });
266
- });
267
-
268
- describe("invalid inputs", () => {
269
- const invalidCases = [
270
- { input: new Date("not-a-date"), description: "invalid Date instance" },
271
- { input: "2024-01-15", description: "string input" },
272
- { input: null, description: "null input" },
273
- { input: undefined, description: "undefined input" },
274
- { input: 20240115, description: "number input" },
275
- { input: {}, description: "plain object input" },
276
- ];
277
-
278
- invalidCases.forEach(({ input, description }) => {
279
- it(`throws for: ${description}`, () => {
280
- expect(() => dateFormatter.toISOFormatString(input)).to.throw(Error);
281
- });
282
- });
283
- });
284
- });
@@ -1,80 +0,0 @@
1
- import { expect } from "@open-wc/testing";
2
- import { AuroDateUtilities } from "./dateUtilities.mjs";
3
-
4
- const utils = new AuroDateUtilities();
5
-
6
- describe("AuroDateUtilities.validDateStr", () => {
7
- it("throws when date is undefined", () => {
8
- expect(() => utils.validDateStr(undefined, "mm/dd/yyyy")).to.throw(Error);
9
- });
10
-
11
- it("throws when format is undefined", () => {
12
- expect(() => utils.validDateStr("01/15/2024", undefined)).to.throw(Error);
13
- });
14
-
15
- it("throws when date is not a string", () => {
16
- expect(() => utils.validDateStr(20240115, "mm/dd/yyyy")).to.throw(Error);
17
- });
18
-
19
- it("returns false when date length does not match format length", () => {
20
- expect(utils.validDateStr("01/15", "mm/dd/yyyy")).to.be.false;
21
- });
22
-
23
- it("returns true for a valid date matching its format", () => {
24
- expect(utils.validDateStr("01/15/2024", "mm/dd/yyyy")).to.be.true;
25
- });
26
-
27
- it("returns false for an invalid calendar date (Feb 30)", () => {
28
- expect(utils.validDateStr("02/30/2024", "mm/dd/yyyy")).to.be.false;
29
- });
30
- });
31
-
32
- describe("AuroDateUtilities.dateAndFormatMatch", () => {
33
- it("throws when value is falsy", () => {
34
- expect(() => utils.dateAndFormatMatch(null, "mm/dd/yyyy")).to.throw(Error);
35
- });
36
-
37
- it("throws when format is falsy", () => {
38
- expect(() => utils.dateAndFormatMatch("01/15/2024", null)).to.throw(Error);
39
- });
40
-
41
- it("returns false when value length differs from format length", () => {
42
- expect(utils.dateAndFormatMatch("01/15", "mm/dd/yyyy")).to.be.false;
43
- });
44
-
45
- it("returns true for a value that matches the format", () => {
46
- expect(utils.dateAndFormatMatch("01/15/2024", "mm/dd/yyyy")).to.be.true;
47
- });
48
-
49
- it("returns false when month is below range", () => {
50
- expect(utils.dateAndFormatMatch("00/15/2024", "mm/dd/yyyy")).to.be.false;
51
- });
52
-
53
- it("returns false when month is above range", () => {
54
- expect(utils.dateAndFormatMatch("13/15/2024", "mm/dd/yyyy")).to.be.false;
55
- });
56
-
57
- it("returns false when day is below range", () => {
58
- expect(utils.dateAndFormatMatch("01/00/2024", "mm/dd/yyyy")).to.be.false;
59
- });
60
-
61
- it("returns false when day is above range", () => {
62
- expect(utils.dateAndFormatMatch("01/32/2024", "mm/dd/yyyy")).to.be.false;
63
- });
64
-
65
- it("returns false when year is below range", () => {
66
- expect(utils.dateAndFormatMatch("01/15/1899", "mm/dd/yyyy")).to.be.false;
67
- });
68
-
69
- it("returns false when year is above range", () => {
70
- expect(utils.dateAndFormatMatch("01/15/2401", "mm/dd/yyyy")).to.be.false;
71
- });
72
-
73
- it("skips day check when format has no day component", () => {
74
- expect(utils.dateAndFormatMatch("01/2024", "mm/yyyy")).to.be.true;
75
- });
76
-
77
- it("skips month check when format has no month component", () => {
78
- expect(utils.dateAndFormatMatch("15/2024", "dd/yyyy")).to.be.true;
79
- });
80
- });