@draftbit/core 43.3.1 → 43.3.4-900303.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.
- package/lib/commonjs/components/Accordion/AccordionGroup.js +14 -26
- package/lib/commonjs/components/Accordion/AccordionGroup.js.map +1 -1
- package/lib/commonjs/components/ActionSheet/ActionSheetCancel.js.map +1 -1
- package/lib/commonjs/components/FAB.js +6 -2
- package/lib/commonjs/components/FAB.js.map +1 -1
- package/lib/commonjs/components/Stepper.js +28 -19
- package/lib/commonjs/components/Stepper.js.map +1 -1
- package/lib/commonjs/components/Swiper/Swiper.js +23 -1
- package/lib/commonjs/components/Swiper/Swiper.js.map +1 -1
- package/lib/commonjs/mappings/{AccordionGroup.js → Accordion.js} +9 -2
- package/lib/commonjs/mappings/Accordion.js.map +1 -0
- package/lib/commonjs/mappings/AccordionItem.js +1 -1
- package/lib/commonjs/mappings/AccordionItem.js.map +1 -1
- package/lib/commonjs/mappings/Stepper.js +9 -0
- package/lib/commonjs/mappings/Stepper.js.map +1 -1
- package/lib/commonjs/mappings/Swiper.js +14 -0
- package/lib/commonjs/mappings/Swiper.js.map +1 -1
- package/lib/commonjs/mappings/TextArea.js +10 -1
- package/lib/commonjs/mappings/TextArea.js.map +1 -1
- package/lib/module/components/Accordion/AccordionGroup.js +13 -26
- package/lib/module/components/Accordion/AccordionGroup.js.map +1 -1
- package/lib/module/components/DatePicker/DatePickerComponent.web.js.map +1 -1
- package/lib/module/components/FAB.js +6 -2
- package/lib/module/components/FAB.js.map +1 -1
- package/lib/module/components/Image.js +4 -6
- package/lib/module/components/Image.js.map +1 -1
- package/lib/module/components/Stepper.js +27 -19
- package/lib/module/components/Stepper.js.map +1 -1
- package/lib/module/components/Swiper/Swiper.js +23 -1
- package/lib/module/components/Swiper/Swiper.js.map +1 -1
- package/lib/module/components/Touchable.js +3 -16
- package/lib/module/components/Touchable.js.map +1 -1
- package/lib/module/mappings/{AccordionGroup.js → Accordion.js} +9 -2
- package/lib/module/mappings/Accordion.js.map +1 -0
- package/lib/module/mappings/AccordionItem.js +1 -1
- package/lib/module/mappings/AccordionItem.js.map +1 -1
- package/lib/module/mappings/CardBlock.js.map +1 -1
- package/lib/module/mappings/Stepper.js +10 -1
- package/lib/module/mappings/Stepper.js.map +1 -1
- package/lib/module/mappings/Swiper.js +15 -1
- package/lib/module/mappings/Swiper.js.map +1 -1
- package/lib/module/mappings/TextArea.js +10 -1
- package/lib/module/mappings/TextArea.js.map +1 -1
- package/lib/typescript/src/components/Stepper.d.ts +2 -0
- package/lib/typescript/src/components/Swiper/Swiper.d.ts +5 -1
- package/lib/typescript/src/mappings/{AccordionGroup.d.ts → Accordion.d.ts} +7 -0
- package/lib/typescript/src/mappings/Stepper.d.ts +22 -0
- package/lib/typescript/src/mappings/Swiper.d.ts +40 -0
- package/lib/typescript/src/mappings/TextArea.d.ts +10 -1
- package/package.json +3 -3
- package/src/components/Accordion/AccordionGroup.js +16 -33
- package/src/components/Accordion/AccordionGroup.tsx +28 -56
- package/src/components/FAB.js +1 -1
- package/src/components/FAB.tsx +6 -2
- package/src/components/Stepper.js +23 -21
- package/src/components/Stepper.tsx +27 -19
- package/src/components/Swiper/Swiper.js +9 -1
- package/src/components/Swiper/Swiper.tsx +16 -0
- package/src/mappings/{AccordionGroup.js → Accordion.js} +8 -1
- package/src/mappings/{AccordionGroup.ts → Accordion.ts} +8 -1
- package/src/mappings/AccordionItem.js +1 -1
- package/src/mappings/AccordionItem.ts +1 -1
- package/src/mappings/Stepper.js +10 -1
- package/src/mappings/Stepper.ts +10 -0
- package/src/mappings/Swiper.js +15 -1
- package/src/mappings/Swiper.ts +15 -0
- package/src/mappings/TextArea.js +12 -1
- package/src/mappings/TextArea.ts +12 -1
- package/lib/commonjs/mappings/AccordionGroup.js.map +0 -1
- package/lib/module/mappings/AccordionGroup.js.map +0 -1
|
@@ -7,9 +7,13 @@ export interface SwiperProps {
|
|
|
7
7
|
timeout?: number;
|
|
8
8
|
prevTitle?: string;
|
|
9
9
|
nextTitle?: string;
|
|
10
|
+
prevTitleColor?: string;
|
|
11
|
+
nextTitleColor?: string;
|
|
10
12
|
dotsTouchable?: boolean;
|
|
13
|
+
dotColor?: string;
|
|
14
|
+
dotActiveColor?: string;
|
|
11
15
|
children: React.ReactNode;
|
|
12
16
|
style?: StyleProp<ViewStyle>;
|
|
13
17
|
}
|
|
14
|
-
declare const Swiper: ({ vertical, loop, timeout, from, prevTitle, nextTitle, dotsTouchable, children, style, }: SwiperProps) => JSX.Element;
|
|
18
|
+
declare const Swiper: ({ vertical, loop, timeout, from, prevTitle, nextTitle, prevTitleColor, nextTitleColor, dotsTouchable, dotColor, dotActiveColor, children, style, }: SwiperProps) => JSX.Element;
|
|
15
19
|
export default Swiper;
|
|
@@ -3,6 +3,13 @@ export declare const SEED_DATA: {
|
|
|
3
3
|
tag: string;
|
|
4
4
|
description: string;
|
|
5
5
|
category: string;
|
|
6
|
+
layout: {
|
|
7
|
+
paddingTop: number;
|
|
8
|
+
paddingRight: number;
|
|
9
|
+
paddingBottom: number;
|
|
10
|
+
paddingLeft: number;
|
|
11
|
+
fontSize: number;
|
|
12
|
+
};
|
|
6
13
|
props: {
|
|
7
14
|
openColor: {
|
|
8
15
|
group: string;
|
|
@@ -39,5 +39,27 @@ export declare const SEED_DATA: {
|
|
|
39
39
|
formType: string;
|
|
40
40
|
propType: string;
|
|
41
41
|
};
|
|
42
|
+
min: {
|
|
43
|
+
label: string;
|
|
44
|
+
description: string;
|
|
45
|
+
formType: string;
|
|
46
|
+
propType: string;
|
|
47
|
+
group: string;
|
|
48
|
+
defaultValue: null;
|
|
49
|
+
editable: boolean;
|
|
50
|
+
required: boolean;
|
|
51
|
+
step: number;
|
|
52
|
+
};
|
|
53
|
+
max: {
|
|
54
|
+
label: string;
|
|
55
|
+
description: string;
|
|
56
|
+
formType: string;
|
|
57
|
+
propType: string;
|
|
58
|
+
group: string;
|
|
59
|
+
defaultValue: null;
|
|
60
|
+
editable: boolean;
|
|
61
|
+
required: boolean;
|
|
62
|
+
step: number;
|
|
63
|
+
};
|
|
42
64
|
};
|
|
43
65
|
}[];
|
|
@@ -52,6 +52,46 @@ export declare const SEED_DATA: {
|
|
|
52
52
|
};
|
|
53
53
|
prevTitle: any;
|
|
54
54
|
nextTitle: any;
|
|
55
|
+
prevTitleColor: {
|
|
56
|
+
group: string;
|
|
57
|
+
label: string;
|
|
58
|
+
description: string;
|
|
59
|
+
editable: boolean;
|
|
60
|
+
required: boolean;
|
|
61
|
+
defaultValue: null;
|
|
62
|
+
formType: string;
|
|
63
|
+
propType: string;
|
|
64
|
+
};
|
|
65
|
+
nextTitleColor: {
|
|
66
|
+
group: string;
|
|
67
|
+
label: string;
|
|
68
|
+
description: string;
|
|
69
|
+
editable: boolean;
|
|
70
|
+
required: boolean;
|
|
71
|
+
defaultValue: null;
|
|
72
|
+
formType: string;
|
|
73
|
+
propType: string;
|
|
74
|
+
};
|
|
75
|
+
dotColor: {
|
|
76
|
+
group: string;
|
|
77
|
+
label: string;
|
|
78
|
+
description: string;
|
|
79
|
+
editable: boolean;
|
|
80
|
+
required: boolean;
|
|
81
|
+
defaultValue: null;
|
|
82
|
+
formType: string;
|
|
83
|
+
propType: string;
|
|
84
|
+
};
|
|
85
|
+
dotActiveColor: {
|
|
86
|
+
group: string;
|
|
87
|
+
label: string;
|
|
88
|
+
description: string;
|
|
89
|
+
editable: boolean;
|
|
90
|
+
required: boolean;
|
|
91
|
+
defaultValue: null;
|
|
92
|
+
formType: string;
|
|
93
|
+
propType: string;
|
|
94
|
+
};
|
|
55
95
|
dotsTouchable: {
|
|
56
96
|
label: string;
|
|
57
97
|
description: string;
|
|
@@ -4,7 +4,16 @@ export declare const SEED_DATA: {
|
|
|
4
4
|
description: string;
|
|
5
5
|
category: string;
|
|
6
6
|
layout: {
|
|
7
|
-
|
|
7
|
+
borderLeftWidth: number;
|
|
8
|
+
borderRightWidth: number;
|
|
9
|
+
borderTopWidth: number;
|
|
10
|
+
borderBottomWidth: number;
|
|
11
|
+
borderColor: string;
|
|
12
|
+
paddingLeft: number;
|
|
13
|
+
paddingRight: number;
|
|
14
|
+
paddingTop: number;
|
|
15
|
+
paddingBottom: number;
|
|
16
|
+
borderRadius: number;
|
|
8
17
|
};
|
|
9
18
|
triggers: string[];
|
|
10
19
|
props: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "43.3.
|
|
3
|
+
"version": "43.3.4-900303.5+90030317",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@date-io/date-fns": "^1.3.13",
|
|
43
43
|
"@draftbit/react-theme-provider": "^2.1.1",
|
|
44
|
-
"@draftbit/types": "^43.3.
|
|
44
|
+
"@draftbit/types": "^43.3.3",
|
|
45
45
|
"@material-ui/core": "^4.11.0",
|
|
46
46
|
"@material-ui/pickers": "^3.2.10",
|
|
47
47
|
"@react-native-community/slider": "4.1.7",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
]
|
|
80
80
|
]
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "9003031730d4f6561505d6f0262e3ef2ba17224f"
|
|
83
83
|
}
|
|
@@ -2,45 +2,31 @@ import * as React from "react";
|
|
|
2
2
|
import { View, StyleSheet, Pressable, } from "react-native";
|
|
3
3
|
import Text from "../Text";
|
|
4
4
|
import { withTheme } from "../../theming";
|
|
5
|
+
import { extractStyles } from "../../utilities";
|
|
5
6
|
const AccordionGroup = ({ Icon, openColor, closedColor, caretColor, icon, iconSize = 24, style, label, children, expanded: expandedProp, theme, }) => {
|
|
6
7
|
const [expanded, setExpanded] = React.useState(expandedProp || false);
|
|
7
8
|
const handlePressAction = () => {
|
|
8
|
-
|
|
9
|
-
setExpanded(!expanded);
|
|
10
|
-
}
|
|
9
|
+
setExpanded(!expanded);
|
|
11
10
|
};
|
|
12
11
|
const expandedInternal = expandedProp !== undefined ? expandedProp : expanded;
|
|
13
12
|
const expandedColor = openColor || theme.colors.primary;
|
|
14
13
|
const collapsedColor = closedColor || theme.colors.primary;
|
|
15
14
|
const labelColor = expanded ? expandedColor : collapsedColor;
|
|
15
|
+
const { textStyles, viewStyles } = extractStyles(style);
|
|
16
16
|
return (React.createElement(React.Fragment, null,
|
|
17
|
-
React.createElement(Pressable, { style: [
|
|
18
|
-
React.createElement(
|
|
19
|
-
|
|
20
|
-
React.createElement(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
? "MaterialIcons/keyboard-arrow-up"
|
|
31
|
-
: "MaterialIcons/keyboard-arrow-down", color: caretColor, size: 24 })))),
|
|
32
|
-
expandedInternal
|
|
33
|
-
? React.Children.map(children, (child) => {
|
|
34
|
-
if (React.isValidElement(child) &&
|
|
35
|
-
!child.props.left &&
|
|
36
|
-
!child.props.right) {
|
|
37
|
-
return React.cloneElement(child, {
|
|
38
|
-
style: child.props.style,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return child;
|
|
42
|
-
})
|
|
43
|
-
: null));
|
|
17
|
+
React.createElement(Pressable, { style: [styles.row, viewStyles], onPress: handlePressAction, accessibilityRole: "button" },
|
|
18
|
+
icon ? React.createElement(Icon, { name: icon, size: iconSize, color: labelColor }) : null,
|
|
19
|
+
React.createElement(View, { style: styles.content },
|
|
20
|
+
React.createElement(Text, { selectable: false, style: [
|
|
21
|
+
{
|
|
22
|
+
color: labelColor,
|
|
23
|
+
},
|
|
24
|
+
textStyles,
|
|
25
|
+
] }, label)),
|
|
26
|
+
React.createElement(Icon, { name: expanded
|
|
27
|
+
? "MaterialIcons/keyboard-arrow-up"
|
|
28
|
+
: "MaterialIcons/keyboard-arrow-down", color: caretColor, size: 24 })),
|
|
29
|
+
expandedInternal ? children : null));
|
|
44
30
|
};
|
|
45
31
|
const styles = StyleSheet.create({
|
|
46
32
|
row: {
|
|
@@ -50,9 +36,6 @@ const styles = StyleSheet.create({
|
|
|
50
36
|
label: {
|
|
51
37
|
fontSize: 16,
|
|
52
38
|
},
|
|
53
|
-
item: {
|
|
54
|
-
margin: 8,
|
|
55
|
-
},
|
|
56
39
|
content: {
|
|
57
40
|
flex: 1,
|
|
58
41
|
justifyContent: "center",
|
|
@@ -10,6 +10,7 @@ import Text from "../Text";
|
|
|
10
10
|
import { withTheme } from "../../theming";
|
|
11
11
|
import type { IconSlot } from "../../interfaces/Icon";
|
|
12
12
|
import type { Theme } from "../../styles/DefaultTheme";
|
|
13
|
+
import { extractStyles } from "../../utilities";
|
|
13
14
|
|
|
14
15
|
type Props = {
|
|
15
16
|
openColor: string;
|
|
@@ -42,9 +43,7 @@ const AccordionGroup = ({
|
|
|
42
43
|
);
|
|
43
44
|
|
|
44
45
|
const handlePressAction = () => {
|
|
45
|
-
|
|
46
|
-
setExpanded(!expanded);
|
|
47
|
-
}
|
|
46
|
+
setExpanded(!expanded);
|
|
48
47
|
};
|
|
49
48
|
|
|
50
49
|
const expandedInternal = expandedProp !== undefined ? expandedProp : expanded;
|
|
@@ -54,64 +53,40 @@ const AccordionGroup = ({
|
|
|
54
53
|
|
|
55
54
|
const labelColor = expanded ? expandedColor : collapsedColor;
|
|
56
55
|
|
|
56
|
+
const { textStyles, viewStyles } = extractStyles(style);
|
|
57
|
+
|
|
57
58
|
return (
|
|
58
59
|
<>
|
|
59
60
|
<Pressable
|
|
60
|
-
style={[
|
|
61
|
+
style={[styles.row, viewStyles]}
|
|
61
62
|
onPress={handlePressAction}
|
|
62
63
|
accessibilityRole="button"
|
|
63
64
|
>
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
styles.label,
|
|
78
|
-
{
|
|
79
|
-
color: labelColor,
|
|
80
|
-
},
|
|
81
|
-
style,
|
|
82
|
-
]}
|
|
83
|
-
>
|
|
84
|
-
{label}
|
|
85
|
-
</Text>
|
|
86
|
-
</View>
|
|
87
|
-
<View style={[styles.item]}>
|
|
88
|
-
<Icon
|
|
89
|
-
name={
|
|
90
|
-
expanded
|
|
91
|
-
? "MaterialIcons/keyboard-arrow-up"
|
|
92
|
-
: "MaterialIcons/keyboard-arrow-down"
|
|
93
|
-
}
|
|
94
|
-
color={caretColor}
|
|
95
|
-
size={24}
|
|
96
|
-
/>
|
|
97
|
-
</View>
|
|
65
|
+
{icon ? <Icon name={icon} size={iconSize} color={labelColor} /> : null}
|
|
66
|
+
<View style={styles.content}>
|
|
67
|
+
<Text
|
|
68
|
+
selectable={false}
|
|
69
|
+
style={[
|
|
70
|
+
{
|
|
71
|
+
color: labelColor,
|
|
72
|
+
},
|
|
73
|
+
textStyles,
|
|
74
|
+
]}
|
|
75
|
+
>
|
|
76
|
+
{label}
|
|
77
|
+
</Text>
|
|
98
78
|
</View>
|
|
79
|
+
<Icon
|
|
80
|
+
name={
|
|
81
|
+
expanded
|
|
82
|
+
? "MaterialIcons/keyboard-arrow-up"
|
|
83
|
+
: "MaterialIcons/keyboard-arrow-down"
|
|
84
|
+
}
|
|
85
|
+
color={caretColor}
|
|
86
|
+
size={24}
|
|
87
|
+
/>
|
|
99
88
|
</Pressable>
|
|
100
|
-
{expandedInternal
|
|
101
|
-
? React.Children.map(children, (child) => {
|
|
102
|
-
if (
|
|
103
|
-
React.isValidElement(child) &&
|
|
104
|
-
!child.props.left &&
|
|
105
|
-
!child.props.right
|
|
106
|
-
) {
|
|
107
|
-
return React.cloneElement(child, {
|
|
108
|
-
style: child.props.style,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return child;
|
|
113
|
-
})
|
|
114
|
-
: null}
|
|
89
|
+
{expandedInternal ? children : null}
|
|
115
90
|
</>
|
|
116
91
|
);
|
|
117
92
|
};
|
|
@@ -124,9 +99,6 @@ const styles = StyleSheet.create({
|
|
|
124
99
|
label: {
|
|
125
100
|
fontSize: 16,
|
|
126
101
|
},
|
|
127
|
-
item: {
|
|
128
|
-
margin: 8,
|
|
129
|
-
},
|
|
130
102
|
content: {
|
|
131
103
|
flex: 1,
|
|
132
104
|
justifyContent: "center",
|
package/src/components/FAB.js
CHANGED
|
@@ -28,7 +28,7 @@ const FAB = ({ onPress, disabled, loading, iconName = "MaterialIcons/add", style
|
|
|
28
28
|
},
|
|
29
29
|
];
|
|
30
30
|
}, ...props },
|
|
31
|
-
React.createElement(View, null, loading ? (React.createElement(ActivityIndicator, { size: "small", color: color })) : (React.createElement(Icon, { name: iconName, size:
|
|
31
|
+
React.createElement(View, null, loading ? (React.createElement(ActivityIndicator, { style: size > 50 ? { marginTop: 2, marginLeft: 2 } : undefined, size: size <= 50 ? "small" : "large", color: color })) : (React.createElement(Icon, { name: iconName, size: size, color: color }))))));
|
|
32
32
|
};
|
|
33
33
|
const styles = StyleSheet.create({
|
|
34
34
|
button: {
|
package/src/components/FAB.tsx
CHANGED
|
@@ -77,9 +77,13 @@ const FAB: React.FC<Props> = ({
|
|
|
77
77
|
>
|
|
78
78
|
<View>
|
|
79
79
|
{loading ? (
|
|
80
|
-
<ActivityIndicator
|
|
80
|
+
<ActivityIndicator
|
|
81
|
+
style={size > 50 ? { marginTop: 2, marginLeft: 2 } : undefined}
|
|
82
|
+
size={size <= 50 ? "small" : "large"}
|
|
83
|
+
color={color}
|
|
84
|
+
/>
|
|
81
85
|
) : (
|
|
82
|
-
<Icon name={iconName} size={
|
|
86
|
+
<Icon name={iconName} size={size} color={color} />
|
|
83
87
|
)}
|
|
84
88
|
</View>
|
|
85
89
|
</Pressable>
|
|
@@ -2,40 +2,42 @@ import * as React from "react";
|
|
|
2
2
|
import { View, Text } from "react-native";
|
|
3
3
|
import { withTheme } from "../theming";
|
|
4
4
|
import IconButton from "./IconButton";
|
|
5
|
-
|
|
5
|
+
import isNumber from "lodash.isnumber";
|
|
6
|
+
const Stepper = ({ Icon, value, min, max, style, onChange, defaultValue, theme: { colors, typography, roundness }, iconSize = 24, iconColor = colors.strong, borderRadius = roundness, typeStyle, }) => {
|
|
6
7
|
const [stateValue, setStateValue] = React.useState(value || defaultValue || 0);
|
|
7
8
|
React.useEffect(() => {
|
|
8
|
-
if (value
|
|
9
|
-
|
|
9
|
+
if (value || value === 0) {
|
|
10
|
+
onChange && onChange(stateValue);
|
|
10
11
|
}
|
|
11
|
-
}, [value]);
|
|
12
|
+
}, [onChange, stateValue, value]);
|
|
12
13
|
React.useEffect(() => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}, [defaultValue]);
|
|
17
|
-
const handleMinus = () => {
|
|
18
|
-
if (value || value === 0) {
|
|
19
|
-
onChange && onChange(value - 1);
|
|
14
|
+
let newValue = value || defaultValue || 0;
|
|
15
|
+
if (isNumber(max) && newValue > max) {
|
|
16
|
+
newValue = max;
|
|
20
17
|
}
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
if (isNumber(min) && newValue < min) {
|
|
19
|
+
newValue = min;
|
|
23
20
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
setStateValue(newValue);
|
|
22
|
+
}, [defaultValue, value, min, max]);
|
|
23
|
+
const handleMinus = React.useCallback(() => {
|
|
24
|
+
if (isNumber(min) && value === min) {
|
|
25
|
+
return;
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
setStateValue(stateValue - 1);
|
|
28
|
+
}, [min, stateValue, value]);
|
|
29
|
+
const handlePlus = React.useCallback(() => {
|
|
30
|
+
if (isNumber(max) && value === max) {
|
|
31
|
+
return;
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
setStateValue(stateValue + 1);
|
|
34
|
+
}, [max, stateValue, value]);
|
|
33
35
|
return (React.createElement(View, { style: [
|
|
34
36
|
{ flexDirection: "row" },
|
|
35
37
|
style,
|
|
36
38
|
borderRadius ? { borderRadius } : {},
|
|
37
39
|
] },
|
|
38
|
-
React.createElement(IconButton, { Icon: Icon, icon: "MaterialIcons/remove", onPress: handleMinus, size: iconSize, color: iconColor, disabled:
|
|
40
|
+
React.createElement(IconButton, { Icon: Icon, icon: "MaterialIcons/remove", onPress: handleMinus, size: iconSize, color: iconColor, disabled: stateValue === 0 }),
|
|
39
41
|
React.createElement(Text, { style: [
|
|
40
42
|
typography.body1,
|
|
41
43
|
{
|
|
@@ -5,9 +5,12 @@ import type { Theme } from "../styles/DefaultTheme";
|
|
|
5
5
|
import type { IconSlot } from "../interfaces/Icon";
|
|
6
6
|
|
|
7
7
|
import IconButton from "./IconButton";
|
|
8
|
+
import isNumber from "lodash.isnumber";
|
|
8
9
|
|
|
9
10
|
type Props = {
|
|
10
11
|
value?: number;
|
|
12
|
+
min?: number;
|
|
13
|
+
max?: number;
|
|
11
14
|
theme: Theme;
|
|
12
15
|
style?: StyleProp<ViewStyle>;
|
|
13
16
|
onChange?: (value: number) => void;
|
|
@@ -21,6 +24,8 @@ type Props = {
|
|
|
21
24
|
const Stepper: React.FC<Props> = ({
|
|
22
25
|
Icon,
|
|
23
26
|
value,
|
|
27
|
+
min,
|
|
28
|
+
max,
|
|
24
29
|
style,
|
|
25
30
|
onChange,
|
|
26
31
|
defaultValue,
|
|
@@ -35,32 +40,35 @@ const Stepper: React.FC<Props> = ({
|
|
|
35
40
|
);
|
|
36
41
|
|
|
37
42
|
React.useEffect(() => {
|
|
38
|
-
if (value
|
|
39
|
-
|
|
43
|
+
if (value || value === 0) {
|
|
44
|
+
onChange && onChange(stateValue);
|
|
40
45
|
}
|
|
41
|
-
}, [value]);
|
|
46
|
+
}, [onChange, stateValue, value]);
|
|
42
47
|
|
|
43
48
|
React.useEffect(() => {
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
let newValue = value || defaultValue || 0;
|
|
50
|
+
if (isNumber(max) && newValue > max) {
|
|
51
|
+
newValue = max;
|
|
52
|
+
}
|
|
53
|
+
if (isNumber(min) && newValue < min) {
|
|
54
|
+
newValue = min;
|
|
46
55
|
}
|
|
47
|
-
|
|
56
|
+
setStateValue(newValue);
|
|
57
|
+
}, [defaultValue, value, min, max]);
|
|
48
58
|
|
|
49
|
-
const handleMinus = () => {
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
} else {
|
|
53
|
-
setStateValue(stateValue - 1);
|
|
59
|
+
const handleMinus = React.useCallback(() => {
|
|
60
|
+
if (isNumber(min) && value === min) {
|
|
61
|
+
return;
|
|
54
62
|
}
|
|
55
|
-
|
|
63
|
+
setStateValue(stateValue - 1);
|
|
64
|
+
}, [min, stateValue, value]);
|
|
56
65
|
|
|
57
|
-
const handlePlus = () => {
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
} else {
|
|
61
|
-
setStateValue(stateValue + 1);
|
|
66
|
+
const handlePlus = React.useCallback(() => {
|
|
67
|
+
if (isNumber(max) && value === max) {
|
|
68
|
+
return;
|
|
62
69
|
}
|
|
63
|
-
|
|
70
|
+
setStateValue(stateValue + 1);
|
|
71
|
+
}, [max, stateValue, value]);
|
|
64
72
|
|
|
65
73
|
return (
|
|
66
74
|
<View
|
|
@@ -76,7 +84,7 @@ const Stepper: React.FC<Props> = ({
|
|
|
76
84
|
onPress={handleMinus}
|
|
77
85
|
size={iconSize}
|
|
78
86
|
color={iconColor}
|
|
79
|
-
disabled={
|
|
87
|
+
disabled={stateValue === 0}
|
|
80
88
|
/>
|
|
81
89
|
<Text
|
|
82
90
|
style={[
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import SwiperComponent from "react-native-web-swiper";
|
|
4
|
-
const Swiper = ({ vertical = false, loop = false, timeout = 0, from = 0, prevTitle = "", nextTitle = "", dotsTouchable = true, children, style, }) => (React.createElement(View, { style: style },
|
|
4
|
+
const Swiper = ({ vertical = false, loop = false, timeout = 0, from = 0, prevTitle = "", nextTitle = "", prevTitleColor, nextTitleColor, dotsTouchable = true, dotColor, dotActiveColor, children, style, }) => (React.createElement(View, { style: style },
|
|
5
5
|
React.createElement(SwiperComponent, { from: from, loop: loop, timeout: timeout, vertical: vertical, controlsProps: {
|
|
6
6
|
prevTitle,
|
|
7
7
|
nextTitle,
|
|
8
|
+
prevTitleStyle: { color: prevTitleColor },
|
|
9
|
+
nextTitleStyle: { color: nextTitleColor },
|
|
8
10
|
dotsTouchable,
|
|
11
|
+
...(dotColor
|
|
12
|
+
? { dotProps: { badgeStyle: { backgroundColor: dotColor } } }
|
|
13
|
+
: {}),
|
|
14
|
+
...(dotActiveColor
|
|
15
|
+
? { dotActiveStyle: { backgroundColor: dotActiveColor } }
|
|
16
|
+
: {}),
|
|
9
17
|
} }, children)));
|
|
10
18
|
export default Swiper;
|
|
@@ -9,7 +9,11 @@ export interface SwiperProps {
|
|
|
9
9
|
timeout?: number;
|
|
10
10
|
prevTitle?: string;
|
|
11
11
|
nextTitle?: string;
|
|
12
|
+
prevTitleColor?: string;
|
|
13
|
+
nextTitleColor?: string;
|
|
12
14
|
dotsTouchable?: boolean;
|
|
15
|
+
dotColor?: string;
|
|
16
|
+
dotActiveColor?: string;
|
|
13
17
|
children: React.ReactNode;
|
|
14
18
|
style?: StyleProp<ViewStyle>;
|
|
15
19
|
}
|
|
@@ -21,7 +25,11 @@ const Swiper = ({
|
|
|
21
25
|
from = 0,
|
|
22
26
|
prevTitle = "",
|
|
23
27
|
nextTitle = "",
|
|
28
|
+
prevTitleColor,
|
|
29
|
+
nextTitleColor,
|
|
24
30
|
dotsTouchable = true,
|
|
31
|
+
dotColor,
|
|
32
|
+
dotActiveColor,
|
|
25
33
|
children,
|
|
26
34
|
style,
|
|
27
35
|
}: SwiperProps) => (
|
|
@@ -34,7 +42,15 @@ const Swiper = ({
|
|
|
34
42
|
controlsProps={{
|
|
35
43
|
prevTitle,
|
|
36
44
|
nextTitle,
|
|
45
|
+
prevTitleStyle: { color: prevTitleColor },
|
|
46
|
+
nextTitleStyle: { color: nextTitleColor },
|
|
37
47
|
dotsTouchable,
|
|
48
|
+
...(dotColor
|
|
49
|
+
? { dotProps: { badgeStyle: { backgroundColor: dotColor } } }
|
|
50
|
+
: {}),
|
|
51
|
+
...(dotActiveColor
|
|
52
|
+
? { dotActiveStyle: { backgroundColor: dotActiveColor } }
|
|
53
|
+
: {}),
|
|
38
54
|
}}
|
|
39
55
|
>
|
|
40
56
|
{children}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { COMPONENT_TYPES, createNumberProp, createIconProp, createTextProp, createStaticBoolProp, createColorProp, } from "@draftbit/types";
|
|
2
2
|
export const SEED_DATA = {
|
|
3
|
-
name: "Accordion
|
|
3
|
+
name: "Accordion",
|
|
4
4
|
tag: "AccordionGroup",
|
|
5
5
|
description: "An expandable container containing components",
|
|
6
6
|
category: COMPONENT_TYPES.container,
|
|
7
|
+
layout: {
|
|
8
|
+
paddingTop: 8,
|
|
9
|
+
paddingRight: 8,
|
|
10
|
+
paddingBottom: 8,
|
|
11
|
+
paddingLeft: 8,
|
|
12
|
+
fontSize: 16,
|
|
13
|
+
},
|
|
7
14
|
props: {
|
|
8
15
|
openColor: createColorProp({
|
|
9
16
|
label: "Open text color",
|
|
@@ -8,10 +8,17 @@ import {
|
|
|
8
8
|
} from "@draftbit/types";
|
|
9
9
|
|
|
10
10
|
export const SEED_DATA = {
|
|
11
|
-
name: "Accordion
|
|
11
|
+
name: "Accordion",
|
|
12
12
|
tag: "AccordionGroup",
|
|
13
13
|
description: "An expandable container containing components",
|
|
14
14
|
category: COMPONENT_TYPES.container,
|
|
15
|
+
layout: {
|
|
16
|
+
paddingTop: 8,
|
|
17
|
+
paddingRight: 8,
|
|
18
|
+
paddingBottom: 8,
|
|
19
|
+
paddingLeft: 8,
|
|
20
|
+
fontSize: 16,
|
|
21
|
+
},
|
|
15
22
|
props: {
|
|
16
23
|
openColor: createColorProp({
|
|
17
24
|
label: "Open text color",
|
|
@@ -9,7 +9,7 @@ export const SEED_DATA = {
|
|
|
9
9
|
name: "Accordion Item",
|
|
10
10
|
tag: "AccordionItem",
|
|
11
11
|
description: "Item to be used in Accordion",
|
|
12
|
-
category: COMPONENT_TYPES.
|
|
12
|
+
category: COMPONENT_TYPES.deprecated,
|
|
13
13
|
props: {
|
|
14
14
|
icon: createIconProp(),
|
|
15
15
|
label: createTextProp({
|
package/src/mappings/Stepper.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { COMPONENT_TYPES, createIconSizeProp, createColorProp, createFieldNameProp, Triggers, } from "@draftbit/types";
|
|
1
|
+
import { COMPONENT_TYPES, createIconSizeProp, createColorProp, createFieldNameProp, createStaticNumberProp, Triggers, } from "@draftbit/types";
|
|
2
2
|
export const SEED_DATA = [
|
|
3
3
|
{
|
|
4
4
|
name: "Stepper",
|
|
@@ -15,6 +15,15 @@ export const SEED_DATA = [
|
|
|
15
15
|
}),
|
|
16
16
|
iconSize: createIconSizeProp({ defaultValue: 24 }),
|
|
17
17
|
iconColor: createColorProp({ defaultValue: "strong" }),
|
|
18
|
+
min: createStaticNumberProp({
|
|
19
|
+
label: "Minimum",
|
|
20
|
+
description: "Minimum Number",
|
|
21
|
+
defaultValue: 0,
|
|
22
|
+
}),
|
|
23
|
+
max: createStaticNumberProp({
|
|
24
|
+
label: "Maximum",
|
|
25
|
+
description: "Maximum Number",
|
|
26
|
+
}),
|
|
18
27
|
},
|
|
19
28
|
},
|
|
20
29
|
];
|