atlas-design-system 1.9.3 → 1.10.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.
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ type ChevronProps = {
3
+ direction: "up" | "down";
4
+ };
5
+ export default function Chevron({ direction }: ChevronProps): React.JSX.Element;
6
+ export {};
@@ -0,0 +1,58 @@
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.default = Chevron;
30
+ const react_1 = __importStar(require("react"));
31
+ const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
32
+ const react_native_1 = require("react-native");
33
+ const Ionicons_1 = __importDefault(require("react-native-vector-icons/Ionicons"));
34
+ const hooks_1 = require("../../hooks");
35
+ const animations_1 = require("../../constants/animations");
36
+ function Chevron({ direction = "down" }) {
37
+ const styles = useStyles().styles;
38
+ const rotation = (0, react_native_reanimated_1.useSharedValue)(direction === "up" ? 1 : 0);
39
+ (0, react_1.useEffect)(() => {
40
+ rotation.value = (0, react_native_reanimated_1.withTiming)(direction === "up" ? 1 : 0, animations_1.DEFAULT_TIMING_CONFIG);
41
+ }, [direction]);
42
+ const animatedChevronStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
43
+ return {
44
+ transform: [
45
+ { rotateX: `${(0, react_native_reanimated_1.interpolate)(rotation.value, [0, 1], [0, 180])}deg` },
46
+ ],
47
+ };
48
+ }, [rotation]);
49
+ return (<react_native_reanimated_1.default.View style={animatedChevronStyle}>
50
+ <Ionicons_1.default style={styles.chevron} name="chevron-down-outline" size={20}/>
51
+ </react_native_reanimated_1.default.View>);
52
+ }
53
+ const useStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((t) => react_native_1.StyleSheet.create({
54
+ chevron: {
55
+ paddingRight: t.size.baseSize * 2,
56
+ color: t.colors.foreground,
57
+ },
58
+ }), []));
@@ -0,0 +1,2 @@
1
+ export * from "./Chevron";
2
+ export { default } from "./Chevron";
@@ -0,0 +1,23 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.default = void 0;
21
+ __exportStar(require("./Chevron"), exports);
22
+ var Chevron_1 = require("./Chevron");
23
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(Chevron_1).default; } });
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import { Option } from "../SelectInput/types";
3
+ type RadioOptionInputProps<T> = {
4
+ caption?: string;
5
+ label: string;
6
+ options: Option<T>[];
7
+ onChange: (newValue: Option<T>) => void;
8
+ renderOption?: (option: Option<T>, onPress: (option: Option<T>) => void) => React.ReactNode;
9
+ renderValue?: (option?: Option<T>) => React.ReactNode;
10
+ };
11
+ export declare function RadioOptionInput<T>({ caption, label, options, onChange, renderOption, renderValue, }: RadioOptionInputProps<T>): React.JSX.Element;
12
+ export default RadioOptionInput;
@@ -0,0 +1,80 @@
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.RadioOptionInput = RadioOptionInput;
30
+ const react_1 = __importStar(require("react"));
31
+ const react_native_1 = require("react-native");
32
+ const hooks_1 = require("../../hooks");
33
+ const Sheet_1 = __importDefault(require("../Sheet"));
34
+ const Text_1 = __importDefault(require("../Text"));
35
+ const Chevron_1 = __importDefault(require("../Chevron"));
36
+ const RadioOptionItem_1 = __importDefault(require("../RadioOptionItem"));
37
+ const MenuItemDescription_1 = require("../MenuItemDescription");
38
+ function RadioOptionInput({ caption, label, options = [], onChange, renderOption, renderValue, }) {
39
+ const styles = useStyles().styles;
40
+ const [sheetOpen, setSheetOpen] = react_1.default.useState(false);
41
+ const value = (0, react_1.useMemo)(() => {
42
+ return options.find((v) => v.selected);
43
+ }, [options]);
44
+ const handleOptionPress = (0, react_1.useCallback)((option) => {
45
+ onChange(option);
46
+ setSheetOpen(false);
47
+ }, []);
48
+ return (<>
49
+ <react_native_1.View style={styles.container}>
50
+ <Text_1.default>{label}</Text_1.default>
51
+ <react_native_1.TouchableOpacity onPress={() => setSheetOpen(true)} style={styles.valueDisplayContainer}>
52
+ {!renderValue && <Text_1.default>{value === null || value === void 0 ? void 0 : value.label}</Text_1.default>}
53
+ {renderValue && renderValue(value)}
54
+ <Chevron_1.default direction={sheetOpen ? "up" : "down"}/>
55
+ </react_native_1.TouchableOpacity>
56
+ {!!caption && <MenuItemDescription_1.MenuItemDescription description={caption}/>}
57
+ </react_native_1.View>
58
+ <Sheet_1.default header={label} open={sheetOpen} setOpen={setSheetOpen}>
59
+ {options.map((option) => {
60
+ return renderOption ? (renderOption(option, onChange)) : (<RadioOptionItem_1.default option={option} onPress={() => handleOptionPress(option)} key={option.value}/>);
61
+ })}
62
+ </Sheet_1.default>
63
+ </>);
64
+ }
65
+ const useStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((t) => react_native_1.StyleSheet.create({
66
+ container: {
67
+ padding: t.size.baseSize * 4,
68
+ },
69
+ chevron: {
70
+ paddingRight: t.size.baseSize * 2,
71
+ color: t.colors.foreground,
72
+ },
73
+ valueDisplayContainer: {
74
+ marginTop: t.size.baseSize * 1,
75
+ flexDirection: "row",
76
+ alignItems: "center",
77
+ gap: t.size.baseSize * 2,
78
+ },
79
+ }), []));
80
+ exports.default = RadioOptionInput;
@@ -0,0 +1,2 @@
1
+ export { default } from "./RadioOptionInput";
2
+ export * from "./RadioOptionInput";
@@ -0,0 +1,23 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.default = void 0;
21
+ var RadioOptionInput_1 = require("./RadioOptionInput");
22
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(RadioOptionInput_1).default; } });
23
+ __exportStar(require("./RadioOptionInput"), exports);
@@ -0,0 +1,9 @@
1
+ import { Option } from "../SelectInput/types";
2
+ export type RadioOptionItemProps<T> = {
3
+ option: Option<T>;
4
+ disabled?: boolean;
5
+ onPress?: (value: T) => void;
6
+ renderItem?: (option: Option<T>) => React.ReactNode;
7
+ };
8
+ export declare function RadioOptionItem<T>({ option, onPress, renderItem, disabled, }: RadioOptionItemProps<T>): import("react").JSX.Element;
9
+ export default RadioOptionItem;
@@ -0,0 +1,56 @@
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.RadioOptionItem = RadioOptionItem;
7
+ const react_1 = require("react");
8
+ const react_native_1 = require("react-native");
9
+ const Text_1 = __importDefault(require("../Text"));
10
+ const hooks_1 = require("../../hooks");
11
+ function RadioOptionItem({ option, onPress, renderItem, disabled, }) {
12
+ const { label, value, selected } = option;
13
+ const styles = useStyles(selected).styles;
14
+ return (<react_native_1.Pressable onPress={() => onPress === null || onPress === void 0 ? void 0 : onPress(value)} style={styles.itemContainer} disabled={disabled || !onPress}>
15
+ <react_native_1.View style={styles.itemContent}>
16
+ <react_native_1.View style={[
17
+ styles.radioContainer,
18
+ disabled && styles.radioContainerDisabled,
19
+ ]}>
20
+ {selected && <react_native_1.View style={styles.radio}/>}
21
+ </react_native_1.View>
22
+ {!renderItem && (<Text_1.default contrast={disabled ? "low" : "high"}>{label}</Text_1.default>)}
23
+ {renderItem && renderItem(option)}
24
+ </react_native_1.View>
25
+ </react_native_1.Pressable>);
26
+ }
27
+ const useStyles = (selected) => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((t) => react_native_1.StyleSheet.create({
28
+ itemContainer: {
29
+ paddingVertical: t.size.baseSize * 2,
30
+ paddingHorizontal: t.size.baseSize * 4,
31
+ },
32
+ itemContent: {
33
+ flexDirection: "row",
34
+ alignItems: "center",
35
+ gap: t.size.baseSize * 2,
36
+ },
37
+ radioContainer: {
38
+ width: t.size.baseSize * 4,
39
+ height: t.size.baseSize * 4,
40
+ borderRadius: t.size.baseSize * 2,
41
+ borderWidth: t.borderWidth,
42
+ borderColor: selected ? t.colors.primary : t.colors.border,
43
+ justifyContent: "center",
44
+ alignItems: "center",
45
+ },
46
+ radioContainerDisabled: {
47
+ borderColor: t.colors.backgroundOnPrimary,
48
+ },
49
+ radio: {
50
+ width: t.size.baseSize * 2,
51
+ height: t.size.baseSize * 2,
52
+ borderRadius: t.size.baseSize,
53
+ backgroundColor: t.colors.primary,
54
+ },
55
+ }), [selected]));
56
+ exports.default = RadioOptionItem;
@@ -0,0 +1,2 @@
1
+ export { default } from "./RadioOptionItem";
2
+ export * from "./RadioOptionItem";
@@ -0,0 +1,23 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.default = void 0;
21
+ var RadioOptionItem_1 = require("./RadioOptionItem");
22
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(RadioOptionItem_1).default; } });
23
+ __exportStar(require("./RadioOptionItem"), exports);
@@ -30,14 +30,13 @@ exports.SelectInput = SelectInput;
30
30
  const react_1 = __importStar(require("react"));
