@draftbit/core 46.2.4-8bc8d1.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/{DSvg.js → SVG.js} +7 -6
  10. package/lib/commonjs/components/Slider.js +24 -5
  11. package/lib/commonjs/index.js +15 -7
  12. package/lib/commonjs/mappings/BottomSheet.js +22 -0
  13. package/lib/commonjs/mappings/{DSvg.js → SVG.js} +0 -2
  14. package/lib/module/components/BottomSheet/BottomSheet.native.js +50 -0
  15. package/lib/module/components/BottomSheet/BottomSheet.web.js +82 -0
  16. package/lib/module/components/BottomSheet/index.js +2 -0
  17. package/lib/module/components/BottomSheet/types.js +1 -0
  18. package/lib/module/components/Button.js +32 -11
  19. package/lib/module/components/CircleImage.js +17 -2
  20. package/lib/module/components/Config.js +1 -1
  21. package/lib/module/components/FAB.js +23 -5
  22. package/lib/module/components/Image.js +18 -3
  23. package/lib/module/components/Layout.js +43 -21
  24. package/lib/module/components/{DSvg.js → SVG.js} +7 -6
  25. package/lib/module/components/Switch.js +23 -10
  26. package/lib/module/index.js +2 -1
  27. package/lib/module/mappings/BottomSheet.js +13 -0
  28. package/lib/module/mappings/SVG.js +14 -0
  29. package/lib/typescript/src/components/BottomSheet/BottomSheet.native.d.ts +4 -0
  30. package/lib/typescript/src/components/BottomSheet/BottomSheet.web.d.ts +4 -0
  31. package/lib/typescript/src/components/BottomSheet/index.d.ts +1 -0
  32. package/lib/typescript/src/components/BottomSheet/types.d.ts +8 -0
  33. package/lib/typescript/src/components/SVG.d.ts +8 -0
  34. package/lib/typescript/src/index.d.ts +2 -1
  35. package/lib/typescript/src/mappings/{DSvg.d.ts → SVG.d.ts} +0 -2
  36. package/package.json +3 -3
  37. package/src/components/BottomSheet/BottomSheet.native.js +37 -0
  38. package/src/components/BottomSheet/BottomSheet.native.tsx +60 -0
  39. package/src/components/BottomSheet/BottomSheet.web.js +56 -0
  40. package/src/components/BottomSheet/BottomSheet.web.tsx +90 -0
  41. package/src/components/BottomSheet/index.js +2 -0
  42. package/src/components/BottomSheet/index.tsx +2 -0
  43. package/src/components/BottomSheet/types.js +1 -0
  44. package/src/components/BottomSheet/types.tsx +8 -0
  45. package/src/components/Config.js +1 -1
  46. package/src/components/Config.ts +1 -1
  47. package/src/components/{DSvg.js → SVG.js} +6 -5
  48. package/src/components/{DSvg.tsx → SVG.tsx} +9 -9
  49. package/src/index.js +2 -1
  50. package/src/index.tsx +2 -1
  51. package/src/mappings/BottomSheet.js +25 -0
  52. package/src/mappings/SVG.js +14 -0
  53. package/src/mappings/SVG.ts +15 -0
  54. package/lib/module/mappings/DSvg.js +0 -16
  55. package/lib/typescript/src/components/DSvg.d.ts +0 -8
  56. package/src/mappings/DSvg.js +0 -21
  57. package/src/mappings/DSvg.ts +0 -26
