@draftbit/core 46.2.4-8c832d.5 → 46.2.4-8ee341.5

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.
Files changed (57) hide show
  1. package/lib/commonjs/components/BottomSheet/BottomSheet.native.js +68 -0
  2. package/lib/commonjs/components/BottomSheet/BottomSheet.web.js +97 -0
  3. package/lib/commonjs/components/BottomSheet/index.js +15 -0
  4. package/lib/commonjs/components/BottomSheet/types.js +5 -0
  5. package/lib/commonjs/components/Checkbox/CheckboxRow.js +24 -6
  6. package/lib/commonjs/components/Checkbox/context.js +1 -1
  7. package/lib/commonjs/components/CircularProgress.js +15 -7
  8. package/lib/commonjs/components/Config.js +1 -1
  9. package/lib/commonjs/components/SVG.js +5 -4
  10. package/lib/commonjs/components/Slider.js +24 -5
  11. package/lib/commonjs/components/StarRating.js +0 -1
  12. package/lib/commonjs/index.js +8 -0
  13. package/lib/commonjs/mappings/BottomSheet.js +22 -0
  14. package/lib/commonjs/mappings/SVG.js +1 -3
  15. package/lib/module/components/BottomSheet/BottomSheet.native.js +50 -0
  16. package/lib/module/components/BottomSheet/BottomSheet.web.js +82 -0
  17. package/lib/module/components/BottomSheet/index.js +2 -0
  18. package/lib/module/components/BottomSheet/types.js +1 -0
  19. package/lib/module/components/Button.js +32 -11
  20. package/lib/module/components/CircleImage.js +17 -2
  21. package/lib/module/components/Config.js +1 -1
  22. package/lib/module/components/FAB.js +23 -5
  23. package/lib/module/components/Image.js +18 -3
  24. package/lib/module/components/Layout.js +43 -21
  25. package/lib/module/components/SVG.js +5 -4
  26. package/lib/module/components/StarRating.js +0 -1
  27. package/lib/module/components/Switch.js +23 -10
  28. package/lib/module/index.js +1 -0
  29. package/lib/module/mappings/BottomSheet.js +13 -0
  30. package/lib/module/mappings/SVG.js +2 -4
  31. package/lib/typescript/src/components/BottomSheet/BottomSheet.native.d.ts +4 -0
  32. package/lib/typescript/src/components/BottomSheet/BottomSheet.web.d.ts +4 -0
  33. package/lib/typescript/src/components/BottomSheet/index.d.ts +1 -0
  34. package/lib/typescript/src/components/BottomSheet/types.d.ts +8 -0
  35. package/lib/typescript/src/components/SVG.d.ts +2 -2
  36. package/lib/typescript/src/index.d.ts +1 -0
  37. package/lib/typescript/src/mappings/SVG.d.ts +0 -2
  38. package/package.json +3 -3
  39. package/src/components/BottomSheet/BottomSheet.native.js +37 -0
  40. package/src/components/BottomSheet/BottomSheet.native.tsx +60 -0
  41. package/src/components/BottomSheet/BottomSheet.web.js +56 -0
  42. package/src/components/BottomSheet/BottomSheet.web.tsx +90 -0
  43. package/src/components/BottomSheet/index.js +2 -0
  44. package/src/components/BottomSheet/index.tsx +2 -0
  45. package/src/components/BottomSheet/types.js +1 -0
  46. package/src/components/BottomSheet/types.tsx +8 -0
  47. package/src/components/Config.js +1 -1
  48. package/src/components/Config.ts +1 -1
  49. package/src/components/SVG.js +5 -4
  50. package/src/components/SVG.tsx +7 -7
  51. package/src/components/StarRating.js +0 -1
  52. package/src/components/StarRating.tsx +0 -1
  53. package/src/index.js +1 -0
  54. package/src/index.tsx +1 -0
  55. package/src/mappings/BottomSheet.js +25 -0
  56. package/src/mappings/SVG.js +2 -9
  57. package/src/mappings/SVG.ts +2 -13
