atlas-design-system 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/DateTimeInput/index.d.ts +2 -1
- package/dist/components/DateTimeInput/index.js +24 -8
- package/dist/components/FieldError/FieldError.d.ts +5 -0
- package/dist/components/FieldError/FieldError.js +22 -0
- package/dist/components/Forms/FormDateTimeInput/FormDateTimeInput.js +4 -2
- 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/{NumericKeyboard → Forms/FormSelectInput}/index.js +1 -1
- package/dist/components/Forms/FormTextInput/FormTextInput.js +5 -2
- package/dist/components/Forms/index.d.ts +1 -0
- package/dist/components/Forms/index.js +1 -0
- package/dist/components/Search/Search.d.ts +15 -0
- package/dist/components/Search/Search.js +95 -0
- package/dist/components/Search/index.d.ts +1 -0
- package/dist/components/Search/index.js +17 -0
- package/dist/components/SelectInput/SelectInput.d.ts +4 -2
- package/dist/components/SelectInput/SelectInput.js +26 -32
- package/dist/components/SelectInput/components/SelectionItem.d.ts +5 -0
- package/dist/components/SelectInput/components/SelectionItem.js +29 -0
- 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 +84 -42
- package/dist/components/TitleBar/TitleBar.js +0 -7
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/constants/animations.d.ts +5 -0
- package/dist/constants/animations.js +9 -0
- 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 +1 -1
- package/dist/components/NumericKeyboard/NumericKeyboard.d.ts +0 -11
- package/dist/components/NumericKeyboard/NumericKeyboard.js +0 -170
- package/dist/components/NumericKeyboard/index.d.ts +0 -1
- package/dist/hooks/useStylesCreator.d.ts +0 -2
- package/dist/hooks/useStylesCreator.js +0 -9
|
@@ -10,6 +10,7 @@ export type DateTimeInputProps = {
|
|
|
10
10
|
testID?: string;
|
|
11
11
|
containerStyle?: StyleProp<ViewStyle>;
|
|
12
12
|
mode?: IOSNativeProps['mode'] | AndroidNativeProps['mode'];
|
|
13
|
+
error?: string;
|
|
13
14
|
};
|
|
14
|
-
export declare const DateTimeInput: ({ value, onChange, testID, containerStyle, label, caption, mode, disabled, onSave, }: DateTimeInputProps) => import("react").JSX.Element;
|
|
15
|
+
export declare const DateTimeInput: ({ value, onChange, testID, containerStyle, label, caption, mode, error, disabled, onSave, }: DateTimeInputProps) => import("react").JSX.Element;
|
|
15
16
|
export default DateTimeInput;
|
|
@@ -38,6 +38,8 @@ 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>
|
|
@@ -95,18 +100,21 @@ const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption
|
|
|
95
100
|
<Ionicons_1.default style={styles.iconRight} color={!disabled ? theme.colors.foreground : theme.colors.foregroundLowContrast} name={mode === 'time' ? 'time-outline' : 'calendar-outline'} size={20}/>
|
|
96
101
|
</react_native_reanimated_1.default.View>
|
|
97
102
|
</react_native_1.TouchableOpacity>
|
|
103
|
+
{!!error && <FieldError_1.FieldError error={error}/>}
|
|
98
104
|
{!!caption && <MenuItemDescription_1.MenuItemDescription description={caption}/>}
|
|
99
105
|
</react_native_1.View>
|
|
100
106
|
<Sheet_1.default disableScroll header={label} open={dateSheetOpen} setOpen={setDateSheetOpen}>
|
|
101
107
|
<datetimepicker_1.default value={date} mode={mode} themeVariant={theme.isDarkTheme ? 'dark' : 'light'} display="spinner" onChange={(_, newDate) => {
|
|
108
|
+
console.log({ newDate });
|
|
102
109
|
if (!newDate) {
|
|
103
110
|
return;
|
|
104
111
|
}
|
|
105
112
|
setDate(newDate);
|
|
106
113
|
onChange === null || onChange === void 0 ? void 0 : onChange(newDate);
|
|
107
114
|
}}/>
|
|
108
|
-
<Button_1.default
|
|
115
|
+
<Button_1.default text="Save" onPress={() => {
|
|
109
116
|
onSave === null || onSave === void 0 ? void 0 : onSave(date);
|
|
117
|
+
setDateSheetOpen(false);
|
|
110
118
|
}}/>
|
|
111
119
|
</Sheet_1.default>
|
|
112
120
|
</>);
|
|
@@ -125,6 +133,14 @@ const useStyles = (disabled) => (0, hooks_1.useThemedStyle)((0, react_1.useCallb
|
|
|
125
133
|
flexDirection: 'row',
|
|
126
134
|
justifyContent: 'space-between',
|
|
127
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,
|
|
128
144
|
},
|
|
129
145
|
itemLabel: {
|
|
130
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
|
+
}), []));
|
|
@@ -4,8 +4,10 @@ exports.FormDateTimeInput = void 0;
|
|
|
4
4
|
const informed_1 = require("informed");
|
|
5
5
|
const DateTimeInput_1 = require("../../DateTimeInput");
|
|
6
6
|
const FormDateTimeInput = (props) => {
|
|
7
|
-
const { render, userProps, fieldApi, informed } = (0, informed_1.useField)(Object.assign({ type: "date" }, props));
|
|
8
|
-
return render(<DateTimeInput_1.DateTimeInput
|
|
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}/>);
|
|
9
11
|
};
|
|
10
12
|
exports.FormDateTimeInput = FormDateTimeInput;
|
|
11
13
|
exports.default = exports.FormDateTimeInput;
|
|
@@ -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';
|
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./FormSelectInput"), exports);
|
|
@@ -8,9 +8,12 @@ const react_1 = __importDefault(require("react"));
|
|
|
8
8
|
const informed_1 = require("informed");
|
|
9
9
|
const TextInput_1 = require("../../TextInput");
|
|
10
10
|
const FormTextInput = (props) => {
|
|
11
|
-
const { render, userProps, fieldApi, informed } = (0, informed_1.useField)(Object.assign({ type: 'text' }, props));
|
|
11
|
+
const { render, userProps, fieldApi, informed, fieldState } = (0, informed_1.useField)(Object.assign({ type: 'text' }, props));
|
|
12
12
|
const { value } = informed;
|
|
13
|
-
|
|
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}/>);
|
|
14
17
|
};
|
|
15
18
|
exports.FormTextInput = FormTextInput;
|
|
16
19
|
exports.default = exports.FormTextInput;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewStyle, ReturnKeyType, StyleProp } from 'react-native';
|
|
3
|
+
type Props = {
|
|
4
|
+
searchQuery: string;
|
|
5
|
+
onChangeText: (text: string) => void;
|
|
6
|
+
rightComponent?: React.ReactNode;
|
|
7
|
+
onPressFilter?: () => void;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
label: string;
|
|
10
|
+
autoFocus?: boolean;
|
|
11
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
12
|
+
returnKeyType?: ReturnKeyType;
|
|
13
|
+
};
|
|
14
|
+
export declare const Search: ({ searchQuery, onChangeText, placeholder, autoFocus, containerStyle, returnKeyType, label, }: Props) => React.JSX.Element;
|
|
15
|
+
export default Search;
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.Search = void 0;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const react_native_1 = require("react-native");
|
|
32
|
+
const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
|
|
33
|
+
const TextInput_1 = __importDefault(require("../TextInput"));
|
|
34
|
+
const Text_1 = __importDefault(require("../Text"));
|
|
35
|
+
const hooks_1 = require("../../hooks");
|
|
36
|
+
const CANCEL_BUTTON_WIDTH = 62;
|
|
37
|
+
const Search = ({ searchQuery, onChangeText, placeholder, autoFocus, containerStyle = {}, returnKeyType, label, }) => {
|
|
38
|
+
const { styles } = useStyles();
|
|
39
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
40
|
+
const [minWidth, setMinWidth] = (0, react_1.useState)(0);
|
|
41
|
+
const focused = (0, react_native_reanimated_1.useSharedValue)(0);
|
|
42
|
+
const onFocus = () => {
|
|
43
|
+
focused.value = (0, react_native_reanimated_1.withTiming)(1, { easing: react_native_reanimated_1.Easing.bezier(0.25, 0.1, 0.25, 1) });
|
|
44
|
+
};
|
|
45
|
+
const onBlur = () => {
|
|
46
|
+
focused.value = (0, react_native_reanimated_1.withTiming)(0, { easing: react_native_reanimated_1.Easing.bezier(0.25, 0.1, 0.25, 1) });
|
|
47
|
+
};
|
|
48
|
+
const animatedCancelButtonStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => ({
|
|
49
|
+
opacity: focused.value,
|
|
50
|
+
}), [focused]);
|
|
51
|
+
const animatedSearchInput = (0, react_native_reanimated_1.useAnimatedStyle)(() => ({
|
|
52
|
+
width: `${(0, react_native_reanimated_1.interpolate)(focused.value, [0, 1], [100, ((minWidth - CANCEL_BUTTON_WIDTH) / minWidth) * 100])}%`,
|
|
53
|
+
}), [focused, minWidth]);
|
|
54
|
+
const onPressCancel = (0, react_1.useCallback)(() => {
|
|
55
|
+
var _a;
|
|
56
|
+
onChangeText('');
|
|
57
|
+
// @ts-expect-error not yet typed
|
|
58
|
+
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
59
|
+
}, [inputRef]);
|
|
60
|
+
const onLayout = (e) => {
|
|
61
|
+
setMinWidth(e.nativeEvent.layout.width);
|
|
62
|
+
};
|
|
63
|
+
return (<react_native_1.View style={[styles.searchBarContainer, containerStyle]} onLayout={onLayout}>
|
|
64
|
+
<react_native_reanimated_1.default.View style={[animatedSearchInput, styles.animatedContainer]}>
|
|
65
|
+
<TextInput_1.default ref={inputRef} autoCapitalize="words" value={searchQuery} onFocus={onFocus} onBlur={onBlur} autoFocus={autoFocus} returnKeyType={returnKeyType !== null && returnKeyType !== void 0 ? returnKeyType : 'search'} label={label || placeholder || 'Enter search term'} onChangeText={onChangeText}/>
|
|
66
|
+
</react_native_reanimated_1.default.View>
|
|
67
|
+
<react_native_reanimated_1.default.View style={animatedCancelButtonStyle}>
|
|
68
|
+
<react_native_1.TouchableOpacity style={styles.cancelButton} onPress={onPressCancel}>
|
|
69
|
+
<Text_1.default style={styles.cancelButtonText}>Cancel</Text_1.default>
|
|
70
|
+
</react_native_1.TouchableOpacity>
|
|
71
|
+
</react_native_reanimated_1.default.View>
|
|
72
|
+
</react_native_1.View>);
|
|
73
|
+
};
|
|
74
|
+
exports.Search = Search;
|
|
75
|
+
exports.default = exports.Search;
|
|
76
|
+
const useStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)(theme => react_native_1.StyleSheet.create({
|
|
77
|
+
searchBarContainer: {
|
|
78
|
+
flexDirection: 'row',
|
|
79
|
+
width: '100%',
|
|
80
|
+
},
|
|
81
|
+
animatedContainer: {
|
|
82
|
+
width: '100%',
|
|
83
|
+
justifyContent: 'center',
|
|
84
|
+
},
|
|
85
|
+
cancelButton: {
|
|
86
|
+
flex: 1,
|
|
87
|
+
maxWidth: CANCEL_BUTTON_WIDTH,
|
|
88
|
+
minWidth: CANCEL_BUTTON_WIDTH,
|
|
89
|
+
justifyContent: 'center',
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
},
|
|
92
|
+
cancelButtonText: {
|
|
93
|
+
color: theme.colors.primary,
|
|
94
|
+
},
|
|
95
|
+
}), []));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Search';
|
|
@@ -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("./Search"), exports);
|
|
@@ -1,10 +1,12 @@
|
|
|
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;
|
|
9
|
+
renderOption?: (option: Option<T>) => React.ReactNode;
|
|
8
10
|
};
|
|
9
|
-
export declare function SelectInput<T>({ caption, label, options, onChange, }:
|
|
11
|
+
export declare function SelectInput<T>({ caption, label, options, onChange, error, renderOption, }: SelectInputProps<T>): React.JSX.Element;
|
|
10
12
|
export default SelectInput;
|
|
@@ -35,20 +35,29 @@ 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
|
+
const SelectionItem_1 = __importDefault(require("./components/SelectionItem"));
|
|
41
|
+
function SelectInput({ caption, label, options = [], onChange, error, renderOption, }) {
|
|
42
|
+
const styles = useStyles().styles;
|
|
41
43
|
const values = (0, react_1.useMemo)(() => {
|
|
42
44
|
return options.filter((v) => v.selected);
|
|
43
45
|
}, options);
|
|
44
46
|
const [sheetOpen, setSheetOpen] = (0, react_1.useState)(false);
|
|
45
47
|
const animatedValue = (0, react_native_reanimated_1.useSharedValue)(values.length ? 1 : 0);
|
|
46
48
|
const rotation = (0, react_native_reanimated_1.useSharedValue)(sheetOpen ? 1 : 0);
|
|
49
|
+
const { animatedBorderStyle, setBorderColor } = (0, useInputFieldAnimatedBorder_1.useInputFieldAnimatedBorder)(styles.itemContainer.borderColor);
|
|
47
50
|
(0, react_1.useEffect)(() => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
51
|
+
if (error) {
|
|
52
|
+
setBorderColor(styles.itemContainerError.borderColor);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
setBorderColor(sheetOpen
|
|
56
|
+
? styles.itemContainerFocused.borderColor
|
|
57
|
+
: styles.itemContainer.borderColor);
|
|
58
|
+
}, [error, sheetOpen]);
|
|
59
|
+
(0, react_1.useEffect)(() => {
|
|
60
|
+
rotation.value = (0, react_native_reanimated_1.withTiming)(sheetOpen ? 1 : 0, animations_1.DEFAULT_TIMING_CONFIG);
|
|
52
61
|
}, [sheetOpen]);
|
|
53
62
|
(0, react_1.useEffect)(() => {
|
|
54
63
|
animatedValue.value = values.length ? 1 : 0;
|
|
@@ -61,11 +70,6 @@ function SelectInput({ caption, label, options = [], onChange, }) {
|
|
|
61
70
|
fontSize: (0, react_native_reanimated_1.interpolate)(animatedValue.value, [0, 1], [14, 10]),
|
|
62
71
|
};
|
|
63
72
|
}, []);
|
|
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
73
|
const animatedValueStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
70
74
|
return {
|
|
71
75
|
flex: 1,
|
|
@@ -85,7 +89,7 @@ function SelectInput({ caption, label, options = [], onChange, }) {
|
|
|
85
89
|
};
|
|
86
90
|
return (<>
|
|
87
91
|
<react_native_1.TouchableOpacity onPress={() => setSheetOpen(true)}>
|
|
88
|
-
<react_native_reanimated_1.default.View style={[styles.itemContainer,
|
|
92
|
+
<react_native_reanimated_1.default.View style={[styles.itemContainer, animatedBorderStyle]}>
|
|
89
93
|
<react_native_1.View pointerEvents="none" style={styles.labelContainer}>
|
|
90
94
|
<react_native_reanimated_1.default.Text style={[styles.label, animatedLabelStyles]}>
|
|
91
95
|
{label}
|
|
@@ -103,13 +107,8 @@ function SelectInput({ caption, label, options = [], onChange, }) {
|
|
|
103
107
|
</react_native_1.TouchableOpacity>
|
|
104
108
|
{!!caption && <MenuItemDescription_1.MenuItemDescription description={caption}/>}
|
|
105
109
|
<Sheet_1.default open={sheetOpen} setOpen={setSheetOpen} header={label}>
|
|
106
|
-
{options.map((option, i) => (<react_native_1.TouchableOpacity
|
|
107
|
-
|
|
108
|
-
option.selected && styles.selectedSelectionItem,
|
|
109
|
-
]} key={i} onPress={() => handleOptionPress(option)}>
|
|
110
|
-
<Text_1.default contrast={option.selected ? "high" : "low"}>
|
|
111
|
-
{option.label}
|
|
112
|
-
</Text_1.default>
|
|
110
|
+
{options.map((option, i) => (<react_native_1.TouchableOpacity onPress={() => handleOptionPress(option)} key={i + option.label}>
|
|
111
|
+
{renderOption ? (renderOption(option)) : (<SelectionItem_1.default option={option}/>)}
|
|
113
112
|
</react_native_1.TouchableOpacity>))}
|
|
114
113
|
</Sheet_1.default>
|
|
115
114
|
</>);
|
|
@@ -119,20 +118,9 @@ const useStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((th
|
|
|
119
118
|
paddingRight: theme.size.baseSize * 2,
|
|
120
119
|
color: theme.colors.foreground,
|
|
121
120
|
},
|
|
122
|
-
selectedSelectionItem: {
|
|
123
|
-
borderColor: theme.colors.primary,
|
|
124
|
-
},
|
|
125
|
-
selectionItem: {
|
|
126
|
-
alignItems: "center",
|
|
127
|
-
borderWidth: theme.borderWidth,
|
|
128
|
-
borderColor: theme.colors.border,
|
|
129
|
-
marginBottom: theme.size.baseSize * 2,
|
|
130
|
-
padding: theme.size.baseSize * 2,
|
|
131
|
-
borderRadius: theme.borderRadius,
|
|
132
|
-
},
|
|
133
121
|
itemContainer: {
|
|
134
122
|
borderWidth: theme.borderWidth,
|
|
135
|
-
borderColor: theme.colors.
|
|
123
|
+
borderColor: theme.colors.backgroundPrimary,
|
|
136
124
|
backgroundColor: theme.colors.backgroundOnPrimary,
|
|
137
125
|
marginBottom: theme.size.baseSize * 2,
|
|
138
126
|
borderRadius: theme.borderRadius,
|
|
@@ -141,6 +129,12 @@ const useStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((th
|
|
|
141
129
|
alignItems: "center",
|
|
142
130
|
justifyContent: "space-between",
|
|
143
131
|
},
|
|
132
|
+
itemContainerFocused: {
|
|
133
|
+
borderColor: theme.colors.border,
|
|
134
|
+
},
|
|
135
|
+
itemContainerError: {
|
|
136
|
+
borderColor: theme.colors.foregroundNegative,
|
|
137
|
+
},
|
|
144
138
|
labelContainer: {
|
|
145
139
|
left: theme.size.baseSize * 2,
|
|
146
140
|
position: "absolute",
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = SelectionItem;
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const Text_1 = require("../../Text");
|
|
7
|
+
const hooks_1 = require("../../../hooks");
|
|
8
|
+
function SelectionItem({ option }) {
|
|
9
|
+
const styles = useStyles().styles;
|
|
10
|
+
return (<react_native_1.View style={[
|
|
11
|
+
styles.selectionItem,
|
|
12
|
+
option.selected && styles.selectedSelectionItem,
|
|
13
|
+
]}>
|
|
14
|
+
<Text_1.Text contrast={option.selected ? "high" : "low"}>{option.label}</Text_1.Text>
|
|
15
|
+
</react_native_1.View>);
|
|
16
|
+
}
|
|
17
|
+
const useStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((t) => react_native_1.StyleSheet.create({
|
|
18
|
+
selectionItem: {
|
|
19
|
+
alignItems: "center",
|
|
20
|
+
borderWidth: t.borderWidth,
|
|
21
|
+
borderColor: t.colors.border,
|
|
22
|
+
marginBottom: t.size.baseSize * 2,
|
|
23
|
+
padding: t.size.baseSize * 2,
|
|
24
|
+
borderRadius: t.borderRadius,
|
|
25
|
+
},
|
|
26
|
+
selectedSelectionItem: {
|
|
27
|
+
borderColor: t.colors.primary,
|
|
28
|
+
},
|
|
29
|
+
}), []));
|
|
@@ -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,37 +102,29 @@ 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
124
|
const startBlurAnimation = () => {
|
|
99
|
-
|
|
100
|
-
duration: 200,
|
|
101
|
-
easing: react_native_reanimated_1.Easing.bezier(0.25, 0.1, 0.25, 1),
|
|
102
|
-
});
|
|
125
|
+
setBorderColor(error ? `${styles.itemContainerError.borderColor}40` : styles.itemContainer.borderColor);
|
|
103
126
|
if (!value) {
|
|
104
|
-
animatedValue.value = (0, react_native_reanimated_1.withTiming)(0,
|
|
105
|
-
duration: 200,
|
|
106
|
-
easing: react_native_reanimated_1.Easing.bezier(0.25, 0.1, 0.25, 1),
|
|
107
|
-
});
|
|
127
|
+
animatedValue.value = (0, react_native_reanimated_1.withTiming)(0, animations_1.DEFAULT_TIMING_CONFIG);
|
|
108
128
|
}
|
|
109
129
|
};
|
|
110
130
|
const handleOnBlur = ({ nativeEvent }) => {
|
|
@@ -112,10 +132,7 @@ exports.TextInput = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
112
132
|
startBlurAnimation();
|
|
113
133
|
};
|
|
114
134
|
const onFocus = () => {
|
|
115
|
-
|
|
116
|
-
duration: 200,
|
|
117
|
-
easing: react_native_reanimated_1.Easing.bezier(0.25, 0.1, 0.25, 1),
|
|
118
|
-
});
|
|
135
|
+
setBorderColor(error ? styles.itemContainerError.borderColor : styles.itemContainerFocused.borderColor);
|
|
119
136
|
};
|
|
120
137
|
return (<react_native_1.View style={styles.container}>
|
|
121
138
|
<react_native_1.Pressable onPress={() => {
|
|
@@ -124,7 +141,7 @@ exports.TextInput = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
124
141
|
}} style={styles.pressable} disabled={disabled}>
|
|
125
142
|
<react_native_reanimated_1.default.View style={[
|
|
126
143
|
styles.itemContainer,
|
|
127
|
-
|
|
144
|
+
animatedBorderStyle,
|
|
128
145
|
containerStyle,
|
|
129
146
|
]}>
|
|
130
147
|
<react_native_1.View pointerEvents="none" style={styles.labelContainer}>
|
|
@@ -133,16 +150,17 @@ exports.TextInput = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
133
150
|
</react_native_reanimated_1.default.Text>
|
|
134
151
|
</react_native_1.View>
|
|
135
152
|
<react_native_reanimated_1.default.View style={animatedInputStyles}>
|
|
136
|
-
{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}/>)}
|
|
137
154
|
</react_native_reanimated_1.default.View>
|
|
138
155
|
</react_native_reanimated_1.default.View>
|
|
139
156
|
</react_native_1.Pressable>
|
|
157
|
+
{!!error && (<FieldError_1.FieldError error={error}/>)}
|
|
140
158
|
{!!caption && <MenuItemDescription_1.MenuItemDescription description={caption}/>}
|
|
141
159
|
</react_native_1.View>);
|
|
142
160
|
});
|
|
143
161
|
exports.default = exports.TextInput;
|
|
144
162
|
exports.TextInput.displayName = "TextInput";
|
|
145
|
-
const useStyles = (disabled) => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((theme) => react_native_1.StyleSheet.create({
|
|
163
|
+
const useStyles = (disabled, error) => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((theme) => react_native_1.StyleSheet.create({
|
|
146
164
|
container: {
|
|
147
165
|
width: "100%",
|
|
148
166
|
flexShrink: 0.5,
|
|
@@ -151,30 +169,54 @@ const useStyles = (disabled) => (0, hooks_1.useThemedStyle)((0, react_1.useCallb
|
|
|
151
169
|
flexGrow: 2,
|
|
152
170
|
flexShrink: 1,
|
|
153
171
|
},
|
|
154
|
-
textInput: Object.assign(Object.assign({ paddingHorizontal: theme.size.baseSize * 2 }, theme.typography.p1),
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
+
})),
|
|
160
194
|
itemContainer: {
|
|
161
195
|
borderWidth: theme.borderWidth,
|
|
162
|
-
borderColor: theme.colors.borderSecondary,
|
|
163
196
|
backgroundColor: theme.colors.backgroundOnPrimary,
|
|
164
197
|
borderRadius: theme.borderRadius,
|
|
165
198
|
minHeight: theme.size.baseSize * 8,
|
|
166
199
|
flexDirection: "row",
|
|
167
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,
|
|
168
208
|
},
|
|
169
209
|
labelContainer: {
|
|
170
210
|
left: theme.size.baseSize * 2,
|
|
171
211
|
position: "absolute",
|
|
172
212
|
},
|
|
173
|
-
label:
|
|
174
|
-
|
|
175
|
-
|
|
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
|
+
}),
|
|
176
218
|
descriptionContainer: {
|
|
177
219
|
marginHorizontal: theme.size.baseSize * 4,
|
|
178
220
|
marginBottom: theme.size.baseSize * 2,
|
|
179
221
|
},
|
|
180
|
-
}), [disabled]));
|
|
222
|
+
}), [disabled, error]));
|
|
@@ -37,13 +37,6 @@ const TitleBarHeight = 60;
|
|
|
37
37
|
const TitleBar = ({ title, onBackPressed, canGoBack = true, rightItem, titleComponent, type = "default", containerStyle = {}, }) => {
|
|
38
38
|
const isModal = type === "modal";
|
|
39
39
|
const styles = useStyles(canGoBack, isModal).styles;
|
|
40
|
-
// const edges: [] = useMemo(() => {
|
|
41
|
-
// let _edges: [] = ['right', 'left'];
|
|
42
|
-
// if (!isModal) {
|
|
43
|
-
// _edges = [..._edges, 'top'];
|
|
44
|
-
// }
|
|
45
|
-
// return _edges;
|
|
46
|
-
// }, [isModal]);
|
|
47
40
|
const handleOnBackPress = (0, react_1.useCallback)(() => {
|
|
48
41
|
if (!onBackPressed) {
|
|
49
42
|
return;
|
package/dist/components/index.js
CHANGED
|
@@ -25,5 +25,6 @@ __exportStar(require("./NavigationListRow"), exports);
|
|
|
25
25
|
__exportStar(require("./DragHandle"), exports);
|
|
26
26
|
__exportStar(require("./TitleBar"), exports);
|
|
27
27
|
__exportStar(require("./SelectInput"), exports);
|
|
28
|
+
__exportStar(require("./Search"), exports);
|
|
28
29
|
// Forms
|
|
29
30
|
__exportStar(require("./Forms"), exports);
|
|
@@ -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
|
+
};
|
|
@@ -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,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
interface NumericKeyboardProps {
|
|
3
|
-
mode?: "integer" | "float";
|
|
4
|
-
setValue: React.Dispatch<React.SetStateAction<string>>;
|
|
5
|
-
onHide?: () => void;
|
|
6
|
-
height: number;
|
|
7
|
-
open: boolean;
|
|
8
|
-
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
9
|
-
}
|
|
10
|
-
declare const NumericKeyboard: ({ setValue, onHide, open, setOpen, height, mode, }: NumericKeyboardProps) => React.JSX.Element;
|
|
11
|
-
export default NumericKeyboard;
|
|
@@ -1,170 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const react_1 = __importStar(require("react"));
|
|
30
|
-
const react_native_1 = require("react-native");
|
|
31
|
-
const Ionicons_1 = __importDefault(require("react-native-vector-icons/Ionicons"));
|
|
32
|
-
const react_native_safe_area_context_1 = require("react-native-safe-area-context");
|
|
33
|
-
const Text_1 = require("../Text");
|
|
34
|
-
const useThemedStyle_1 = require("../../hooks/useThemedStyle");
|
|
35
|
-
const BottomSheet_1 = require("../BottomSheet/BottomSheet");
|
|
36
|
-
const keypad = [
|
|
37
|
-
[7, 8, 9],
|
|
38
|
-
[4, 5, 6],
|
|
39
|
-
[1, 2, 3],
|
|
40
|
-
[null, 0, "."],
|
|
41
|
-
];
|
|
42
|
-
const NumericKeyboard = ({ setValue, onHide, open, setOpen, height, mode = "float", }) => {
|
|
43
|
-
const styles = useStyles().styles;
|
|
44
|
-
const [firstTouch, setFirstTouch] = (0, react_1.useState)(true);
|
|
45
|
-
const onPressKeypadButton = (value) => {
|
|
46
|
-
if (!value) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (typeof value === "number") {
|
|
50
|
-
if (firstTouch) {
|
|
51
|
-
setValue(`${value}`);
|
|
52
|
-
setFirstTouch(false);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
setValue((prevState) => {
|
|
56
|
-
const isZero = prevState === "0";
|
|
57
|
-
return !isZero ? `${prevState}${value}` : `${value}`;
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
else if (typeof value === "string") {
|
|
61
|
-
setValue(() => {
|
|
62
|
-
return `${value}`;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const onPressBackspace = () => {
|
|
67
|
-
setValue((prevState) => {
|
|
68
|
-
let string = String(prevState);
|
|
69
|
-
if (string.length > 1) {
|
|
70
|
-
return string.substr(0, string.length - 1);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
return "0";
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
const handleOnPressKeyPadButton = (value) => {
|
|
78
|
-
value !== null && onPressKeypadButton(value);
|
|
79
|
-
};
|
|
80
|
-
const handleOnHide = () => {
|
|
81
|
-
setFirstTouch(true);
|
|
82
|
-
setOpen(false);
|
|
83
|
-
onHide === null || onHide === void 0 ? void 0 : onHide();
|
|
84
|
-
};
|
|
85
|
-
return (<BottomSheet_1.BottomSheet open={open} height={height} defaultMargins={true}>
|
|
86
|
-
<react_native_1.View style={styles.keyboardContainer}>
|
|
87
|
-
<react_native_1.View style={styles.keypadContainer}>
|
|
88
|
-
{keypad.map((row, index) => (<react_native_1.View key={index.toString()} style={styles.keypadRow}>
|
|
89
|
-
{row.map((column, colIndex) => {
|
|
90
|
-
if (mode === "integer" && column === ".") {
|
|
91
|
-
return (<react_native_1.View key={colIndex + "hidden"} style={styles.keypadCellHidden}/>);
|
|
92
|
-
}
|
|
93
|
-
return (<react_native_1.TouchableOpacity key={colIndex} onPress={() => {
|
|
94
|
-
column !== null
|
|
95
|
-
? handleOnPressKeyPadButton(column)
|
|
96
|
-
: handleOnHide();
|
|
97
|
-
}} style={[
|
|
98
|
-
styles.keypadCell,
|
|
99
|
-
column === null && styles.keypadCellDisabled,
|
|
100
|
-
]}>
|
|
101
|
-
{column !== null ? (<Text_1.Text contrast="low" category="h1" style={styles.keypadCellText}>
|
|
102
|
-
{column}
|
|
103
|
-
</Text_1.Text>) : (<Ionicons_1.default style={styles.keypadCellText} name="caret-down-outline" size={23}/>)}
|
|
104
|
-
</react_native_1.TouchableOpacity>);
|
|
105
|
-
})}
|
|
106
|
-
</react_native_1.View>))}
|
|
107
|
-
</react_native_1.View>
|
|
108
|
-
<react_native_1.View style={styles.keyboardSideBar}>
|
|
109
|
-
<react_native_1.TouchableOpacity onPress={onPressBackspace} style={styles.backspaceKey}>
|
|
110
|
-
<Ionicons_1.default name="backspace-outline" size={28} color={styles.backspaceIcon.color}/>
|
|
111
|
-
</react_native_1.TouchableOpacity>
|
|
112
|
-
<react_native_1.View />
|
|
113
|
-
</react_native_1.View>
|
|
114
|
-
</react_native_1.View>
|
|
115
|
-
</BottomSheet_1.BottomSheet>);
|
|
116
|
-
};
|
|
117
|
-
const useStyles = () => {
|
|
118
|
-
const insets = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
|
|
119
|
-
return (0, useThemedStyle_1.useThemedStyle)((0, react_1.useCallback)((theme) => react_native_1.StyleSheet.create({
|
|
120
|
-
keypadContainer: {
|
|
121
|
-
flex: 0.78,
|
|
122
|
-
},
|
|
123
|
-
keyboardSideBar: {
|
|
124
|
-
flex: 0.22,
|
|
125
|
-
},
|
|
126
|
-
backspaceKey: {
|
|
127
|
-
flex: 0.5,
|
|
128
|
-
margin: 2,
|
|
129
|
-
alignItems: "center",
|
|
130
|
-
justifyContent: "center",
|
|
131
|
-
borderRadius: theme.borderRadius,
|
|
132
|
-
backgroundColor: theme.colors.foregroundNegative,
|
|
133
|
-
},
|
|
134
|
-
keypadCell: {
|
|
135
|
-
flex: 1 / 3,
|
|
136
|
-
margin: 2,
|
|
137
|
-
justifyContent: "center",
|
|
138
|
-
borderRadius: theme.borderRadius,
|
|
139
|
-
backgroundColor: theme.colors.foreground,
|
|
140
|
-
},
|
|
141
|
-
keypadCellHidden: {
|
|
142
|
-
flex: 1 / 3,
|
|
143
|
-
margin: 2,
|
|
144
|
-
justifyContent: "center",
|
|
145
|
-
borderRadius: theme.borderRadius,
|
|
146
|
-
backgroundColor: theme.colors.backgroundPrimary,
|
|
147
|
-
},
|
|
148
|
-
keypadCellDisabled: {
|
|
149
|
-
backgroundColor: theme.colors.foregroundLowContrast,
|
|
150
|
-
},
|
|
151
|
-
keypadCellText: {
|
|
152
|
-
textAlign: "center",
|
|
153
|
-
},
|
|
154
|
-
keypadRow: {
|
|
155
|
-
flex: 1,
|
|
156
|
-
flexDirection: "row",
|
|
157
|
-
},
|
|
158
|
-
keyboardContainer: {
|
|
159
|
-
paddingBottom: insets.bottom,
|
|
160
|
-
backgroundColor: theme.colors.backgroundPrimary,
|
|
161
|
-
flexDirection: "row",
|
|
162
|
-
flex: 1,
|
|
163
|
-
paddingHorizontal: theme.size.baseSize * 2,
|
|
164
|
-
},
|
|
165
|
-
backspaceIcon: {
|
|
166
|
-
color: theme.colors.foregroundHighContrast,
|
|
167
|
-
},
|
|
168
|
-
}), [insets]));
|
|
169
|
-
};
|
|
170
|
-
exports.default = NumericKeyboard;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './NumericKeyboard';
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useStylesCreator = useStylesCreator;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const react_native_1 = require("react-native");
|
|
6
|
-
const useThemedStyle_1 = require("./useThemedStyle");
|
|
7
|
-
function useStylesCreator(styles) {
|
|
8
|
-
return (0, useThemedStyle_1.useThemedStyle)((0, react_1.useCallback)(t => react_native_1.StyleSheet.create(styles), [styles])).styles;
|
|
9
|
-
}
|