@ovotech/element-native 4.0.2 → 4.0.3-canary-30342e8-260

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.
Files changed (66) hide show
  1. package/dist/components/ActionCard/ActionCard.js +6 -1
  2. package/dist/components/Disclosure/Disclosure.js +1 -1
  3. package/dist/components/FilterSelect/FilterSelect.js +1 -1
  4. package/dist/components/NavHeader/NavHeader.js +4 -6
  5. package/dist/components/NavHeader/NavHeader.styles.d.ts +5 -2
  6. package/dist/components/NavHeader/NavHeader.styles.js +14 -11
  7. package/dist/components/SegmentedControls/SegmentedControls.d.ts +16 -0
  8. package/dist/components/SegmentedControls/SegmentedControls.js +78 -0
  9. package/dist/components/SegmentedControls/components/SegmentButton.d.ts +12 -0
  10. package/dist/components/SegmentedControls/components/SegmentButton.js +94 -0
  11. package/dist/components/SegmentedControls/index.d.ts +2 -0
  12. package/dist/components/SegmentedControls/index.js +5 -0
  13. package/dist/components/TextLink/TextLink.js +1 -1
  14. package/dist/components/index.d.ts +1 -0
  15. package/dist/components/index.js +1 -0
  16. package/dist/esm/components/ActionCard/ActionCard.js +6 -1
  17. package/dist/esm/components/Disclosure/Disclosure.js +1 -1
  18. package/dist/esm/components/FilterSelect/FilterSelect.js +1 -1
  19. package/dist/esm/components/NavHeader/NavHeader.js +4 -6
  20. package/dist/esm/components/NavHeader/NavHeader.styles.js +14 -11
  21. package/dist/esm/components/SegmentedControls/SegmentedControls.js +51 -0
  22. package/dist/esm/components/SegmentedControls/components/SegmentButton.js +64 -0
  23. package/dist/esm/components/SegmentedControls/index.js +2 -0
  24. package/dist/esm/components/TextLink/TextLink.js +1 -1
  25. package/dist/esm/components/index.js +1 -0
  26. package/dist/esm/providers/IconsProvider.js +22 -24
  27. package/dist/esm/providers/icons/CaretArrowDown.js +14 -0
  28. package/dist/esm/providers/icons/CaretArrowLeft.js +14 -0
  29. package/dist/esm/providers/icons/CaretArrowRight.js +14 -0
  30. package/dist/esm/providers/icons/CaretArrowUp.js +14 -0
  31. package/dist/esm/providers/icons/Chart.js +1 -1
  32. package/dist/esm/providers/icons/ChartFilled.js +1 -1
  33. package/dist/esm/providers/icons/Gas.js +1 -1
  34. package/dist/esm/providers/icons/HomeFilled.js +1 -1
  35. package/dist/esm/providers/icons/Logo.js +2 -2
  36. package/dist/esm/providers/icons/MessageFilled.js +1 -1
  37. package/dist/esm/providers/icons/Show.js +1 -1
  38. package/dist/esm/providers/icons/StarFilled.js +1 -1
  39. package/dist/esm/providers/icons/Trees.js +1 -1
  40. package/dist/esm/providers/icons/User.js +1 -1
  41. package/dist/esm/providers/icons/UserFilled.js +1 -1
  42. package/dist/esm/providers/icons/index.js +19 -21
  43. package/dist/providers/IconsProvider.js +21 -23
  44. package/dist/providers/icons/CaretArrowDown.d.ts +2 -0
  45. package/dist/providers/icons/CaretArrowDown.js +41 -0
  46. package/dist/providers/icons/CaretArrowLeft.d.ts +2 -0
  47. package/dist/providers/icons/CaretArrowLeft.js +41 -0
  48. package/dist/providers/icons/CaretArrowRight.d.ts +2 -0
  49. package/dist/providers/icons/CaretArrowRight.js +41 -0
  50. package/dist/providers/icons/CaretArrowUp.d.ts +2 -0
  51. package/dist/providers/icons/CaretArrowUp.js +41 -0
  52. package/dist/providers/icons/Chart.js +1 -1
  53. package/dist/providers/icons/ChartFilled.js +1 -1
  54. package/dist/providers/icons/Gas.js +1 -1
  55. package/dist/providers/icons/HomeFilled.js +1 -1
  56. package/dist/providers/icons/Logo.js +25 -2
  57. package/dist/providers/icons/MessageFilled.js +1 -1
  58. package/dist/providers/icons/Show.js +1 -1
  59. package/dist/providers/icons/StarFilled.js +1 -1
  60. package/dist/providers/icons/Trees.js +1 -1
  61. package/dist/providers/icons/User.js +1 -1
  62. package/dist/providers/icons/UserFilled.js +1 -1
  63. package/dist/providers/icons/index.d.ts +19 -21
  64. package/dist/providers/icons/index.js +19 -21
  65. package/dist/providers/types.d.ts +1 -1
  66. 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: onPressIndicator, 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: {
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)); }) }) }) }) })] }));
@@ -25,7 +25,6 @@ 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"));
30
29
  var ActionList_1 = require("../ActionList");