@@ -0,0 +1,60 @@
1
+ import React, { useCallback, useMemo, useRef } from "react";
2
+ import { View, StyleSheet } from "react-native";
3
+ import BottomSheet, { BottomSheetView } from "@gorhom/bottom-sheet";
4
+
5
+ import { extractStyles } from "../../utilities";
6
+ import { BottomSheetProps } from "./types";
7
+
8
+ const BottomSheetComponent: React.FC<BottomSheetProps> = ({
9
+ style,
10
+ children,
11
+ step,
12
+ }) => {
13
+ const bottomSheetRef = useRef<BottomSheet>(null);
14
+ const { viewStyles } = extractStyles(style);
15
+
16
+ // variables
17
+ const snapPoints = useMemo(() => ["25%", "50%", "90%"], []);
18
+
19
+ // callbacks
20
+ const handleSheetChanges = useCallback((index: number) => {
21
+ console.log("handleSheetChanges", index);
22
+ }, []);
23
+
24
+ React.useEffect(() => {
25
+ if (step === -1) {
26
+ bottomSheetRef?.current?.close();
27
+ }
28
+ }, [step]);
29
+
30
+ return (
31
+ <View
32
+ style={[
33
+ containerStyle.container,
34
+ viewStyles,
35
+ { backgroundColor: step !== -1 ? "grey" : "transparent" },
36
+ ]}
37
+ >
38
+ <BottomSheet
39
+ ref={bottomSheetRef}
40
+ index={step}
41
+ snapPoints={snapPoints}
42
+ onChange={handleSheetChanges}
43
+ >
44
+ <BottomSheetView>{children}</BottomSheetView>
45
+ </BottomSheet>
46
+ </View>
47
+ );
48
+ };
49
+
50
+ export default BottomSheetComponent;
51
+
52
+ const containerStyle = StyleSheet.create({
53
+ container: {
54
+ flex: 1,
55
+ },
56
+ contentContainer: {
57
+ flex: 1,
58
+ alignItems: "center",
59
+ },
60
+ });
@@ -0,0 +1,56 @@
1
+ import React from "react";
2
+ import { StyleSheet, View, Dimensions } from "react-native";
3
+ import ScrollBottomSheet from "react-native-scroll-bottom-sheet";
4
+ import { extractStyles } from "../../utilities";
5
+ const windowHeight = Dimensions.get("window").height;
6
+ const BottomSheetComponent = ({ style, children, step, }) => {
7
+ const { viewStyles } = extractStyles(style);
8
+ const bottomSheetRef = React.useRef();
9
+ const webStep = React.useMemo(() => step + 1, [step]);
10
+ const snapPoints = React.useMemo(() => ["25%", "50%", windowHeight - 200], []);
11
+ React.useEffect(() => {
12
+ var _a;
13
+ (_a = bottomSheetRef === null || bottomSheetRef === void 0 ? void 0 : bottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.snapTo(snapPoints.length - webStep);
14
+ // bottomSheetRef.current.snapTo(step);
15
+ }, [webStep, step, snapPoints]);
16
+ if (step === -1) {
17
+ return React.createElement(React.Fragment, null);
18
+ }
19
+ return (React.createElement(View, { style: styles.container },
20
+ React.createElement(ScrollBottomSheet, { ref: bottomSheetRef, componentType: "ScrollView", snapPoints: snapPoints, initialSnapIndex: 0, renderHandle: () => (React.createElement(View, { style: styles.header },
21
+ React.createElement(View, { style: styles.panelHandle }))), contentContainerStyle: styles.contentContainerStyle },
22
+ React.createElement(View, { style: {
23
+ ...styles.container,
24
+ ...viewStyles,
25
+ backgroundColor: webStep !== -1 ? "grey" : "transparent",
26
+ } }, children))));
27
+ };
28
+ export default BottomSheetComponent;
29
+ const styles = StyleSheet.create({
30
+ container: {
31
+ flex: 1,
32
+ },
33
+ contentContainerStyle: {
34
+ padding: 16,
35
+ },
36
+ header: {
37
+ alignItems: "center",
38
+ backgroundColor: "white",
39
+ paddingVertical: 20,
40
+ borderTopLeftRadius: 20,
41
+ borderTopRightRadius: 20,
42
+ },
43
+ panelHandle: {
44
+ width: 40,
45
+ height: 2,
46
+ backgroundColor: "rgba(0,0,0,0.3)",
47
+ borderRadius: 4,
48
+ },
49
+ item: {
50
+ padding: 20,
51
+ justifyContent: "center",
52
+ backgroundColor: "white",
53
+ alignItems: "center",
54
+ marginVertical: 10,
55
+ },
56
+ });
@@ -0,0 +1,90 @@
1
+ import React from "react";
2
+ import { StyleSheet, View, Dimensions } from "react-native";
3
+ import ScrollBottomSheet from "react-native-scroll-bottom-sheet";
4
+
5
+ import { extractStyles } from "../../utilities";
6
+ import { BottomSheetProps } from "./types";
7
+
8
+ const windowHeight = Dimensions.get("window").height;
9
+
10
+ const BottomSheetComponent: React.FC<BottomSheetProps> = ({
11
+ style,
12
+ children,
13
+ step,
14
+ }) => {
15
+ const { viewStyles } = extractStyles(style);
16
+ const bottomSheetRef = React.useRef<any>();
17
+
18
+ const webStep = React.useMemo(() => step + 1, [step]);
19
+ const snapPoints = React.useMemo(
20
+ () => ["25%", "50%", windowHeight - 200],
21
+ []
22
+ );
23
+
24
+ React.useEffect(() => {
25
+ bottomSheetRef?.current?.snapTo(snapPoints.length - webStep);
26
+ // bottomSheetRef.current.snapTo(step);
27
+ }, [webStep, step, snapPoints]);
28
+
29
+ if (step === -1) {
30
+ return <></>;
31
+ }
32
+
33
+ return (
34
+ <View style={styles.container}>
35
+ <ScrollBottomSheet
36
+ ref={bottomSheetRef}
37
+ componentType="ScrollView"
38
+ snapPoints={snapPoints}
39
+ initialSnapIndex={0}
40
+ renderHandle={() => (
41
+ <View style={styles.header}>
42
+ <View style={styles.panelHandle} />
43
+ </View>
44
+ )}
45
+ contentContainerStyle={styles.contentContainerStyle}
46
+ >
47
+ <View
48
+ style={{
49
+ ...styles.container,
50
+ ...viewStyles,
51
+ backgroundColor: webStep !== -1 ? "grey" : "transparent",
52
+ }}
53
+ >
54
+ {children}
55
+ </View>
56
+ </ScrollBottomSheet>
57
+ </View>
58
+ );
59
+ };
60
+
61
+ export default BottomSheetComponent;
62
+
63
+ const styles = StyleSheet.create({
64
+ container: {
65
+ flex: 1,
66
+ },
67
+ contentContainerStyle: {
68
+ padding: 16,
69
+ },
70
+ header: {
71
+ alignItems: "center",
72
+ backgroundColor: "white",
73
+ paddingVertical: 20,
74
+ borderTopLeftRadius: 20,
75
+ borderTopRightRadius: 20,
76
+ },
77
+ panelHandle: {
78
+ width: 40,
79
+ height: 2,
80
+ backgroundColor: "rgba(0,0,0,0.3)",
81
+ borderRadius: 4,
82
+ },
83
+ item: {
84
+ padding: 20,
85
+ justifyContent: "center",
86
+ backgroundColor: "white",
87
+ alignItems: "center",
88
+ marginVertical: 10,
89
+ },
90
+ });
@@ -0,0 +1,2 @@
1
+ //@ts-ignore
2
+ export { default as BottomSheet } from "./BottomSheet";
@@ -0,0 +1,2 @@
1
+ //@ts-ignore
2
+ export { default as BottomSheet } from "./BottomSheet";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { StyleProp, ViewStyle, TextStyle } from "react-native";
2
+
3
+ export interface BottomSheetProps {
4
+ style: StyleProp<ViewStyle | TextStyle>;
5
+ children: React.ReactNode;
6
+ step: number;
7
+ isOpen?: Boolean;
8
+ }
@@ -42,7 +42,7 @@ export default {
42
42
  cardIconElevation: 1,
43
43
  placeholderImageURL: "https://static.draftbit.com/images/placeholder-image" + getExtension(),
44
44
  getPlaceholderImageUrl: (size) => buildImageUrl({ width: size.width, height: size.height }, "image-placeholder_1"),
45
- placeholderSvgURL: "https://static.draftbit.com/images/placeholder-image.svg",
45
+ placeholderSvgURL: "https://static.draftbit.com/images/placeholder-svg.svg",
46
46
  squareImageUrl: buildImageUrl({ width: 100, height: 100 }, "Avatar"),
47
47
  FABSize: 40,
48
48
  FABBorderRadius: 20,
@@ -60,7 +60,7 @@ export default {
60
60
  { width: size.width, height: size.height },
61
61
  "image-placeholder_1"
62
62
  ),
63
- placeholderSvgURL: "https://static.draftbit.com/images/placeholder-image.svg",
63
+ placeholderSvgURL: "https://static.draftbit.com/images/placeholder-svg.svg",
64
64
  squareImageUrl: buildImageUrl({ width: 100, height: 100 }, "Avatar"),
65
65
  FABSize: 40,
66
66
  FABBorderRadius: 20,
@@ -2,12 +2,13 @@ import * as React from "react";
2
2
  import { View, Platform, Image } from "react-native";
3
3
  import { SvgUri } from "react-native-svg";
4
4
  import Config from "./Config";
5
- const SVG = ({ source = Config.placeholderSvgURL, style, }) => {
5
+ const SVG = ({ source, style }) => {
6
+ let svgSource = source === null || source === undefined ? Config.placeholderSvgURL : source;
6
7
  return (React.createElement(React.Fragment, null,
7
8
  Platform.OS === "ios" && (React.createElement(View, { style: style },
8
- React.createElement(SvgUri, { width: "100%", height: "100%", uri: source }))),
9
+ React.createElement(SvgUri, { width: "100%", height: "100%", uri: svgSource }))),
9
10
  Platform.OS === "android" && (React.createElement(View, { style: style },
10
- React.createElement(SvgUri, { width: "100%", height: "100%", uri: source }))),
11
- Platform.OS === "web" && (React.createElement(Image, { style: style, source: { uri: source } }))));
11
+ React.createElement(SvgUri, { width: "100%", height: "100%", uri: svgSource }))),
12
+ Platform.OS === "web" && (React.createElement(Image, { style: style, source: { uri: svgSource } }))));
12
13
  };
