agroptima-design-system 0.33.0-beta.2 → 0.33.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agroptima-design-system",
3
- "version": "0.33.0-beta.2",
3
+ "version": "0.33.0",
4
4
  "scripts": {
5
5
  "dev": "npm run storybook",
6
6
  "storybook": "storybook dev -p 6006 --ci",
@@ -87,7 +87,9 @@
87
87
  &:has(textarea:disabled) {
88
88
  border: 1px solid color_alias.$neutral-color-400;
89
89
  background: color_alias.$neutral-color-50;
90
- color: color_alias.$neutral-color-400;
90
+ input {
91
+ color: color_alias.$neutral-color-400;
92
+ }
91
93
 
92
94
  input::placeholder,
93
95
  textarea::placeholder {
@@ -67,7 +67,6 @@ export function Select({
67
67
  }
68
68
 
69
69
  function handleClear(event: React.MouseEvent) {
70
- if (disabled) return
71
70
  event.stopPropagation()
72
71
  setSelectedOption(EMPTY_OPTION)
73
72
  onChange('')
@@ -27,6 +27,10 @@ export function SelectTrigger({
27
27
  isEmpty,
28
28
  children,
29
29
  }: SelectTriggerProps) {
30
+ const handleClear = (event: React.MouseEvent) => {
31
+ if (disabled) return
32
+ onClear(event)
33
+ }
30
34
  return (
31
35
  <div className="select-container">
32
36
  <button
@@ -51,11 +55,12 @@ export function SelectTrigger({
51
55
  />
52
56
  </button>
53
57
  <IconButton
58
+ type="button"
54
59
  size="3"
55
60
  icon="Close"
56
61
  className="clear-button"
57
- accessibilityLabel="close"
58
- onClick={onClear}
62
+ accessibilityLabel="clear"
63
+ onClick={handleClear}
59
64
  visible={!isEmpty}
60
65
  />
61
66
  </div>
@@ -34,11 +34,11 @@
34
34
 
35
35
  &.primary {
36
36
  @include typography.body-regular-primary;
37
- border-bottom: 2px solid color_alias.$neutral-color-200;
37
+ border-bottom: 1px solid color_alias.$neutral-color-200;
38
38
 
39
39
  &:hover {
40
40
  color: color_alias.$primary-color-600;
41
- border-bottom: 2px solid color_alias.$primary-color-600;
41
+ border-bottom: 1px solid color_alias.$primary-color-600;
42
42
  }
43
43
 
44
44
  &.active {
@@ -48,7 +48,7 @@
48
48
 
49
49
  &.disabled {
50
50
  color: color_alias.$neutral-color-400;
51
- border-bottom: 2px solid color_alias.$neutral-color-200;
51
+ border-bottom: 1px solid color_alias.$neutral-color-200;
52
52
  }
53
53
  }
54
54
  }
@@ -63,7 +63,7 @@
63
63
  position: absolute;
64
64
  top: 28px;
65
65
  width: 100%;
66
- height: config.$space-halfx;
66
+ height: 1px;
67
67
  background-color: color_alias.$neutral-color-200;
68
68
  }
69
69
  }
@@ -8,6 +8,14 @@ import { Meta } from "@storybook/blocks";
8
8
 
9
9
  * Add TabMenu component
10
10
 
11
+ ## 0.32.3
12
+
13
+ * Fix send form when click on deselect button in Select component
14
+
15
+ ## 0.32.2
16
+
17
+ * Fix disabled color input
18
+
11
19
  ## 0.32.1
12
20
 
13
21
  * Add reason icon
@@ -2,7 +2,7 @@ import { render, screen } from '@testing-library/react'
2
2
  import userEvent from '@testing-library/user-event'
3
3
  import React from 'react'
4
4
  import { Multiselect } from '../src/atoms/Multiselect'
5
- import type { Option } from '../src/atoms/Select'
5
+ import { type Option, Select } from '../src/atoms/Select'
6
6
 
7
7
  const zelda = {
8
8
  id: '1',
@@ -112,7 +112,7 @@ describe('Multiselect', () => {
112
112
  />,
113
113
  )
114
114
 
115
- await user.click(screen.getByRole('button', { name: /close/i }))
115
+ await user.click(screen.getByRole('button', { name: /clear/i }))
116
116
 
117
117
  expect(getByText(placeholder)).toBeInTheDocument()
118
118
  expect(mockChange).toHaveBeenCalledWith([])
@@ -143,4 +143,46 @@ describe('Multiselect', () => {
143
143
  expect(queryByText('Spyro the Dragon')).not.toBeInTheDocument()
144
144
  expect(queryByText('Halo')).not.toBeInTheDocument()
145
145
  })
146
+
147
+ it('deselects when click on deselect button', async () => {
148
+ const user = userEvent.setup()
149
+ const placeholder = 'Select your favourite gaming system...'
150
+ const handleSubmit = jest.fn()
151
+
152
+ render(
153
+ <form onSubmit={handleSubmit}>
154
+ <Multiselect
155
+ label="Videogames"
156
+ name="select-videogames"
157
+ placeholder="Select your favourite gaming system..."
158
+ defaultValue={[zelda.id]}
159
+ options={OPTIONS}
160
+ />
161
+ </form>,
162
+ )
163
+
164
+ await user.click(screen.getByLabelText(/clear/i))
165
+
166
+ expect(screen.getByLabelText('Videogames')).toHaveTextContent(placeholder)
167
+ expect(handleSubmit).toHaveBeenCalledTimes(0)
168
+ })
169
+
170
+ it('disables deselect button when is disabled', async () => {
171
+ const user = userEvent.setup()
172
+ render(
173
+ <Multiselect
174
+ disabled
175
+ label="Videogames"
176
+ name="select-videogames"
177
+ defaultValue={[zelda.id]}
178
+ options={OPTIONS}
179
+ />,
180
+ )
181
+
182
+ await user.click(screen.getByLabelText(/clear/i))
183
+
184
+ expect(screen.getByLabelText('Videogames')).toHaveTextContent(
185
+ /1 items selected/i,
186
+ )
187
+ })
146
188
  })
@@ -100,7 +100,7 @@ describe('Select', () => {
100
100
  />,
101
101
  )
102
102
 
103
- await user.click(screen.getByRole('button', { name: /close/i }))
103
+ await user.click(screen.getByRole('button', { name: /clear/i }))
104
104
 
105
105
  expect(getByText(placeholder)).toBeInTheDocument()
106
106
  expect(mockChange).toHaveBeenCalledWith('')
@@ -124,4 +124,46 @@ describe('Select', () => {
124
124
  expect(queryByText('Nintendo Switch')).not.toBeInTheDocument()
125
125
  expect(queryByText('Xbox Series S/X')).not.toBeInTheDocument()
126
126
  })
127
+ it('deselects when click on deselect button', async () => {
128
+ const user = userEvent.setup()
129
+ const placeholder = 'Select your favourite gaming system...'
130
+ const handleSubmit = jest.fn()
131
+
132
+ render(
133
+ <form onSubmit={handleSubmit}>
134
+ <Select
135
+ label="Videogames"
136
+ name="select-videogames"
137
+ isSearchable
138
+ placeholder={placeholder}
139
+ defaultValue={playstation5.id}
140
+ options={OPTIONS}
141
+ />
142
+ </form>,
143
+ )
144
+
145
+ await user.click(screen.getByLabelText(/clear/i))
146
+
147
+ expect(screen.getByLabelText('Videogames')).toHaveTextContent(placeholder)
148
+ expect(handleSubmit).toHaveBeenCalledTimes(0)
149
+ })
150
+ it('disables deselect button when is disabled', async () => {
151
+ const user = userEvent.setup()
152
+ render(
153
+ <Select
154
+ label="Videogames"
155
+ name="select-videogames"
156
+ isSearchable
157
+ disabled
158
+ defaultValue={playstation5.id}
159
+ options={OPTIONS}
160
+ />,
161
+ )
162
+
163
+ await user.click(screen.getByLabelText(/clear/i))
164
+
165
+ expect(screen.getByLabelText('Videogames')).toHaveTextContent(
166
+ playstation5.label,
167
+ )
168
+ })
127
169
  })