@codeleap/mobile 1.4.0 → 1.5.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/dist/components/ActivityIndicator.js +3 -4
- package/dist/components/ActivityIndicator.js.map +1 -1
- package/dist/components/Button.d.ts +1 -1
- package/dist/components/Button.js +1 -1
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Checkbox/index.js +1 -1
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/FileInput.js +2 -2
- package/dist/components/FileInput.js.map +1 -1
- package/dist/components/Icon.d.ts +2 -1
- package/dist/components/Icon.js +9 -3
- package/dist/components/Icon.js.map +1 -1
- package/dist/components/Image.d.ts +2 -1
- package/dist/components/Image.js +9 -3
- package/dist/components/Image.js.map +1 -1
- package/dist/components/Modal/styles.d.ts +1 -1
- package/dist/components/Modal/styles.js +9 -1
- package/dist/components/Modal/styles.js.map +1 -1
- package/dist/components/Navigation/Navigation.js +11 -3
- package/dist/components/Navigation/Navigation.js.map +1 -1
- package/dist/components/Navigation/types.js.map +1 -1
- package/dist/components/Navigation/utils.js +3 -0
- package/dist/components/Navigation/utils.js.map +1 -1
- package/dist/components/Overlay.js +1 -1
- package/dist/components/Overlay.js.map +1 -1
- package/dist/components/Pager/index.js +2 -2
- package/dist/components/Pager/index.js.map +1 -1
- package/dist/components/RadioInput/index.js +2 -2
- package/dist/components/RadioInput/index.js.map +1 -1
- package/dist/components/Select/index.js +10 -9
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Switch.js.map +1 -1
- package/dist/components/TextInput.d.ts +2 -0
- package/dist/components/TextInput.js +3 -3
- package/dist/components/TextInput.js.map +1 -1
- package/dist/components/Touchable.d.ts +1 -1
- package/dist/modules/documentPicker.js.map +1 -1
- package/dist/utils/OSAlert.d.ts +3 -3
- package/dist/utils/OSAlert.js +63 -10
- package/dist/utils/OSAlert.js.map +1 -1
- package/package.json +3 -1
- package/src/components/ActivityIndicator.tsx +6 -7
- package/src/components/Animated.tsx +7 -7
- package/src/components/Button.tsx +12 -14
- package/src/components/Checkbox/index.tsx +7 -6
- package/src/components/Checkbox/styles.ts +2 -2
- package/src/components/ContentView.tsx +4 -4
- package/src/components/FileInput.tsx +28 -27
- package/src/components/Icon.tsx +14 -4
- package/src/components/Image.tsx +19 -9
- package/src/components/List.tsx +7 -7
- package/src/components/Modal/index.tsx +15 -15
- package/src/components/Modal/styles.ts +18 -3
- package/src/components/Navigation/Navigation.tsx +22 -15
- package/src/components/Navigation/index.tsx +2 -2
- package/src/components/Navigation/types.ts +3 -5
- package/src/components/Navigation/utils.tsx +25 -20
- package/src/components/Overlay.tsx +9 -8
- package/src/components/Pager/index.tsx +20 -21
- package/src/components/Pager/styles.ts +1 -1
- package/src/components/RadioInput/index.tsx +17 -16
- package/src/components/RadioInput/styles.ts +3 -3
- package/src/components/Scroll.tsx +7 -7
- package/src/components/Sections.tsx +100 -0
- package/src/components/Select/index.tsx +36 -33
- package/src/components/Select/styles.ts +7 -7
- package/src/components/Select/types.ts +18 -18
- package/src/components/Slider/Mark.tsx +7 -7
- package/src/components/Slider/Thumb.tsx +1 -1
- package/src/components/Slider/index.tsx +14 -14
- package/src/components/Slider/types.ts +18 -18
- package/src/components/Switch.tsx +6 -7
- package/src/components/Text.tsx +3 -3
- package/src/components/TextInput.tsx +14 -13
- package/src/components/Touchable.tsx +7 -7
- package/src/components/View.tsx +3 -3
- package/src/modules/documentPicker.ts +3 -4
- package/src/modules/index.d.ts +82 -82
- package/src/modules/types/documentPicker.d.ts +191 -191
- package/src/modules/types/fileTypes.ts +138 -138
- package/src/types/utility.ts +1 -1
- package/src/utils/OSAlert.ts +83 -27
- package/src/utils/misc.ts +2 -2
|
@@ -53,7 +53,7 @@ var react_native_1 = require("react-native");
|
|
|
53
53
|
var Touchable_1 = require("./Touchable");
|
|
54
54
|
exports.TextInput = (0, react_1.forwardRef)(function (rawprops, inputRef) {
|
|
55
55
|
var _a;
|
|
56
|
-
var onChange = rawprops.onChange, type = rawprops.type, value = rawprops.value, onChangeText = rawprops.onChangeText, disabled = rawprops.disabled, edited = rawprops.edited, onFocus = rawprops.onFocus, onBlur = rawprops.onBlur, multiline = rawprops.multiline, variants = rawprops.variants, label = rawprops.label, leftIcon = rawprops.leftIcon, rightIcon = rawprops.rightIcon, styles = rawprops.styles, validate = rawprops.validate, password = rawprops.password, visibilityToggle = rawprops.visibilityToggle, touchableWrapper = rawprops.touchableWrapper, innerWrapperProps = rawprops.innerWrapperProps, props = __rest(rawprops, ["onChange", "type", "value", "onChangeText", "disabled", "edited", "onFocus", "onBlur", "multiline", "variants", "label", "leftIcon", "rightIcon", "styles", "validate", "password", "visibilityToggle", "touchableWrapper", "innerWrapperProps"]);
|
|
56
|
+
var onChange = rawprops.onChange, type = rawprops.type, value = rawprops.value, onChangeText = rawprops.onChangeText, disabled = rawprops.disabled, edited = rawprops.edited, onFocus = rawprops.onFocus, onBlur = rawprops.onBlur, multiline = rawprops.multiline, variants = rawprops.variants, label = rawprops.label, leftIcon = rawprops.leftIcon, rightIcon = rawprops.rightIcon, styles = rawprops.styles, validate = rawprops.validate, password = rawprops.password, visibilityToggle = rawprops.visibilityToggle, touchableWrapper = rawprops.touchableWrapper, innerWrapperProps = rawprops.innerWrapperProps, debugName = rawprops.debugName, props = __rest(rawprops, ["onChange", "type", "value", "onChangeText", "disabled", "edited", "onFocus", "onBlur", "multiline", "variants", "label", "leftIcon", "rightIcon", "styles", "validate", "password", "visibilityToggle", "touchableWrapper", "innerWrapperProps", "debugName"]);
|
|
57
57
|
var _b = (0, react_1.useState)(false), isFocused = _b[0], setFocus = _b[1];
|
|
58
58
|
var _c = (0, react_1.useState)(edited), editedState = _c[0], setEdited = _c[1];
|
|
59
59
|
var input = (0, react_1.useRef)(null);
|
|
@@ -102,7 +102,7 @@ exports.TextInput = (0, react_1.forwardRef)(function (rawprops, inputRef) {
|
|
|
102
102
|
var InnerWrapper = touchableWrapper ? Touchable_1.Touchable : View_1.View;
|
|
103
103
|
return (<View_1.View style={getStyles('wrapper')}>
|
|
104
104
|
<exports.InputLabel label={label} style={getStyles('label')}/>
|
|
105
|
-
<InnerWrapper style={getStyles('innerWrapper')} {...innerWrapperProps}>
|
|
105
|
+
<InnerWrapper debugName={debugName} style={getStyles('innerWrapper')} {...innerWrapperProps}>
|
|
106
106
|
<exports.InputIcon {...leftIcon} style={leftIconStyle}/>
|
|
107
107
|
<InputElement ref={input} secureTextEntry={password && !textIsVisible} onChange={handleChange} value={value} editable={disabled} onFocus={handleFocus} onBlur={handleBlur} placeholderTextColor={(_a = react_native_1.StyleSheet.flatten(getStyles('placeholder'))) === null || _a === void 0 ? void 0 : _a.color} {...props} style={getStyles('textField')}/>
|
|
108
108
|
{visibilityToggle ?
|
|
@@ -126,7 +126,7 @@ var InputIcon = function (_a) {
|
|
|
126
126
|
if (!name)
|
|
127
127
|
return null;
|
|
128
128
|
if (action) {
|
|
129
|
-
return <Button_1.Button icon={name} onPress={function () { return action(); }} styles={{
|
|
129
|
+
return <Button_1.Button icon={name} debugName={"".concat(name, " icon button")} onPress={function () { return action(); }} styles={{
|
|
130
130
|
icon: style,
|
|
131
131
|
}} variants={['icon']}/>;
|
|
132
132
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../src/components/TextInput.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA8B;AAC9B,2CASyB;AACzB,+BAAmG;AACnG,+BAA6B;AAC7B,+
|
|
1
|
+
{"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../src/components/TextInput.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA8B;AAC9B,2CASyB;AACzB,+BAAmG;AACnG,+BAA6B;AAC7B,+BAAwC;AACxC,mCAAiC;AAEjC,+BAA6B;AAC7B,6CAAuH;AACvH,yC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AAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IAEvB,QAAQ,OAAO,KAAK,EAAE;QACpB,KAAK,QAAQ;YACX,OAAO,CAAC,WAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,EAAG,CAAA;QAC5C,KAAK,QAAQ;YACX,OAAO,KAAK,CAAA;QACd;YACE,OAAO,IAAI,CAAA;KACd;AACH,CAAC,CAAA;AAXY,QAAA,UAAU,cAWtB"}
|
|
@@ -6,7 +6,7 @@ export declare type TouchableProps = Omit<ComponentPropsWithoutRef<typeof Native
|
|
|
6
6
|
variants?: ComponentVariants<typeof ViewStyles>['variants'];
|
|
7
7
|
component?: any;
|
|
8
8
|
ref?: React.Ref<NativeTouchable>;
|
|
9
|
-
debugName
|
|
9
|
+
debugName: string;
|
|
10
10
|
debugComponent?: string;
|
|
11
11
|
onPress?: AnyFunction;
|
|
12
12
|
} & BaseViewProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentPicker.js","sourceRoot":"","sources":["../../src/modules/documentPicker.ts"],"names":[],"mappings":";;;;;;AAAA,aAAa;AACb,
|
|
1
|
+
{"version":3,"file":"documentPicker.js","sourceRoot":"","sources":["../../src/modules/documentPicker.ts"],"names":[],"mappings":";;;;;;AAAA,aAAa;AACb,8FAA6C;AAGhC,QAAA,cAAc,GAAG,sCAAwC,CAAA;AAEtE,iFAA2E;AAAlE,kJAAA,OAAO,OAAmB"}
|
package/dist/utils/OSAlert.d.ts
CHANGED
|
@@ -19,9 +19,9 @@ declare type OSAlertArgs = {
|
|
|
19
19
|
declare type AlertEvent = AlertButton['onPress'];
|
|
20
20
|
declare type NamedEvents<E extends string> = Partial<Record<E, AlertEvent>>;
|
|
21
21
|
declare function ask({ title, body, options }: OSAlertArgs): void;
|
|
22
|
-
declare function warn(
|
|
23
|
-
declare function info(
|
|
24
|
-
declare function OSError(
|
|
22
|
+
declare function warn(args: OSAlertArgs & NamedEvents<'onReject' | 'onAccept'>): void;
|
|
23
|
+
declare function info(args: OSAlertArgs & NamedEvents<'onDismiss'>): void;
|
|
24
|
+
declare function OSError(args: OSAlertArgs & NamedEvents<'onDismiss'>): void;
|
|
25
25
|
declare const _default: {
|
|
26
26
|
ask: typeof ask;
|
|
27
27
|
warn: typeof warn;
|
package/dist/utils/OSAlert.js
CHANGED
|
@@ -1,7 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
/* eslint no-restricted-imports: 'off' */
|
|
15
|
+
/* eslint prefer-const: 'off' */
|
|
4
16
|
var react_native_1 = require("react-native");
|
|
17
|
+
var currentAlerts = {};
|
|
18
|
+
function generateAlertID(from) {
|
|
19
|
+
return [
|
|
20
|
+
from.type,
|
|
21
|
+
from.title,
|
|
22
|
+
from.body,
|
|
23
|
+
].join('-');
|
|
24
|
+
}
|
|
25
|
+
function shouldShowAlert(args, type) {
|
|
26
|
+
var alertId = generateAlertID(__assign(__assign({}, args), { type: type }));
|
|
27
|
+
if (!Object.keys(currentAlerts).includes(alertId)) {
|
|
28
|
+
currentAlerts[alertId] = true;
|
|
29
|
+
return alertId;
|
|
30
|
+
}
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
function popAlert(id) {
|
|
34
|
+
delete currentAlerts[id];
|
|
35
|
+
}
|
|
5
36
|
function ask(_a) {
|
|
6
37
|
var title = _a.title, body = _a.body, _b = _a.options, options = _b === void 0 ? null : _b;
|
|
7
38
|
if (!title) {
|
|
@@ -13,8 +44,11 @@ function ask(_a) {
|
|
|
13
44
|
options: options,
|
|
14
45
|
});
|
|
15
46
|
}
|
|
16
|
-
function warn(
|
|
17
|
-
var
|
|
47
|
+
function warn(args) {
|
|
48
|
+
var id = shouldShowAlert(args, 'warn');
|
|
49
|
+
if (!id)
|
|
50
|
+
return;
|
|
51
|
+
var title = args.title, body = args.body, onAccept = args.onAccept, onReject = args.onReject;
|
|
18
52
|
if (!title) {
|
|
19
53
|
title = 'Hang on';
|
|
20
54
|
}
|
|
@@ -30,18 +64,27 @@ function warn(_a) {
|
|
|
30
64
|
options: [
|
|
31
65
|
{
|
|
32
66
|
text: 'Cancel',
|
|
33
|
-
onPress:
|
|
67
|
+
onPress: function () {
|
|
68
|
+
popAlert(id);
|
|
69
|
+
onReject();
|
|
70
|
+
},
|
|
34
71
|
},
|
|
35
72
|
{
|
|
36
73
|
text: 'OK',
|
|
37
74
|
style: 'destructive',
|
|
38
|
-
onPress:
|
|
75
|
+
onPress: function () {
|
|
76
|
+
popAlert(id);
|
|
77
|
+
onAccept === null || onAccept === void 0 ? void 0 : onAccept();
|
|
78
|
+
},
|
|
39
79
|
},
|
|
40
80
|
],
|
|
41
81
|
});
|
|
42
82
|
}
|
|
43
|
-
function info(
|
|
44
|
-
var
|
|
83
|
+
function info(args) {
|
|
84
|
+
var id = shouldShowAlert(args, 'info');
|
|
85
|
+
if (!id)
|
|
86
|
+
return;
|
|
87
|
+
var title = args.title, body = args.body, _a = args.onDismiss, onDismiss = _a === void 0 ? function () { return null; } : _a;
|
|
45
88
|
if (!title) {
|
|
46
89
|
title = 'FYI';
|
|
47
90
|
}
|
|
@@ -51,13 +94,19 @@ function info(_a) {
|
|
|
51
94
|
options: [
|
|
52
95
|
{
|
|
53
96
|
text: 'OK',
|
|
54
|
-
onPress:
|
|
97
|
+
onPress: function () {
|
|
98
|
+
popAlert(id);
|
|
99
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
100
|
+
},
|
|
55
101
|
},
|
|
56
102
|
],
|
|
57
103
|
});
|
|
58
104
|
}
|
|
59
|
-
function OSError(
|
|
60
|
-
var
|
|
105
|
+
function OSError(args) {
|
|
106
|
+
var id = shouldShowAlert(args, 'error');
|
|
107
|
+
if (!id)
|
|
108
|
+
return;
|
|
109
|
+
var title = args.title, body = args.body;
|
|
61
110
|
if (!title) {
|
|
62
111
|
title = 'Whoops!';
|
|
63
112
|
}
|
|
@@ -70,7 +119,11 @@ function OSError(_a) {
|
|
|
70
119
|
options: [
|
|
71
120
|
{
|
|
72
121
|
text: 'OK',
|
|
73
|
-
onPress: function () {
|
|
122
|
+
onPress: function () {
|
|
123
|
+
var _a;
|
|
124
|
+
popAlert(id);
|
|
125
|
+
(_a = args === null || args === void 0 ? void 0 : args.onDismiss) === null || _a === void 0 ? void 0 : _a.call(args);
|
|
126
|
+
},
|
|
74
127
|
},
|
|
75
128
|
],
|
|
76
129
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OSAlert.js","sourceRoot":"","sources":["../../src/utils/OSAlert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OSAlert.js","sourceRoot":"","sources":["../../src/utils/OSAlert.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,yCAAyC;AACzC,gCAAgC;AAChC,6CAAiD;AAyBjD,IAAM,aAAa,GAAG,EAErB,CAAA;AAED,SAAS,eAAe,CAAC,IAAsC;IAC7D,OAAO;QACL,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,IAAI;KACV,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACb,CAAC;AAED,SAAS,eAAe,CAAC,IAAgB,EAAE,IAAiB;IAC1D,IAAM,OAAO,GAAG,eAAe,uBAAM,IAAI,KAAE,IAAI,MAAA,IAAG,CAAA;IAElD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,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AAQ,CAAC,EAAE,CAAC,CAAA;oBACZ,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,+CAAf,IAAI,CAAe,CAAA;gBACrB,CAAC;aACF;SACF;KACF,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,MAAmB;IAClC,oBAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE;QACrD,UAAU,EAAE,KAAK;KAClB,CAAC,CAAA;AACJ,CAAC;AAED,kBAAe;IACb,GAAG,KAAA;IACH,IAAI,MAAA;IACJ,IAAI,MAAA;IACJ,KAAK,EAAE,OAAO;CACf,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeleap/mobile",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"repository": "git@github.com:codeleap-uk/codeleap-lib.git",
|
|
6
6
|
"author": "Paulo Henrique De Souza <paulosouza300272@gmail.com>",
|
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@miblanchard/react-native-slider": "^2.1.0",
|
|
34
|
+
"lottie-ios": "3.2.3",
|
|
35
|
+
"lottie-react-native": "^5.0.1",
|
|
34
36
|
"react-native-animatable": "^1.3.3",
|
|
35
37
|
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
36
38
|
"react-native-pose": "^0.9.1"
|
|
@@ -13,9 +13,9 @@ import { StylesOf } from '../types/utility'
|
|
|
13
13
|
export type ActivityIndicatorProps = ComponentPropsWithoutRef<
|
|
14
14
|
typeof Indicator
|
|
15
15
|
> & {
|
|
16
|
-
variants?: ComponentVariants<typeof ActivityIndicatorStyles>['variants']
|
|
17
|
-
styles?: StylesOf<ActivityIndicatorComposition
|
|
18
|
-
}
|
|
16
|
+
variants?: ComponentVariants<typeof ActivityIndicatorStyles>['variants']
|
|
17
|
+
styles?: StylesOf<ActivityIndicatorComposition>
|
|
18
|
+
}
|
|
19
19
|
|
|
20
20
|
export const ActivityIndicator = forwardRef<Indicator, ActivityIndicatorProps>(
|
|
21
21
|
(activityIndicatorProps, ref) => {
|
|
@@ -29,11 +29,10 @@ export const ActivityIndicator = forwardRef<Indicator, ActivityIndicatorProps>(
|
|
|
29
29
|
|
|
30
30
|
const { Theme } = useCodeleapContext()
|
|
31
31
|
|
|
32
|
-
const color = variantStyles.wrapper?.color || Theme.colors.gray
|
|
33
|
-
const size = variantStyles.wrapper?.height || variantStyles.wrapper?.width || 'large'
|
|
34
|
-
|
|
35
32
|
const styles = StyleSheet.flatten([variantStyles.wrapper, style])
|
|
36
|
-
|
|
33
|
+
const color = styles?.color || Theme.colors.gray
|
|
34
|
+
const size = styles?.height || styles?.width || 'large'
|
|
35
|
+
|
|
37
36
|
return (
|
|
38
37
|
<Indicator
|
|
39
38
|
size={size}
|
|
@@ -13,15 +13,15 @@ const PosedComponents = Object.fromEntries(
|
|
|
13
13
|
Object.entries(Components).map(([key, Render]) => [key, posed(Render)]),
|
|
14
14
|
)
|
|
15
15
|
|
|
16
|
-
type AnimatedComponents = typeof Components
|
|
17
|
-
type CP = keyof AnimatedComponents
|
|
16
|
+
type AnimatedComponents = typeof Components
|
|
17
|
+
type CP = keyof AnimatedComponents
|
|
18
18
|
|
|
19
19
|
type AnimatedProps<T extends CP, CFG = Record<string, any>> = {
|
|
20
|
-
component: T
|
|
21
|
-
config: CFG
|
|
22
|
-
pose: keyof CFG
|
|
23
|
-
initialPose?: keyof CFG
|
|
24
|
-
} & Omit<Parameters<AnimatedComponents[T]>[0], 'component'
|
|
20
|
+
component: T
|
|
21
|
+
config: CFG
|
|
22
|
+
pose: keyof CFG
|
|
23
|
+
initialPose?: keyof CFG
|
|
24
|
+
} & Omit<Parameters<AnimatedComponents[T]>[0], 'component'>
|
|
25
25
|
|
|
26
26
|
export const Animated = <T extends CP, CFG = any>({
|
|
27
27
|
config,
|
|
@@ -15,17 +15,16 @@ import { Icon } from './Icon'
|
|
|
15
15
|
import { ActivityIndicator } from './ActivityIndicator'
|
|
16
16
|
import { StyleSheet, TouchableOpacity } from 'react-native'
|
|
17
17
|
|
|
18
|
-
|
|
19
18
|
export type ButtonProps = Omit<TouchableProps, 'variants'> &
|
|
20
19
|
ComponentVariants<typeof ButtonStyles> & {
|
|
21
|
-
text?: string
|
|
22
|
-
rightIcon?: IconPlaceholder
|
|
23
|
-
icon?: IconPlaceholder
|
|
24
|
-
styles?: StylesOf<ButtonComposition
|
|
25
|
-
loading?: boolean
|
|
20
|
+
text?: string
|
|
21
|
+
rightIcon?: IconPlaceholder
|
|
22
|
+
icon?: IconPlaceholder
|
|
23
|
+
styles?: StylesOf<ButtonComposition>
|
|
24
|
+
loading?: boolean
|
|
26
25
|
debounce?: number
|
|
27
|
-
debugName
|
|
28
|
-
}
|
|
26
|
+
debugName: string
|
|
27
|
+
}
|
|
29
28
|
|
|
30
29
|
export const Button = forwardRef<TouchableOpacity, ButtonProps>((buttonProps, ref) => {
|
|
31
30
|
const {
|
|
@@ -43,7 +42,6 @@ export const Button = forwardRef<TouchableOpacity, ButtonProps>((buttonProps, re
|
|
|
43
42
|
} = buttonProps
|
|
44
43
|
const [pressed, setPressed] = React.useState(false)
|
|
45
44
|
|
|
46
|
-
|
|
47
45
|
const variantStyles = useDefaultComponentStyle('Button', {
|
|
48
46
|
variants,
|
|
49
47
|
transform: StyleSheet.flatten,
|
|
@@ -51,11 +49,11 @@ export const Button = forwardRef<TouchableOpacity, ButtonProps>((buttonProps, re
|
|
|
51
49
|
})
|
|
52
50
|
|
|
53
51
|
function handlePress() {
|
|
54
|
-
if (!pressed){
|
|
55
|
-
setPressed(true)
|
|
52
|
+
if (!pressed) {
|
|
53
|
+
setPressed(true)
|
|
56
54
|
|
|
57
55
|
setTimeout(() => setPressed(false), debounce)
|
|
58
|
-
|
|
56
|
+
|
|
59
57
|
onPress && onPress()
|
|
60
58
|
}
|
|
61
59
|
}
|
|
@@ -73,7 +71,7 @@ export const Button = forwardRef<TouchableOpacity, ButtonProps>((buttonProps, re
|
|
|
73
71
|
|
|
74
72
|
const leftIconStyle = StyleSheet.flatten([iconStyle, getStyles('leftIcon')])
|
|
75
73
|
const rightIconStyle = StyleSheet.flatten([iconStyle, getStyles('rightIcon')])
|
|
76
|
-
|
|
74
|
+
|
|
77
75
|
const hasText = !!(text || children)
|
|
78
76
|
return (
|
|
79
77
|
<Touchable
|
|
@@ -84,7 +82,7 @@ export const Button = forwardRef<TouchableOpacity, ButtonProps>((buttonProps, re
|
|
|
84
82
|
debugComponent={'Button'}
|
|
85
83
|
{...props}
|
|
86
84
|
>
|
|
87
|
-
|
|
85
|
+
|
|
88
86
|
{loading && <ActivityIndicator style={getStyles('loader')} />}
|
|
89
87
|
{!loading && <Icon name={icon} style={leftIconStyle} renderEmptySpace={hasText}/>}
|
|
90
88
|
{text ? <Text text={text} style={getStyles('text')} /> : null}
|
|
@@ -20,13 +20,13 @@ export * from './styles'
|
|
|
20
20
|
type NativeCheckboxProps = Omit<
|
|
21
21
|
ComponentPropsWithRef<typeof NativeCheckbox>,
|
|
22
22
|
'thumbColor' | 'trackColor'
|
|
23
|
-
|
|
23
|
+
>
|
|
24
24
|
type CheckboxProps = NativeCheckboxProps & {
|
|
25
|
-
variants?: ComponentVariants<typeof CheckboxStyles>['variants']
|
|
26
|
-
label?: ReactNode
|
|
27
|
-
styles?: StylesOf<CheckboxComposition
|
|
28
|
-
validate?: Form.ValidatorFunctionWithoutForm | string
|
|
29
|
-
}
|
|
25
|
+
variants?: ComponentVariants<typeof CheckboxStyles>['variants']
|
|
26
|
+
label?: ReactNode
|
|
27
|
+
styles?: StylesOf<CheckboxComposition>
|
|
28
|
+
validate?: Form.ValidatorFunctionWithoutForm | string
|
|
29
|
+
}
|
|
30
30
|
|
|
31
31
|
export const Checkbox = forwardRef<NativeCheckbox, CheckboxProps>(
|
|
32
32
|
(checkboxProps, ref) => {
|
|
@@ -65,6 +65,7 @@ export const Checkbox = forwardRef<NativeCheckbox, CheckboxProps>(
|
|
|
65
65
|
return (
|
|
66
66
|
<View style={getStyles('wrapper')} {...props}>
|
|
67
67
|
<Touchable
|
|
68
|
+
debugName={`Set checkbox value to ${!value}`}
|
|
68
69
|
style={getStyles('input')}
|
|
69
70
|
onPress={() => onValueChange(!value)}
|
|
70
71
|
>
|
|
@@ -6,13 +6,13 @@ type CheckboxParts =
|
|
|
6
6
|
| 'input'
|
|
7
7
|
| 'checkmark'
|
|
8
8
|
| 'checkmarkWrapper'
|
|
9
|
-
| 'error'
|
|
9
|
+
| 'error'
|
|
10
10
|
|
|
11
11
|
export type MobileCheckboxComposition =
|
|
12
12
|
| CheckboxParts
|
|
13
13
|
| `${CheckboxParts}:checked`
|
|
14
14
|
| `${CheckboxParts}:disabled`
|
|
15
|
-
| `${CheckboxParts}:error
|
|
15
|
+
| `${CheckboxParts}:error`
|
|
16
16
|
const createCheckboxStyle =
|
|
17
17
|
createDefaultVariantFactory<MobileCheckboxComposition>()
|
|
18
18
|
|
|
@@ -15,10 +15,10 @@ export type ContentViewProps = Omit<
|
|
|
15
15
|
ViewProps,
|
|
16
16
|
'variants' | 'responsiveVariants'
|
|
17
17
|
> & {
|
|
18
|
-
placeholderMsg: string
|
|
19
|
-
loading?: boolean
|
|
20
|
-
styles?: StylesOf<ViewComposition
|
|
21
|
-
} & ComponentVariants<typeof ContentViewStyles
|
|
18
|
+
placeholderMsg: string
|
|
19
|
+
loading?: boolean
|
|
20
|
+
styles?: StylesOf<ViewComposition>
|
|
21
|
+
} & ComponentVariants<typeof ContentViewStyles>
|
|
22
22
|
|
|
23
23
|
const WrapContent = ({ children, ...props }) => (
|
|
24
24
|
<View {...props}>{children}</View>
|
|
@@ -19,24 +19,24 @@ import { Options } from 'react-native-image-crop-picker'
|
|
|
19
19
|
import { DocumentPickerOptions } from '../modules/types/documentPicker'
|
|
20
20
|
|
|
21
21
|
export type FileInputRef = {
|
|
22
|
-
openFilePicker: () => void
|
|
23
|
-
}
|
|
22
|
+
openFilePicker: () => void
|
|
23
|
+
}
|
|
24
24
|
|
|
25
25
|
export type FileInputProps = {
|
|
26
|
-
label?: string
|
|
27
|
-
iconName?: IconPlaceholder
|
|
28
|
-
styles?: StylesOf<FileInputComposition
|
|
29
|
-
mode: 'hidden' | 'button'
|
|
30
|
-
variants?: ComponentVariants<typeof FileInputStyles>['variants']
|
|
31
|
-
onFileSelect(files: MobileInputFile[]): void
|
|
32
|
-
options?: DocumentPickerOptions<any
|
|
33
|
-
buttonProps?: ButtonProps
|
|
34
|
-
ref?: FileInputRef
|
|
26
|
+
label?: string
|
|
27
|
+
iconName?: IconPlaceholder
|
|
28
|
+
styles?: StylesOf<FileInputComposition>
|
|
29
|
+
mode: 'hidden' | 'button'
|
|
30
|
+
variants?: ComponentVariants<typeof FileInputStyles>['variants']
|
|
31
|
+
onFileSelect(files: MobileInputFile[]): void
|
|
32
|
+
options?: DocumentPickerOptions<any>
|
|
33
|
+
buttonProps?: ButtonProps
|
|
34
|
+
ref?: FileInputRef
|
|
35
35
|
placeholder?: string
|
|
36
36
|
type?: 'image' | 'anyFile'
|
|
37
37
|
alertProps?: Parameters<typeof OSAlert.ask>[0]
|
|
38
38
|
pickerOptions?: Partial<Options>
|
|
39
|
-
}
|
|
39
|
+
}
|
|
40
40
|
|
|
41
41
|
const pickerDefaults = {
|
|
42
42
|
width: 300,
|
|
@@ -54,7 +54,7 @@ function parsePickerData(data:any):MobileInputFile {
|
|
|
54
54
|
uri: data.path,
|
|
55
55
|
fileCopyUri: data.path,
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
return {
|
|
59
59
|
file: d,
|
|
60
60
|
preview: data.path,
|
|
@@ -84,7 +84,7 @@ export const FileInput = forwardRef<
|
|
|
84
84
|
|
|
85
85
|
const { logger } = useCodeleapContext()
|
|
86
86
|
|
|
87
|
-
async function openFileSystem(){
|
|
87
|
+
async function openFileSystem() {
|
|
88
88
|
try {
|
|
89
89
|
let files = await DocumentPicker.pick(options)
|
|
90
90
|
if (!Array.isArray(files)) {
|
|
@@ -101,30 +101,25 @@ export const FileInput = forwardRef<
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
const mergedOptions
|
|
104
|
+
const mergedOptions = {
|
|
105
105
|
...pickerDefaults,
|
|
106
106
|
...pickerOptions,
|
|
107
107
|
} as Options
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
const handlePickerResolution = data => {
|
|
110
|
-
onFileSelect(mergedOptions.multiple ? data.map(parsePickerData)
|
|
110
|
+
onFileSelect(mergedOptions.multiple ? data.map(parsePickerData) : [
|
|
111
111
|
parsePickerData(data),
|
|
112
112
|
])
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
const openFilePicker = async () => {
|
|
116
|
-
|
|
117
|
-
if (type === 'image'){
|
|
116
|
+
|
|
117
|
+
if (type === 'image') {
|
|
118
118
|
OSAlert.ask({
|
|
119
119
|
title: 'Change Image',
|
|
120
120
|
body: 'Do you want to take a new picture or select an existing one?',
|
|
121
121
|
...alertProps,
|
|
122
122
|
options: [
|
|
123
|
-
{
|
|
124
|
-
text: 'Cancel',
|
|
125
|
-
onPress: () => {},
|
|
126
|
-
...alertProps?.options[0],
|
|
127
|
-
},
|
|
128
123
|
{
|
|
129
124
|
text: alertProps?.options?.[0]?.text || 'Camera',
|
|
130
125
|
onPress: () => {
|
|
@@ -136,17 +131,22 @@ export const FileInput = forwardRef<
|
|
|
136
131
|
text: 'Library',
|
|
137
132
|
onPress: () => {
|
|
138
133
|
ImageCropPicker.openPicker(mergedOptions).then(handlePickerResolution)
|
|
139
|
-
|
|
140
134
|
},
|
|
141
135
|
...alertProps?.options[2],
|
|
142
136
|
},
|
|
143
|
-
|
|
137
|
+
{
|
|
138
|
+
text: 'Cancel',
|
|
139
|
+
style: 'cancel',
|
|
140
|
+
onPress: () => {},
|
|
141
|
+
...alertProps?.options[0],
|
|
142
|
+
},
|
|
143
|
+
|
|
144
144
|
],
|
|
145
145
|
})
|
|
146
146
|
} else {
|
|
147
147
|
openFileSystem()
|
|
148
148
|
}
|
|
149
|
-
|
|
149
|
+
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
const variantStyles = useDefaultComponentStyle('FileInput', {
|
|
@@ -166,6 +166,7 @@ export const FileInput = forwardRef<
|
|
|
166
166
|
<Button
|
|
167
167
|
onPress={() => openFilePicker()}
|
|
168
168
|
text={filenames || placeholder}
|
|
169
|
+
debugName={'Open file picker'}
|
|
169
170
|
icon={iconName || ('fileInputButton' as IconPlaceholder)}
|
|
170
171
|
variants={filenames ? '' : 'icon'}
|
|
171
172
|
{...buttonProps}
|
package/src/components/Icon.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
IconStyles,
|
|
6
6
|
useDefaultComponentStyle,
|
|
7
7
|
useCodeleapContext,
|
|
8
|
+
arePropsEqual,
|
|
8
9
|
} from '@codeleap/common'
|
|
9
10
|
import { StyleSheet } from 'react-native'
|
|
10
11
|
import { View } from './View'
|
|
@@ -16,11 +17,11 @@ export type IconProps = {
|
|
|
16
17
|
variants?: ComponentVariants<typeof IconStyles>['variants']
|
|
17
18
|
renderEmptySpace?: boolean
|
|
18
19
|
size?: number
|
|
19
|
-
}
|
|
20
|
+
}
|
|
20
21
|
|
|
21
|
-
export const
|
|
22
|
+
export const IconComponent: React.FC<IconProps> = ({ name, style, variants, renderEmptySpace, ...otherProps }) => {
|
|
22
23
|
const { Theme, logger } = useCodeleapContext()
|
|
23
|
-
|
|
24
|
+
|
|
24
25
|
const variantStyles = useDefaultComponentStyle('Icon', {
|
|
25
26
|
variants,
|
|
26
27
|
transform: StyleSheet.flatten,
|
|
@@ -29,7 +30,7 @@ export const Icon: React.FC<IconProps> = ({ name, style, variants, renderEmptySp
|
|
|
29
30
|
},
|
|
30
31
|
rootElement: 'icon',
|
|
31
32
|
})
|
|
32
|
-
|
|
33
|
+
|
|
33
34
|
if (!name) {
|
|
34
35
|
return renderEmptySpace ? <View style={variantStyles.icon}/> : null
|
|
35
36
|
}
|
|
@@ -46,3 +47,12 @@ export const Icon: React.FC<IconProps> = ({ name, style, variants, renderEmptySp
|
|
|
46
47
|
}
|
|
47
48
|
return <Component {...otherProps} style={variantStyles.icon} />
|
|
48
49
|
}
|
|
50
|
+
|
|
51
|
+
function areEqual(prevProps, nextProps) {
|
|
52
|
+
const check = ['name', 'style', 'variants', 'renderEmptySpace']
|
|
53
|
+
const res = arePropsEqual(prevProps, nextProps, { check })
|
|
54
|
+
return res
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const Icon = React.memo(IconComponent, areEqual)
|
|
58
|
+
|
package/src/components/Image.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
ImageStyles,
|
|
5
5
|
MobileInputFile,
|
|
6
6
|
useDefaultComponentStyle,
|
|
7
|
+
arePropsEqual,
|
|
7
8
|
} from '@codeleap/common'
|
|
8
9
|
import { ComponentPropsWithoutRef } from 'react'
|
|
9
10
|
import {
|
|
@@ -15,21 +16,21 @@ import {
|
|
|
15
16
|
} from 'react-native'
|
|
16
17
|
import { FastImage } from '../modules/fastImage'
|
|
17
18
|
|
|
18
|
-
type NativeImageProps = ComponentPropsWithoutRef<typeof NativeImage
|
|
19
|
+
type NativeImageProps = ComponentPropsWithoutRef<typeof NativeImage>
|
|
19
20
|
export type ImageProps = Omit<NativeImageProps, 'source' | 'style'> & {
|
|
20
|
-
variants?: ComponentVariants<typeof ImageStyles>['variants']
|
|
21
|
-
fast?: boolean
|
|
22
|
-
style?: StyleProp<ImageStyle | TextStyle | ViewStyle
|
|
21
|
+
variants?: ComponentVariants<typeof ImageStyles>['variants']
|
|
22
|
+
fast?: boolean
|
|
23
|
+
style?: StyleProp<ImageStyle | TextStyle | ViewStyle>
|
|
23
24
|
source:
|
|
24
25
|
| (NativeImageProps['source'] & {
|
|
25
|
-
priority?: keyof typeof FastImage.priority
|
|
26
|
+
priority?: keyof typeof FastImage.priority
|
|
26
27
|
})
|
|
27
28
|
| MobileInputFile
|
|
28
|
-
| string
|
|
29
|
-
resizeMode?: keyof typeof FastImage.resizeMode
|
|
30
|
-
}
|
|
29
|
+
| string
|
|
30
|
+
resizeMode?: keyof typeof FastImage.resizeMode
|
|
31
|
+
}
|
|
31
32
|
|
|
32
|
-
export const
|
|
33
|
+
export const ImageComponent: React.FC<ImageProps> = (props) => {
|
|
33
34
|
const { variants, style, fast = true, resizeMode = 'contain', ...imageProps } = props
|
|
34
35
|
|
|
35
36
|
const variantStyles = useDefaultComponentStyle('Image', { variants })
|
|
@@ -47,3 +48,12 @@ export const Image: React.FC<ImageProps> = (props) => {
|
|
|
47
48
|
}
|
|
48
49
|
return <NativeImage style={styles} resizeMode={resizeMode} {...(imageProps as any)} />
|
|
49
50
|
}
|
|
51
|
+
|
|
52
|
+
function areEqual(prevProps, nextProps) {
|
|
53
|
+
const check = ['source', 'style', 'variants', 'resizeMode', 'fast']
|
|
54
|
+
const res = arePropsEqual(prevProps, nextProps, { check })
|
|
55
|
+
return res
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const Image = React.memo(ImageComponent, areEqual)
|
|
59
|
+
|