@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.
- package/LICENSE +21 -0
- package/lib/commonjs/components/DatePicker/DatePicker.js +6 -1
- package/lib/commonjs/components/DatePicker/DatePicker.js.map +1 -1
- package/lib/commonjs/components/DatePicker/DatePickerComponentType.js +2 -0
- package/lib/commonjs/components/Divider.js +18 -5
- package/lib/commonjs/components/Divider.js.map +1 -1
- package/lib/commonjs/components/Elevation.js +14 -3
- package/lib/commonjs/components/Elevation.js.map +1 -1
- package/lib/commonjs/components/Justification.js +3 -0
- package/lib/commonjs/components/Picker/PickerComponent.android.js +4 -1
- package/lib/commonjs/components/Picker/PickerComponent.android.js.map +1 -1
- package/lib/commonjs/components/Picker/PickerComponent.web.js +4 -1
- package/lib/commonjs/components/Picker/PickerComponent.web.js.map +1 -1
- package/lib/commonjs/components/Picker/PickerTypes.js +3 -0
- package/lib/commonjs/components/Portal/PortalHost.js.map +1 -1
- package/lib/commonjs/components/ResizeMode.js +3 -0
- package/lib/module/components/DatePicker/DatePicker.js +6 -1
- package/lib/module/components/DatePicker/DatePicker.js.map +1 -1
- package/lib/module/components/DatePicker/DatePickerComponentType.js +1 -1
- package/lib/module/components/Justification.js +1 -1
- package/lib/module/components/Picker/PickerComponent.android.js +4 -1
- package/lib/module/components/Picker/PickerComponent.android.js.map +1 -1
- package/lib/module/components/Picker/PickerComponent.web.js +4 -1
- package/lib/module/components/Picker/PickerComponent.web.js.map +1 -1
- package/lib/module/components/Picker/PickerTypes.js +1 -1
- package/lib/module/components/ResizeMode.js +1 -1
- package/package.json +3 -2
- package/src/Provider.js +9 -0
- package/src/components/Accordion/AccordionGroup.js +94 -0
- package/src/components/Accordion/AccordionItem.js +48 -0
- package/src/components/Accordion/index.js +2 -0
- package/src/components/ActionSheet/ActionSheet.js +57 -0
- package/src/components/ActionSheet/ActionSheetCancel.js +28 -0
- package/src/components/ActionSheet/ActionSheetItem.js +49 -0
- package/src/components/ActionSheet/index.js +3 -0
- package/src/components/AnimatedCircularProgress.js +43 -0
- package/src/components/AspectRatio.js +18 -0
- package/src/components/AvatarEdit.js +67 -0
- package/src/components/Button.js +187 -0
- package/src/components/Card.js +109 -0
- package/src/components/CardBlock.js +176 -0
- package/src/components/CardContainer.js +171 -0
- package/src/components/CardContainerRating.js +203 -0
- package/src/components/CardContainerShortImage.js +151 -0
- package/src/components/CardInline.js +87 -0
- package/src/components/Carousel.js +85 -0
- package/src/components/Checkbox/Checkbox.js +114 -0
- package/src/components/Checkbox/CheckboxGroup.js +46 -0
- package/src/components/Checkbox/CheckboxRow.js +109 -0
- package/src/components/Checkbox/context.js +14 -0
- package/src/components/Checkbox/index.js +3 -0
- package/src/components/CircleImage.js +32 -0
- package/src/components/CircularProgress.js +78 -0
- package/src/components/Config.js +63 -0
- package/src/components/Container.js +73 -0
- package/src/components/DatePicker/DatePicker.js +379 -0
- package/src/components/DatePicker/DatePicker.tsx +7 -1
- package/src/components/DatePicker/DatePickerComponent.js +13 -0
- package/src/components/DatePicker/DatePickerComponent.web.js +30 -0
- package/src/components/DatePicker/DatePickerComponentType.js +1 -0
- package/src/components/DeprecatedButton.js +201 -0
- package/src/components/DeprecatedCardWrapper.js +18 -0
- package/src/components/DeprecatedFAB.js +261 -0
- package/src/components/Divider.js +39 -0
- package/src/components/Elevation.js +20 -0
- package/src/components/FAB.js +82 -0
- package/src/components/FieldSearchBarFull.js +92 -0
- package/src/components/FormRow.js +19 -0
- package/src/components/Header.js +44 -0
- package/src/components/HeaderLarge.js +35 -0
- package/src/components/HeaderMedium.js +61 -0
- package/src/components/HeaderOverline.js +61 -0
- package/src/components/IconButton.js +65 -0
- package/src/components/Image.js +62 -0
- package/src/components/Justification.js +1 -0
- package/src/components/Layout.js +245 -0
- package/src/components/Picker/Picker.js +204 -0
- package/src/components/Picker/PickerComponent.android.js +68 -0
- package/src/components/Picker/PickerComponent.android.tsx +6 -1
- package/src/components/Picker/PickerComponent.ios.js +72 -0
- package/src/components/Picker/PickerComponent.web.js +68 -0
- package/src/components/Picker/PickerComponent.web.tsx +6 -1
- package/src/components/Picker/PickerTypes.js +1 -0
- package/src/components/Portal/Portal.js +35 -0
- package/src/components/Portal/PortalConsumer.js +28 -0
- package/src/components/Portal/PortalHost.js +105 -0
- package/src/components/Portal/PortalManager.js +29 -0
- package/src/components/ProgressBar.js +218 -0
- package/src/components/ProgressCircle.js +121 -0
- package/src/components/ProgressIndicator.js +207 -0
- package/src/components/RadioButton/RadioButton.js +66 -0
- package/src/components/RadioButton/RadioButtonFieldGroup.js +17 -0
- package/src/components/RadioButton/RadioButtonGroup.js +43 -0
- package/src/components/RadioButton/RadioButtonRow.js +111 -0
- package/src/components/RadioButton/context.js +14 -0
- package/src/components/RadioButton/index.js +4 -0
- package/src/components/ResizeMode.js +1 -0
- package/src/components/Row.js +48 -0
- package/src/components/RowBodyIcon.js +83 -0
- package/src/components/RowHeadlineImageCaption.js +179 -0
- package/src/components/RowHeadlineImageIcon.js +113 -0
- package/src/components/ScreenContainer.js +35 -0
- package/src/components/Slider.js +114 -0
- package/src/components/StarRating.js +80 -0
- package/src/components/StepIndicator.js +346 -0
- package/src/components/Stepper.js +69 -0
- package/src/components/Surface.js +36 -0
- package/src/components/Switch.js +59 -0
- package/src/components/Text.js +232 -0
- package/src/components/TextField.js +552 -0
- package/src/components/TextInput.js +13 -0
- package/src/components/ToggleButton.js +75 -0
- package/src/components/Touchable.js +24 -0
- package/src/components/Touchable.web.js +2 -0
- package/src/components/Typography.js +36 -0
- package/src/components/useAuthState.js +31 -0
- package/src/constants.js +10 -0
- package/src/hooks.js +12 -0
- package/src/index.js +48 -0
- package/src/interfaces/Icon.js +8 -0
- package/src/styles/DarkTheme.js +26 -0
- package/src/styles/DefaultTheme.js +111 -0
- package/src/styles/fonts.js +62 -0
- package/src/styles/overlay.js +60 -0
- package/src/styles/shadow.js +51 -0
- package/src/theming.js +3 -0
- package/src/utilities.js +42 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { COMPONENT_TYPES, FORM_TYPES, GROUPS, PROP_TYPES, } from "@draftbit/types";
|
|
3
|
+
import { Text } from "react-native";
|
|
4
|
+
import AnimatedCircularProgress from "./AnimatedCircularProgress";
|
|
5
|
+
import { withTheme } from "../theming";
|
|
6
|
+
const ProgressCircle = ({ progress = 0.5, style, color = "primary", size = 100, showsText = true, unfilledColor, strokeCap = "butt", textStyle, thickness = 1, theme, }) => {
|
|
7
|
+
const progressNum = Math.round(progress * 100);
|
|
8
|
+
const tintColor = color || theme.colors.primary;
|
|
9
|
+
const backgroundColor = unfilledColor || theme.colors.secondary;
|
|
10
|
+
return (React.createElement(AnimatedCircularProgress, { size: size, width: thickness, backgroundWidth: thickness, fill: progressNum, tintColor: tintColor, backgroundColor: backgroundColor, rotation: 0, lineCap: strokeCap, style: style }, (fill) => showsText ? (React.createElement(Text, { style: [{ fontSize: size * 0.275, color: tintColor }, textStyle] },
|
|
11
|
+
Math.round(fill),
|
|
12
|
+
"%")) : null));
|
|
13
|
+
};
|
|
14
|
+
export default withTheme(ProgressCircle);
|
|
15
|
+
export const SEED_DATA = {
|
|
16
|
+
name: "Progress Circle",
|
|
17
|
+
tag: "ProgressCircle",
|
|
18
|
+
description: "A circle used to show completed progress",
|
|
19
|
+
category: COMPONENT_TYPES.deprecated,
|
|
20
|
+
preview_image_url: "{CLOUDINARY_URL}/Status_Progress.png",
|
|
21
|
+
supports_list_render: false,
|
|
22
|
+
props: {
|
|
23
|
+
progress: {
|
|
24
|
+
group: GROUPS.data,
|
|
25
|
+
label: "Progress",
|
|
26
|
+
description: "The amount of progress to display. A number 0-1.",
|
|
27
|
+
formType: FORM_TYPES.number,
|
|
28
|
+
propType: PROP_TYPES.NUMBER,
|
|
29
|
+
defaultValue: 0.5,
|
|
30
|
+
min: 0,
|
|
31
|
+
max: 1,
|
|
32
|
+
step: 0.01,
|
|
33
|
+
precision: 2,
|
|
34
|
+
editable: true,
|
|
35
|
+
required: true,
|
|
36
|
+
},
|
|
37
|
+
color: {
|
|
38
|
+
group: GROUPS.basic,
|
|
39
|
+
label: "Color",
|
|
40
|
+
description: "Color for the progress shown",
|
|
41
|
+
editable: true,
|
|
42
|
+
defaultValue: "primary",
|
|
43
|
+
required: true,
|
|
44
|
+
formType: FORM_TYPES.color,
|
|
45
|
+
propType: PROP_TYPES.THEME,
|
|
46
|
+
},
|
|
47
|
+
unfilledColor: {
|
|
48
|
+
group: GROUPS.basic,
|
|
49
|
+
label: "Unfilled Color",
|
|
50
|
+
description: "The color of the unfilled portion of the progress bar(eg. if at 50% then this is the color of the other 50%)",
|
|
51
|
+
editable: true,
|
|
52
|
+
defaultValue: null,
|
|
53
|
+
required: true,
|
|
54
|
+
formType: FORM_TYPES.color,
|
|
55
|
+
propType: PROP_TYPES.THEME,
|
|
56
|
+
},
|
|
57
|
+
size: {
|
|
58
|
+
group: GROUPS.basic,
|
|
59
|
+
label: "Size",
|
|
60
|
+
description: "The size of the circle",
|
|
61
|
+
formType: FORM_TYPES.number,
|
|
62
|
+
propType: PROP_TYPES.NUMBER,
|
|
63
|
+
defaultValue: 100,
|
|
64
|
+
min: 0,
|
|
65
|
+
max: 300,
|
|
66
|
+
step: 1,
|
|
67
|
+
precision: 1,
|
|
68
|
+
editable: true,
|
|
69
|
+
required: true,
|
|
70
|
+
},
|
|
71
|
+
showsText: {
|
|
72
|
+
group: GROUPS.basic,
|
|
73
|
+
label: "Show Progress Text",
|
|
74
|
+
description: "Shows progress in the middle of the circle",
|
|
75
|
+
formType: FORM_TYPES.boolean,
|
|
76
|
+
propType: PROP_TYPES.BOOLEAN,
|
|
77
|
+
defaultValue: true,
|
|
78
|
+
editable: true,
|
|
79
|
+
required: true,
|
|
80
|
+
},
|
|
81
|
+
textStyle: {
|
|
82
|
+
group: GROUPS.basic,
|
|
83
|
+
label: "Text Style",
|
|
84
|
+
description: "Text Style of the inner circle",
|
|
85
|
+
editable: true,
|
|
86
|
+
required: true,
|
|
87
|
+
formType: FORM_TYPES.typeStyle,
|
|
88
|
+
propType: PROP_TYPES.THEME,
|
|
89
|
+
defaultValue: null,
|
|
90
|
+
},
|
|
91
|
+
thickness: {
|
|
92
|
+
group: GROUPS.basic,
|
|
93
|
+
label: "Thickness",
|
|
94
|
+
description: "Thickness of the inner circle",
|
|
95
|
+
formType: FORM_TYPES.number,
|
|
96
|
+
propType: PROP_TYPES.NUMBER,
|
|
97
|
+
defaultValue: 1,
|
|
98
|
+
min: 0,
|
|
99
|
+
max: 15,
|
|
100
|
+
step: 1,
|
|
101
|
+
precision: 1,
|
|
102
|
+
editable: true,
|
|
103
|
+
required: true,
|
|
104
|
+
},
|
|
105
|
+
strokeCap: {
|
|
106
|
+
group: GROUPS.basic,
|
|
107
|
+
label: "Stroke Cap",
|
|
108
|
+
description: "The style of the stroke",
|
|
109
|
+
formType: FORM_TYPES.flatArray,
|
|
110
|
+
propType: PROP_TYPES.STRING,
|
|
111
|
+
defaultValue: "butt",
|
|
112
|
+
options: ["butt", "square", "round"],
|
|
113
|
+
editable: true,
|
|
114
|
+
required: true,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
layout: {
|
|
118
|
+
width: 250,
|
|
119
|
+
height: 250,
|
|
120
|
+
},
|
|
121
|
+
};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import StepIndicator from "./StepIndicator";
|
|
3
|
+
import { withTheme } from "../theming";
|
|
4
|
+
import { COMPONENT_TYPES, FORM_TYPES, GROUPS, PROP_TYPES, } from "@draftbit/types";
|
|
5
|
+
const ProgressIndicator = ({ numberOfSteps, currentStep, currentStepStrokeWidth = 3, stepStrokeCurrentColor = "primary", stepIndicatorSize, currentStepIndicatorSize, stepIndicatorCurrentColor, stepIndicatorLabelCurrentColor, stepIndicatorLabelFontSize = 12, stepNumberFinishedColor = "strongInverse", stepNumberUnfinishedColor = "primary", unfinishedColor = "light", finishedColor = "primary", theme, }) => {
|
|
6
|
+
const currentPosition = currentStep - 1;
|
|
7
|
+
return (React.createElement(StepIndicator, { stepCount: numberOfSteps, currentPosition: currentPosition, customStyles: {
|
|
8
|
+
stepIndicatorSize,
|
|
9
|
+
currentStepIndicatorSize: currentStepIndicatorSize
|
|
10
|
+
? currentStepIndicatorSize
|
|
11
|
+
: stepIndicatorSize,
|
|
12
|
+
stepStrokeFinishedColor: finishedColor,
|
|
13
|
+
stepStrokeUnFinishedColor: unfinishedColor,
|
|
14
|
+
separatorFinishedColor: finishedColor,
|
|
15
|
+
separatorUnFinishedColor: unfinishedColor,
|
|
16
|
+
stepIndicatorFinishedColor: finishedColor,
|
|
17
|
+
stepIndicatorUnFinishedColor: unfinishedColor,
|
|
18
|
+
currentStepStrokeWidth,
|
|
19
|
+
stepStrokeCurrentColor: stepStrokeCurrentColor || stepIndicatorCurrentColor,
|
|
20
|
+
stepIndicatorLabelUnFinishedColor: stepNumberUnfinishedColor,
|
|
21
|
+
stepIndicatorLabelFinishedColor: stepNumberFinishedColor,
|
|
22
|
+
stepIndicatorCurrentColor: stepIndicatorCurrentColor || unfinishedColor,
|
|
23
|
+
stepIndicatorLabelCurrentColor: stepIndicatorLabelCurrentColor || stepNumberUnfinishedColor,
|
|
24
|
+
stepIndicatorLabelFontSize,
|
|
25
|
+
labelFontFamily: theme.typography.body1.fontFamily,
|
|
26
|
+
} }));
|
|
27
|
+
};
|
|
28
|
+
export default withTheme(ProgressIndicator);
|
|
29
|
+
export const SEED_DATA = {
|
|
30
|
+
name: "Progress Indicator",
|
|
31
|
+
tag: "ProgressIndicator",
|
|
32
|
+
description: "A component used to show current Step in a process",
|
|
33
|
+
category: COMPONENT_TYPES.deprecated,
|
|
34
|
+
preview_image_url: "{CLOUDINARY_URL}/Control_Slider.png",
|
|
35
|
+
supports_list_render: false,
|
|
36
|
+
layout: {},
|
|
37
|
+
props: {
|
|
38
|
+
numberOfSteps: {
|
|
39
|
+
group: GROUPS.data,
|
|
40
|
+
label: "Number of Steps",
|
|
41
|
+
description: "The border radius for the thumb",
|
|
42
|
+
editable: true,
|
|
43
|
+
required: false,
|
|
44
|
+
formType: FORM_TYPES.number,
|
|
45
|
+
propType: PROP_TYPES.NUMBER,
|
|
46
|
+
min: 0,
|
|
47
|
+
max: 10,
|
|
48
|
+
step: 1,
|
|
49
|
+
precision: 0,
|
|
50
|
+
defaultValue: 5,
|
|
51
|
+
},
|
|
52
|
+
currentStep: {
|
|
53
|
+
group: GROUPS.data,
|
|
54
|
+
label: "Current Step",
|
|
55
|
+
description: "The step that the user is on",
|
|
56
|
+
editable: true,
|
|
57
|
+
required: false,
|
|
58
|
+
formType: FORM_TYPES.number,
|
|
59
|
+
propType: PROP_TYPES.NUMBER,
|
|
60
|
+
min: 0,
|
|
61
|
+
max: 10,
|
|
62
|
+
step: 1,
|
|
63
|
+
precision: 0,
|
|
64
|
+
defaultValue: 5,
|
|
65
|
+
},
|
|
66
|
+
stepIndicatorSize: {
|
|
67
|
+
group: GROUPS.basic,
|
|
68
|
+
label: "Step Size",
|
|
69
|
+
description: "The size of the step circle",
|
|
70
|
+
editable: true,
|
|
71
|
+
required: false,
|
|
72
|
+
formType: FORM_TYPES.number,
|
|
73
|
+
propType: PROP_TYPES.NUMBER,
|
|
74
|
+
min: 10,
|
|
75
|
+
max: 100,
|
|
76
|
+
step: 5,
|
|
77
|
+
precision: 0,
|
|
78
|
+
defaultValue: 25,
|
|
79
|
+
},
|
|
80
|
+
stepIndicatorLabelFontSize: {
|
|
81
|
+
group: GROUPS.basic,
|
|
82
|
+
label: "Step Font Size",
|
|
83
|
+
description: "The font size of the step number",
|
|
84
|
+
editable: true,
|
|
85
|
+
required: false,
|
|
86
|
+
formType: FORM_TYPES.number,
|
|
87
|
+
propType: PROP_TYPES.NUMBER,
|
|
88
|
+
min: 6,
|
|
89
|
+
max: 36,
|
|
90
|
+
step: 1,
|
|
91
|
+
precision: 0,
|
|
92
|
+
defaultValue: 15,
|
|
93
|
+
},
|
|
94
|
+
currentStepIndicatorLabelFontSize: {
|
|
95
|
+
group: GROUPS.basic,
|
|
96
|
+
label: "Current Step Font Size",
|
|
97
|
+
description: "The font size of the current step number",
|
|
98
|
+
editable: true,
|
|
99
|
+
required: false,
|
|
100
|
+
formType: FORM_TYPES.number,
|
|
101
|
+
propType: PROP_TYPES.NUMBER,
|
|
102
|
+
min: 6,
|
|
103
|
+
max: 36,
|
|
104
|
+
step: 1,
|
|
105
|
+
precision: 0,
|
|
106
|
+
defaultValue: 15,
|
|
107
|
+
},
|
|
108
|
+
unfinishedColor: {
|
|
109
|
+
group: GROUPS.basic,
|
|
110
|
+
label: "Unfinished Color",
|
|
111
|
+
description: "The color of the step and divider when the step is either not the current step or not finished",
|
|
112
|
+
editable: true,
|
|
113
|
+
required: false,
|
|
114
|
+
formType: FORM_TYPES.color,
|
|
115
|
+
propType: PROP_TYPES.THEME,
|
|
116
|
+
defaultValue: null,
|
|
117
|
+
},
|
|
118
|
+
finishedColor: {
|
|
119
|
+
group: GROUPS.basic,
|
|
120
|
+
label: "Finished Color",
|
|
121
|
+
description: "The color of the step and divider when the step is the current step or finished",
|
|
122
|
+
editable: true,
|
|
123
|
+
required: false,
|
|
124
|
+
formType: FORM_TYPES.color,
|
|
125
|
+
propType: PROP_TYPES.THEME,
|
|
126
|
+
defaultValue: null,
|
|
127
|
+
},
|
|
128
|
+
stepNumberUnfinishedColor: {
|
|
129
|
+
group: GROUPS.basic,
|
|
130
|
+
label: "Unfinished Number Color",
|
|
131
|
+
description: "The color of the number within the step when unfinished",
|
|
132
|
+
editable: true,
|
|
133
|
+
required: false,
|
|
134
|
+
formType: FORM_TYPES.color,
|
|
135
|
+
propType: PROP_TYPES.THEME,
|
|
136
|
+
defaultValue: null,
|
|
137
|
+
},
|
|
138
|
+
stepNumberFinishedColor: {
|
|
139
|
+
group: GROUPS.basic,
|
|
140
|
+
label: "Finished Number Color",
|
|
141
|
+
description: "The color of the number within the step when finished",
|
|
142
|
+
editable: true,
|
|
143
|
+
required: false,
|
|
144
|
+
formType: FORM_TYPES.color,
|
|
145
|
+
propType: PROP_TYPES.THEME,
|
|
146
|
+
defaultValue: null,
|
|
147
|
+
},
|
|
148
|
+
stepIndicatorCurrentColor: {
|
|
149
|
+
group: GROUPS.basic,
|
|
150
|
+
label: "Current Step Color",
|
|
151
|
+
description: "The color of current step circle",
|
|
152
|
+
editable: true,
|
|
153
|
+
required: false,
|
|
154
|
+
formType: FORM_TYPES.color,
|
|
155
|
+
propType: PROP_TYPES.THEME,
|
|
156
|
+
defaultValue: null,
|
|
157
|
+
},
|
|
158
|
+
stepIndicatorLabelCurrentColor: {
|
|
159
|
+
group: GROUPS.basic,
|
|
160
|
+
label: "Current Step Number Color",
|
|
161
|
+
description: "The color of current number within the step circle",
|
|
162
|
+
editable: true,
|
|
163
|
+
required: false,
|
|
164
|
+
formType: FORM_TYPES.color,
|
|
165
|
+
propType: PROP_TYPES.THEME,
|
|
166
|
+
defaultValue: null,
|
|
167
|
+
},
|
|
168
|
+
stepStrokeCurrentColor: {
|
|
169
|
+
group: GROUPS.basic,
|
|
170
|
+
label: "Current Step Border Color",
|
|
171
|
+
description: "The color of current border color of the step",
|
|
172
|
+
editable: true,
|
|
173
|
+
required: false,
|
|
174
|
+
formType: FORM_TYPES.color,
|
|
175
|
+
propType: PROP_TYPES.THEME,
|
|
176
|
+
defaultValue: null,
|
|
177
|
+
},
|
|
178
|
+
currentStepStrokeWidth: {
|
|
179
|
+
group: GROUPS.basic,
|
|
180
|
+
label: "Current Step Border Width",
|
|
181
|
+
description: "The width of the border for the current step",
|
|
182
|
+
editable: true,
|
|
183
|
+
required: false,
|
|
184
|
+
formType: FORM_TYPES.number,
|
|
185
|
+
propType: PROP_TYPES.NUMBER,
|
|
186
|
+
min: 1,
|
|
187
|
+
max: 20,
|
|
188
|
+
step: 1,
|
|
189
|
+
precision: 0,
|
|
190
|
+
defaultValue: 0,
|
|
191
|
+
},
|
|
192
|
+
currentStepIndicatorSize: {
|
|
193
|
+
group: GROUPS.basic,
|
|
194
|
+
label: "Current Step Size",
|
|
195
|
+
description: "The size of the current step circle",
|
|
196
|
+
editable: true,
|
|
197
|
+
required: false,
|
|
198
|
+
formType: FORM_TYPES.number,
|
|
199
|
+
propType: PROP_TYPES.NUMBER,
|
|
200
|
+
min: 10,
|
|
201
|
+
max: 100,
|
|
202
|
+
step: 5,
|
|
203
|
+
precision: 0,
|
|
204
|
+
defaultValue: null,
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import Config from "../Config";
|
|
3
|
+
import IconButton from "../IconButton";
|
|
4
|
+
import { useRadioButtonGroupContext } from "./context";
|
|
5
|
+
import { GROUPS, COMPONENT_TYPES, createBoolProp, createColorProp, createNumberProp, createIconProp, createTextProp, Triggers, } from "@draftbit/types";
|
|
6
|
+
const RadioButton = ({ Icon, disabled = false, color, value, selected, unselectedColor, onPress = () => { }, size = Config.radioButtonSize, selectedIcon = "MaterialIcons/radio-button-checked", unselectedIcon = "MaterialIcons/radio-button-unchecked", style, ...rest }) => {
|
|
7
|
+
const { value: contextValue, onValueChange } = useRadioButtonGroupContext();
|
|
8
|
+
const handlePress = () => {
|
|
9
|
+
onPress && onPress();
|
|
10
|
+
if (onValueChange && value) {
|
|
11
|
+
onValueChange(value);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const isSelected = selected || (contextValue != null && contextValue === value);
|
|
15
|
+
return (React.createElement(IconButton, { Icon: Icon, icon: isSelected ? selectedIcon : unselectedIcon, color: isSelected ? color : unselectedColor, disabled: disabled, onPress: handlePress, size: size, style: style, ...rest }));
|
|
16
|
+
};
|
|
17
|
+
export default RadioButton;
|
|
18
|
+
export const SEED_DATA = {
|
|
19
|
+
name: "Radio Button",
|
|
20
|
+
tag: "RadioButton",
|
|
21
|
+
category: COMPONENT_TYPES.input,
|
|
22
|
+
triggers: [Triggers.OnPress],
|
|
23
|
+
props: {
|
|
24
|
+
value: createTextProp({
|
|
25
|
+
label: "Value",
|
|
26
|
+
description: "Value of the radio button",
|
|
27
|
+
defaultValue: null,
|
|
28
|
+
required: true,
|
|
29
|
+
}),
|
|
30
|
+
color: createColorProp({
|
|
31
|
+
group: GROUPS.basic,
|
|
32
|
+
description: "Color for the button",
|
|
33
|
+
defaultValue: "primary",
|
|
34
|
+
}),
|
|
35
|
+
unselectedColor: createColorProp({
|
|
36
|
+
group: GROUPS.basic,
|
|
37
|
+
label: "Unselected Color",
|
|
38
|
+
description: "Unselected Color for the button",
|
|
39
|
+
defaultValue: "primary",
|
|
40
|
+
}),
|
|
41
|
+
disabled: createBoolProp({
|
|
42
|
+
label: "Disabled",
|
|
43
|
+
description: "Whether radio button is disabled",
|
|
44
|
+
}),
|
|
45
|
+
size: createNumberProp({
|
|
46
|
+
group: GROUPS.basic,
|
|
47
|
+
label: "Size",
|
|
48
|
+
description: "Specifies the size of the button",
|
|
49
|
+
defaultValue: 24,
|
|
50
|
+
min: 16,
|
|
51
|
+
max: 128,
|
|
52
|
+
step: 1,
|
|
53
|
+
precision: 0,
|
|
54
|
+
}),
|
|
55
|
+
selectedIcon: createIconProp({
|
|
56
|
+
label: "Selected Icon",
|
|
57
|
+
description: "Icon to show when the radio button is selected",
|
|
58
|
+
defaultValue: "MaterialIcons/radio-button-checked",
|
|
59
|
+
}),
|
|
60
|
+
unselectedIcon: createIconProp({
|
|
61
|
+
label: "Unselected Icon",
|
|
62
|
+
description: "Icon to show when the radio button is unselected",
|
|
63
|
+
defaultValue: "MaterialIcons/radio-button-unchecked",
|
|
64
|
+
}),
|
|
65
|
+
},
|
|
66
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import Text from "../Text";
|
|
4
|
+
import { withTheme } from "../../theming";
|
|
5
|
+
import RadioButtonGroup from "./RadioButtonGroup";
|
|
6
|
+
const RadioButtonFieldGroup = ({ label, children, theme, labelStyle, style, ...rest }) => {
|
|
7
|
+
return (React.createElement(View, { style: style },
|
|
8
|
+
React.createElement(Text, { style: [
|
|
9
|
+
{
|
|
10
|
+
fontSize: theme.typography.headline4.fontSize,
|
|
11
|
+
color: theme.typography.headline4.color,
|
|
12
|
+
},
|
|
13
|
+
labelStyle,
|
|
14
|
+
] }, label),
|
|
15
|
+
React.createElement(RadioButtonGroup, { theme: theme, ...rest }, children)));
|
|
16
|
+
};
|
|
17
|
+
export default withTheme(RadioButtonFieldGroup);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { COMPONENT_TYPES, createFieldNameProp, createDirectionProp, Triggers, } from "@draftbit/types";
|
|
4
|
+
import { radioButtonGroupContext, Direction } from "./context";
|
|
5
|
+
import { usePrevious } from "../../hooks";
|
|
6
|
+
const { Provider } = radioButtonGroupContext;
|
|
7
|
+
const RadioButtonGroup = ({ direction = Direction.Vertical, value, onValueChange = () => { }, initialValue, style, children, ...rest }) => {
|
|
8
|
+
const previousInitialValue = usePrevious(initialValue);
|
|
9
|
+
React.useEffect(() => {
|
|
10
|
+
if (initialValue !== previousInitialValue) {
|
|
11
|
+
onValueChange(initialValue);
|
|
12
|
+
}
|
|
13
|
+
}, [initialValue, previousInitialValue, onValueChange]);
|
|
14
|
+
const _containerStyle = [
|
|
15
|
+
{
|
|
16
|
+
flexDirection: direction === Direction.Horizontal ? "row" : "column",
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
if (direction !== Direction.Vertical) {
|
|
20
|
+
_containerStyle.push({
|
|
21
|
+
alignItems: "center",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return (React.createElement(View, { style: [{ minHeight: 40 }, style], ...rest },
|
|
25
|
+
React.createElement(Provider, { value: { value, onValueChange, direction } },
|
|
26
|
+
React.createElement(View, { style: _containerStyle }, children))));
|
|
27
|
+
};
|
|
28
|
+
export default RadioButtonGroup;
|
|
29
|
+
export const SEED_DATA = {
|
|
30
|
+
name: "Radio Button Group",
|
|
31
|
+
tag: "RadioButtonGroup",
|
|
32
|
+
category: COMPONENT_TYPES.input,
|
|
33
|
+
layout: {},
|
|
34
|
+
triggers: [Triggers.OnValueChange],
|
|
35
|
+
props: {
|
|
36
|
+
direction: createDirectionProp(),
|
|
37
|
+
fieldName: createFieldNameProp({
|
|
38
|
+
handlerPropName: "onValueChange",
|
|
39
|
+
valuePropName: "value",
|
|
40
|
+
defaultValue: "radioButtonGroupValue",
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { StyleSheet, View, Platform, } from "react-native";
|
|
3
|
+
import RadioButton from "./RadioButton";
|
|
4
|
+
import Text from "../Text";
|
|
5
|
+
import { useRadioButtonGroupContext } from "./context";
|
|
6
|
+
import { createTextProp, createTextEnumProp, COMPONENT_TYPES, createColorProp, GROUPS, } 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 getRadioButtonAlignment = (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 RadioButtonRow = ({ Icon, label, value, color, unselectedColor, onPress = () => { }, labelContainerStyle, labelStyle, radioButtonStyle, direction = Direction.Row, selected, disabled, style, ...rest }) => {
|
|
35
|
+
const { value: contextValue, onValueChange, direction: parentDirection, } = useRadioButtonGroupContext();
|
|
36
|
+
const handlePress = () => {
|
|
37
|
+
onPress(value);
|
|
38
|
+
onValueChange && onValueChange(value);
|
|
39
|
+
};
|
|
40
|
+
const { textStyles, viewStyles } = extractStyles(style);
|
|
41
|
+
return (React.createElement(Touchable, { onPress: handlePress, style: [styles.mainParent, { flexDirection: direction }, viewStyles], disabled: disabled, ...rest },
|
|
42
|
+
React.createElement(View, { style: [
|
|
43
|
+
styles.label,
|
|
44
|
+
{
|
|
45
|
+
alignItems: direction === Direction.Row ? "flex-start" : "flex-end",
|
|
46
|
+
},
|
|
47
|
+
labelContainerStyle,
|
|
48
|
+
] }, renderLabel(label, labelStyle, textStyles)),
|
|
49
|
+
React.createElement(View, { style: {
|
|
50
|
+
flex: 1,
|
|
51
|
+
alignItems: getRadioButtonAlignment(parentDirection, direction),
|
|
52
|
+
} },
|
|
53
|
+
React.createElement(RadioButton, { Icon: Icon, selected: selected || (contextValue != null && contextValue === value), color: color, unselectedColor: unselectedColor, onPress: handlePress, style: radioButtonStyle }))));
|
|
54
|
+
};
|
|
55
|
+
const styles = StyleSheet.create({
|
|
56
|
+
mainParent: {
|
|
57
|
+
alignItems: "center",
|
|
58
|
+
justifyContent: "space-around",
|
|
59
|
+
paddingStart: 20,
|
|
60
|
+
minHeight: 50,
|
|
61
|
+
paddingEnd: 20,
|
|
62
|
+
flex: 1,
|
|
63
|
+
...Platform.select({
|
|
64
|
+
web: {
|
|
65
|
+
cursor: "pointer",
|
|
66
|
+
userSelect: "none",
|
|
67
|
+
},
|
|
68
|
+
}),
|
|
69
|
+
},
|
|
70
|
+
label: {
|
|
71
|
+
flex: 3,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
export default RadioButtonRow;
|
|
75
|
+
export const SEED_DATA = {
|
|
76
|
+
name: "Radio Button Row",
|
|
77
|
+
tag: "RadioButtonRow",
|
|
78
|
+
category: COMPONENT_TYPES.input,
|
|
79
|
+
layout: {},
|
|
80
|
+
props: {
|
|
81
|
+
label: createTextProp({
|
|
82
|
+
label: "Label",
|
|
83
|
+
description: "Label to show with the radio button",
|
|
84
|
+
required: true,
|
|
85
|
+
defaultValue: "First Option",
|
|
86
|
+
}),
|
|
87
|
+
direction: createTextEnumProp({
|
|
88
|
+
label: "Direction",
|
|
89
|
+
description: "Whether the checkbox will appear on the left or on the right",
|
|
90
|
+
options: ["row", "row-reverse"],
|
|
91
|
+
}),
|
|
92
|
+
value: createTextProp({
|
|
93
|
+
label: "Value",
|
|
94
|
+
description: "Value of the radio button",
|
|
95
|
+
defaultValue: null,
|
|
96
|
+
required: true,
|
|
97
|
+
}),
|
|
98
|
+
color: createColorProp({
|
|
99
|
+
group: GROUPS.basic,
|
|
100
|
+
description: "Color for the button",
|
|
101
|
+
defaultValue: "primary",
|
|
102
|
+
}),
|
|
103
|
+
unselectedColor: createColorProp({
|
|
104
|
+
group: GROUPS.basic,
|
|
105
|
+
label: "Unselected Color",
|
|
106
|
+
description: "Unselected Color for the button",
|
|
107
|
+
defaultValue: "primary",
|
|
108
|
+
}),
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
// TODO comment testing
|
|
@@ -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 radioButtonGroupContext = createContext({
|
|
8
|
+
onValueChange: () => { },
|
|
9
|
+
value: "",
|
|
10
|
+
direction: undefined,
|
|
11
|
+
});
|
|
12
|
+
export function useRadioButtonGroupContext() {
|
|
13
|
+
return useContext(radioButtonGroupContext);
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, Text, Image, StyleSheet, } from "react-native";
|
|
3
|
+
import { withTheme } from "../theming";
|
|
4
|
+
import Config from "./Config";
|
|
5
|
+
const Row = ({ titleTypeStyle, titleColor, subtitleTypeStyle, subtitleColor, title, subtitle, multilineSubtitle, image, right, style, }) => {
|
|
6
|
+
return (React.createElement(View, { style: [styles.container, { padding: 16 }, style] },
|
|
7
|
+
React.createElement(View, { style: styles.leftContainer },
|
|
8
|
+
image && (React.createElement(Image, { source: typeof image === "string" ? { uri: image } : image, style: {
|
|
9
|
+
marginRight: 12,
|
|
10
|
+
width: subtitle
|
|
11
|
+
? Config.rowMultiLineImageSize
|
|
12
|
+
: Config.rowSingleLineImageSize,
|
|
13
|
+
height: subtitle
|
|
14
|
+
? Config.rowMultiLineImageSize
|
|
15
|
+
: Config.rowSingleLineImageSize,
|
|
16
|
+
} })),
|
|
17
|
+
React.createElement(View, { style: styles.textContainer },
|
|
18
|
+
React.createElement(Text, { style: [
|
|
19
|
+
titleTypeStyle,
|
|
20
|
+
{
|
|
21
|
+
color: titleColor,
|
|
22
|
+
},
|
|
23
|
+
], numberOfLines: 1 }, title),
|
|
24
|
+
subtitle ? (React.createElement(Text, { style: [
|
|
25
|
+
subtitleTypeStyle,
|
|
26
|
+
{
|
|
27
|
+
color: subtitleColor,
|
|
28
|
+
marginTop: 4,
|
|
29
|
+
},
|
|
30
|
+
], numberOfLines: multilineSubtitle ? undefined : 1 }, subtitle)) : null)),
|
|
31
|
+
right && right()));
|
|
32
|
+
};
|
|
33
|
+
const styles = StyleSheet.create({
|
|
34
|
+
leftContainer: {
|
|
35
|
+
flexDirection: "row",
|
|
36
|
+
flex: 1,
|
|
37
|
+
},
|
|
38
|
+
container: {
|
|
39
|
+
flexDirection: "row",
|
|
40
|
+
justifyContent: "space-between",
|
|
41
|
+
alignItems: "center",
|
|
42
|
+
},
|
|
43
|
+
textContainer: {
|
|
44
|
+
flex: 1,
|
|
45
|
+
justifyContent: "center",
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
export default withTheme(Row);
|