atlas-design-system 1.4.1 → 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/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 +2 -1
- package/dist/components/SelectInput/SelectInput.js +8 -21
- package/dist/components/SelectInput/components/SelectionItem.d.ts +5 -0
- package/dist/components/SelectInput/components/SelectionItem.js +29 -0
- package/dist/components/TitleBar/TitleBar.js +0 -7
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/package.json +1 -1
|
@@ -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);
|
|
@@ -6,6 +6,7 @@ export type SelectInputProps<T> = {
|
|
|
6
6
|
options: Option<T>[];
|
|
7
7
|
onChange: (newValue: Option<T>) => void;
|
|
8
8
|
error?: string;
|
|
9
|
+
renderOption?: (option: Option<T>) => React.ReactNode;
|
|
9
10
|
};
|
|
10
|
-
export declare function SelectInput<T>({ caption, label, options, onChange, error, }: SelectInputProps<T>): React.JSX.Element;
|
|
11
|
+
export declare function SelectInput<T>({ caption, label, options, onChange, error, renderOption, }: SelectInputProps<T>): React.JSX.Element;
|
|
11
12
|
export default SelectInput;
|
|
@@ -37,8 +37,9 @@ const MenuItemDescription_1 = require("../MenuItemDescription");
|
|
|
37
37
|
const hooks_1 = require("../../hooks");
|
|
38
38
|
const useInputFieldAnimatedBorder_1 = require("../../hooks/useInputFieldAnimatedBorder");
|
|
39
39
|
const animations_1 = require("../../constants/animations");
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
const SelectionItem_1 = __importDefault(require("./components/SelectionItem"));
|
|
41
|
+
function SelectInput({ caption, label, options = [], onChange, error, renderOption, }) {
|
|
42
|
+
const styles = useStyles().styles;
|
|
42
43
|
const values = (0, react_1.useMemo)(() => {
|
|
43
44
|
return options.filter((v) => v.selected);
|
|
44
45
|
}, options);
|
|
@@ -51,7 +52,9 @@ function SelectInput({ caption, label, options = [], onChange, error, }) {
|
|
|
51
52
|
setBorderColor(styles.itemContainerError.borderColor);
|
|
52
53
|
return;
|
|
53
54
|
}
|
|
54
|
-
setBorderColor(sheetOpen
|
|
55
|
+
setBorderColor(sheetOpen
|
|
56
|
+
? styles.itemContainerFocused.borderColor
|
|
57
|
+
: styles.itemContainer.borderColor);
|
|
55
58
|
}, [error, sheetOpen]);
|
|
56
59
|
(0, react_1.useEffect)(() => {
|
|
57
60
|
rotation.value = (0, react_native_reanimated_1.withTiming)(sheetOpen ? 1 : 0, animations_1.DEFAULT_TIMING_CONFIG);
|
|
@@ -104,13 +107,8 @@ function SelectInput({ caption, label, options = [], onChange, error, }) {
|
|
|
104
107
|
</react_native_1.TouchableOpacity>
|
|
105
108
|
{!!caption && <MenuItemDescription_1.MenuItemDescription description={caption}/>}
|
|
106
109
|
<Sheet_1.default open={sheetOpen} setOpen={setSheetOpen} header={label}>
|
|
107
|
-
{options.map((option, i) => (<react_native_1.TouchableOpacity
|
|
108
|
-
|
|
109
|
-
option.selected && styles.selectedSelectionItem,
|
|
110
|
-
]} key={i} onPress={() => handleOptionPress(option)}>
|
|
111
|
-
<Text_1.default contrast={option.selected ? "high" : "low"}>
|
|
112
|
-
{option.label}
|
|
113
|
-
</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}/>)}
|
|
114
112
|
</react_native_1.TouchableOpacity>))}
|
|
115
113
|
</Sheet_1.default>
|
|
116
114
|
</>);
|
|
@@ -120,17 +118,6 @@ const useStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((th
|
|
|
120
118
|
paddingRight: theme.size.baseSize * 2,
|
|
121
119
|
color: theme.colors.foreground,
|
|
122
120
|
},
|
|
123
|
-
selectedSelectionItem: {
|
|
124
|
-
borderColor: theme.colors.primary,
|
|
125
|
-
},
|
|
126
|
-
selectionItem: {
|
|
127
|
-
alignItems: "center",
|
|
128
|
-
borderWidth: theme.borderWidth,
|
|
129
|
-
borderColor: theme.colors.border,
|
|
130
|
-
marginBottom: theme.size.baseSize * 2,
|
|
131
|
-
padding: theme.size.baseSize * 2,
|
|
132
|
-
borderRadius: theme.borderRadius,
|
|
133
|
-
},
|
|
134
121
|
itemContainer: {
|
|
135
122
|
borderWidth: theme.borderWidth,
|
|
136
123
|
borderColor: theme.colors.backgroundPrimary,
|
|
@@ -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
|
+
}), []));
|
|
@@ -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);
|