atlas-design-system 1.3.1 → 1.4.1
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/BottomSheet/BottomSheet.d.ts +11 -0
- package/dist/components/BottomSheet/BottomSheet.js +98 -0
- package/dist/components/DateTimeInput/index.d.ts +2 -2
- package/dist/components/DateTimeInput/index.js +27 -16
- package/dist/components/FieldError/FieldError.d.ts +5 -0
- package/dist/components/FieldError/FieldError.js +22 -0
- package/dist/components/Forms/Form/Form.d.ts +5 -0
- package/dist/components/Forms/Form/Form.js +28 -0
- package/dist/components/Forms/Form/index.d.ts +1 -0
- package/dist/components/Forms/Form/index.js +17 -0
- package/dist/components/Forms/FormDateTimeInput/FormDateTimeInput.d.ts +4 -0
- package/dist/components/Forms/FormDateTimeInput/FormDateTimeInput.js +13 -0
- package/dist/components/Forms/FormDateTimeInput/index.d.ts +1 -0
- package/dist/components/Forms/FormDateTimeInput/index.js +17 -0
- package/dist/components/Forms/FormSelectInput/FormSelectInput.d.ts +3 -0
- package/dist/components/Forms/FormSelectInput/FormSelectInput.js +24 -0
- package/dist/components/Forms/FormSelectInput/index.d.ts +1 -0
- package/dist/components/Forms/FormSelectInput/index.js +17 -0
- package/dist/components/Forms/FormSwitchToggle/FormSwitchToggle.d.ts +4 -0
- package/dist/components/Forms/FormSwitchToggle/FormSwitchToggle.js +12 -0
- package/dist/components/Forms/FormSwitchToggle/index.d.ts +1 -0
- package/dist/components/Forms/FormSwitchToggle/index.js +17 -0
- package/dist/components/Forms/FormTextInput/FormTextInput.d.ts +4 -0
- package/dist/components/Forms/FormTextInput/FormTextInput.js +19 -0
- package/dist/components/Forms/FormTextInput/index.d.ts +1 -0
- package/dist/components/Forms/FormTextInput/index.js +17 -0
- package/dist/components/Forms/index.d.ts +5 -0
- package/dist/components/Forms/index.js +21 -0
- package/dist/components/SelectInput/SelectInput.d.ts +3 -2
- package/dist/components/SelectInput/SelectInput.js +21 -14
- package/dist/components/SwitchToggle/index.d.ts +2 -1
- package/dist/components/SwitchToggle/index.js +39 -6
- package/dist/components/TextInput/TextInput.d.ts +2 -0
- package/dist/components/TextInput/TextInput.js +90 -45
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +2 -0
- package/dist/constants/animations.d.ts +5 -0
- package/dist/constants/animations.js +9 -0
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/useInputFieldAnimatedBorder.d.ts +6 -0
- package/dist/hooks/useInputFieldAnimatedBorder.js +22 -0
- package/dist/hooks/usePrevious.d.ts +1 -0
- package/dist/hooks/usePrevious.js +16 -0
- package/dist/shared/styles/index.d.ts +2 -0
- package/dist/shared/styles/index.js +2 -0
- package/package.json +12 -10
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type Props = {
|
|
3
|
+
open: boolean;
|
|
4
|
+
setOpen: (open: boolean) => void;
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
defaultMargins?: boolean;
|
|
7
|
+
transparent?: boolean;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const BottomSheet: ({ open, children, height, setOpen }: Props) => React.JSX.Element | null;
|
|
11
|
+
export default BottomSheet;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.BottomSheet = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const react_native_1 = require("react-native");
|
|
29
|
+
const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
|
|
30
|
+
const react_native_safe_area_context_1 = require("react-native-safe-area-context");
|
|
31
|
+
const hooks_1 = require("../../hooks");
|
|
32
|
+
const DEFAULT_EASING = react_native_reanimated_1.Easing.bezier(0.5, 0, 0, 0.75);
|
|
33
|
+
const BottomSheet = ({ open, children, height, setOpen }) => {
|
|
34
|
+
const styles = useStyles(height).styles;
|
|
35
|
+
const { height: deviceHeight } = (0, react_native_1.useWindowDimensions)();
|
|
36
|
+
const [visible, setVisible] = (0, react_1.useState)(open);
|
|
37
|
+
const position = (0, react_native_reanimated_1.useSharedValue)(deviceHeight);
|
|
38
|
+
(0, react_1.useEffect)(() => {
|
|
39
|
+
if (!open) {
|
|
40
|
+
position.value = (0, react_native_reanimated_1.withTiming)(height, {
|
|
41
|
+
duration: 200,
|
|
42
|
+
easing: DEFAULT_EASING,
|
|
43
|
+
}, () => {
|
|
44
|
+
(0, react_native_reanimated_1.runOnJS)(setVisible)(false);
|
|
45
|
+
});
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
setVisible(true);
|
|
49
|
+
}, [open]);
|
|
50
|
+
(0, react_1.useEffect)(() => {
|
|
51
|
+
if (!visible) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
position.value = (0, react_native_reanimated_1.withTiming)(0, {
|
|
55
|
+
duration: 250,
|
|
56
|
+
easing: DEFAULT_EASING,
|
|
57
|
+
});
|
|
58
|
+
}, [visible]);
|
|
59
|
+
const animatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
60
|
+
return {
|
|
61
|
+
transform: [{ translateY: position.value }],
|
|
62
|
+
};
|
|
63
|
+
}, [position]);
|
|
64
|
+
// // Don't render anything if it's not visible
|
|
65
|
+
if (!visible) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return (<react_native_1.Modal transparent visible>
|
|
69
|
+
<react_native_1.Pressable onPress={() => {
|
|
70
|
+
setOpen(false);
|
|
71
|
+
console.log("tests");
|
|
72
|
+
}} style={styles.wrapper}></react_native_1.Pressable>
|
|
73
|
+
<react_native_reanimated_1.default.View style={[styles.sheet, animatedStyle]}>
|
|
74
|
+
{children}
|
|
75
|
+
</react_native_reanimated_1.default.View>
|
|
76
|
+
</react_native_1.Modal>);
|
|
77
|
+
};
|
|
78
|
+
exports.BottomSheet = BottomSheet;
|
|
79
|
+
exports.default = exports.BottomSheet;
|
|
80
|
+
const useStyles = (height) => {
|
|
81
|
+
const bottom = (0, react_native_safe_area_context_1.useSafeAreaInsets)().bottom;
|
|
82
|
+
return (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((theme) => react_native_1.StyleSheet.create({
|
|
83
|
+
wrapper: {
|
|
84
|
+
height: "100%",
|
|
85
|
+
bottom: 0,
|
|
86
|
+
width: "100%",
|
|
87
|
+
position: "absolute",
|
|
88
|
+
},
|
|
89
|
+
sheet: {
|
|
90
|
+
height: "40%",
|
|
91
|
+
bottom: 0,
|
|
92
|
+
position: "absolute",
|
|
93
|
+
alignSelf: "center",
|
|
94
|
+
width: "100%",
|
|
95
|
+
backgroundColor: theme.colors.backgroundPrimary,
|
|
96
|
+
},
|
|
97
|
+
}), [bottom, height]));
|
|
98
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { IOSNativeProps, AndroidNativeProps } from '@react-native-community/datetimepicker';
|
|
3
2
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
4
3
|
export type DateTimeInputProps = {
|
|
@@ -11,6 +10,7 @@ export type DateTimeInputProps = {
|
|
|
11
10
|
testID?: string;
|
|
12
11
|
containerStyle?: StyleProp<ViewStyle>;
|
|
13
12
|
mode?: IOSNativeProps['mode'] | AndroidNativeProps['mode'];
|
|
13
|
+
error?: string;
|
|
14
14
|
};
|
|
15
|
-
export declare const DateTimeInput: ({ value, onChange, testID, containerStyle, label, caption, mode, disabled, onSave, }: DateTimeInputProps) =>
|
|
15
|
+
export declare const DateTimeInput: ({ value, onChange, testID, containerStyle, label, caption, mode, error, disabled, onSave, }: DateTimeInputProps) => import("react").JSX.Element;
|
|
16
16
|
export default DateTimeInput;
|
|
@@ -27,17 +27,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.DateTimeInput = void 0;
|
|
30
|
-
const react_1 =
|
|
30
|
+
const react_1 = require("react");
|
|
31
31
|
const datetimepicker_1 = __importDefault(require("@react-native-community/datetimepicker"));
|
|
32
32
|
const react_native_1 = require("react-native");
|
|
33
33
|
const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
|
|
34
|
-
|
|
34
|
+
const Ionicons_1 = __importDefault(require("react-native-vector-icons/Ionicons"));
|
|
35
35
|
const moment_1 = __importDefault(require("moment"));
|
|
36
36
|
const Sheet_1 = __importDefault(require("../Sheet"));
|
|
37
37
|
const Text_1 = __importDefault(require("../Text"));
|
|
38
38
|
const MenuItemDescription_1 = require("../MenuItemDescription");
|
|
39
39
|
const hooks_1 = require("../../hooks");
|
|
40
40
|
const Button_1 = __importDefault(require("../Button"));
|
|
41
|
+
const useInputFieldAnimatedBorder_1 = require("../../hooks/useInputFieldAnimatedBorder");
|
|
42
|
+
const FieldError_1 = require("../FieldError/FieldError");
|
|
41
43
|
const getFormat = (mode) => {
|
|
42
44
|
switch (mode) {
|
|
43
45
|
case 'date': {
|
|
@@ -52,7 +54,7 @@ const getFormat = (mode) => {
|
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
};
|
|
55
|
-
const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption, mode = 'date', disabled = false, onSave, }) => {
|
|
57
|
+
const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption, mode = 'date', error, disabled = false, onSave, }) => {
|
|
56
58
|
const { styles, theme } = useStyles(disabled);
|
|
57
59
|
const [dateSheetOpen, setDateSheetOpen] = (0, react_1.useState)(false);
|
|
58
60
|
const [date, setDate] = (0, react_1.useState)(value);
|
|
@@ -63,17 +65,20 @@ const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption
|
|
|
63
65
|
setDate(value);
|
|
64
66
|
}, [dateSheetOpen, value]);
|
|
65
67
|
const animatedValue = (0, react_native_reanimated_1.useSharedValue)(value ? 1 : 0);
|
|
68
|
+
const { animatedBorderStyle, setBorderColor } = (0, useInputFieldAnimatedBorder_1.useInputFieldAnimatedBorder)(styles.itemContainer.borderColor);
|
|
69
|
+
(0, react_1.useEffect)(() => {
|
|
70
|
+
if (error) {
|
|
71
|
+
setBorderColor(styles.itemContainerError.borderColor);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
setBorderColor(dateSheetOpen ? styles.itemContainerFocused.borderColor : styles.itemContainer.borderColor);
|
|
75
|
+
}, [error, dateSheetOpen]);
|
|
66
76
|
const animatedLabelStyles = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
67
77
|
return {
|
|
68
78
|
transform: [{ translateY: (0, react_native_reanimated_1.interpolate)(animatedValue.value, [0, 1], [1, -8]) }],
|
|
69
79
|
fontSize: (0, react_native_reanimated_1.interpolate)(animatedValue.value, [0, 1], [14, 10]),
|
|
70
80
|
};
|
|
71
81
|
}, []);
|
|
72
|
-
const animatedContainerStyles = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
73
|
-
return {
|
|
74
|
-
borderColor: (0, react_native_reanimated_1.interpolateColor)(animatedValue.value, [0, 1], ['#ffffff00', theme.colors.border]),
|
|
75
|
-
};
|
|
76
|
-
});
|
|
77
82
|
const animatedValueStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
78
83
|
return {
|
|
79
84
|
flex: 1,
|
|
@@ -83,7 +88,7 @@ const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption
|
|
|
83
88
|
return (<>
|
|
84
89
|
<react_native_1.View testID={testID} style={[styles.container, containerStyle]}>
|
|
85
90
|
<react_native_1.TouchableOpacity onPress={() => setDateSheetOpen(true)} disabled={disabled}>
|
|
86
|
-
<react_native_reanimated_1.default.View style={[styles.itemContainer,
|
|
91
|
+
<react_native_reanimated_1.default.View style={[styles.itemContainer, animatedBorderStyle]}>
|
|
87
92
|
<react_native_1.View pointerEvents="none" style={styles.labelContainer}>
|
|
88
93
|
<react_native_reanimated_1.default.Text style={[styles.label, animatedLabelStyles]}>{label}</react_native_reanimated_1.default.Text>
|
|
89
94
|
</react_native_1.View>
|
|
@@ -92,26 +97,24 @@ const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption
|
|
|
92
97
|
{(0, moment_1.default)(value).format(getFormat(mode)).toString()}
|
|
93
98
|
</Text_1.default>
|
|
94
99
|
</react_native_reanimated_1.default.View>
|
|
95
|
-
{
|
|
96
|
-
style={styles.iconRight}
|
|
97
|
-
color={!disabled ? theme.colors.foreground : theme.colors.foregroundLowContrast}
|
|
98
|
-
name={mode === 'time' ? 'time-outline' : 'calendar-outline'}
|
|
99
|
-
size={20}
|
|
100
|
-
/>*/}
|
|
100
|
+
<Ionicons_1.default style={styles.iconRight} color={!disabled ? theme.colors.foreground : theme.colors.foregroundLowContrast} name={mode === 'time' ? 'time-outline' : 'calendar-outline'} size={20}/>
|
|
101
101
|
</react_native_reanimated_1.default.View>
|
|
102
102
|
</react_native_1.TouchableOpacity>
|
|
103
|
+
{!!error && <FieldError_1.FieldError error={error}/>}
|
|
103
104
|
{!!caption && <MenuItemDescription_1.MenuItemDescription description={caption}/>}
|
|
104
105
|
</react_native_1.View>
|
|
105
106
|
<Sheet_1.default disableScroll header={label} open={dateSheetOpen} setOpen={setDateSheetOpen}>
|
|
106
107
|
<datetimepicker_1.default value={date} mode={mode} themeVariant={theme.isDarkTheme ? 'dark' : 'light'} display="spinner" onChange={(_, newDate) => {
|
|
108
|
+
console.log({ newDate });
|
|
107
109
|
if (!newDate) {
|
|
108
110
|
return;
|
|
109
111
|
}
|
|
110
112
|
setDate(newDate);
|
|
111
113
|
onChange === null || onChange === void 0 ? void 0 : onChange(newDate);
|
|
112
114
|
}}/>
|
|
113
|
-
<Button_1.default
|
|
115
|
+
<Button_1.default text="Save" onPress={() => {
|
|
114
116
|
onSave === null || onSave === void 0 ? void 0 : onSave(date);
|
|
117
|
+
setDateSheetOpen(false);
|
|
115
118
|
}}/>
|
|
116
119
|
</Sheet_1.default>
|
|
117
120
|
</>);
|
|
@@ -130,6 +133,14 @@ const useStyles = (disabled) => (0, hooks_1.useThemedStyle)((0, react_1.useCallb
|
|
|
130
133
|
flexDirection: 'row',
|
|
131
134
|
justifyContent: 'space-between',
|
|
132
135
|
alignItems: 'center',
|
|
136
|
+
borderColor: t.colors.backgroundPrimary,
|
|
137
|
+
borderWidth: t.borderWidth,
|
|
138
|
+
},
|
|
139
|
+
itemContainerError: {
|
|
140
|
+
borderColor: t.colors.foregroundNegative
|
|
141
|
+
},
|
|
142
|
+
itemContainerFocused: {
|
|
143
|
+
borderColor: t.colors.border,
|
|
133
144
|
},
|
|
134
145
|
itemLabel: {
|
|
135
146
|
color: t.textPrimary,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FieldError = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const react_native_1 = require("react-native");
|
|
6
|
+
const hooks_1 = require("../../hooks");
|
|
7
|
+
const Text_1 = require("../Text");
|
|
8
|
+
const FieldError = ({ error }) => {
|
|
9
|
+
const styles = useStyles().styles;
|
|
10
|
+
return (<react_native_1.View style={styles.errorContainer}>
|
|
11
|
+
<Text_1.Text category="p2" status="error">
|
|
12
|
+
{error}
|
|
13
|
+
</Text_1.Text>
|
|
14
|
+
</react_native_1.View>);
|
|
15
|
+
};
|
|
16
|
+
exports.FieldError = FieldError;
|
|
17
|
+
const useStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)(t => react_native_1.StyleSheet.create({
|
|
18
|
+
errorContainer: {
|
|
19
|
+
paddingLeft: t.size.baseSize * 1,
|
|
20
|
+
marginTop: t.size.baseSize * 1,
|
|
21
|
+
},
|
|
22
|
+
}), []));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Form = void 0;
|
|
18
|
+
const react_1 = __importDefault(require("react"));
|
|
19
|
+
const informed_1 = require("informed");
|
|
20
|
+
const react_native_1 = require("react-native");
|
|
21
|
+
const Form = (_a) => {
|
|
22
|
+
var { children, onValid, onInvalid } = _a, props = __rest(_a, ["children", "onValid", "onInvalid"]);
|
|
23
|
+
const { render, userProps } = (0, informed_1.useForm)(Object.assign(Object.assign({}, props), { onValid, onInvalid }));
|
|
24
|
+
// @ts-expect-error no types yet :/
|
|
25
|
+
return render(<react_native_1.View {...userProps}>{children}</react_native_1.View>);
|
|
26
|
+
};
|
|
27
|
+
exports.Form = Form;
|
|
28
|
+
exports.default = exports.Form;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Form';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Form"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FormDateTimeInput = void 0;
|
|
4
|
+
const informed_1 = require("informed");
|
|
5
|
+
const DateTimeInput_1 = require("../../DateTimeInput");
|
|
6
|
+
const FormDateTimeInput = (props) => {
|
|
7
|
+
const { render, userProps, fieldApi, informed, fieldState } = (0, informed_1.useField)(Object.assign({ type: "date" }, props));
|
|
8
|
+
return render(<DateTimeInput_1.DateTimeInput
|
|
9
|
+
//@ts-expect-error no types yet
|
|
10
|
+
error={fieldState.error} value={informed.value} onSave={fieldApi.setValue} {...userProps}/>);
|
|
11
|
+
};
|
|
12
|
+
exports.FormDateTimeInput = FormDateTimeInput;
|
|
13
|
+
exports.default = exports.FormDateTimeInput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FormDateTimeInput';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./FormDateTimeInput"), exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FormSelectInput = FormSelectInput;
|
|
7
|
+
const informed_1 = require("informed");
|
|
8
|
+
const SelectInput_1 = __importDefault(require("../../SelectInput"));
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
function FormSelectInput(props) {
|
|
11
|
+
const { render, userProps, fieldApi, informed, fieldState } = (0, informed_1.useField)(Object.assign({}, props));
|
|
12
|
+
const { value } = informed;
|
|
13
|
+
const { error } = fieldState;
|
|
14
|
+
const options = (0, react_1.useMemo)(() => {
|
|
15
|
+
return userProps.options.map((v) => {
|
|
16
|
+
return Object.assign(Object.assign({}, v), { selected: v.value === value });
|
|
17
|
+
});
|
|
18
|
+
}, [userProps.options, value]);
|
|
19
|
+
return render(<SelectInput_1.default onChange={(v) => {
|
|
20
|
+
fieldApi.setValue(v.value);
|
|
21
|
+
}}
|
|
22
|
+
//@ts-expect-error no types yet :(
|
|
23
|
+
error={error} {...userProps} options={options}/>);
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FormSelectInput';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./FormSelectInput"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FormSwitchToggle = void 0;
|
|
4
|
+
const informed_1 = require("informed");
|
|
5
|
+
const SwitchToggle_1 = require("../../SwitchToggle");
|
|
6
|
+
const FormSwitchToggle = (props) => {
|
|
7
|
+
const { render, userProps, fieldApi, informed } = (0, informed_1.useField)(Object.assign({ type: "boolean" }, props));
|
|
8
|
+
const { value } = informed;
|
|
9
|
+
return render(<SwitchToggle_1.SwitchToggle value={value} onChange={fieldApi.setValue} {...userProps}/>);
|
|
10
|
+
};
|
|
11
|
+
exports.FormSwitchToggle = FormSwitchToggle;
|
|
12
|
+
exports.default = exports.FormSwitchToggle;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FormSwitchToggle';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./FormSwitchToggle"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FormTextInput = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const informed_1 = require("informed");
|
|
9
|
+
const TextInput_1 = require("../../TextInput");
|
|
10
|
+
const FormTextInput = (props) => {
|
|
11
|
+
const { render, userProps, fieldApi, informed, fieldState } = (0, informed_1.useField)(Object.assign({ type: 'text' }, props));
|
|
12
|
+
const { value } = informed;
|
|
13
|
+
const { error } = fieldState;
|
|
14
|
+
return render(<TextInput_1.TextInput
|
|
15
|
+
//@ts-expect-error no types yet
|
|
16
|
+
error={error} onChangeText={fieldApi.setValue} {...userProps} value={value}/>);
|
|
17
|
+
};
|
|
18
|
+
exports.FormTextInput = FormTextInput;
|
|
19
|
+
exports.default = exports.FormTextInput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FormTextInput';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./FormTextInput"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Form"), exports);
|
|
18
|
+
__exportStar(require("./FormSwitchToggle"), exports);
|
|
19
|
+
__exportStar(require("./FormTextInput"), exports);
|
|
20
|
+
__exportStar(require("./FormDateTimeInput"), exports);
|
|
21
|
+
__exportStar(require("./FormSelectInput"), exports);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Option } from "./types";
|
|
3
|
-
type
|
|
3
|
+
export type SelectInputProps<T> = {
|
|
4
4
|
caption?: string;
|
|
5
5
|
label: string;
|
|
6
6
|
options: Option<T>[];
|
|
7
7
|
onChange: (newValue: Option<T>) => void;
|
|
8
|
+
error?: string;
|
|
8
9
|
};
|
|
9
|
-
export declare function SelectInput<T>({ caption, label, options, onChange, }:
|
|
10
|
+
export declare function SelectInput<T>({ caption, label, options, onChange, error, }: SelectInputProps<T>): React.JSX.Element;
|
|
10
11
|
export default SelectInput;
|
|
@@ -35,20 +35,26 @@ const Text_1 = __importDefault(require("../Text"));
|
|
|
35
35
|
const Sheet_1 = __importDefault(require("../Sheet"));
|
|
36
36
|
const MenuItemDescription_1 = require("../MenuItemDescription");
|
|
37
37
|
const hooks_1 = require("../../hooks");
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const useInputFieldAnimatedBorder_1 = require("../../hooks/useInputFieldAnimatedBorder");
|
|
39
|
+
const animations_1 = require("../../constants/animations");
|
|
40
|
+
function SelectInput({ caption, label, options = [], onChange, error, }) {
|
|
41
|
+
const { styles } = useStyles();
|
|
41
42
|
const values = (0, react_1.useMemo)(() => {
|
|
42
43
|
return options.filter((v) => v.selected);
|
|
43
44
|
}, options);
|
|
44
45
|
const [sheetOpen, setSheetOpen] = (0, react_1.useState)(false);
|
|
45
46
|
const animatedValue = (0, react_native_reanimated_1.useSharedValue)(values.length ? 1 : 0);
|
|
46
47
|
const rotation = (0, react_native_reanimated_1.useSharedValue)(sheetOpen ? 1 : 0);
|
|
48
|
+
const { animatedBorderStyle, setBorderColor } = (0, useInputFieldAnimatedBorder_1.useInputFieldAnimatedBorder)(styles.itemContainer.borderColor);
|
|
47
49
|
(0, react_1.useEffect)(() => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
50
|
+
if (error) {
|
|
51
|
+
setBorderColor(styles.itemContainerError.borderColor);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
setBorderColor(sheetOpen ? styles.itemContainerFocused.borderColor : styles.itemContainer.borderColor);
|
|
55
|
+
}, [error, sheetOpen]);
|
|
56
|
+
(0, react_1.useEffect)(() => {
|
|
57
|
+
rotation.value = (0, react_native_reanimated_1.withTiming)(sheetOpen ? 1 : 0, animations_1.DEFAULT_TIMING_CONFIG);
|
|
52
58
|
}, [sheetOpen]);
|
|
53
59
|
(0, react_1.useEffect)(() => {
|
|
54
60
|
animatedValue.value = values.length ? 1 : 0;
|
|
@@ -61,11 +67,6 @@ function SelectInput({ caption, label, options = [], onChange, }) {
|
|
|
61
67
|
fontSize: (0, react_native_reanimated_1.interpolate)(animatedValue.value, [0, 1], [14, 10]),
|
|
62
68
|
};
|
|
63
69
|
}, []);
|
|
64
|
-
const animatedContainerStyles = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
65
|
-
return {
|
|
66
|
-
borderColor: (0, react_native_reanimated_1.interpolateColor)(animatedValue.value, [0, 1], ["#ffffff00", theme.colors.border]),
|
|
67
|
-
};
|
|
68
|
-
}, [animatedValue]);
|
|
69
70
|
const animatedValueStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
70
71
|
return {
|
|
71
72
|
flex: 1,
|
|
@@ -85,7 +86,7 @@ function SelectInput({ caption, label, options = [], onChange, }) {
|
|
|
85
86
|
};
|
|
86
87
|
return (<>
|
|
87
88
|
<react_native_1.TouchableOpacity onPress={() => setSheetOpen(true)}>
|
|
88
|
-
<react_native_reanimated_1.default.View style={[styles.itemContainer,
|
|
89
|
+
<react_native_reanimated_1.default.View style={[styles.itemContainer, animatedBorderStyle]}>
|
|
89
90
|
<react_native_1.View pointerEvents="none" style={styles.labelContainer}>
|
|
90
91
|
<react_native_reanimated_1.default.Text style={[styles.label, animatedLabelStyles]}>
|
|
91
92
|
{label}
|
|
@@ -132,7 +133,7 @@ const useStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((th
|
|
|
132
133
|
},
|
|
133
134
|
itemContainer: {
|
|
134
135
|
borderWidth: theme.borderWidth,
|
|
135
|
-
borderColor: theme.colors.
|
|
136
|
+
borderColor: theme.colors.backgroundPrimary,
|
|
136
137
|
backgroundColor: theme.colors.backgroundOnPrimary,
|
|
137
138
|
marginBottom: theme.size.baseSize * 2,
|
|
138
139
|
borderRadius: theme.borderRadius,
|
|
@@ -141,6 +142,12 @@ const useStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((th
|
|
|
141
142
|
alignItems: "center",
|
|
142
143
|
justifyContent: "space-between",
|
|
143
144
|
},
|
|
145
|
+
itemContainerFocused: {
|
|
146
|
+
borderColor: theme.colors.border,
|
|
147
|
+
},
|
|
148
|
+
itemContainerError: {
|
|
149
|
+
borderColor: theme.colors.foregroundNegative,
|
|
150
|
+
},
|
|
144
151
|
labelContainer: {
|
|
145
152
|
left: theme.size.baseSize * 2,
|
|
146
153
|
position: "absolute",
|
|
@@ -7,6 +7,7 @@ export type SwitchToggleProps = {
|
|
|
7
7
|
testId?: string;
|
|
8
8
|
onChange?: (value: boolean) => void;
|
|
9
9
|
touchableStyle?: StyleProp<ViewStyle>;
|
|
10
|
+
error?: string;
|
|
10
11
|
};
|
|
11
|
-
export declare const SwitchToggle: ({ testId, onChange, value, caption, label, touchableStyle }: SwitchToggleProps) => React.JSX.Element;
|
|
12
|
+
export declare const SwitchToggle: ({ testId, onChange, value, caption, label, touchableStyle, error }: SwitchToggleProps) => React.JSX.Element;
|
|
12
13
|
export default SwitchToggle;
|
|
@@ -1,21 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.SwitchToggle = void 0;
|
|
7
|
-
const react_1 =
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
8
31
|
const react_native_1 = require("react-native");
|
|
32
|
+
const react_native_reanimated_1 = __importDefault(require("react-native-reanimated"));
|
|
9
33
|
const Text_1 = __importDefault(require("../Text"));
|
|
10
34
|
const MenuItemDescription_1 = require("../MenuItemDescription");
|
|
11
35
|
const index_1 = require("../../shared/styles/index");
|
|
12
|
-
const
|
|
13
|
-
|
|
36
|
+
const FieldError_1 = require("../FieldError/FieldError");
|
|
37
|
+
const useInputFieldAnimatedBorder_1 = require("../../hooks/useInputFieldAnimatedBorder");
|
|
38
|
+
const SwitchToggle = ({ testId, onChange, value, caption, label, touchableStyle, error }) => {
|
|
39
|
+
const { styles, theme } = (0, index_1.useMenuItemStyles)();
|
|
40
|
+
const { animatedBorderStyle, setBorderColor } = (0, useInputFieldAnimatedBorder_1.useInputFieldAnimatedBorder)(styles.itemContainer.borderColor);
|
|
41
|
+
(0, react_1.useEffect)(() => {
|
|
42
|
+
setBorderColor(error ? theme.colors.foregroundNegative : styles.itemContainer.borderColor);
|
|
43
|
+
}, [error]);
|
|
14
44
|
return (<react_native_1.View style={styles.container}>
|
|
15
|
-
<react_native_1.TouchableOpacity testID={testId} style={
|
|
16
|
-
<
|
|
17
|
-
|
|
45
|
+
<react_native_1.TouchableOpacity testID={testId} style={touchableStyle}>
|
|
46
|
+
<react_native_reanimated_1.default.View style={[styles.itemContainer, animatedBorderStyle]}>
|
|
47
|
+
<Text_1.default numberOfLines={1}>{label}</Text_1.default>
|
|
48
|
+
<react_native_1.Switch testID={`${testId}_toggle`} onValueChange={onChange} value={value}/>
|
|
49
|
+
</react_native_reanimated_1.default.View>
|
|
18
50
|
</react_native_1.TouchableOpacity>
|
|
51
|
+
{!!error && <FieldError_1.FieldError error={error}/>}
|
|
19
52
|
{!!caption && <MenuItemDescription_1.MenuItemDescription description={caption}/>}
|
|
20
53
|
</react_native_1.View>);
|
|
21
54
|
};
|
|
@@ -9,6 +9,7 @@ export type TextInputProps = {
|
|
|
9
9
|
value: string;
|
|
10
10
|
label: string;
|
|
11
11
|
containerStyle?: StyleProp<ViewStyle>;
|
|
12
|
+
error?: string;
|
|
12
13
|
} & Omit<RNTextInputProps, "onBlur">;
|
|
13
14
|
export declare const TextInput: React.ForwardRefExoticComponent<{
|
|
14
15
|
disabled?: boolean;
|
|
@@ -19,5 +20,6 @@ export declare const TextInput: React.ForwardRefExoticComponent<{
|
|
|
19
20
|
value: string;
|
|
20
21
|
label: string;
|
|
21
22
|
containerStyle?: StyleProp<ViewStyle>;
|
|
23
|
+
error?: string;
|
|
22
24
|
} & Omit<RNTextInputProps, "onBlur"> & React.RefAttributes<unknown>>;
|
|
23
25
|
export default TextInput;
|
|
@@ -44,9 +44,30 @@ const react_native_reanimated_1 = __importStar(require("react-native-reanimated"
|
|
|
44
44
|
const Text_1 = __importDefault(require("../Text"));
|
|
45
45
|
const MenuItemDescription_1 = require("../MenuItemDescription");
|
|
46
46
|
const hooks_1 = require("../../hooks");
|
|
47
|
+
const FieldError_1 = require("../FieldError/FieldError");
|
|
48
|
+
const useInputFieldAnimatedBorder_1 = require("../../hooks/useInputFieldAnimatedBorder");
|
|
49
|
+
const animations_1 = require("../../constants/animations");
|
|
50
|
+
const getLabelStyle = (disabled, error, style) => {
|
|
51
|
+
if (disabled) {
|
|
52
|
+
return style.disabled;
|
|
53
|
+
}
|
|
54
|
+
else if (error) {
|
|
55
|
+
return style.error;
|
|
56
|
+
}
|
|
57
|
+
return style.default;
|
|
58
|
+
};
|
|
59
|
+
const getTextInputStyle = (disabled, error, style) => {
|
|
60
|
+
if (disabled) {
|
|
61
|
+
return style.disabled;
|
|
62
|
+
}
|
|
63
|
+
else if (error) {
|
|
64
|
+
return style.error;
|
|
65
|
+
}
|
|
66
|
+
return style.default;
|
|
67
|
+
};
|
|
47
68
|
exports.TextInput = (0, react_1.forwardRef)((_a, ref) => {
|
|
48
|
-
var { caption, keyboardType, onChangeText, testId, value, label, onBlur, containerStyle, disabled = false } = _a, rest = __rest(_a, ["caption", "keyboardType", "onChangeText", "testId", "value", "label", "onBlur", "containerStyle", "disabled"]);
|
|
49
|
-
const { styles, theme } = useStyles(disabled);
|
|
69
|
+
var { caption, keyboardType, onChangeText, testId, value, label, onBlur, containerStyle, disabled = false, error } = _a, rest = __rest(_a, ["caption", "keyboardType", "onChangeText", "testId", "value", "label", "onBlur", "containerStyle", "disabled", "error"]);
|
|
70
|
+
const { styles, theme } = useStyles(disabled, !!error);
|
|
50
71
|
const inputRef = (0, react_1.useRef)(null);
|
|
51
72
|
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
52
73
|
focus: () => {
|
|
@@ -59,7 +80,14 @@ exports.TextInput = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
59
80
|
},
|
|
60
81
|
}));
|
|
61
82
|
const animatedValue = (0, react_native_reanimated_1.useSharedValue)(value ? 1 : 0);
|
|
62
|
-
const
|
|
83
|
+
const { animatedBorderStyle, setBorderColor } = (0, useInputFieldAnimatedBorder_1.useInputFieldAnimatedBorder)(styles.itemContainer.borderColor);
|
|
84
|
+
(0, react_1.useEffect)(() => {
|
|
85
|
+
var _a;
|
|
86
|
+
if ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.isFocused()) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
animatedValue.value = (0, react_native_reanimated_1.withTiming)(value ? 1 : 0, animations_1.DEFAULT_TIMING_CONFIG);
|
|
90
|
+
}, [value]);
|
|
63
91
|
const animatedLabelStyles = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
64
92
|
return {
|
|
65
93
|
transform: [
|
|
@@ -74,45 +102,37 @@ exports.TextInput = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
74
102
|
transform: [{ translateY: animatedValue.value * 4 }],
|
|
75
103
|
};
|
|
76
104
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
105
|
+
(0, react_1.useEffect)(() => {
|
|
106
|
+
var _a;
|
|
107
|
+
if ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.isFocused()) {
|
|
108
|
+
setBorderColor(error ? styles.itemContainerError.borderColor : styles.itemContainerFocused.borderColor);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
startBlurAnimation();
|
|
112
|
+
}
|
|
113
|
+
}, [error]);
|
|
82
114
|
const handleOnChangeText = (text) => {
|
|
83
115
|
if (text.length === 0) {
|
|
84
|
-
animatedValue.value = (0, react_native_reanimated_1.withTiming)(0,
|
|
85
|
-
duration: 200,
|
|
86
|
-
easing: react_native_reanimated_1.Easing.bezier(0.25, 0.1, 0.25, 1),
|
|
87
|
-
});
|
|
116
|
+
animatedValue.value = (0, react_native_reanimated_1.withTiming)(0, animations_1.DEFAULT_TIMING_CONFIG);
|
|
88
117
|
}
|
|
89
118
|
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(text);
|
|
90
119
|
if (value || animatedValue.value === 1) {
|
|
91
120
|
return;
|
|
92
121
|
}
|
|
93
|
-
animatedValue.value = (0, react_native_reanimated_1.withTiming)(1,
|
|
94
|
-
duration: 200,
|
|
95
|
-
easing: react_native_reanimated_1.Easing.bezier(0.25, 0.1, 0.25, 1),
|
|
96
|
-
});
|
|
122
|
+
animatedValue.value = (0, react_native_reanimated_1.withTiming)(1, animations_1.DEFAULT_TIMING_CONFIG);
|
|
97
123
|
};
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
focusedValue.value = (0, react_native_reanimated_1.withTiming)(0, {
|
|
101
|
-
duration: 200,
|
|
102
|
-
easing: react_native_reanimated_1.Easing.bezier(0.25, 0.1, 0.25, 1),
|
|
103
|
-
});
|
|
124
|
+
const startBlurAnimation = () => {
|
|
125
|
+
setBorderColor(error ? `${styles.itemContainerError.borderColor}40` : styles.itemContainer.borderColor);
|
|
104
126
|
if (!value) {
|
|
105
|
-
animatedValue.value = (0, react_native_reanimated_1.withTiming)(0,
|
|
106
|
-
duration: 200,
|
|
107
|
-
easing: react_native_reanimated_1.Easing.bezier(0.25, 0.1, 0.25, 1),
|
|
108
|
-
});
|
|
127
|
+
animatedValue.value = (0, react_native_reanimated_1.withTiming)(0, animations_1.DEFAULT_TIMING_CONFIG);
|
|
109
128
|
}
|
|
110
129
|
};
|
|
130
|
+
const handleOnBlur = ({ nativeEvent }) => {
|
|
131
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(nativeEvent.text);
|
|
132
|
+
startBlurAnimation();
|
|
133
|
+
};
|
|
111
134
|
const onFocus = () => {
|
|
112
|
-
|
|
113
|
-
duration: 200,
|
|
114
|
-
easing: react_native_reanimated_1.Easing.bezier(0.25, 0.1, 0.25, 1),
|
|
115
|
-
});
|
|
135
|
+
setBorderColor(error ? styles.itemContainerError.borderColor : styles.itemContainerFocused.borderColor);
|
|
116
136
|
};
|
|
117
137
|
return (<react_native_1.View style={styles.container}>
|
|
118
138
|
<react_native_1.Pressable onPress={() => {
|
|
@@ -121,7 +141,7 @@ exports.TextInput = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
121
141
|
}} style={styles.pressable} disabled={disabled}>
|
|
122
142
|
<react_native_reanimated_1.default.View style={[
|
|
123
143
|
styles.itemContainer,
|
|
124
|
-
|
|
144
|
+
animatedBorderStyle,
|
|
125
145
|
containerStyle,
|
|
126
146
|
]}>
|
|
127
147
|
<react_native_1.View pointerEvents="none" style={styles.labelContainer}>
|
|
@@ -130,16 +150,17 @@ exports.TextInput = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
130
150
|
</react_native_reanimated_1.default.Text>
|
|
131
151
|
</react_native_1.View>
|
|
132
152
|
<react_native_reanimated_1.default.View style={animatedInputStyles}>
|
|
133
|
-
{disabled ? (<Text_1.default style={styles.text}>{value}</Text_1.default>) : (<react_native_1.TextInput ref={inputRef} testID={testId} value={value} style={styles.textInput} numberOfLines={1} keyboardType={keyboardType}
|
|
153
|
+
{disabled ? (<Text_1.default style={styles.text}>{value}</Text_1.default>) : (<react_native_1.TextInput ref={inputRef} testID={testId} value={value} style={styles.textInput} numberOfLines={1} keyboardType={keyboardType} onChangeText={handleOnChangeText} maxLength={40} returnKeyType="done" onBlur={handleOnBlur} onFocus={onFocus} keyboardAppearance={theme.keyboardAppearance} {...rest}/>)}
|
|
134
154
|
</react_native_reanimated_1.default.View>
|
|
135
155
|
</react_native_reanimated_1.default.View>
|
|
136
156
|
</react_native_1.Pressable>
|
|
157
|
+
{!!error && (<FieldError_1.FieldError error={error}/>)}
|
|
137
158
|
{!!caption && <MenuItemDescription_1.MenuItemDescription description={caption}/>}
|
|
138
159
|
</react_native_1.View>);
|
|
139
160
|
});
|
|
140
161
|
exports.default = exports.TextInput;
|
|
141
|
-
exports.TextInput.displayName =
|
|
142
|
-
const useStyles = (disabled) => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((theme) => react_native_1.StyleSheet.create({
|
|
162
|
+
exports.TextInput.displayName = "TextInput";
|
|
163
|
+
const useStyles = (disabled, error) => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((theme) => react_native_1.StyleSheet.create({
|
|
143
164
|
container: {
|
|
144
165
|
width: "100%",
|
|
145
166
|
flexShrink: 0.5,
|
|
@@ -148,30 +169,54 @@ const useStyles = (disabled) => (0, hooks_1.useThemedStyle)((0, react_1.useCallb
|
|
|
148
169
|
flexGrow: 2,
|
|
149
170
|
flexShrink: 1,
|
|
150
171
|
},
|
|
151
|
-
textInput: Object.assign(Object.assign({ paddingHorizontal: theme.size.baseSize * 2 }, theme.typography.p1),
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
172
|
+
textInput: Object.assign(Object.assign({ paddingHorizontal: theme.size.baseSize * 2 }, theme.typography.p1), getTextInputStyle(disabled, error, {
|
|
173
|
+
disabled: {
|
|
174
|
+
color: theme.colors.foregroundLowContrast,
|
|
175
|
+
},
|
|
176
|
+
error: {
|
|
177
|
+
color: theme.colors.foregroundNegative,
|
|
178
|
+
},
|
|
179
|
+
default: {
|
|
180
|
+
color: theme.colors.foregroundLowContrast,
|
|
181
|
+
},
|
|
182
|
+
})),
|
|
183
|
+
text: Object.assign({ marginTop: theme.size.baseSize, paddingHorizontal: theme.size.baseSize * 2, color: theme.colors.foregroundLowContrast }, getTextInputStyle(disabled, error, {
|
|
184
|
+
disabled: {
|
|
185
|
+
color: theme.colors.foregroundLowContrast,
|
|
186
|
+
},
|
|
187
|
+
error: {
|
|
188
|
+
color: theme.colors.foregroundNegative,
|
|
189
|
+
},
|
|
190
|
+
default: {
|
|
191
|
+
color: theme.colors.foregroundLowContrast,
|
|
192
|
+
},
|
|
193
|
+
})),
|
|
157
194
|
itemContainer: {
|
|
158
195
|
borderWidth: theme.borderWidth,
|
|
159
|
-
borderColor: theme.colors.borderSecondary,
|
|
160
196
|
backgroundColor: theme.colors.backgroundOnPrimary,
|
|
161
197
|
borderRadius: theme.borderRadius,
|
|
162
198
|
minHeight: theme.size.baseSize * 8,
|
|
163
199
|
flexDirection: "row",
|
|
164
200
|
alignItems: "center",
|
|
201
|
+
borderColor: `${theme.colors.border}00`,
|
|
202
|
+
},
|
|
203
|
+
itemContainerFocused: {
|
|
204
|
+
borderColor: theme.colors.border,
|
|
205
|
+
},
|
|
206
|
+
itemContainerError: {
|
|
207
|
+
borderColor: theme.colors.foregroundNegative,
|
|
165
208
|
},
|
|
166
209
|
labelContainer: {
|
|
167
210
|
left: theme.size.baseSize * 2,
|
|
168
211
|
position: "absolute",
|
|
169
212
|
},
|
|
170
|
-
label:
|
|
171
|
-
|
|
172
|
-
|
|
213
|
+
label: getLabelStyle(disabled, error, {
|
|
214
|
+
default: Object.assign({ color: theme.colors.foreground }, theme.typography.p1),
|
|
215
|
+
disabled: Object.assign({ color: theme.colors.foregroundLowContrast }, theme.typography.p1),
|
|
216
|
+
error: Object.assign({ color: theme.colors.foregroundNegative }, theme.typography.p1),
|
|
217
|
+
}),
|
|
173
218
|
descriptionContainer: {
|
|
174
219
|
marginHorizontal: theme.size.baseSize * 4,
|
|
175
220
|
marginBottom: theme.size.baseSize * 2,
|
|
176
221
|
},
|
|
177
|
-
}), [disabled]));
|
|
222
|
+
}), [disabled, error]));
|
package/dist/components/index.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_TIMING_CONFIG = exports.DEFAULT_EASING = void 0;
|
|
4
|
+
const react_native_reanimated_1 = require("react-native-reanimated");
|
|
5
|
+
exports.DEFAULT_EASING = react_native_reanimated_1.Easing.inOut(react_native_reanimated_1.Easing.quad);
|
|
6
|
+
exports.DEFAULT_TIMING_CONFIG = {
|
|
7
|
+
duration: 150,
|
|
8
|
+
easing: exports.DEFAULT_EASING,
|
|
9
|
+
};
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./useTheme";
|
|
2
|
+
export * from "./useThemedStyle";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useInputFieldAnimatedBorder = void 0;
|
|
4
|
+
const react_native_reanimated_1 = require("react-native-reanimated");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const animations_1 = require("../constants/animations");
|
|
7
|
+
const useInputFieldAnimatedBorder = (initialColor) => {
|
|
8
|
+
const inputBorderColor = (0, react_native_reanimated_1.useSharedValue)(initialColor); //starts hidden
|
|
9
|
+
const setBorderColor = (0, react_1.useCallback)((color) => {
|
|
10
|
+
inputBorderColor.value = (0, react_native_reanimated_1.withTiming)(color, animations_1.DEFAULT_TIMING_CONFIG);
|
|
11
|
+
}, []);
|
|
12
|
+
const borderStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
13
|
+
return {
|
|
14
|
+
borderColor: inputBorderColor.value,
|
|
15
|
+
};
|
|
16
|
+
}, []);
|
|
17
|
+
return {
|
|
18
|
+
animatedBorderStyle: borderStyle,
|
|
19
|
+
setBorderColor,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.useInputFieldAnimatedBorder = useInputFieldAnimatedBorder;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function usePrevious<T>(value: T): T | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.usePrevious = usePrevious;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
function usePrevious(value) {
|
|
9
|
+
const [current, setCurrent] = react_1.default.useState(value);
|
|
10
|
+
const [previous, setPrevious] = react_1.default.useState(null);
|
|
11
|
+
if (value !== current) {
|
|
12
|
+
setPrevious(current);
|
|
13
|
+
setCurrent(value);
|
|
14
|
+
}
|
|
15
|
+
return previous;
|
|
16
|
+
}
|
|
@@ -11,6 +11,8 @@ const useMenuItemStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallb
|
|
|
11
11
|
marginBottom: theme.size.baseSize * 3,
|
|
12
12
|
},
|
|
13
13
|
itemContainer: {
|
|
14
|
+
borderWidth: theme.borderWidth,
|
|
15
|
+
borderColor: theme.colors.backgroundPrimary,
|
|
14
16
|
backgroundColor: theme.menuItemContainerBackground,
|
|
15
17
|
borderRadius: theme.borderRadius,
|
|
16
18
|
paddingHorizontal: theme.size.baseSize * 2,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atlas-design-system",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "A react native design system for the Atlas workout app",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,22 +27,17 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"
|
|
30
|
+
"informed": ">=4.0.0",
|
|
31
|
+
"@react-native-community/datetimepicker": ">=8.0.0",
|
|
31
32
|
"moment": ">=2.24.0",
|
|
33
|
+
"react": ">=17.0.1",
|
|
32
34
|
"react-native": ">=0.64.1",
|
|
33
35
|
"react-native-reanimated": ">=3.0.0",
|
|
34
36
|
"react-native-safe-area-context": ">=4.0.0",
|
|
35
|
-
"react-native-vector-icons": ">=10.0.0"
|
|
36
|
-
"@react-native-community/datetimepicker": ">=8.0.0"
|
|
37
|
+
"react-native-vector-icons": ">=10.0.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"react-native": "0.74.3",
|
|
40
|
-
"react-native-reanimated": "~3.10.1",
|
|
41
|
-
"react-native-safe-area-context": "^4.10.9",
|
|
42
|
-
"react-native-vector-icons": "^10.1.0",
|
|
43
40
|
"@react-native-community/datetimepicker": "~8.0.1",
|
|
44
|
-
"moment": "^2.29.0",
|
|
45
|
-
"react": "^18.2.0",
|
|
46
41
|
"@types/react": "^18.2.0",
|
|
47
42
|
"@types/react-native-vector-icons": "^6.4.18",
|
|
48
43
|
"@typescript-eslint/eslint-plugin": "^8.4.0",
|
|
@@ -50,6 +45,13 @@
|
|
|
50
45
|
"eslint": "^8.19.0",
|
|
51
46
|
"eslint-plugin-react": "^7.35.2",
|
|
52
47
|
"eslint-plugin-react-native": "^4.1.0",
|
|
48
|
+
"informed": "^4.60.3",
|
|
49
|
+
"moment": "^2.29.0",
|
|
50
|
+
"react": "^18.2.0",
|
|
51
|
+
"react-native": "0.74.3",
|
|
52
|
+
"react-native-reanimated": "~3.10.1",
|
|
53
|
+
"react-native-safe-area-context": "^4.10.9",
|
|
54
|
+
"react-native-vector-icons": "^10.1.0",
|
|
53
55
|
"typescript": "^5.5.4"
|
|
54
56
|
},
|
|
55
57
|
"author": "Juan Castillo",
|