agroptima-design-system 1.2.28-beta.1 → 1.2.29
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/package.json
CHANGED
|
@@ -27,8 +27,7 @@ export function Collapsible({
|
|
|
27
27
|
onToggle,
|
|
28
28
|
...props
|
|
29
29
|
}: CollapsibleProps) {
|
|
30
|
-
const [
|
|
31
|
-
const isOpen = controlledOpen !== undefined ? controlledOpen : expanded
|
|
30
|
+
const [isOpen, setIsOpen] = useState(controlledOpen ?? false)
|
|
32
31
|
|
|
33
32
|
const cssClasses = classNames('collapsible', variant, className, {
|
|
34
33
|
open: isOpen,
|
|
@@ -46,7 +45,7 @@ export function Collapsible({
|
|
|
46
45
|
className={cssClasses}
|
|
47
46
|
aria-label={title}
|
|
48
47
|
onToggle={(e) => {
|
|
49
|
-
|
|
48
|
+
setIsOpen(e.currentTarget.open)
|
|
50
49
|
onToggle?.(e)
|
|
51
50
|
}}
|
|
52
51
|
{...props}
|
package/src/icons/index.tsx
CHANGED
|
@@ -29,7 +29,6 @@ import Download from './download.svg'
|
|
|
29
29
|
import Duplicate from './duplicate.svg'
|
|
30
30
|
import Edit from './edit.svg'
|
|
31
31
|
import EditColumns from './edit-columns.svg'
|
|
32
|
-
import Link from './link.svg'
|
|
33
32
|
import ElectronicInvoice from './electronic-invoice.svg'
|
|
34
33
|
import EmptyState from './empty-customize.svg'
|
|
35
34
|
import Error from './error.svg'
|
|
@@ -39,6 +38,7 @@ import Import from './import.svg'
|
|
|
39
38
|
import Improvements from './improvements.svg'
|
|
40
39
|
import Info from './info.svg'
|
|
41
40
|
import Invoice from './invoice.svg'
|
|
41
|
+
import Link from './link.svg'
|
|
42
42
|
import Loading from './loading.svg'
|
|
43
43
|
import Logout from './logout.svg'
|
|
44
44
|
import Minus from './minus.svg'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { render } from '@testing-library/react'
|
|
1
|
+
import { render, waitFor } from '@testing-library/react'
|
|
2
|
+
import userEvent from '@testing-library/user-event'
|
|
2
3
|
import React from 'react'
|
|
3
4
|
import { Collapsible } from '../src/atoms/Collapsible'
|
|
4
5
|
import { Input } from '../src/atoms/Input'
|
|
@@ -24,4 +25,50 @@ describe('Collapsible', () => {
|
|
|
24
25
|
expect(getByRole('textbox')).toBeInTheDocument()
|
|
25
26
|
expect(getByRole('group')).toHaveClass(`collapsible primary open`)
|
|
26
27
|
})
|
|
28
|
+
|
|
29
|
+
it('removes the open styles when a default-open collapsible is closed', async () => {
|
|
30
|
+
const user = userEvent.setup()
|
|
31
|
+
const { getByRole } = render(
|
|
32
|
+
<Collapsible title="My personal data" name="personal-data" open>
|
|
33
|
+
<Input
|
|
34
|
+
accessibilityLabel="Fill the form name"
|
|
35
|
+
id="name_input"
|
|
36
|
+
label="Name"
|
|
37
|
+
name="name"
|
|
38
|
+
type="name"
|
|
39
|
+
variant="primary"
|
|
40
|
+
/>
|
|
41
|
+
</Collapsible>,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
const group = getByRole('group')
|
|
45
|
+
expect(group).toHaveClass('open')
|
|
46
|
+
|
|
47
|
+
await user.click(group.querySelector('summary')!)
|
|
48
|
+
|
|
49
|
+
await waitFor(() => expect(group).not.toHaveClass('open'))
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('adds the open styles when a closed collapsible is opened', async () => {
|
|
53
|
+
const user = userEvent.setup()
|
|
54
|
+
const { getByRole } = render(
|
|
55
|
+
<Collapsible title="My personal data" name="personal-data">
|
|
56
|
+
<Input
|
|
57
|
+
accessibilityLabel="Fill the form name"
|
|
58
|
+
id="name_input"
|
|
59
|
+
label="Name"
|
|
60
|
+
name="name"
|
|
61
|
+
type="name"
|
|
62
|
+
variant="primary"
|
|
63
|
+
/>
|
|
64
|
+
</Collapsible>,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
const group = getByRole('group')
|
|
68
|
+
expect(group).not.toHaveClass('open')
|
|
69
|
+
|
|
70
|
+
await user.click(group.querySelector('summary')!)
|
|
71
|
+
|
|
72
|
+
await waitFor(() => expect(group).toHaveClass('open'))
|
|
73
|
+
})
|
|
27
74
|
})
|