@charcoal-ui/react 2.0.0-rc.2 → 2.0.1
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/Modal/index.d.ts +4 -2
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/index.cjs +113 -18437
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +186 -17465
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +177 -18483
- package/dist/index.module.js.map +1 -1
- package/package.json +8 -7
- package/src/components/Modal/index.story.tsx +5 -5
- package/src/components/Modal/index.tsx +27 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@charcoal-ui/react",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -48,15 +48,15 @@
|
|
|
48
48
|
"typescript": "^4.5.5"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@charcoal-ui/icons": "^2.0.
|
|
52
|
-
"@charcoal-ui/styled": "^2.0.
|
|
53
|
-
"@charcoal-ui/theme": "^2.0.
|
|
54
|
-
"@charcoal-ui/utils": "^2.0.
|
|
51
|
+
"@charcoal-ui/icons": "^2.0.1",
|
|
52
|
+
"@charcoal-ui/styled": "^2.0.1",
|
|
53
|
+
"@charcoal-ui/theme": "^2.0.1",
|
|
54
|
+
"@charcoal-ui/utils": "^2.0.1",
|
|
55
55
|
"@react-aria/button": "^3.6.2",
|
|
56
56
|
"@react-aria/checkbox": "^3.2.3",
|
|
57
57
|
"@react-aria/dialog": "^3.2.1",
|
|
58
58
|
"@react-aria/focus": "^3.6.1",
|
|
59
|
-
"@react-aria/overlays": "3.
|
|
59
|
+
"@react-aria/overlays": "^3.12.1",
|
|
60
60
|
"@react-aria/radio": "^3.4.0",
|
|
61
61
|
"@react-aria/select": "^3.8.2",
|
|
62
62
|
"@react-aria/ssr": "^3.3.0",
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"@react-aria/textfield": "^3.5.0",
|
|
65
65
|
"@react-aria/visually-hidden": "^3.2.3",
|
|
66
66
|
"polished": "^4.1.4",
|
|
67
|
+
"react-spring": "^9.0.0",
|
|
67
68
|
"react-stately": "^3.19.0",
|
|
68
69
|
"warning": "^4.0.3"
|
|
69
70
|
},
|
|
@@ -83,5 +84,5 @@
|
|
|
83
84
|
"url": "https://github.com/pixiv/charcoal.git",
|
|
84
85
|
"directory": "packages/react"
|
|
85
86
|
},
|
|
86
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "0e44e748ea47f54d7ddf6717d0abfd631d8705d6"
|
|
87
88
|
}
|
|
@@ -46,10 +46,10 @@ const DefaultStory = (args: ModalProps) => {
|
|
|
46
46
|
<Button onClick={() => state.open()}>Open Modal</Button>
|
|
47
47
|
|
|
48
48
|
<Modal
|
|
49
|
+
{...args}
|
|
49
50
|
isOpen={state.isOpen}
|
|
50
51
|
onClose={() => state.close()}
|
|
51
52
|
isDismissable
|
|
52
|
-
{...args}
|
|
53
53
|
>
|
|
54
54
|
<ModalHeader />
|
|
55
55
|
<ModalBody>
|
|
@@ -109,11 +109,11 @@ const FullBottomSheetStory = (args: ModalProps) => {
|
|
|
109
109
|
<Button onClick={() => state.open()}>Open Modal</Button>
|
|
110
110
|
|
|
111
111
|
<Modal
|
|
112
|
-
|
|
113
|
-
onClose={() => state.close()}
|
|
112
|
+
{...args}
|
|
114
113
|
isDismissable
|
|
115
114
|
bottomSheet="full"
|
|
116
|
-
{
|
|
115
|
+
isOpen={state.isOpen}
|
|
116
|
+
onClose={() => state.close()}
|
|
117
117
|
>
|
|
118
118
|
<ModalHeader />
|
|
119
119
|
<ModalBody>
|
|
@@ -164,11 +164,11 @@ const BottomSheetStory = (args: ModalProps) => {
|
|
|
164
164
|
<Button onClick={() => state.open()}>Open Modal</Button>
|
|
165
165
|
|
|
166
166
|
<Modal
|
|
167
|
+
{...args}
|
|
167
168
|
isOpen={state.isOpen}
|
|
168
169
|
onClose={() => state.close()}
|
|
169
170
|
bottomSheet
|
|
170
171
|
isDismissable
|
|
171
|
-
{...args}
|
|
172
172
|
>
|
|
173
173
|
<ModalHeader />
|
|
174
174
|
<ModalBody>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useContext, useRef } from 'react'
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
AriaModalOverlayProps,
|
|
4
|
+
Overlay,
|
|
5
|
+
useModalOverlay,
|
|
6
6
|
useOverlay,
|
|
7
7
|
usePreventScroll,
|
|
8
8
|
} from '@react-aria/overlays'
|
|
@@ -19,13 +19,15 @@ import { animated, useTransition, easings } from 'react-spring'
|
|
|
19
19
|
import Button, { ButtonProps } from '../Button'
|
|
20
20
|
import IconButton from '../IconButton'
|
|
21
21
|
|
|
22
|
-
export type ModalProps =
|
|
22
|
+
export type ModalProps = AriaModalOverlayProps &
|
|
23
23
|
AriaDialogProps & {
|
|
24
24
|
children: React.ReactNode
|
|
25
25
|
zIndex?: number
|
|
26
26
|
title: string
|
|
27
27
|
size?: 'S' | 'M' | 'L'
|
|
28
28
|
bottomSheet?: boolean | 'full'
|
|
29
|
+
isOpen: boolean
|
|
30
|
+
onClose: () => void
|
|
29
31
|
|
|
30
32
|
// NOTICE: デフォルト値を与えてはならない
|
|
31
33
|
// (たとえば document.body をデフォルト値にすると SSR できなくなる)
|
|
@@ -53,7 +55,25 @@ export default function Modal({
|
|
|
53
55
|
const { overlayProps, underlayProps } = useOverlay(props, ref)
|
|
54
56
|
|
|
55
57
|
usePreventScroll()
|
|
56
|
-
const { modalProps } =
|
|
58
|
+
const { modalProps } = useModalOverlay(
|
|
59
|
+
props,
|
|
60
|
+
{
|
|
61
|
+
close: onClose,
|
|
62
|
+
isOpen: isOpen,
|
|
63
|
+
// these props are not used actually.
|
|
64
|
+
// https://github.com/adobe/react-spectrum/blob/df14e3fb129b94b310f0397a701b83f006b51dfe/packages/%40react-aria/overlays/src/useModalOverlay.ts
|
|
65
|
+
open: () => {
|
|
66
|
+
// nope
|
|
67
|
+
},
|
|
68
|
+
setOpen: () => {
|
|
69
|
+
// nope
|
|
70
|
+
},
|
|
71
|
+
toggle: () => {
|
|
72
|
+
// nope
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
ref
|
|
76
|
+
)
|
|
57
77
|
|
|
58
78
|
const { dialogProps, titleProps } = useDialog(props, ref)
|
|
59
79
|
|
|
@@ -82,7 +102,7 @@ export default function Modal({
|
|
|
82
102
|
return transition(
|
|
83
103
|
({ backgroundColor, transform }, item) =>
|
|
84
104
|
item && (
|
|
85
|
-
<
|
|
105
|
+
<Overlay>
|
|
86
106
|
<ModalBackground
|
|
87
107
|
zIndex={zIndex}
|
|
88
108
|
{...underlayProps}
|
|
@@ -113,7 +133,7 @@ export default function Modal({
|
|
|
113
133
|
</ModalDialog>
|
|
114
134
|
</FocusScope>
|
|
115
135
|
</ModalBackground>
|
|
116
|
-
</
|
|
136
|
+
</Overlay>
|
|
117
137
|
)
|
|
118
138
|
)
|
|
119
139
|
}
|