@charcoal-ui/react 3.13.1 → 3.14.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.
Files changed (30) hide show
  1. package/dist/components/Switch/index.d.ts.map +1 -1
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js.map +1 -1
  4. package/package.json +8 -8
  5. package/src/README.mdx +68 -0
  6. package/src/SSR.mdx +67 -0
  7. package/src/_lib/index.ts +1 -1
  8. package/src/components/Button/__snapshots__/index.story.storyshot +9 -9
  9. package/src/components/Checkbox/__snapshots__/index.story.storyshot +6 -6
  10. package/src/components/Clickable/__snapshots__/index.story.storyshot +2 -2
  11. package/src/components/DropdownSelector/ListItem/__snapshots__/index.story.storyshot +1 -1
  12. package/src/components/DropdownSelector/MenuList/__snapshots__/index.story.storyshot +23 -23
  13. package/src/components/DropdownSelector/Popover/__snapshots__/index.story.storyshot +1 -1
  14. package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +14 -14
  15. package/src/components/Icon/__snapshots__/index.story.storyshot +1 -1
  16. package/src/components/IconButton/__snapshots__/index.story.storyshot +3 -3
  17. package/src/components/LoadingSpinner/__snapshots__/index.story.storyshot +4 -4
  18. package/src/components/Modal/index.story.tsx +5 -0
  19. package/src/components/MultiSelect/__snapshots__/index.story.storyshot +4 -4
  20. package/src/components/MultiSelect/index.test.tsx +6 -5
  21. package/src/components/Radio/__snapshots__/index.story.storyshot +5 -5
  22. package/src/components/Radio/index.test.tsx +4 -3
  23. package/src/components/SegmentedControl/__snapshots__/index.story.storyshot +2 -2
  24. package/src/components/Switch/__snapshots__/index.story.storyshot +4 -4
  25. package/src/components/Switch/index.tsx +0 -1
  26. package/src/components/TagItem/__snapshots__/index.story.storyshot +8 -8
  27. package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +11 -11
  28. package/src/components/TextField/__snapshots__/TextField.story.storyshot +13 -13
  29. package/src/components/Modal/__snapshots__/index.story.storyshot +0 -4091
  30. package/src/components/a11y.test.tsx +0 -99
@@ -1,99 +0,0 @@
1
- import path from 'path'
2
- import * as glob from 'glob'
3
- import { axe, toHaveNoViolations } from 'jest-axe'
4
- import { render } from '@testing-library/react'
5
- import { ThemeProvider } from 'styled-components'
6
- import { Story } from '../_lib/compat'
7
- import ComponentAbstraction, { DefaultLink } from '../core/ComponentAbstraction'
8
- import { light, dark } from '@charcoal-ui/theme'
9
-
10
- expect.extend(toHaveNoViolations)
11
-
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- interface StoryWithMetadata<ArgsType = any> {
14
- filename: string
15
- name: string
16
- story: Story<ArgsType>
17
- args: ArgsType
18
- }
19
-
20
- const stories: StoryWithMetadata[] = glob
21
- .sync(path.resolve(__dirname, '**/*.story.tsx'))
22
- .flatMap((filePath) => {
23
- // eslint-disable-next-line @typescript-eslint/no-var-requires
24
- const exports = require(`./${path.relative(
25
- __dirname,
26
- filePath
27
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
- )}`) as Record<string, any>
29
-
30
- return Object.entries(exports)
31
- .filter(
32
- ([exportName, exportValue]) =>
33
- exportName !== 'default' && typeof exportValue === 'function'
34
- )
35
- .map(([exportName, exportValue]) => ({
36
- filename: path.relative(__dirname, filePath),
37
- name: exportName,
38
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
- story: exportValue as Story<any>,
40
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
41
- args: { ...exports.default.args, ...exportValue.args },
42
- }))
43
- })
44
-
45
- const themes = Object.entries({
46
- light,
47
- dark,
48
- })
49
-
50
- const links = Object.entries({
51
- DefaultLink,
52
- })
53
-
54
- const div = document.body.appendChild(document.createElement('div'))
55
-
56
- beforeEach(() => {
57
- global.IntersectionObserver = jest.fn().mockImplementation(() => ({
58
- observe() {
59
- return null
60
- },
61
- disconnect() {
62
- return null
63
- },
64
- }))
65
-
66
- global.matchMedia = jest.fn().mockImplementation(() => ({
67
- matches: true,
68
- media: '(max-width: 600px)',
69
- addEventListener() {
70
- // Do Nothing
71
- },
72
- removeEventListener() {
73
- // Do Nothing
74
- },
75
- }))
76
- })
77
-
78
- describe.each(themes)('using %s theme', (_name, theme) => {
79
- describe.each(links)('using %s component', (_name, link) => {
80
- describe.each(stories)(
81
- 'storiesOf($filename).add($name)',
82
- ({ story: Story, args }) => {
83
- it('has no accessibility violations', async () => {
84
- expect(() => {
85
- render(
86
- <ThemeProvider theme={theme}>
87
- <ComponentAbstraction components={{ Link: link }}>
88
- <Story {...args} />
89
- </ComponentAbstraction>
90
- </ThemeProvider>
91
- )
92
- }).not.toThrow()
93
-
94
- expect(await axe(div)).toHaveNoViolations()
95
- })
96
- }
97
- )
98
- })
99
- })