@stackoverflow/stacks 1.8.0 → 1.9.1

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 (137) hide show
  1. package/README.md +161 -153
  2. package/dist/{controllers/s-banner.d.ts → components/banner/banner.d.ts} +1 -1
  3. package/dist/{controllers/s-expandable-control.d.ts → components/expandable/expandable.d.ts} +1 -1
  4. package/dist/{controllers/s-modal.d.ts → components/modal/modal.d.ts} +1 -1
  5. package/dist/{controllers/s-navigation-tablist.d.ts → components/navigation/navigation.d.ts} +1 -1
  6. package/dist/{controllers/s-popover.d.ts → components/popover/popover.d.ts} +1 -1
  7. package/dist/{controllers/s-tooltip.d.ts → components/popover/tooltip.d.ts} +1 -1
  8. package/dist/components/table/table.d.ts +30 -0
  9. package/dist/{controllers/s-toast.d.ts → components/toast/toast.d.ts} +1 -1
  10. package/dist/{controllers/s-uploader.d.ts → components/uploader/uploader.d.ts} +1 -1
  11. package/dist/controllers.d.ts +9 -0
  12. package/dist/css/stacks.css +2063 -1994
  13. package/dist/css/stacks.min.css +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/js/stacks.js +1465 -1436
  16. package/dist/js/stacks.min.js +1 -1
  17. package/lib/{css/atomic/borders.less → atomic/border.less} +397 -379
  18. package/lib/{css/atomic/colors.less → atomic/color.less} +210 -210
  19. package/lib/{css/atomic → atomic}/flex.less +426 -426
  20. package/lib/{css/atomic → atomic}/gap.less +44 -44
  21. package/lib/{css/atomic → atomic}/grid.less +139 -139
  22. package/lib/{css/atomic → atomic}/misc.less +343 -343
  23. package/lib/{css/atomic → atomic}/spacing.less +342 -342
  24. package/lib/{css/atomic → atomic}/typography.less +267 -267
  25. package/lib/{css/atomic → atomic}/width-height.less +194 -194
  26. package/lib/{css/base → base}/body.less +44 -44
  27. package/lib/{css/base → base}/configuration-static.less +61 -61
  28. package/lib/{css/base → base}/fieldset.less +5 -5
  29. package/lib/{css/base/icons.less → base/icon.less} +11 -20
  30. package/lib/{css/base/internals.less → base/internal.less} +220 -220
  31. package/lib/{css/base → base}/reset-meyer.less +64 -64
  32. package/lib/{css/base → base}/reset-normalize.less +449 -449
  33. package/lib/{css/base → base}/reset.less +20 -20
  34. package/lib/components/activity-indicator/activity-indicator.a11y.test.ts +21 -0
  35. package/lib/{css/components → components/activity-indicator}/activity-indicator.less +40 -40
  36. package/lib/components/activity-indicator/activity-indicator.visual.test.ts +23 -0
  37. package/lib/{css/components/anchors.less → components/anchor/anchor.less} +61 -61
  38. package/lib/components/avatar/avatar.a11y.test.ts +36 -0
  39. package/lib/{css/components/avatars.less → components/avatar/avatar.less} +108 -108
  40. package/lib/components/avatar/avatar.visual.test.ts +54 -0
  41. package/lib/components/award-bling/award-bling.a11y.test.ts +17 -0
  42. package/lib/{css/components → components/award-bling}/award-bling.less +31 -31
  43. package/lib/components/award-bling/award-bling.visual.test.ts +26 -0
  44. package/lib/{css/components/badges.less → components/badge/badge.less} +251 -251
  45. package/lib/components/banner/banner.a11y.test.ts +37 -0
  46. package/lib/components/banner/banner.less +51 -0
  47. package/lib/{test/s-banner.test.ts → components/banner/banner.test.ts} +73 -73
  48. package/lib/{ts/controllers/s-banner.ts → components/banner/banner.ts} +149 -149
  49. package/lib/components/banner/banner.visual.test.ts +37 -0
  50. package/lib/components/block-link/block-link.a11y.test.ts +68 -0
  51. package/lib/{css/components → components/block-link}/block-link.less +80 -80
  52. package/lib/components/block-link/block-link.visual.test.ts +61 -0
  53. package/lib/components/breadcrumbs/breadcrumbs.a11y.test.ts +37 -0
  54. package/lib/{css/components → components/breadcrumbs}/breadcrumbs.less +41 -41
  55. package/lib/components/breadcrumbs/breadcrumbs.visual.test.ts +37 -0
  56. package/lib/components/button/button.a11y.test.ts +32 -0
  57. package/lib/{css/components/buttons.less → components/button/button.less} +502 -501
  58. package/lib/components/button/button.visual.test.ts +52 -0
  59. package/lib/{css/components/button-groups.less → components/button-group/button-group.less} +83 -83
  60. package/lib/components/card/card.a11y.test.ts +13 -0
  61. package/lib/{css/components/cards.less → components/card/card.less} +29 -29
  62. package/lib/components/card/card.visual.test.ts +54 -0
  63. package/lib/components/check-control/check-control.less +17 -0
  64. package/lib/components/check-group/check-group.less +19 -0
  65. package/lib/{css/components/checkboxes-radios.less → components/checkbox_radio/checkbox_radio.less} +158 -158
  66. package/lib/{css/components/code-blocks.less → components/code-block/code-block.less} +116 -116
  67. package/lib/{css/components → components/description}/description.less +9 -9
  68. package/lib/{css/components/empty-states.less → components/empty-state/empty-state.less} +16 -16
  69. package/lib/{css/components → components/expandable}/expandable.less +118 -115
  70. package/lib/components/expandable/expandable.test.ts +51 -0
  71. package/lib/{ts/controllers/s-expandable-control.ts → components/expandable/expandable.ts} +238 -238
  72. package/lib/components/input-fill/input-fill.less +35 -0
  73. package/lib/components/input-icon/input-icon.less +45 -0
  74. package/lib/components/input-message/input-message.less +48 -0
  75. package/lib/{css/components/inputs.less → components/input_textarea/input_textarea.less} +166 -297
  76. package/lib/{css/components/labels.less → components/label/label.less} +111 -111
  77. package/lib/{css/components → components/link}/link.less +119 -119
  78. package/lib/{css/components/link-previews.less → components/link-preview/link-preview.less} +139 -139
  79. package/lib/{css/components → components/menu}/menu.less +41 -41
  80. package/lib/{css/components/modals.less → components/modal/modal.less} +113 -113
  81. package/lib/{ts/controllers/s-modal.ts → components/modal/modal.ts} +379 -379
  82. package/lib/{css/components → components/navigation}/navigation.less +134 -134
  83. package/lib/{ts/controllers/s-navigation-tablist.ts → components/navigation/navigation.ts} +128 -128
  84. package/lib/{css/components/notices.less → components/notice/notice.less} +203 -292
  85. package/lib/{css/components/page-titles.less → components/page-title/page-title.less} +51 -51
  86. package/lib/{css/components → components/pagination}/pagination.less +52 -52
  87. package/lib/{css/components/popovers.less → components/popover/popover.less} +148 -147
  88. package/lib/{ts/controllers/s-popover.ts → components/popover/popover.ts} +651 -651
  89. package/lib/{test/s-tooltip.test.ts → components/popover/tooltip.test.ts} +62 -62
  90. package/lib/{ts/controllers/s-tooltip.ts → components/popover/tooltip.ts} +343 -343
  91. package/lib/{test/s-tooltip.visual.test.ts → components/popover/tooltip.visual.test.ts} +31 -31
  92. package/lib/{css/components → components/post-summary}/post-summary.less +415 -415
  93. package/lib/{css/components/progress-bars.less → components/progress-bar/progress-bar.less} +291 -291
  94. package/lib/{css/components → components/prose}/prose.less +452 -452
  95. package/lib/{css/components → components/select}/select.less +148 -148
  96. package/lib/{css/components/sidebar-widgets.less → components/sidebar-widget/sidebar-widget.less} +257 -259
  97. package/lib/{css/components → components/spinner}/spinner.less +103 -103
  98. package/lib/{css/components → components/table}/table.less +307 -297
  99. package/lib/components/table/table.test.ts +366 -0
  100. package/lib/{ts/controllers/s-table.ts → components/table/table.ts} +296 -263
  101. package/lib/components/table-container/table-container.less +4 -0
  102. package/lib/{css/components/tags.less → components/tag/tag.less} +213 -213
  103. package/lib/components/toast/toast.less +35 -0
  104. package/lib/{test/s-toast.test.ts → components/toast/toast.test.ts} +63 -63
  105. package/lib/{ts/controllers/s-toast.ts → components/toast/toast.ts} +357 -357
  106. package/lib/components/toast/toast.visual.test.ts +27 -0
  107. package/lib/{css/components/toggle-switches.less → components/toggle-switch/toggle-switch.less} +110 -110
  108. package/lib/{css/components → components/topbar}/topbar.less +436 -435
  109. package/lib/{css/components → components/uploader}/uploader.less +195 -195
  110. package/lib/{ts/controllers/s-uploader.ts → components/uploader/uploader.ts} +205 -205
  111. package/lib/{css/components/user-cards.less → components/user-card/user-card.less} +129 -129
  112. package/lib/controllers.ts +33 -0
  113. package/lib/{css/exports → exports}/constants-colors.less +1112 -1111
  114. package/lib/{css/exports → exports}/constants-helpers.less +108 -108
  115. package/lib/{css/exports → exports}/constants-type.less +153 -153
  116. package/lib/{css/exports → exports}/exports.less +15 -15
  117. package/lib/{css/exports → exports}/mixins.less +299 -299
  118. package/lib/{ts/index.ts → index.ts} +32 -32
  119. package/lib/{css/input-utils.less → input-utils.less} +44 -44
  120. package/lib/{css/stacks-dynamic.less → stacks-dynamic.less} +24 -25
  121. package/lib/stacks-static.less +93 -0
  122. package/lib/{css/stacks.less → stacks.less} +13 -13
  123. package/lib/{ts/stacks.ts → stacks.ts} +113 -113
  124. package/lib/test/open-wc-testing-patch.d.ts +26 -0
  125. package/lib/test/test-utils.ts +466 -0
  126. package/lib/tsconfig.build.json +4 -0
  127. package/lib/tsconfig.json +16 -13
  128. package/package.json +106 -105
  129. package/dist/controllers/index.d.ts +0 -9
  130. package/dist/controllers/s-table.d.ts +0 -8
  131. package/lib/css/stacks-static.less +0 -87
  132. package/lib/test/s-avatar.a11y.test.ts +0 -77
  133. package/lib/test/s-banner.visual.test.ts +0 -61
  134. package/lib/test/s-btn.a11y.test.ts +0 -123
  135. package/lib/test/s-btn.visual.test.ts +0 -16
  136. package/lib/test/s-toast.visual.test.ts +0 -48
  137. package/lib/ts/controllers/index.ts +0 -17
