@loadsmart/loadsmart-ui 5.5.0 → 5.6.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.
- package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +1 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.stories.d.ts +14 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.test.d.ts +1 -0
- package/dist/components/VisuallyHidden/index.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.js.map +1 -1
- package/package.json +3 -2
- package/src/@types/@loadsmart/{utils-function.d.ts → utilsFunction.d.ts} +0 -0
- package/src/@types/@loadsmart/{utils-object.d.ts → utilsObject.d.ts} +0 -0
- package/src/components/DragDropFile/components/DropZone.test.tsx +8 -0
- package/src/components/DragDropFile/components/DropZone.tsx +11 -9
- package/src/components/Select/Select.test.tsx +2 -2
- package/src/components/VisuallyHidden/VisuallyHidden.mdx +26 -0
- package/src/components/VisuallyHidden/VisuallyHidden.stories.tsx +32 -0
- package/src/components/VisuallyHidden/VisuallyHidden.test.tsx +18 -0
- package/src/components/VisuallyHidden/VisuallyHidden.tsx +6 -0
- package/src/components/VisuallyHidden/index.ts +1 -0
- package/src/index.ts +2 -0
- package/src/stories/{start-page.stories.mdx → startPage.stories.mdx} +0 -0
- package/src/testing/SelectEvent/SelectEvent.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loadsmart/loadsmart-ui",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.1",
|
|
4
4
|
"description": "Miranda UI, a React UI library",
|
|
5
5
|
"main": "dist",
|
|
6
6
|
"files": [
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"@svgr/rollup": "5.5.0",
|
|
99
99
|
"@svgr/webpack": "5.5.0",
|
|
100
100
|
"@tailwindcss/postcss7-compat": "2.1.2",
|
|
101
|
-
"@testing-library/jest-dom": "5.
|
|
101
|
+
"@testing-library/jest-dom": "5.16.5",
|
|
102
102
|
"@testing-library/react": "11.2.6",
|
|
103
103
|
"@testing-library/react-hooks": "5.1.2",
|
|
104
104
|
"@testing-library/user-event": "13.1.9",
|
|
@@ -110,6 +110,7 @@
|
|
|
110
110
|
"@types/lodash.isempty": "4.4.6",
|
|
111
111
|
"@types/lodash.omit": "4.5.6",
|
|
112
112
|
"@types/lodash.range": "3.2.6",
|
|
113
|
+
"@types/mdx": "^2.0.2",
|
|
113
114
|
"@types/react": "17.0.5",
|
|
114
115
|
"@types/react-dom": "17.0.3",
|
|
115
116
|
"@types/react-test-renderer": "17.0.1",
|
|
File without changes
|
|
File without changes
|
|
@@ -97,4 +97,12 @@ describe('<DragDropFile.DropZone />', () => {
|
|
|
97
97
|
|
|
98
98
|
expect(onFilesAdded).toHaveBeenCalledWith(filesMock)
|
|
99
99
|
})
|
|
100
|
+
|
|
101
|
+
it('does not call onFilesAdded when files are dropped in the drop zone and disabled is true', () => {
|
|
102
|
+
setup({ multiple: true, disabled: true })
|
|
103
|
+
|
|
104
|
+
DragDropFileEvent.dropFiles(getInput(), filesMock)
|
|
105
|
+
|
|
106
|
+
expect(onFilesAdded).not.toHaveBeenCalled()
|
|
107
|
+
})
|
|
100
108
|
})
|
|
@@ -39,11 +39,11 @@ const DropZone = ({
|
|
|
39
39
|
|
|
40
40
|
const onKeyPress = useCallback(
|
|
41
41
|
(event: React.KeyboardEvent) => {
|
|
42
|
-
if (inputRef.current && KeyboardKey(event).is('ENTER')) {
|
|
42
|
+
if (!disabled && inputRef.current && KeyboardKey(event).is('ENTER')) {
|
|
43
43
|
inputRef.current.click()
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
[inputRef]
|
|
46
|
+
[disabled, inputRef]
|
|
47
47
|
)
|
|
48
48
|
|
|
49
49
|
const onDrop = useCallback(
|
|
@@ -51,13 +51,15 @@ const DropZone = ({
|
|
|
51
51
|
event.preventDefault()
|
|
52
52
|
event.stopPropagation()
|
|
53
53
|
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
if (!disabled) {
|
|
55
|
+
if (isDragging) {
|
|
56
|
+
setIsDragging(false)
|
|
57
|
+
}
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
onFilesAdded(Array.from(event.dataTransfer.files || []))
|
|
60
|
+
}
|
|
59
61
|
},
|
|
60
|
-
[isDragging, onFilesAdded]
|
|
62
|
+
[disabled, isDragging, onFilesAdded]
|
|
61
63
|
)
|
|
62
64
|
|
|
63
65
|
const onDragStart = useCallback((event: React.DragEvent<HTMLDivElement>) => {
|
|
@@ -68,11 +70,11 @@ const DropZone = ({
|
|
|
68
70
|
(event: React.DragEvent<HTMLDivElement>) => {
|
|
69
71
|
event.preventDefault()
|
|
70
72
|
|
|
71
|
-
if (!isDragging) {
|
|
73
|
+
if (!disabled && !isDragging) {
|
|
72
74
|
setIsDragging(true)
|
|
73
75
|
}
|
|
74
76
|
},
|
|
75
|
-
[isDragging]
|
|
77
|
+
[disabled, isDragging]
|
|
76
78
|
)
|
|
77
79
|
|
|
78
80
|
const onDragLeave = useCallback(
|
|
@@ -517,7 +517,7 @@ describe('Select', () => {
|
|
|
517
517
|
|
|
518
518
|
it.each([[{ multiple: true }], [{ multiple: false }]])(
|
|
519
519
|
'overrides the empty component with %s',
|
|
520
|
-
(props) => {
|
|
520
|
+
async (props) => {
|
|
521
521
|
const Empty = () => {
|
|
522
522
|
return <Select.Empty data-testid="custom-empty">No fruit found.</Select.Empty>
|
|
523
523
|
}
|
|
@@ -530,7 +530,7 @@ describe('Select', () => {
|
|
|
530
530
|
target: { value: 'foo' },
|
|
531
531
|
})
|
|
532
532
|
|
|
533
|
-
expect(screen.
|
|
533
|
+
expect(await screen.findByTestId('custom-empty')).toHaveTextContent('No fruit found.')
|
|
534
534
|
}
|
|
535
535
|
)
|
|
536
536
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# VisuallyHidden
|
|
2
|
+
|
|
3
|
+
Use this component to visually hide elements but keep them accessible to assistive technologies.
|
|
4
|
+
|
|
5
|
+
Visually hide an element while still allowing it to be exposed to assistive technologies (such as screen readers) with `VisuallyHidden`.
|
|
6
|
+
This would typically be used when you want to take advantage of the behavior and semantics of a native element like a checkbox or radio button, but replace it with a custom styled element visually.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import { VisuallyHidden } from '@loadsmart/loadsmart-ui'
|
|
12
|
+
|
|
13
|
+
const Example = () => (
|
|
14
|
+
<Layout.Stack>
|
|
15
|
+
<Text as="p">
|
|
16
|
+
Bellow you can't see the text, but assistive technologies can. Try to use devtools to
|
|
17
|
+
inspect this element.
|
|
18
|
+
</Text>
|
|
19
|
+
<Text as="p">
|
|
20
|
+
<VisuallyHidden>
|
|
21
|
+
This text is invisible but accessible by assistive technologies
|
|
22
|
+
</VisuallyHidden>
|
|
23
|
+
</Text>
|
|
24
|
+
</Layout.Stack>
|
|
25
|
+
)
|
|
26
|
+
```
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Layout } from 'components/Layout'
|
|
2
|
+
import { Text } from 'components/Text'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
import { VisuallyHidden } from '.'
|
|
6
|
+
import Docs from './VisuallyHidden.mdx'
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Components/VisuallyHidden',
|
|
10
|
+
component: VisuallyHidden,
|
|
11
|
+
parameters: {
|
|
12
|
+
docs: {
|
|
13
|
+
page: Docs,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function Playground(): JSX.Element {
|
|
19
|
+
return (
|
|
20
|
+
<Layout.Stack className="p-10 bg-neutral-dark w-60 text-center">
|
|
21
|
+
<Text color="color-neutral-white" as="p">
|
|
22
|
+
Bellow you can't see the text, but assistive technologies can. Try to use devtools to
|
|
23
|
+
inspect this element.
|
|
24
|
+
</Text>
|
|
25
|
+
<Text color="color-neutral-white" as="p">
|
|
26
|
+
<VisuallyHidden>
|
|
27
|
+
This text is invisible but accessible by assistive technologies
|
|
28
|
+
</VisuallyHidden>
|
|
29
|
+
</Text>
|
|
30
|
+
</Layout.Stack>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { screen } from '@testing-library/react'
|
|
3
|
+
|
|
4
|
+
import renderer from '../../../tests/renderer'
|
|
5
|
+
|
|
6
|
+
import hiddenStyle from 'styles/hidden'
|
|
7
|
+
import { VisuallyHidden } from './VisuallyHidden'
|
|
8
|
+
|
|
9
|
+
describe('VisuallyHidden', () => {
|
|
10
|
+
it('should render children accessibly', () => {
|
|
11
|
+
const children = 'Should not be visible'
|
|
12
|
+
const expectedHiddenStyle = hiddenStyle(true).replace(/!important/g, '')
|
|
13
|
+
|
|
14
|
+
renderer(<VisuallyHidden>{children}</VisuallyHidden>).render()
|
|
15
|
+
|
|
16
|
+
expect(screen.getByText(children)).toHaveStyle(expectedHiddenStyle)
|
|
17
|
+
})
|
|
18
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { VisuallyHidden } from './VisuallyHidden'
|
package/src/index.ts
CHANGED
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
import { queries, waitFor, within } from '@testing-library/dom'
|
|
2
|
+
import { fireEvent, queries, waitFor, within } from '@testing-library/dom'
|
|
3
3
|
import { act } from '@testing-library/react'
|
|
4
4
|
import userEvent from '@testing-library/user-event'
|
|
5
5
|
|
|
@@ -152,7 +152,7 @@ async function search(query: string, input: HTMLElement): Promise<void> {
|
|
|
152
152
|
const selectContainer = getReactSelectContainerFromInput(input)
|
|
153
153
|
|
|
154
154
|
await act(async () => {
|
|
155
|
-
|
|
155
|
+
fireEvent.change(input, { target: { value: query } })
|
|
156
156
|
|
|
157
157
|
await queries.findAllByRole(selectContainer, 'option')
|
|
158
158
|
})
|