agroptima-design-system 1.2.29 → 1.2.30-beta.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.
@@ -0,0 +1,7 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(git rev-list *)"
5
+ ]
6
+ }
7
+ }
@@ -17,7 +17,7 @@ jobs:
17
17
  # Setup .npmrc file to publish to npm
18
18
  - uses: actions/setup-node@v6
19
19
  with:
20
- node-version: 'lts/*'
20
+ node-version: '20.x'
21
21
  registry-url: 'https://registry.npmjs.org'
22
22
 
23
23
  # Ensure npm 11.5.1 or later is installed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agroptima-design-system",
3
- "version": "1.2.29",
3
+ "version": "1.2.30-beta.0",
4
4
  "scripts": {
5
5
  "dev": "npm run storybook",
6
6
  "storybook": "storybook dev -p 6006 --ci",
@@ -27,7 +27,8 @@ export function Collapsible({
27
27
  onToggle,
28
28
  ...props
29
29
  }: CollapsibleProps) {
30
- const [isOpen, setIsOpen] = useState(controlledOpen ?? false)
30
+ const [expanded, setExpanded] = useState(false)
31
+ const isOpen = controlledOpen !== undefined ? controlledOpen : expanded
31
32
 
32
33
  const cssClasses = classNames('collapsible', variant, className, {
33
34
  open: isOpen,
@@ -45,7 +46,7 @@ export function Collapsible({
45
46
  className={cssClasses}
46
47
  aria-label={title}
47
48
  onToggle={(e) => {
48
- setIsOpen(e.currentTarget.open)
49
+ if (controlledOpen === undefined) setExpanded(e.currentTarget.open)
49
50
  onToggle?.(e)
50
51
  }}
51
52
  {...props}
@@ -1,6 +1,6 @@
1
1
  import './Icon.scss'
2
2
  import type { ReactNode } from 'react'
3
- import * as icons from '../icons'
3
+ import { icons } from '../icons'
4
4
  import { classNames } from '../utils/classNames'
5
5
  export type IconType = keyof typeof icons
6
6
 
@@ -33,10 +33,12 @@ export const Icon: React.FC<IconProps> = ({
33
33
  rotate: name === 'Loading',
34
34
  })
35
35
 
36
+ const IconComponent = icons[name]
37
+
36
38
  if (decorative) {
37
39
  return (
38
40
  <span aria-hidden="true" className={cssClasses}>
39
- {icons[name](props) as ReactNode}
41
+ {IconComponent ? ((<IconComponent {...props} />) as ReactNode) : null}
40
42
  </span>
41
43
  )
42
44
  }
@@ -48,7 +50,7 @@ export const Icon: React.FC<IconProps> = ({
48
50
  title={accessibilityLabel || name}
49
51
  className={cssClasses}
50
52
  >
51
- {icons[name](props) as ReactNode}
53
+ {IconComponent ? ((<IconComponent {...props} />) as ReactNode) : null}
52
54
  </span>
53
55
  )
54
56
  }
@@ -73,7 +73,7 @@ import UserMenu from './user-menu.svg'
73
73
  import ValidateInvoice from './validate-invoice.svg'
74
74
  import Warning from './warning.svg'
75
75
 
76
- export {
76
+ export const icons = {
77
77
  Add,
78
78
  AddCircle,
79
79
  AngleDown,
@@ -148,4 +148,4 @@ export {
148
148
  UserMenu,
149
149
  ValidateInvoice,
150
150
  Warning,
151
- }
151
+ } as const
@@ -4,10 +4,6 @@ import { Meta } from "@storybook/addon-docs/blocks";
4
4
 
5
5
  # Changelog
6
6
 
7
- ## 1.2.29
8
-
9
- * Fix Collapsible styles not updating when closing a default-open collapsible
10
-
11
7
  ## 1.2.28
12
8
 
13
9
  * Add Link icon
@@ -1,5 +1,5 @@
1
1
  import { Meta, Title, IconGallery, IconItem } from '@storybook/addon-docs/blocks'
2
- import * as Icons from '../icons'
2
+ import { icons } from '../icons'
3
3
 
4
4
  <Meta title="Design System/Styles/Icons" tags={['Styles', 'Documentation','!Components']} />
5
5
 
@@ -11,7 +11,7 @@ import * as Icons from '../icons'
11
11
 
12
12
  <IconGallery>
13
13
  {
14
- Object.values(Icons).map((Icon) => {
14
+ Object.values(icons).map((Icon) => {
15
15
  return(
16
16
  <IconItem name={Icon['name'].substring(3)}>
17
17
  <Icon />
@@ -1,5 +1,4 @@
1
- import { render, waitFor } from '@testing-library/react'
2
- import userEvent from '@testing-library/user-event'
1
+ import { render } from '@testing-library/react'
3
2
  import React from 'react'
4
3
  import { Collapsible } from '../src/atoms/Collapsible'
5
4
  import { Input } from '../src/atoms/Input'
@@ -25,50 +24,4 @@ describe('Collapsible', () => {
25
24
  expect(getByRole('textbox')).toBeInTheDocument()
26
25
  expect(getByRole('group')).toHaveClass(`collapsible primary open`)
27
26
  })
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
- })
74
27
  })