13
14
  export default SVG;
@@ -9,24 +9,24 @@ type SVGComponentProps = {
9
9
  style?: StyleProp<ImageStyle>;
10
10
  };
11
11
 
12
- const SVG: React.FC<React.PropsWithChildren<SVGComponentProps>> = ({
13
- source = Config.placeholderSvgURL,
14
- style,
15
- }) => {
12
+ const SVG = ({ source, style }: SVGComponentProps) => {
13
+ let svgSource =
14
+ source === null || source === undefined ? Config.placeholderSvgURL : source;
15
+
16
16
  return (
17
17
  <>
18
18
  {Platform.OS === "ios" && (
19
19
  <View style={style}>
20
- <SvgUri width="100%" height="100%" uri={source} />
20
+ <SvgUri width="100%" height="100%" uri={svgSource} />
21
21
  </View>
22
22
  )}
23
23
  {Platform.OS === "android" && (
24
24
  <View style={style}>
25
- <SvgUri width="100%" height="100%" uri={source} />
25
+ <SvgUri width="100%" height="100%" uri={svgSource} />
26
26
  </View>
27
27
  )}
28
28
  {Platform.OS === "web" && (
29
- <Image style={style} source={{ uri: source }} />
29
+ <Image style={style} source={{ uri: svgSource }} />
30
30
  )}
31
31
  </>
32
32
  );
@@ -27,7 +27,6 @@ const StarRating = ({ Icon, starSize = 16, maxStars = 5, rating = 0, defaultValu
27
27
  React.createElement(Pressable, { style: styles.pressable, onPress: () => ratingHandler(i + 1) }))))))));
