@faststore/ui 1.5.17 → 1.5.20
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/CHANGELOG.md +30 -0
- package/dist/ui.cjs.development.js +16 -8
- package/dist/ui.cjs.development.js.map +1 -1
- package/dist/ui.cjs.production.min.js +1 -1
- package/dist/ui.cjs.production.min.js.map +1 -1
- package/dist/ui.esm.js +17 -9
- package/dist/ui.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/molecules/Breadcrumb/Breadcrumb.test.tsx +36 -0
- package/src/molecules/Breadcrumb/Breadcrumb.tsx +27 -13
- package/src/molecules/Breadcrumb/stories/Breadcrumb.mdx +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/ui",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.20",
|
|
4
4
|
"description": "A lightweight, framework agnostic component library for React",
|
|
5
5
|
"author": "emersonlaurentino",
|
|
6
6
|
"license": "MIT",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@types/jest-axe": "^3.5.3",
|
|
77
77
|
"@types/tabbable": "^3.1.1",
|
|
78
78
|
"@types/testing-library__jest-dom": "^5.9.5",
|
|
79
|
-
"@vtex/theme-b2c-tailwind": "^1.5.
|
|
79
|
+
"@vtex/theme-b2c-tailwind": "^1.5.20",
|
|
80
80
|
"@vtex/tsconfig": "^0.5.0",
|
|
81
81
|
"chalk": "^5.0.0",
|
|
82
82
|
"jest-axe": "^5.0.1",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"tsdx": "^0.14.1",
|
|
90
90
|
"typescript": "^4.2.4"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "0f87dc9b1c6f7b3c99a666a15a8433a42907ebd0"
|
|
93
93
|
}
|
|
@@ -60,6 +60,41 @@ describe('Breadcrumb', () => {
|
|
|
60
60
|
}
|
|
61
61
|
})
|
|
62
62
|
|
|
63
|
+
it('renders an <ol> with valid HTML as children (only <li>s)', () => {
|
|
64
|
+
const { getByRole } = render(
|
|
65
|
+
<Breadcrumb divider="/">
|
|
66
|
+
<a href="/office">Office</a>
|
|
67
|
+
<a href="/office/chairs">Chairs</a>
|
|
68
|
+
</Breadcrumb>
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
const listItems = getByRole('list').children
|
|
72
|
+
|
|
73
|
+
for (const item of Array.from(listItems)) {
|
|
74
|
+
expect(item.nodeName).toEqual('LI')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
expect(listItems).toHaveLength(2)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('renders `n - 1` dividers, where `n` is the number of list items', () => {
|
|
81
|
+
const { queryAllByText } = render(
|
|
82
|
+
<Breadcrumb divider={<span>~</span>}>
|
|
83
|
+
<a href="/office">Office</a>
|
|
84
|
+
<a href="/office/chairs">Chairs</a>
|
|
85
|
+
<a href="/office/chairs/tulip">Tulip</a>
|
|
86
|
+
</Breadcrumb>
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
const dividers = queryAllByText('~')
|
|
90
|
+
|
|
91
|
+
for (const divider of Array.from(dividers)) {
|
|
92
|
+
expect(divider).toHaveAttribute('aria-hidden', 'true')
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
expect(dividers).toHaveLength(2)
|
|
96
|
+
})
|
|
97
|
+
|
|
63
98
|
it('AXE Test', async () => {
|
|
64
99
|
render(
|
|
65
100
|
<Breadcrumb aria-label="test modal" divider="/">
|
|
@@ -70,5 +105,6 @@ describe('Breadcrumb', () => {
|
|
|
70
105
|
)
|
|
71
106
|
|
|
72
107
|
expect(await axe(document.body)).toHaveNoViolations()
|
|
108
|
+
expect(await axe(document.body)).toHaveNoIncompletes()
|
|
73
109
|
})
|
|
74
110
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
2
|
import type { FC, HTMLAttributes, ReactNode } from 'react'
|
|
3
3
|
|
|
4
4
|
import List from '../../atoms/List'
|
|
@@ -31,10 +31,16 @@ const Divider: FC<BreadcrumbProps> = ({ divider, testId }) => {
|
|
|
31
31
|
type ListItemProps = {
|
|
32
32
|
children: ReactNode
|
|
33
33
|
isLastItem: boolean
|
|
34
|
+
divider: BreadcrumbProps['divider']
|
|
34
35
|
testId: string
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
const ListItem: FC<ListItemProps> = ({
|
|
38
|
+
const ListItem: FC<ListItemProps> = ({
|
|
39
|
+
children,
|
|
40
|
+
isLastItem,
|
|
41
|
+
divider,
|
|
42
|
+
testId,
|
|
43
|
+
}) => {
|
|
38
44
|
const props = {
|
|
39
45
|
'data-testid': `${testId}-item`,
|
|
40
46
|
'data-breadcrumb-item': isLastItem ? 'current' : true,
|
|
@@ -43,13 +49,21 @@ const ListItem: FC<ListItemProps> = ({ children, isLastItem, testId }) => {
|
|
|
43
49
|
|
|
44
50
|
if (!React.isValidElement(children)) {
|
|
45
51
|
return (
|
|
46
|
-
<li>
|
|
47
|
-
<span {...props}>
|
|
52
|
+
<li data-breadcrumb-list-item>
|
|
53
|
+
<span {...props}>
|
|
54
|
+
{children}
|
|
55
|
+
{isLastItem ? null : <Divider divider={divider} testId={testId} />}
|
|
56
|
+
</span>
|
|
48
57
|
</li>
|
|
49
58
|
)
|
|
50
59
|
}
|
|
51
60
|
|
|
52
|
-
return
|
|
61
|
+
return (
|
|
62
|
+
<li data-breadcrumb-list-item>
|
|
63
|
+
{React.cloneElement(children, props)}
|
|
64
|
+
{isLastItem ? null : <Divider divider={divider} testId={testId} />}
|
|
65
|
+
</li>
|
|
66
|
+
)
|
|
53
67
|
}
|
|
54
68
|
|
|
55
69
|
const Breadcrumb = forwardRef<HTMLDivElement, BreadcrumbProps>(
|
|
@@ -78,14 +92,14 @@ const Breadcrumb = forwardRef<HTMLDivElement, BreadcrumbProps>(
|
|
|
78
92
|
const isLastItem = index === lastIndex - 1
|
|
79
93
|
|
|
80
94
|
return (
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
{
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
</
|
|
95
|
+
<ListItem
|
|
96
|
+
isLastItem={isLastItem}
|
|
97
|
+
divider={rawDivider}
|
|
98
|
+
key={`breadcrumb-${index}`}
|
|
99
|
+
testId={testId}
|
|
100
|
+
>
|
|
101
|
+
{child}
|
|
102
|
+
</ListItem>
|
|
89
103
|
)
|
|
90
104
|
})}
|
|
91
105
|
</List>
|