@teamturing/react-kit 2.51.5 → 2.51.6
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/index.js +120 -68
- package/esm/core/Dialog/index.js +121 -67
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4023,6 +4023,8 @@ const BaseIconButton = styled__default.default(UnstyledButton)(({
|
|
|
4023
4023
|
}
|
|
4024
4024
|
}));
|
|
4025
4025
|
|
|
4026
|
+
const MotionView = framerMotion.motion(View);
|
|
4027
|
+
|
|
4026
4028
|
const UnstyledDialogBody = styled__default.default.div`
|
|
4027
4029
|
flex-grow: 1;
|
|
4028
4030
|
flex-shrink: 1;
|
|
@@ -4131,15 +4133,15 @@ const Dialog = ({
|
|
|
4131
4133
|
sx
|
|
4132
4134
|
}, ref) => {
|
|
4133
4135
|
const handleDismiss = React.useCallback(() => onDismiss?.(), [onDismiss]);
|
|
4134
|
-
const
|
|
4136
|
+
const blanketRef = React.useRef(null);
|
|
4135
4137
|
const dialogRef = React.useRef(null);
|
|
4136
4138
|
const closeButtonRef = React.useRef(null);
|
|
4137
4139
|
React.useImperativeHandle(ref, () => dialogRef.current);
|
|
4138
4140
|
const handleOutsideClick = React.useCallback(e => {
|
|
4139
|
-
if (dialogRef.current &&
|
|
4141
|
+
if (dialogRef.current && blanketRef.current && e.target instanceof Node && !dialogRef.current.contains(e.target) && blanketRef.current.contains(e.target)) {
|
|
4140
4142
|
handleDismiss?.();
|
|
4141
4143
|
}
|
|
4142
|
-
}, [handleDismiss, dialogRef,
|
|
4144
|
+
}, [handleDismiss, dialogRef, blanketRef]);
|
|
4143
4145
|
const handleKeyDown = React.useCallback(event => {
|
|
4144
4146
|
switch (event.key) {
|
|
4145
4147
|
case 'Escape':
|
|
@@ -4161,72 +4163,124 @@ const Dialog = ({
|
|
|
4161
4163
|
};
|
|
4162
4164
|
}
|
|
4163
4165
|
}, [isOpen, isOutsideClickDismissable, handleOutsideClick]);
|
|
4164
|
-
return
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
maxHeight: 'calc(100dvh - 64px)',
|
|
4184
|
-
width: ['calc(100% - 64px)', 400, 400],
|
|
4185
|
-
marginX: 'auto',
|
|
4186
|
-
marginY: 'auto',
|
|
4187
|
-
borderRadius: 'l'
|
|
4188
|
-
} : size === 'm' ? {
|
|
4189
|
-
maxHeight: ['100%', '100%', 'calc(100dvh - 64px)'],
|
|
4190
|
-
height: ['100%', '100%', 'auto'],
|
|
4191
|
-
minHeight: ['-webkit-fill-available', '-webkit-fill-available', 'auto'],
|
|
4192
|
-
width: ['100%', '100%', 640],
|
|
4193
|
-
marginX: [0, 0, 'auto'],
|
|
4194
|
-
marginY: 'auto',
|
|
4195
|
-
borderRadius: ['none', 'none', 'l']
|
|
4196
|
-
} : size === 'l' ? {
|
|
4197
|
-
maxHeight: ['100%', '100%', 'calc(100dvh - 64px)'],
|
|
4198
|
-
height: ['100%', '100%', 'auto'],
|
|
4199
|
-
minHeight: ['-webkit-fill-available', '-webkit-fill-available', 'auto'],
|
|
4200
|
-
width: ['100%', '100%', 860],
|
|
4201
|
-
marginX: [0, 0, 'auto'],
|
|
4202
|
-
marginY: 'auto',
|
|
4203
|
-
borderRadius: ['none', 'none', 'l']
|
|
4204
|
-
} : size === 'full' ? {
|
|
4205
|
-
height: ['100%', '100%', 'calc(100dvh - 40px)'],
|
|
4206
|
-
width: ['100%', '100%', 'calc(100vw - 40px)'],
|
|
4207
|
-
marginX: [0, 0, 'auto'],
|
|
4208
|
-
marginY: 'auto',
|
|
4209
|
-
borderRadius: ['none', 'none', 'l']
|
|
4210
|
-
} : {}),
|
|
4211
|
-
...sx
|
|
4212
|
-
},
|
|
4213
|
-
onKeyDown: handleKeyDown,
|
|
4214
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(View, {
|
|
4166
|
+
return /*#__PURE__*/jsxRuntime.jsx(framerMotion.AnimatePresence, {
|
|
4167
|
+
children: isOpen ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
4168
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(MotionView, {
|
|
4169
|
+
initial: {
|
|
4170
|
+
opacity: 0
|
|
4171
|
+
},
|
|
4172
|
+
animate: {
|
|
4173
|
+
opacity: 1
|
|
4174
|
+
},
|
|
4175
|
+
exit: {
|
|
4176
|
+
opacity: 0
|
|
4177
|
+
},
|
|
4178
|
+
transition: {
|
|
4179
|
+
duration: 0.25,
|
|
4180
|
+
/**
|
|
4181
|
+
* easeOutQuad by https://easings.net/ko#easeOutQuad
|
|
4182
|
+
*/
|
|
4183
|
+
ease: framerMotion.cubicBezier(0.5, 1, 0.89, 1)
|
|
4184
|
+
},
|
|
4215
4185
|
sx: {
|
|
4216
|
-
position: '
|
|
4217
|
-
top:
|
|
4218
|
-
right:
|
|
4186
|
+
position: 'fixed',
|
|
4187
|
+
top: 0,
|
|
4188
|
+
right: 0,
|
|
4189
|
+
bottom: 0,
|
|
4190
|
+
left: 0,
|
|
4191
|
+
zIndex: 9999
|
|
4219
4192
|
},
|
|
4220
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
4221
|
-
ref:
|
|
4222
|
-
icon: icons.CloseIcon,
|
|
4223
|
-
variant: 'plain',
|
|
4224
|
-
size: 'm',
|
|
4225
|
-
onClick: handleDismiss
|
|
4193
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Blanket$1, {
|
|
4194
|
+
ref: blanketRef
|
|
4226
4195
|
})
|
|
4227
|
-
}),
|
|
4228
|
-
|
|
4229
|
-
|
|
4196
|
+
}), /*#__PURE__*/jsxRuntime.jsx(MotionView, {
|
|
4197
|
+
initial: {
|
|
4198
|
+
opacity: 0,
|
|
4199
|
+
scale: 1.1,
|
|
4200
|
+
translateX: '-50%',
|
|
4201
|
+
translateY: '-50%'
|
|
4202
|
+
},
|
|
4203
|
+
animate: {
|
|
4204
|
+
opacity: 1,
|
|
4205
|
+
scale: 1,
|
|
4206
|
+
translateX: '-50%',
|
|
4207
|
+
translateY: '-50%'
|
|
4208
|
+
},
|
|
4209
|
+
exit: {
|
|
4210
|
+
opacity: 0,
|
|
4211
|
+
scale: 1.1,
|
|
4212
|
+
translateX: '-50%',
|
|
4213
|
+
translateY: '-50%'
|
|
4214
|
+
},
|
|
4215
|
+
transition: {
|
|
4216
|
+
duration: 0.25,
|
|
4217
|
+
/**
|
|
4218
|
+
* easeOutQuad by https://easings.net/ko#easeOutQuad
|
|
4219
|
+
*/
|
|
4220
|
+
ease: framerMotion.cubicBezier(0.5, 1, 0.89, 1)
|
|
4221
|
+
},
|
|
4222
|
+
sx: {
|
|
4223
|
+
position: 'fixed',
|
|
4224
|
+
top: '50%',
|
|
4225
|
+
left: '50%',
|
|
4226
|
+
zIndex: 9999
|
|
4227
|
+
},
|
|
4228
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(BaseDialog, {
|
|
4229
|
+
ref: dialogRef,
|
|
4230
|
+
"aria-modal": 'true',
|
|
4231
|
+
role: 'dialog',
|
|
4232
|
+
tabIndex: -1,
|
|
4233
|
+
sx: {
|
|
4234
|
+
...(size === 's' ? {
|
|
4235
|
+
maxHeight: 'calc(100dvh - 64px)',
|
|
4236
|
+
width: ['calc(100% - 64px)', 400, 400],
|
|
4237
|
+
marginX: 'auto',
|
|
4238
|
+
marginY: 'auto',
|
|
4239
|
+
borderRadius: 'l'
|
|
4240
|
+
} : size === 'm' ? {
|
|
4241
|
+
maxHeight: ['100%', '100%', 'calc(100dvh - 64px)'],
|
|
4242
|
+
height: ['100%', '100%', 'auto'],
|
|
4243
|
+
minHeight: ['-webkit-fill-available', '-webkit-fill-available', 'auto'],
|
|
4244
|
+
width: ['100%', '100%', 640],
|
|
4245
|
+
marginX: [0, 0, 'auto'],
|
|
4246
|
+
marginY: 'auto',
|
|
4247
|
+
borderRadius: ['none', 'none', 'l']
|
|
4248
|
+
} : size === 'l' ? {
|
|
4249
|
+
maxHeight: ['100%', '100%', 'calc(100dvh - 64px)'],
|
|
4250
|
+
height: ['100%', '100%', 'auto'],
|
|
4251
|
+
minHeight: ['-webkit-fill-available', '-webkit-fill-available', 'auto'],
|
|
4252
|
+
width: ['100%', '100%', 860],
|
|
4253
|
+
marginX: [0, 0, 'auto'],
|
|
4254
|
+
marginY: 'auto',
|
|
4255
|
+
borderRadius: ['none', 'none', 'l']
|
|
4256
|
+
} : size === 'full' ? {
|
|
4257
|
+
height: ['100%', '100%', 'calc(100dvh - 40px)'],
|
|
4258
|
+
width: ['100%', '100%', 'calc(100vw - 40px)'],
|
|
4259
|
+
marginX: [0, 0, 'auto'],
|
|
4260
|
+
marginY: 'auto',
|
|
4261
|
+
borderRadius: ['none', 'none', 'l']
|
|
4262
|
+
} : {}),
|
|
4263
|
+
...sx
|
|
4264
|
+
},
|
|
4265
|
+
onKeyDown: handleKeyDown,
|
|
4266
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(View, {
|
|
4267
|
+
sx: {
|
|
4268
|
+
position: 'absolute',
|
|
4269
|
+
top: 3,
|
|
4270
|
+
right: 3
|
|
4271
|
+
},
|
|
4272
|
+
children: /*#__PURE__*/jsxRuntime.jsx(IconButton, {
|
|
4273
|
+
ref: closeButtonRef,
|
|
4274
|
+
icon: icons.CloseIcon,
|
|
4275
|
+
variant: 'plain',
|
|
4276
|
+
size: 'm',
|
|
4277
|
+
onClick: handleDismiss
|
|
4278
|
+
})
|
|
4279
|
+
}), children]
|
|
4280
|
+
})
|
|
4281
|
+
})]
|
|
4282
|
+
}) : null
|
|
4283
|
+
});
|
|
4230
4284
|
};
|
|
4231
4285
|
const Blanket$1 = styled__default.default.span`
|
|
4232
4286
|
&:before {
|
|
@@ -4266,8 +4320,6 @@ var index$8 = Object.assign( /*#__PURE__*/React.forwardRef(Dialog), {
|
|
|
4266
4320
|
Footer: DialogFooter
|
|
4267
4321
|
});
|
|
4268
4322
|
|
|
4269
|
-
const MotionView = framerMotion.motion(View);
|
|
4270
|
-
|
|
4271
4323
|
const UnstyledDrawerBody = styled__default.default.div`
|
|
4272
4324
|
flex-grow: 1;
|
|
4273
4325
|
flex-shrink: 1;
|
package/esm/core/Dialog/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CloseIcon } from '@teamturing/icons';
|
|
2
|
+
import { AnimatePresence, cubicBezier } from 'framer-motion';
|
|
2
3
|
import { forwardRef, useCallback, useRef, useImperativeHandle, useEffect } from 'react';
|
|
3
4
|
import styled from 'styled-components';
|
|
4
5
|
import IconButton from '../IconButton/index.js';
|
|
5
6
|
import View from '../View/index.js';
|
|
6
7
|
import useFocusTrap from '../../hook/useFocusTrap.js';
|
|
7
8
|
import { sx } from '../../utils/styled-system/index.js';
|
|
9
|
+
import MotionView from '../MotionView/index.js';
|
|
8
10
|
import DialogBody from './DialogBody.js';
|
|
9
11
|
import DialogFooter from './DialogFooter.js';
|
|
10
12
|
import DialogHeader from './DialogHeader.js';
|
|
@@ -13,7 +15,7 @@ import DialogHeaderTitle from './DialogHeaderTitle.js';
|
|
|
13
15
|
import UnstyledDialogBody from './_UnstyledDialogBody.js';
|
|
14
16
|
import UnstyledDialogFooter from './_UnstyledDialogFooter.js';
|
|
15
17
|
import UnstyledDialogHeader from './_UnstyledDialogHeader.js';
|
|
16
|
-
import { jsxs,
|
|
18
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
17
19
|
|
|
18
20
|
const Dialog = ({
|
|
19
21
|
children,
|
|
@@ -25,15 +27,15 @@ const Dialog = ({
|
|
|
25
27
|
sx
|
|
26
28
|
}, ref) => {
|
|
27
29
|
const handleDismiss = useCallback(() => onDismiss?.(), [onDismiss]);
|
|
28
|
-
const
|
|
30
|
+
const blanketRef = useRef(null);
|
|
29
31
|
const dialogRef = useRef(null);
|
|
30
32
|
const closeButtonRef = useRef(null);
|
|
31
33
|
useImperativeHandle(ref, () => dialogRef.current);
|
|
32
34
|
const handleOutsideClick = useCallback(e => {
|
|
33
|
-
if (dialogRef.current &&
|
|
35
|
+
if (dialogRef.current && blanketRef.current && e.target instanceof Node && !dialogRef.current.contains(e.target) && blanketRef.current.contains(e.target)) {
|
|
34
36
|
handleDismiss?.();
|
|
35
37
|
}
|
|
36
|
-
}, [handleDismiss, dialogRef,
|
|
38
|
+
}, [handleDismiss, dialogRef, blanketRef]);
|
|
37
39
|
const handleKeyDown = useCallback(event => {
|
|
38
40
|
switch (event.key) {
|
|
39
41
|
case 'Escape':
|
|
@@ -55,72 +57,124 @@ const Dialog = ({
|
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
59
|
}, [isOpen, isOutsideClickDismissable, handleOutsideClick]);
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
60
|
+
return /*#__PURE__*/jsx(AnimatePresence, {
|
|
61
|
+
children: isOpen ? /*#__PURE__*/jsxs(Fragment, {
|
|
62
|
+
children: [/*#__PURE__*/jsx(MotionView, {
|
|
63
|
+
initial: {
|
|
64
|
+
opacity: 0
|
|
65
|
+
},
|
|
66
|
+
animate: {
|
|
67
|
+
opacity: 1
|
|
68
|
+
},
|
|
69
|
+
exit: {
|
|
70
|
+
opacity: 0
|
|
71
|
+
},
|
|
72
|
+
transition: {
|
|
73
|
+
duration: 0.25,
|
|
74
|
+
/**
|
|
75
|
+
* easeOutQuad by https://easings.net/ko#easeOutQuad
|
|
76
|
+
*/
|
|
77
|
+
ease: cubicBezier(0.5, 1, 0.89, 1)
|
|
78
|
+
},
|
|
79
|
+
sx: {
|
|
80
|
+
position: 'fixed',
|
|
81
|
+
top: 0,
|
|
82
|
+
right: 0,
|
|
83
|
+
bottom: 0,
|
|
84
|
+
left: 0,
|
|
85
|
+
zIndex: 9999
|
|
86
|
+
},
|
|
87
|
+
children: /*#__PURE__*/jsx(Blanket, {
|
|
88
|
+
ref: blanketRef
|
|
89
|
+
})
|
|
90
|
+
}), /*#__PURE__*/jsx(MotionView, {
|
|
91
|
+
initial: {
|
|
92
|
+
opacity: 0,
|
|
93
|
+
scale: 1.1,
|
|
94
|
+
translateX: '-50%',
|
|
95
|
+
translateY: '-50%'
|
|
96
|
+
},
|
|
97
|
+
animate: {
|
|
98
|
+
opacity: 1,
|
|
99
|
+
scale: 1,
|
|
100
|
+
translateX: '-50%',
|
|
101
|
+
translateY: '-50%'
|
|
102
|
+
},
|
|
103
|
+
exit: {
|
|
104
|
+
opacity: 0,
|
|
105
|
+
scale: 1.1,
|
|
106
|
+
translateX: '-50%',
|
|
107
|
+
translateY: '-50%'
|
|
108
|
+
},
|
|
109
|
+
transition: {
|
|
110
|
+
duration: 0.25,
|
|
111
|
+
/**
|
|
112
|
+
* easeOutQuad by https://easings.net/ko#easeOutQuad
|
|
113
|
+
*/
|
|
114
|
+
ease: cubicBezier(0.5, 1, 0.89, 1)
|
|
115
|
+
},
|
|
109
116
|
sx: {
|
|
110
|
-
position: '
|
|
111
|
-
top:
|
|
112
|
-
|
|
117
|
+
position: 'fixed',
|
|
118
|
+
top: '50%',
|
|
119
|
+
left: '50%',
|
|
120
|
+
zIndex: 9999
|
|
113
121
|
},
|
|
114
|
-
children: /*#__PURE__*/
|
|
115
|
-
ref:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
children: /*#__PURE__*/jsxs(BaseDialog, {
|
|
123
|
+
ref: dialogRef,
|
|
124
|
+
"aria-modal": 'true',
|
|
125
|
+
role: 'dialog',
|
|
126
|
+
tabIndex: -1,
|
|
127
|
+
sx: {
|
|
128
|
+
...(size === 's' ? {
|
|
129
|
+
maxHeight: 'calc(100dvh - 64px)',
|
|
130
|
+
width: ['calc(100% - 64px)', 400, 400],
|
|
131
|
+
marginX: 'auto',
|
|
132
|
+
marginY: 'auto',
|
|
133
|
+
borderRadius: 'l'
|
|
134
|
+
} : size === 'm' ? {
|
|
135
|
+
maxHeight: ['100%', '100%', 'calc(100dvh - 64px)'],
|
|
136
|
+
height: ['100%', '100%', 'auto'],
|
|
137
|
+
minHeight: ['-webkit-fill-available', '-webkit-fill-available', 'auto'],
|
|
138
|
+
width: ['100%', '100%', 640],
|
|
139
|
+
marginX: [0, 0, 'auto'],
|
|
140
|
+
marginY: 'auto',
|
|
141
|
+
borderRadius: ['none', 'none', 'l']
|
|
142
|
+
} : size === 'l' ? {
|
|
143
|
+
maxHeight: ['100%', '100%', 'calc(100dvh - 64px)'],
|
|
144
|
+
height: ['100%', '100%', 'auto'],
|
|
145
|
+
minHeight: ['-webkit-fill-available', '-webkit-fill-available', 'auto'],
|
|
146
|
+
width: ['100%', '100%', 860],
|
|
147
|
+
marginX: [0, 0, 'auto'],
|
|
148
|
+
marginY: 'auto',
|
|
149
|
+
borderRadius: ['none', 'none', 'l']
|
|
150
|
+
} : size === 'full' ? {
|
|
151
|
+
height: ['100%', '100%', 'calc(100dvh - 40px)'],
|
|
152
|
+
width: ['100%', '100%', 'calc(100vw - 40px)'],
|
|
153
|
+
marginX: [0, 0, 'auto'],
|
|
154
|
+
marginY: 'auto',
|
|
155
|
+
borderRadius: ['none', 'none', 'l']
|
|
156
|
+
} : {}),
|
|
157
|
+
...sx
|
|
158
|
+
},
|
|
159
|
+
onKeyDown: handleKeyDown,
|
|
160
|
+
children: [/*#__PURE__*/jsx(View, {
|
|
161
|
+
sx: {
|
|
162
|
+
position: 'absolute',
|
|
163
|
+
top: 3,
|
|
164
|
+
right: 3
|
|
165
|
+
},
|
|
166
|
+
children: /*#__PURE__*/jsx(IconButton, {
|
|
167
|
+
ref: closeButtonRef,
|
|
168
|
+
icon: CloseIcon,
|
|
169
|
+
variant: 'plain',
|
|
170
|
+
size: 'm',
|
|
171
|
+
onClick: handleDismiss
|
|
172
|
+
})
|
|
173
|
+
}), children]
|
|
120
174
|
})
|
|
121
|
-
})
|
|
122
|
-
})
|
|
123
|
-
})
|
|
175
|
+
})]
|
|
176
|
+
}) : null
|
|
177
|
+
});
|
|
124
178
|
};
|
|
125
179
|
const Blanket = styled.span`
|
|
126
180
|
&:before {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamturing/react-kit",
|
|
3
|
-
"version": "2.51.
|
|
3
|
+
"version": "2.51.6",
|
|
4
4
|
"description": "React components, hooks for create teamturing web application",
|
|
5
5
|
"author": "Sungchang Park <psch300@gmail.com> (https://github.com/psch300)",
|
|
6
6
|
"homepage": "https://github.com/weareteamturing/bombe#readme",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"react-textarea-autosize": "^8.5.3",
|
|
67
67
|
"styled-system": "^5.1.5"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "b48f843f109e5d541144fd5c3de7f7a7609ac86f"
|
|
70
70
|
}
|