@draftbit/core 47.2.1-a33ddf.2 → 47.2.1-d833e1.2
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/lib/commonjs/components/BottomSheet/BottomSheet.js +18 -3
- package/lib/commonjs/components/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/commonjs/components/Checkbox/CheckboxGroup.js +16 -3
- package/lib/commonjs/components/Checkbox/CheckboxGroup.js.map +1 -1
- package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js +22 -5
- package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js.map +1 -1
- package/lib/commonjs/components/Checkbox/CheckboxRow.js +6 -23
- package/lib/commonjs/components/Checkbox/CheckboxRow.js.map +1 -1
- package/lib/commonjs/components/SwipeableView/SwipeableView.js +155 -0
- package/lib/commonjs/components/SwipeableView/SwipeableView.js.map +1 -0
- package/lib/commonjs/components/SwipeableView/SwipeableViewButton.js +13 -0
- package/lib/commonjs/components/SwipeableView/SwipeableViewButton.js.map +1 -0
- package/lib/commonjs/components/SwipeableView/SwipeableViewSwipeHandler.js +13 -0
- package/lib/commonjs/components/SwipeableView/SwipeableViewSwipeHandler.js.map +1 -0
- package/lib/commonjs/components/SwipeableView/index.js +28 -0
- package/lib/commonjs/components/SwipeableView/index.js.map +1 -0
- package/lib/commonjs/index.js +19 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mappings/BottomSheet.js +37 -9
- package/lib/commonjs/mappings/BottomSheet.js.map +1 -1
- package/lib/commonjs/mappings/SwipeableView.js +183 -0
- package/lib/commonjs/mappings/SwipeableView.js.map +1 -0
- package/lib/commonjs/utilities.js +27 -2
- package/lib/commonjs/utilities.js.map +1 -1
- package/lib/module/components/BottomSheet/BottomSheet.js +18 -3
- package/lib/module/components/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/module/components/SwipeableView/SwipeableView.js +147 -0
- package/lib/module/components/SwipeableView/SwipeableView.js.map +1 -0
- package/lib/module/components/SwipeableView/SwipeableViewButton.js +6 -0
- package/lib/module/components/SwipeableView/SwipeableViewButton.js.map +1 -0
- package/lib/module/components/SwipeableView/SwipeableViewSwipeHandler.js +6 -0
- package/lib/module/components/SwipeableView/SwipeableViewSwipeHandler.js.map +1 -0
- package/lib/module/components/SwipeableView/index.js +4 -0
- package/lib/module/components/SwipeableView/index.js.map +1 -0
- package/lib/module/constants.js +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/mappings/BottomSheet.js +38 -10
- package/lib/module/mappings/BottomSheet.js.map +1 -1
- package/lib/module/mappings/SwipeableView.js +175 -0
- package/lib/module/mappings/SwipeableView.js.map +1 -0
- package/lib/module/mappings/TextArea.js.map +1 -1
- package/lib/module/utilities.js +18 -0
- package/lib/module/utilities.js.map +1 -1
- package/lib/typescript/src/components/BottomSheet/BottomSheet.d.ts +6 -1
- package/lib/typescript/src/components/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/lib/typescript/src/components/SwipeableView/SwipeableView.d.ts +29 -0
- package/lib/typescript/src/components/SwipeableView/SwipeableView.d.ts.map +1 -0
- package/lib/typescript/src/components/SwipeableView/SwipeableViewButton.d.ts +13 -0
- package/lib/typescript/src/components/SwipeableView/SwipeableViewButton.d.ts.map +1 -0
- package/lib/typescript/src/components/SwipeableView/SwipeableViewSwipeHandler.d.ts +13 -0
- package/lib/typescript/src/components/SwipeableView/SwipeableViewSwipeHandler.d.ts.map +1 -0
- package/lib/typescript/src/components/SwipeableView/index.d.ts +4 -0
- package/lib/typescript/src/components/SwipeableView/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mappings/BottomSheet.d.ts +48 -4
- package/lib/typescript/src/mappings/BottomSheet.d.ts.map +1 -1
- package/lib/typescript/src/mappings/SwipeableView.d.ts +426 -0
- package/lib/typescript/src/mappings/SwipeableView.d.ts.map +1 -0
- package/lib/typescript/src/utilities.d.ts +6 -0
- package/lib/typescript/src/utilities.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/components/BottomSheet/BottomSheet.js +17 -2
- package/src/components/BottomSheet/BottomSheet.tsx +32 -4
- package/src/components/SwipeableView/SwipeableView.js +117 -0
- package/src/components/SwipeableView/SwipeableView.tsx +299 -0
- package/src/components/SwipeableView/SwipeableViewButton.js +5 -0
- package/src/components/SwipeableView/SwipeableViewButton.tsx +18 -0
- package/src/components/SwipeableView/SwipeableViewSwipeHandler.js +5 -0
- package/src/components/SwipeableView/SwipeableViewSwipeHandler.tsx +20 -0
- package/src/components/SwipeableView/index.js +3 -0
- package/src/components/SwipeableView/index.tsx +3 -0
- package/src/index.js +1 -0
- package/src/index.tsx +6 -0
- package/src/mappings/BottomSheet.js +37 -9
- package/src/mappings/BottomSheet.ts +43 -8
- package/src/mappings/SwipeableView.js +181 -0
- package/src/mappings/SwipeableView.ts +210 -0
- package/src/utilities.js +41 -0
- package/src/utilities.ts +71 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
StyleProp,
|
|
5
|
+
ViewStyle,
|
|
6
|
+
TextStyle,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
Text,
|
|
9
|
+
} from "react-native";
|
|
10
|
+
import Pressable from "../Pressable";
|
|
11
|
+
import {
|
|
12
|
+
extractBorderAndMarginStyles,
|
|
13
|
+
extractEffectStyles,
|
|
14
|
+
extractFlexItemStyles,
|
|
15
|
+
extractPositionStyles,
|
|
16
|
+
extractSizeStyles,
|
|
17
|
+
extractStyles,
|
|
18
|
+
} from "../../utilities";
|
|
19
|
+
import { SwipeRow } from "react-native-swipe-list-view";
|
|
20
|
+
import { IconSlot } from "../../interfaces/Icon";
|
|
21
|
+
import type { Theme } from "../../styles/DefaultTheme";
|
|
22
|
+
import { withTheme } from "../../theming";
|
|
23
|
+
import { SwipeableViewButtonProps } from "./SwipeableViewButton";
|
|
24
|
+
import { SwipeableViewSwipeHandlerProps } from "./SwipeableViewSwipeHandler";
|
|
25
|
+
|
|
26
|
+
export interface SwipeableViewProps extends IconSlot {
|
|
27
|
+
closeOnPress?: boolean;
|
|
28
|
+
leftOpenValue?: number;
|
|
29
|
+
rightOpenValue?: number;
|
|
30
|
+
leftActivationValue?: number;
|
|
31
|
+
rightActivationValue?: number;
|
|
32
|
+
swipeActivationPercentage?: number;
|
|
33
|
+
stopLeftSwipe?: number;
|
|
34
|
+
stopRightSwipe?: number;
|
|
35
|
+
directionalDistanceChangeThreshold?: number;
|
|
36
|
+
friction?: number;
|
|
37
|
+
tension?: number;
|
|
38
|
+
disableLeftSwipe?: boolean;
|
|
39
|
+
disableRightSwipe?: boolean;
|
|
40
|
+
swipeToOpenVelocityContribution?: number;
|
|
41
|
+
swipeToOpenPercent?: number;
|
|
42
|
+
swipeToClosePercent?: number;
|
|
43
|
+
style?: StyleProp<ViewStyle | TextStyle>;
|
|
44
|
+
theme: Theme;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const SwipeableView: React.FC<React.PropsWithChildren<SwipeableViewProps>> = ({
|
|
48
|
+
theme,
|
|
49
|
+
style,
|
|
50
|
+
children,
|
|
51
|
+
Icon,
|
|
52
|
+
closeOnPress,
|
|
53
|
+
leftOpenValue,
|
|
54
|
+
rightOpenValue,
|
|
55
|
+
leftActivationValue,
|
|
56
|
+
rightActivationValue,
|
|
57
|
+
swipeActivationPercentage = 80,
|
|
58
|
+
stopLeftSwipe,
|
|
59
|
+
stopRightSwipe,
|
|
60
|
+
friction = 20,
|
|
61
|
+
...rest
|
|
62
|
+
}) => {
|
|
63
|
+
const instanceOfSwipeableViewButtonProps = (
|
|
64
|
+
object: any
|
|
65
|
+
): object is SwipeableViewButtonProps => {
|
|
66
|
+
return "title" in object && "side" in object && "onPress" in object;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const instanceOfSwipeableViewSwipeHandlerProps = (
|
|
70
|
+
object: any
|
|
71
|
+
): object is SwipeableViewSwipeHandlerProps => {
|
|
72
|
+
return "title" in object && "side" in object && "onSwipe" in object;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const { viewStyles, textStyles } = extractStyles(style);
|
|
76
|
+
|
|
77
|
+
const { borderStyles, marginStyles } =
|
|
78
|
+
extractBorderAndMarginStyles(viewStyles);
|
|
79
|
+
|
|
80
|
+
const parentContainerStyles = StyleSheet.flatten([
|
|
81
|
+
borderStyles,
|
|
82
|
+
marginStyles,
|
|
83
|
+
extractFlexItemStyles(viewStyles),
|
|
84
|
+
extractPositionStyles(viewStyles),
|
|
85
|
+
extractEffectStyles(viewStyles),
|
|
86
|
+
extractSizeStyles(viewStyles),
|
|
87
|
+
]);
|
|
88
|
+
|
|
89
|
+
//Remove styles already consumed from viewStyles
|
|
90
|
+
Object.keys(parentContainerStyles).forEach((key) => delete viewStyles[key]);
|
|
91
|
+
const surfaceContainerStyles = viewStyles;
|
|
92
|
+
|
|
93
|
+
const [componentWidth, setComponentWidth] = React.useState<number | null>(
|
|
94
|
+
null
|
|
95
|
+
);
|
|
96
|
+
const leftButtons = React.useMemo(
|
|
97
|
+
() =>
|
|
98
|
+
React.Children.toArray(children).filter(
|
|
99
|
+
(child) =>
|
|
100
|
+
React.isValidElement(child) &&
|
|
101
|
+
instanceOfSwipeableViewButtonProps(child.props) &&
|
|
102
|
+
child.props.side === "left"
|
|
103
|
+
) as React.ReactElement<SwipeableViewButtonProps>[],
|
|
104
|
+
[children]
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const rightButtons = React.useMemo(
|
|
108
|
+
() =>
|
|
109
|
+
React.Children.toArray(children).filter(
|
|
110
|
+
(child) =>
|
|
111
|
+
React.isValidElement(child) &&
|
|
112
|
+
instanceOfSwipeableViewButtonProps(child.props) &&
|
|
113
|
+
child.props.side === "right"
|
|
114
|
+
) as React.ReactElement<SwipeableViewButtonProps>[],
|
|
115
|
+
[children]
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const leftSwipeHandlers = React.useMemo(
|
|
119
|
+
() =>
|
|
120
|
+
React.Children.toArray(children).filter(
|
|
121
|
+
(child) =>
|
|
122
|
+
React.isValidElement(child) &&
|
|
123
|
+
instanceOfSwipeableViewSwipeHandlerProps(child.props) &&
|
|
124
|
+
child.props.side === "left"
|
|
125
|
+
) as React.ReactElement<SwipeableViewSwipeHandlerProps>[],
|
|
126
|
+
[children]
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const rightSwipeHandlers = React.useMemo(
|
|
130
|
+
() =>
|
|
131
|
+
React.Children.toArray(children).filter(
|
|
132
|
+
(child) =>
|
|
133
|
+
React.isValidElement(child) &&
|
|
134
|
+
instanceOfSwipeableViewSwipeHandlerProps(child.props) &&
|
|
135
|
+
child.props.side === "right"
|
|
136
|
+
) as React.ReactElement<SwipeableViewSwipeHandlerProps>[],
|
|
137
|
+
[children]
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const remainingChildren = React.useMemo(
|
|
141
|
+
() =>
|
|
142
|
+
React.Children.toArray(children).filter(
|
|
143
|
+
(child) =>
|
|
144
|
+
React.isValidElement(child) &&
|
|
145
|
+
!instanceOfSwipeableViewSwipeHandlerProps(child.props) &&
|
|
146
|
+
!instanceOfSwipeableViewButtonProps(child.props)
|
|
147
|
+
),
|
|
148
|
+
[children]
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
if (leftButtons.length > 2 || rightButtons.length > 2) {
|
|
152
|
+
throw Error("Cannot have more than 2 buttons per side");
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (leftSwipeHandlers.length > 1 || rightSwipeHandlers.length > 1) {
|
|
156
|
+
throw Error("Cannot have more than 1 swiper handler per side");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (
|
|
160
|
+
(leftButtons.length && leftSwipeHandlers.length) ||
|
|
161
|
+
(rightButtons.length && rightSwipeHandlers.length)
|
|
162
|
+
) {
|
|
163
|
+
throw Error("Cannot combine swiper handler and buttons on the same side");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
//Renders a single button/item. Used for both buttons and swipe handler
|
|
167
|
+
const renderBehindItem = (
|
|
168
|
+
props: SwipeableViewSwipeHandlerProps | SwipeableViewButtonProps,
|
|
169
|
+
index: number
|
|
170
|
+
) => (
|
|
171
|
+
<Pressable
|
|
172
|
+
key={index.toString()}
|
|
173
|
+
onPress={(props as any).onPress}
|
|
174
|
+
style={[
|
|
175
|
+
styles.buttonContainer,
|
|
176
|
+
{ backgroundColor: props.backgroundColor || theme.colors.primary },
|
|
177
|
+
]}
|
|
178
|
+
>
|
|
179
|
+
{props.icon && (
|
|
180
|
+
<Icon
|
|
181
|
+
name={props.icon}
|
|
182
|
+
size={props.iconSize || 25}
|
|
183
|
+
color={props.color || theme.colors.surface}
|
|
184
|
+
/>
|
|
185
|
+
)}
|
|
186
|
+
<Text
|
|
187
|
+
style={[textStyles, { color: props.color || theme.colors.surface }]}
|
|
188
|
+
>
|
|
189
|
+
{props.title}
|
|
190
|
+
</Text>
|
|
191
|
+
</Pressable>
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
const isLeftSwipeHandler = !!leftSwipeHandlers.length;
|
|
195
|
+
const isRightSwipeHandler = !!rightSwipeHandlers.length;
|
|
196
|
+
|
|
197
|
+
const defaultLeftOpenValue = componentWidth ? componentWidth / 2 : 0;
|
|
198
|
+
const defaultRightOpenValue = componentWidth ? -componentWidth / 2 : 0;
|
|
199
|
+
|
|
200
|
+
return (
|
|
201
|
+
<View
|
|
202
|
+
onLayout={(event) => {
|
|
203
|
+
setComponentWidth(event.nativeEvent.layout.width);
|
|
204
|
+
}}
|
|
205
|
+
style={[styles.parentContainer, parentContainerStyles]}
|
|
206
|
+
>
|
|
207
|
+
{/*@ts-ignore*/}
|
|
208
|
+
<SwipeRow
|
|
209
|
+
leftOpenValue={
|
|
210
|
+
isLeftSwipeHandler ? 0 : leftOpenValue || defaultLeftOpenValue //If in swiping mode, don't keep open
|
|
211
|
+
}
|
|
212
|
+
rightOpenValue={
|
|
213
|
+
isRightSwipeHandler ? 0 : rightOpenValue || defaultRightOpenValue
|
|
214
|
+
}
|
|
215
|
+
leftActivationValue={
|
|
216
|
+
leftActivationValue || isLeftSwipeHandler
|
|
217
|
+
? defaultLeftOpenValue * (swipeActivationPercentage / 100) //When swipe passes activation percentage then it should be considered activated (call onSwipe)
|
|
218
|
+
: defaultLeftOpenValue
|
|
219
|
+
}
|
|
220
|
+
rightActivationValue={
|
|
221
|
+
rightActivationValue || isRightSwipeHandler
|
|
222
|
+
? defaultRightOpenValue * (swipeActivationPercentage / 100)
|
|
223
|
+
: defaultRightOpenValue
|
|
224
|
+
}
|
|
225
|
+
stopLeftSwipe={stopLeftSwipe || defaultLeftOpenValue}
|
|
226
|
+
stopRightSwipe={stopRightSwipe || defaultRightOpenValue}
|
|
227
|
+
onLeftAction={
|
|
228
|
+
isLeftSwipeHandler
|
|
229
|
+
? () => leftSwipeHandlers[0].props.onSwipe?.()
|
|
230
|
+
: undefined
|
|
231
|
+
}
|
|
232
|
+
onRightAction={
|
|
233
|
+
isRightSwipeHandler
|
|
234
|
+
? () => rightSwipeHandlers[0].props.onSwipe?.()
|
|
235
|
+
: undefined
|
|
236
|
+
}
|
|
237
|
+
closeOnRowPress={closeOnPress}
|
|
238
|
+
friction={friction}
|
|
239
|
+
{...rest}
|
|
240
|
+
>
|
|
241
|
+
<View style={styles.behindContainer}>
|
|
242
|
+
<View style={styles.behindContainerItem}>
|
|
243
|
+
{(isLeftSwipeHandler ? leftSwipeHandlers : leftButtons).map(
|
|
244
|
+
(item, index) => renderBehindItem(item.props, index)
|
|
245
|
+
)}
|
|
246
|
+
</View>
|
|
247
|
+
<View style={styles.behindContainerItem}>
|
|
248
|
+
{(isRightSwipeHandler ? rightSwipeHandlers : rightButtons).map(
|
|
249
|
+
(item, index) => renderBehindItem(item.props, index)
|
|
250
|
+
)}
|
|
251
|
+
</View>
|
|
252
|
+
</View>
|
|
253
|
+
<View
|
|
254
|
+
style={[
|
|
255
|
+
styles.surfaceContainer,
|
|
256
|
+
{
|
|
257
|
+
backgroundColor: theme.colors.background,
|
|
258
|
+
},
|
|
259
|
+
surfaceContainerStyles,
|
|
260
|
+
]}
|
|
261
|
+
>
|
|
262
|
+
{remainingChildren}
|
|
263
|
+
</View>
|
|
264
|
+
</SwipeRow>
|
|
265
|
+
</View>
|
|
266
|
+
);
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
const styles = StyleSheet.create({
|
|
270
|
+
parentContainer: {
|
|
271
|
+
overflow: "hidden",
|
|
272
|
+
minHeight: 50,
|
|
273
|
+
},
|
|
274
|
+
behindContainer: {
|
|
275
|
+
flex: 1,
|
|
276
|
+
width: "100%",
|
|
277
|
+
height: "100%",
|
|
278
|
+
flexDirection: "row",
|
|
279
|
+
},
|
|
280
|
+
behindContainerItem: {
|
|
281
|
+
flex: 1,
|
|
282
|
+
flexDirection: "row",
|
|
283
|
+
},
|
|
284
|
+
buttonContainer: {
|
|
285
|
+
flex: 1,
|
|
286
|
+
alignItems: "center",
|
|
287
|
+
justifyContent: "center",
|
|
288
|
+
},
|
|
289
|
+
surfaceContainer: {
|
|
290
|
+
flexDirection: "row",
|
|
291
|
+
width: "100%",
|
|
292
|
+
height: "100%",
|
|
293
|
+
padding: 10,
|
|
294
|
+
alignItems: "center",
|
|
295
|
+
overflow: "hidden",
|
|
296
|
+
},
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
export default withTheme(SwipeableView);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export interface SwipeableViewButtonProps {
|
|
4
|
+
title: string;
|
|
5
|
+
side: "left" | "right";
|
|
6
|
+
onPress: (() => void) | null; //Not optional in order to always exist in props
|
|
7
|
+
icon?: string;
|
|
8
|
+
iconSize?: number;
|
|
9
|
+
backgroundColor?: string;
|
|
10
|
+
color?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//Renders nothing, acts as a wrapper be used by SwipeableView
|
|
14
|
+
const SwipeableViewButton: React.FC<SwipeableViewButtonProps> = () => {
|
|
15
|
+
return null;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default SwipeableViewButton;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export interface SwipeableViewSwipeHandlerProps {
|
|
4
|
+
title: string;
|
|
5
|
+
side: "left" | "right";
|
|
6
|
+
onSwipe: (() => void) | null; //Not optional in order to always exist in props
|
|
7
|
+
icon?: string;
|
|
8
|
+
iconSize?: number;
|
|
9
|
+
backgroundColor?: string;
|
|
10
|
+
color?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//Renders nothing, acts as a wrapper to be used by SwipeableView
|
|
14
|
+
const SwipeableViewSwipeHandler: React.FC<
|
|
15
|
+
SwipeableViewSwipeHandlerProps
|
|
16
|
+
> = () => {
|
|
17
|
+
return null;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default SwipeableViewSwipeHandler;
|
package/src/index.js
CHANGED
|
@@ -38,6 +38,7 @@ export { default as Markdown } from "./components/Markdown";
|
|
|
38
38
|
export { BottomSheet } from "./components/BottomSheet";
|
|
39
39
|
export { YoutubePlayer } from "./components/YoutubePlayer";
|
|
40
40
|
export { Table, TableRow, TableCell } from "./components/Table";
|
|
41
|
+
export { SwipeableView, SwipeableViewButton, SwipeableViewSwipeHandler, } from "./components/SwipeableView";
|
|
41
42
|
/* Deprecated: Fix or Delete! */
|
|
42
43
|
export { default as DatePicker } from "./components/DatePicker/DatePicker";
|
|
43
44
|
export { default as Picker } from "./components/Picker/Picker";
|
package/src/index.tsx
CHANGED
|
@@ -64,6 +64,12 @@ export { YoutubePlayer } from "./components/YoutubePlayer";
|
|
|
64
64
|
|
|
65
65
|
export { Table, TableRow, TableCell } from "./components/Table";
|
|
66
66
|
|
|
67
|
+
export {
|
|
68
|
+
SwipeableView,
|
|
69
|
+
SwipeableViewButton,
|
|
70
|
+
SwipeableViewSwipeHandler,
|
|
71
|
+
} from "./components/SwipeableView";
|
|
72
|
+
|
|
67
73
|
/* Deprecated: Fix or Delete! */
|
|
68
74
|
export { default as DatePicker } from "./components/DatePicker/DatePicker";
|
|
69
75
|
export { default as Picker } from "./components/Picker/Picker";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { COMPONENT_TYPES, createStaticBoolProp, CONTAINER_COMPONENT_STYLES_SECTIONS, Triggers, createActionProp, createColorProp, createStaticNumberProp, createArrayProp, } from "@draftbit/types";
|
|
1
|
+
import { COMPONENT_TYPES, createStaticBoolProp, CONTAINER_COMPONENT_STYLES_SECTIONS, Triggers, createActionProp, createColorProp, createStaticNumberProp, createArrayProp, GROUPS, createTextEnumProp, FORM_TYPES, } from "@draftbit/types";
|
|
2
2
|
export const SEED_DATA = {
|
|
3
3
|
name: "Bottom Sheet",
|
|
4
4
|
tag: "BottomSheet",
|
|
@@ -11,16 +11,32 @@ export const SEED_DATA = {
|
|
|
11
11
|
label: "On settle",
|
|
12
12
|
description: "Action to execute when sheet settles on a snap point",
|
|
13
13
|
}),
|
|
14
|
-
|
|
15
|
-
label: "
|
|
16
|
-
description: "
|
|
17
|
-
defaultValue:
|
|
14
|
+
topSnapPosition: createStaticNumberProp({
|
|
15
|
+
label: "Top snap position",
|
|
16
|
+
description: "Top most postion where bottom sheet can snap to. A numerical value that represents distance from the top",
|
|
17
|
+
defaultValue: "10%",
|
|
18
|
+
required: false,
|
|
19
|
+
formType: FORM_TYPES.numeric,
|
|
18
20
|
}),
|
|
19
|
-
|
|
20
|
-
label: "
|
|
21
|
-
description: "
|
|
22
|
-
defaultValue:
|
|
21
|
+
middleSnapPosition: createStaticNumberProp({
|
|
22
|
+
label: "Middle snap position",
|
|
23
|
+
description: "Middle postion where bottom sheet can snap to. A numerical value that represents distance from the top",
|
|
24
|
+
defaultValue: "50%",
|
|
23
25
|
required: false,
|
|
26
|
+
formType: FORM_TYPES.numeric,
|
|
27
|
+
}),
|
|
28
|
+
bottomSnapPosition: createStaticNumberProp({
|
|
29
|
+
label: "Bottom snap position",
|
|
30
|
+
description: "Bottom most postion where bottom sheet can snap to. A numerical value that represents distance from the top",
|
|
31
|
+
defaultValue: "80%",
|
|
32
|
+
required: false,
|
|
33
|
+
formType: FORM_TYPES.numeric,
|
|
34
|
+
}),
|
|
35
|
+
initialSnapPosition: createTextEnumProp({
|
|
36
|
+
label: "Initial snap position",
|
|
37
|
+
description: "Initial snap position that bottom sheet will snap to",
|
|
38
|
+
options: ["top", "middle", "bottom"],
|
|
39
|
+
defaultValue: "bottom",
|
|
24
40
|
}),
|
|
25
41
|
showHandle: createStaticBoolProp({
|
|
26
42
|
label: "Show handle",
|
|
@@ -59,5 +75,17 @@ export const SEED_DATA = {
|
|
|
59
75
|
description: "When true, the scroll view bounces when it reaches the end of the content if the content is larger then the scroll view along the axis of the scroll direction.",
|
|
60
76
|
defaultValue: true,
|
|
61
77
|
}),
|
|
78
|
+
snapPoints: createArrayProp({
|
|
79
|
+
label: "Custom Snap points",
|
|
80
|
+
description: "An array of numerical values (that represent distance from the top) where bottom sheet can snap to. Accepts numbers and percentages (minimum 2 snap points). Overrides snap position props",
|
|
81
|
+
defaultValue: null,
|
|
82
|
+
}),
|
|
83
|
+
initialSnapIndex: createStaticNumberProp({
|
|
84
|
+
label: "Initial snap index",
|
|
85
|
+
description: "Index of the snap point to be used as the initial point. Overrides initial snap position",
|
|
86
|
+
defaultValue: null,
|
|
87
|
+
required: false,
|
|
88
|
+
group: GROUPS.advanced,
|
|
89
|
+
}),
|
|
62
90
|
},
|
|
63
91
|
};
|
|
@@ -7,6 +7,9 @@ import {
|
|
|
7
7
|
createColorProp,
|
|
8
8
|
createStaticNumberProp,
|
|
9
9
|
createArrayProp,
|
|
10
|
+
GROUPS,
|
|
11
|
+
createTextEnumProp,
|
|
12
|
+
FORM_TYPES,
|
|
10
13
|
} from "@draftbit/types";
|
|
11
14
|
|
|
12
15
|
export const SEED_DATA = {
|
|
@@ -22,17 +25,35 @@ export const SEED_DATA = {
|
|
|
22
25
|
label: "On settle",
|
|
23
26
|
description: "Action to execute when sheet settles on a snap point",
|
|
24
27
|
}),
|
|
25
|
-
|
|
26
|
-
label: "
|
|
28
|
+
topSnapPosition: createStaticNumberProp({
|
|
29
|
+
label: "Top snap position",
|
|
27
30
|
description:
|
|
28
|
-
"
|
|
29
|
-
defaultValue:
|
|
31
|
+
"Top most postion where bottom sheet can snap to. A numerical value that represents distance from the top",
|
|
32
|
+
defaultValue: "10%",
|
|
33
|
+
required: false,
|
|
34
|
+
formType: FORM_TYPES.numeric,
|
|
30
35
|
}),
|
|
31
|
-
|
|
32
|
-
label: "
|
|
33
|
-
description:
|
|
34
|
-
|
|
36
|
+
middleSnapPosition: createStaticNumberProp({
|
|
37
|
+
label: "Middle snap position",
|
|
38
|
+
description:
|
|
39
|
+
"Middle postion where bottom sheet can snap to. A numerical value that represents distance from the top",
|
|
40
|
+
defaultValue: "50%",
|
|
35
41
|
required: false,
|
|
42
|
+
formType: FORM_TYPES.numeric,
|
|
43
|
+
}),
|
|
44
|
+
bottomSnapPosition: createStaticNumberProp({
|
|
45
|
+
label: "Bottom snap position",
|
|
46
|
+
description:
|
|
47
|
+
"Bottom most postion where bottom sheet can snap to. A numerical value that represents distance from the top",
|
|
48
|
+
defaultValue: "80%",
|
|
49
|
+
required: false,
|
|
50
|
+
formType: FORM_TYPES.numeric,
|
|
51
|
+
}),
|
|
52
|
+
initialSnapPosition: createTextEnumProp({
|
|
53
|
+
label: "Initial snap position",
|
|
54
|
+
description: "Initial snap position that bottom sheet will snap to",
|
|
55
|
+
options: ["top", "middle", "bottom"],
|
|
56
|
+
defaultValue: "bottom",
|
|
36
57
|
}),
|
|
37
58
|
showHandle: createStaticBoolProp({
|
|
38
59
|
label: "Show handle",
|
|
@@ -73,5 +94,19 @@ export const SEED_DATA = {
|
|
|
73
94
|
"When true, the scroll view bounces when it reaches the end of the content if the content is larger then the scroll view along the axis of the scroll direction.",
|
|
74
95
|
defaultValue: true,
|
|
75
96
|
}),
|
|
97
|
+
snapPoints: createArrayProp({
|
|
98
|
+
label: "Custom Snap points",
|
|
99
|
+
description:
|
|
100
|
+
"An array of numerical values (that represent distance from the top) where bottom sheet can snap to. Accepts numbers and percentages (minimum 2 snap points). Overrides snap position props",
|
|
101
|
+
defaultValue: null,
|
|
102
|
+
}),
|
|
103
|
+
initialSnapIndex: createStaticNumberProp({
|
|
104
|
+
label: "Initial snap index",
|
|
105
|
+
description:
|
|
106
|
+
"Index of the snap point to be used as the initial point. Overrides initial snap position",
|
|
107
|
+
defaultValue: null,
|
|
108
|
+
required: false,
|
|
109
|
+
group: GROUPS.advanced,
|
|
110
|
+
}),
|
|
76
111
|
},
|
|
77
112
|
};
|