@charcoal-ui/react 2.7.0 → 2.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/DropdownSelector/index.story.d.ts.map +1 -1
- package/dist/components/LoadingSpinner/index.d.ts.map +1 -1
- package/dist/components/Modal/index.d.ts +5 -2
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/SegmentedControl/index.d.ts.map +1 -1
- package/dist/components/SegmentedControl/index.story.d.ts.map +1 -1
- package/dist/index.cjs.js +52 -27
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +52 -27
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
- package/src/components/DropdownSelector/index.story.tsx +4 -1
- package/src/components/LoadingSpinner/index.tsx +1 -0
- package/src/components/Modal/index.tsx +79 -61
- package/src/components/Radio/index.tsx +2 -0
- package/src/components/SegmentedControl/index.story.tsx +2 -0
- package/src/components/SegmentedControl/index.tsx +1 -0
- package/src/components/TextField/index.tsx +1 -0
- package/src/index.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@charcoal-ui/react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"typescript": "^4.9.5"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@charcoal-ui/icons": "^2.
|
|
53
|
-
"@charcoal-ui/styled": "^2.
|
|
54
|
-
"@charcoal-ui/theme": "^2.
|
|
55
|
-
"@charcoal-ui/utils": "^2.
|
|
52
|
+
"@charcoal-ui/icons": "^2.9.0",
|
|
53
|
+
"@charcoal-ui/styled": "^2.9.0",
|
|
54
|
+
"@charcoal-ui/theme": "^2.9.0",
|
|
55
|
+
"@charcoal-ui/utils": "^2.9.0",
|
|
56
56
|
"@react-aria/button": "^3.7.0",
|
|
57
57
|
"@react-aria/checkbox": "^3.8.0",
|
|
58
58
|
"@react-aria/dialog": "^3.5.0",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"url": "https://github.com/pixiv/charcoal.git",
|
|
89
89
|
"directory": "packages/react"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "37a14b2a014a752fe20c358eb5d35e0e74063805"
|
|
92
92
|
}
|
|
@@ -47,6 +47,7 @@ export const Sections: Story<DropdownSelectorProps> = (props) => {
|
|
|
47
47
|
<div>
|
|
48
48
|
<DropdownSelector
|
|
49
49
|
{...props}
|
|
50
|
+
label="sections"
|
|
50
51
|
placeholder={'Drop Down menu'}
|
|
51
52
|
onChange={action('change')}
|
|
52
53
|
onOpenChange={action('open')}
|
|
@@ -68,6 +69,7 @@ export const Bottom: Story<DropdownSelectorProps> = (props) => {
|
|
|
68
69
|
<div style={{ marginTop: '1000px' }}>
|
|
69
70
|
<DropdownSelector
|
|
70
71
|
{...props}
|
|
72
|
+
label="bottom"
|
|
71
73
|
placeholder={'Drop Down menu'}
|
|
72
74
|
onChange={action('change')}
|
|
73
75
|
onOpenChange={action('open')}
|
|
@@ -86,6 +88,7 @@ export const Many: Story<DropdownSelectorProps> = (props) => {
|
|
|
86
88
|
<div style={{ padding: '300px 100px' }}>
|
|
87
89
|
<DropdownSelector
|
|
88
90
|
{...props}
|
|
91
|
+
label="many"
|
|
89
92
|
placeholder={'Drop Down menu'}
|
|
90
93
|
onChange={(v) => {
|
|
91
94
|
setValue(v.toString())
|
|
@@ -181,7 +184,7 @@ type InvalidProps = {
|
|
|
181
184
|
}
|
|
182
185
|
export const Invalid: Story<InvalidProps> = ({ disabled }) => {
|
|
183
186
|
const props: Omit<DropdownSelectorProps, 'children'> = {
|
|
184
|
-
label: '',
|
|
187
|
+
label: 'invalid',
|
|
185
188
|
assertiveText: 'error message',
|
|
186
189
|
invalid: true,
|
|
187
190
|
}
|
|
@@ -18,13 +18,16 @@ import { animated, useTransition, easings } from 'react-spring'
|
|
|
18
18
|
import Button, { ButtonProps } from '../Button'
|
|
19
19
|
import IconButton from '../IconButton'
|
|
20
20
|
|
|
21
|
+
type BottomSheet = boolean | 'full'
|
|
22
|
+
type Size = 'S' | 'M' | 'L'
|
|
23
|
+
|
|
21
24
|
export type ModalProps = AriaModalOverlayProps &
|
|
22
25
|
AriaDialogProps & {
|
|
23
26
|
children: React.ReactNode
|
|
24
27
|
zIndex?: number
|
|
25
28
|
title: string
|
|
26
|
-
size?:
|
|
27
|
-
bottomSheet?:
|
|
29
|
+
size?: Size
|
|
30
|
+
bottomSheet?: BottomSheet
|
|
28
31
|
isOpen: boolean
|
|
29
32
|
onClose: () => void
|
|
30
33
|
|
|
@@ -133,28 +136,30 @@ export default function Modal({
|
|
|
133
136
|
style={transitionEnabled ? { backgroundColor } : {}}
|
|
134
137
|
>
|
|
135
138
|
<FocusScope contain restoreFocus autoFocus>
|
|
136
|
-
<
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
<ModalContext.Provider
|
|
146
|
-
value={{ titleProps, title, close: onClose, showDismiss }}
|
|
139
|
+
<DialogContainer bottomSheet={bottomSheet} size={size}>
|
|
140
|
+
<ModalDialog
|
|
141
|
+
ref={ref}
|
|
142
|
+
{...overlayProps}
|
|
143
|
+
{...modalProps}
|
|
144
|
+
{...dialogProps}
|
|
145
|
+
style={transitionEnabled ? { transform } : {}}
|
|
146
|
+
size={size}
|
|
147
|
+
bottomSheet={bottomSheet}
|
|
147
148
|
>
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
149
|
+
<ModalContext.Provider
|
|
150
|
+
value={{ titleProps, title, close: onClose, showDismiss }}
|
|
151
|
+
>
|
|
152
|
+
{children}
|
|
153
|
+
{isDismissable === true && (
|
|
154
|
+
<ModalCrossButton
|
|
155
|
+
size="S"
|
|
156
|
+
icon="24/Close"
|
|
157
|
+
onClick={onClose}
|
|
158
|
+
/>
|
|
159
|
+
)}
|
|
160
|
+
</ModalContext.Provider>
|
|
161
|
+
</ModalDialog>
|
|
162
|
+
</DialogContainer>
|
|
158
163
|
</FocusScope>
|
|
159
164
|
</ModalBackground>
|
|
160
165
|
</Overlay>
|
|
@@ -176,6 +181,8 @@ const ModalContext = React.createContext<{
|
|
|
176
181
|
|
|
177
182
|
const ModalBackground = animated(styled.div<{ zIndex: number }>`
|
|
178
183
|
z-index: ${({ zIndex }) => zIndex};
|
|
184
|
+
overflow: scroll;
|
|
185
|
+
display: flex;
|
|
179
186
|
position: fixed;
|
|
180
187
|
top: 0;
|
|
181
188
|
left: 0;
|
|
@@ -185,50 +192,61 @@ const ModalBackground = animated(styled.div<{ zIndex: number }>`
|
|
|
185
192
|
${theme((o) => [o.bg.surface4])}
|
|
186
193
|
`)
|
|
187
194
|
|
|
195
|
+
const DialogContainer = styled.div<{ bottomSheet: BottomSheet; size: Size }>`
|
|
196
|
+
position: relative;
|
|
197
|
+
margin: auto;
|
|
198
|
+
padding: 24px 0;
|
|
199
|
+
width: ${(p) => {
|
|
200
|
+
switch (p.size) {
|
|
201
|
+
case 'S': {
|
|
202
|
+
return columnSystem(3, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2
|
|
203
|
+
}
|
|
204
|
+
case 'M': {
|
|
205
|
+
return columnSystem(4, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2
|
|
206
|
+
}
|
|
207
|
+
case 'L': {
|
|
208
|
+
return columnSystem(6, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2
|
|
209
|
+
}
|
|
210
|
+
default: {
|
|
211
|
+
return unreachable(p.size)
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}}px;
|
|
215
|
+
|
|
216
|
+
@media ${({ theme }) => maxWidth(theme.breakpoint.screen1)} {
|
|
217
|
+
width: calc(100% - 48px);
|
|
218
|
+
${(p) =>
|
|
219
|
+
p.bottomSheet !== false &&
|
|
220
|
+
css`
|
|
221
|
+
margin: 0;
|
|
222
|
+
padding: 0;
|
|
223
|
+
bottom: 0;
|
|
224
|
+
position: absolute;
|
|
225
|
+
width: 100%;
|
|
226
|
+
${p.bottomSheet === 'full' ? 'height: 100%' : ''};
|
|
227
|
+
`}
|
|
228
|
+
}
|
|
229
|
+
`
|
|
230
|
+
|
|
188
231
|
const ModalDialog = animated(styled.div<{
|
|
189
|
-
size:
|
|
190
|
-
bottomSheet:
|
|
232
|
+
size: Size
|
|
233
|
+
bottomSheet: BottomSheet
|
|
191
234
|
}>`
|
|
192
|
-
position:
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
transform: translate(-50%, -50%);
|
|
196
|
-
width: ${(p) =>
|
|
197
|
-
p.size === 'S'
|
|
198
|
-
? columnSystem(3, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2
|
|
199
|
-
: p.size === 'M'
|
|
200
|
-
? columnSystem(4, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2
|
|
201
|
-
: // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
202
|
-
p.size === 'L'
|
|
203
|
-
? columnSystem(6, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2
|
|
204
|
-
: unreachable(p.size)}px;
|
|
235
|
+
position: relative;
|
|
236
|
+
margin: auto;
|
|
237
|
+
padding: 24px 0;
|
|
205
238
|
|
|
206
239
|
${theme((o) => [o.bg.background1, o.borderRadius(24)])}
|
|
207
|
-
|
|
208
240
|
@media ${({ theme }) => maxWidth(theme.breakpoint.screen1)} {
|
|
209
241
|
${(p) =>
|
|
210
|
-
p.bottomSheet
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
height: 100%;
|
|
219
|
-
`
|
|
220
|
-
: p.bottomSheet
|
|
221
|
-
? css`
|
|
222
|
-
top: auto;
|
|
223
|
-
bottom: 0;
|
|
224
|
-
left: 0;
|
|
225
|
-
transform: none;
|
|
226
|
-
border-radius: 0;
|
|
227
|
-
width: 100%;
|
|
228
|
-
`
|
|
229
|
-
: css`
|
|
230
|
-
width: calc(100% - 48px);
|
|
231
|
-
`}
|
|
242
|
+
p.bottomSheet !== false &&
|
|
243
|
+
css`
|
|
244
|
+
border-radius: 0;
|
|
245
|
+
${p.bottomSheet === 'full' &&
|
|
246
|
+
css`
|
|
247
|
+
height: 100%;
|
|
248
|
+
`}
|
|
249
|
+
`}
|
|
232
250
|
}
|
|
233
251
|
`)
|
|
234
252
|
|
|
@@ -13,6 +13,7 @@ export const StringSegments: Story<SegmentedControlProps> = (props) => {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
StringSegments.args = {
|
|
16
|
+
name: 'test',
|
|
16
17
|
data: ['option1', 'option2', 'option3'],
|
|
17
18
|
disabled: false,
|
|
18
19
|
readonly: false,
|
|
@@ -24,6 +25,7 @@ export const ObjectSegments: Story<SegmentedControlProps> = (props) => {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
ObjectSegments.args = {
|
|
28
|
+
name: 'test',
|
|
27
29
|
data: [
|
|
28
30
|
{ label: '選択肢1', value: 'option1' },
|
|
29
31
|
{ label: '選択肢2', value: 'option2' },
|
package/src/index.ts
CHANGED
|
@@ -52,11 +52,12 @@ export {
|
|
|
52
52
|
} from './components/LoadingSpinner'
|
|
53
53
|
export {
|
|
54
54
|
default as DropdownSelector,
|
|
55
|
+
type DropdownSelectorProps,
|
|
55
56
|
DropdownSelectorItem,
|
|
56
57
|
} from './components/DropdownSelector'
|
|
57
58
|
export {
|
|
58
59
|
default as SegmentedControl,
|
|
59
60
|
type SegmentedControlProps,
|
|
60
61
|
} from './components/SegmentedControl'
|
|
61
|
-
export { default as Checkbox } from './components/Checkbox'
|
|
62
|
+
export { default as Checkbox, type CheckboxProps } from './components/Checkbox'
|
|
62
63
|
export { default as TagItem, type TagItemProps } from './components/TagItem'
|