@@ -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 DSvg = ({ 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
- export default DSvg;
14
+ export default SVG;
@@ -4,32 +4,32 @@ import { SvgUri } from "react-native-svg";
4
4
 
5
5
  import Config from "./Config";
6
6
 
7
- type SvgComponentProps = {
7
+ type SVGComponentProps = {
8
8
  source: string;
9
9
  style?: StyleProp<ImageStyle>;
10
10
  };
11
11
 
12
- const DSvg: 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
  );
33
33
  };
34
34
 
35
- export default DSvg;
35
+ export default SVG;
package/src/index.js CHANGED
@@ -17,7 +17,7 @@ export { default as FAB } from "./components/FAB";
17
17
  export { default as FieldSearchBarFull } from "./components/FieldSearchBarFull";
18
18
  export { default as IconButton } from "./components/IconButton";
19
19
  export { default as Image } from "./components/Image";
20
- export { default as DSvg } from "./components/DSvg";
20
+ export { default as SVG } from "./components/SVG";
21
21
  export { default as NumberInput } from "./components/NumberInput";
22
22
  export { default as ScreenContainer } from "./components/ScreenContainer";
23
23
  export { default as StarRating } from "./components/StarRating";
@@ -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
@@ -18,7 +18,7 @@ export { default as FAB } from "./components/FAB";
18
18
  export { default as FieldSearchBarFull } from "./components/FieldSearchBarFull";
19
19
  export { default as IconButton } from "./components/IconButton";
20
20
  export { default as Image } from "./components/Image";
21
- export { default as DSvg } from "./components/DSvg";
21
+ export { default as SVG } from "./components/SVG";
22
22
  export { default as NumberInput } from "./components/NumberInput";
23
23
  export { default as ScreenContainer } from "./components/ScreenContainer";
24
24
  export { default as StarRating } from "./components/StarRating";
@@ -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
+ };
@@ -0,0 +1,14 @@
1
+ import { COMPONENT_TYPES, createSvgProp } from "@draftbit/types";
2
+ export const SEED_DATA = {
3
+ name: "SVG",
4
+ tag: "SVG",
5
+ description: "An SVG component",
6
+ category: COMPONENT_TYPES.media,
7
+ layout: {
8
+ width: 100,
9
+ height: 100,
10
+ },
11
+ props: {
12
+ source: createSvgProp(),
13
+ },
14
+ };
@@ -0,0 +1,15 @@
1
+ import { COMPONENT_TYPES, createSvgProp } from "@draftbit/types";
2
+
3
+ export const SEED_DATA = {
4
+ name: "SVG",
5
+ tag: "SVG",
6
+ description: "An SVG component",
7
+ category: COMPONENT_TYPES.media,
8
+ layout: {
9
+ width: 100,
10
+ height: 100,
11
+ },
12
+ props: {
13
+ source: createSvgProp(),
14
+ },
15
+ };
@@ -1,16 +0,0 @@
1
- import { COMPONENT_TYPES, createSvgProp, StylesPanelSections } from "@draftbit/types";
2
- export const SEED_DATA = {
3
- name: "SVG",
4
- tag: "SVG",
5
- description: "An SVG component",
6
- packageName: "@draftbit/core",
7
- category: COMPONENT_TYPES.media,
8
- layout: {
9
- width: 100,
10
- height: 100
11
- },
12
- stylesPanelSections: [StylesPanelSections.Size, StylesPanelSections.Margins, StylesPanelSections.Position, StylesPanelSections.Effects],
13
- props: {
14
- source: createSvgProp()
15
- }
16
- };
@@ -1,8 +0,0 @@
1
- import * as React from "react";
2
- import { StyleProp, ImageStyle } from "react-native";
3
- declare type SvgComponentProps = {
4
- source: string;
5
- style?: StyleProp<ImageStyle>;
6
- };
7
- declare const DSvg: React.FC<React.PropsWithChildren<SvgComponentProps>>;
8
- export default DSvg;
@@ -1,21 +0,0 @@
1
- import { COMPONENT_TYPES, createSvgProp, StylesPanelSections, } from "@draftbit/types";
2
- export const SEED_DATA = {
3
- name: "SVG",
4
- tag: "SVG",
5
- description: "An SVG component",
6
- packageName: "@draftbit/core",
7
- category: COMPONENT_TYPES.media,
8
- layout: {
9
- width: 100,
10
- height: 100,
11
- },
12
- stylesPanelSections: [
13
- StylesPanelSections.Size,
14
- StylesPanelSections.Margins,
15
- StylesPanelSections.Position,
16
- StylesPanelSections.Effects,
17
- ],
18
- props: {
19
- source: createSvgProp(),
20
- },
21
- };
@@ -1,26 +0,0 @@
1
- import {
2
- COMPONENT_TYPES,
3
- createSvgProp,
4
- StylesPanelSections,
5
- } from "@draftbit/types";
6
-
7
- export const SEED_DATA = {
8
- name: "SVG",
9
- tag: "SVG",
10
- description: "An SVG component",
11
- packageName: "@draftbit/core",
12
- category: COMPONENT_TYPES.media,
13
- layout: {
14
- width: 100,
15
- height: 100,
16
- },
17
- stylesPanelSections: [
18
- StylesPanelSections.Size,
19
- StylesPanelSections.Margins,
20
- StylesPanelSections.Position,
21
- StylesPanelSections.Effects,
22
- ],
23
- props: {
24
- source: createSvgProp(),
25
- },
26
- };