@@ -0,0 +1,466 @@
1
+ import { html, fixture, expect, unsafeStatic } from "@open-wc/testing";
2
+ import { screen } from "@testing-library/dom";
3
+ import { visualDiff } from "@web/test-runner-visual-regression";
4
+ import type { TemplateResult } from "lit-html";
5
+
6
+ const colorThemes = ["dark", "light"];
7
+ const baseThemes = ["", "highcontrast"];
8
+ export const defaultOptions = {
9
+ testColorThemes: true,
10
+ testHighContrast: true,
11
+ includeNullVariant: true,
12
+ includeNullModifier: true,
13
+ };
14
+
15
+ type Themes = ["light" | "dark" | "highcontrast" | ""];
16
+ type TestTypes = "visual" | "a11y";
17
+
18
+ type TestOptions = {
19
+ /**
20
+ * Enable tests for all color themes
21
+ * default: true
22
+ */
23
+ testColorThemes: boolean;
24
+ /**
25
+ * Enable tests for high contrast
26
+ * default: true
27
+ */
28
+ testHighContrast: boolean;
29
+ /**
30
+ * Provide a custom testid suffix
31
+ * default: undefined
32
+ */
33
+ testidSuffix?: string;
34
+ /**
35
+ * Include tests for the component without any variants applied
36
+ * default: true
37
+ */
38
+ includeNullVariant: boolean;
39
+ /**
40
+ * Include tests for the component without any modifiers applied
41
+ * default: true
42
+ */
43
+ includeNullModifier: boolean;
44
+ };
45
+
46
+ interface ComponentTestVariationArgs {
47
+ /**
48
+ * Base class of the component
49
+ * (e.g. "s-component")
50
+ */
51
+ baseClass: string;
52
+ /**
53
+ * Variants of the component
54
+ * (e.g. ["primary", "secondary"])
55
+ */
56
+ variants?: string[];
57
+ /**
58
+ * Modifiers of the component
59
+ * (e.g. { primary: ["filled", "outlined"], secondary: ["xs", "sm", "md"] })
60
+ */
61
+ modifiers?: ComponentTestModifiers;
62
+ /**
63
+ * Options for the test
64
+ */
65
+ options?: TestOptions;
66
+ }
67
+
68
+ type ComponentTestArgs = {
69
+ /**
70
+ * The element to test
71
+ * use the `html` template tag to render the element
72
+ */
73
+ element: TemplateResult;
74
+ /**
75
+ * testid of the test
76
+ * (e.g. "s-component-primary-important")
77
+ */
78
+ testid: string;
79
+ /**
80
+ * Theme to apply to the test element
81
+ */
82
+ theme?: Themes;
83
+ /**
84
+ * Type of test to run
85
+ */
86
+ type: TestTypes;
87
+ };
88
+
89
+ interface ComponentTestsArgs extends ComponentTestVariationArgs {
90
+ /**
91
+ * Additional html attributes applied to the test element
92
+ * (e.g. { role: "button", id: "id" } -> <element role="button" id="id"> )
93
+ */
94
+ attributes?: Record<string, string>;
95
+ /**
96
+ * Child elements to render inside the test element
97
+ * (if key `default` is used, the testid will not include the child name)
98
+ */
99
+ children?: {
100
+ [key: string]: string;
101
+ };
102
+ /**
103
+ * testids of tests to exclude from testing
104
+ */
105
+ excludedTestids?: (string | RegExp)[];
106
+ /**
107
+ * testids of tests to skip
108
+ */
109
+ skippedTestids?: (string | RegExp)[];
110
+ /**
111
+ * HTML tag name of the test element
112
+ */
113
+ tag?: string;
114
+ /**
115
+ * Function that returns a template for the test element
116
+ * used to wrap the component test element in a container
117
+ */
118
+ template?: (args: {
119
+ component: unknown;
120
+ tag?: string;
121
+ testid: string;
122
+ }) => ReturnType<typeof html>;
123
+ /**
124
+ * Type of test to run
125
+ */
126
+ type: TestTypes;
127
+ }
128
+
129
+ type ComponentTestModifiers = {
130
+ /**
131
+ * Primary grouping of modifiers to test
132
+ * The base class will be used as a prefix for these modifiers
133
+ */
134
+ primary?: string[];
135
+ /**
136
+ * Secondary grouping of modifiers to test
137
+ * The base class will be used as a prefix for these modifiers
138
+ */
139
+ secondary?: string[];
140
+ /**
141
+ * Grouping of modifers to test that will not be prefixed with the base class
142
+ */
143
+ global?: string[];
144
+ /**
145
+ * Modifiers to test individually
146
+ * The base class will be used as a prefix for these modifiers
147
+ */
148
+ standalone?: string[];
149
+ };
150
+
151
+ type ComponentTestProps = {
152
+ classes: string;
153
+ testid: string;
154
+ theme?: Themes;
155
+ };
156
+
157
+ const attrObjToString = (attrs: Record<string, string>): string => {
158
+ const attrString = Object.keys(attrs).map((key) => {
159
+ return `${key}="${attrs[key]}"` || "";
160
+ });
161
+ return attrString.join(" ") || "";
162
+ };
163
+
164
+ const buildClasses = ({
165
+ baseClass,
166
+ prefixed = [],
167
+ unprefixed = [],
168
+ }: {
169
+ baseClass: string;
170
+ prefixed?: string[];
171
+ unprefixed?: string[];
172
+ }) =>
173
+ [
174
+ baseClass,
175
+ ...prefixed.filter((x) => x).map((suffix) => `${baseClass}__${suffix}`),
176
+ ...unprefixed.filter((x) => x),
177
+ ].join(" ");
178
+
179
+ const buildTestElement = ({
180
+ attributes = {},
181
+ children = "",
182
+ tag = "div",
183
+ testid,
184
+ }: {
185
+ attributes?: Record<string, string>;
186
+ children?: string;
187
+ tag?: string;
188
+ testid: string;
189
+ }) => {
190
+ const unsafe = {
191
+ tag: unsafeStatic(tag),
192
+ attributes: unsafeStatic(attrObjToString(attributes).toString()),
193
+ children: unsafeStatic(children),
194
+ };
195
+
196
+ return html`
197
+ <${unsafe.tag}
198
+ ${unsafe.attributes}
199
+ data-testid="${testid}"
200
+ >
201
+ ${unsafe.children}
202
+ </${unsafe.tag}>
203
+ `;
204
+ };
205
+
206
+ const buildTestid = (arr: string[]) => arr.filter(Boolean).join("-");
207
+
208
+ const getComponentTestVariations = ({
209
+ baseClass,
210
+ variants = [],
211
+ modifiers,
212
+ options = defaultOptions,
213
+ }: ComponentTestVariationArgs): ComponentTestProps[] => {
214
+ const testVariations: ComponentTestProps[] = [];
215
+ // Test default, high contrast themes
216
+ [...(options.testHighContrast ? baseThemes : [""])].forEach((baseTheme) => {
217
+ // Test light, dark theme
218
+ [...(options.testColorThemes ? colorThemes : [""])].forEach(
219
+ (colorTheme) => {
220
+ const theme = [baseTheme, colorTheme].filter(Boolean) as Themes;
221
+ const testidBase = buildTestid([baseClass, ...theme]);
222
+ const allVariants = options.includeNullVariant
223
+ ? ["", ...variants]
224
+ : variants;
225
+ const primaryModifiers = modifiers?.primary
226
+ ? options.includeNullModifier
227
+ ? ["", ...(<[]>modifiers.primary)]
228
+ : modifiers.primary
229
+ : [""];
230
+ const secondaryModifiers = modifiers?.secondary
231
+ ? ["", ...(<[]>modifiers.secondary)]
232
+ : [""];
233
+ const globalModifiers = modifiers?.global
234
+ ? ["", ...(<[]>modifiers.global)]
235
+ : [""];
236
+
237
+ primaryModifiers.forEach((primaryModifier) => {
238
+ secondaryModifiers.forEach((secondaryModifier) => {
239
+ globalModifiers.forEach((globalModifier) => {
240
+ allVariants.forEach((variant) => {
241
+ testVariations.push({
242
+ classes: buildClasses({
243
+ baseClass,
244
+ prefixed: [
245
+ variant,
246
+ primaryModifier,
247
+ secondaryModifier,
248
+ ],
249
+ unprefixed: [globalModifier],
250
+ }),
251
+ testid: buildTestid([
252
+ testidBase,
253
+ variant,
254
+ [
255
+ primaryModifier,
256
+ secondaryModifier,
257
+ globalModifier,
258
+ ]
259
+ .filter(Boolean)
260
+ .join("-"),
261
+ ]),
262
+ theme,
263
+ });
264
+ });
265
+ });
266
+ });
267
+ });
268
+
269
+ // create standalone modifiers test props
270
+ modifiers?.standalone?.forEach((standaloneModifier) => {
271
+ testVariations.push({
272
+ testid: buildTestid([testidBase, standaloneModifier]),
273
+ classes: buildClasses({
274
+ baseClass,
275
+ prefixed: [standaloneModifier],
276
+ }),
277
+ theme,
278
+ });
279
+ });
280
+ }
281
+ );
282
+ });
283
+
284
+ // Sorting for readability
285
+ return testVariations.sort((a, b) => a.testid.localeCompare(b.testid));
286
+ };
287
+
288
+ /**
289
+ * Constructs and runs an individual test for a component
290
+ */
291
+ const runComponentTest = ({
292
+ element,
293
+ testid,
294
+ theme,
295
+ type,
296
+ }: ComponentTestArgs) => {
297
+ const getDescription = (type: TestTypes) => {
298
+ switch (type) {
299
+ case "a11y":
300
+ return "should be accessible";
301
+ case "visual":
302
+ return "should not introduce visual regressions";
303
+ default:
304
+ return "";
305
+ }
306
+ };
307
+
308
+ it(`${type}: ${testid} ${getDescription(type)}`, async () => {
309
+ await fixture(element);
310
+ const el = screen.getByTestId(testid);
311
+
312
+ document.body.className = "";
313
+
314
+ if (theme?.length) {
315
+ const prefixedThemes = theme.map((t) => `theme-${t}`);
316
+ document.body.classList.add(...prefixedThemes);
317
+ }
318
+
319
+ if (type === "a11y") {
320
+ // TODO add conditional option for high contrast mode to test against AAA
321
+ await expect(el).to.be.accessible();
322
+ }
323
+
324
+ if (type === "visual") {
325
+ await visualDiff(el, testid);
326
+ }
327
+ });
328
+ };
329
+
330
+ /**
331
+ * Constructs and runs tests for a component with a each provided combination
332
+ */
333
+ const runComponentTests = ({
334
+ baseClass,
335
+ variants = [],
336
+ modifiers,
337
+ options = defaultOptions,
338
+ attributes,
339
+ children,
340
+ excludedTestids = [],
341
+ skippedTestids = [],
342
+ tag,
343
+ template,
344
+ type,
345
+ }: ComponentTestsArgs) => {
346
+ getComponentTestVariations({
347
+ baseClass,
348
+ variants,
349
+ modifiers,
350
+ options,
351
+ }).forEach(({ testid, classes, theme }) => {
352
+ const allChildren: {
353
+ [key: string]: string;
354
+ } = children ? { ...children } : { default: "" };
355
+ const { testidSuffix } = options;
356
+
357
+ Object.keys(allChildren).forEach((key) => {
358
+ let testidModified = (
359
+ key !== "default" ? `${testid}-${key}` : testid
360
+ ).replace(" ", "-");
361
+ testidModified = testidSuffix
362
+ ? `${testidModified}-${testidSuffix}`
363
+ : testidModified;
364
+
365
+ const children = allChildren[key];
366
+
367
+ const shouldSkipTest = excludeOrSkipTest({
368
+ patterns: skippedTestids,
369
+ skip: true,
370
+ testid: testidModified,
371
+ type,
372
+ });
373
+
374
+ const shouldExcludeTest = excludeOrSkipTest({
375
+ patterns: excludedTestids,
376
+ testid: testidModified,
377
+ type,
378
+ });
379
+
380
+ if (shouldSkipTest || shouldExcludeTest) {
381
+ return;
382
+ }
383
+
384
+ const element = template
385
+ ? html`${template({
386
+ testid: testidModified,
387
+ component: buildTestElement({
388
+ attributes: {
389
+ ...attributes,
390
+ class: `${classes} ${attributes?.class || ""}`,
391
+ },
392
+ children,
393
+ testid: `${testidModified}-nested`,
394
+ tag,
395
+ }),
396
+ })}`
397
+ : buildTestElement({
398
+ attributes: {
399
+ ...attributes,
400
+ class: `${classes} ${attributes?.class || ""}`,
401
+ },
402
+ children,
403
+ testid: testidModified,
404
+ tag,
405
+ });
406
+
407
+ runComponentTest({
408
+ element,
409
+ testid: testidModified,
410
+ theme,
411
+ type,
412
+ });
413
+ });
414
+ });
415
+ };
416
+
417
+ const matchTestidByPattern = ({
418
+ testid,
419
+ pattern,
420
+ }: {
421
+ testid: string;
422
+ pattern: string | RegExp;
423
+ }): boolean => {
424
+ if (pattern instanceof RegExp) {
425
+ return pattern.test(testid);
426
+ } else {
427
+ return pattern === testid;
428
+ }
429
+ };
430
+
431
+ const excludeOrSkipTest = ({
432
+ patterns,
433
+ skip = false,
434
+ testid,
435
+ type,
436
+ }: {
437
+ patterns: (string | RegExp)[];
438
+ skip?: boolean;
439
+ testid: string;
440
+ type: TestTypes;
441
+ }): boolean => {
442
+ const matchesTest = patterns.some((pattern) => {
443
+ return matchTestidByPattern({ testid, pattern });
444
+ });
445
+
446
+ if (matchesTest && skip) {
447
+ it.skip(`${type}: ${testid} (skipped)`, () => {
448
+ return;
449
+ });
450
+ }
451
+
452
+ return matchesTest;
453
+ };
454
+
455
+ export { runComponentTest, runComponentTests };
456
+
457
+ /**
458
+ * Convert a const array of strings into a union type of the array's values.
459
+ *
460
+ * @example
461
+ * ```
462
+ * const arrayOfStrings = ['Stacky', 'Ben', 'Dan', 'Giamir'] as const;
463
+ * type StringLiterals = AsLiterals<typeof arrayOfStrings>; // 'Stacky' | 'Ben' | 'Dan' | 'Giamir'
464
+ * ```
465
+ */
466
+ export type AsLiterals<T extends Readonly<string[]>> = T[number];
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "exclude": ["test/**/*.ts", "**/*.test.ts"]
4
+ }
package/lib/tsconfig.json CHANGED
@@ -1,13 +1,16 @@
1
- {
2
- "compilerOptions": {
3
- "strict": true,
4
- "target": "es6",
5
- "lib": ["dom", "es6", "dom.iterable", "scripthost"],
6
- "outDir": "../dist",
7
- "sourceMap": true,
8
- "moduleResolution": "node",
9
- "skipLibCheck": true,
10
- "declaration": true
11
- },
12
- "include": ["ts/**/*"]
13
- }
1
+ {
2
+ "compilerOptions": {
3
+ "strict": true,
4
+ "target": "es6",
5
+ "lib": ["dom", "es6", "dom.iterable", "scripthost"],
6
+ "outDir": "../dist",
7
+ "sourceMap": true,
8
+ "moduleResolution": "node",
9
+ "skipLibCheck": true,
10
+ "declaration": true,
11
+ "paths": {
12
+ "@open-wc/testing": ["./test/open-wc-testing-patch.d.ts"]
13
+ }
14
+ },
15
+ "include": ["**/*.ts"]
16
+ }