agroptima-design-system 0.34.10 → 0.34.11
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
|
@@ -29,7 +29,6 @@ export interface SelectProps extends InputPropsWithoutOnChange {
|
|
|
29
29
|
onChange?: (value: string) => void
|
|
30
30
|
isSearchable?: boolean
|
|
31
31
|
searchLabel?: string
|
|
32
|
-
isClereable?: boolean
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
const EMPTY_OPTION = { id: '', label: '' }
|
|
@@ -51,12 +50,11 @@ export function Select({
|
|
|
51
50
|
defaultValue,
|
|
52
51
|
isSearchable = false,
|
|
53
52
|
searchLabel = 'Search',
|
|
54
|
-
isClereable = true,
|
|
55
53
|
...props
|
|
56
54
|
}: SelectProps): React.JSX.Element {
|
|
57
55
|
const { isOpen, close, toggle } = useOpen()
|
|
58
56
|
const defaultOption =
|
|
59
|
-
options.find((option) => option.id === defaultValue) ||
|
|
57
|
+
options.find((option) => option.id === defaultValue) || EMPTY_OPTION
|
|
60
58
|
const [selectedOption, setSelectedOption] = useState<Option>(defaultOption)
|
|
61
59
|
const isEmpty = selectedOption.id === EMPTY_OPTION.id
|
|
62
60
|
const isInvalid = Boolean(errors?.length)
|
|
@@ -100,7 +98,6 @@ export function Select({
|
|
|
100
98
|
onClick={toggle}
|
|
101
99
|
onClear={handleClear}
|
|
102
100
|
isEmpty={isEmpty}
|
|
103
|
-
isClereable={isClereable}
|
|
104
101
|
>
|
|
105
102
|
{selectedOption.label || placeholder}
|
|
106
103
|
</SelectTrigger>
|
|
@@ -12,7 +12,6 @@ export interface SelectTriggerProps {
|
|
|
12
12
|
isEmpty: boolean
|
|
13
13
|
onClick: () => void
|
|
14
14
|
onClear: (event: React.MouseEvent) => void
|
|
15
|
-
isClereable?: boolean
|
|
16
15
|
children: React.ReactNode
|
|
17
16
|
}
|
|
18
17
|
|
|
@@ -25,7 +24,6 @@ export function SelectTrigger({
|
|
|
25
24
|
isOpen,
|
|
26
25
|
onClick,
|
|
27
26
|
onClear,
|
|
28
|
-
isClereable=true,
|
|
29
27
|
isEmpty,
|
|
30
28
|
children,
|
|
31
29
|
}: SelectTriggerProps) {
|
|
@@ -56,7 +54,7 @@ export function SelectTrigger({
|
|
|
56
54
|
visible={isEmpty}
|
|
57
55
|
/>
|
|
58
56
|
</button>
|
|
59
|
-
|
|
57
|
+
<IconButton
|
|
60
58
|
type="button"
|
|
61
59
|
size="3"
|
|
62
60
|
icon="Close"
|
|
@@ -64,7 +62,7 @@ export function SelectTrigger({
|
|
|
64
62
|
accessibilityLabel="clear"
|
|
65
63
|
onClick={handleClear}
|
|
66
64
|
visible={!isEmpty}
|
|
67
|
-
/>
|
|
65
|
+
/>
|
|
68
66
|
</div>
|
|
69
67
|
)
|
|
70
68
|
}
|
|
@@ -82,7 +82,6 @@ export const Primary: Story = {
|
|
|
82
82
|
accessibilityLabel: 'Select your favourite gaming system options',
|
|
83
83
|
hideLabel: false,
|
|
84
84
|
isSearchable: false,
|
|
85
|
-
isClereable: true,
|
|
86
85
|
placeholder: 'Select your favourite gaming system...',
|
|
87
86
|
options: [
|
|
88
87
|
{ id: '1', label: 'Nintendo Switch' },
|
|
@@ -121,7 +120,6 @@ export const PrimaryWithSelectedOptions: Story = {
|
|
|
121
120
|
hideLabel: false,
|
|
122
121
|
placeholder: 'Select your favourite gaming system...',
|
|
123
122
|
isSearchable: false,
|
|
124
|
-
isClereable: true,
|
|
125
123
|
options: [
|
|
126
124
|
{ id: '1', label: 'Nintendo Switch' },
|
|
127
125
|
{ id: '2', label: 'PlayStation 5' },
|
|
@@ -144,7 +142,6 @@ export const PrimaryWithErrors: Story = {
|
|
|
144
142
|
hideLabel: false,
|
|
145
143
|
placeholder: 'Select your favourite gaming system...',
|
|
146
144
|
isSearchable: false,
|
|
147
|
-
isClereable: true,
|
|
148
145
|
options: [
|
|
149
146
|
{ id: '1', label: 'Nintendo Switch' },
|
|
150
147
|
{ id: '2', label: 'PlayStation 5' },
|
|
@@ -190,7 +187,6 @@ export const PrimaryWithSearch: Story = {
|
|
|
190
187
|
id: 'select-videogames',
|
|
191
188
|
onChange: (optionId) => console.log('onChange optionId:', optionId),
|
|
192
189
|
isSearchable: true,
|
|
193
|
-
isClereable: true,
|
|
194
190
|
searchLabel: 'Search',
|
|
195
191
|
},
|
|
196
192
|
parameters: figmaPrimaryDesign,
|
package/tests/Select.spec.tsx
CHANGED
|
@@ -166,43 +166,4 @@ describe('Select', () => {
|
|
|
166
166
|
playstation5.label,
|
|
167
167
|
)
|
|
168
168
|
})
|
|
169
|
-
|
|
170
|
-
describe('when isClereable is false', () => {
|
|
171
|
-
it('hides deselect button', async () => {
|
|
172
|
-
const user = userEvent.setup()
|
|
173
|
-
|
|
174
|
-
render(
|
|
175
|
-
<Select
|
|
176
|
-
label="Videogames"
|
|
177
|
-
name="select-videogames"
|
|
178
|
-
isSearchable
|
|
179
|
-
disabled
|
|
180
|
-
defaultValue={playstation5.id}
|
|
181
|
-
options={OPTIONS}
|
|
182
|
-
isClereable={false}
|
|
183
|
-
/>,
|
|
184
|
-
)
|
|
185
|
-
|
|
186
|
-
expect(screen.queryByLabelText(/clear/i)).not.toBeInTheDocument()
|
|
187
|
-
})
|
|
188
|
-
|
|
189
|
-
it('renders first option by default if no other is passed', async () => {
|
|
190
|
-
const user = userEvent.setup()
|
|
191
|
-
|
|
192
|
-
render(
|
|
193
|
-
<Select
|
|
194
|
-
isClereable={false}
|
|
195
|
-
helpText="This text can help you"
|
|
196
|
-
label="Videogames"
|
|
197
|
-
name="videogames"
|
|
198
|
-
options={OPTIONS}
|
|
199
|
-
placeholder="Select your favourite gaming system..."
|
|
200
|
-
/>,
|
|
201
|
-
)
|
|
202
|
-
|
|
203
|
-
expect(screen.getByLabelText('Videogames')).toHaveTextContent(
|
|
204
|
-
'Nintendo Switch',
|
|
205
|
-
)
|
|
206
|
-
})
|
|
207
|
-
})
|
|
208
169
|
})
|