@ovotech/element-native 4.0.2 → 4.0.3-canary-a852513-261
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/ActionCard/ActionCard.js +6 -1
- package/dist/components/Disclosure/Disclosure.js +1 -1
- package/dist/components/FilterSelect/FilterSelect.js +1 -1
- package/dist/components/NavHeader/IconButton.js +4 -3
- package/dist/components/NavHeader/NavHeader.js +8 -6
- package/dist/components/NavHeader/NavHeader.styles.d.ts +5 -2
- package/dist/components/NavHeader/NavHeader.styles.js +16 -11
- package/dist/components/SegmentedControls/SegmentedControls.d.ts +16 -0
- package/dist/components/SegmentedControls/SegmentedControls.js +105 -0
- package/dist/components/SegmentedControls/components/SegmentButton.d.ts +13 -0
- package/dist/components/SegmentedControls/components/SegmentButton.js +94 -0
- package/dist/components/SegmentedControls/index.d.ts +2 -0
- package/dist/components/SegmentedControls/index.js +5 -0
- package/dist/components/TextLink/TextLink.js +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/esm/components/ActionCard/ActionCard.js +6 -1
- package/dist/esm/components/Disclosure/Disclosure.js +1 -1
- package/dist/esm/components/FilterSelect/FilterSelect.js +1 -1
- package/dist/esm/components/NavHeader/IconButton.js +3 -2
- package/dist/esm/components/NavHeader/NavHeader.js +8 -6
- package/dist/esm/components/NavHeader/NavHeader.styles.js +16 -11
- package/dist/esm/components/SegmentedControls/SegmentedControls.js +78 -0
- package/dist/esm/components/SegmentedControls/components/SegmentButton.js +64 -0
- package/dist/esm/components/SegmentedControls/index.js +2 -0
- package/dist/esm/components/TextLink/TextLink.js +1 -1
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/providers/IconsProvider.js +22 -24
- package/dist/esm/providers/icons/CaretArrowDown.js +14 -0
- package/dist/esm/providers/icons/CaretArrowLeft.js +14 -0
- package/dist/esm/providers/icons/CaretArrowRight.js +14 -0
- package/dist/esm/providers/icons/CaretArrowUp.js +14 -0
- package/dist/esm/providers/icons/Chart.js +1 -1
- package/dist/esm/providers/icons/ChartFilled.js +1 -1
- package/dist/esm/providers/icons/Gas.js +1 -1
- package/dist/esm/providers/icons/HomeFilled.js +1 -1
- package/dist/esm/providers/icons/Logo.js +2 -2
- package/dist/esm/providers/icons/MessageFilled.js +1 -1
- package/dist/esm/providers/icons/Show.js +1 -1
- package/dist/esm/providers/icons/StarFilled.js +1 -1
- package/dist/esm/providers/icons/Trees.js +1 -1
- package/dist/esm/providers/icons/User.js +1 -1
- package/dist/esm/providers/icons/UserFilled.js +1 -1
- package/dist/esm/providers/icons/index.js +19 -21
- package/dist/providers/IconsProvider.js +21 -23
- package/dist/providers/icons/CaretArrowDown.d.ts +2 -0
- package/dist/providers/icons/CaretArrowDown.js +41 -0
- package/dist/providers/icons/CaretArrowLeft.d.ts +2 -0
- package/dist/providers/icons/CaretArrowLeft.js +41 -0
- package/dist/providers/icons/CaretArrowRight.d.ts +2 -0
- package/dist/providers/icons/CaretArrowRight.js +41 -0
- package/dist/providers/icons/CaretArrowUp.d.ts +2 -0
- package/dist/providers/icons/CaretArrowUp.js +41 -0
- package/dist/providers/icons/Chart.js +1 -1
- package/dist/providers/icons/ChartFilled.js +1 -1
- package/dist/providers/icons/Gas.js +1 -1
- package/dist/providers/icons/HomeFilled.js +1 -1
- package/dist/providers/icons/Logo.js +25 -2
- package/dist/providers/icons/MessageFilled.js +1 -1
- package/dist/providers/icons/Show.js +1 -1
- package/dist/providers/icons/StarFilled.js +1 -1
- package/dist/providers/icons/Trees.js +1 -1
- package/dist/providers/icons/User.js +1 -1
- package/dist/providers/icons/UserFilled.js +1 -1
- package/dist/providers/icons/index.d.ts +19 -21
- package/dist/providers/icons/index.js +19 -21
- package/dist/providers/types.d.ts +1 -1
- package/package.json +3 -3
|
@@ -50,6 +50,11 @@ var StyledP = (0, styled_native_1.default)(P_1.P)(function (_a) {
|
|
|
50
50
|
var ActionCard = function (_a) {
|
|
51
51
|
var onPressCloseButton = _a.onPressCloseButton, onPressActionButton = _a.onPressActionButton, onPressIndicator = _a.onPressIndicator, onMount = _a.onMount, body = _a.body, title = _a.title, buttonTitle = _a.buttonTitle, ctaVariant = _a.ctaVariant, image = _a.image, testID = _a.testID, _b = _a.accessibilityLabel, accessibilityLabel = _b === void 0 ? 'image' : _b, _c = _a.inverted, inverted = _c === void 0 ? false : _c, _d = _a.inline, inline = _d === void 0 ? false : _d;
|
|
52
52
|
var _e = (0, react_1.useContext)(styled_native_1.ThemeContext), core = _e.core, semantic = _e.semantic;
|
|
53
|
+
var hasSingleAction = (onPressActionButton && !onPressIndicator && !onPressCloseButton) ||
|
|
54
|
+
(onPressIndicator && !onPressActionButton && !onPressCloseButton);
|
|
55
|
+
var cardAction = hasSingleAction
|
|
56
|
+
? onPressActionButton || onPressIndicator
|
|
57
|
+
: null;
|
|
53
58
|
(0, react_1.useEffect)(function () {
|
|
54
59
|
if (onMount) {
|
|
55
60
|
onMount();
|
|
@@ -58,7 +63,7 @@ var ActionCard = function (_a) {
|
|
|
58
63
|
var Heading = inline ? __1.Heading3 : __1.Heading2;
|
|
59
64
|
var cardPadding = core.space[inline ? 4 : 6];
|
|
60
65
|
var negativeMarginAdjustment = -cardPadding;
|
|
61
|
-
return ((0, jsx_runtime_1.jsx)(StyledCard, { onPress:
|
|
66
|
+
return ((0, jsx_runtime_1.jsx)(StyledCard, { onPress: cardAction, inline: inline, inverted: inverted, reducedBottomPadding: Boolean(buttonTitle && !ctaVariant), testID: "".concat(testID, "-card"), children: (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: { flexDirection: 'row' }, children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { style: { flex: 1 }, children: (0, jsx_runtime_1.jsxs)(__1.Stack, { spaceBetween: 2, children: [(0, jsx_runtime_1.jsx)(Heading, { style: {
|
|
62
67
|
color: inverted
|
|
63
68
|
? semantic.inverted.message.link
|
|
64
69
|
: semantic.message.branded,
|
|
@@ -76,6 +76,6 @@ exports.Disclosure = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
76
76
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(DisclosureButton, __assign({ onPress: function () {
|
|
77
77
|
setIsExpanded(!isExpanded);
|
|
78
78
|
onToggle && onToggle(!isExpanded);
|
|
79
|
-
}, ref: ref, accessibilityState: { expanded: isExpanded } }, rest, { children: [(0, jsx_runtime_1.jsx)(DisclosureButtonIcon, __assign({ name: "caret-down" }, breakpoints, { size: 14, expanded: isExpanded })), (0, jsx_runtime_1.jsx)(DisclosureButtonText, __assign({}, breakpoints, { children: title }))] })), isExpanded && ((0, jsx_runtime_1.jsx)(DisclosurePanel, __assign({}, breakpoints, { children: children })))] }));
|
|
79
|
+
}, ref: ref, accessibilityState: { expanded: isExpanded } }, rest, { children: [(0, jsx_runtime_1.jsx)(DisclosureButtonIcon, __assign({ name: "caret-arrow-down" }, breakpoints, { size: 14, expanded: isExpanded })), (0, jsx_runtime_1.jsx)(DisclosureButtonText, __assign({}, breakpoints, { children: title }))] })), isExpanded && ((0, jsx_runtime_1.jsx)(DisclosurePanel, __assign({}, breakpoints, { children: children })))] }));
|
|
80
80
|
});
|
|
81
81
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
@@ -70,7 +70,7 @@ var FilterSelect = function (_a) {
|
|
|
70
70
|
(_a = selectRef.current) === null || _a === void 0 ? void 0 : _a.measureInWindow(function (x, y) {
|
|
71
71
|
setMeasure({ top: y - 12, left: x });
|
|
72
72
|
});
|
|
73
|
-
}, children: [(0, jsx_runtime_1.jsx)(P_1.P, { children: (0, jsx_runtime_1.jsx)(Strong_1.Strong, { children: selected.value === 'default' ? '' : selected.label }) }), (0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: "caret-down", size: 14, style: { marginLeft: 2 } })] }, String(isOpen)), rightText ? (0, jsx_runtime_1.jsxs)(P_1.P, { children: [" ", rightText] }) : null, (0, jsx_runtime_1.jsx)(react_native_1.Modal, { transparent: true, visible: isOpen, animationType: "fade", onRequestClose: function () { return setOpen(false); }, children: (0, jsx_runtime_1.jsx)(DropdownWrapper, { children: (0, jsx_runtime_1.jsx)(DropdownContainer, { style: {
|
|
73
|
+
}, children: [(0, jsx_runtime_1.jsx)(P_1.P, { children: (0, jsx_runtime_1.jsx)(Strong_1.Strong, { children: selected.value === 'default' ? '' : selected.label }) }), (0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: "caret-arrow-down", size: 14, style: { marginLeft: 2 } })] }, String(isOpen)), rightText ? (0, jsx_runtime_1.jsxs)(P_1.P, { children: [" ", rightText] }) : null, (0, jsx_runtime_1.jsx)(react_native_1.Modal, { transparent: true, visible: isOpen, animationType: "fade", onRequestClose: function () { return setOpen(false); }, children: (0, jsx_runtime_1.jsx)(DropdownWrapper, { children: (0, jsx_runtime_1.jsx)(DropdownContainer, { style: {
|
|
74
74
|
top: measure === null || measure === void 0 ? void 0 : measure.top,
|
|
75
75
|
left: measure === null || measure === void 0 ? void 0 : measure.left,
|
|
76
76
|
}, children: (0, jsx_runtime_1.jsx)(react_native_1.ScrollView, { nestedScrollEnabled: true, children: options.map(function (option, i) { return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SelectOption, { accessible: true, accessibilityRole: "button", onPress: function () { return handleOptionPress(option); }, children: (0, jsx_runtime_1.jsx)(Margin_1.Margin, { vertical: 3, children: (0, jsx_runtime_1.jsx)(P_1.P, { children: (0, jsx_runtime_1.jsx)(Strong_1.Strong, { children: option.label }) }) }) }), i === options.length - 1 ? null : ((0, jsx_runtime_1.jsx)(Divider_1.Divider, { type: "differentiated" }))] }, option.label)); }) }) }) }) })] }));
|
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.IconButton = void 0;
|
|
4
4
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
var element_core_1 = require("@ovotech/element-core");
|
|
6
5
|
var react_native_1 = require("react-native");
|
|
6
|
+
var styled_native_1 = require("../../styled.native");
|
|
7
7
|
var Icon_1 = require("../Icon");
|
|
8
8
|
var NavHeader_styles_1 = require("./NavHeader.styles");
|
|
9
9
|
var IconButton = function (_a) {
|
|
10
10
|
var size = _a.size, animation = _a.animation, rightActionConfig = _a.rightActionConfig;
|
|
11
11
|
var ButtonStyled = size === 'small' ? NavHeader_styles_1.StyledIconButtonS : NavHeader_styles_1.StyledIconButtonL;
|
|
12
|
+
var theme = (0, styled_native_1.useTheme)();
|
|
12
13
|
if (!rightActionConfig || !(rightActionConfig === null || rightActionConfig === void 0 ? void 0 : rightActionConfig.iconName)) {
|
|
13
14
|
return null;
|
|
14
15
|
}
|
|
15
|
-
return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { hitSlop:
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { hitSlop: theme.core.space[2], pressRetentionOffset: theme.core.space[2], onPress: rightActionConfig === null || rightActionConfig === void 0 ? void 0 : rightActionConfig.onActionPress, children: function (_a) {
|
|
16
17
|
var pressed = _a.pressed;
|
|
17
|
-
return ((0, jsx_runtime_1.jsx)(ButtonStyled, { entering: animation, "$pressed": pressed, children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: rightActionConfig.iconName, size: size === 'small' ? 16 : 18, color:
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)(ButtonStyled, { entering: animation, "$pressed": pressed, children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: rightActionConfig.iconName, size: size === 'small' ? 16 : 18, color: theme.semantic.inverted.message.base }) }));
|
|
18
19
|
} }));
|
|
19
20
|
};
|
|
20
21
|
exports.IconButton = IconButton;
|
|
@@ -25,8 +25,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.NavHeader = void 0;
|
|
27
27
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
|
-
var element_core_1 = require("@ovotech/element-core");
|
|
29
28
|
var react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
|
|
29
|
+
var styled_native_1 = require("../../styled.native");
|
|
30
30
|
var ActionList_1 = require("../ActionList");
|
|
31
31
|
var IconButton_1 = require("./IconButton");
|
|
32
32
|
var NavHeader_styles_1 = require("./NavHeader.styles");
|
|
@@ -34,6 +34,8 @@ var FADE_ANIMATION_DURATION = 200;
|
|
|
34
34
|
var NavHeader = function (_a) {
|
|
35
35
|
var title = _a.title, scrolled = _a.scrolled, canGoBack = _a.canGoBack, rightActionConfig = _a.rightActionConfig, _b = _a.topOffset, topOffset = _b === void 0 ? 0 : _b, _c = _a.backButtonText, backButtonText = _c === void 0 ? 'Back' : _c, onHeaderHeightChange = _a.onHeaderHeightChange, onBackButtonPress = _a.onBackButtonPress;
|
|
36
36
|
var hasRightAction = !!rightActionConfig;
|
|
37
|
+
var hasTitle = title !== undefined && (title === null || title === void 0 ? void 0 : title.length) > 0;
|
|
38
|
+
var theme = (0, styled_native_1.useTheme)();
|
|
37
39
|
var layoutHeight = (0, react_native_reanimated_1.useSharedValue)(0);
|
|
38
40
|
var animatedHeightStyle = (0, react_native_reanimated_1.useAnimatedStyle)(function () {
|
|
39
41
|
return {
|
|
@@ -56,14 +58,14 @@ var NavHeader = function (_a) {
|
|
|
56
58
|
};
|
|
57
59
|
// NavWrapper will recieve height of the NavContainer and animate it
|
|
58
60
|
// content inside NavContainer is the only dynamic part of NavHeader
|
|
59
|
-
return ((0, jsx_runtime_1.jsx)(NavHeader_styles_1.NavWrapper, { collapsed: scrolled, style: animatedHeightStyle, children: (0, jsx_runtime_1.jsxs)(NavHeader_styles_1.NavContainer, { topOffset: topOffset, onLayout: onLayout, children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: {
|
|
61
|
+
return ((0, jsx_runtime_1.jsx)(NavHeader_styles_1.NavWrapper, { collapsed: scrolled, style: animatedHeightStyle, children: (0, jsx_runtime_1.jsxs)(NavHeader_styles_1.NavContainer, { topOffset: topOffset, onLayout: onLayout, titleVisible: hasTitle, children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: {
|
|
60
62
|
width: scrolled ? '33.3%' : '100%',
|
|
61
|
-
//
|
|
62
|
-
height: !canGoBack ?
|
|
63
|
-
}, children: canGoBack && ((0, jsx_runtime_1.jsx)(NavHeader_styles_1.ActionWrapper, { collapsed: scrolled, children: (0, jsx_runtime_1.jsx)(ActionList_1.Action, { iconLeft: "chevron-left-small", inline: true, onPress: onBackButtonPress, children: backButtonText }) })) }), scrolled ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(NavHeader_styles_1.CollapsedTitleWrapper, { children: (0, jsx_runtime_1.jsx)(NavHeader_styles_1.CollapsedTitle, { numberOfLines: 1, ellipsizeMode: "tail", entering: react_native_reanimated_1.FadeInDown.delay(FADE_ANIMATION_DURATION), exiting: react_native_reanimated_1.FadeOutDown.duration(FADE_ANIMATION_DURATION), children: title }) }), (0, jsx_runtime_1.jsx)(NavHeader_styles_1.IconButtonWrapper, { children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { rightActionConfig: rightActionConfig, size: "small", animation: react_native_reanimated_1.FadeInDown.delay(FADE_ANIMATION_DURATION) }) })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(NavHeader_styles_1.ExpandedTitle
|
|
63
|
+
// Important for maintaining white space above the title on main app screens.
|
|
64
|
+
height: !canGoBack ? theme.core.space[10] : undefined,
|
|
65
|
+
}, children: canGoBack && ((0, jsx_runtime_1.jsx)(NavHeader_styles_1.ActionWrapper, { collapsed: scrolled, children: (0, jsx_runtime_1.jsx)(ActionList_1.Action, { iconLeft: "chevron-left-small", inline: true, onPress: onBackButtonPress, children: backButtonText }) })) }), scrolled ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(NavHeader_styles_1.CollapsedTitleWrapper, { titleVisible: hasTitle, children: (0, jsx_runtime_1.jsx)(NavHeader_styles_1.CollapsedTitle, { numberOfLines: 1, ellipsizeMode: "tail", entering: react_native_reanimated_1.FadeInDown.delay(FADE_ANIMATION_DURATION), exiting: react_native_reanimated_1.FadeOutDown.duration(FADE_ANIMATION_DURATION), children: title }) }), (0, jsx_runtime_1.jsx)(NavHeader_styles_1.IconButtonWrapper, { children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { rightActionConfig: rightActionConfig, size: "small", animation: react_native_reanimated_1.FadeInDown.delay(FADE_ANIMATION_DURATION) }) })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(NavHeader_styles_1.ExpandedTitle
|
|
64
66
|
// if we don't have right action leave more space for the title text in expanded state
|
|
65
67
|
, {
|
|
66
68
|
// if we don't have right action leave more space for the title text in expanded state
|
|
67
|
-
fullWidth: !scrolled && !hasRightAction, numberOfLines: 2, ellipsizeMode: "tail", hasBackButton: canGoBack, entering: react_native_reanimated_1.FadeInUp.delay(FADE_ANIMATION_DURATION), exiting: react_native_reanimated_1.FadeOutUp.duration(FADE_ANIMATION_DURATION), children: title }), (0, jsx_runtime_1.jsx)(NavHeader_styles_1.IconButtonWrapper, { children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { rightActionConfig: rightActionConfig, size: "large", animation: react_native_reanimated_1.FadeInUp.delay(FADE_ANIMATION_DURATION) }) })] }))] }) }));
|
|
69
|
+
fullWidth: !scrolled && !hasRightAction, numberOfLines: 2, ellipsizeMode: "tail", hasBackButton: canGoBack, titleVisible: hasTitle, entering: react_native_reanimated_1.FadeInUp.delay(FADE_ANIMATION_DURATION), exiting: react_native_reanimated_1.FadeOutUp.duration(FADE_ANIMATION_DURATION), children: title }), (0, jsx_runtime_1.jsx)(NavHeader_styles_1.IconButtonWrapper, { children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { rightActionConfig: rightActionConfig, size: "large", animation: react_native_reanimated_1.FadeInUp.delay(FADE_ANIMATION_DURATION) }) })] }))] }) }));
|
|
68
70
|
};
|
|
69
71
|
exports.NavHeader = NavHeader;
|
|
@@ -971,8 +971,8 @@ export declare const NavContainer: import("styled-components").StyledComponent<t
|
|
|
971
971
|
};
|
|
972
972
|
};
|
|
973
973
|
}, {
|
|
974
|
-
collapsed: boolean;
|
|
975
974
|
topOffset: number;
|
|
975
|
+
titleVisible?: boolean | undefined;
|
|
976
976
|
}, never>;
|
|
977
977
|
export declare const ExpandedTitle: import("styled-components").StyledComponent<import("react").ComponentClass<import("react-native-reanimated").AnimateProps<import("react-native").TextProps>, any>, {
|
|
978
978
|
core: {
|
|
@@ -1461,6 +1461,7 @@ export declare const ExpandedTitle: import("styled-components").StyledComponent<
|
|
|
1461
1461
|
}, {
|
|
1462
1462
|
hasBackButton?: boolean | undefined;
|
|
1463
1463
|
fullWidth: boolean;
|
|
1464
|
+
titleVisible?: boolean | undefined;
|
|
1464
1465
|
}, never>;
|
|
1465
1466
|
export declare const CollapsedTitleWrapper: import("styled-components").StyledComponent<import("react").ComponentClass<import("react-native-reanimated").AnimateProps<import("react-native").ViewProps>, any>, {
|
|
1466
1467
|
core: {
|
|
@@ -1946,7 +1947,9 @@ export declare const CollapsedTitleWrapper: import("styled-components").StyledCo
|
|
|
1946
1947
|
};
|
|
1947
1948
|
};
|
|
1948
1949
|
};
|
|
1949
|
-
}, {
|
|
1950
|
+
}, {
|
|
1951
|
+
titleVisible?: boolean | undefined;
|
|
1952
|
+
}, never>;
|
|
1950
1953
|
export declare const CollapsedTitle: import("styled-components").StyledComponent<import("react").ComponentClass<import("react-native-reanimated").AnimateProps<import("react-native").TextProps>, any>, {
|
|
1951
1954
|
core: {
|
|
1952
1955
|
color: {
|
|
@@ -41,33 +41,38 @@ exports.NavWrapper = (0, styled_native_1.default)(react_native_reanimated_1.defa
|
|
|
41
41
|
? (0, styled_native_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-bottom-width: ", ";\n border-bottom-style: solid;\n border-bottom-color: ", ";\n "], ["\n border-bottom-width: ", ";\n border-bottom-style: solid;\n border-bottom-color: ", ";\n "])), (0, element_core_1.numToPx)(core.borderWidth.small), semantic.border.differentiated) : '');
|
|
42
42
|
});
|
|
43
43
|
exports.NavContainer = styled_native_1.default.View(function (_a) {
|
|
44
|
-
var core = _a.theme.core, topOffset = _a.topOffset;
|
|
45
|
-
return (0, styled_native_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: absolute;\n\n /* NavWrapper zIndex + 1 so it is always on top of the wrapper */\n z-index: ", ";\n width:
|
|
44
|
+
var core = _a.theme.core, topOffset = _a.topOffset, titleVisible = _a.titleVisible;
|
|
45
|
+
return (0, styled_native_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: absolute;\n\n /* NavWrapper zIndex + 1 so it is always on top of the wrapper */\n z-index: ", ";\n width: ", ";\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n "], ["\n position: absolute;\n\n /* NavWrapper zIndex + 1 so it is always on top of the wrapper */\n z-index: ", ";\n width: ", ";\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n "])), Z_INDEX + 1, titleVisible ? '100%' : '50%', topOffset
|
|
46
|
+
? topOffset
|
|
47
|
+
: (0, element_core_1.numToPx)(core.space[titleVisible ? 2 : 4]), (0, element_core_1.numToPx)(core.space[titleVisible ? 2 : 4]), (0, element_core_1.numToPx)(core.space[4]), (0, element_core_1.numToPx)(core.space[4]));
|
|
46
48
|
});
|
|
47
49
|
exports.ExpandedTitle = (0, styled_native_1.default)(react_native_reanimated_1.default.Text)(function (_a) {
|
|
48
|
-
var _b = _a.theme, core = _b.core, semantic = _b.semantic, hasBackButton = _a.hasBackButton, fullWidth = _a.fullWidth;
|
|
49
|
-
return (0, styled_native_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: ", ";\n font-family: ", ";\n font-size: ", ";\n line-height: ", ";\n color: ", ";\n "], ["\n width: ", ";\n font-family: ", ";\n font-size: ", ";\n line-height: ", ";\n color: ", ";\n "])), fullWidth ? '100%' : '65%', core.fontFamily.heading.native, (0, element_core_1.numToPx)(core.fontSize.heading1[hasBackButton ? 'small' : 'large']), (0, element_core_1.numToPx)(hasBackButton ? core.lineHeight.heading1.small : core.space[13]), semantic.message.branded);
|
|
50
|
+
var _b = _a.theme, core = _b.core, semantic = _b.semantic, hasBackButton = _a.hasBackButton, fullWidth = _a.fullWidth, titleVisible = _a.titleVisible;
|
|
51
|
+
return (0, styled_native_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: ", ";\n font-family: ", ";\n font-size: ", ";\n line-height: ", ";\n color: ", ";\n ", ";\n "], ["\n width: ", ";\n font-family: ", ";\n font-size: ", ";\n line-height: ", ";\n color: ", ";\n ", ";\n "])), fullWidth ? '100%' : '65%', core.fontFamily.heading.native, (0, element_core_1.numToPx)(core.fontSize.heading1[hasBackButton ? 'small' : 'large']), (0, element_core_1.numToPx)(hasBackButton ? core.lineHeight.heading1.small : core.space[13]), semantic.message.branded, !titleVisible && 'height: 0;');
|
|
52
|
+
});
|
|
53
|
+
exports.CollapsedTitleWrapper = (0, styled_native_1.default)(react_native_reanimated_1.default.View)(function (_a) {
|
|
54
|
+
var titleVisible = _a.titleVisible;
|
|
55
|
+
return "\n width: ".concat(titleVisible ? '33.3%' : '0', ";\n align-items: center;\n justify-content: center;\n");
|
|
50
56
|
});
|
|
51
|
-
exports.CollapsedTitleWrapper = (0, styled_native_1.default)(react_native_reanimated_1.default.View)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n width: 33.3%;\n align-items: center;\n justify-content: center;\n"], ["\n width: 33.3%;\n align-items: center;\n justify-content: center;\n"])));
|
|
52
57
|
exports.CollapsedTitle = (0, styled_native_1.default)(react_native_reanimated_1.default.Text)(function (_a) {
|
|
53
58
|
var _b = _a.theme, core = _b.core, semantic = _b.semantic;
|
|
54
|
-
return (0, styled_native_1.css)(
|
|
59
|
+
return (0, styled_native_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n font-family: ", ";\n font-size: ", ";\n line-height: ", ";\n color: ", ";\n "], ["\n font-family: ", ";\n font-size: ", ";\n line-height: ", ";\n color: ", ";\n "])), core.fontFamily.heading.native, (0, element_core_1.numToPx)(core.fontSize.heading4.small), (0, element_core_1.numToPx)(core.lineHeight.heading4.small), semantic.message.branded);
|
|
55
60
|
});
|
|
56
|
-
exports.IconButtonWrapper = styled_native_1.default.View(
|
|
61
|
+
exports.IconButtonWrapper = styled_native_1.default.View(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n width: 33.3%;\n flex-direction: row;\n justify-content: flex-end;\n"], ["\n width: 33.3%;\n flex-direction: row;\n justify-content: flex-end;\n"])));
|
|
57
62
|
var iconButtonSharedStyles = (0, styled_native_1.css)(function (_a) {
|
|
58
63
|
var semantic = _a.theme.semantic;
|
|
59
64
|
return "\n border-radius: 100px;\n background-color: ".concat(semantic.inverted.surface, ";\n align-items: center;\n justify-content: center;\n");
|
|
60
65
|
});
|
|
61
|
-
exports.StyledIconButtonS = (0, styled_native_1.default)(react_native_reanimated_1.default.View)(
|
|
66
|
+
exports.StyledIconButtonS = (0, styled_native_1.default)(react_native_reanimated_1.default.View)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n width: 28px;\n height: 28px;\n opacity: ", ";\n ", ";\n"], ["\n width: 28px;\n height: 28px;\n opacity: ", ";\n ", ";\n"])), function (_a) {
|
|
62
67
|
var $pressed = _a.$pressed;
|
|
63
68
|
return ($pressed ? 0.8 : 1);
|
|
64
69
|
}, iconButtonSharedStyles);
|
|
65
|
-
exports.StyledIconButtonL = (0, styled_native_1.default)(react_native_reanimated_1.default.View)(
|
|
70
|
+
exports.StyledIconButtonL = (0, styled_native_1.default)(react_native_reanimated_1.default.View)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n width: 36px;\n height: 36px;\n opacity: ", ";\n ", ";\n"], ["\n width: 36px;\n height: 36px;\n opacity: ", ";\n ", ";\n"])), function (_a) {
|
|
66
71
|
var $pressed = _a.$pressed;
|
|
67
72
|
return ($pressed ? 0.8 : 1);
|
|
68
73
|
}, iconButtonSharedStyles);
|
|
69
74
|
exports.ActionWrapper = styled_native_1.default.View(function (_a) {
|
|
70
75
|
var core = _a.theme.core, collapsed = _a.collapsed;
|
|
71
|
-
return (0, styled_native_1.css)(
|
|
76
|
+
return (0, styled_native_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n margin-bottom: ", ";\n "], ["\n margin-bottom: ", ";\n "])), collapsed ? '0' : (0, element_core_1.numToPx)(core.space[2]));
|
|
72
77
|
});
|
|
73
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9
|
|
78
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ViewProps } from 'react-native';
|
|
2
|
+
export type Segment = {
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
accessibilityLabel?: string;
|
|
6
|
+
};
|
|
7
|
+
type SegmentedControlsProps = ViewProps & {
|
|
8
|
+
activeSegment: Segment[][number];
|
|
9
|
+
segments: Segment[];
|
|
10
|
+
setActiveSegment: (...args: any[]) => void;
|
|
11
|
+
inline?: boolean;
|
|
12
|
+
multipleRows?: boolean;
|
|
13
|
+
size?: 'small' | 'large';
|
|
14
|
+
};
|
|
15
|
+
export declare const SegmentedControls: ({ activeSegment, setActiveSegment, segments, inline, multipleRows, size, ...rest }: SegmentedControlsProps) => JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
37
|
+
var t = {};
|
|
38
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
39
|
+
t[p] = s[p];
|
|
40
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
41
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
42
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
43
|
+
t[p[i]] = s[p[i]];
|
|
44
|
+
}
|
|
45
|
+
return t;
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.SegmentedControls = void 0;
|
|
49
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
50
|
+
var react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
|
|
51
|
+
var styled_native_1 = __importStar(require("../../styled.native"));
|
|
52
|
+
var SegmentButton_1 = require("./components/SegmentButton");
|
|
53
|
+
/* These settings were found to be nice and fast whilst maintaining spring */
|
|
54
|
+
var springSettings = {
|
|
55
|
+
damping: 25,
|
|
56
|
+
mass: 0.25,
|
|
57
|
+
};
|
|
58
|
+
var SegmentedControls = function (_a) {
|
|
59
|
+
var activeSegment = _a.activeSegment, setActiveSegment = _a.setActiveSegment, segments = _a.segments, _b = _a.inline, inline = _b === void 0 ? false : _b, multipleRows = _a.multipleRows, _c = _a.size, size = _c === void 0 ? 'large' : _c, rest = __rest(_a, ["activeSegment", "setActiveSegment", "segments", "inline", "multipleRows", "size"]);
|
|
60
|
+
var animatedX = (0, react_native_reanimated_1.useSharedValue)(0);
|
|
61
|
+
var animatedY = (0, react_native_reanimated_1.useSharedValue)(0);
|
|
62
|
+
var animatedHeight = (0, react_native_reanimated_1.useSharedValue)(0);
|
|
63
|
+
var animatedWidth = (0, react_native_reanimated_1.useSharedValue)(0);
|
|
64
|
+
var theme = (0, styled_native_1.useTheme)();
|
|
65
|
+
var animatedBackgroundStyle = (0, react_native_reanimated_1.useAnimatedStyle)(function () { return ({
|
|
66
|
+
transform: [
|
|
67
|
+
{
|
|
68
|
+
translateX: animatedX.value,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
translateY: animatedY.value + theme.core.space[size === 'small' ? 1 : 2],
|
|
72
|
+
} /* accounting for margin from top & bottom */,
|
|
73
|
+
],
|
|
74
|
+
width: animatedWidth.value,
|
|
75
|
+
height: animatedHeight.value,
|
|
76
|
+
position: 'absolute',
|
|
77
|
+
borderRadius: theme.core.radius.max,
|
|
78
|
+
backgroundColor: theme.semantic.surface.elevated,
|
|
79
|
+
}); }, [animatedX, animatedY, animatedWidth, animatedHeight]);
|
|
80
|
+
return ((0, jsx_runtime_1.jsxs)(SegmentsContainer, __assign({ "$inline": inline, "$multipleRows": multipleRows }, rest, { children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: animatedBackgroundStyle }), segments.map(function (segment) {
|
|
81
|
+
var _a;
|
|
82
|
+
return ((0, jsx_runtime_1.jsx)(SegmentButton_1.SegmentButton, { isSelected: activeSegment.key === segment.key, label: segment.label, accessibilityLabel: segment.accessibilityLabel, onPress: function (x, y, width) {
|
|
83
|
+
setActiveSegment(segment);
|
|
84
|
+
animatedX.value = (0, react_native_reanimated_1.withSpring)(x, springSettings);
|
|
85
|
+
animatedY.value = (0, react_native_reanimated_1.withSpring)(y, springSettings);
|
|
86
|
+
animatedWidth.value = width;
|
|
87
|
+
}, onLayout: function (width, height, x, y) {
|
|
88
|
+
if (activeSegment.key === segment.key) {
|
|
89
|
+
animatedX.value = x;
|
|
90
|
+
// (adrian.pop) - I couldn't figure out how to make the positioning work once the
|
|
91
|
+
// choices go on the second row. The only way I could get it to work
|
|
92
|
+
// was to hardcode the denominator to 3 for the single row ones
|
|
93
|
+
// and 1.1 for the multiple row ones.
|
|
94
|
+
animatedY.value = y - height / (multipleRows ? 1.1 : 3);
|
|
95
|
+
animatedHeight.value = height;
|
|
96
|
+
animatedWidth.value = width;
|
|
97
|
+
}
|
|
98
|
+
}, multipleRows: multipleRows, size: size, inline: inline, testID: "".concat((_a = rest.testID) !== null && _a !== void 0 ? _a : 'segment', "-").concat(segment.key) }, segment.key));
|
|
99
|
+
})] })));
|
|
100
|
+
};
|
|
101
|
+
exports.SegmentedControls = SegmentedControls;
|
|
102
|
+
var SegmentsContainer = styled_native_1.default.View(function (_a) {
|
|
103
|
+
var _b = _a.theme, core = _b.core, semantic = _b.semantic, $inline = _a.$inline, $multipleRows = _a.$multipleRows;
|
|
104
|
+
return "\n flex-direction: row;\n flex-wrap: ".concat($multipleRows ? '' : 'no-', "wrap;\n justify-content: ").concat($multipleRows ? 'space-between' : 'space-apart', ";\n align-items: center;\n gap: ").concat($inline ? 0 : core.space[1], "px;\n width: ").concat($inline ? 'auto' : '100%', ";\n align-self: ").concat($inline ? 'flex-start' : 'stretch', ";\n padding: ").concat(core.space[1], "px;\n background-color: ").concat(semantic.surface.cutout, ";\n border-radius: ").concat(core.radius.max, "px;\n");
|
|
105
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type SegmentButtonProps = {
|
|
2
|
+
isSelected: boolean;
|
|
3
|
+
label: string;
|
|
4
|
+
onPress: (x: number, y: number, width: number) => void;
|
|
5
|
+
onLayout: (width: number, height: number, x: number, y: number) => void;
|
|
6
|
+
accessibilityLabel?: string;
|
|
7
|
+
inline?: boolean;
|
|
8
|
+
multipleRows?: boolean;
|
|
9
|
+
size?: 'small' | 'large';
|
|
10
|
+
testID?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const SegmentButton: ({ accessibilityLabel, inline, isSelected, label, multipleRows, onLayout, onPress, size, testID, }: SegmentButtonProps) => JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
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.SegmentButton = void 0;
|
|
30
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
31
|
+
var react_1 = require("react");
|
|
32
|
+
var react_native_1 = require("react-native");
|
|
33
|
+
var react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
|
|
34
|
+
var styled_native_1 = __importDefault(require("../../../styled.native"));
|
|
35
|
+
var P_1 = require("../../P");
|
|
36
|
+
var AnimatedP = react_native_reanimated_1.default.createAnimatedComponent(P_1.P);
|
|
37
|
+
var SegmentButton = function (_a) {
|
|
38
|
+
var accessibilityLabel = _a.accessibilityLabel, inline = _a.inline, isSelected = _a.isSelected, label = _a.label, multipleRows = _a.multipleRows, onLayout = _a.onLayout, onPress = _a.onPress, _b = _a.size, size = _b === void 0 ? 'large' : _b, testID = _a.testID;
|
|
39
|
+
var xRef = (0, react_1.useRef)(0);
|
|
40
|
+
var yRef = (0, react_1.useRef)(0);
|
|
41
|
+
var widthRef = (0, react_1.useRef)(0);
|
|
42
|
+
var heightRef = (0, react_1.useRef)(0);
|
|
43
|
+
var hitslopVal = size === 'small' ? 8 : 4;
|
|
44
|
+
var fontWeightAnim = (0, react_native_reanimated_1.useSharedValue)(isSelected ? 1 : 0);
|
|
45
|
+
var animatedStyleNormal = (0, react_native_reanimated_1.useAnimatedStyle)(function () {
|
|
46
|
+
return {
|
|
47
|
+
opacity: 1 - fontWeightAnim.value,
|
|
48
|
+
position: 'absolute',
|
|
49
|
+
};
|
|
50
|
+
}, [fontWeightAnim]);
|
|
51
|
+
var animatedStyleBold = (0, react_native_reanimated_1.useAnimatedStyle)(function () {
|
|
52
|
+
return {
|
|
53
|
+
opacity: fontWeightAnim.value,
|
|
54
|
+
position: 'absolute',
|
|
55
|
+
};
|
|
56
|
+
}, [fontWeightAnim]);
|
|
57
|
+
(0, react_1.useEffect)(function () {
|
|
58
|
+
fontWeightAnim.value = (0, react_native_reanimated_1.withTiming)(isSelected ? 1 : 0);
|
|
59
|
+
}, [fontWeightAnim, isSelected]);
|
|
60
|
+
var handleLayout = function (event) {
|
|
61
|
+
var _a = event.nativeEvent.layout, width = _a.width, height = _a.height, x = _a.x, y = _a.y;
|
|
62
|
+
xRef.current = x;
|
|
63
|
+
yRef.current = y;
|
|
64
|
+
heightRef.current = height;
|
|
65
|
+
widthRef.current = width;
|
|
66
|
+
onLayout(width, height, x, y);
|
|
67
|
+
};
|
|
68
|
+
var handlePress = function () {
|
|
69
|
+
onPress(xRef.current,
|
|
70
|
+
// (adrian.pop) - I couldn't figure out how to make the positioning work once the
|
|
71
|
+
// choices go on the second row. The only way I could get it to work
|
|
72
|
+
// was to hardcode the denominator to 3 for the single row ones
|
|
73
|
+
// and 1.1 for the multiple row ones.
|
|
74
|
+
yRef.current - heightRef.current / (multipleRows ? 1.1 : 3), widthRef.current);
|
|
75
|
+
};
|
|
76
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { onLayout: handleLayout, onPress: handlePress, accessible: true, accessibilityRole: "checkbox", accessibilityState: { selected: isSelected }, accessibilityLabel: accessibilityLabel, hitSlop: {
|
|
77
|
+
top: hitslopVal,
|
|
78
|
+
bottom: hitslopVal,
|
|
79
|
+
}, style: { flexGrow: inline || multipleRows ? undefined : 1 }, testID: testID, children: (0, jsx_runtime_1.jsxs)(SSegmentsWrapper, { "$isSelected": isSelected, "$size": size, children: [(0, jsx_runtime_1.jsx)(SSegmentText, { style: {
|
|
80
|
+
opacity: 0,
|
|
81
|
+
fontWeight: '900',
|
|
82
|
+
}, "$isSelected": false, children: label }), (0, jsx_runtime_1.jsx)(SSegmentText, { style: animatedStyleNormal, "$isSelected": false, numberOfLines: 1, adjustsFontSizeToFit: true, children: label }), (0, jsx_runtime_1.jsx)(SSegmentText, { style: animatedStyleBold, "$isSelected": true, numberOfLines: 1, adjustsFontSizeToFit: true, children: label })] }) }));
|
|
83
|
+
};
|
|
84
|
+
exports.SegmentButton = SegmentButton;
|
|
85
|
+
var SSegmentsWrapper = styled_native_1.default.View(function (_a) {
|
|
86
|
+
var theme = _a.theme, $size = _a.$size;
|
|
87
|
+
return "\n padding: ".concat($size === 'small' ? 0 : 6, "px ").concat(theme.core.space[$size === 'small' ? 3 : 4], "px;\n align-items: center;\n justify-content: center;\n");
|
|
88
|
+
});
|
|
89
|
+
var SSegmentText = (0, styled_native_1.default)(AnimatedP)(function (_a) {
|
|
90
|
+
var $isSelected = _a.$isSelected, theme = _a.theme;
|
|
91
|
+
return "\n font-family: ".concat($isSelected
|
|
92
|
+
? theme.core.fontFamily.bodyBold.native
|
|
93
|
+
: theme.core.fontFamily.body.native, ";\n color: ").concat(theme.semantic.message.base, ";\n ");
|
|
94
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SegmentedControls = void 0;
|
|
4
|
+
var SegmentedControls_1 = require("./SegmentedControls");
|
|
5
|
+
Object.defineProperty(exports, "SegmentedControls", { enumerable: true, get: function () { return SegmentedControls_1.SegmentedControls; } });
|
|
@@ -62,7 +62,7 @@ var StyledText = styled_native_1.default.Text(function (_a) {
|
|
|
62
62
|
});
|
|
63
63
|
var StyledIcon = (0, styled_native_1.default)(Icon_1.Icon)(function (_a) {
|
|
64
64
|
var semantic = _a.theme.semantic;
|
|
65
|
-
return (0, styled_native_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n
|
|
65
|
+
return (0, styled_native_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), semantic.message.branded);
|
|
66
66
|
});
|
|
67
67
|
var TextLink = (0, react_1.forwardRef)(function (_a, ref) {
|
|
68
68
|
var children = _a.children, _b = _a.opensInNewWindow, opensInNewWindow = _b === void 0 ? false : _b, accessibilityLabel = _a.accessibilityLabel, rest = __rest(_a, ["children", "opensInNewWindow", "accessibilityLabel"]);
|
|
@@ -40,6 +40,7 @@ export * from './PasswordInput';
|
|
|
40
40
|
export * from './PhoneField';
|
|
41
41
|
export * from './PhoneInput';
|
|
42
42
|
export * from './Radio';
|
|
43
|
+
export * from './SegmentedControls';
|
|
43
44
|
export * from './SelectField';
|
|
44
45
|
export * from './SkeletonCircle';
|
|
45
46
|
export * from './SkeletonCTA';
|
package/dist/components/index.js
CHANGED
|
@@ -56,6 +56,7 @@ __exportStar(require("./PasswordInput"), exports);
|
|
|
56
56
|
__exportStar(require("./PhoneField"), exports);
|
|
57
57
|
__exportStar(require("./PhoneInput"), exports);
|
|
58
58
|
__exportStar(require("./Radio"), exports);
|
|
59
|
+
__exportStar(require("./SegmentedControls"), exports);
|
|
59
60
|
__exportStar(require("./SelectField"), exports);
|
|
60
61
|
__exportStar(require("./SkeletonCircle"), exports);
|
|
61
62
|
__exportStar(require("./SkeletonCTA"), exports);
|
|
@@ -21,6 +21,11 @@ var StyledP = styled(P)(function (_a) {
|
|
|
21
21
|
export var ActionCard = function (_a) {
|
|
22
22
|
var onPressCloseButton = _a.onPressCloseButton, onPressActionButton = _a.onPressActionButton, onPressIndicator = _a.onPressIndicator, onMount = _a.onMount, body = _a.body, title = _a.title, buttonTitle = _a.buttonTitle, ctaVariant = _a.ctaVariant, image = _a.image, testID = _a.testID, _b = _a.accessibilityLabel, accessibilityLabel = _b === void 0 ? 'image' : _b, _c = _a.inverted, inverted = _c === void 0 ? false : _c, _d = _a.inline, inline = _d === void 0 ? false : _d;
|
|
23
23
|
var _e = useContext(ThemeContext), core = _e.core, semantic = _e.semantic;
|
|
24
|
+
var hasSingleAction = (onPressActionButton && !onPressIndicator && !onPressCloseButton) ||
|
|
25
|
+
(onPressIndicator && !onPressActionButton && !onPressCloseButton);
|
|
26
|
+
var cardAction = hasSingleAction
|
|
27
|
+
? onPressActionButton || onPressIndicator
|
|
28
|
+
: null;
|
|
24
29
|
useEffect(function () {
|
|
25
30
|
if (onMount) {
|
|
26
31
|
onMount();
|
|
@@ -29,7 +34,7 @@ export var ActionCard = function (_a) {
|
|
|
29
34
|
var Heading = inline ? Heading3 : Heading2;
|
|
30
35
|
var cardPadding = core.space[inline ? 4 : 6];
|
|
31
36
|
var negativeMarginAdjustment = -cardPadding;
|
|
32
|
-
return (_jsx(StyledCard, { onPress:
|
|
37
|
+
return (_jsx(StyledCard, { onPress: cardAction, inline: inline, inverted: inverted, reducedBottomPadding: Boolean(buttonTitle && !ctaVariant), testID: "".concat(testID, "-card"), children: _jsxs(View, { style: { flexDirection: 'row' }, children: [_jsx(View, { style: { flex: 1 }, children: _jsxs(Stack, { spaceBetween: 2, children: [_jsx(Heading, { style: {
|
|
33
38
|
color: inverted
|
|
34
39
|
? semantic.inverted.message.link
|
|
35
40
|
: semantic.message.branded,
|
|
@@ -50,6 +50,6 @@ export var Disclosure = forwardRef(function (_a, ref) {
|
|
|
50
50
|
return (_jsxs(_Fragment, { children: [_jsxs(DisclosureButton, __assign({ onPress: function () {
|
|
51
51
|
setIsExpanded(!isExpanded);
|
|
52
52
|
onToggle && onToggle(!isExpanded);
|
|
53
|
-
}, ref: ref, accessibilityState: { expanded: isExpanded } }, rest, { children: [_jsx(DisclosureButtonIcon, __assign({ name: "caret-down" }, breakpoints, { size: 14, expanded: isExpanded })), _jsx(DisclosureButtonText, __assign({}, breakpoints, { children: title }))] })), isExpanded && (_jsx(DisclosurePanel, __assign({}, breakpoints, { children: children })))] }));
|
|
53
|
+
}, ref: ref, accessibilityState: { expanded: isExpanded } }, rest, { children: [_jsx(DisclosureButtonIcon, __assign({ name: "caret-arrow-down" }, breakpoints, { size: 14, expanded: isExpanded })), _jsx(DisclosureButtonText, __assign({}, breakpoints, { children: title }))] })), isExpanded && (_jsx(DisclosurePanel, __assign({}, breakpoints, { children: children })))] }));
|
|
54
54
|
});
|
|
55
55
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
@@ -44,7 +44,7 @@ export var FilterSelect = function (_a) {
|
|
|
44
44
|
(_a = selectRef.current) === null || _a === void 0 ? void 0 : _a.measureInWindow(function (x, y) {
|
|
45
45
|
setMeasure({ top: y - 12, left: x });
|
|
46
46
|
});
|
|
47
|
-
}, children: [_jsx(P, { children: _jsx(Strong, { children: selected.value === 'default' ? '' : selected.label }) }), _jsx(Icon, { name: "caret-down", size: 14, style: { marginLeft: 2 } })] }, String(isOpen)), rightText ? _jsxs(P, { children: [" ", rightText] }) : null, _jsx(Modal, { transparent: true, visible: isOpen, animationType: "fade", onRequestClose: function () { return setOpen(false); }, children: _jsx(DropdownWrapper, { children: _jsx(DropdownContainer, { style: {
|
|
47
|
+
}, children: [_jsx(P, { children: _jsx(Strong, { children: selected.value === 'default' ? '' : selected.label }) }), _jsx(Icon, { name: "caret-arrow-down", size: 14, style: { marginLeft: 2 } })] }, String(isOpen)), rightText ? _jsxs(P, { children: [" ", rightText] }) : null, _jsx(Modal, { transparent: true, visible: isOpen, animationType: "fade", onRequestClose: function () { return setOpen(false); }, children: _jsx(DropdownWrapper, { children: _jsx(DropdownContainer, { style: {
|
|
48
48
|
top: measure === null || measure === void 0 ? void 0 : measure.top,
|
|
49
49
|
left: measure === null || measure === void 0 ? void 0 : measure.left,
|
|
50
50
|
}, children: _jsx(ScrollView, { nestedScrollEnabled: true, children: options.map(function (option, i) { return (_jsxs(Fragment, { children: [_jsx(SelectOption, { accessible: true, accessibilityRole: "button", onPress: function () { return handleOptionPress(option); }, children: _jsx(Margin, { vertical: 3, children: _jsx(P, { children: _jsx(Strong, { children: option.label }) }) }) }), i === options.length - 1 ? null : (_jsx(Divider, { type: "differentiated" }))] }, option.label)); }) }) }) }) })] }));
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { theme } from '@ovotech/element-core';
|
|
3
2
|
import { Pressable } from 'react-native';
|
|
3
|
+
import { useTheme } from '../../styled.native';
|
|
4
4
|
import { Icon } from '../Icon';
|
|
5
5
|
import { StyledIconButtonL, StyledIconButtonS } from './NavHeader.styles';
|
|
6
6
|
export var IconButton = function (_a) {
|
|
7
7
|
var size = _a.size, animation = _a.animation, rightActionConfig = _a.rightActionConfig;
|
|
8
8
|
var ButtonStyled = size === 'small' ? StyledIconButtonS : StyledIconButtonL;
|
|
9
|
+
var theme = useTheme();
|
|
9
10
|
if (!rightActionConfig || !(rightActionConfig === null || rightActionConfig === void 0 ? void 0 : rightActionConfig.iconName)) {
|
|
10
11
|
return null;
|
|
11
12
|
}
|
|
12
|
-
return (_jsx(Pressable, { hitSlop:
|
|
13
|
+
return (_jsx(Pressable, { hitSlop: theme.core.space[2], pressRetentionOffset: theme.core.space[2], onPress: rightActionConfig === null || rightActionConfig === void 0 ? void 0 : rightActionConfig.onActionPress, children: function (_a) {
|
|
13
14
|
var pressed = _a.pressed;
|
|
14
15
|
return (_jsx(ButtonStyled, { entering: animation, "$pressed": pressed, children: _jsx(Icon, { name: rightActionConfig.iconName, size: size === 'small' ? 16 : 18, color: theme.semantic.inverted.message.base }) }));
|
|
15
16
|
} }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { theme } from '@ovotech/element-core';
|
|
3
2
|
import Animated, { Easing, FadeInDown, FadeInUp, FadeOutDown, FadeOutUp, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated';
|
|
3
|
+
import { useTheme } from '../../styled.native';
|
|
4
4
|
import { Action } from '../ActionList';
|
|
5
5
|
import { IconButton } from './IconButton';
|
|
6
6
|
import { ActionWrapper, CollapsedTitle, CollapsedTitleWrapper, ExpandedTitle, IconButtonWrapper, NavContainer, NavWrapper, } from './NavHeader.styles';
|
|
@@ -8,6 +8,8 @@ var FADE_ANIMATION_DURATION = 200;
|
|
|
8
8
|
export var NavHeader = function (_a) {
|
|
9
9
|
var title = _a.title, scrolled = _a.scrolled, canGoBack = _a.canGoBack, rightActionConfig = _a.rightActionConfig, _b = _a.topOffset, topOffset = _b === void 0 ? 0 : _b, _c = _a.backButtonText, backButtonText = _c === void 0 ? 'Back' : _c, onHeaderHeightChange = _a.onHeaderHeightChange, onBackButtonPress = _a.onBackButtonPress;
|
|
10
10
|
var hasRightAction = !!rightActionConfig;
|
|
11
|
+
var hasTitle = title !== undefined && (title === null || title === void 0 ? void 0 : title.length) > 0;
|
|
12
|
+
var theme = useTheme();
|
|
11
13
|
var layoutHeight = useSharedValue(0);
|
|
12
14
|
var animatedHeightStyle = useAnimatedStyle(function () {
|
|
13
15
|
return {
|
|
@@ -30,13 +32,13 @@ export var NavHeader = function (_a) {
|
|
|
30
32
|
};
|
|
31
33
|
// NavWrapper will recieve height of the NavContainer and animate it
|
|
32
34
|
// content inside NavContainer is the only dynamic part of NavHeader
|
|
33
|
-
return (_jsx(NavWrapper, { collapsed: scrolled, style: animatedHeightStyle, children: _jsxs(NavContainer, { topOffset: topOffset, onLayout: onLayout, children: [_jsx(Animated.View, { style: {
|
|
35
|
+
return (_jsx(NavWrapper, { collapsed: scrolled, style: animatedHeightStyle, children: _jsxs(NavContainer, { topOffset: topOffset, onLayout: onLayout, titleVisible: hasTitle, children: [_jsx(Animated.View, { style: {
|
|
34
36
|
width: scrolled ? '33.3%' : '100%',
|
|
35
|
-
//
|
|
36
|
-
height: !canGoBack ?
|
|
37
|
-
}, children: canGoBack && (_jsx(ActionWrapper, { collapsed: scrolled, children: _jsx(Action, { iconLeft: "chevron-left-small", inline: true, onPress: onBackButtonPress, children: backButtonText }) })) }), scrolled ? (_jsxs(_Fragment, { children: [_jsx(CollapsedTitleWrapper, { children: _jsx(CollapsedTitle, { numberOfLines: 1, ellipsizeMode: "tail", entering: FadeInDown.delay(FADE_ANIMATION_DURATION), exiting: FadeOutDown.duration(FADE_ANIMATION_DURATION), children: title }) }), _jsx(IconButtonWrapper, { children: _jsx(IconButton, { rightActionConfig: rightActionConfig, size: "small", animation: FadeInDown.delay(FADE_ANIMATION_DURATION) }) })] })) : (_jsxs(_Fragment, { children: [_jsx(ExpandedTitle
|
|
37
|
+
// Important for maintaining white space above the title on main app screens.
|
|
38
|
+
height: !canGoBack ? theme.core.space[10] : undefined,
|
|
39
|
+
}, children: canGoBack && (_jsx(ActionWrapper, { collapsed: scrolled, children: _jsx(Action, { iconLeft: "chevron-left-small", inline: true, onPress: onBackButtonPress, children: backButtonText }) })) }), scrolled ? (_jsxs(_Fragment, { children: [_jsx(CollapsedTitleWrapper, { titleVisible: hasTitle, children: _jsx(CollapsedTitle, { numberOfLines: 1, ellipsizeMode: "tail", entering: FadeInDown.delay(FADE_ANIMATION_DURATION), exiting: FadeOutDown.duration(FADE_ANIMATION_DURATION), children: title }) }), _jsx(IconButtonWrapper, { children: _jsx(IconButton, { rightActionConfig: rightActionConfig, size: "small", animation: FadeInDown.delay(FADE_ANIMATION_DURATION) }) })] })) : (_jsxs(_Fragment, { children: [_jsx(ExpandedTitle
|
|
38
40
|
// if we don't have right action leave more space for the title text in expanded state
|
|
39
41
|
, {
|
|
40
42
|
// if we don't have right action leave more space for the title text in expanded state
|
|
41
|
-
fullWidth: !scrolled && !hasRightAction, numberOfLines: 2, ellipsizeMode: "tail", hasBackButton: canGoBack, entering: FadeInUp.delay(FADE_ANIMATION_DURATION), exiting: FadeOutUp.duration(FADE_ANIMATION_DURATION), children: title }), _jsx(IconButtonWrapper, { children: _jsx(IconButton, { rightActionConfig: rightActionConfig, size: "large", animation: FadeInUp.delay(FADE_ANIMATION_DURATION) }) })] }))] }) }));
|
|
43
|
+
fullWidth: !scrolled && !hasRightAction, numberOfLines: 2, ellipsizeMode: "tail", hasBackButton: canGoBack, titleVisible: hasTitle, entering: FadeInUp.delay(FADE_ANIMATION_DURATION), exiting: FadeOutUp.duration(FADE_ANIMATION_DURATION), children: title }), _jsx(IconButtonWrapper, { children: _jsx(IconButton, { rightActionConfig: rightActionConfig, size: "large", animation: FadeInUp.delay(FADE_ANIMATION_DURATION) }) })] }))] }) }));
|
|
42
44
|
};
|