agroptima-design-system 1.2.30-beta.0 → 1.2.30
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/.github/workflows/publish-package-to-npmjs.yml +1 -1
- package/package.json +1 -1
- package/src/atoms/Button/BaseButton.tsx +1 -2
- package/src/atoms/Collapsible/Collapsible.tsx +2 -3
- package/src/atoms/Modal/Modal.tsx +1 -6
- package/src/stories/Changelog.mdx +8 -0
- package/tests/Collapsible.spec.tsx +48 -1
- package/.claude/settings.local.json +0 -7
package/package.json
CHANGED
|
@@ -13,8 +13,7 @@ type HtmlButtonProps = ButtonHTMLAttributes<HTMLButtonElement>
|
|
|
13
13
|
type AnchorProps = AnchorHTMLAttributes<HTMLAnchorElement> & LinkProps
|
|
14
14
|
|
|
15
15
|
export type BaseButtonProps =
|
|
16
|
-
| (
|
|
17
|
-
| (AnchorProps & CommonProps)
|
|
16
|
+
(HtmlButtonProps & CommonProps) | (AnchorProps & CommonProps)
|
|
18
17
|
|
|
19
18
|
const hasHref = (
|
|
20
19
|
props: HtmlButtonProps | AnchorProps,
|
|
@@ -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}
|
|
@@ -13,12 +13,7 @@ import {
|
|
|
13
13
|
} from '.'
|
|
14
14
|
|
|
15
15
|
export type Variant =
|
|
16
|
-
| '
|
|
17
|
-
| 'success'
|
|
18
|
-
| 'warning'
|
|
19
|
-
| 'error'
|
|
20
|
-
| 'discard'
|
|
21
|
-
| 'details'
|
|
16
|
+
'info' | 'success' | 'warning' | 'error' | 'discard' | 'details'
|
|
22
17
|
|
|
23
18
|
export interface ModalProps {
|
|
24
19
|
id: string
|
|
@@ -4,6 +4,14 @@ import { Meta } from "@storybook/addon-docs/blocks";
|
|
|
4
4
|
|
|
5
5
|
# Changelog
|
|
6
6
|
|
|
7
|
+
## 1.2.30
|
|
8
|
+
|
|
9
|
+
* Fix Webpack icons exports bug
|
|
10
|
+
|
|
11
|
+
## 1.2.29
|
|
12
|
+
|
|
13
|
+
* Fix Collapsible styles not updating when closing a default-open collapsible
|
|
14
|
+
|
|
7
15
|
## 1.2.28
|
|
8
16
|
|
|
9
17
|
* Add Link icon
|
|
@@ -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
|
})
|