@draftbit/core 43.4.16-cbc807.1 → 43.4.17-ab8b1a.0
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/ActionSheet/ActionSheetCancel.js.map +1 -1
- package/lib/commonjs/components/CardContainerRating.js +5 -16
- package/lib/commonjs/components/CardContainerRating.js.map +1 -1
- package/lib/commonjs/components/Config.js.map +1 -1
- package/lib/commonjs/components/DatePicker/DatePickerComponent.js.map +1 -1
- package/lib/commonjs/components/Header.js.map +1 -1
- package/lib/commonjs/components/Picker/PickerComponent.ios.js +10 -30
- package/lib/commonjs/components/Picker/PickerComponent.ios.js.map +1 -1
- package/lib/commonjs/components/Portal/PortalConsumer.js.map +1 -1
- package/lib/commonjs/components/Portal/PortalManager.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButton.js +3 -15
- package/lib/commonjs/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonFieldGroup.js +2 -11
- package/lib/commonjs/components/RadioButton/RadioButtonFieldGroup.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonGroup.js +5 -17
- package/lib/commonjs/components/RadioButton/RadioButtonGroup.js.map +1 -1
- package/lib/commonjs/components/ScreenContainer.js +1 -1
- package/lib/commonjs/components/ScreenContainer.js.map +1 -1
- package/lib/commonjs/components/Stepper.js +40 -58
- package/lib/commonjs/components/Stepper.js.map +1 -1
- package/lib/commonjs/components/Surface.js +5 -15
- package/lib/commonjs/components/Surface.js.map +1 -1
- package/lib/commonjs/components/Swiper/SwiperItem.js.map +1 -1
- package/lib/commonjs/mappings/Accordion.js.map +1 -1
- package/lib/commonjs/mappings/BlurView.js.map +1 -1
- package/lib/commonjs/mappings/Container.js.map +1 -1
- package/lib/commonjs/mappings/FAB.js.map +1 -1
- package/lib/commonjs/mappings/Slider.js.map +1 -1
- package/lib/commonjs/mappings/TextArea.js.map +1 -1
- package/lib/module/components/IconButton.js +5 -21
- package/lib/module/components/IconButton.js.map +1 -1
- package/lib/module/components/Portal/PortalHost.js.map +1 -1
- package/lib/module/components/RowHeadlineImageIcon.js.map +1 -1
- package/lib/module/components/ScreenContainer.js +1 -1
- package/lib/module/components/ScreenContainer.js.map +1 -1
- package/lib/module/components/Stepper.js +36 -54
- package/lib/module/components/Stepper.js.map +1 -1
- package/lib/module/components/Surface.js +6 -16
- package/lib/module/components/Surface.js.map +1 -1
- package/lib/typescript/src/components/ScreenContainer.d.ts +6 -6
- package/lib/typescript/src/components/Stepper.d.ts +8 -9
- package/package.json +2 -2
- package/src/components/ScreenContainer.js +1 -1
- package/src/components/ScreenContainer.tsx +5 -5
- package/src/components/Stepper.js +23 -37
- package/src/components/Stepper.tsx +48 -64
- package/src/components/Surface.js +4 -15
- package/src/components/Surface.tsx +4 -23
|
@@ -1,77 +1,59 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
2
|
import { View, Text } from "react-native";
|
|
3
|
+
import { isNumber } from "lodash";
|
|
3
4
|
import { withTheme } from "../theming";
|
|
4
5
|
import IconButton from "./IconButton";
|
|
5
|
-
import isNumber from "lodash.isnumber";
|
|
6
6
|
|
|
7
7
|
const Stepper = _ref => {
|
|
8
8
|
let {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
min = -Infinity,
|
|
10
|
+
max = Infinity,
|
|
11
|
+
value: valueProp,
|
|
12
|
+
defaultValue,
|
|
13
13
|
style,
|
|
14
|
+
typeStyle,
|
|
15
|
+
iconSize = 24,
|
|
16
|
+
iconColor,
|
|
14
17
|
onChange,
|
|
15
|
-
defaultValue,
|
|
16
18
|
theme: {
|
|
17
19
|
colors,
|
|
18
|
-
typography
|
|
19
|
-
roundness
|
|
20
|
+
typography
|
|
20
21
|
},
|
|
21
|
-
|
|
22
|
-
iconColor = colors.strong,
|
|
23
|
-
borderRadius = roundness,
|
|
24
|
-
typeStyle
|
|
22
|
+
Icon
|
|
25
23
|
} = _ref;
|
|
26
|
-
const [
|
|
27
|
-
React.useEffect(() => {
|
|
28
|
-
if (value || value === 0) {
|
|
29
|
-
onChange && onChange(stateValue);
|
|
30
|
-
}
|
|
31
|
-
}, [onChange, stateValue, value]);
|
|
32
|
-
React.useEffect(() => {
|
|
33
|
-
let newValue = value || defaultValue || 0;
|
|
24
|
+
const [value, setValue] = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : 0);
|
|
34
25
|
|
|
35
|
-
|
|
36
|
-
newValue = max;
|
|
37
|
-
}
|
|
26
|
+
const isValidValue = valueArg => valueArg >= min && valueArg <= max;
|
|
38
27
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
28
|
+
const handlePlusOrMinus = type => {
|
|
29
|
+
const newValue = type === "plus" ? value + 1 : value - 1;
|
|
42
30
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (isNumber(min) && value === min) {
|
|
47
|
-
return;
|
|
31
|
+
if (isValidValue(newValue)) {
|
|
32
|
+
setValue(newValue);
|
|
33
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
48
34
|
}
|
|
35
|
+
};
|
|
49
36
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (valueProp != null && isNumber(valueProp) && valueProp !== value && isValidValue(valueProp)) {
|
|
39
|
+
setValue(valueProp);
|
|
40
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
41
|
|
|
57
|
-
|
|
58
|
-
}, [max, stateValue, value]);
|
|
42
|
+
}, [valueProp]);
|
|
59
43
|
return /*#__PURE__*/React.createElement(View, {
|
|
60
44
|
style: [{
|
|
61
45
|
flexDirection: "row"
|
|
62
|
-
}, style
|
|
63
|
-
borderRadius
|
|
64
|
-
} : {}]
|
|
46
|
+
}, style]
|
|
65
47
|
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
66
48
|
Icon: Icon,
|
|
67
49
|
icon: "MaterialIcons/remove",
|
|
68
|
-
onPress:
|
|
50
|
+
onPress: () => handlePlusOrMinus("minus"),
|
|
69
51
|
size: iconSize,
|
|
70
52
|
color: iconColor,
|
|
71
|
-
disabled:
|
|
72
|
-
style:
|
|
73
|
-
opacity: 0.5
|
|
74
|
-
}
|
|
53
|
+
disabled: value === min,
|
|
54
|
+
style: {
|
|
55
|
+
opacity: value === min ? 0.5 : 1
|
|
56
|
+
}
|
|
75
57
|
}), /*#__PURE__*/React.createElement(Text, {
|
|
76
58
|
style: [typography.body1, {
|
|
77
59
|
textAlign: "center",
|
|
@@ -79,16 +61,16 @@ const Stepper = _ref => {
|
|
|
79
61
|
color: colors.medium,
|
|
80
62
|
marginHorizontal: 8
|
|
81
63
|
}, typeStyle]
|
|
82
|
-
}, value
|
|
64
|
+
}, value), /*#__PURE__*/React.createElement(IconButton, {
|
|
83
65
|
Icon: Icon,
|
|
84
66
|
icon: "MaterialIcons/add",
|
|
85
|
-
onPress:
|
|
67
|
+
onPress: () => handlePlusOrMinus("plus"),
|
|
86
68
|
size: iconSize,
|
|
87
69
|
color: iconColor,
|
|
88
|
-
disabled:
|
|
89
|
-
style:
|
|
90
|
-
opacity: 0.5
|
|
91
|
-
}
|
|
70
|
+
disabled: value === max,
|
|
71
|
+
style: {
|
|
72
|
+
opacity: value === max ? 0.5 : 1
|
|
73
|
+
}
|
|
92
74
|
}));
|
|
93
75
|
};
|
|
94
76
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Stepper.tsx"],"names":["React","
|
|
1
|
+
{"version":3,"sources":["Stepper.tsx"],"names":["React","useEffect","useState","View","Text","isNumber","withTheme","IconButton","Stepper","min","Infinity","max","value","valueProp","defaultValue","style","typeStyle","iconSize","iconColor","onChange","theme","colors","typography","Icon","setValue","isValidValue","valueArg","handlePlusOrMinus","type","newValue","flexDirection","opacity","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E;AAAEoB,MAAAA,OAAO,EAAEnB,KAAK,KAAKD,GAAV,GAAgB,GAAhB,GAAsB;AAAjC;AAPT,IA1BF,CADF;AAsCD,CA5ED;;AA8EA,eAAeL,SAAS,CAACE,OAAD,CAAxB","sourcesContent":["import React, { FC, useEffect, useState } from \"react\";\nimport { View, Text, StyleProp, ViewStyle, TextStyle } from \"react-native\";\nimport { isNumber } from \"lodash\";\n\nimport { withTheme } from \"../theming\";\nimport type { Theme } from \"../styles/DefaultTheme\";\nimport type { IconSlot } from \"../interfaces/Icon\";\nimport IconButton from \"./IconButton\";\n\ntype Props = {\n min: number;\n max: number;\n value?: number;\n defaultValue?: number;\n style?: StyleProp<ViewStyle>;\n typeStyle?: StyleProp<TextStyle>;\n iconSize: number;\n iconColor?: string;\n onChange?: (value: number) => void;\n theme: Theme;\n} & IconSlot;\n\nconst Stepper: FC<Props> = ({\n min = -Infinity,\n max = Infinity,\n value: valueProp,\n defaultValue,\n style,\n typeStyle,\n iconSize = 24,\n iconColor,\n onChange,\n theme: { colors, typography },\n Icon,\n}) => {\n const [value, setValue] = useState(defaultValue ?? 0);\n\n const isValidValue = (valueArg: number) => valueArg >= min && valueArg <= max;\n\n const handlePlusOrMinus = (type: \"plus\" | \"minus\") => {\n const newValue = type === \"plus\" ? value + 1 : value - 1;\n\n if (isValidValue(newValue)) {\n setValue(newValue);\n onChange?.(newValue);\n }\n };\n\n useEffect(() => {\n if (\n valueProp != null &&\n isNumber(valueProp) &&\n valueProp !== value &&\n isValidValue(valueProp)\n ) {\n setValue(valueProp);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [valueProp]);\n\n return (\n <View style={[{ flexDirection: \"row\" }, style]}>\n <IconButton\n Icon={Icon}\n icon=\"MaterialIcons/remove\"\n onPress={() => handlePlusOrMinus(\"minus\")}\n size={iconSize}\n color={iconColor}\n disabled={value === min}\n style={{ opacity: value === min ? 0.5 : 1 }}\n />\n\n <Text\n style={[\n typography.body1,\n {\n textAlign: \"center\",\n alignSelf: \"center\",\n color: colors.medium,\n marginHorizontal: 8,\n },\n typeStyle,\n ]}\n >\n {value}\n </Text>\n\n <IconButton\n Icon={Icon}\n icon=\"MaterialIcons/add\"\n onPress={() => handlePlusOrMinus(\"plus\")}\n size={iconSize}\n color={iconColor}\n disabled={value === max}\n style={{ opacity: value === max ? 0.5 : 1 }}\n />\n </View>\n );\n};\n\nexport default withTheme(Stepper);\n"]}
|
|
@@ -2,7 +2,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
2
2
|
|
|
3
3
|
/* Copied from https://github.com/callstack/react-native-paper/blob/main/src/components/Surface.tsx */
|
|
4
4
|
import * as React from "react";
|
|
5
|
-
import { Animated, StyleSheet
|
|
5
|
+
import { Animated, StyleSheet } from "react-native";
|
|
6
6
|
import shadow from "../styles/shadow";
|
|
7
7
|
import overlay from "../styles/overlay";
|
|
8
8
|
import { withTheme } from "../theming";
|
|
@@ -18,10 +18,7 @@ const Surface = _ref => {
|
|
|
18
18
|
const {
|
|
19
19
|
elevation: styleElevation = 3,
|
|
20
20
|
backgroundColor,
|
|
21
|
-
|
|
22
|
-
overflow,
|
|
23
|
-
height,
|
|
24
|
-
width
|
|
21
|
+
...restStyle
|
|
25
22
|
} = StyleSheet.flatten(style) || {};
|
|
26
23
|
const {
|
|
27
24
|
dark: isDarkTheme,
|
|
@@ -42,20 +39,13 @@ const Surface = _ref => {
|
|
|
42
39
|
};
|
|
43
40
|
|
|
44
41
|
return /*#__PURE__*/React.createElement(Animated.View, _extends({}, rest, {
|
|
45
|
-
style: [
|
|
42
|
+
style: [{
|
|
46
43
|
backgroundColor: getBackgroundColor(),
|
|
47
|
-
overflow: Platform.OS === "web" && overflow === "hidden" ? "hidden" : "visible",
|
|
48
44
|
elevation,
|
|
49
|
-
...evalationStyles
|
|
50
|
-
|
|
51
|
-
}), /*#__PURE__*/React.createElement(View, {
|
|
52
|
-
style: [{
|
|
53
|
-
overflow,
|
|
54
|
-
borderRadius,
|
|
55
|
-
height,
|
|
56
|
-
width
|
|
45
|
+
...evalationStyles,
|
|
46
|
+
...restStyle
|
|
57
47
|
}]
|
|
58
|
-
}, children)
|
|
48
|
+
}), children);
|
|
59
49
|
};
|
|
60
50
|
|
|
61
51
|
export default withTheme(Surface);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Surface.tsx"],"names":["React","Animated","StyleSheet","
|
|
1
|
+
{"version":3,"sources":["Surface.tsx"],"names":["React","Animated","StyleSheet","shadow","overlay","withTheme","Surface","elevation","propElevation","style","theme","children","rest","styleElevation","backgroundColor","restStyle","flatten","dark","isDarkTheme","mode","colors","evalationStyles","getBackgroundColor","surface"],"mappings":";;AAAA;AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAEEC,UAFF,QAMO,cANP;AAQA,OAAOC,MAAP,MAAmB,kBAAnB;AACA,OAAOC,OAAP,MAAoB,mBAApB;AACA,SAASC,SAAT,QAA0B,YAA1B;;AASA,MAAMC,OAAwB,GAAG,QAM3B;AAAA,MAN4B;AAChCC,IAAAA,SAAS,EAAEC,aADqB;AAEhCC,IAAAA,KAFgC;AAGhCC,IAAAA,KAHgC;AAIhCC,IAAAA,QAJgC;AAKhC,OAAGC;AAL6B,GAM5B;AACJ,QAAM;AACJL,IAAAA,SAAS,EAAEM,cAAc,GAAG,CADxB;AAEJC,IAAAA,eAFI;AAGJ,OAAGC;AAHC,MAIDb,UAAU,CAACc,OAAX,CAAmBP,KAAnB,KAA6B,EAJlC;AAMA,QAAM;AAAEQ,IAAAA,IAAI,EAAEC,WAAR;AAAqBC,IAAAA,IAArB;AAA2BC,IAAAA;AAA3B,MAAsCV,KAA5C;AAEA,QAAMH,SAAS,GAAGC,aAAa,IAAIK,cAAnC;AAEA,QAAMQ,eAAe,GAAGd,SAAS,GAAGJ,MAAM,CAACI,SAAD,CAAT,GAAuB,EAAxD;;AAEA,QAAMe,kBAAkB,GAAG,MAAM;AAC/B,QAAIR,eAAJ,EAAqB;AACnB,aAAOA,eAAP;AACD,KAFD,MAEO,IAAII,WAAW,IAAIC,IAAI,KAAK,UAA5B,EAAwC;AAC7C,aAAOf,OAAO,CAACG,SAAD,EAAYa,MAAM,CAACG,OAAnB,CAAd;AACD,KAFM,MAEA;AACL,aAAOH,MAAM,CAACG,OAAd;AACD;AACF,GARD;;AAUA,sBACE,oBAAC,QAAD,CAAU,IAAV,eACMX,IADN;AAEE,IAAA,KAAK,EAAE,CACL;AACEE,MAAAA,eAAe,EAAEQ,kBAAkB,EADrC;AAEEf,MAAAA,SAFF;AAGE,SAAGc,eAHL;AAIE,SAAGN;AAJL,KADK;AAFT,MAWGJ,QAXH,CADF;AAeD,CA5CD;;AA8CA,eAAeN,SAAS,CAACC,OAAD,CAAxB","sourcesContent":["/* Copied from https://github.com/callstack/react-native-paper/blob/main/src/components/Surface.tsx */\nimport * as React from \"react\";\nimport {\n Animated,\n StyleSheet,\n ViewProps,\n StyleProp,\n ViewStyle,\n} from \"react-native\";\n\nimport shadow from \"../styles/shadow\";\nimport overlay from \"../styles/overlay\";\nimport { withTheme } from \"../theming\";\nimport type { Theme } from \"../styles/DefaultTheme\";\n\ntype Props = {\n elevation?: number;\n style?: StyleProp<ViewStyle>;\n theme: Theme;\n} & ViewProps;\n\nconst Surface: React.FC<Props> = ({\n elevation: propElevation,\n style,\n theme,\n children,\n ...rest\n}) => {\n const {\n elevation: styleElevation = 3,\n backgroundColor,\n ...restStyle\n } = (StyleSheet.flatten(style) || {}) as ViewStyle;\n\n const { dark: isDarkTheme, mode, colors } = theme;\n\n const elevation = propElevation || styleElevation;\n\n const evalationStyles = elevation ? shadow(elevation) : {};\n\n const getBackgroundColor = () => {\n if (backgroundColor) {\n return backgroundColor;\n } else if (isDarkTheme && mode === \"adaptive\") {\n return overlay(elevation, colors.surface);\n } else {\n return colors.surface;\n }\n };\n\n return (\n <Animated.View\n {...rest}\n style={[\n {\n backgroundColor: getBackgroundColor(),\n elevation,\n ...evalationStyles,\n ...restStyle,\n },\n ]}\n >\n {children}\n </Animated.View>\n );\n};\n\nexport default withTheme(Surface);\n"]}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { StyleProp, ViewStyle } from "react-native";
|
|
3
3
|
import type { Theme } from "../styles/DefaultTheme";
|
|
4
|
-
declare type
|
|
5
|
-
hasSafeArea: boolean;
|
|
4
|
+
declare type ScreenContainerProps = {
|
|
6
5
|
scrollable: boolean;
|
|
7
|
-
|
|
6
|
+
hasSafeArea: boolean;
|
|
8
7
|
hasTopSafeArea: boolean;
|
|
8
|
+
hasBottomSafeArea: boolean;
|
|
9
9
|
theme: Theme;
|
|
10
10
|
style?: StyleProp<ViewStyle>;
|
|
11
11
|
children?: React.ReactNode;
|
|
12
12
|
};
|
|
13
|
-
declare function ScreenContainer({
|
|
14
|
-
declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<
|
|
13
|
+
declare function ScreenContainer({ scrollable, hasSafeArea, hasBottomSafeArea, hasTopSafeArea, theme, style, children, ...rest }: ScreenContainerProps): JSX.Element;
|
|
14
|
+
declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<ScreenContainerProps, "theme"> & {
|
|
15
15
|
theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
|
|
16
|
-
}> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<
|
|
16
|
+
}> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<ScreenContainerProps> & typeof ScreenContainer, {}>;
|
|
17
17
|
export default _default;
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { StyleProp, ViewStyle, TextStyle } from "react-native";
|
|
3
3
|
import type { Theme } from "../styles/DefaultTheme";
|
|
4
4
|
import type { IconSlot } from "../interfaces/Icon";
|
|
5
5
|
declare type Props = {
|
|
6
|
+
min: number;
|
|
7
|
+
max: number;
|
|
6
8
|
value?: number;
|
|
7
|
-
min?: number;
|
|
8
|
-
max?: number;
|
|
9
|
-
theme: Theme;
|
|
10
|
-
style?: StyleProp<ViewStyle>;
|
|
11
|
-
onChange?: (value: number) => void;
|
|
12
9
|
defaultValue?: number;
|
|
13
|
-
|
|
14
|
-
iconColor?: string;
|
|
15
|
-
borderRadius?: number;
|
|
10
|
+
style?: StyleProp<ViewStyle>;
|
|
16
11
|
typeStyle?: StyleProp<TextStyle>;
|
|
12
|
+
iconSize: number;
|
|
13
|
+
iconColor?: string;
|
|
14
|
+
onChange?: (value: number) => void;
|
|
15
|
+
theme: Theme;
|
|
17
16
|
} & IconSlot;
|
|
18
17
|
declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<Props, "theme"> & {
|
|
19
18
|
theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "43.4.
|
|
3
|
+
"version": "43.4.17-ab8b1a.0+ab8b1acf",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
]
|
|
81
81
|
]
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "ab8b1acf6dbba1f8e7224cc87ac7c3c7e8a74a4d"
|
|
84
84
|
}
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { StyleSheet, ScrollView, View, } from "react-native";
|
|
3
3
|
import { SafeAreaView } from "react-native-safe-area-context";
|
|
4
4
|
import { withTheme } from "../theming";
|
|
5
|
-
function ScreenContainer({
|
|
5
|
+
function ScreenContainer({ scrollable = false, hasSafeArea = false, hasBottomSafeArea = false, hasTopSafeArea = false, theme, style, children, ...rest }) {
|
|
6
6
|
const backgroundColor = theme.colors.background;
|
|
7
7
|
const edges = ["left", "right"];
|
|
8
8
|
if (hasSafeArea || hasTopSafeArea) {
|
|
@@ -11,26 +11,26 @@ import type { Edge } from "react-native-safe-area-context";
|
|
|
11
11
|
import { withTheme } from "../theming";
|
|
12
12
|
import type { Theme } from "../styles/DefaultTheme";
|
|
13
13
|
|
|
14
|
-
type
|
|
15
|
-
hasSafeArea: boolean;
|
|
14
|
+
type ScreenContainerProps = {
|
|
16
15
|
scrollable: boolean;
|
|
17
|
-
|
|
16
|
+
hasSafeArea: boolean;
|
|
18
17
|
hasTopSafeArea: boolean;
|
|
18
|
+
hasBottomSafeArea: boolean;
|
|
19
19
|
theme: Theme;
|
|
20
20
|
style?: StyleProp<ViewStyle>;
|
|
21
21
|
children?: React.ReactNode;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
function ScreenContainer({
|
|
25
|
-
hasSafeArea,
|
|
26
25
|
scrollable = false,
|
|
26
|
+
hasSafeArea = false,
|
|
27
27
|
hasBottomSafeArea = false,
|
|
28
28
|
hasTopSafeArea = false,
|
|
29
29
|
theme,
|
|
30
30
|
style,
|
|
31
31
|
children,
|
|
32
32
|
...rest
|
|
33
|
-
}:
|
|
33
|
+
}: ScreenContainerProps) {
|
|
34
34
|
const backgroundColor = theme.colors.background;
|
|
35
35
|
|
|
36
36
|
const edges: Edge[] = ["left", "right"];
|
|
@@ -1,43 +1,29 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
2
|
import { View, Text } from "react-native";
|
|
3
|
+
import { isNumber } from "lodash";
|
|
3
4
|
import { withTheme } from "../theming";
|
|
4
5
|
import IconButton from "./IconButton";
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const Stepper = ({ min = -Infinity, max = Infinity, value: valueProp, defaultValue, style, typeStyle, iconSize = 24, iconColor, onChange, theme: { colors, typography }, Icon, }) => {
|
|
7
|
+
const [value, setValue] = useState(defaultValue ?? 0);
|
|
8
|
+
const isValidValue = (valueArg) => valueArg >= min && valueArg <= max;
|
|
9
|
+
const handlePlusOrMinus = (type) => {
|
|
10
|
+
const newValue = type === "plus" ? value + 1 : value - 1;
|
|
11
|
+
if (isValidValue(newValue)) {
|
|
12
|
+
setValue(newValue);
|
|
13
|
+
onChange?.(newValue);
|
|
11
14
|
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
};
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (valueProp != null &&
|
|
18
|
+
isNumber(valueProp) &&
|
|
19
|
+
valueProp !== value &&
|
|
20
|
+
isValidValue(valueProp)) {
|
|
21
|
+
setValue(valueProp);
|
|
17
22
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}, [defaultValue, value, min, max]);
|
|
23
|
-
const handleMinus = React.useCallback(() => {
|
|
24
|
-
if (isNumber(min) && value === min) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
setStateValue(stateValue - 1);
|
|
28
|
-
}, [min, stateValue, value]);
|
|
29
|
-
const handlePlus = React.useCallback(() => {
|
|
30
|
-
if (isNumber(max) && value === max) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
setStateValue(stateValue + 1);
|
|
34
|
-
}, [max, stateValue, value]);
|
|
35
|
-
return (React.createElement(View, { style: [
|
|
36
|
-
{ flexDirection: "row" },
|
|
37
|
-
style,
|
|
38
|
-
borderRadius ? { borderRadius } : {},
|
|
39
|
-
] },
|
|
40
|
-
React.createElement(IconButton, { Icon: Icon, icon: "MaterialIcons/remove", onPress: handleMinus, size: iconSize, color: iconColor, disabled: stateValue === min, style: stateValue === min ? { opacity: 0.5 } : {} }),
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
}, [valueProp]);
|
|
25
|
+
return (React.createElement(View, { style: [{ flexDirection: "row" }, style] },
|
|
26
|
+
React.createElement(IconButton, { Icon: Icon, icon: "MaterialIcons/remove", onPress: () => handlePlusOrMinus("minus"), size: iconSize, color: iconColor, disabled: value === min, style: { opacity: value === min ? 0.5 : 1 } }),
|
|
41
27
|
React.createElement(Text, { style: [
|
|
42
28
|
typography.body1,
|
|
43
29
|
{
|
|
@@ -47,7 +33,7 @@ const Stepper = ({ Icon, value, min, max, style, onChange, defaultValue, theme:
|
|
|
47
33
|
marginHorizontal: 8,
|
|
48
34
|
},
|
|
49
35
|
typeStyle,
|
|
50
|
-
] }, value
|
|
51
|
-
React.createElement(IconButton, { Icon: Icon, icon: "MaterialIcons/add", onPress:
|
|
36
|
+
] }, value),
|
|
37
|
+
React.createElement(IconButton, { Icon: Icon, icon: "MaterialIcons/add", onPress: () => handlePlusOrMinus("plus"), size: iconSize, color: iconColor, disabled: value === max, style: { opacity: value === max ? 0.5 : 1 } })));
|
|
52
38
|
};
|
|
53
39
|
export default withTheme(Stepper);
|
|
@@ -1,92 +1,75 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { FC, useEffect, useState } from "react";
|
|
2
2
|
import { View, Text, StyleProp, ViewStyle, TextStyle } from "react-native";
|
|
3
|
+
import { isNumber } from "lodash";
|
|
4
|
+
|
|
3
5
|
import { withTheme } from "../theming";
|
|
4
6
|
import type { Theme } from "../styles/DefaultTheme";
|
|
5
7
|
import type { IconSlot } from "../interfaces/Icon";
|
|
6
|
-
|
|
7
8
|
import IconButton from "./IconButton";
|
|
8
|
-
import isNumber from "lodash.isnumber";
|
|
9
9
|
|
|
10
10
|
type Props = {
|
|
11
|
+
min: number;
|
|
12
|
+
max: number;
|
|
11
13
|
value?: number;
|
|
12
|
-
min?: number;
|
|
13
|
-
max?: number;
|
|
14
|
-
theme: Theme;
|
|
15
|
-
style?: StyleProp<ViewStyle>;
|
|
16
|
-
onChange?: (value: number) => void;
|
|
17
14
|
defaultValue?: number;
|
|
18
|
-
|
|
19
|
-
iconColor?: string;
|
|
20
|
-
borderRadius?: number;
|
|
15
|
+
style?: StyleProp<ViewStyle>;
|
|
21
16
|
typeStyle?: StyleProp<TextStyle>;
|
|
17
|
+
iconSize: number;
|
|
18
|
+
iconColor?: string;
|
|
19
|
+
onChange?: (value: number) => void;
|
|
20
|
+
theme: Theme;
|
|
22
21
|
} & IconSlot;
|
|
23
22
|
|
|
24
|
-
const Stepper:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
max,
|
|
29
|
-
style,
|
|
30
|
-
onChange,
|
|
23
|
+
const Stepper: FC<Props> = ({
|
|
24
|
+
min = -Infinity,
|
|
25
|
+
max = Infinity,
|
|
26
|
+
value: valueProp,
|
|
31
27
|
defaultValue,
|
|
32
|
-
|
|
33
|
-
iconSize = 24,
|
|
34
|
-
iconColor = colors.strong,
|
|
35
|
-
borderRadius = roundness,
|
|
28
|
+
style,
|
|
36
29
|
typeStyle,
|
|
30
|
+
iconSize = 24,
|
|
31
|
+
iconColor,
|
|
32
|
+
onChange,
|
|
33
|
+
theme: { colors, typography },
|
|
34
|
+
Icon,
|
|
37
35
|
}) => {
|
|
38
|
-
const [
|
|
39
|
-
value || defaultValue || 0
|
|
40
|
-
);
|
|
36
|
+
const [value, setValue] = useState(defaultValue ?? 0);
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
if (value || value === 0) {
|
|
44
|
-
onChange && onChange(stateValue);
|
|
45
|
-
}
|
|
46
|
-
}, [onChange, stateValue, value]);
|
|
38
|
+
const isValidValue = (valueArg: number) => valueArg >= min && valueArg <= max;
|
|
47
39
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (isNumber(max) && newValue > max) {
|
|
51
|
-
newValue = max;
|
|
52
|
-
}
|
|
53
|
-
if (isNumber(min) && newValue < min) {
|
|
54
|
-
newValue = min;
|
|
55
|
-
}
|
|
56
|
-
setStateValue(newValue);
|
|
57
|
-
}, [defaultValue, value, min, max]);
|
|
40
|
+
const handlePlusOrMinus = (type: "plus" | "minus") => {
|
|
41
|
+
const newValue = type === "plus" ? value + 1 : value - 1;
|
|
58
42
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
43
|
+
if (isValidValue(newValue)) {
|
|
44
|
+
setValue(newValue);
|
|
45
|
+
onChange?.(newValue);
|
|
62
46
|
}
|
|
63
|
-
|
|
64
|
-
}, [min, stateValue, value]);
|
|
47
|
+
};
|
|
65
48
|
|
|
66
|
-
|
|
67
|
-
if (
|
|
68
|
-
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (
|
|
51
|
+
valueProp != null &&
|
|
52
|
+
isNumber(valueProp) &&
|
|
53
|
+
valueProp !== value &&
|
|
54
|
+
isValidValue(valueProp)
|
|
55
|
+
) {
|
|
56
|
+
setValue(valueProp);
|
|
69
57
|
}
|
|
70
|
-
|
|
71
|
-
}, [
|
|
58
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
|
+
}, [valueProp]);
|
|
72
60
|
|
|
73
61
|
return (
|
|
74
|
-
<View
|
|
75
|
-
style={[
|
|
76
|
-
{ flexDirection: "row" },
|
|
77
|
-
style,
|
|
78
|
-
borderRadius ? { borderRadius } : {},
|
|
79
|
-
]}
|
|
80
|
-
>
|
|
62
|
+
<View style={[{ flexDirection: "row" }, style]}>
|
|
81
63
|
<IconButton
|
|
82
64
|
Icon={Icon}
|
|
83
65
|
icon="MaterialIcons/remove"
|
|
84
|
-
onPress={
|
|
66
|
+
onPress={() => handlePlusOrMinus("minus")}
|
|
85
67
|
size={iconSize}
|
|
86
68
|
color={iconColor}
|
|
87
|
-
disabled={
|
|
88
|
-
style={
|
|
69
|
+
disabled={value === min}
|
|
70
|
+
style={{ opacity: value === min ? 0.5 : 1 }}
|
|
89
71
|
/>
|
|
72
|
+
|
|
90
73
|
<Text
|
|
91
74
|
style={[
|
|
92
75
|
typography.body1,
|
|
@@ -99,16 +82,17 @@ const Stepper: React.FC<Props> = ({
|
|
|
99
82
|
typeStyle,
|
|
100
83
|
]}
|
|
101
84
|
>
|
|
102
|
-
{value
|
|
85
|
+
{value}
|
|
103
86
|
</Text>
|
|
87
|
+
|
|
104
88
|
<IconButton
|
|
105
89
|
Icon={Icon}
|
|
106
90
|
icon="MaterialIcons/add"
|
|
107
|
-
onPress={
|
|
91
|
+
onPress={() => handlePlusOrMinus("plus")}
|
|
108
92
|
size={iconSize}
|
|
109
93
|
color={iconColor}
|
|
110
|
-
disabled={
|
|
111
|
-
style={
|
|
94
|
+
disabled={value === max}
|
|
95
|
+
style={{ opacity: value === max ? 0.5 : 1 }}
|
|
112
96
|
/>
|
|
113
97
|
</View>
|
|
114
98
|
);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* Copied from https://github.com/callstack/react-native-paper/blob/main/src/components/Surface.tsx */
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { Animated, StyleSheet,
|
|
3
|
+
import { Animated, StyleSheet, } from "react-native";
|
|
4
4
|
import shadow from "../styles/shadow";
|
|
5
5
|
import overlay from "../styles/overlay";
|
|
6
6
|
import { withTheme } from "../theming";
|
|
7
7
|
const Surface = ({ elevation: propElevation, style, theme, children, ...rest }) => {
|
|
8
|
-
const { elevation: styleElevation = 3, backgroundColor,
|
|
8
|
+
const { elevation: styleElevation = 3, backgroundColor, ...restStyle } = (StyleSheet.flatten(style) || {});
|
|
9
9
|
const { dark: isDarkTheme, mode, colors } = theme;
|
|
10
10
|
const elevation = propElevation || styleElevation;
|
|
11
11
|
const evalationStyles = elevation ? shadow(elevation) : {};
|
|
@@ -21,23 +21,12 @@ const Surface = ({ elevation: propElevation, style, theme, children, ...rest })
|
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
return (React.createElement(Animated.View, { ...rest, style: [
|
|
24
|
-
style,
|
|
25
24
|
{
|
|
26
25
|
backgroundColor: getBackgroundColor(),
|
|
27
|
-
overflow: Platform.OS === "web" && overflow === "hidden"
|
|
28
|
-
? "hidden"
|
|
29
|
-
: "visible",
|
|
30
26
|
elevation,
|
|
31
27
|
...evalationStyles,
|
|
28
|
+
...restStyle,
|
|
32
29
|
},
|
|
33
|
-
] },
|
|
34
|
-
React.createElement(View, { style: [
|
|
35
|
-
{
|
|
36
|
-
overflow,
|
|
37
|
-
borderRadius,
|
|
38
|
-
height,
|
|
39
|
-
width,
|
|
40
|
-
},
|
|
41
|
-
] }, children)));
|
|
30
|
+
] }, children));
|
|
42
31
|
};
|
|
43
32
|
export default withTheme(Surface);
|