agroptima-design-system 1.2.29-beta.0 → 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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agroptima-design-system",
3
- "version": "1.2.29-beta.0",
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
  }
@@ -38,6 +38,7 @@ import Import from './import.svg'
38
38
  import Improvements from './improvements.svg'
39
39
  import Info from './info.svg'
40
40
  import Invoice from './invoice.svg'
41
+ import Link from './link.svg'
41
42
  import Loading from './loading.svg'
42
43
  import Logout from './logout.svg'
43
44
  import Minus from './minus.svg'
@@ -72,7 +73,7 @@ import UserMenu from './user-menu.svg'
72
73
  import ValidateInvoice from './validate-invoice.svg'
73
74
  import Warning from './warning.svg'
74
75
 
75
- export {
76
+ export const icons = {
76
77
  Add,
77
78
  AddCircle,
78
79
  AngleDown,
@@ -113,6 +114,7 @@ export {
113
114
  Improvements,
114
115
  Info,
115
116
  Invoice,
117
+ Link,
116
118
  Loading,
117
119
  Logout,
118
120
  Minus,
@@ -146,4 +148,4 @@ export {
146
148
  UserMenu,
147
149
  ValidateInvoice,
148
150
  Warning,
149
- }
151
+ } as const
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 15H5c-1.383 0-2.563-.488-3.538-1.463C.488 12.563 0 11.383 0 10s.487-2.563 1.462-3.537C2.438 5.487 3.617 5 5 5h4v2H5c-.833 0-1.542.292-2.125.875A2.893 2.893 0 0 0 2 10c0 .833.292 1.542.875 2.125A2.893 2.893 0 0 0 5 13h4v2Zm-3-4V9h8v2H6Zm5 4v-2h4c.833 0 1.542-.292 2.125-.875A2.893 2.893 0 0 0 18 10c0-.833-.292-1.542-.875-2.125A2.893 2.893 0 0 0 15 7h-4V5h4c1.383 0 2.563.487 3.538 1.463C19.512 7.437 20 8.617 20 10s-.488 2.563-1.462 3.537C17.562 14.512 16.383 15 15 15h-4Z" fill="#161C26"/></svg>
@@ -6,7 +6,7 @@ import { Meta } from "@storybook/addon-docs/blocks";
6
6
 
7
7
  ## 1.2.28
8
8
 
9
- * Fix Collapsible styles not updating when closing a default-open collapsible
9
+ * Add Link icon
10
10
 
11
11
  ## 1.2.27
12
12
 
@@ -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
  })