atlas-design-system 1.3.1 → 1.4.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/BottomSheet/BottomSheet.d.ts +11 -0
- package/dist/components/BottomSheet/BottomSheet.js +98 -0
- package/dist/components/DateTimeInput/index.d.ts +1 -2
- package/dist/components/DateTimeInput/index.js +3 -8
- 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 +11 -0
- package/dist/components/Forms/FormDateTimeInput/index.d.ts +1 -0
- package/dist/components/Forms/FormDateTimeInput/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 +16 -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 +4 -0
- package/dist/components/Forms/index.js +20 -0
- package/dist/components/NumericKeyboard/NumericKeyboard.d.ts +11 -0
- package/dist/components/NumericKeyboard/NumericKeyboard.js +170 -0
- package/dist/components/NumericKeyboard/index.d.ts +1 -0
- package/dist/components/NumericKeyboard/index.js +17 -0
- package/dist/components/TextInput/TextInput.js +6 -3
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +2 -0
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/useStylesCreator.d.ts +2 -0
- package/dist/hooks/useStylesCreator.js +9 -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 = {
|
|
@@ -12,5 +11,5 @@ export type DateTimeInputProps = {
|
|
|
12
11
|
containerStyle?: StyleProp<ViewStyle>;
|
|
13
12
|
mode?: IOSNativeProps['mode'] | AndroidNativeProps['mode'];
|
|
14
13
|
};
|
|
15
|
-
export declare const DateTimeInput: ({ value, onChange, testID, containerStyle, label, caption, mode, disabled, onSave, }: DateTimeInputProps) =>
|
|
14
|
+
export declare const DateTimeInput: ({ value, onChange, testID, containerStyle, label, caption, mode, disabled, onSave, }: DateTimeInputProps) => import("react").JSX.Element;
|
|
16
15
|
export default DateTimeInput;
|
|
@@ -27,11 +27,11 @@ 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"));
|
|
@@ -92,12 +92,7 @@ const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption
|
|
|
92
92
|
{(0, moment_1.default)(value).format(getFormat(mode)).toString()}
|
|
93
93
|
</Text_1.default>
|
|
94
94
|
</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
|
-
/>*/}
|
|
95
|
+
<Ionicons_1.default style={styles.iconRight} color={!disabled ? theme.colors.foreground : theme.colors.foregroundLowContrast} name={mode === 'time' ? 'time-outline' : 'calendar-outline'} size={20}/>
|
|
101
96
|
</react_native_reanimated_1.default.View>
|
|
102
97
|
</react_native_1.TouchableOpacity>
|
|
103
98
|
{!!caption && <MenuItemDescription_1.MenuItemDescription description={caption}/>}
|
|
@@ -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,11 @@
|
|
|
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 } = (0, informed_1.useField)(Object.assign({ type: "date" }, props));
|
|
8
|
+
return render(<DateTimeInput_1.DateTimeInput value={informed.value} onSave={fieldApi.setValue} {...userProps}/>);
|
|
9
|
+
};
|
|
10
|
+
exports.FormDateTimeInput = FormDateTimeInput;
|
|
11
|
+
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,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,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.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 } = (0, informed_1.useField)(Object.assign({ type: 'text' }, props));
|
|
12
|
+
const { value } = informed;
|
|
13
|
+
return render(<TextInput_1.TextInput onChangeText={fieldApi.setValue} {...userProps} value={value}/>);
|
|
14
|
+
};
|
|
15
|
+
exports.FormTextInput = FormTextInput;
|
|
16
|
+
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,20 @@
|
|
|
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);
|
|
@@ -0,0 +1,11 @@
|
|
|
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;
|
|
@@ -0,0 +1,170 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NumericKeyboard';
|
|
@@ -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("./NumericKeyboard"), exports);
|
|
@@ -95,8 +95,7 @@ exports.TextInput = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
95
95
|
easing: react_native_reanimated_1.Easing.bezier(0.25, 0.1, 0.25, 1),
|
|
96
96
|
});
|
|
97
97
|
};
|
|
98
|
-
const
|
|
99
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur(nativeEvent.text);
|
|
98
|
+
const startBlurAnimation = () => {
|
|
100
99
|
focusedValue.value = (0, react_native_reanimated_1.withTiming)(0, {
|
|
101
100
|
duration: 200,
|
|
102
101
|
easing: react_native_reanimated_1.Easing.bezier(0.25, 0.1, 0.25, 1),
|
|
@@ -108,6 +107,10 @@ exports.TextInput = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
108
107
|
});
|
|
109
108
|
}
|
|
110
109
|
};
|
|
110
|
+
const handleOnBlur = ({ nativeEvent }) => {
|
|
111
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(nativeEvent.text);
|
|
112
|
+
startBlurAnimation();
|
|
113
|
+
};
|
|
111
114
|
const onFocus = () => {
|
|
112
115
|
focusedValue.value = (0, react_native_reanimated_1.withTiming)(1, {
|
|
113
116
|
duration: 200,
|
|
@@ -138,7 +141,7 @@ exports.TextInput = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
138
141
|
</react_native_1.View>);
|
|
139
142
|
});
|
|
140
143
|
exports.default = exports.TextInput;
|
|
141
|
-
exports.TextInput.displayName =
|
|
144
|
+
exports.TextInput.displayName = "TextInput";
|
|
142
145
|
const useStyles = (disabled) => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((theme) => react_native_1.StyleSheet.create({
|
|
143
146
|
container: {
|
|
144
147
|
width: "100%",
|
package/dist/components/index.js
CHANGED
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,9 @@
|
|
|
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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atlas-design-system",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
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",
|