31
30
  var IconButton_1 = require("./IconButton");
@@ -34,6 +33,7 @@ var FADE_ANIMATION_DURATION = 200;
34
33
  var NavHeader = function (_a) {
35
34
  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
35
  var hasRightAction = !!rightActionConfig;
36
+ var hasTitle = title !== undefined && (title === null || title === void 0 ? void 0 : title.length) > 0;
37
37
  var layoutHeight = (0, react_native_reanimated_1.useSharedValue)(0);
38
38
  var animatedHeightStyle = (0, react_native_reanimated_1.useAnimatedStyle)(function () {
39
39
  return {
@@ -56,14 +56,12 @@ var NavHeader = function (_a) {
56
56
  };
57
57
  // NavWrapper will recieve height of the NavContainer and animate it
58
58
  // 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: {
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, titleVisible: hasTitle, children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: {
60
60
  width: scrolled ? '33.3%' : '100%',
61
- // when back button is off we have small margin top for title, to write less code we can just set height
62
- height: !canGoBack ? parseInt(element_core_1.theme.core.space[10]) : undefined,
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
61
+ }, 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
62
  // if we don't have right action leave more space for the title text in expanded state
65
63
  , {
66
64
  // 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) }) })] }))] }) }));
65
+ 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
66
  };
69
67
  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
- }, {}, never>;
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,36 @@ 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: 100%;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n padding: ", " ", ";\n padding-top: ", ";\n "], ["\n position: absolute;\n\n /* NavWrapper zIndex + 1 so it is always on top of the wrapper */\n z-index: ", ";\n width: 100%;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n padding: ", " ", ";\n padding-top: ", ";\n "])), Z_INDEX + 1, (0, element_core_1.numToPx)(core.space[2]), (0, element_core_1.numToPx)(core.space[4]), (0, element_core_1.numToPx)(topOffset ? topOffset : core.space[2]));
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%', (0, element_core_1.numToPx)(core.space[(topOffset !== null && topOffset !== void 0 ? topOffset : 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
46
  });
47
47
  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);
48
+ var _b = _a.theme, core = _b.core, semantic = _b.semantic, hasBackButton = _a.hasBackButton, fullWidth = _a.fullWidth, titleVisible = _a.titleVisible;
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 "], ["\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;');
50
+ });
51
+ exports.CollapsedTitleWrapper = (0, styled_native_1.default)(react_native_reanimated_1.default.View)(function (_a) {
52
+ var titleVisible = _a.titleVisible;
53
+ return "\n width: ".concat(titleVisible ? '33.3%' : '0', ";\n align-items: center;\n justify-content: center;\n");
50
54
  });
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
55
  exports.CollapsedTitle = (0, styled_native_1.default)(react_native_reanimated_1.default.Text)(function (_a) {
53
56
  var _b = _a.theme, core = _b.core, semantic = _b.semantic;
54
- return (0, styled_native_1.css)(templateObject_6 || (templateObject_6 = __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);
57
+ 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
58
  });
56
- exports.IconButtonWrapper = styled_native_1.default.View(templateObject_7 || (templateObject_7 = __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"])));
59
+ 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
60
  var iconButtonSharedStyles = (0, styled_native_1.css)(function (_a) {
58
61
  var semantic = _a.theme.semantic;
59
62
  return "\n border-radius: 100px;\n background-color: ".concat(semantic.inverted.surface, ";\n align-items: center;\n justify-content: center;\n");
60
63
  });
61
- exports.StyledIconButtonS = (0, styled_native_1.default)(react_native_reanimated_1.default.View)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n width: 28px;\n height: 28px;\n opacity: ", ";\n ", ";\n"], ["\n width: 28px;\n height: 28px;\n opacity: ", ";\n ", ";\n"])), function (_a) {
64
+ 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
65
  var $pressed = _a.$pressed;
63
66
  return ($pressed ? 0.8 : 1);
64
67
  }, iconButtonSharedStyles);
65
- exports.StyledIconButtonL = (0, styled_native_1.default)(react_native_reanimated_1.default.View)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n width: 36px;\n height: 36px;\n opacity: ", ";\n ", ";\n"], ["\n width: 36px;\n height: 36px;\n opacity: ", ";\n ", ";\n"])), function (_a) {
68
+ 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
69
  var $pressed = _a.$pressed;
67
70
  return ($pressed ? 0.8 : 1);
68
71
  }, iconButtonSharedStyles);
