@charcoal-ui/react 3.7.0 → 3.9.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/dist/components/Button/StyledButton.d.ts +1 -0
- package/dist/components/Button/StyledButton.d.ts.map +1 -1
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.story.d.ts +16 -32
- package/dist/components/Button/index.story.d.ts.map +1 -1
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/ListItem/index.story.d.ts +7 -7
- package/dist/components/DropdownSelector/ListItem/index.story.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuList/index.story.d.ts +6 -9
- package/dist/components/DropdownSelector/MenuList/index.story.d.ts.map +1 -1
- package/dist/components/DropdownSelector/Popover/index.story.d.ts +3 -7
- package/dist/components/DropdownSelector/Popover/index.story.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.story.d.ts +9 -12
- package/dist/components/DropdownSelector/index.story.d.ts.map +1 -1
- package/dist/components/Icon/index.story.d.ts +4 -26
- package/dist/components/Icon/index.story.d.ts.map +1 -1
- package/dist/components/IconButton/index.d.ts +1 -0
- package/dist/components/IconButton/index.d.ts.map +1 -1
- package/dist/components/IconButton/index.story.d.ts +6 -25
- package/dist/components/IconButton/index.story.d.ts.map +1 -1
- package/dist/components/LoadingSpinner/LoadingSpinnerIcon.story.d.ts +8 -0
- package/dist/components/LoadingSpinner/LoadingSpinnerIcon.story.d.ts.map +1 -0
- package/dist/components/LoadingSpinner/index.d.ts +2 -2
- package/dist/components/LoadingSpinner/index.d.ts.map +1 -1
- package/dist/components/LoadingSpinner/index.story.d.ts +4 -7
- package/dist/components/LoadingSpinner/index.story.d.ts.map +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.story.d.ts +16 -41
- package/dist/components/Modal/index.story.d.ts.map +1 -1
- package/dist/components/Modal/useCustomModalOverlay.d.ts +12 -0
- package/dist/components/Modal/useCustomModalOverlay.d.ts.map +1 -0
- package/dist/components/MultiSelect/index.d.ts.map +1 -1
- package/dist/components/Radio/index.d.ts +0 -2
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/Radio/index.story.d.ts +12 -23
- package/dist/components/Radio/index.story.d.ts.map +1 -1
- package/dist/components/SegmentedControl/index.story.d.ts +5 -8
- package/dist/components/SegmentedControl/index.story.d.ts.map +1 -1
- package/dist/components/Switch/index.d.ts.map +1 -1
- package/dist/components/Switch/index.story.d.ts +7 -12
- package/dist/components/Switch/index.story.d.ts.map +1 -1
- package/dist/components/TagItem/index.d.ts.map +1 -1
- package/dist/components/TagItem/index.story.d.ts +14 -24
- package/dist/components/TagItem/index.story.d.ts.map +1 -1
- package/dist/components/TextArea/TextArea.story.d.ts +7 -25
- package/dist/components/TextArea/TextArea.story.d.ts.map +1 -1
- package/dist/components/TextArea/index.d.ts.map +1 -1
- package/dist/components/TextField/TextField.story.d.ts +14 -20
- package/dist/components/TextField/TextField.story.d.ts.map +1 -1
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/index.cjs.js +1006 -2240
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1001 -2241
- package/dist/index.esm.js.map +1 -1
- package/dist/styled.d.ts +4 -4
- package/package.json +7 -6
- package/src/components/Button/StyledButton.tsx +19 -14
- package/src/components/Button/__snapshots__/index.story.storyshot +314 -118
- package/src/components/Button/index.story.tsx +141 -138
- package/src/components/Button/index.tsx +3 -0
- package/src/components/Checkbox/__snapshots__/index.story.storyshot +55 -42
- package/src/components/Checkbox/index.tsx +15 -17
- package/src/components/Clickable/__snapshots__/index.story.storyshot +2 -2
- package/src/components/DropdownSelector/ListItem/__snapshots__/index.story.storyshot +42 -37
- package/src/components/DropdownSelector/ListItem/index.story.tsx +8 -4
- package/src/components/DropdownSelector/MenuList/__snapshots__/index.story.storyshot +38 -38
- package/src/components/DropdownSelector/MenuList/index.story.tsx +33 -27
- package/src/components/DropdownSelector/Popover/__snapshots__/index.story.storyshot +11 -5
- package/src/components/DropdownSelector/Popover/index.story.tsx +6 -6
- package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +148 -47
- package/src/components/DropdownSelector/index.story.tsx +207 -204
- package/src/components/DropdownSelector/index.tsx +17 -10
- package/src/components/Icon/__snapshots__/index.story.storyshot +1 -1
- package/src/components/Icon/index.story.tsx +8 -12
- package/src/components/IconButton/__snapshots__/index.story.storyshot +135 -13
- package/src/components/IconButton/index.story.tsx +30 -23
- package/src/components/IconButton/index.tsx +35 -20
- package/src/components/LoadingSpinner/LoadingSpinnerIcon.story.tsx +12 -0
- package/src/components/LoadingSpinner/__snapshots__/LoadingSpinnerIcon.story.storyshot +28 -0
- package/src/components/LoadingSpinner/__snapshots__/index.story.storyshot +1 -35
- package/src/components/LoadingSpinner/index.story.tsx +11 -54
- package/src/components/LoadingSpinner/index.tsx +1 -1
- package/src/components/Modal/__snapshots__/index.story.storyshot +224 -171
- package/src/components/Modal/index.story.tsx +139 -133
- package/src/components/Modal/index.tsx +15 -20
- package/src/components/Modal/useCustomModalOverlay.tsx +42 -0
- package/src/components/MultiSelect/__snapshots__/index.story.storyshot +56 -4
- package/src/components/MultiSelect/index.tsx +3 -0
- package/src/components/Radio/__snapshots__/index.story.storyshot +1001 -121
- package/src/components/Radio/index.story.tsx +128 -63
- package/src/components/Radio/index.tsx +15 -17
- package/src/components/SegmentedControl/__snapshots__/index.story.storyshot +2 -2
- package/src/components/SegmentedControl/index.story.tsx +24 -29
- package/src/components/Switch/__snapshots__/index.story.storyshot +184 -26
- package/src/components/Switch/index.story.tsx +72 -48
- package/src/components/Switch/index.tsx +2 -7
- package/src/components/TagItem/__snapshots__/index.story.storyshot +72 -33
- package/src/components/TagItem/index.story.tsx +154 -159
- package/src/components/TagItem/index.tsx +2 -6
- package/src/components/TextArea/TextArea.story.tsx +29 -32
- package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +127 -73
- package/src/components/TextArea/index.tsx +22 -14
- package/src/components/TextField/TextField.story.tsx +85 -64
- package/src/components/TextField/__snapshots__/TextField.story.storyshot +479 -167
- package/src/components/TextField/index.tsx +22 -21
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
2
|
import DropdownSelector, { DropdownSelectorProps } from '.'
|
|
3
|
-
import { Story } from '../../_lib/compat'
|
|
4
3
|
import { Divider } from './Divider'
|
|
5
4
|
import MenuItemGroup from './MenuItemGroup'
|
|
6
5
|
import DropdownMenuItem from './DropdownMenuItem'
|
|
@@ -8,11 +7,12 @@ import Modal from '../Modal'
|
|
|
8
7
|
import { ModalBody, ModalHeader } from '../Modal/ModalPlumbing'
|
|
9
8
|
import styled from 'styled-components'
|
|
10
9
|
import Button from '../Button'
|
|
10
|
+
import { Meta, StoryObj } from '@storybook/react'
|
|
11
11
|
|
|
12
12
|
export default {
|
|
13
13
|
title: 'DropdownSelector',
|
|
14
14
|
component: DropdownSelector,
|
|
15
|
-
}
|
|
15
|
+
} as Meta<typeof DropdownSelector>
|
|
16
16
|
|
|
17
17
|
const baseProps: DropdownSelectorProps = {
|
|
18
18
|
label: 'Label',
|
|
@@ -24,78 +24,36 @@ const baseProps: DropdownSelectorProps = {
|
|
|
24
24
|
children: <DropdownMenuItem value="item" />,
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export const Playground:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
<DropdownSelector
|
|
35
|
-
{...props}
|
|
36
|
-
onChange={(value) => {
|
|
37
|
-
setSelected(value)
|
|
38
|
-
}}
|
|
39
|
-
value={selected}
|
|
40
|
-
label="label"
|
|
41
|
-
>
|
|
42
|
-
{[...(Array(100) as undefined[])].map((_, i) => {
|
|
43
|
-
return (
|
|
44
|
-
<DropdownMenuItem key={i} value={i.toString()}>
|
|
45
|
-
{i}
|
|
46
|
-
</DropdownMenuItem>
|
|
47
|
-
)
|
|
48
|
-
})}
|
|
49
|
-
</DropdownSelector>
|
|
50
|
-
</div>
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
Playground.args = { ...baseProps }
|
|
55
|
-
|
|
56
|
-
export const Basic: Story<DropdownSelectorProps> = (
|
|
57
|
-
props: DropdownSelectorProps
|
|
58
|
-
) => {
|
|
59
|
-
return (
|
|
60
|
-
<div style={{ width: 288 }}>
|
|
61
|
-
<PlaygroundDropdownSelector {...props} />
|
|
62
|
-
</div>
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
Basic.args = { ...baseProps }
|
|
27
|
+
export const Playground: StoryObj<typeof DropdownSelector> = {
|
|
28
|
+
args: {
|
|
29
|
+
...baseProps,
|
|
30
|
+
},
|
|
31
|
+
render: (props) => {
|
|
32
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
33
|
+
const [selected, setSelected] = useState('50')
|
|
67
34
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
|
91
|
-
</DropdownMenuItem>
|
|
92
|
-
<DropdownMenuItem value={'30'}>
|
|
93
|
-
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
|
|
94
|
-
nisi ut aliquip ex ea commodo consequat.
|
|
95
|
-
</DropdownMenuItem>
|
|
96
|
-
</DropdownSelector>
|
|
97
|
-
</div>
|
|
98
|
-
)
|
|
35
|
+
return (
|
|
36
|
+
<div style={{ width: 288 }}>
|
|
37
|
+
<Button></Button>
|
|
38
|
+
<DropdownSelector
|
|
39
|
+
{...props}
|
|
40
|
+
onChange={(value) => {
|
|
41
|
+
setSelected(value)
|
|
42
|
+
}}
|
|
43
|
+
value={selected}
|
|
44
|
+
label="label"
|
|
45
|
+
>
|
|
46
|
+
{[...(Array(100) as undefined[])].map((_, i) => {
|
|
47
|
+
return (
|
|
48
|
+
<DropdownMenuItem key={i} value={i.toString()}>
|
|
49
|
+
{i}
|
|
50
|
+
</DropdownMenuItem>
|
|
51
|
+
)
|
|
52
|
+
})}
|
|
53
|
+
</DropdownSelector>
|
|
54
|
+
</div>
|
|
55
|
+
)
|
|
56
|
+
},
|
|
99
57
|
}
|
|
100
58
|
|
|
101
59
|
function PlaygroundDropdownSelector(props: Partial<DropdownSelectorProps>) {
|
|
@@ -116,6 +74,50 @@ function PlaygroundDropdownSelector(props: Partial<DropdownSelectorProps>) {
|
|
|
116
74
|
)
|
|
117
75
|
}
|
|
118
76
|
|
|
77
|
+
export const Basic: StoryObj<typeof DropdownSelector> = {
|
|
78
|
+
args: {
|
|
79
|
+
...baseProps,
|
|
80
|
+
},
|
|
81
|
+
render: (props) => (
|
|
82
|
+
<div style={{ width: 288 }}>
|
|
83
|
+
<PlaygroundDropdownSelector {...props} />
|
|
84
|
+
</div>
|
|
85
|
+
),
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const LongNames: StoryObj<typeof DropdownSelector> = {
|
|
89
|
+
render: function Render(args) {
|
|
90
|
+
const [selected, setSelected] = useState('10')
|
|
91
|
+
return (
|
|
92
|
+
<div
|
|
93
|
+
style={{
|
|
94
|
+
width: 288,
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
<DropdownSelector
|
|
98
|
+
{...args}
|
|
99
|
+
onChange={(value) => {
|
|
100
|
+
setSelected(value)
|
|
101
|
+
}}
|
|
102
|
+
value={selected}
|
|
103
|
+
label="label"
|
|
104
|
+
>
|
|
105
|
+
<DropdownMenuItem value={'10'}>
|
|
106
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
|
|
107
|
+
</DropdownMenuItem>
|
|
108
|
+
<DropdownMenuItem value={'20'}>
|
|
109
|
+
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
|
110
|
+
</DropdownMenuItem>
|
|
111
|
+
<DropdownMenuItem value={'30'}>
|
|
112
|
+
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
|
|
113
|
+
nisi ut aliquip ex ea commodo consequat.
|
|
114
|
+
</DropdownMenuItem>
|
|
115
|
+
</DropdownSelector>
|
|
116
|
+
</div>
|
|
117
|
+
)
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
|
|
119
121
|
const DummyBox = styled.div`
|
|
120
122
|
border: solid 1px ${({ theme }) => theme.border.default.color};
|
|
121
123
|
display: flex;
|
|
@@ -124,143 +126,144 @@ const DummyBox = styled.div`
|
|
|
124
126
|
height: 256px;
|
|
125
127
|
`
|
|
126
128
|
|
|
127
|
-
export const InModal:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
>
|
|
135
|
-
<button onClick={() => setOpen(true)}>open</button>
|
|
136
|
-
<Modal
|
|
137
|
-
bottomSheet="full"
|
|
138
|
-
title="modal"
|
|
139
|
-
isOpen={open}
|
|
140
|
-
isDismissable
|
|
141
|
-
onClose={() => {
|
|
142
|
-
setOpen(false)
|
|
129
|
+
export const InModal: StoryObj<typeof DropdownSelector> = {
|
|
130
|
+
render: function Render() {
|
|
131
|
+
const [open, setOpen] = useState(true)
|
|
132
|
+
return (
|
|
133
|
+
<div
|
|
134
|
+
style={{
|
|
135
|
+
height: '10px',
|
|
143
136
|
}}
|
|
144
137
|
>
|
|
145
|
-
<
|
|
146
|
-
<
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
138
|
+
<button onClick={() => setOpen(true)}>open</button>
|
|
139
|
+
<Modal
|
|
140
|
+
bottomSheet="full"
|
|
141
|
+
title="modal"
|
|
142
|
+
isOpen={open}
|
|
143
|
+
isDismissable
|
|
144
|
+
onClose={() => {
|
|
145
|
+
setOpen(false)
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
<ModalHeader />
|
|
149
|
+
<ModalBody>
|
|
150
|
+
<div
|
|
151
|
+
style={{
|
|
152
|
+
padding: '16px',
|
|
153
|
+
}}
|
|
154
|
+
>
|
|
155
|
+
<DummyBox>256px</DummyBox>
|
|
156
|
+
<PlaygroundDropdownSelector />
|
|
157
|
+
<DummyBox>256px</DummyBox>
|
|
158
|
+
<PlaygroundDropdownSelector />
|
|
159
|
+
<DummyBox>256px</DummyBox>
|
|
160
|
+
</div>
|
|
161
|
+
</ModalBody>
|
|
162
|
+
</Modal>
|
|
163
|
+
</div>
|
|
164
|
+
)
|
|
165
|
+
},
|
|
162
166
|
}
|
|
163
167
|
|
|
164
|
-
export const InFormTag:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
</
|
|
182
|
-
|
|
183
|
-
|
|
168
|
+
export const InFormTag: StoryObj<typeof DropdownSelector> = {
|
|
169
|
+
render: function Render(props) {
|
|
170
|
+
const [selected, setSelected] = useState('')
|
|
171
|
+
return (
|
|
172
|
+
<form style={{ width: 288 }}>
|
|
173
|
+
<DropdownSelector
|
|
174
|
+
{...props}
|
|
175
|
+
onChange={(value) => {
|
|
176
|
+
setSelected(value)
|
|
177
|
+
}}
|
|
178
|
+
value={selected}
|
|
179
|
+
label="label"
|
|
180
|
+
>
|
|
181
|
+
<DropdownMenuItem value={'10'}>Apple</DropdownMenuItem>
|
|
182
|
+
<DropdownMenuItem value={'20'}>Banana</DropdownMenuItem>
|
|
183
|
+
<DropdownMenuItem value={'30'}>Orange</DropdownMenuItem>
|
|
184
|
+
</DropdownSelector>
|
|
185
|
+
</form>
|
|
186
|
+
)
|
|
187
|
+
},
|
|
184
188
|
}
|
|
185
189
|
|
|
186
|
-
export const CustomChildren:
|
|
187
|
-
|
|
188
|
-
)
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
190
|
+
export const CustomChildren: StoryObj<typeof DropdownSelector> = {
|
|
191
|
+
args: { ...baseProps },
|
|
192
|
+
render: function Render(props) {
|
|
193
|
+
const [selected, setSelected] = useState('10')
|
|
194
|
+
return (
|
|
195
|
+
<div style={{ width: 288 }}>
|
|
196
|
+
<DropdownSelector
|
|
197
|
+
{...props}
|
|
198
|
+
onChange={(value) => {
|
|
199
|
+
setSelected(value)
|
|
200
|
+
}}
|
|
201
|
+
value={selected}
|
|
202
|
+
label="label"
|
|
203
|
+
>
|
|
204
|
+
<DropdownMenuItem value={'10'}>
|
|
205
|
+
<div
|
|
206
|
+
style={{
|
|
207
|
+
color: 'pink',
|
|
208
|
+
fontWeight: 'bold',
|
|
209
|
+
}}
|
|
210
|
+
>
|
|
211
|
+
Apple
|
|
212
|
+
</div>
|
|
213
|
+
</DropdownMenuItem>
|
|
214
|
+
<DropdownMenuItem value={'20'}>
|
|
215
|
+
<div
|
|
216
|
+
style={{
|
|
217
|
+
color: 'yellowgreen',
|
|
218
|
+
fontStyle: 'italic',
|
|
219
|
+
}}
|
|
220
|
+
>
|
|
221
|
+
Banana
|
|
222
|
+
</div>
|
|
223
|
+
</DropdownMenuItem>
|
|
224
|
+
<DropdownMenuItem value={'30'}>
|
|
225
|
+
<div
|
|
226
|
+
style={{
|
|
227
|
+
color: 'orange',
|
|
228
|
+
fontSize: '24px',
|
|
229
|
+
}}
|
|
230
|
+
>
|
|
231
|
+
Orange
|
|
232
|
+
</div>
|
|
233
|
+
</DropdownMenuItem>
|
|
234
|
+
</DropdownSelector>
|
|
235
|
+
</div>
|
|
236
|
+
)
|
|
237
|
+
},
|
|
233
238
|
}
|
|
234
239
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
<
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
)
|
|
240
|
+
export const SectionList: StoryObj<typeof DropdownSelector> = {
|
|
241
|
+
args: { ...baseProps },
|
|
242
|
+
render: function Render(props) {
|
|
243
|
+
const [selected, setSelected] = useState('10')
|
|
244
|
+
return (
|
|
245
|
+
<div style={{ width: 288 }}>
|
|
246
|
+
<DropdownSelector
|
|
247
|
+
{...props}
|
|
248
|
+
onChange={(value) => {
|
|
249
|
+
setSelected(value)
|
|
250
|
+
}}
|
|
251
|
+
value={selected}
|
|
252
|
+
label="label"
|
|
253
|
+
>
|
|
254
|
+
<MenuItemGroup text="fruits">
|
|
255
|
+
<DropdownMenuItem value={'10'}>Apple</DropdownMenuItem>
|
|
256
|
+
<DropdownMenuItem value={'20'}>Banana</DropdownMenuItem>
|
|
257
|
+
<DropdownMenuItem value={'30'}>Orange</DropdownMenuItem>
|
|
258
|
+
</MenuItemGroup>
|
|
259
|
+
<Divider />
|
|
260
|
+
<MenuItemGroup text="vehicle">
|
|
261
|
+
<DropdownMenuItem value={'40'}>bicycle</DropdownMenuItem>
|
|
262
|
+
<DropdownMenuItem value={'50'}>car</DropdownMenuItem>
|
|
263
|
+
<DropdownMenuItem value={'60'}>train</DropdownMenuItem>
|
|
264
|
+
</MenuItemGroup>
|
|
265
|
+
</DropdownSelector>
|
|
266
|
+
</div>
|
|
267
|
+
)
|
|
268
|
+
},
|
|
265
269
|
}
|
|
266
|
-
SectionList.args = { ...baseProps }
|
|
@@ -6,6 +6,7 @@ import FieldLabel from '../FieldLabel'
|
|
|
6
6
|
import { DropdownPopover } from './DropdownPopover'
|
|
7
7
|
import { findPreviewRecursive } from './utils/findPreviewRecursive'
|
|
8
8
|
import MenuList, { MenuListChildren } from './MenuList'
|
|
9
|
+
import { focusVisibleFocusRingCss } from '@charcoal-ui/styled'
|
|
9
10
|
|
|
10
11
|
export type DropdownSelectorProps = {
|
|
11
12
|
label: string
|
|
@@ -48,6 +49,7 @@ export default function DropdownSelector(props: DropdownSelectorProps) {
|
|
|
48
49
|
}}
|
|
49
50
|
ref={triggerRef}
|
|
50
51
|
type="button"
|
|
52
|
+
$active={isOpen}
|
|
51
53
|
>
|
|
52
54
|
<DropdownButtonText>
|
|
53
55
|
{props.placeholder !== undefined && preview === undefined
|
|
@@ -98,7 +100,7 @@ const DropdownFieldLabel = styled(FieldLabel)`
|
|
|
98
100
|
margin-bottom: 8px;
|
|
99
101
|
`
|
|
100
102
|
|
|
101
|
-
const DropdownButton = styled.button<{ invalid?: boolean }>`
|
|
103
|
+
const DropdownButton = styled.button<{ invalid?: boolean; $active?: boolean }>`
|
|
102
104
|
display: flex;
|
|
103
105
|
justify-content: space-between;
|
|
104
106
|
align-items: center;
|
|
@@ -123,15 +125,20 @@ const DropdownButton = styled.button<{ invalid?: boolean }>`
|
|
|
123
125
|
|
|
124
126
|
&:not(:disabled):not([aria-disabled]),
|
|
125
127
|
&[aria-disabled='false'] {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
${focusVisibleFocusRingCss}
|
|
129
|
+
${({ $active }) =>
|
|
130
|
+
$active === true
|
|
131
|
+
? css`
|
|
132
|
+
background-color: var(--charcoal-surface3-press);
|
|
133
|
+
`
|
|
134
|
+
: css`
|
|
135
|
+
&:hover {
|
|
136
|
+
background-color: var(--charcoal-surface3-hover);
|
|
137
|
+
}
|
|
138
|
+
&:active {
|
|
139
|
+
background-color: var(--charcoal-surface3-press);
|
|
140
|
+
}
|
|
141
|
+
`}
|
|
135
142
|
}
|
|
136
143
|
|
|
137
144
|
${({ invalid }) =>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Icon
|
|
1
|
+
import Icon from '.'
|
|
2
2
|
import { KNOWN_ICON_FILES } from '@charcoal-ui/icons'
|
|
3
|
-
import {
|
|
3
|
+
import { Meta, StoryObj } from '@storybook/react'
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
title: 'Icon',
|
|
@@ -19,14 +19,10 @@ export default {
|
|
|
19
19
|
},
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<Icon {...props} />
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
export const Default = Template.bind({})
|
|
22
|
+
args: {
|
|
23
|
+
name: KNOWN_ICON_FILES[0],
|
|
24
|
+
scale: 1,
|
|
25
|
+
},
|
|
26
|
+
} as Meta<typeof Icon>
|
|
31
27
|
|
|
32
|
-
|
|
28
|
+
export const Default: StoryObj<typeof Icon> = {}
|