@draftbit/core 46.7.9-13d0dd.2 → 46.7.9-193328.2
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/DatePicker/DatePicker.js +8 -1
- package/lib/commonjs/components/DeckSwiper/DeckSwiper.js +74 -0
- package/lib/commonjs/components/DeckSwiper/DeckSwiperCard.js +34 -0
- package/lib/commonjs/components/DeckSwiper/index.js +20 -0
- package/lib/commonjs/components/Divider.js +1 -14
- package/lib/commonjs/components/Elevation.js +2 -14
- package/lib/commonjs/components/NumberInput.js +10 -10
- package/lib/commonjs/components/Picker/Picker.js +3 -2
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/mappings/DatePicker.js +2 -1
- package/lib/commonjs/mappings/DeckSwiper.js +55 -0
- package/lib/commonjs/mappings/DeckSwiperCard.js +23 -0
- package/lib/commonjs/mappings/HtmlElements.js +177 -0
- package/lib/module/components/Accordion/AccordionItem.js +4 -25
- package/lib/module/components/DatePicker/DatePicker.js +8 -1
- package/lib/module/components/DeckSwiper/DeckSwiper.js +66 -0
- package/lib/module/components/DeckSwiper/DeckSwiperCard.js +26 -0
- package/lib/module/components/DeckSwiper/index.js +2 -0
- package/lib/module/components/NumberInput.js +10 -10
- package/lib/module/components/Picker/Picker.js +3 -2
- package/lib/module/index.js +1 -0
- package/lib/module/mappings/DatePicker.js +2 -1
- package/lib/module/mappings/DeckSwiper.js +48 -0
- package/lib/module/mappings/DeckSwiperCard.js +16 -0
- package/lib/module/mappings/HtmlElements.js +170 -0
- package/lib/typescript/src/components/DeckSwiper/DeckSwiper.d.ts +15 -0
- package/lib/typescript/src/components/DeckSwiper/DeckSwiper.d.ts.map +1 -0
- package/lib/typescript/src/components/DeckSwiper/DeckSwiperCard.d.ts +13 -0
- package/lib/typescript/src/components/DeckSwiper/DeckSwiperCard.d.ts.map +1 -0
- package/lib/typescript/src/components/DeckSwiper/index.d.ts +3 -0
- package/lib/typescript/src/components/DeckSwiper/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Picker/Picker.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mappings/DatePicker.d.ts.map +1 -1
- package/lib/typescript/src/mappings/DeckSwiper.d.ts +86 -0
- package/lib/typescript/src/mappings/DeckSwiper.d.ts.map +1 -0
- package/lib/typescript/src/mappings/DeckSwiperCard.d.ts +16 -0
- package/lib/typescript/src/mappings/DeckSwiperCard.d.ts.map +1 -0
- package/lib/typescript/src/mappings/HtmlElements.d.ts +77 -0
- package/lib/typescript/src/mappings/HtmlElements.d.ts.map +1 -0
- package/package.json +5 -3
- package/src/components/DatePicker/DatePicker.js +1 -1
- package/src/components/DatePicker/DatePicker.tsx +1 -1
- package/src/components/DeckSwiper/DeckSwiper.js +35 -0
- package/src/components/DeckSwiper/DeckSwiper.tsx +94 -0
- package/src/components/DeckSwiper/DeckSwiperCard.js +21 -0
- package/src/components/DeckSwiper/DeckSwiperCard.tsx +41 -0
- package/src/components/DeckSwiper/index.js +2 -0
- package/src/components/DeckSwiper/index.tsx +2 -0
- package/src/components/NumberInput.js +9 -9
- package/src/components/NumberInput.tsx +11 -11
- package/src/components/Picker/Picker.js +2 -1
- package/src/components/Picker/Picker.tsx +5 -2
- package/src/index.js +1 -0
- package/src/index.tsx +2 -0
- package/src/mappings/DatePicker.js +2 -1
- package/src/mappings/DatePicker.ts +2 -1
- package/src/mappings/DeckSwiper.js +48 -0
- package/src/mappings/DeckSwiper.ts +57 -0
- package/src/mappings/DeckSwiperCard.js +16 -0
- package/src/mappings/DeckSwiperCard.ts +20 -0
- package/src/mappings/HtmlElements.js +193 -0
- package/src/mappings/HtmlElements.ts +207 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export declare const SEED_DATA: ({
|
|
2
|
+
props: {
|
|
3
|
+
href: any;
|
|
4
|
+
target: {
|
|
5
|
+
group: string;
|
|
6
|
+
label: string;
|
|
7
|
+
description: string;
|
|
8
|
+
formType: string;
|
|
9
|
+
defaultValue: string;
|
|
10
|
+
options: string[];
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
category: string;
|
|
14
|
+
doc_link: string;
|
|
15
|
+
code_link: string;
|
|
16
|
+
packageName: string;
|
|
17
|
+
stylesPanelSections: string[];
|
|
18
|
+
layout: {
|
|
19
|
+
margin: number;
|
|
20
|
+
};
|
|
21
|
+
triggers: string[];
|
|
22
|
+
name: string;
|
|
23
|
+
tag: string;
|
|
24
|
+
} | {
|
|
25
|
+
props: {
|
|
26
|
+
href?: undefined;
|
|
27
|
+
target?: undefined;
|
|
28
|
+
};
|
|
29
|
+
category: string;
|
|
30
|
+
doc_link: string;
|
|
31
|
+
code_link: string;
|
|
32
|
+
packageName: string;
|
|
33
|
+
stylesPanelSections: string[];
|
|
34
|
+
layout: {
|
|
35
|
+
margin: number;
|
|
36
|
+
};
|
|
37
|
+
triggers: string[];
|
|
38
|
+
name: string;
|
|
39
|
+
tag: string;
|
|
40
|
+
} | {
|
|
41
|
+
category: string;
|
|
42
|
+
props: {
|
|
43
|
+
children: {
|
|
44
|
+
group: string;
|
|
45
|
+
label: string;
|
|
46
|
+
description: string;
|
|
47
|
+
defaultValue: string;
|
|
48
|
+
editable: boolean;
|
|
49
|
+
required: boolean;
|
|
50
|
+
formType: string;
|
|
51
|
+
propType: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
doc_link: string;
|
|
55
|
+
code_link: string;
|
|
56
|
+
packageName: string;
|
|
57
|
+
stylesPanelSections: string[];
|
|
58
|
+
layout: {
|
|
59
|
+
margin: number;
|
|
60
|
+
};
|
|
61
|
+
triggers: string[];
|
|
62
|
+
name: string;
|
|
63
|
+
tag: string;
|
|
64
|
+
} | {
|
|
65
|
+
doc_link: string;
|
|
66
|
+
code_link: string;
|
|
67
|
+
packageName: string;
|
|
68
|
+
stylesPanelSections: string[];
|
|
69
|
+
layout: {
|
|
70
|
+
margin: number;
|
|
71
|
+
};
|
|
72
|
+
triggers: string[];
|
|
73
|
+
category: string;
|
|
74
|
+
name: string;
|
|
75
|
+
tag: string;
|
|
76
|
+
})[];
|
|
77
|
+
//# sourceMappingURL=HtmlElements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HtmlElements.d.ts","sourceRoot":"","sources":["../../../../src/mappings/HtmlElements.ts"],"names":[],"mappings":"AAsFA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwHrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "46.7.9-
|
|
3
|
+
"version": "46.7.9-193328.2+1933281",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -41,7 +41,8 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@date-io/date-fns": "^1.3.13",
|
|
43
43
|
"@draftbit/react-theme-provider": "^2.1.1",
|
|
44
|
-
"@draftbit/types": "^46.7.9-
|
|
44
|
+
"@draftbit/types": "^46.7.9-193328.2+1933281",
|
|
45
|
+
"@expo/html-elements": "^0.3.1",
|
|
45
46
|
"@material-ui/core": "^4.11.0",
|
|
46
47
|
"@material-ui/pickers": "^3.2.10",
|
|
47
48
|
"@react-native-community/slider": "4.2.3",
|
|
@@ -53,6 +54,7 @@
|
|
|
53
54
|
"lodash.isnumber": "^3.0.3",
|
|
54
55
|
"lodash.omit": "^4.5.0",
|
|
55
56
|
"lodash.tonumber": "^4.0.3",
|
|
57
|
+
"react-native-deck-swiper": "^2.0.12",
|
|
56
58
|
"react-native-modal-datetime-picker": "^13.0.0",
|
|
57
59
|
"react-native-svg": "12.3.0",
|
|
58
60
|
"react-native-typography": "^1.4.1",
|
|
@@ -91,5 +93,5 @@
|
|
|
91
93
|
]
|
|
92
94
|
]
|
|
93
95
|
},
|
|
94
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "1933281a981a18f99c4c7eaeccf250cad7e58d23"
|
|
95
97
|
}
|
|
@@ -137,7 +137,7 @@ const DatePicker = ({ Icon, style, theme: { colors, typography, roundness, disab
|
|
|
137
137
|
? labelSize
|
|
138
138
|
: typography.caption.fontSize;
|
|
139
139
|
const hasActiveOutline = focused;
|
|
140
|
-
let inputTextColor, activeColor, underlineColor, borderColor, placeholderColor, containerStyle, backgroundColor, inputStyle;
|
|
140
|
+
let inputTextColor, activeColor, underlineColor, borderColor = inputBorderColor, placeholderColor, containerStyle, backgroundColor, inputStyle;
|
|
141
141
|
inputTextColor = colors.strong;
|
|
142
142
|
if (disabled) {
|
|
143
143
|
activeColor = colors.light;
|
|
@@ -241,7 +241,7 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
|
|
|
241
241
|
let inputTextColor,
|
|
242
242
|
activeColor,
|
|
243
243
|
underlineColor,
|
|
244
|
-
borderColor,
|
|
244
|
+
borderColor = inputBorderColor,
|
|
245
245
|
placeholderColor,
|
|
246
246
|
containerStyle: StyleProp<ViewStyle>,
|
|
247
247
|
backgroundColor,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleSheet, View } from "react-native";
|
|
3
|
+
import DeckSwiperComponent from "react-native-deck-swiper";
|
|
4
|
+
const DeckSwiper = ({ onIndexChanged, onEndReached, startCardIndex = 0, infiniteSwiping = false, verticalEnabled = true, horizontalEnabled = true, visibleCardCount = 1, style, children, }) => {
|
|
5
|
+
const childrenArray = React.useMemo(() => React.Children.toArray(children), [children]);
|
|
6
|
+
// an array of indices based on children count
|
|
7
|
+
const cardsFillerData = React.useMemo(() => Array.from(Array(childrenArray.length).keys()), [childrenArray]);
|
|
8
|
+
/**
|
|
9
|
+
* By default react-native-deck-swiper positions everything with absolute position.
|
|
10
|
+
* To overcome this, it is wrapped in a View to be able to add the component in any layout structure.
|
|
11
|
+
*
|
|
12
|
+
*
|
|
13
|
+
* Since all children of that View are absolutley positioned, the View does not have a height and still looks and behaves weird.
|
|
14
|
+
* To fix/mitage this without setting a static height, the first card is rendered in invisible state to take up space.
|
|
15
|
+
* This effectivley makes the default height of the container be the height of the first card.
|
|
16
|
+
*/
|
|
17
|
+
return (React.createElement(View, null,
|
|
18
|
+
React.createElement(View, { style: styles.containerHeightFiller }, childrenArray.length && childrenArray[0]),
|
|
19
|
+
React.createElement(DeckSwiperComponent, { cards: cardsFillerData, renderCard: (_, i) => React.createElement(React.Fragment, null, childrenArray[i]), keyExtractor: (card) => card === null || card === void 0 ? void 0 : card.toString(), containerStyle: StyleSheet.flatten([styles.cardsContainer, style]), cardStyle: styles.card, onSwiped: onIndexChanged, onSwipedAll: onEndReached, cardIndex: startCardIndex, infinite: infiniteSwiping, verticalSwipe: verticalEnabled, horizontalSwipe: horizontalEnabled, showSecondCard: visibleCardCount > 1, stackSize: visibleCardCount, backgroundColor: "transparent", cardVerticalMargin: 0, cardHorizontalMargin: 0 })));
|
|
20
|
+
};
|
|
21
|
+
const styles = StyleSheet.create({
|
|
22
|
+
cardsContainer: {
|
|
23
|
+
width: "100%",
|
|
24
|
+
},
|
|
25
|
+
card: {
|
|
26
|
+
left: 0,
|
|
27
|
+
right: 0,
|
|
28
|
+
width: "auto",
|
|
29
|
+
height: "auto",
|
|
30
|
+
},
|
|
31
|
+
containerHeightFiller: {
|
|
32
|
+
opacity: 0.0,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
export default DeckSwiper;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleProp, ViewStyle, StyleSheet, View } from "react-native";
|
|
3
|
+
import DeckSwiperComponent from "react-native-deck-swiper";
|
|
4
|
+
|
|
5
|
+
export interface DeckSwiperProps {
|
|
6
|
+
onIndexChanged?: (index: number) => void;
|
|
7
|
+
onEndReached?: () => void;
|
|
8
|
+
startCardIndex?: number;
|
|
9
|
+
infiniteSwiping?: boolean;
|
|
10
|
+
verticalEnabled?: boolean;
|
|
11
|
+
horizontalEnabled?: boolean;
|
|
12
|
+
visibleCardCount?: number;
|
|
13
|
+
style?: StyleProp<ViewStyle>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const DeckSwiper: React.FC<React.PropsWithChildren<DeckSwiperProps>> = ({
|
|
17
|
+
onIndexChanged,
|
|
18
|
+
onEndReached,
|
|
19
|
+
startCardIndex = 0,
|
|
20
|
+
infiniteSwiping = false,
|
|
21
|
+
verticalEnabled = true,
|
|
22
|
+
horizontalEnabled = true,
|
|
23
|
+
visibleCardCount = 1,
|
|
24
|
+
style,
|
|
25
|
+
children,
|
|
26
|
+
}) => {
|
|
27
|
+
const childrenArray = React.useMemo(
|
|
28
|
+
() => React.Children.toArray(children),
|
|
29
|
+
[children]
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// an array of indices based on children count
|
|
33
|
+
const cardsFillerData = React.useMemo(
|
|
34
|
+
() => Array.from(Array(childrenArray.length).keys()),
|
|
35
|
+
[childrenArray]
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* By default react-native-deck-swiper positions everything with absolute position.
|
|
40
|
+
* To overcome this, it is wrapped in a View to be able to add the component in any layout structure.
|
|
41
|
+
*
|
|
42
|
+
*
|
|
43
|
+
* Since all children of that View are absolutley positioned, the View does not have a height and still looks and behaves weird.
|
|
44
|
+
* To fix/mitage this without setting a static height, the first card is rendered in invisible state to take up space.
|
|
45
|
+
* This effectivley makes the default height of the container be the height of the first card.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<View>
|
|
50
|
+
<View style={styles.containerHeightFiller}>
|
|
51
|
+
{childrenArray.length && childrenArray[0]}
|
|
52
|
+
</View>
|
|
53
|
+
<DeckSwiperComponent
|
|
54
|
+
cards={cardsFillerData}
|
|
55
|
+
renderCard={(_, i) => <>{childrenArray[i]}</>}
|
|
56
|
+
keyExtractor={(card) => card?.toString()}
|
|
57
|
+
containerStyle={
|
|
58
|
+
StyleSheet.flatten([styles.cardsContainer, style]) as
|
|
59
|
+
| object
|
|
60
|
+
| undefined
|
|
61
|
+
}
|
|
62
|
+
cardStyle={styles.card as object | undefined}
|
|
63
|
+
onSwiped={onIndexChanged}
|
|
64
|
+
onSwipedAll={onEndReached}
|
|
65
|
+
cardIndex={startCardIndex}
|
|
66
|
+
infinite={infiniteSwiping}
|
|
67
|
+
verticalSwipe={verticalEnabled}
|
|
68
|
+
horizontalSwipe={horizontalEnabled}
|
|
69
|
+
showSecondCard={visibleCardCount > 1}
|
|
70
|
+
stackSize={visibleCardCount}
|
|
71
|
+
backgroundColor="transparent"
|
|
72
|
+
cardVerticalMargin={0}
|
|
73
|
+
cardHorizontalMargin={0}
|
|
74
|
+
/>
|
|
75
|
+
</View>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const styles = StyleSheet.create({
|
|
80
|
+
cardsContainer: {
|
|
81
|
+
width: "100%",
|
|
82
|
+
},
|
|
83
|
+
card: {
|
|
84
|
+
left: 0,
|
|
85
|
+
right: 0,
|
|
86
|
+
width: "auto",
|
|
87
|
+
height: "auto",
|
|
88
|
+
},
|
|
89
|
+
containerHeightFiller: {
|
|
90
|
+
opacity: 0.0,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
export default DeckSwiper;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import { withTheme } from "../../theming";
|
|
4
|
+
const DeckSwiperCard = ({ style, children, theme, }) => (React.createElement(View, { style: [
|
|
5
|
+
styles.card,
|
|
6
|
+
{
|
|
7
|
+
backgroundColor: theme.colors.background,
|
|
8
|
+
borderColor: theme.colors.divider,
|
|
9
|
+
},
|
|
10
|
+
style,
|
|
11
|
+
] }, children));
|
|
12
|
+
const styles = StyleSheet.create({
|
|
13
|
+
card: {
|
|
14
|
+
flex: 1,
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
justifyContent: "center",
|
|
17
|
+
padding: 20,
|
|
18
|
+
borderWidth: 2,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
export default withTheme(DeckSwiperCard);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleSheet, StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
import type { Theme } from "../../styles/DefaultTheme";
|
|
4
|
+
import { withTheme } from "../../theming";
|
|
5
|
+
|
|
6
|
+
export interface DeckSwiperCardProps {
|
|
7
|
+
style?: StyleProp<ViewStyle>;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
theme: Theme;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const DeckSwiperCard: React.FC<DeckSwiperCardProps> = ({
|
|
13
|
+
style,
|
|
14
|
+
children,
|
|
15
|
+
theme,
|
|
16
|
+
}) => (
|
|
17
|
+
<View
|
|
18
|
+
style={[
|
|
19
|
+
styles.card,
|
|
20
|
+
{
|
|
21
|
+
backgroundColor: theme.colors.background,
|
|
22
|
+
borderColor: theme.colors.divider,
|
|
23
|
+
},
|
|
24
|
+
style,
|
|
25
|
+
]}
|
|
26
|
+
>
|
|
27
|
+
{children}
|
|
28
|
+
</View>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const styles = StyleSheet.create({
|
|
32
|
+
card: {
|
|
33
|
+
flex: 1,
|
|
34
|
+
alignItems: "center",
|
|
35
|
+
justifyContent: "center",
|
|
36
|
+
padding: 20,
|
|
37
|
+
borderWidth: 2,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export default withTheme(DeckSwiperCard);
|
|
@@ -20,16 +20,8 @@ const NumberInput = ({ onChangeText, value, defaultValue, ...props }) => {
|
|
|
20
20
|
return valueToFormat.toString();
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
return "
|
|
23
|
+
return "";
|
|
24
24
|
};
|
|
25
|
-
// set currentStringNumberValue as defaultValue prop if there is a differnce on first render only
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
const defaultStringNumberValue = formatValueToStringNumber(defaultValue);
|
|
28
|
-
if (currentStringNumberValue !== defaultStringNumberValue) {
|
|
29
|
-
setCurrentStringNumberValue(defaultStringNumberValue);
|
|
30
|
-
}
|
|
31
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
-
}, []);
|
|
33
25
|
const handleChangeText = (newValue) => {
|
|
34
26
|
const newStringNumberValue = formatValueToStringNumber(newValue);
|
|
35
27
|
const number = parseFloat(newStringNumberValue);
|
|
@@ -44,6 +36,14 @@ const NumberInput = ({ onChangeText, value, defaultValue, ...props }) => {
|
|
|
44
36
|
}
|
|
45
37
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
38
|
}, [value]);
|
|
39
|
+
// set currentStringNumberValue as defaultValue prop if there is a differnce on first render only
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const defaultStringNumberValue = formatValueToStringNumber(defaultValue);
|
|
42
|
+
if (currentStringNumberValue !== defaultStringNumberValue) {
|
|
43
|
+
setCurrentStringNumberValue(defaultStringNumberValue);
|
|
44
|
+
}
|
|
45
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
+
}, []);
|
|
47
47
|
return (React.createElement(TextInput, { keyboardType: "numeric", value: currentStringNumberValue, onChangeText: handleChangeText, ...props }));
|
|
48
48
|
};
|
|
49
49
|
export default NumberInput;
|
|
@@ -31,19 +31,9 @@ const NumberInput: FC<Props> = ({
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
return "
|
|
34
|
+
return "";
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
// set currentStringNumberValue as defaultValue prop if there is a differnce on first render only
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
const defaultStringNumberValue = formatValueToStringNumber(defaultValue);
|
|
40
|
-
|
|
41
|
-
if (currentStringNumberValue !== defaultStringNumberValue) {
|
|
42
|
-
setCurrentStringNumberValue(defaultStringNumberValue);
|
|
43
|
-
}
|
|
44
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
|
-
}, []);
|
|
46
|
-
|
|
47
37
|
const handleChangeText = (newValue: string) => {
|
|
48
38
|
const newStringNumberValue = formatValueToStringNumber(newValue);
|
|
49
39
|
const number = parseFloat(newStringNumberValue);
|
|
@@ -62,6 +52,16 @@ const NumberInput: FC<Props> = ({
|
|
|
62
52
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
53
|
}, [value]);
|
|
64
54
|
|
|
55
|
+
// set currentStringNumberValue as defaultValue prop if there is a differnce on first render only
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const defaultStringNumberValue = formatValueToStringNumber(defaultValue);
|
|
58
|
+
|
|
59
|
+
if (currentStringNumberValue !== defaultStringNumberValue) {
|
|
60
|
+
setCurrentStringNumberValue(defaultStringNumberValue);
|
|
61
|
+
}
|
|
62
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
65
|
return (
|
|
66
66
|
<TextInput
|
|
67
67
|
keyboardType="numeric"
|
|
@@ -32,6 +32,7 @@ function normalizeOptions(options) {
|
|
|
32
32
|
}
|
|
33
33
|
const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
|
|
34
34
|
const isIos = Platform.OS === "ios";
|
|
35
|
+
const isWeb = Platform.OS === "web";
|
|
35
36
|
const unstyledColor = "rgba(165, 173, 183, 1)";
|
|
36
37
|
const disabledColor = "rgb(240, 240, 240)";
|
|
37
38
|
const errorColor = "rgba(255, 69, 100, 1)";
|
|
@@ -191,7 +192,7 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
191
192
|
React.createElement(View, { style: styles.iosPickerContent },
|
|
192
193
|
React.createElement(Button, { Icon: Icon, type: "text", onPress: togglePickerVisible, style: styles.iosButton }, "Close"),
|
|
193
194
|
React.createElement(NativePicker, { style: styles.iosNativePicker, selectedValue: internalValue, onValueChange: handleValueChange }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value })))))))) : null,
|
|
194
|
-
!isIos && pickerVisible ? (React.createElement(NativePicker, { enabled:
|
|
195
|
+
!isIos && (pickerVisible || isWeb) ? (React.createElement(NativePicker, { enabled: !disabled, selectedValue: internalValue, onValueChange: handleValueChange, style: styles.nonIosPicker, ref: androidPickerRef, onBlur: () => setPickerVisible(false) }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value }))))) : null));
|
|
195
196
|
};
|
|
196
197
|
const styles = StyleSheet.create({
|
|
197
198
|
marginsContainer: {
|
|
@@ -86,6 +86,8 @@ function normalizeOptions(options: PickerProps["options"]): PickerOption[] {
|
|
|
86
86
|
|
|
87
87
|
const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
|
|
88
88
|
const isIos = Platform.OS === "ios";
|
|
89
|
+
const isWeb = Platform.OS === "web";
|
|
90
|
+
|
|
89
91
|
const unstyledColor = "rgba(165, 173, 183, 1)";
|
|
90
92
|
const disabledColor = "rgb(240, 240, 240)";
|
|
91
93
|
const errorColor = "rgba(255, 69, 100, 1)";
|
|
@@ -383,9 +385,10 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
383
385
|
) : null}
|
|
384
386
|
|
|
385
387
|
{/* nonIosPicker */}
|
|
386
|
-
{
|
|
388
|
+
{/* Web version is collapsed by default, always show to allow direct expand */}
|
|
389
|
+
{!isIos && (pickerVisible || isWeb) ? (
|
|
387
390
|
<NativePicker
|
|
388
|
-
enabled={
|
|
391
|
+
enabled={!disabled}
|
|
389
392
|
selectedValue={internalValue}
|
|
390
393
|
onValueChange={handleValueChange}
|
|
391
394
|
style={styles.nonIosPicker}
|
package/src/index.js
CHANGED
|
@@ -31,6 +31,7 @@ export { ActionSheet, ActionSheetItem, ActionSheetCancel, } from "./components/A
|
|
|
31
31
|
export { Swiper, SwiperItem } from "./components/Swiper";
|
|
32
32
|
export { Center, Circle, Square, Row, Stack, Spacer, } from "./components/Layout";
|
|
33
33
|
export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup, } from "./components/RadioButton/index";
|
|
34
|
+
export { DeckSwiper, DeckSwiperCard } from "./components/DeckSwiper";
|
|
34
35
|
/* Deprecated: Fix or Delete! */
|
|
35
36
|
export { default as DatePicker } from "./components/DatePicker/DatePicker";
|
|
36
37
|
export { default as Picker } from "./components/Picker/Picker";
|
package/src/index.tsx
CHANGED
|
@@ -51,6 +51,8 @@ export {
|
|
|
51
51
|
RadioButtonFieldGroup,
|
|
52
52
|
} from "./components/RadioButton/index";
|
|
53
53
|
|
|
54
|
+
export { DeckSwiper, DeckSwiperCard } from "./components/DeckSwiper";
|
|
55
|
+
|
|
54
56
|
/* Deprecated: Fix or Delete! */
|
|
55
57
|
export { default as DatePicker } from "./components/DatePicker/DatePicker";
|
|
56
58
|
export { default as Picker } from "./components/Picker/Picker";
|
|
@@ -31,7 +31,8 @@ const SEED_DATA_PROPS = {
|
|
|
31
31
|
label: "Border Color",
|
|
32
32
|
}),
|
|
33
33
|
borderColorActive: createColorProp({
|
|
34
|
-
label: "Border Color",
|
|
34
|
+
label: "Active Border Color",
|
|
35
|
+
description: "Color of border when date picker is active",
|
|
35
36
|
}),
|
|
36
37
|
format: {
|
|
37
38
|
label: "Format",
|
|
@@ -43,7 +43,8 @@ const SEED_DATA_PROPS = {
|
|
|
43
43
|
label: "Border Color",
|
|
44
44
|
}),
|
|
45
45
|
borderColorActive: createColorProp({
|
|
46
|
-
label: "Border Color",
|
|
46
|
+
label: "Active Border Color",
|
|
47
|
+
description: "Color of border when date picker is active",
|
|
47
48
|
}),
|
|
48
49
|
format: {
|
|
49
50
|
label: "Format",
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { COMPONENT_TYPES, Triggers, createActionProp, createStaticNumberProp, createStaticBoolProp, BLOCK_STYLES_SECTIONS, } from "@draftbit/types";
|
|
2
|
+
export const SEED_DATA = {
|
|
3
|
+
name: "Deck Swiper",
|
|
4
|
+
tag: "DeckSwiper",
|
|
5
|
+
description: "Deck swiper container",
|
|
6
|
+
category: COMPONENT_TYPES.swiper,
|
|
7
|
+
stylesPanelSections: BLOCK_STYLES_SECTIONS,
|
|
8
|
+
layout: {
|
|
9
|
+
width: "100%",
|
|
10
|
+
},
|
|
11
|
+
triggers: [Triggers.OnIndexChanged, Triggers.OnEndReached],
|
|
12
|
+
props: {
|
|
13
|
+
onIndexChanged: createActionProp({
|
|
14
|
+
label: "On index changed",
|
|
15
|
+
description: "Action to execute when swipe to new index",
|
|
16
|
+
}),
|
|
17
|
+
onEndReached: createActionProp({
|
|
18
|
+
label: "On end reached",
|
|
19
|
+
description: "Action to execute when end of swiping reached",
|
|
20
|
+
}),
|
|
21
|
+
startCardIndex: createStaticNumberProp({
|
|
22
|
+
label: "Start card index",
|
|
23
|
+
description: "Index of card to start swiping from",
|
|
24
|
+
defaultValue: 0,
|
|
25
|
+
}),
|
|
26
|
+
infiniteSwiping: createStaticBoolProp({
|
|
27
|
+
label: "Infinite swiping",
|
|
28
|
+
description: "Whether to infinitley loop through cards or not",
|
|
29
|
+
}),
|
|
30
|
+
verticalEnabled: createStaticBoolProp({
|
|
31
|
+
label: "Vertical swipe enabled",
|
|
32
|
+
description: "Whether cards should be swipeable vertically or not",
|
|
33
|
+
defaultValue: true,
|
|
34
|
+
}),
|
|
35
|
+
horizontalEnabled: createStaticBoolProp({
|
|
36
|
+
label: "Horizontal swipe enabled",
|
|
37
|
+
description: "Whether cards should be swipeable horizontally or not",
|
|
38
|
+
defaultValue: true,
|
|
39
|
+
}),
|
|
40
|
+
visibleCardCount: createStaticNumberProp({
|
|
41
|
+
label: "Visible card count",
|
|
42
|
+
description: "Number of cards visible behind (and including) the current card",
|
|
43
|
+
defaultValue: 1,
|
|
44
|
+
min: 1,
|
|
45
|
+
step: 1,
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COMPONENT_TYPES,
|
|
3
|
+
Triggers,
|
|
4
|
+
createActionProp,
|
|
5
|
+
createStaticNumberProp,
|
|
6
|
+
createStaticBoolProp,
|
|
7
|
+
BLOCK_STYLES_SECTIONS,
|
|
8
|
+
} from "@draftbit/types";
|
|
9
|
+
|
|
10
|
+
export const SEED_DATA = {
|
|
11
|
+
name: "Deck Swiper",
|
|
12
|
+
tag: "DeckSwiper",
|
|
13
|
+
description: "Deck swiper container",
|
|
14
|
+
category: COMPONENT_TYPES.swiper,
|
|
15
|
+
stylesPanelSections: BLOCK_STYLES_SECTIONS,
|
|
16
|
+
layout: {
|
|
17
|
+
width: "100%",
|
|
18
|
+
},
|
|
19
|
+
triggers: [Triggers.OnIndexChanged, Triggers.OnEndReached],
|
|
20
|
+
props: {
|
|
21
|
+
onIndexChanged: createActionProp({
|
|
22
|
+
label: "On index changed",
|
|
23
|
+
description: "Action to execute when swipe to new index",
|
|
24
|
+
}),
|
|
25
|
+
onEndReached: createActionProp({
|
|
26
|
+
label: "On end reached",
|
|
27
|
+
description: "Action to execute when end of swiping reached",
|
|
28
|
+
}),
|
|
29
|
+
startCardIndex: createStaticNumberProp({
|
|
30
|
+
label: "Start card index",
|
|
31
|
+
description: "Index of card to start swiping from",
|
|
32
|
+
defaultValue: 0,
|
|
33
|
+
}),
|
|
34
|
+
infiniteSwiping: createStaticBoolProp({
|
|
35
|
+
label: "Infinite swiping",
|
|
36
|
+
description: "Whether to infinitley loop through cards or not",
|
|
37
|
+
}),
|
|
38
|
+
verticalEnabled: createStaticBoolProp({
|
|
39
|
+
label: "Vertical swipe enabled",
|
|
40
|
+
description: "Whether cards should be swipeable vertically or not",
|
|
41
|
+
defaultValue: true,
|
|
42
|
+
}),
|
|
43
|
+
horizontalEnabled: createStaticBoolProp({
|
|
44
|
+
label: "Horizontal swipe enabled",
|
|
45
|
+
description: "Whether cards should be swipeable horizontally or not",
|
|
46
|
+
defaultValue: true,
|
|
47
|
+
}),
|
|
48
|
+
visibleCardCount: createStaticNumberProp({
|
|
49
|
+
label: "Visible card count",
|
|
50
|
+
description:
|
|
51
|
+
"Number of cards visible behind (and including) the current card",
|
|
52
|
+
defaultValue: 1,
|
|
53
|
+
min: 1,
|
|
54
|
+
step: 1,
|
|
55
|
+
}),
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { COMPONENT_TYPES, CONTAINER_COMPONENT_STYLES_SECTIONS, } from "@draftbit/types";
|
|
2
|
+
export const SEED_DATA = {
|
|
3
|
+
name: "Deck Swiper Card",
|
|
4
|
+
tag: "DeckSwiperCard",
|
|
5
|
+
description: "Single Deck Swiper Card item to be used in DeckSwiper",
|
|
6
|
+
category: COMPONENT_TYPES.swiper,
|
|
7
|
+
stylesPanelSections: CONTAINER_COMPONENT_STYLES_SECTIONS,
|
|
8
|
+
layout: {
|
|
9
|
+
flex: 1,
|
|
10
|
+
alignItems: "center",
|
|
11
|
+
justifyContent: "center",
|
|
12
|
+
padding: 20,
|
|
13
|
+
borderWidth: 2,
|
|
14
|
+
},
|
|
15
|
+
props: {},
|
|
16
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COMPONENT_TYPES,
|
|
3
|
+
CONTAINER_COMPONENT_STYLES_SECTIONS,
|
|
4
|
+
} from "@draftbit/types";
|
|
5
|
+
|
|
6
|
+
export const SEED_DATA = {
|
|
7
|
+
name: "Deck Swiper Card",
|
|
8
|
+
tag: "DeckSwiperCard",
|
|
9
|
+
description: "Single Deck Swiper Card item to be used in DeckSwiper",
|
|
10
|
+
category: COMPONENT_TYPES.swiper,
|
|
11
|
+
stylesPanelSections: CONTAINER_COMPONENT_STYLES_SECTIONS,
|
|
12
|
+
layout: {
|
|
13
|
+
flex: 1,
|
|
14
|
+
alignItems: "center",
|
|
15
|
+
justifyContent: "center",
|
|
16
|
+
padding: 20,
|
|
17
|
+
borderWidth: 2,
|
|
18
|
+
},
|
|
19
|
+
props: {},
|
|
20
|
+
};
|