@teamturing/react-kit 2.28.1 → 2.29.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.
@@ -8,11 +8,13 @@ import { UnstyledDrawerBodyProps } from './_UnstyledDrawerBody';
8
8
  import { UnstyledDrawerFooterProps } from './_UnstyledDrawerFooter';
9
9
  import { UnstyledDrawerHeaderProps } from './_UnstyledDrawerHeader';
10
10
  type DrawerSizeType = 'full' | 'l' | 'm' | 's';
11
+ type DrawerDirectionType = 'right' | 'bottom';
11
12
  type Props = {
12
13
  isOpen?: boolean;
13
14
  onDismiss?: () => void;
14
15
  isOutsideClickDismissable?: boolean;
15
16
  size?: DrawerSizeType;
17
+ direction?: DrawerDirectionType;
16
18
  initialFocusRef?: RefObject<HTMLElement>;
17
19
  } & SxProp;
18
20
  declare const _default: import("react").ForwardRefExoticComponent<{
@@ -20,6 +22,7 @@ declare const _default: import("react").ForwardRefExoticComponent<{
20
22
  onDismiss?: (() => void) | undefined;
21
23
  isOutsideClickDismissable?: boolean | undefined;
22
24
  size?: DrawerSizeType | undefined;
25
+ direction?: DrawerDirectionType | undefined;
23
26
  initialFocusRef?: RefObject<HTMLElement> | undefined;
24
27
  } & SxProp & {
25
28
  children?: import("react").ReactNode;
package/dist/index.js CHANGED
@@ -19081,6 +19081,7 @@ const Drawer = ({
19081
19081
  onDismiss,
19082
19082
  isOutsideClickDismissable = true,
19083
19083
  size = 'm',
19084
+ direction = 'right',
19084
19085
  initialFocusRef,
19085
19086
  sx
19086
19087
  }, ref) => {
@@ -19143,15 +19144,27 @@ const Drawer = ({
19143
19144
  ref: blanketRef
19144
19145
  })
19145
19146
  }), /*#__PURE__*/jsxRuntimeExports.jsx(MotionView, {
19146
- initial: {
19147
- x: '100%'
19148
- },
19149
- animate: {
19150
- x: 0
19151
- },
19152
- exit: {
19153
- x: '100%'
19154
- },
19147
+ ...(direction === 'right' ? {
19148
+ initial: {
19149
+ x: '100%'
19150
+ },
19151
+ animate: {
19152
+ x: 0
19153
+ },
19154
+ exit: {
19155
+ x: '100%'
19156
+ }
19157
+ } : direction === 'bottom' ? {
19158
+ initial: {
19159
+ y: '100%'
19160
+ },
19161
+ animate: {
19162
+ y: 0
19163
+ },
19164
+ exit: {
19165
+ y: '100%'
19166
+ }
19167
+ } : {}),
19155
19168
  transition: {
19156
19169
  duration: 0.25,
19157
19170
  ease: easeInOut
@@ -19159,29 +19172,27 @@ const Drawer = ({
19159
19172
  sx: {
19160
19173
  position: 'fixed',
19161
19174
  display: 'flex',
19162
- top: 0,
19163
- right: 0,
19164
- bottom: 0,
19165
19175
  zIndex: 9999,
19166
- width: ['100%', '100%', 'fit-content']
19176
+ ...(direction === 'right' ? {
19177
+ top: 0,
19178
+ right: 0,
19179
+ bottom: 0,
19180
+ width: ['100%', '100%', 'fit-content']
19181
+ } : direction === 'bottom' ? {
19182
+ left: 0,
19183
+ right: 0,
19184
+ bottom: 0,
19185
+ width: '100%'
19186
+ } : {})
19167
19187
  },
19168
19188
  children: /*#__PURE__*/jsxRuntimeExports.jsxs(BaseDrawer, {
19169
19189
  ref: drawerRef,
19170
19190
  "aria-modal": 'true',
19171
19191
  role: 'dialog',
19172
19192
  tabIndex: -1,
19173
- sx: {
19174
- ...(size === 's' ? {
19175
- width: ['calc(100% - 32px)', 400, 400]
19176
- } : size === 'm' ? {
19177
- width: ['100%', '100%', 640]
19178
- } : size === 'l' ? {
19179
- width: ['100%', '100%', 860]
19180
- } : size === 'full' ? {
19181
- width: ['100%', '100%', 'calc(100vw - 80px)']
19182
- } : {}),
19183
- ...sx
19184
- },
19193
+ size: size,
19194
+ direction: direction,
19195
+ sx: sx,
19185
19196
  onKeyDown: handleKeyDown,
19186
19197
  children: [/*#__PURE__*/jsxRuntimeExports.jsx(View, {
19187
19198
  sx: {
@@ -19231,6 +19242,52 @@ const BaseDrawer = styled__default.default.div(({
19231
19242
  margin: 'auto',
19232
19243
  height: '100%',
19233
19244
  marginRight: 0
19245
+ }), ({
19246
+ direction
19247
+ }) => direction === 'right' ? variant({
19248
+ prop: 'size',
19249
+ variants: {
19250
+ s: {
19251
+ width: ['calc(100% - 32px)', 400, 400]
19252
+ },
19253
+ m: {
19254
+ width: ['100%', '100%', 640]
19255
+ },
19256
+ l: {
19257
+ width: ['100%', '100%', 860]
19258
+ },
19259
+ full: {
19260
+ width: ['100%', '100%', 'calc(100vw - 80px)']
19261
+ }
19262
+ }
19263
+ }) : variant({
19264
+ prop: 'size',
19265
+ variants: {
19266
+ s: {
19267
+ height: '40dvh',
19268
+ maxHeight: '40dvh'
19269
+ },
19270
+ m: {
19271
+ height: '60dvh',
19272
+ maxHeight: '60dvh'
19273
+ },
19274
+ l: {
19275
+ height: '80dvh',
19276
+ maxHeight: '80dvh'
19277
+ },
19278
+ full: {
19279
+ height: 'calc(100dvh - 80px)',
19280
+ maxHeight: 'calc(100dvh - 80px)'
19281
+ }
19282
+ }
19283
+ }), variant({
19284
+ prop: 'direction',
19285
+ variants: {
19286
+ right: {},
19287
+ bottom: {
19288
+ width: '100% !important'
19289
+ }
19290
+ }
19234
19291
  }), sx);
19235
19292
  var index$7 = Object.assign( /*#__PURE__*/React.forwardRef(Drawer), {
19236
19293
  UnstyledHeader: UnstyledDrawerHeader,
@@ -34685,7 +34742,9 @@ const OverlayPopper = ({
34685
34742
  } = useFloating({
34686
34743
  placement,
34687
34744
  whileElementsMounted: autoUpdate,
34688
- middleware: [offset(theme.space[1]), flip(), shift()],
34745
+ middleware: [offset(theme.space[1]), flip(), shift({
34746
+ crossAxis: true
34747
+ })],
34689
34748
  strategy: 'fixed'
34690
34749
  });
34691
34750
  const [isOpen, toggleOverlay, openOverlay, closeOverlay] = useToggleState({
@@ -1,6 +1,7 @@
1
1
  import { forwardRef, useCallback, useRef, useImperativeHandle, useEffect } from 'react';
2
2
  import SvgClose from '../../packages/icons/esm/Close.js';
3
3
  import styled from 'styled-components';
4
+ import '../../node_modules/styled-system/dist/index.esm.js';
4
5
  import useFocusTrap from '../../hook/useFocusTrap.js';
5
6
  import { sx } from '../../utils/styled-system/index.js';
6
7
  import IconButton from '../IconButton/index.js';
@@ -14,6 +15,7 @@ import UnstyledDrawerBody from './_UnstyledDrawerBody.js';
14
15
  import UnstyledDrawerFooter from './_UnstyledDrawerFooter.js';
15
16
  import UnstyledDrawerHeader from './_UnstyledDrawerHeader.js';
16
17
  import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
18
+ import { variant } from '../../node_modules/@styled-system/variant/dist/index.esm.js';
17
19
  import { AnimatePresence } from '../../node_modules/framer-motion/dist/es/components/AnimatePresence/index.js';
18
20
  import { easeInOut } from '../../node_modules/framer-motion/dist/es/easing/ease.js';
19
21
 
@@ -23,6 +25,7 @@ const Drawer = ({
23
25
  onDismiss,
24
26
  isOutsideClickDismissable = true,
25
27
  size = 'm',
28
+ direction = 'right',
26
29
  initialFocusRef,
27
30
  sx
28
31
  }, ref) => {
@@ -85,15 +88,27 @@ const Drawer = ({
85
88
  ref: blanketRef
86
89
  })
87
90
  }), /*#__PURE__*/jsxRuntimeExports.jsx(MotionView, {
88
- initial: {
89
- x: '100%'
90
- },
91
- animate: {
92
- x: 0
93
- },
94
- exit: {
95
- x: '100%'
96
- },
91
+ ...(direction === 'right' ? {
92
+ initial: {
93
+ x: '100%'
94
+ },
95
+ animate: {
96
+ x: 0
97
+ },
98
+ exit: {
99
+ x: '100%'
100
+ }
101
+ } : direction === 'bottom' ? {
102
+ initial: {
103
+ y: '100%'
104
+ },
105
+ animate: {
106
+ y: 0
107
+ },
108
+ exit: {
109
+ y: '100%'
110
+ }
111
+ } : {}),
97
112
  transition: {
98
113
  duration: 0.25,
99
114
  ease: easeInOut
@@ -101,29 +116,27 @@ const Drawer = ({
101
116
  sx: {
102
117
  position: 'fixed',
103
118
  display: 'flex',
104
- top: 0,
105
- right: 0,
106
- bottom: 0,
107
119
  zIndex: 9999,
108
- width: ['100%', '100%', 'fit-content']
120
+ ...(direction === 'right' ? {
121
+ top: 0,
122
+ right: 0,
123
+ bottom: 0,
124
+ width: ['100%', '100%', 'fit-content']
125
+ } : direction === 'bottom' ? {
126
+ left: 0,
127
+ right: 0,
128
+ bottom: 0,
129
+ width: '100%'
130
+ } : {})
109
131
  },
110
132
  children: /*#__PURE__*/jsxRuntimeExports.jsxs(BaseDrawer, {
111
133
  ref: drawerRef,
112
134
  "aria-modal": 'true',
113
135
  role: 'dialog',
114
136
  tabIndex: -1,
115
- sx: {
116
- ...(size === 's' ? {
117
- width: ['calc(100% - 32px)', 400, 400]
118
- } : size === 'm' ? {
119
- width: ['100%', '100%', 640]
120
- } : size === 'l' ? {
121
- width: ['100%', '100%', 860]
122
- } : size === 'full' ? {
123
- width: ['100%', '100%', 'calc(100vw - 80px)']
124
- } : {}),
125
- ...sx
126
- },
137
+ size: size,
138
+ direction: direction,
139
+ sx: sx,
127
140
  onKeyDown: handleKeyDown,
128
141
  children: [/*#__PURE__*/jsxRuntimeExports.jsx(View, {
129
142
  sx: {
@@ -173,6 +186,52 @@ const BaseDrawer = styled.div(({
173
186
  margin: 'auto',
174
187
  height: '100%',
175
188
  marginRight: 0
189
+ }), ({
190
+ direction
191
+ }) => direction === 'right' ? variant({
192
+ prop: 'size',
193
+ variants: {
194
+ s: {
195
+ width: ['calc(100% - 32px)', 400, 400]
196
+ },
197
+ m: {
198
+ width: ['100%', '100%', 640]
199
+ },
200
+ l: {
201
+ width: ['100%', '100%', 860]
202
+ },
203
+ full: {
204
+ width: ['100%', '100%', 'calc(100vw - 80px)']
205
+ }
206
+ }
207
+ }) : variant({
208
+ prop: 'size',
209
+ variants: {
210
+ s: {
211
+ height: '40dvh',
212
+ maxHeight: '40dvh'
213
+ },
214
+ m: {
215
+ height: '60dvh',
216
+ maxHeight: '60dvh'
217
+ },
218
+ l: {
219
+ height: '80dvh',
220
+ maxHeight: '80dvh'
221
+ },
222
+ full: {
223
+ height: 'calc(100dvh - 80px)',
224
+ maxHeight: 'calc(100dvh - 80px)'
225
+ }
226
+ }
227
+ }), variant({
228
+ prop: 'direction',
229
+ variants: {
230
+ right: {},
231
+ bottom: {
232
+ width: '100% !important'
233
+ }
234
+ }
176
235
  }), sx);
177
236
  var index = Object.assign( /*#__PURE__*/forwardRef(Drawer), {
178
237
  UnstyledHeader: UnstyledDrawerHeader,
@@ -29,7 +29,9 @@ const OverlayPopper = ({
29
29
  } = useFloating({
30
30
  placement,
31
31
  whileElementsMounted: autoUpdate,
32
- middleware: [offset(theme.space[1]), flip(), shift()],
32
+ middleware: [offset(theme.space[1]), flip(), shift({
33
+ crossAxis: true
34
+ })],
33
35
  strategy: 'fixed'
34
36
  });
35
37
  const [isOpen, toggleOverlay, openOverlay, closeOverlay] = useToggleState({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamturing/react-kit",
3
- "version": "2.28.1",
3
+ "version": "2.29.0",
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": "49e0faeb615a1860be291a9b7a60ec4201f9b877"
69
+ "gitHead": "b7418ad2dcfc8309263758233b2711bac6812586"
70
70
  }