31
31
  const react_native_1 = require("react-native");
32
32
  const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
33
- const Ionicons_1 = __importDefault(require("react-native-vector-icons/Ionicons"));
34
33
  const Text_1 = __importDefault(require("../Text"));
35
34
  const Sheet_1 = __importDefault(require("../Sheet"));
36
35
  const MenuItemDescription_1 = require("../MenuItemDescription");
37
36
  const hooks_1 = require("../../hooks");
38
37
  const useInputFieldAnimatedBorder_1 = require("../../hooks/useInputFieldAnimatedBorder");
39
- const animations_1 = require("../../constants/animations");
40
38
  const SelectionItem_1 = __importDefault(require("./components/SelectionItem"));
39
+ const Chevron_1 = __importDefault(require("../Chevron"));
41
40
  function SelectInput({ caption, label, options = [], onChange, error, renderOption, containerStyle, }) {
42
41
  const styles = useStyles().styles;
43
42
  const value = (0, react_1.useMemo)(() => {
@@ -45,7 +44,6 @@ function SelectInput({ caption, label, options = [], onChange, error, renderOpti
45
44
  }, [options]);
46
45
  const [sheetOpen, setSheetOpen] = (0, react_1.useState)(false);
47
46
  const animatedValue = (0, react_native_reanimated_1.useSharedValue)(value ? 1 : 0);
48
- const rotation = (0, react_native_reanimated_1.useSharedValue)(sheetOpen ? 1 : 0);
49
47
  const { animatedBorderStyle, setBorderColor } = (0, useInputFieldAnimatedBorder_1.useInputFieldAnimatedBorder)(styles.itemContainer.borderColor);
50
48
  (0, react_1.useEffect)(() => {
51
49
  if (error) {
@@ -56,9 +54,6 @@ function SelectInput({ caption, label, options = [], onChange, error, renderOpti
56
54
  ? styles.itemContainerFocused.borderColor
57
55
  : styles.itemContainer.borderColor);
58
56
  }, [error, sheetOpen]);
59
- (0, react_1.useEffect)(() => {
60
- rotation.value = (0, react_native_reanimated_1.withTiming)(sheetOpen ? 1 : 0, animations_1.DEFAULT_TIMING_CONFIG);
61
- }, [sheetOpen]);
62
57
  (0, react_1.useEffect)(() => {
63
58
  animatedValue.value = value ? 1 : 0;
64
59
  }, [value]);
@@ -76,13 +71,6 @@ function SelectInput({ caption, label, options = [], onChange, error, renderOpti
76
71
  transform: [{ translateY: animatedValue.value * 6 }],
77
72
  };
78
73
  }, [animatedValue]);
79
- const animatedChevronStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
80
- return {
81
- transform: [
82
- { rotateX: `${(0, react_native_reanimated_1.interpolate)(rotation.value, [0, 1], [0, 180])}deg` },
83
- ],
84
- };
85
- }, [rotation]);
86
74
  const handleOptionPress = (0, react_1.useCallback)((option) => {
87
75
  onChange(option);
88
76
  setSheetOpen(false);
@@ -100,9 +88,7 @@ function SelectInput({ caption, label, options = [], onChange, error, renderOpti
100
88
  {value.label}
101
89
  </Text_1.default>)}
102
90
  </react_native_reanimated_1.default.View>
103
- <react_native_reanimated_1.default.View style={animatedChevronStyle}>
104
- <Ionicons_1.default style={styles.chevron} name="chevron-down-outline" size={20}/>
105
- </react_native_reanimated_1.default.View>
91
+ <Chevron_1.default direction={sheetOpen ? "up" : "down"}/>
106
92
  </react_native_reanimated_1.default.View>
107
93
  </react_native_1.TouchableOpacity>
108
94
  {!!caption && <MenuItemDescription_1.MenuItemDescription description={caption}/>}
@@ -11,4 +11,7 @@ export * from "./TitleBar";
11
11
  export * from "./SelectInput";
12
12
  export * from "./Search";
13
13
  export * from "./SegmentedControl";
14
+ export * from "./RadioOptionItem";
15
+ export * from "./RadioOptionInput";
16
+ export * from "./Chevron";
14
17
  export * from "./Forms";
@@ -27,5 +27,8 @@ __exportStar(require("./TitleBar"), exports);
27
27
  __exportStar(require("./SelectInput"), exports);
28
28
  __exportStar(require("./Search"), exports);
29
29
  __exportStar(require("./SegmentedControl"), exports);
30
+ __exportStar(require("./RadioOptionItem"), exports);
31
+ __exportStar(require("./RadioOptionInput"), exports);
32
+ __exportStar(require("./Chevron"), exports);
30
33
  // Forms
31
34
  __exportStar(require("./Forms"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atlas-design-system",
3
- "version": "1.9.3",
3
+ "version": "1.10.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",