28
28
  };
29
29
  const styles = StyleSheet.create({
30
- //comment!
31
30
  container: {
32
31
  flexDirection: "row",
33
32
  alignItems: "center",
@@ -94,7 +94,6 @@ const StarRating: React.FC<React.PropsWithChildren<Props>> = ({
94
94
  };
95
95
 
96
96
  const styles = StyleSheet.create({
97
- //comment!
98
97
  container: {
99
98
  flexDirection: "row",
100
99
  alignItems: "center",
package/src/index.js CHANGED
@@ -29,6 +29,7 @@ export { default as Touchable } from "./components/Touchable";
29
29
  export { AccordionGroup, AccordionItem } from "./components/Accordion";
30
30
  export { ActionSheet, ActionSheetItem, ActionSheetCancel, } from "./components/ActionSheet";
31
31
  export { Swiper, SwiperItem } from "./components/Swiper";
32
+ export { BottomSheet } from "./components/BottomSheet";
32
33
  export { Center, Circle, Square, Row, Stack, Spacer, } from "./components/Layout";
33
34
  export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup, } from "./components/RadioButton/index";
34
35
  /* Deprecated: Fix or Delete! */
package/src/index.tsx CHANGED
@@ -34,6 +34,7 @@ export {
34
34
  ActionSheetCancel,
35
35
  } from "./components/ActionSheet";
36
36
  export { Swiper, SwiperItem } from "./components/Swiper";
37
+ export { BottomSheet } from "./components/BottomSheet";
37
38
 
38
39
  export {
39
40
  Center,
@@ -0,0 +1,25 @@
1
+ import {
2
+ COMPONENT_TYPES,
3
+ createNumberProp,
4
+ StylesPanelSections,
5
+ } from "@draftbit/types";
6
+
7
+ export const SEED_DATA = {
8
+ name: "Bottom Sheet",
9
+ tag: "BotttomSheet",
10
+ category: COMPONENT_TYPES.container,
11
+ stylesPanelSections: [
12
+ StylesPanelSections.Background,
13
+ StylesPanelSections.Borders,
14
+ StylesPanelSections.Size,
15
+ StylesPanelSections.MarginsAndPaddings,
16
+ StylesPanelSections.Position,
17
+ StylesPanelSections.Effects,
18
+ ],
19
+ props: {
20
+ step: createNumberProp({
21
+ label: "Step",
22
+ description: "Step can be -1, 0, 1, or 2.",
23
+ }),
24
+ },
25
+ };
@@ -1,21 +1,14 @@
1
- import { COMPONENT_TYPES, createSVGProp, StylesPanelSections, } from "@draftbit/types";
1
+ import { COMPONENT_TYPES, createSvgProp } from "@draftbit/types";
2
2
  export const SEED_DATA = {
3
3
  name: "SVG",
4
4
  tag: "SVG",
5
5
  description: "An SVG component",
6
- packageName: "@draftbit/core",
7
6
  category: COMPONENT_TYPES.media,
8
7
  layout: {
9
8
  width: 100,
10
9
  height: 100,
11
10
  },
12
- stylesPanelSections: [
13
- StylesPanelSections.Size,
14
- StylesPanelSections.Margins,
15
- StylesPanelSections.Position,
16
- StylesPanelSections.Effects,
17
- ],
18
11
  props: {
19
- source: createSVGProp(),
12
+ source: createSvgProp(),
20
13
  },
21
14
  };
@@ -1,26 +1,15 @@
1
- import {
2
- COMPONENT_TYPES,
3
- createSVGProp,
4
- StylesPanelSections,
5
- } from "@draftbit/types";
1
+ import { COMPONENT_TYPES, createSvgProp } from "@draftbit/types";
6
2
 
7
3
  export const SEED_DATA = {
8
4
  name: "SVG",
9
5
  tag: "SVG",
10
6
  description: "An SVG component",
11
- packageName: "@draftbit/core",
12
7
  category: COMPONENT_TYPES.media,
13
8
  layout: {
14
9
  width: 100,
15
10
  height: 100,
16
11
  },
17
- stylesPanelSections: [
18
- StylesPanelSections.Size,
19
- StylesPanelSections.Margins,
20
- StylesPanelSections.Position,
21
- StylesPanelSections.Effects,
22
- ],
23
12
  props: {
24
- source: createSVGProp(),
13
+ source: createSvgProp(),
25
14
  },
26
15
  };