@draftbit/core 43.4.16-ee8347.1 → 43.4.17
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/Card.js.map +1 -1
- package/lib/commonjs/components/CardContainerShortImage.js +18 -5
- package/lib/commonjs/components/CardContainerShortImage.js.map +1 -1
- package/lib/commonjs/components/ScreenContainer.js +3 -3
- 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/Touchable.js +3 -16
- package/lib/commonjs/components/Touchable.js.map +1 -1
- package/lib/commonjs/styles/overlay.js.map +1 -1
- package/lib/module/components/Elevation.js +3 -5
- package/lib/module/components/Elevation.js.map +1 -1
- package/lib/module/components/RowBodyIcon.js.map +1 -1
- package/lib/module/components/ScreenContainer.js +3 -3
- 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/Touchable.web.js.map +1 -1
- package/lib/module/hooks.js.map +1 -1
- package/lib/typescript/src/components/ScreenContainer.d.ts +7 -7
- 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 +8 -8
- package/src/components/Stepper.js +23 -37
- package/src/components/Stepper.tsx +48 -64
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Card.
|
|
1
|
+
{"version":3,"sources":["Card.js"],"names":["ICON_SIZE","Config","cardIconSize","ICON_CONTAINER_SIZE","ICON_CONTAINER_PADDING","ICON_ELEVATION","cardIconElevation","TopRightCircleIcon","Icon","icon","theme","onPress","React","createElement","Surface","style","justifyContent","alignItems","elevation","position","top","right","width","height","padding","borderRadius","backgroundColor","Pressable","disabled","pressed","opacity","name","size","color","colors","surface","Card","image","cardImageUrl","title","subtitle","description","textCentered","aspectRatio","onPressIcon","titleStyle","subtitleStyle","descriptionStyle","children","bgColor","styles","StyleSheet","flatten","innerPadding","Image","source","uri","resizeMode","View","Title","text","Subtitle","marginTop","Caption"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AACA,MAAMA,SAAS,GAAGC,gBAAOC,YAAzB;AACA,MAAMC,mBAAmB,GAAGF,gBAAOC,YAAP,GAAsB,CAAlD;AACA,MAAME,sBAAsB,GAAGH,gBAAOC,YAAP,GAAsB,CAAtB,GAA0B,CAAzD;AACA,MAAMG,cAAc,GAAGJ,gBAAOK,iBAA9B;AACO,MAAMC,kBAAkB,GAAG,wBAAU,QAAqC;AAAA,MAApC;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,IAAR;AAAcC,IAAAA,KAAd;AAAqBC,IAAAA;AAArB,GAAoC;AAC7E,sBAAQC,eAAMC,aAAN,CAAoBC,gBAApB,EAA6B;AAAEC,IAAAA,KAAK,EAAE;AACtCC,MAAAA,cAAc,EAAE,QADsB;AAEtCC,MAAAA,UAAU,EAAE,QAF0B;AAGtCC,MAAAA,SAAS,EAAEb,cAH2B;AAItCc,MAAAA,QAAQ,EAAE,UAJ4B;AAKtCC,MAAAA,GAAG,EAAE,EALiC;AAMtCC,MAAAA,KAAK,EAAE,EAN+B;AAOtCC,MAAAA,KAAK,EAAEnB,mBAP+B;AAQtCoB,MAAAA,MAAM,EAAEpB,mBAR8B;AAStCqB,MAAAA,OAAO,EAAEpB,sBAT6B;AAUtCqB,MAAAA,YAAY,EAAEtB,mBAVwB;AAWtCuB,MAAAA,eAAe,EAAE;AAXqB;AAAT,GAA7B,eAaJd,eAAMC,aAAN,CAAoBc,sBAApB,EAA+B;AAAEC,IAAAA,QAAQ,EAAE,CAACjB,OAAb;AAAsBA,IAAAA,OAAO,EAAEA,OAA/B;AAAwCI,IAAAA,KAAK,EAAE,SAAiB;AAAA,UAAhB;AAAEc,QAAAA;AAAF,OAAgB;AACvF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,QAAR;AAAkBzB,IAAAA,KAAK,EAAE+B;AAAzB,GAA9B,CAA7C,GAAwH,IAF5H,EAGIL,WAAW,IAAKA,WAAW,IAAIA,WAAW,KAAK,EAA/C,gBAAsD7B,eAAMC,aAAN,CAAoB6C,iBAApB,EAA0B;AAAE3C,IAAAA,KAAK,EAAE;AAAE+C,MAAAA,SAAS,EAAE;AAAb;AAAT,GAA1B,eAClDlD,eAAMC,aAAN,CAAoBkD,mBAApB,EAA6B;AAAEH,IAAAA,IAAI,EAAEnB,WAAR;AAAqB1B,IAAAA,KAAK,EAAEgC;AAA5B,GAA7B,CADkD,CAAtD,GACqF,IAJzF,EAKIC,QALJ,CADJ,CARJ,EAeIvC,IAAI,gBAAIG,eAAMC,aAAN,CAAoBN,kBAApB,EAAwC;AAAEC,IAAAA,IAAI,EAAEA,IAAR;AAAcC,IAAAA,IAAI,EAAEA,IAApB;AAA0BE,IAAAA,OAAO,EAAEiC;AAAnC,GAAxC,CAAJ,GAAiG,IAfzG,CADI,CAAR;AAiBH,CArBD;;eAsBe,wBAAUR,IAAV,C","sourcesContent":["import React from \"react\";\nimport { StyleSheet, View, Pressable, } from \"react-native\";\nimport Image from \"./Image\";\nimport Surface from \"./Surface\";\nimport { Title, Subtitle, Caption } from \"./Typography\";\nimport { withTheme } from \"../theming\";\nimport Config from \"./Config\";\nconst ICON_SIZE = Config.cardIconSize;\nconst ICON_CONTAINER_SIZE = Config.cardIconSize * 2;\nconst ICON_CONTAINER_PADDING = Config.cardIconSize / 2 - 1;\nconst ICON_ELEVATION = Config.cardIconElevation;\nexport const TopRightCircleIcon = withTheme(({ Icon, icon, theme, onPress, }) => {\n return (React.createElement(Surface, { style: {\n justifyContent: \"center\",\n alignItems: \"center\",\n elevation: ICON_ELEVATION,\n position: \"absolute\",\n top: 12,\n right: 12,\n width: ICON_CONTAINER_SIZE,\n height: ICON_CONTAINER_SIZE,\n padding: ICON_CONTAINER_PADDING,\n borderRadius: ICON_CONTAINER_SIZE,\n backgroundColor: \"rgba(0, 0, 0, 0.1)\",\n } },\n React.createElement(Pressable, { disabled: !onPress, onPress: onPress, style: ({ pressed }) => {\n return [\n {\n opacity: pressed ? 0.8 : 1,\n },\n ];\n } },\n React.createElement(Icon, { name: icon, size: ICON_SIZE, color: theme.colors.surface }))));\n});\nconst Card = ({ Icon, image = Config.cardImageUrl, title, subtitle, description, textCentered, icon, aspectRatio = 1.5, elevation = 2, style, onPress, onPressIcon, titleStyle, subtitleStyle, descriptionStyle, theme, children, }) => {\n const { backgroundColor: bgColor, padding, ...styles } = StyleSheet.flatten(style || {});\n const backgroundColor = bgColor ? bgColor : theme.colors.surface;\n const innerPadding = padding ? padding : 12;\n return (React.createElement(Surface, { style: [{ elevation, backgroundColor }, styles] },\n React.createElement(Pressable, { disabled: !onPress, onPress: onPress, style: ({ pressed }) => {\n return [\n {\n opacity: pressed ? 0.8 : 1,\n },\n ];\n } },\n React.createElement(Image, { style: { aspectRatio }, source: typeof image === \"string\" ? { uri: image } : image, resizeMode: \"cover\" }),\n React.createElement(View, { style: { padding: innerPadding } },\n React.createElement(View, { style: { alignItems: textCentered ? \"center\" : \"flex-start\" } },\n title || (title && title !== \"\") ? (React.createElement(Title, { text: title, style: titleStyle })) : null,\n subtitle || (subtitle && subtitle !== \"\") ? (React.createElement(Subtitle, { text: subtitle, style: subtitleStyle })) : null,\n description || (description && description !== \"\") ? (React.createElement(View, { style: { marginTop: 4 } },\n React.createElement(Caption, { text: description, style: descriptionStyle }))) : null,\n children)),\n icon ? (React.createElement(TopRightCircleIcon, { Icon: Icon, icon: icon, onPress: onPressIcon })) : null)));\n};\nexport default withTheme(Card);\n"]}
|
|
@@ -21,8 +21,6 @@ var _Config = _interopRequireDefault(require("./Config"));
|
|
|
21
21
|
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
23
|
|
|
24
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
25
|
-
|
|
26
24
|
const CardContainerShortImage = _ref => {
|
|
27
25
|
let {
|
|
28
26
|
image = _Config.default.squareImageUrl,
|
|
@@ -40,10 +38,11 @@ const CardContainerShortImage = _ref => {
|
|
|
40
38
|
onPress,
|
|
41
39
|
...rest
|
|
42
40
|
} = _ref;
|
|
43
|
-
return /*#__PURE__*/_react.default.createElement(_DeprecatedCardWrapper.default,
|
|
41
|
+
return /*#__PURE__*/_react.default.createElement(_DeprecatedCardWrapper.default, {
|
|
44
42
|
style: style,
|
|
45
|
-
onPress: onPress
|
|
46
|
-
|
|
43
|
+
onPress: onPress,
|
|
44
|
+
...rest
|
|
45
|
+
}, /*#__PURE__*/_react.default.createElement(_Elevation.default, {
|
|
47
46
|
style: {
|
|
48
47
|
elevation,
|
|
49
48
|
borderRadius: roundness
|
|
@@ -93,5 +92,19 @@ const CardContainerShortImage = _ref => {
|
|
|
93
92
|
|
|
94
93
|
var _default = (0, _theming.withTheme)(CardContainerShortImage);
|
|
95
94
|
|
|
95
|
+
exports.default = _default;
|
|
96
|
+
//# sourceMappingURL=CardContainerShortImage.js.mapteElement(_Image.default, {
|
|
97
|
+
style: {
|
|
98
|
+
aspectRatio
|
|
99
|
+
},
|
|
100
|
+
source: typeof image === "string" ? {
|
|
101
|
+
uri: image
|
|
102
|
+
} : image,
|
|
103
|
+
resizeMode: "cover"
|
|
104
|
+
}))));
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
var _default = (0, _theming.withTheme)(CardContainerShortImage);
|
|
108
|
+
|
|
96
109
|
exports.default = _default;
|
|
97
110
|
//# sourceMappingURL=CardContainerShortImage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CardContainerShortImage.
|
|
1
|
+
{"version":3,"sources":["CardContainerShortImage.js"],"names":["CardContainerShortImage","image","Config","squareImageUrl","title","subtitle","mode","aspectRatio","elevation","theme","colors","roundness","typography","style","onPress","rest","React","createElement","Card","Elevation","borderRadius","View","overflow","flexDirection","justifyContent","Image","source","uri","resizeMode","padding","backgroundColor","surface","flex","Text","numberOfLines","headline5","color","strong","body2","medium","marginTop"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AACA,MAAMA,uBAAuB,GAAG,QAA0K;AAAA,MAAzK;AAAEC,IAAAA,KAAK,GAAGC,gBAAOC,cAAjB;AAAiCC,IAAAA,KAAjC;AAAwCC,IAAAA,QAAxC;AAAkDC,IAAAA,IAAI,GAAG,MAAzD;AAAiEC,IAAAA,WAAW,GAAG,CAA/E;AAAkFC,IAAAA,SAAS,GAAG,CAA9F;AAAiGC,IAAAA,KAAK,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA,SAAV;AAAqBC,MAAAA;AAArB,KAAxG;AAA2IC,IAAAA,KAA3I;AAAkJC,IAAAA,OAAlJ;AAA2J,OAAGC;AAA9J,GAAyK;AACtM,sBAAQC,eAAMC,aAAN,CAAoBC,8BAApB,EAA0B;AAAEL,IAAAA,KAAK,EAAEA,KAAT;AAAgBC,IAAAA,OAAO,EAAEA,OAAzB;AAAkC,OAAGC;AAArC,GAA1B,eACJC,eAAMC,aAAN,CAAoBE,kBAApB,EAA+B;AAAEN,IAAAA,KAAK,EAAE;AAChCL,MAAAA,SADgC;AAEhCY,MAAAA,YAAY,EAAET;AAFkB;AAAT,GAA/B,eAIIK,eAAMC,aAAN,CAAoBI,iBAApB,EAA0B;AAAER,IAAAA,KAAK,EAAE;AAC3BS,MAAAA,QAAQ,EAAE,QADiB;AAE3BC,MAAAA,aAAa,EAAE,KAFY;AAG3BC,MAAAA,cAAc,EAAElB,IAAI,KAAK,OAAT,GAAmB,eAAnB,GAAqC,YAH1B;AAI3Bc,MAAAA,YAAY,EAAET;AAJa;AAAT,GAA1B,EAMIL,IAAI,KAAK,MAAT,iBAAoBU,eAAMC,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AA5B,GAA6CA,KAA/E;AAAsF2B,IAAAA,UAAU,EAAE;AAAlG,GAA3B,CAjBzB,CAJJ,CADI,CAAR;AAuBH,CAxBD;;eAyBe,wBAAU5B,uBAAV,C","sourcesContent":["import React from \"react\";\nimport { View, Text, } from \"react-native\";\nimport Image from \"./Image\";\nimport Card from \"./DeprecatedCardWrapper\";\nimport Elevation from \"./Elevation\";\nimport { withTheme } from \"../theming\";\nimport Config from \"./Config\";\nconst CardContainerShortImage = ({ image = Config.squareImageUrl, title, subtitle, mode = \"left\", aspectRatio = 1, elevation = 2, theme: { colors, roundness, typography }, style, onPress, ...rest }) => {\n return (React.createElement(Card, { style: style, onPress: onPress, ...rest },\n React.createElement(Elevation, { style: {\n elevation,\n borderRadius: roundness,\n } },\n React.createElement(View, { style: {\n overflow: \"hidden\",\n flexDirection: \"row\",\n justifyContent: mode === \"right\" ? \"space-between\" : \"flex-start\",\n borderRadius: roundness,\n } },\n mode === \"left\" && (React.createElement(Image, { style: { aspectRatio }, source: typeof image === \"string\" ? { uri: image } : image, resizeMode: \"cover\" })),\n React.createElement(View, { style: {\n padding: 16,\n backgroundColor: colors.surface,\n flex: 1,\n } },\n React.createElement(Text, { numberOfLines: 1, style: [typography.headline5, { color: colors.strong }] }, title),\n subtitle ? (React.createElement(Text, { numberOfLines: 1, style: [\n typography.body2,\n { color: colors.medium, marginTop: 4 },\n ] }, subtitle)) : null),\n mode === \"right\" && (React.createElement(Image, { style: { aspectRatio }, source: typeof image === \"string\" ? { uri: image } : image, resizeMode: \"cover\" }))))));\n};\nexport default withTheme(CardContainerShortImage);\n"]}
|
|
@@ -21,10 +21,10 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
21
21
|
|
|
22
22
|
function ScreenContainer(_ref) {
|
|
23
23
|
let {
|
|
24
|
-
hasSafeArea = false,
|
|
25
24
|
scrollable = false,
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
hasSafeArea = false,
|
|
26
|
+
hasBottomSafeArea = false,
|
|
27
|
+
hasTopSafeArea = false,
|
|
28
28
|
theme,
|
|
29
29
|
style,
|
|
30
30
|
children,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ScreenContainer.tsx"],"names":["ScreenContainer","
|
|
1
|
+
{"version":3,"sources":["ScreenContainer.tsx"],"names":["ScreenContainer","scrollable","hasSafeArea","hasBottomSafeArea","hasTopSafeArea","theme","style","children","rest","backgroundColor","colors","background","edges","push","styles","container","scrollViewContainer","StyleSheet","create","flex","flexGrow","undefined"],"mappings":";;;;;;;AAAA;;AACA;;AAOA;;AAEA;;;;;;;;AAaA,SAASA,eAAT,OASyB;AAAA,MATA;AACvBC,IAAAA,UAAU,GAAG,KADU;AAEvBC,IAAAA,WAAW,GAAG,KAFS;AAGvBC,IAAAA,iBAAiB,GAAG,KAHG;AAIvBC,IAAAA,cAAc,GAAG,KAJM;AAKvBC,IAAAA,KALuB;AAMvBC,IAAAA,KANuB;AAOvBC,IAAAA,QAPuB;AAQvB,OAAGC;AARoB,GASA;AACvB,QAAMC,eAAe,GAAGJ,KAAK,CAACK,MAAN,CAAaC,UAArC;AAEA,QAAMC,KAAa,GAAG,CAAC,MAAD,EAAS,OAAT,CAAtB;;AACA,MAAIV,WAAW,IAAIE,cAAnB,EAAmC;AACjCQ,IAAAA,KAAK,CAACC,IAAN,CAAW,KAAX;AACD;;AAED,MAAIX,WAAW,IAAIC,iBAAnB,EAAsC;AACpCS,IAAAA,KAAK,CAACC,IAAN,CAAW,QAAX;AACD;;AAED,sBACE,oBAAC,wCAAD;AACE,IAAA,KAAK,EAAED,KADT;AAEE,IAAA,KAAK,EAAE,CACLE,MAAM,CAACC,SADF,EAEL;AACEN,MAAAA;AADF,KAFK;AAFT,KAQMD,IARN,GAUGP,UAAU,gBACT,oBAAC,uBAAD;AACE,IAAA,qBAAqB,EAAE,CACrBa,MAAM,CAACE,mBADc,EAErB;AAAEP,MAAAA;AAAF,KAFqB,EAGrBH,KAHqB;AADzB,KAOGC,QAPH,CADS,gBAWT,oBAAC,iBAAD;AAAM,IAAA,KAAK,EAAE,CAACO,MAAM,CAACC,SAAR,EAAmB;AAAEN,MAAAA;AAAF,KAAnB,EAAwCH,KAAxC;AAAb,KACGC,QADH,CArBJ,CADF;AA4BD;;AAED,MAAMO,MAAM,GAAGG,wBAAWC,MAAX,CAAkB;AAC/BH,EAAAA,SAAS,EAAE;AACTI,IAAAA,IAAI,EAAE;AADG,GADoB;AAI/BH,EAAAA,mBAAmB,EAAE;AACnBI,IAAAA,QAAQ,EAAE,CADS;AAEnBD,IAAAA,IAAI,EAAEE;AAFa;AAJU,CAAlB,CAAf;;eAUe,wBAAUrB,eAAV,C","sourcesContent":["import * as React from \"react\";\nimport {\n StyleSheet,\n ScrollView,\n StyleProp,\n ViewStyle,\n View,\n} from \"react-native\";\nimport { SafeAreaView } from \"react-native-safe-area-context\";\nimport type { Edge } from \"react-native-safe-area-context\";\nimport { withTheme } from \"../theming\";\nimport type { Theme } from \"../styles/DefaultTheme\";\n\ntype ScreenContainerProps = {\n scrollable: boolean;\n hasSafeArea: boolean;\n hasTopSafeArea: boolean;\n hasBottomSafeArea: boolean;\n theme: Theme;\n style?: StyleProp<ViewStyle>;\n children?: React.ReactNode;\n};\n\nfunction ScreenContainer({\n scrollable = false,\n hasSafeArea = false,\n hasBottomSafeArea = false,\n hasTopSafeArea = false,\n theme,\n style,\n children,\n ...rest\n}: ScreenContainerProps) {\n const backgroundColor = theme.colors.background;\n\n const edges: Edge[] = [\"left\", \"right\"];\n if (hasSafeArea || hasTopSafeArea) {\n edges.push(\"top\");\n }\n\n if (hasSafeArea || hasBottomSafeArea) {\n edges.push(\"bottom\");\n }\n\n return (\n <SafeAreaView\n edges={edges}\n style={[\n styles.container,\n {\n backgroundColor,\n },\n ]}\n {...rest}\n >\n {scrollable ? (\n <ScrollView\n contentContainerStyle={[\n styles.scrollViewContainer,\n { backgroundColor },\n style,\n ]}\n >\n {children}\n </ScrollView>\n ) : (\n <View style={[styles.container, { backgroundColor }, style]}>\n {children}\n </View>\n )}\n </SafeAreaView>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n scrollViewContainer: {\n flexGrow: 1,\n flex: undefined,\n },\n});\n\nexport default withTheme(ScreenContainer);\n"]}
|
|
@@ -5,16 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _reactNative = require("react-native");
|
|
11
11
|
|
|
12
|
+
var _lodash = require("lodash");
|
|
13
|
+
|
|
12
14
|
var _theming = require("../theming");
|
|
13
15
|
|
|
14
16
|
var _IconButton = _interopRequireDefault(require("./IconButton"));
|
|
15
17
|
|
|
16
|
-
var _lodash = _interopRequireDefault(require("lodash.isnumber"));
|
|
17
|
-
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
20
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -23,89 +23,71 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
23
23
|
|
|
24
24
|
const Stepper = _ref => {
|
|
25
25
|
let {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
min = -Infinity,
|
|
27
|
+
max = Infinity,
|
|
28
|
+
value: valueProp,
|
|
29
|
+
defaultValue,
|
|
30
30
|
style,
|
|
31
|
+
typeStyle,
|
|
32
|
+
iconSize = 24,
|
|
33
|
+
iconColor,
|
|
31
34
|
onChange,
|
|
32
|
-
defaultValue,
|
|
33
35
|
theme: {
|
|
34
36
|
colors,
|
|
35
|
-
typography
|
|
36
|
-
roundness
|
|
37
|
+
typography
|
|
37
38
|
},
|
|
38
|
-
|
|
39
|
-
iconColor = colors.strong,
|
|
40
|
-
borderRadius = roundness,
|
|
41
|
-
typeStyle
|
|
39
|
+
Icon
|
|
42
40
|
} = _ref;
|
|
43
|
-
const [
|
|
44
|
-
React.useEffect(() => {
|
|
45
|
-
if (value || value === 0) {
|
|
46
|
-
onChange && onChange(stateValue);
|
|
47
|
-
}
|
|
48
|
-
}, [onChange, stateValue, value]);
|
|
49
|
-
React.useEffect(() => {
|
|
50
|
-
let newValue = value || defaultValue || 0;
|
|
41
|
+
const [value, setValue] = (0, _react.useState)(defaultValue !== null && defaultValue !== void 0 ? defaultValue : 0);
|
|
51
42
|
|
|
52
|
-
|
|
53
|
-
newValue = max;
|
|
54
|
-
}
|
|
43
|
+
const isValidValue = valueArg => valueArg >= min && valueArg <= max;
|
|
55
44
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
45
|
+
const handlePlusOrMinus = type => {
|
|
46
|
+
const newValue = type === "plus" ? value + 1 : value - 1;
|
|
59
47
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if ((0, _lodash.default)(min) && value === min) {
|
|
64
|
-
return;
|
|
48
|
+
if (isValidValue(newValue)) {
|
|
49
|
+
setValue(newValue);
|
|
50
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
65
51
|
}
|
|
52
|
+
};
|
|
66
53
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
54
|
+
(0, _react.useEffect)(() => {
|
|
55
|
+
if (valueProp != null && (0, _lodash.isNumber)(valueProp) && valueProp !== value && isValidValue(valueProp)) {
|
|
56
|
+
setValue(valueProp);
|
|
57
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
73
58
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
59
|
+
}, [valueProp]);
|
|
60
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
77
61
|
style: [{
|
|
78
62
|
flexDirection: "row"
|
|
79
|
-
}, style
|
|
80
|
-
|
|
81
|
-
} : {}]
|
|
82
|
-
}, /*#__PURE__*/React.createElement(_IconButton.default, {
|
|
63
|
+
}, style]
|
|
64
|
+
}, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
83
65
|
Icon: Icon,
|
|
84
66
|
icon: "MaterialIcons/remove",
|
|
85
|
-
onPress:
|
|
67
|
+
onPress: () => handlePlusOrMinus("minus"),
|
|
86
68
|
size: iconSize,
|
|
87
69
|
color: iconColor,
|
|
88
|
-
disabled:
|
|
89
|
-
style:
|
|
90
|
-
opacity: 0.5
|
|
91
|
-
}
|
|
92
|
-
}), /*#__PURE__*/
|
|
70
|
+
disabled: value === min,
|
|
71
|
+
style: {
|
|
72
|
+
opacity: value === min ? 0.5 : 1
|
|
73
|
+
}
|
|
74
|
+
}), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
93
75
|
style: [typography.body1, {
|
|
94
76
|
textAlign: "center",
|
|
95
77
|
alignSelf: "center",
|
|
96
78
|
color: colors.medium,
|
|
97
79
|
marginHorizontal: 8
|
|
98
80
|
}, typeStyle]
|
|
99
|
-
}, value
|
|
81
|
+
}, value), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
100
82
|
Icon: Icon,
|
|
101
83
|
icon: "MaterialIcons/add",
|
|
102
|
-
onPress:
|
|
84
|
+
onPress: () => handlePlusOrMinus("plus"),
|
|
103
85
|
size: iconSize,
|
|
104
86
|
color: iconColor,
|
|
105
|
-
disabled:
|
|
106
|
-
style:
|
|
107
|
-
opacity: 0.5
|
|
108
|
-
}
|
|
87
|
+
disabled: value === max,
|
|
88
|
+
style: {
|
|
89
|
+
opacity: value === max ? 0.5 : 1
|
|
90
|
+
}
|
|
109
91
|
}));
|
|
110
92
|
};
|
|
111
93
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Stepper.tsx"],"names":["Stepper","
|
|
1
|
+
{"version":3,"sources":["Stepper.tsx"],"names":["Stepper","min","Infinity","max","value","valueProp","defaultValue","style","typeStyle","iconSize","iconColor","onChange","theme","colors","typography","Icon","setValue","isValidValue","valueArg","handlePlusOrMinus","type","newValue","flexDirection","opacity","body1","textAlign","alignSelf","color","medium","marginHorizontal"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAGA;;;;;;;;AAeA,MAAMA,OAAkB,GAAG,QAYrB;AAAA,MAZsB;AAC1BC,IAAAA,GAAG,GAAG,CAACC,QADmB;AAE1BC,IAAAA,GAAG,GAAGD,QAFoB;AAG1BE,IAAAA,KAAK,EAAEC,SAHmB;AAI1BC,IAAAA,YAJ0B;AAK1BC,IAAAA,KAL0B;AAM1BC,IAAAA,SAN0B;AAO1BC,IAAAA,QAAQ,GAAG,EAPe;AAQ1BC,IAAAA,SAR0B;AAS1BC,IAAAA,QAT0B;AAU1BC,IAAAA,KAAK,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV,KAVmB;AAW1BC,IAAAA;AAX0B,GAYtB;AACJ,QAAM,CAACX,KAAD,EAAQY,QAAR,IAAoB,qBAASV,YAAT,aAASA,YAAT,cAASA,YAAT,GAAyB,CAAzB,CAA1B;;AAEA,QAAMW,YAAY,GAAIC,QAAD,IAAsBA,QAAQ,IAAIjB,GAAZ,IAAmBiB,QAAQ,IAAIf,GAA1E;;AAEA,QAAMgB,iBAAiB,GAAIC,IAAD,IAA4B;AACpD,UAAMC,QAAQ,GAAGD,IAAI,KAAK,MAAT,GAAkBhB,KAAK,GAAG,CAA1B,GAA8BA,KAAK,GAAG,CAAvD;;AAEA,QAAIa,YAAY,CAACI,QAAD,CAAhB,EAA4B;AAC1BL,MAAAA,QAAQ,CAACK,QAAD,CAAR;AACAV,MAAAA,QA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,KAAK,EAAEC,SALT;AAME,IAAA,QAAQ,EAAEN,KAAK,KAAKD,GANtB;AAOE,IAAA,KAAK,EAAE;AAAEoB,MAAAA,OAAO,EAAEnB,KAAK,KAAKD,GAAV,GAAgB,GAAhB,GAAsB;AAAjC;AAPT,IA1BF,CADF;AAsCD,CA5ED;;eA8Ee,wBAAUH,OAAV,C","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"]}
|
|
@@ -11,6 +11,8 @@ var _reactNative = require("react-native");
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
14
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
+
|
|
14
16
|
function Touchable(_ref) {
|
|
15
17
|
let {
|
|
16
18
|
children,
|
|
@@ -19,22 +21,7 @@ function Touchable(_ref) {
|
|
|
19
21
|
style,
|
|
20
22
|
...props
|
|
21
23
|
} = _ref;
|
|
22
|
-
return /*#__PURE__*/_react.default.createElement(_reactNative.Pressable, {
|
|
23
|
-
onPress: onPress,
|
|
24
|
-
disabled: disabled,
|
|
25
|
-
hitSlop: 8,
|
|
26
|
-
style: _ref2 => {
|
|
27
|
-
let {
|
|
28
|
-
pressed
|
|
29
|
-
} = _ref2;
|
|
30
|
-
return [{
|
|
31
|
-
opacity: pressed || disabled ? 0.75 : 1
|
|
32
|
-
}, style];
|
|
33
|
-
},
|
|
34
|
-
...props
|
|
35
|
-
}, children);
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=Touchable.js.mapElement(_reactNative.Pressable, _extends({
|
|
24
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.Pressable, _extends({
|
|
38
25
|
onPress: onPress,
|
|
39
26
|
disabled: disabled,
|
|
40
27
|
hitSlop: 8,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Touchable.
|
|
1
|
+
{"version":3,"sources":["Touchable.tsx"],"names":["Touchable","children","disabled","onPress","style","props","pressed","opacity"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AASe,SAASA,SAAT,OAML;AAAA,MANwB;AAChCC,IAAAA,QADgC;AAEhCC,IAAAA,QAFgC;AAGhCC,IAAAA,OAHgC;AAIhCC,IAAAA,KAJgC;AAKhC,OAAGC;AAL6B,GAMxB;AACR,sBACE,6BAAC,sBAAD;AACE,IAAA,OAAO,EAAEF,OADX;AAEE,IAAA,QAAQ,EAAED,QAFZ;AAGE,IAAA,OAAO,EAAE,CAHX;AAIE,IAAA,KAAK,EAAE,SAAiB;AAAA,UAAhB;AAAEI,QAAAA;AAAF,OAAgB;AACtB,aAAO,CACL;AACEC,QAAAA,OAAO,EAAED,OAAO,IAAIJ,QAAX,GAAsB,IAAtB,GAA6B;AADxC,OADK,EAILE,KAJK,CAAP;AAMD;AAXH,KAYMC,KAZN,GAcGJ,QAdH,CADF;AAkBD","sourcesContent":["import React from \"react\";\nimport { Pressable, ViewStyle, PressableProps } from \"react-native\";\n\ntype Props = {\n disabled?: boolean;\n children: React.ReactNode;\n style?: ViewStyle;\n onPress?: () => void;\n} & PressableProps;\n\nexport default function Touchable({\n children,\n disabled,\n onPress,\n style,\n ...props\n}: Props) {\n return (\n <Pressable\n onPress={onPress}\n disabled={disabled}\n hitSlop={8}\n style={({ pressed }) => {\n return [\n {\n opacity: pressed || disabled ? 0.75 : 1,\n },\n style,\n ];\n }}\n {...props}\n >\n {children}\n </Pressable>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["overlay.
|
|
1
|
+
{"version":3,"sources":["overlay.tsx"],"names":["isAnimatedValue","it","Animated","Value","overlay","elevation","surfaceColor","DarkTheme","colors","surface","inputRange","interpolate","outputRange","map","e","calculateColor","overlayTransparency","elevationOverlayTransparency","mix","hex"],"mappings":";;;;;;;AACA;;AACA;;AACA;;;;AAHA;AAKA,MAAMA,eAAe,GACnBC,EADsB,IAEGA,EAAE,YAAYC,sBAASC,KAFlD;;AAIe,SAASC,OAAT,CACbC,SADa,EAG+C;AAAA,MAD5DC,YAC4D,uEADrCC,mBAAUC,MAAV,CAAiBC,OACoB;;AAC5D,MAAIT,eAAe,CAACK,SAAD,CAAnB,EAAgC;AAC9B,UAAMK,UAAU,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,EAAa,CAAb,EAAgB,EAAhB,CAAnB,CAD8B,CAG9B;;AACA,WAAOL,SAAS,CAACM,WAAV,CAAsB;AAC3BD,MAAAA,UAD2B;AAE3BE,MAAAA,WAAW,EAAEF,UAAU,CAACG,GAAX,CAAgBC,CAAD,IAAO;AACjC,eAAOC,cAAc,CAACT,YAAD,EAAeQ,CAAf,CAArB;AACD,OAFY;AAFc,KAAtB,CAAP;AAMD,GAX2D,CAa5D;;;AACA,SAAOC,cAAc,CAACT,YAAD,EAAeD,SAAf,CAArB;AACD;;AAED,SAASU,cAAT,CAAwBT,YAAxB,EAAqE;AAAA,MAAvBD,SAAuB,uEAAH,CAAG;AACnE,MAAIW,mBAAJ;;AACA,MAAIX,SAAS,IAAI,CAAb,IAAkBA,SAAS,IAAI,EAAnC,EAAuC;AACrCW,IAAAA,mBAAmB,GAAGC,4BAA4B,CAACZ,SAAD,CAAlD;AACD,GAFD,MAEO,IAAIA,SAAS,GAAG,EAAhB,EAAoB;AACzBW,IAAAA,mBAAmB,GAAGC,4BAA4B,CAAC,EAAD,CAAlD;AACD,GAFM,MAEA;AACLD,IAAAA,mBAAmB,GAAGC,4BAA4B,CAAC,CAAD,CAAlD;AACD;;AACD,SAAO,oBAAMX,YAAN,EACJY,GADI,CACA,oBAAM,OAAN,CADA,EACgBF,mBAAmB,GAAG,IADtC,EAEJG,GAFI,EAAP;AAGD;;AAED,MAAMF,4BAAoD,GAAG;AAC3D,KAAG,CADwD;AAE3D,KAAG,CAFwD;AAG3D,KAAG,CAHwD;AAI3D,KAAG,CAJwD;AAK3D,KAAG,EALwD;AAM3D,KAAG,EANwD;AAO3D,KAAG,IAPwD;AAQ3D,KAAG,EARwD;AAS3D,KAAG,IATwD;AAU3D,MAAI,EAVuD;AAW3D,MAAI,IAXuD;AAY3D,MAAI,EAZuD;AAa3D,MAAI,KAbuD;AAc3D,MAAI,IAduD;AAe3D,MAAI,KAfuD;AAgB3D,MAAI,EAhBuD;AAiB3D,MAAI,KAjBuD;AAkB3D,MAAI,KAlBuD;AAmB3D,MAAI,KAnBuD;AAoB3D,MAAI,KApBuD;AAqB3D,MAAI,IArBuD;AAsB3D,MAAI,KAtBuD;AAuB3D,MAAI,KAvBuD;AAwB3D,MAAI;AAxBuD,CAA7D","sourcesContent":["/* Copied from https://github.com/callstack/react-native-paper/blob/main/src/styles/overlay.tsx */\nimport color from \"color\";\nimport { Animated } from \"react-native\";\nimport DarkTheme from \"./DarkTheme\";\n\nconst isAnimatedValue = (\n it: number | Animated.AnimatedInterpolation\n): it is Animated.Value => it instanceof Animated.Value;\n\nexport default function overlay<T extends Animated.Value | number>(\n elevation: T,\n surfaceColor: string = DarkTheme.colors.surface\n): T extends number ? string : Animated.AnimatedInterpolation {\n if (isAnimatedValue(elevation)) {\n const inputRange = [0, 1, 2, 3, 8, 24];\n\n // @ts-expect-error: TS doesn't seem to refine the type correctly\n return elevation.interpolate({\n inputRange,\n outputRange: inputRange.map((e) => {\n return calculateColor(surfaceColor, e);\n }),\n });\n }\n\n // @ts-expect-error: TS doesn't seem to refine the type correctly\n return calculateColor(surfaceColor, elevation);\n}\n\nfunction calculateColor(surfaceColor: string, elevation: number = 1) {\n let overlayTransparency: number;\n if (elevation >= 1 && elevation <= 24) {\n overlayTransparency = elevationOverlayTransparency[elevation];\n } else if (elevation > 24) {\n overlayTransparency = elevationOverlayTransparency[24];\n } else {\n overlayTransparency = elevationOverlayTransparency[1];\n }\n return color(surfaceColor)\n .mix(color(\"white\"), overlayTransparency * 0.01)\n .hex();\n}\n\nconst elevationOverlayTransparency: Record<string, number> = {\n 1: 5,\n 2: 7,\n 3: 8,\n 4: 9,\n 5: 10,\n 6: 11,\n 7: 11.5,\n 8: 12,\n 9: 12.5,\n 10: 13,\n 11: 13.5,\n 12: 14,\n 13: 14.25,\n 14: 14.5,\n 15: 14.75,\n 16: 15,\n 17: 15.12,\n 18: 15.24,\n 19: 15.36,\n 20: 15.48,\n 21: 15.6,\n 22: 15.72,\n 23: 15.84,\n 24: 16,\n};\n"]}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
1
|
import * as React from "react";
|
|
4
2
|
import { Animated, StyleSheet, View } from "react-native";
|
|
5
3
|
import shadow from "../styles/shadow";
|
|
6
4
|
import { withTheme } from "../theming";
|
|
7
|
-
|
|
8
5
|
/* directly copied from https://github.com/callstack/react-native-paper/blob/main/src/components/Surface.tsx#L62 */
|
|
6
|
+
|
|
9
7
|
const Elevation = _ref => {
|
|
10
8
|
let {
|
|
11
9
|
style,
|
|
@@ -21,12 +19,12 @@ const Elevation = _ref => {
|
|
|
21
19
|
colors
|
|
22
20
|
} = theme;
|
|
23
21
|
const borderRadius = radius;
|
|
24
|
-
return /*#__PURE__*/React.createElement(Animated.View,
|
|
22
|
+
return /*#__PURE__*/React.createElement(Animated.View, { ...rest,
|
|
25
23
|
style: [{
|
|
26
24
|
borderRadius,
|
|
27
25
|
backgroundColor: colors.surface
|
|
28
26
|
}, elevation ? shadow(elevation) : null, style]
|
|
29
|
-
}
|
|
27
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
30
28
|
style: {
|
|
31
29
|
overflow: "hidden",
|
|
32
30
|
borderRadius
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Elevation.
|
|
1
|
+
{"version":3,"sources":["Elevation.js"],"names":["React","Animated","StyleSheet","View","shadow","withTheme","Elevation","style","theme","children","rest","elevation","borderRadius","radius","flatten","colors","createElement","backgroundColor","surface","overflow"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,QAAT,EAAmBC,UAAnB,EAA+BC,IAA/B,QAA4C,cAA5C;AACA,OAAOC,MAAP,MAAmB,kBAAnB;AACA,SAASC,SAAT,QAA0B,YAA1B;AACA;;AACA,MAAMC,SAAS,GAAG,QAAyC;AAAA,MAAxC;AAAEC,IAAAA,KAAF;AAASC,IAAAA,KAAT;AAAgBC,IAAAA,QAAhB;AAA0B,OAAGC;AAA7B,GAAwC;AACvD,QAAM;AAAEC,IAAAA,SAAS,GAAG,CAAd;AAAiBC,IAAAA,YAAY,EAAEC;AAA/B,MAA0CX,UAAU,CAACY,OAAX,CAAmBP,KAAnB,KAA6B,EAA7E;AACA,QAAM;AAAEQ,IAAAA;AAAF,MAAaP,KAAnB;AACA,QAAMI,YAAY,GAAGC,MAArB;AACA,sBAAQb,KAAK,CAACgB,aAAN,CAAoBf,QAAQ,CAACE,IAA7B,EAAmC,EAAE,GAAGO,IAAL;AAAWH,IAAAA,KAAK,EAAE,CACrD;AACIK,MAAAA,YADJ;AAEIK,MAAAA,eAAe,EAAEF,MAAM,CAACG;AAF5B,KADqD,EAKrDP,SAAS,GAAGP,MAAM,CAACO,SAAD,CAAT,GAAuB,IALqB,EAMrDJ,KANqD;AAAlB,GAAnC,eAQJP,KAAK,CAACgB,aAAN,CAAoBb,IAApB,EAA0B;AAAEI,IAAAA,KAAK,EAAE;AAAEY,MAAAA,QAAQ,EAAE,QAAZ;AAAsBP,MAAAA;AAAtB;AAAT,GAA1B,EAA2EH,QAA3E,CARI,CAAR;AASH,CAbD;;AAcA,eAAeJ,SAAS,CAACC,SAAD,CAAxB","sourcesContent":["import * as React from \"react\";\nimport { Animated, StyleSheet, View, } from \"react-native\";\nimport shadow from \"../styles/shadow\";\nimport { withTheme } from \"../theming\";\n/* directly copied from https://github.com/callstack/react-native-paper/blob/main/src/components/Surface.tsx#L62 */\nconst Elevation = ({ style, theme, children, ...rest }) => {\n const { elevation = 4, borderRadius: radius } = StyleSheet.flatten(style) || {};\n const { colors } = theme;\n const borderRadius = radius;\n return (React.createElement(Animated.View, { ...rest, style: [\n {\n borderRadius,\n backgroundColor: colors.surface,\n },\n elevation ? shadow(elevation) : null,\n style,\n ] },\n React.createElement(View, { style: { overflow: \"hidden\", borderRadius } }, children)));\n};\nexport default withTheme(Elevation);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RowBodyIcon.
|
|
1
|
+
{"version":3,"sources":["RowBodyIcon.tsx"],"names":["React","withTheme","Row","Config","RowBodyIcon","Icon","title","subtitle","icon","style","theme","colors","typography","body1","medium","subtitle2","light","rowSingleLineIconSize","marginLeft"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,SAAT,QAA0B,YAA1B;AAIA,OAAOC,GAAP,MAAgB,OAAhB;AACA,OAAOC,MAAP,MAAmB,UAAnB;;AAWA,MAAMC,WAA4B,GAAG,QAO/B;AAAA,MAPgC;AACpCC,IAAAA,IADoC;AAEpCC,IAAAA,KAFoC;AAGpCC,IAAAA,QAHoC;AAIpCC,IAAAA,IAJoC;AAKpCC,IAAAA,KALoC;AAMpCC,IAAAA,KAAK,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV;AAN6B,GAOhC;AACJ,sBACE,oBAAC,GAAD;AACE,IAAA,cAAc,EAAEA,UAAU,CAACC,KAD7B;AAEE,IAAA,UAAU,EAAEF,MAAM,CAACG,MAFrB;AAGE,IAAA,iBAAiB,EAAEF,UAAU,CAACG,SAHhC;AAIE,IAAA,aAAa,EAAEJ,MAAM,CAACK,KAJxB;AAKE,IAAA,KAAK,EAAEV,KALT;AAME,IAAA,QAAQ,EAAEC,QANZ;AAOE,IAAA,KAAK,EAAE,mBACL,oBAAC,IAAD;AACE,MAAA,IAAI,EAAEC,IADR;AAEE,MAAA,IAAI,EAAEL,MAAM,CAACc,qBAFf;AAGE,MAAA,KAAK,EAAEN,MAAM,CAACK,KAHhB;AAIE,MAAA,KAAK,EAAE;AAAEE,QAAAA,UAAU,EAAE;AAAd;AAJT,MARJ;AAeE,IAAA,KAAK,EAAET;AAfT,IADF;AAmBD,CA3BD;;AA6BA,eAAeR,SAAS,CAACG,WAAD,CAAxB","sourcesContent":["import * as React from \"react\";\nimport { withTheme } from \"../theming\";\nimport type { Theme } from \"../styles/DefaultTheme\";\nimport type { IconSlot } from \"../interfaces/Icon\";\n\nimport Row from \"./Row\";\nimport Config from \"./Config\";\nimport { StyleProp, ViewStyle } from \"react-native\";\n\ntype Props = {\n title?: string;\n subtitle?: string;\n icon: string;\n style?: StyleProp<ViewStyle>;\n theme: Theme;\n} & IconSlot;\n\nconst RowBodyIcon: React.FC<Props> = ({\n Icon,\n title,\n subtitle,\n icon,\n style,\n theme: { colors, typography },\n}) => {\n return (\n <Row\n titleTypeStyle={typography.body1}\n titleColor={colors.medium}\n subtitleTypeStyle={typography.subtitle2}\n subtitleColor={colors.light}\n title={title}\n subtitle={subtitle}\n right={() => (\n <Icon\n name={icon}\n size={Config.rowSingleLineIconSize}\n color={colors.light}\n style={{ marginLeft: 16 }}\n />\n )}\n style={style}\n />\n );\n};\n\nexport default withTheme(RowBodyIcon);\n"]}
|
|
@@ -7,10 +7,10 @@ import { withTheme } from "../theming";
|
|
|
7
7
|
|
|
8
8
|
function ScreenContainer(_ref) {
|
|
9
9
|
let {
|
|
10
|
-
hasSafeArea = false,
|
|
11
10
|
scrollable = false,
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
hasSafeArea = false,
|
|
12
|
+
hasBottomSafeArea = false,
|
|
13
|
+
hasTopSafeArea = false,
|
|
14
14
|
theme,
|
|
15
15
|
style,
|
|
16
16
|
children,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ScreenContainer.tsx"],"names":["React","StyleSheet","ScrollView","View","SafeAreaView","withTheme","ScreenContainer","
|
|
1
|
+
{"version":3,"sources":["ScreenContainer.tsx"],"names":["React","StyleSheet","ScrollView","View","SafeAreaView","withTheme","ScreenContainer","scrollable","hasSafeArea","hasBottomSafeArea","hasTopSafeArea","theme","style","children","rest","backgroundColor","colors","background","edges","push","styles","container","scrollViewContainer","create","flex","flexGrow","undefined"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,UADF,EAEEC,UAFF,EAKEC,IALF,QAMO,cANP;AAOA,SAASC,YAAT,QAA6B,gCAA7B;AAEA,SAASC,SAAT,QAA0B,YAA1B;;AAaA,SAASC,eAAT,OASyB;AAAA,MATA;AACvBC,IAAAA,UAAU,GAAG,KADU;AAEvBC,IAAAA,WAAW,GAAG,KAFS;AAGvBC,IAAAA,iBAAiB,GAAG,KAHG;AAIvBC,IAAAA,cAAc,GAAG,KAJM;AAKvBC,IAAAA,KALuB;AAMvBC,IAAAA,KANuB;AAOvBC,IAAAA,QAPuB;AAQvB,OAAGC;AARoB,GASA;AACvB,QAAMC,eAAe,GAAGJ,KAAK,CAACK,MAAN,CAAaC,UAArC;AAEA,QAAMC,KAAa,GAAG,CAAC,MAAD,EAAS,OAAT,CAAtB;;AACA,MAAIV,WAAW,IAAIE,cAAnB,EAAmC;AACjCQ,IAAAA,KAAK,CAACC,IAAN,CAAW,KAAX;AACD;;AAED,MAAIX,WAAW,IAAIC,iBAAnB,EAAsC;AACpCS,IAAAA,KAAK,CAACC,IAAN,CAAW,QAAX;AACD;;AAED,sBACE,oBAAC,YAAD;AACE,IAAA,KAAK,EAAED,KADT;AAEE,IAAA,KAAK,EAAE,CACLE,MAAM,CAACC,SADF,EAEL;AACEN,MAAAA;AADF,KAFK;AAFT,KAQMD,IARN,GAUGP,UAAU,gBACT,oBAAC,UAAD;AACE,IAAA,qBAAqB,EAAE,CACrBa,MAAM,CAACE,mBADc,EAErB;AAAEP,MAAAA;AAAF,KAFqB,EAGrBH,KAHqB;AADzB,KAOGC,QAPH,CADS,gBAWT,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAE,CAACO,MAAM,CAACC,SAAR,EAAmB;AAAEN,MAAAA;AAAF,KAAnB,EAAwCH,KAAxC;AAAb,KACGC,QADH,CArBJ,CADF;AA4BD;;AAED,MAAMO,MAAM,GAAGnB,UAAU,CAACsB,MAAX,CAAkB;AAC/BF,EAAAA,SAAS,EAAE;AACTG,IAAAA,IAAI,EAAE;AADG,GADoB;AAI/BF,EAAAA,mBAAmB,EAAE;AACnBG,IAAAA,QAAQ,EAAE,CADS;AAEnBD,IAAAA,IAAI,EAAEE;AAFa;AAJU,CAAlB,CAAf;AAUA,eAAerB,SAAS,CAACC,eAAD,CAAxB","sourcesContent":["import * as React from \"react\";\nimport {\n StyleSheet,\n ScrollView,\n StyleProp,\n ViewStyle,\n View,\n} from \"react-native\";\nimport { SafeAreaView } from \"react-native-safe-area-context\";\nimport type { Edge } from \"react-native-safe-area-context\";\nimport { withTheme } from \"../theming\";\nimport type { Theme } from \"../styles/DefaultTheme\";\n\ntype ScreenContainerProps = {\n scrollable: boolean;\n hasSafeArea: boolean;\n hasTopSafeArea: boolean;\n hasBottomSafeArea: boolean;\n theme: Theme;\n style?: StyleProp<ViewStyle>;\n children?: React.ReactNode;\n};\n\nfunction ScreenContainer({\n scrollable = false,\n hasSafeArea = false,\n hasBottomSafeArea = false,\n hasTopSafeArea = false,\n theme,\n style,\n children,\n ...rest\n}: ScreenContainerProps) {\n const backgroundColor = theme.colors.background;\n\n const edges: Edge[] = [\"left\", \"right\"];\n if (hasSafeArea || hasTopSafeArea) {\n edges.push(\"top\");\n }\n\n if (hasSafeArea || hasBottomSafeArea) {\n edges.push(\"bottom\");\n }\n\n return (\n <SafeAreaView\n edges={edges}\n style={[\n styles.container,\n {\n backgroundColor,\n },\n ]}\n {...rest}\n >\n {scrollable ? (\n <ScrollView\n contentContainerStyle={[\n styles.scrollViewContainer,\n { backgroundColor },\n style,\n ]}\n >\n {children}\n </ScrollView>\n ) : (\n <View style={[styles.container, { backgroundColor }, style]}>\n {children}\n </View>\n )}\n </SafeAreaView>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n scrollViewContainer: {\n flexGrow: 1,\n flex: undefined,\n },\n});\n\nexport default withTheme(ScreenContainer);\n"]}
|
|
@@ -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","body1","textAlign","alignSelf","color","medium","marginHorizontal"],"mappings":"AAAA,OAAOA,KAAP,IAAoBC,SAApB,EAA+BC,QAA/B,QAA+C,OAA/C;AACA,SAASC,IAAT,EAAeC,IAAf,QAA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E,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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Touchable.web.
|
|
1
|
+
{"version":3,"sources":["Touchable.web.js"],"names":["TouchableOpacity"],"mappings":"AAAA,SAASA,gBAAT,QAAiC,cAAjC;AACA,eAAeA,gBAAf","sourcesContent":["import { TouchableOpacity } from \"react-native\";\nexport default TouchableOpacity;\n"]}
|
package/lib/module/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["hooks.
|
|
1
|
+
{"version":3,"sources":["hooks.js"],"names":["React","usePrevious","value","ref","useRef","useEffect","current"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAO,SAASC,WAAT,CAAqBC,KAArB,EAA4B;AAC/B;AACA;AACA,QAAMC,GAAG,GAAGH,KAAK,CAACI,MAAN,EAAZ,CAH+B,CAI/B;;AACAJ,EAAAA,KAAK,CAACK,SAAN,CAAgB,MAAM;AAClBF,IAAAA,GAAG,CAACG,OAAJ,GAAcJ,KAAd;AACH,GAFD,EAEG,CAACA,KAAD,CAFH,EAL+B,CAQ/B;;AACA,SAAOC,GAAG,CAACG,OAAX;AACH","sourcesContent":["import React from \"react\";\nexport function usePrevious(value) {\n // The ref object is a generic container whose current property is mutable\n // and can hold any value, similar to an instance property on a class\n const ref = React.useRef();\n // Store current value in ref\n React.useEffect(() => {\n ref.current = value;\n }, [value]);\n // Return previous value (happens before update in useEffect above)\n return ref.current;\n}\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
|
-
|
|
8
|
-
hasTopSafeArea
|
|
6
|
+
hasSafeArea: boolean;
|
|
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",
|
|
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": "bb5a474e9ca7c610a01542540c43e4691ebe2bea"
|
|
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
|
-
|
|
18
|
-
hasTopSafeArea
|
|
16
|
+
hasSafeArea: boolean;
|
|
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 = false,
|
|
26
25
|
scrollable = false,
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
hasSafeArea = false,
|
|
27
|
+
hasBottomSafeArea = false,
|
|
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
|
);
|