@draftbit/core 42.1.5 → 42.1.7-71d4c6.1

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 (127) hide show
  1. package/LICENSE +21 -0
  2. package/lib/commonjs/components/DatePicker/DatePicker.js +6 -1
  3. package/lib/commonjs/components/DatePicker/DatePicker.js.map +1 -1
  4. package/lib/commonjs/components/DatePicker/DatePickerComponentType.js +2 -0
  5. package/lib/commonjs/components/Divider.js +18 -5
  6. package/lib/commonjs/components/Divider.js.map +1 -1
  7. package/lib/commonjs/components/Elevation.js +14 -3
  8. package/lib/commonjs/components/Elevation.js.map +1 -1
  9. package/lib/commonjs/components/Justification.js +3 -0
  10. package/lib/commonjs/components/Picker/PickerComponent.android.js +4 -1
  11. package/lib/commonjs/components/Picker/PickerComponent.android.js.map +1 -1
  12. package/lib/commonjs/components/Picker/PickerComponent.web.js +4 -1
  13. package/lib/commonjs/components/Picker/PickerComponent.web.js.map +1 -1
  14. package/lib/commonjs/components/Picker/PickerTypes.js +3 -0
  15. package/lib/commonjs/components/Portal/PortalHost.js.map +1 -1
  16. package/lib/commonjs/components/ResizeMode.js +3 -0
  17. package/lib/module/components/DatePicker/DatePicker.js +6 -1
  18. package/lib/module/components/DatePicker/DatePicker.js.map +1 -1
  19. package/lib/module/components/DatePicker/DatePickerComponentType.js +1 -1
  20. package/lib/module/components/Justification.js +1 -1
  21. package/lib/module/components/Picker/PickerComponent.android.js +4 -1
  22. package/lib/module/components/Picker/PickerComponent.android.js.map +1 -1
  23. package/lib/module/components/Picker/PickerComponent.web.js +4 -1
  24. package/lib/module/components/Picker/PickerComponent.web.js.map +1 -1
  25. package/lib/module/components/Picker/PickerTypes.js +1 -1
  26. package/lib/module/components/ResizeMode.js +1 -1
  27. package/package.json +3 -2
  28. package/src/Provider.js +9 -0
  29. package/src/components/Accordion/AccordionGroup.js +94 -0
  30. package/src/components/Accordion/AccordionItem.js +48 -0
  31. package/src/components/Accordion/index.js +2 -0
  32. package/src/components/ActionSheet/ActionSheet.js +57 -0
  33. package/src/components/ActionSheet/ActionSheetCancel.js +28 -0
  34. package/src/components/ActionSheet/ActionSheetItem.js +49 -0
  35. package/src/components/ActionSheet/index.js +3 -0
  36. package/src/components/AnimatedCircularProgress.js +43 -0
  37. package/src/components/AspectRatio.js +18 -0
  38. package/src/components/AvatarEdit.js +67 -0
  39. package/src/components/Button.js +187 -0
  40. package/src/components/Card.js +109 -0
  41. package/src/components/CardBlock.js +176 -0
  42. package/src/components/CardContainer.js +171 -0
  43. package/src/components/CardContainerRating.js +203 -0
  44. package/src/components/CardContainerShortImage.js +151 -0
  45. package/src/components/CardInline.js +87 -0
  46. package/src/components/Carousel.js +85 -0
  47. package/src/components/Checkbox/Checkbox.js +114 -0
  48. package/src/components/Checkbox/CheckboxGroup.js +46 -0
  49. package/src/components/Checkbox/CheckboxRow.js +109 -0
  50. package/src/components/Checkbox/context.js +14 -0
  51. package/src/components/Checkbox/index.js +3 -0
  52. package/src/components/CircleImage.js +32 -0
  53. package/src/components/CircularProgress.js +78 -0
  54. package/src/components/Config.js +63 -0
  55. package/src/components/Container.js +73 -0
  56. package/src/components/DatePicker/DatePicker.js +379 -0
  57. package/src/components/DatePicker/DatePicker.tsx +7 -1
  58. package/src/components/DatePicker/DatePickerComponent.js +13 -0
  59. package/src/components/DatePicker/DatePickerComponent.web.js +30 -0
  60. package/src/components/DatePicker/DatePickerComponentType.js +1 -0
  61. package/src/components/DeprecatedButton.js +201 -0
  62. package/src/components/DeprecatedCardWrapper.js +18 -0
  63. package/src/components/DeprecatedFAB.js +261 -0
  64. package/src/components/Divider.js +39 -0
  65. package/src/components/Elevation.js +20 -0
  66. package/src/components/FAB.js +82 -0
  67. package/src/components/FieldSearchBarFull.js +92 -0
  68. package/src/components/FormRow.js +19 -0
  69. package/src/components/Header.js +44 -0
  70. package/src/components/HeaderLarge.js +35 -0
  71. package/src/components/HeaderMedium.js +61 -0
  72. package/src/components/HeaderOverline.js +61 -0
  73. package/src/components/IconButton.js +65 -0
  74. package/src/components/Image.js +62 -0
  75. package/src/components/Justification.js +1 -0
  76. package/src/components/Layout.js +245 -0
  77. package/src/components/Picker/Picker.js +204 -0
  78. package/src/components/Picker/PickerComponent.android.js +68 -0
  79. package/src/components/Picker/PickerComponent.android.tsx +6 -1
  80. package/src/components/Picker/PickerComponent.ios.js +72 -0
  81. package/src/components/Picker/PickerComponent.web.js +68 -0
  82. package/src/components/Picker/PickerComponent.web.tsx +6 -1
  83. package/src/components/Picker/PickerTypes.js +1 -0
  84. package/src/components/Portal/Portal.js +35 -0
  85. package/src/components/Portal/PortalConsumer.js +28 -0
  86. package/src/components/Portal/PortalHost.js +105 -0
  87. package/src/components/Portal/PortalManager.js +29 -0
  88. package/src/components/ProgressBar.js +218 -0
  89. package/src/components/ProgressCircle.js +121 -0
  90. package/src/components/ProgressIndicator.js +207 -0
  91. package/src/components/RadioButton/RadioButton.js +66 -0
  92. package/src/components/RadioButton/RadioButtonFieldGroup.js +17 -0
  93. package/src/components/RadioButton/RadioButtonGroup.js +43 -0
  94. package/src/components/RadioButton/RadioButtonRow.js +111 -0
  95. package/src/components/RadioButton/context.js +14 -0
  96. package/src/components/RadioButton/index.js +4 -0
  97. package/src/components/ResizeMode.js +1 -0
  98. package/src/components/Row.js +48 -0
  99. package/src/components/RowBodyIcon.js +83 -0
  100. package/src/components/RowHeadlineImageCaption.js +179 -0
  101. package/src/components/RowHeadlineImageIcon.js +113 -0
  102. package/src/components/ScreenContainer.js +35 -0
  103. package/src/components/Slider.js +114 -0
  104. package/src/components/StarRating.js +80 -0
  105. package/src/components/StepIndicator.js +346 -0
  106. package/src/components/Stepper.js +69 -0
  107. package/src/components/Surface.js +36 -0
  108. package/src/components/Switch.js +59 -0
  109. package/src/components/Text.js +232 -0
  110. package/src/components/TextField.js +552 -0
  111. package/src/components/TextInput.js +13 -0
  112. package/src/components/ToggleButton.js +75 -0
  113. package/src/components/Touchable.js +24 -0
  114. package/src/components/Touchable.web.js +2 -0
  115. package/src/components/Typography.js +36 -0
  116. package/src/components/useAuthState.js +31 -0
  117. package/src/constants.js +10 -0
  118. package/src/hooks.js +12 -0
  119. package/src/index.js +48 -0
  120. package/src/interfaces/Icon.js +8 -0
  121. package/src/styles/DarkTheme.js +26 -0
  122. package/src/styles/DefaultTheme.js +111 -0
  123. package/src/styles/fonts.js +62 -0
  124. package/src/styles/overlay.js +60 -0
  125. package/src/styles/shadow.js +51 -0
  126. package/src/theming.js +3 -0
  127. package/src/utilities.js +42 -0
