@charcoal-ui/react 3.6.0 → 3.8.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/_lib/compat.d.ts +1 -0
- package/dist/_lib/compat.d.ts.map +1 -1
- package/dist/components/Button/StyledButton.d.ts +13 -0
- package/dist/components/Button/StyledButton.d.ts.map +1 -0
- package/dist/components/Button/index.d.ts +3 -2
- 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/Button/lib/variantToBackground.d.ts +3 -0
- package/dist/components/Button/lib/variantToBackground.d.ts.map +1 -0
- package/dist/components/Button/lib/variantToFont.d.ts +3 -0
- package/dist/components/Button/lib/variantToFont.d.ts.map +1 -0
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.story.d.ts +6 -16
- package/dist/components/Checkbox/index.story.d.ts.map +1 -1
- package/dist/components/Clickable/index.story.d.ts +4 -6
- package/dist/components/Clickable/index.story.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 -11
- 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.story.d.ts +16 -41
- package/dist/components/Modal/index.story.d.ts.map +1 -1
- 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/RadioGroupContext.d.ts +1 -1
- package/dist/components/SegmentedControl/RadioGroupContext.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/TextField/TextField.story.d.ts +13 -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 +418 -206
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +387 -175
- package/dist/index.esm.js.map +1 -1
- package/dist/styled.d.ts +4 -4
- package/package.json +17 -20
- package/src/_lib/compat.ts +8 -0
- package/src/components/Button/StyledButton.tsx +71 -0
- 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 +15 -104
- package/src/components/Button/lib/variantToBackground.tsx +19 -0
- package/src/components/Button/lib/variantToFont.tsx +19 -0
- package/src/components/Checkbox/__snapshots__/index.story.storyshot +12 -27
- package/src/components/Checkbox/index.story.tsx +82 -88
- package/src/components/Checkbox/index.tsx +2 -12
- package/src/components/Clickable/__snapshots__/index.story.storyshot +2 -2
- package/src/components/Clickable/index.story.tsx +12 -9
- package/src/components/DropdownSelector/DropdownMenuItem.tsx +1 -14
- 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 +313 -151
- package/src/components/DropdownSelector/index.story.tsx +207 -171
- package/src/components/DropdownSelector/index.tsx +22 -22
- 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 +130 -13
- package/src/components/IconButton/index.story.tsx +30 -23
- package/src/components/IconButton/index.tsx +32 -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 +231 -194
- package/src/components/Modal/index.story.tsx +139 -133
- 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 +981 -121
- package/src/components/Radio/index.story.tsx +128 -63
- package/src/components/Radio/index.tsx +10 -16
- package/src/components/SegmentedControl/RadioGroupContext.tsx +1 -1
- package/src/components/SegmentedControl/__snapshots__/index.story.storyshot +11 -11
- package/src/components/SegmentedControl/index.story.tsx +24 -29
- package/src/components/SegmentedControl/index.tsx +1 -1
- 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 +139 -83
- package/src/components/TextField/TextField.story.tsx +67 -66
- package/src/components/TextField/__snapshots__/TextField.story.storyshot +198 -162
- package/src/components/TextField/index.tsx +0 -7
- package/dist/components/Checkbox/performance.test.d.ts +0 -4
- package/dist/components/Checkbox/performance.test.d.ts.map +0 -1
- package/dist/components/Checkbox/snapshot.test.d.ts +0 -2
- package/dist/components/Checkbox/snapshot.test.d.ts.map +0 -1
- package/src/components/Checkbox/__snapshots__/snapshot.test.tsx.snap +0 -1093
- package/src/components/Checkbox/performance.test.tsx +0 -30
- package/src/components/Checkbox/snapshot.test.tsx +0 -66
|
@@ -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,47 +24,38 @@ 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 }
|
|
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')
|
|
55
34
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
+
},
|
|
64
57
|
}
|
|
65
58
|
|
|
66
|
-
Basic.args = { ...baseProps }
|
|
67
|
-
|
|
68
59
|
function PlaygroundDropdownSelector(props: Partial<DropdownSelectorProps>) {
|
|
69
60
|
const [selected, setSelected] = useState('10')
|
|
70
61
|
return (
|
|
@@ -83,6 +74,50 @@ function PlaygroundDropdownSelector(props: Partial<DropdownSelectorProps>) {
|
|
|
83
74
|
)
|
|
84
75
|
}
|
|
85
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
|
+
|
|
86
121
|
const DummyBox = styled.div`
|
|
87
122
|
border: solid 1px ${({ theme }) => theme.border.default.color};
|
|
88
123
|
display: flex;
|
|
@@ -91,143 +126,144 @@ const DummyBox = styled.div`
|
|
|
91
126
|
height: 256px;
|
|
92
127
|
`
|
|
93
128
|
|
|
94
|
-
export const InModal:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
>
|
|
102
|
-
<button onClick={() => setOpen(true)}>open</button>
|
|
103
|
-
<Modal
|
|
104
|
-
bottomSheet="full"
|
|
105
|
-
title="modal"
|
|
106
|
-
isOpen={open}
|
|
107
|
-
isDismissable
|
|
108
|
-
onClose={() => {
|
|
109
|
-
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',
|
|
110
136
|
}}
|
|
111
137
|
>
|
|
112
|
-
<
|
|
113
|
-
<
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
+
},
|
|
129
166
|
}
|
|
130
167
|
|
|
131
|
-
export const InFormTag:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
</
|
|
149
|
-
|
|
150
|
-
|
|
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
|
+
},
|
|
151
188
|
}
|
|
152
189
|
|
|
153
|
-
export const CustomChildren:
|
|
154
|
-
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
+
},
|
|
200
238
|
}
|
|
201
239
|
|
|
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
|
-
)
|
|
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
|
+
},
|
|
232
269
|
}
|
|
233
|
-
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;
|
|
@@ -108,6 +110,7 @@ const DropdownButton = styled.button<{ invalid?: boolean }>`
|
|
|
108
110
|
box-sizing: border-box;
|
|
109
111
|
border: none;
|
|
110
112
|
cursor: pointer;
|
|
113
|
+
gap: 4px;
|
|
111
114
|
|
|
112
115
|
${disabledSelector} {
|
|
113
116
|
cursor: default;
|
|
@@ -118,16 +121,24 @@ const DropdownButton = styled.button<{ invalid?: boolean }>`
|
|
|
118
121
|
background-color: var(--charcoal-surface3);
|
|
119
122
|
border-radius: 4px;
|
|
120
123
|
|
|
121
|
-
transition: 0.2s box-shadow;
|
|
124
|
+
transition: 0.2s box-shadow, 0.2s background-color;
|
|
122
125
|
|
|
123
126
|
&:not(:disabled):not([aria-disabled]),
|
|
124
127
|
&[aria-disabled='false'] {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
+
`}
|
|
131
142
|
}
|
|
132
143
|
|
|
133
144
|
${({ invalid }) =>
|
|
@@ -146,20 +157,9 @@ const DropdownButtonText = styled.span`
|
|
|
146
157
|
line-height: 22px;
|
|
147
158
|
display: flow-root;
|
|
148
159
|
color: var(--charcoal-text2);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
height: 0;
|
|
153
|
-
content: '';
|
|
154
|
-
margin-top: -4px;
|
|
155
|
-
}
|
|
156
|
-
&::after {
|
|
157
|
-
display: block;
|
|
158
|
-
width: 0;
|
|
159
|
-
height: 0;
|
|
160
|
-
content: '';
|
|
161
|
-
margin-bottom: -4px;
|
|
162
|
-
}
|
|
160
|
+
overflow: hidden;
|
|
161
|
+
text-overflow: ellipsis;
|
|
162
|
+
white-space: nowrap;
|
|
163
163
|
`
|
|
164
164
|
|
|
165
165
|
const DropdownButtonIcon = styled(Icon)`
|
|
@@ -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> = {}
|