69
72
  exports.ActionWrapper = styled_native_1.default.View(function (_a) {
70
73
  var core = _a.theme.core, collapsed = _a.collapsed;
71
- return (0, styled_native_1.css)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n margin-bottom: ", ";\n "], ["\n margin-bottom: ", ";\n "])), collapsed ? '0' : (0, element_core_1.numToPx)(core.space[2]));
74
+ 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
75
  });
73
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
76
+ 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 { Dispatch, SetStateAction } from 'react';
2
+ export type Segment = {
3
+ key: string;
4
+ label: string;
5
+ accessibilityLabel?: string;
6
+ };
7
+ type SegmentedControlsProps = {
8
+ activeSegment: Segment[][number];
9
+ segments: Segment[];
10
+ setActiveSegment: Dispatch<SetStateAction<Segment[][number]>>;
11
+ inline?: boolean;
12
+ multipleRows?: boolean;
13
+ size?: 'small' | 'large';
14
+ };
15
+ export declare const SegmentedControls: ({ activeSegment, setActiveSegment, segments, inline, multipleRows, size, }: SegmentedControlsProps) => JSX.Element;
16
+ export {};
@@ -0,0 +1,78 @@
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.SegmentedControls = void 0;
27
+ var jsx_runtime_1 = require("react/jsx-runtime");
28
+ var react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
29
+ var styled_native_1 = __importStar(require("../../styled.native"));
30
+ var SegmentButton_1 = require("./components/SegmentButton");
31
+ var springSettings = {
32
+ damping: 15,
33
+ };
34
+ var SegmentedControls = function (_a) {
35
+ 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;
36
+ var animatedX = (0, react_native_reanimated_1.useSharedValue)(0);
37
+ var animatedY = (0, react_native_reanimated_1.useSharedValue)(0);
38
+ var animatedHeight = (0, react_native_reanimated_1.useSharedValue)(0);
39
+ var animatedWidth = (0, react_native_reanimated_1.useSharedValue)(0);
40
+ var theme = (0, styled_native_1.useTheme)();
41
+ var animatedBackgroundStyle = (0, react_native_reanimated_1.useAnimatedStyle)(function () { return ({
42
+ transform: [
43
+ {
44
+ translateX: animatedX.value,
45
+ },
46
+ {
47
+ translateY: animatedY.value + theme.core.space[size === 'small' ? 1 : 2],
48
+ } /* accounting for margin from top & bottom */,
49
+ ],
50
+ width: animatedWidth.value,
51
+ height: animatedHeight.value,
52
+ position: 'absolute',
53
+ borderRadius: theme.core.radius.max,
54
+ backgroundColor: theme.semantic.surface.elevated,
55
+ }); }, [animatedX, animatedY, animatedWidth, animatedHeight]);
56
+ return ((0, jsx_runtime_1.jsxs)(SegmentsContainer, { "$inline": inline, "$multipleRows": multipleRows, children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: animatedBackgroundStyle }), segments.map(function (segment) { 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) {
57
+ setActiveSegment(segment);
58
+ animatedX.value = (0, react_native_reanimated_1.withSpring)(x, springSettings);
59
+ animatedY.value = (0, react_native_reanimated_1.withSpring)(y, springSettings);
60
+ animatedWidth.value = width;
61
+ }, onLayout: function (width, height, x, y) {
62
+ if (activeSegment.key === segment.key) {
63
+ animatedX.value = x;
64
+ // (adrian.pop) - I couldn't figure out how to make the positioning work once the
65
+ // choices go on the second row. The only way I could get it to work
66
+ // was to hardcode the denominator to 3 for the single row ones
67
+ // and 1.1 for the multiple row ones.
68
+ animatedY.value = y - height / (multipleRows ? 1.1 : 3);
69
+ animatedHeight.value = height;
70
+ animatedWidth.value = width;
71
+ }
72
+ }, multipleRows: multipleRows, size: size, inline: inline }, segment.key)); })] }));
73
+ };
74
+ exports.SegmentedControls = SegmentedControls;
75
+ var SegmentsContainer = styled_native_1.default.View(function (_a) {
76
+ var _b = _a.theme, core = _b.core, semantic = _b.semantic, $inline = _a.$inline, $multipleRows = _a.$multipleRows;
77
+ 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");
78
+ });
@@ -0,0 +1,12 @@
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
+ };
11
+ export declare const SegmentButton: ({ accessibilityLabel, inline, isSelected, label, multipleRows, onLayout, onPress, size, }: SegmentButtonProps) => JSX.Element;
12
+ 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;
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 }, 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,2 @@
1
+ import { SegmentedControls } from './SegmentedControls';
2
+ export { SegmentedControls };
@@ -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 color: ", ";\n "], ["\n color: ", ";\n "])), semantic.message.branded);
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';
@@ -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: onPressIndicator, 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: {
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,5 +1,4 @@
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';
4
3
  import { Action } from '../ActionList';
5
4
  import { IconButton } from './IconButton';
@@ -8,6 +7,7 @@ var FADE_ANIMATION_DURATION = 200;
8
7
  export var NavHeader = function (_a) {
9
8
  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
9
  var hasRightAction = !!rightActionConfig;
10
+ var hasTitle = title !== undefined && (title === null || title === void 0 ? void 0 : title.length) > 0;
11
11
  var layoutHeight = useSharedValue(0);
12
12
  var animatedHeightStyle = useAnimatedStyle(function () {
13
13
  return {
@@ -30,13 +30,11 @@ export var NavHeader = function (_a) {
30
30
  };
31
31
  // NavWrapper will recieve height of the NavContainer and animate it
32
32
  // 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: {
33
+ return (_jsx(NavWrapper, { collapsed: scrolled, style: animatedHeightStyle, children: _jsxs(NavContainer, { topOffset: topOffset, onLayout: onLayout, titleVisible: hasTitle, children: [_jsx(Animated.View, { style: {
34
34
  width: scrolled ? '33.3%' : '100%',
35
- // when back button is off we have small margin top for title, to write less code we can just set height
36
- height: !canGoBack ? parseInt(theme.core.space[10]) : undefined,
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
35
+ }, 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
36
  // if we don't have right action leave more space for the title text in expanded state
39
37
  , {
40
38
  // 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) }) })] }))] }) }));
39
+ 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
40
  };
@@ -12,33 +12,36 @@ export var NavWrapper = styled(Animated.View)(function (_a) {
12
12
  ? 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 "])), numToPx(core.borderWidth.small), semantic.border.differentiated) : '');
13
13
  });
14
14
  export var NavContainer = styled.View(function (_a) {
15
- var core = _a.theme.core, topOffset = _a.topOffset;
16
- return 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: 100%;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n padding: ", " ", ";\n padding-top: ", ";\n "], ["\n position: absolute;\n\n /* NavWrapper zIndex + 1 so it is always on top of the wrapper */\n z-index: ", ";\n width: 100%;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n padding: ", " ", ";\n padding-top: ", ";\n "])), Z_INDEX + 1, numToPx(core.space[2]), numToPx(core.space[4]), numToPx(topOffset ? topOffset : core.space[2]));
15
+ var core = _a.theme.core, topOffset = _a.topOffset, titleVisible = _a.titleVisible;
16
+ return 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%', numToPx(core.space[(topOffset !== null && topOffset !== void 0 ? topOffset : titleVisible) ? 2 : 4]), numToPx(core.space[titleVisible ? 2 : 4]), numToPx(core.space[4]), numToPx(core.space[4]));
17
17
  });
18
18
  export var ExpandedTitle = styled(Animated.Text)(function (_a) {
19
- var _b = _a.theme, core = _b.core, semantic = _b.semantic, hasBackButton = _a.hasBackButton, fullWidth = _a.fullWidth;
20
- return 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, numToPx(core.fontSize.heading1[hasBackButton ? 'small' : 'large']), numToPx(hasBackButton ? core.lineHeight.heading1.small : core.space[13]), semantic.message.branded);
19
+ var _b = _a.theme, core = _b.core, semantic = _b.semantic, hasBackButton = _a.hasBackButton, fullWidth = _a.fullWidth, titleVisible = _a.titleVisible;
20
+ return 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, numToPx(core.fontSize.heading1[hasBackButton ? 'small' : 'large']), numToPx(hasBackButton ? core.lineHeight.heading1.small : core.space[13]), semantic.message.branded, !titleVisible && 'height: 0;');
21
+ });
22
+ export var CollapsedTitleWrapper = styled(Animated.View)(function (_a) {
23
+ var titleVisible = _a.titleVisible;
24
+ return "\n width: ".concat(titleVisible ? '33.3%' : '0', ";\n align-items: center;\n justify-content: center;\n");
21
25
  });
22
- export var CollapsedTitleWrapper = styled(Animated.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"])));
23
26
  export var CollapsedTitle = styled(Animated.Text)(function (_a) {
24
27
  var _b = _a.theme, core = _b.core, semantic = _b.semantic;
25
- return css(templateObject_6 || (templateObject_6 = __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, numToPx(core.fontSize.heading4.small), numToPx(core.lineHeight.heading4.small), semantic.message.branded);
28
+ return 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, numToPx(core.fontSize.heading4.small), numToPx(core.lineHeight.heading4.small), semantic.message.branded);
26
29
  });
27
- export var IconButtonWrapper = styled.View(templateObject_7 || (templateObject_7 = __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"])));
30
+ export var IconButtonWrapper = styled.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"])));
28
31
  var iconButtonSharedStyles = css(function (_a) {
29
32
  var semantic = _a.theme.semantic;
30
33
  return "\n border-radius: 100px;\n background-color: ".concat(semantic.inverted.surface, ";\n align-items: center;\n justify-content: center;\n");
31
34
  });
32
- export var StyledIconButtonS = styled(Animated.View)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n width: 28px;\n height: 28px;\n opacity: ", ";\n ", ";\n"], ["\n width: 28px;\n height: 28px;\n opacity: ", ";\n ", ";\n"])), function (_a) {
35
+ export var StyledIconButtonS = styled(Animated.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) {
33
36
  var $pressed = _a.$pressed;
34
37
  return ($pressed ? 0.8 : 1);
35
38
  }, iconButtonSharedStyles);
36
- export var StyledIconButtonL = styled(Animated.View)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n width: 36px;\n height: 36px;\n opacity: ", ";\n ", ";\n"], ["\n width: 36px;\n height: 36px;\n opacity: ", ";\n ", ";\n"])), function (_a) {
39
+ export var StyledIconButtonL = styled(Animated.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) {
37
40
  var $pressed = _a.$pressed;
38
41
  return ($pressed ? 0.8 : 1);
39
42
  }, iconButtonSharedStyles);
40
43
  export var ActionWrapper = styled.View(function (_a) {
41
44
  var core = _a.theme.core, collapsed = _a.collapsed;
42
- return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n margin-bottom: ", ";\n "], ["\n margin-bottom: ", ";\n "])), collapsed ? '0' : numToPx(core.space[2]));
45
+ return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n margin-bottom: ", ";\n "], ["\n margin-bottom: ", ";\n "])), collapsed ? '0' : numToPx(core.space[2]));
43
46
  });
44
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
47
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9;