@@ -0,0 +1,85 @@
1
+ import * as React from "react";
2
+ import { withTheme } from "../theming";
3
+ import { ScrollView, View, StyleSheet, Dimensions, } from "react-native";
4
+ import Image from "./Image";
5
+ import { COMPONENT_TYPES, createResizeModeProp, createColorProp, } from "@draftbit/types";
6
+ const screenWidth = Dimensions.get("window").width;
7
+ function Pager({ color, index, length, }) {
8
+ return (React.createElement(View, { style: styles.pager }, Array.from({ length }).map((_, i) => {
9
+ const current = index === i;
10
+ const opacity = current ? 1 : 0.5;
11
+ const size = current ? 10 : 8;
12
+ return (React.createElement(View, { key: i, style: [
13
+ styles.bullet,
14
+ { backgroundColor: color, opacity, width: size, height: size },
15
+ ] }));
16
+ })));
17
+ }
18
+ function Carousel({ data, children, dotColor = "strong", style, ...rest }) {
19
+ const [index, setIndex] = React.useState(0);
20
+ const length = React.Children.count(children);
21
+ const itemsLength = (data?.length ?? 0) + length;
22
+ const slides = Array.isArray(data) ? data : [];
23
+ const { width, height } = StyleSheet.flatten(style || {});
24
+ const slideWidth = width || screenWidth;
25
+ const slideHeight = height || 250;
26
+ return (React.createElement(View, { style: [styles.container, style], ...rest },
27
+ React.createElement(ScrollView, { pagingEnabled: true, horizontal: true, decelerationRate: "fast", scrollEventThrottle: 200, showsHorizontalScrollIndicator: false, onScroll: ({ nativeEvent }) => {
28
+ const layoutWidth = nativeEvent.layoutMeasurement.width;
29
+ const offset = nativeEvent.contentOffset.x;
30
+ const currentIndex = Math.ceil(offset / layoutWidth);
31
+ setIndex(currentIndex);
32
+ } },
33
+ slides.length > 0
34
+ ? slides.map((item, i) => {
35
+ return (React.createElement(Image, { key: i, resizeMode: "cover", source: typeof item === "string" ? { uri: item } : item, style: [{ width: slideWidth, height: slideHeight }] }));
36
+ })
37
+ : null,
38
+ React.Children.map(children, (child) => {
39
+ const s = child?.props?.style || {};
40
+ return (React.createElement(View, { style: { width: slideWidth } }, React.cloneElement(child, {
41
+ style: { ...s, width: slideWidth },
42
+ })));
43
+ })),
44
+ React.createElement(Pager, { color: dotColor, index: index, length: itemsLength })));
45
+ }
46
+ const styles = StyleSheet.create({
47
+ container: {
48
+ height: 250,
49
+ position: "relative",
50
+ width: screenWidth,
51
+ backgroundColor: "#eee",
52
+ },
53
+ pager: {
54
+ position: "absolute",
55
+ bottom: 12,
56
+ left: 0,
57
+ right: 0,
58
+ flexDirection: "row",
59
+ justifyContent: "center",
60
+ alignItems: "center",
61
+ },
62
+ bullet: {
63
+ marginHorizontal: 2,
64
+ width: 10,
65
+ height: 10,
66
+ borderRadius: 20,
67
+ backgroundColor: "#000",
68
+ },
69
+ });
70
+ export default withTheme(Carousel);
71
+ export const SEED_DATA = [
72
+ {
73
+ name: "Carousel",
74
+ tag: "Carousel",
75
+ category: COMPONENT_TYPES.media,
76
+ description: "A horizontal scrolling carousel of images",
77
+ layout: {},
78
+ props: {
79
+ resizeMode: createResizeModeProp(),
80
+ dotColor: createColorProp({
81
+ label: "Dot color",
82
+ }),
83
+ },
84
+ },
85
+ ];
@@ -0,0 +1,114 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, } from "react-native";
3
+ import { COMPONENT_TYPES, createBoolProp, createIconProp, createStaticNumberProp, createColorProp, createFieldNameProp, GROUPS, Triggers, } from "@draftbit/types";
4
+ import { useTheme } from "../../theming";
5
+ import Touchable from "../Touchable";
6
+ import { usePrevious } from "../../hooks";
7
+ export var CheckboxStatus;
8
+ (function (CheckboxStatus) {
9
+ CheckboxStatus["Checked"] = "checked";
10
+ CheckboxStatus["Unchecked"] = "unchecked";
11
+ CheckboxStatus["Indeterminate"] = "indeterminate";
12
+ })(CheckboxStatus || (CheckboxStatus = {}));
13
+ const Checkbox = ({ Icon, status = CheckboxStatus.Unchecked, disabled = false, onPress = () => { }, color, uncheckedColor, indeterminateColor, initialValue, checkedIcon = "MaterialCommunityIcons/checkbox-marked", uncheckedIcon = "MaterialCommunityIcons/checkbox-blank-outline", indeterminateIcon = "AntDesign/minussquareo", size = 24, style, ...rest }) => {
14
+ const previousInitialValue = usePrevious(initialValue);
15
+ React.useEffect(() => {
16
+ if (initialValue !== previousInitialValue) {
17
+ onPress(initialValue);
18
+ }
19
+ }, [initialValue, previousInitialValue, onPress]);
20
+ const { colors } = useTheme();
21
+ const colorsMap = {
22
+ [CheckboxStatus.Checked]: color || colors.primary,
23
+ [CheckboxStatus.Unchecked]: uncheckedColor || colors.primary,
24
+ [CheckboxStatus.Indeterminate]: indeterminateColor || colors.light,
25
+ };
26
+ const iconsMap = {
27
+ [CheckboxStatus.Checked]: checkedIcon,
28
+ [CheckboxStatus.Unchecked]: uncheckedIcon,
29
+ [CheckboxStatus.Indeterminate]: indeterminateIcon,
30
+ };
31
+ const checkboxColor = colorsMap[status];
32
+ return (React.createElement(Touchable, { ...rest, onPress: () => onPress(status === "unchecked" ? true : false), disabled: disabled, accessibilityState: { disabled }, accessibilityRole: "button", accessibilityLiveRegion: "polite", style: [styles.container, style, { width: size, height: size }] },
33
+ React.createElement(Icon, { style: styles.icon, name: iconsMap[status], size: size, color: checkboxColor }),
34
+ React.createElement(View, { style: [StyleSheet.absoluteFill, styles.fillContainer] },
35
+ React.createElement(View, { style: [
36
+ styles.fill,
37
+ { opacity: disabled ? 0.5 : 1 },
38
+ { borderColor: checkboxColor },
39
+ ] }))));
40
+ };
41
+ const styles = StyleSheet.create({
42
+ container: {
43
+ borderRadius: 18,
44
+ },
45
+ fillContainer: {
46
+ alignItems: "center",
47
+ justifyContent: "center",
48
+ },
49
+ icon: {
50
+ alignSelf: "center",
51
+ },
52
+ fill: {
53
+ borderRadius: 5,
54
+ width: 30,
55
+ height: 30,
56
+ alignSelf: "center",
57
+ },
58
+ });
59
+ export default Checkbox;
60
+ export const SEED_DATA = {
61
+ name: "Checkbox",
62
+ tag: "Checkbox",
63
+ category: COMPONENT_TYPES.input,
64
+ triggers: [Triggers.OnPress],
65
+ props: {
66
+ fieldName: createFieldNameProp({
67
+ defaultValue: "checkboxValue",
68
+ valuePropName: "status",
69
+ handlerPropName: "onPress",
70
+ }),
71
+ color: createColorProp({
72
+ group: GROUPS.basic,
73
+ label: "Color",
74
+ description: "Color for the button (used when the checkbox is checked)",
75
+ defaultValue: null,
76
+ }),
77
+ uncheckedColor: createColorProp({
78
+ group: GROUPS.basic,
79
+ label: "Unselected Color",
80
+ description: "Color for the button when the checkbox is unchecked",
81
+ defaultValue: null,
82
+ }),
83
+ indeterminateColor: createColorProp({
84
+ group: GROUPS.basic,
85
+ label: "Indeterminate Color",
86
+ description: "Color for the button when the checkbox is indeterminate",
87
+ defaultValue: null,
88
+ }),
89
+ disabled: createBoolProp({
90
+ label: "Disabled",
91
+ description: "Whether the checkbox is disabled",
92
+ }),
93
+ size: createStaticNumberProp({
94
+ label: "Size",
95
+ description: "Specifies the size of the icon",
96
+ defaultValue: null,
97
+ }),
98
+ checkedIcon: createIconProp({
99
+ label: "Checked Icon",
100
+ description: 'Icon to show when the checkbox status is "checked"',
101
+ defaultValue: null,
102
+ }),
103
+ uncheckedIcon: createIconProp({
104
+ label: "Unchecked Icon",
105
+ description: 'Icon to show when the checkbox status is "unchecked"',
106
+ defaultValue: null,
107
+ }),
108
+ indeterminateIcon: createIconProp({
109
+ label: "Indeterminate Icon",
110
+ description: 'Icon to show when the checkbox status is "indeterminate"',
111
+ defaultValue: null,
112
+ }),
113
+ },
114
+ };
@@ -0,0 +1,46 @@
1
+ import * as React from "react";
2
+ import { View } from "react-native";
3
+ import { GROUPS, COMPONENT_TYPES, FORM_TYPES, createTextProp, PROP_TYPES, createFieldNameProp, createDirectionProp, Triggers, } from "@draftbit/types";
4
+ import { checkboxGroupContext, Direction } from "./context";
5
+ const { Provider } = checkboxGroupContext;
6
+ const CheckboxGroup = ({ direction = Direction.Vertical, values, onValueChange = () => { }, style, children, ...rest }) => {
7
+ const _containerStyle = [
8
+ {
9
+ flexDirection: direction === Direction.Horizontal ? "row" : "column",
10
+ overflow: "hidden",
11
+ },
12
+ ];
13
+ if (direction !== Direction.Vertical) {
14
+ _containerStyle.push({
15
+ alignItems: "center",
16
+ });
17
+ }
18
+ return (React.createElement(View, { style: [{ minHeight: 40 }, style], ...rest },
19
+ React.createElement(Provider, { value: { values, onValueChange, direction } },
20
+ React.createElement(View, { style: _containerStyle }, children))));
21
+ };
22
+ export default CheckboxGroup;
23
+ export const SEED_DATA = {
24
+ name: "Checkbox Group",
25
+ tag: "CheckboxGroup",
26
+ category: COMPONENT_TYPES.deprecated,
27
+ layout: {},
28
+ triggers: [Triggers.OnValueChange],
29
+ props: {
30
+ direction: createDirectionProp(),
31
+ values: createTextProp({
32
+ group: GROUPS.data,
33
+ formType: FORM_TYPES.flatArray,
34
+ propType: PROP_TYPES.ARRAY,
35
+ label: "Values",
36
+ description: "Currently selected values of the checkbox group",
37
+ required: true,
38
+ defaultValue: null,
39
+ }),
40
+ fieldName: createFieldNameProp({
41
+ defaultValue: "checkboxGroupValue",
42
+ handlerPropName: "onValueChange",
43
+ valuePropName: "checkboxGroupValue",
44
+ }),
45
+ },
46
+ };
@@ -0,0 +1,109 @@
1
+ import * as React from "react";
2
+ import { StyleSheet, View, Platform, } from "react-native";
3
+ import Checkbox, { CheckboxStatus } from "./Checkbox";
4
+ import Text from "../Text";
5
+ import { useCheckboxGroupContext } from "./context";
6
+ import { createTextProp, createTextStyle, createRowDirectionProp, createFieldNameProp, COMPONENT_TYPES, Triggers, } from "@draftbit/types";
7
+ import { Direction as GroupDirection } from "./context";
8
+ import Touchable from "../Touchable";
9
+ import { extractStyles } from "../../utilities";
10
+ export var Direction;
11
+ (function (Direction) {
12
+ Direction["Row"] = "row";
13
+ Direction["RowReverse"] = "row-reverse";
14
+ })(Direction || (Direction = {}));
15
+ const getCheckboxAlignment = (parentDirection, direction) => {
16
+ if (parentDirection === GroupDirection.Horizontal) {
17
+ return direction === Direction.Row ? "flex-start" : "flex-end";
18
+ }
19
+ else if (direction === Direction.RowReverse) {
20
+ return "flex-start";
21
+ }
22
+ else {
23
+ return "flex-end";
24
+ }
25
+ };
26
+ const renderLabel = (value, labelStyle, textStyle) => {
27
+ if (typeof value === "string") {
28
+ return React.createElement(Text, { style: [labelStyle, textStyle] }, value);
29
+ }
30
+ else {
31
+ return React.createElement(React.Fragment, null, value);
32
+ }
33
+ };
34
+ const CheckboxRow = ({ Icon, label = "Label", value, onPress = () => { }, labelContainerStyle, labelStyle, checkboxStyle, direction = Direction.Row, status, disabled, style, ...rest }) => {
35
+ const { values: selectedValues, onValueChange, direction: parentDirection, } = useCheckboxGroupContext();
36
+ const values = Array.isArray(selectedValues) ? selectedValues : [];
37
+ const isChecked = status === CheckboxStatus.Checked || values.includes(value);
38
+ const handlePress = () => {
39
+ if (!disabled) {
40
+ onPress(value);
41
+ onValueChange && onValueChange(value, !isChecked);
42
+ }
43
+ };
44
+ const { textStyles, viewStyles } = extractStyles(style);
45
+ return (React.createElement(Touchable, { onPress: handlePress, style: [styles.mainParent, { flexDirection: direction }, viewStyles], disabled: disabled, ...rest },
46
+ React.createElement(View, { style: [
47
+ styles.label,
48
+ {
49
+ alignItems: direction === Direction.Row ? "flex-start" : "flex-end",
50
+ },
51
+ labelContainerStyle,
52
+ ] }, renderLabel(label, labelStyle, textStyles)),
53
+ React.createElement(View, { style: {
54
+ flex: 1,
55
+ alignItems: getCheckboxAlignment(parentDirection, direction),
56
+ } },
57
+ React.createElement(Checkbox, { Icon: Icon, status: status || values.includes(value)
58
+ ? CheckboxStatus.Checked
59
+ : CheckboxStatus.Unchecked, onPress: handlePress, style: checkboxStyle, disabled: disabled }))));
60
+ };
61
+ const styles = StyleSheet.create({
62
+ mainParent: {
63
+ alignItems: "center",
64
+ justifyContent: "space-around",
65
+ paddingStart: 20,
66
+ minHeight: 50,
67
+ paddingEnd: 20,
68
+ flex: 1,
69
+ ...Platform.select({
70
+ web: {
71
+ cursor: "pointer",
72
+ userSelect: "none",
73
+ },
74
+ }),
75
+ },
76
+ label: {
77
+ flex: 3,
78
+ },
79
+ });
80
+ export default CheckboxRow;
81
+ export const SEED_DATA = {
82
+ name: "Checkbox Row",
83
+ tag: "CheckboxRow",
84
+ category: COMPONENT_TYPES.deprecated,
85
+ layout: {
86
+ minHeight: 50,
87
+ },
88
+ triggers: [Triggers.OnPress],
89
+ props: {
90
+ label: createTextProp({
91
+ label: "Label",
92
+ description: "Label to show with the checkbox",
93
+ required: true,
94
+ defaultValue: "First Option",
95
+ }),
96
+ labelStyle: createTextStyle({
97
+ label: "Label Style",
98
+ description: "Change the styles of the label",
99
+ required: false,
100
+ editable: false,
101
+ }),
102
+ direction: createRowDirectionProp(),
103
+ fieldName: createFieldNameProp({
104
+ defaultValue: "unchecked",
105
+ valuePropName: "status",
106
+ handlerPropName: "onPress",
107
+ }),
108
+ },
109
+ };
@@ -0,0 +1,14 @@
1
+ import { createContext, useContext } from "react";
2
+ export var Direction;
3
+ (function (Direction) {
4
+ Direction["Horizontal"] = "horizontal";
5
+ Direction["Vertical"] = "vertical";
6
+ })(Direction || (Direction = {}));
7
+ export const checkboxGroupContext = createContext({
8
+ onValueChange: () => { },
9
+ values: [],
10
+ direction: undefined,
11
+ });
12
+ export function useCheckboxGroupContext() {
13
+ return useContext(checkboxGroupContext);
14
+ }
@@ -0,0 +1,3 @@
1
+ export { default as Checkbox } from "./Checkbox";
2
+ export { default as CheckboxGroup } from "./CheckboxGroup";
3
+ export { default as CheckboxRow } from "./CheckboxRow";
@@ -0,0 +1,32 @@
1
+ import * as React from "react";
2
+ import { Image, } from "react-native";
3
+ import Config from "./Config";
4
+ import { GROUPS, COMPONENT_TYPES, FORM_TYPES, PROP_TYPES, createImageProp, } from "@draftbit/types";
5
+ const CircleImage = ({ source = Config.placeholderImageURL, size = 60, style, ...props }) => {
6
+ const borderRadius = size / 2;
7
+ return (React.createElement(Image, { style: [{ width: size, height: size, borderRadius }, style], source: typeof source === "string" ? { uri: source } : source, resizeMode: "cover", ...props }));
8
+ };
9
+ export default CircleImage;
10
+ export const SEED_DATA = {
11
+ name: "Circle Image",
12
+ tag: "CircleImage",
13
+ description: "A circle image",
14
+ category: COMPONENT_TYPES.media,
15
+ props: {
16
+ source: createImageProp(),
17
+ size: {
18
+ group: GROUPS.basic,
19
+ label: "Size",
20
+ description: "Size of your circle image",
21
+ editable: true,
22
+ required: false,
23
+ formType: FORM_TYPES.number,
24
+ propType: PROP_TYPES.NUMBER,
25
+ min: 0,
26
+ max: 300,
27
+ precision: 0,
28
+ step: 1,
29
+ defaultValue: 60,
30
+ },
31
+ },
32
+ };
@@ -0,0 +1,78 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import { Svg, Path, G } from "react-native-svg";
4
+ class CircularProgress extends React.Component {
5
+ polarToCartesian = (centerX, centerY, radius, angleInDegrees) => {
6
+ var angleInRadians = ((angleInDegrees - 90) * Math.PI) / 180.0;
7
+ return {
8
+ x: centerX + radius * Math.cos(angleInRadians),
9
+ y: centerY + radius * Math.sin(angleInRadians),
10
+ };
11
+ };
12
+ circlePath = (x, y, radius, startAngle, endAngle) => {
13
+ var start = this.polarToCartesian(x, y, radius, endAngle * 0.9999);
14
+ var end = this.polarToCartesian(x, y, radius, startAngle);
15
+ var largeArcFlag = endAngle - startAngle <= 180 ? "0" : "1";
16
+ var d = [
17
+ "M",
18
+ start.x,
19
+ start.y,
20
+ "A",
21
+ radius,
22
+ radius,
23
+ 0,
24
+ largeArcFlag,
25
+ 0,
26
+ end.x,
27
+ end.y,
28
+ ];
29
+ return d.join(" ");
30
+ };
31
+ clampFill = (fill) => Math.min(100, Math.max(0, fill));
32
+ render() {
33
+ const { size, width, backgroundWidth, tintColor = "black", tintTransparency = true, backgroundColor, style, rotation = 90, lineCap = "butt", arcSweepAngle = 360, fill, children, childrenContainerStyle, padding = 0, renderCap, dashedBackground = { width: 0, gap: 0 }, dashedTint = { width: 0, gap: 0 }, } = this.props;
34
+ const maxWidthCircle = backgroundWidth
35
+ ? Math.max(width, backgroundWidth)
36
+ : width;
37
+ const sizeWithPadding = size / 2 + padding / 2;
38
+ const radius = size / 2 - maxWidthCircle / 2 - padding / 2;
39
+ const currentFillAngle = (arcSweepAngle * this.clampFill(fill)) / 100;
40
+ const backgroundPath = this.circlePath(sizeWithPadding, sizeWithPadding, radius, tintTransparency ? 0 : currentFillAngle, arcSweepAngle);
41
+ const circlePathItem = this.circlePath(sizeWithPadding, sizeWithPadding, radius, 0, currentFillAngle);
42
+ const coordinate = this.polarToCartesian(sizeWithPadding, sizeWithPadding, radius, currentFillAngle);
43
+ const cap = renderCap ? renderCap({ center: coordinate }) : null;
44
+ const offset = size - maxWidthCircle * 2;
45
+ const localChildrenContainerStyle = [
46
+ {
47
+ position: "absolute",
48
+ left: maxWidthCircle + padding / 2,
49
+ top: maxWidthCircle + padding / 2,
50
+ width: offset,
51
+ height: offset,
52
+ borderRadius: offset / 2,
53
+ alignItems: "center",
54
+ justifyContent: "center",
55
+ overflow: "hidden",
56
+ },
57
+ childrenContainerStyle,
58
+ ];
59
+ const strokeDasharrayTint = dashedTint.gap > 0
60
+ ? Object.values(dashedTint)
61
+ .map((value) => value.toString())
62
+ .join(" ")
63
+ : "";
64
+ const strokeDasharrayBackground = dashedBackground.gap > 0
65
+ ? Object.values(dashedBackground)
66
+ .map((value) => value.toString())
67
+ .join(" ")
68
+ : "";
69
+ return (React.createElement(View, { style: style },
70
+ React.createElement(Svg, { width: size + padding, height: size + padding },
71
+ React.createElement(G, { rotation: rotation, originX: (size + padding) / 2, originY: (size + padding) / 2 },
72
+ backgroundColor && (React.createElement(Path, { d: backgroundPath, stroke: backgroundColor, strokeWidth: backgroundWidth || width, strokeLinecap: lineCap, strokeDasharray: strokeDasharrayBackground, fill: "transparent" })),
73
+ fill > 0 && (React.createElement(Path, { d: circlePathItem, stroke: tintColor, strokeWidth: width, strokeLinecap: lineCap, strokeDasharray: strokeDasharrayTint, fill: "transparent" })),
74
+ cap)),
75
+ children && (React.createElement(View, { style: localChildrenContainerStyle }, children(fill)))));
76
+ }
77
+ }
78
+ export default CircularProgress;
@@ -0,0 +1,63 @@
1
+ import { Dimensions, Platform } from "react-native";
2
+ const getWindowDimensions = () => {
3
+ const { width, height } = Dimensions.get("window");
4
+ return {
5
+ windowWidth: width,
6
+ windowHeight: height,
7
+ };
8
+ };
9
+ const { windowWidth, windowHeight } = getWindowDimensions();
10
+ const getFilters = (options) => {
11
+ const { width, height } = options;
12
+ const filters = ["c_scale", "q_auto", "dpr_auto"];
13
+ if (width)
14
+ filters.push(`w_${width}`);
15
+ if (height)
16
+ filters.push(`h_${height}`);
17
+ return filters.join(",");
18
+ };
19
+ const buildImageUrl = (options, name) => {
20
+ const filters = getFilters(options);
21
+ return [
22
+ "https://res.cloudinary.com/altos/image/upload",
23
+ filters,
24
+ `${name}.png`,
25
+ ].join("/");
26
+ };
27
+ const getExtension = () => {
28
+ return Platform.OS === "web" ? ".svg" : ".png";
29
+ };
30
+ export default {
31
+ windowWidth,
32
+ windowHeight,
33
+ avatarImageUrl: buildImageUrl({
34
+ width: 60,
35
+ height: 60,
36
+ }, "Avatar"),
37
+ avatarImageSize: 60,
38
+ cardImageSize: 200,
39
+ cardImageUrl: "https://static.draftbit.com/images/placeholder-image" + getExtension(),
40
+ cardIconSize: 16,
41
+ cardIconBackgroundOpacity: 0.24,
42
+ cardIconElevation: 1,
43
+ placeholderImageURL: "https://static.draftbit.com/images/placeholder-image" + getExtension(),
44
+ getPlaceholderImageUrl: (size) => buildImageUrl({ width: size.width, height: size.height }, "image-placeholder_1"),
45
+ squareImageUrl: buildImageUrl({ width: 100, height: 100 }, "Avatar"),
46
+ FABSize: 40,
47
+ FABBorderRadius: 20,
48
+ FABFixedHeight: 64,
49
+ cardContainerShortImageAspectRatio: 1,
50
+ rowSingleLineImageSize: 24,
51
+ rowMultiLineImageSize: 48,
52
+ rowSingleLineIconSize: 24,
53
+ rowMultiLineIconSize: 16,
54
+ headerIconSize: 24,
55
+ buttonIconSize: 24,
56
+ swiperInactiveDotSize: 6,
57
+ swiperActiveDotSize: 10,
58
+ fieldSearchBarFullIconSize: 24,
59
+ stepperButtonSize: 40,
60
+ radioButtonSize: 24,
61
+ topSafeAreaViewHeight: 0,
62
+ // topSafeAreaViewHeight: Platform.OS === "android" ? Constants.statusBarHeight : 0
63
+ };
@@ -0,0 +1,73 @@
1
+ import * as React from "react";
2
+ import { View, ImageBackground, StyleSheet, } from "react-native";
3
+ import { withTheme } from "../theming";
4
+ import Elevation from "./Elevation";
5
+ import { GROUPS, COMPONENT_TYPES, FORM_TYPES, PROP_TYPES, createElevationType, createImageProp, createResizeModeProp, } from "@draftbit/types";
6
+ const Container = ({ useThemeGutterPadding, borderColor, borderWidth, backgroundColor, backgroundImage, backgroundImageResizeMode, elevation, style, children, theme, // eslint-disable-line @typescript-eslint/no-unused-vars
7
+ ...rest }) => {
8
+ const { flex, flexGrow, flexWrap, flexBasis, flexShrink, flexDirection, alignContent, justifyContent, alignItems, padding, paddingTop, paddingBottom, paddingLeft, paddingRight, paddingVertical, paddingHorizontal, ...styleProp } = StyleSheet.flatten(style) || {};
9
+ const containerStyle = {
10
+ backgroundColor,
11
+ borderColor,
12
+ borderWidth,
13
+ width: "100%",
14
+ ...styleProp,
15
+ };
16
+ const innerStyle = {
17
+ flex,
18
+ flexGrow,
19
+ flexWrap,
20
+ flexBasis,
21
+ flexShrink,
22
+ flexDirection,
23
+ alignContent,
24
+ justifyContent,
25
+ alignItems,
26
+ padding,
27
+ paddingTop,
28
+ paddingBottom,
29
+ paddingLeft,
30
+ paddingRight,
31
+ paddingVertical,
32
+ paddingHorizontal: paddingHorizontal || useThemeGutterPadding ? 16 : 0,
33
+ };
34
+ const Wrap = elevation ? Elevation : View;
35
+ if (elevation) {
36
+ containerStyle.elevation = elevation;
37
+ }
38
+ return (React.createElement(Wrap, { style: [containerStyle, style], ...rest }, backgroundImage ? (React.createElement(ImageBackground, { source: typeof backgroundImage === "string"
39
+ ? { uri: backgroundImage }
40
+ : backgroundImage, resizeMode: backgroundImageResizeMode, style: {
41
+ flex: 1,
42
+ } },
43
+ React.createElement(View, { style: innerStyle }, children))) : (React.createElement(View, { style: innerStyle }, children))));
44
+ };
45
+ export default withTheme(Container);
46
+ export const SEED_DATA = {
47
+ name: "Container",
48
+ tag: "Container",
49
+ description: "A container component with gutter padding",
50
+ category: COMPONENT_TYPES.deprecated,
51
+ layout: {
52
+ height: 250,
53
+ },
54
+ props: {
55
+ useThemeGutterPadding: {
56
+ group: GROUPS.basic,
57
+ label: "Use gutter padding",
58
+ description: "When true, uses the theme gutter spacing as the container's horizontal padding",
59
+ formType: FORM_TYPES.boolean,
60
+ propType: PROP_TYPES.BOOLEAN,
61
+ defaultValue: false,
62
+ editable: false,
63
+ required: true,
64
+ },
65
+ backgroundImage: createImageProp({
66
+ label: "Background Image",
67
+ description: "Apply a custom background image",
68
+ defaultValue: null,
69
+ }),
70
+ backgroundImageResizeMode: createResizeModeProp(),
71
+ elevation: createElevationType(0),
72
+ },
73
+ };