@ovotech/element-native 4.0.2-canary-e5d087a-257 → 4.0.2-canary-9474c73-259

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.
@@ -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;
@@ -1,12 +1,16 @@
1
1
  import { Dispatch, SetStateAction } from 'react';
2
- import { SegmentTypes } from './constants';
3
- type SegmentedControlsProps<T extends keyof SegmentTypes> = {
4
- activeSegment: SegmentTypes[T][number];
5
- segments: SegmentTypes[T];
6
- setActiveSegment: Dispatch<SetStateAction<SegmentTypes[T][number]>>;
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]>>;
7
11
  inline?: boolean;
8
12
  multipleRows?: boolean;
9
13
  size?: 'small' | 'large';
10
14
  };
11
- export declare const SegmentedControls: <T extends keyof SegmentTypes>({ activeSegment, setActiveSegment, segments, inline, multipleRows, size, }: SegmentedControlsProps<T>) => JSX.Element;
15
+ export declare const SegmentedControls: ({ activeSegment, setActiveSegment, segments, inline, multipleRows, size, }: SegmentedControlsProps) => JSX.Element;
12
16
  export {};
@@ -53,7 +53,7 @@ var SegmentedControls = function (_a) {
53
53
  borderRadius: theme.core.radius.max,
54
54
  backgroundColor: theme.semantic.surface.elevated,
55
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, onPress: function (x, y, width) {
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
57
  setActiveSegment(segment);
58
58
  animatedX.value = (0, react_native_reanimated_1.withSpring)(x, springSettings);
59
59
  animatedY.value = (0, react_native_reanimated_1.withSpring)(y, springSettings);
@@ -1,11 +1,12 @@
1
1
  type SegmentButtonProps = {
2
- onPress: (x: number, y: number, width: number) => void;
3
- onLayout: (width: number, height: number, x: number, y: number) => void;
4
2
  isSelected: boolean;
5
3
  label: string;
6
- multipleRows?: boolean;
4
+ onPress: (x: number, y: number, width: number) => void;
5
+ onLayout: (width: number, height: number, x: number, y: number) => void;
6
+ accessibilityLabel?: string;
7
7
  inline?: boolean;
8
+ multipleRows?: boolean;
8
9
  size?: 'small' | 'large';
9
10
  };
10
- export declare const SegmentButton: ({ onPress, onLayout, inline, isSelected, label, multipleRows, size, }: SegmentButtonProps) => JSX.Element;
11
+ export declare const SegmentButton: ({ accessibilityLabel, inline, isSelected, label, multipleRows, onLayout, onPress, size, }: SegmentButtonProps) => JSX.Element;
11
12
  export {};
@@ -35,7 +35,7 @@ var styled_native_1 = __importDefault(require("../../../styled.native"));
35
35
  var P_1 = require("../../P");
36
36
  var AnimatedP = react_native_reanimated_1.default.createAnimatedComponent(P_1.P);
37
37
  var SegmentButton = function (_a) {
38
- var onPress = _a.onPress, onLayout = _a.onLayout, inline = _a.inline, isSelected = _a.isSelected, label = _a.label, multipleRows = _a.multipleRows, _b = _a.size, size = _b === void 0 ? 'large' : _b;
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
39
  var xRef = (0, react_1.useRef)(0);
40
40
  var yRef = (0, react_1.useRef)(0);
41
41
  var widthRef = (0, react_1.useRef)(0);
@@ -73,7 +73,7 @@ var SegmentButton = function (_a) {
73
73
  // and 1.1 for the multiple row ones.
74
74
  yRef.current - heightRef.current / (multipleRows ? 1.1 : 3), widthRef.current);
75
75
  };
76
- return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { onLayout: handleLayout, onPress: handlePress, accessibilityRole: "checkbox", accessibilityState: { selected: isSelected }, hitSlop: {
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
77
  top: hitslopVal,
78
78
  bottom: hitslopVal,
79
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: {
@@ -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;
@@ -27,7 +27,7 @@ export var SegmentedControls = function (_a) {
27
27
  borderRadius: theme.core.radius.max,
28
28
  backgroundColor: theme.semantic.surface.elevated,
29
29
  }); }, [animatedX, animatedY, animatedWidth, animatedHeight]);
30
- return (_jsxs(SegmentsContainer, { "$inline": inline, "$multipleRows": multipleRows, children: [_jsx(Animated.View, { style: animatedBackgroundStyle }), segments.map(function (segment) { return (_jsx(SegmentButton, { isSelected: activeSegment.key === segment.key, label: segment.label, onPress: function (x, y, width) {
30
+ return (_jsxs(SegmentsContainer, { "$inline": inline, "$multipleRows": multipleRows, children: [_jsx(Animated.View, { style: animatedBackgroundStyle }), segments.map(function (segment) { return (_jsx(SegmentButton, { isSelected: activeSegment.key === segment.key, label: segment.label, accessibilityLabel: segment.accessibilityLabel, onPress: function (x, y, width) {
31
31
  setActiveSegment(segment);
32
32
  animatedX.value = withSpring(x, springSettings);
33
33
  animatedY.value = withSpring(y, springSettings);
@@ -6,7 +6,7 @@ import styled from '../../../styled.native';
6
6
  import { P } from '../../P';
7
7
  var AnimatedP = Animated.createAnimatedComponent(P);
8
8
  export var SegmentButton = function (_a) {
9
- var onPress = _a.onPress, onLayout = _a.onLayout, inline = _a.inline, isSelected = _a.isSelected, label = _a.label, multipleRows = _a.multipleRows, _b = _a.size, size = _b === void 0 ? 'large' : _b;
9
+ 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;
10
10
  var xRef = useRef(0);
11
11
  var yRef = useRef(0);
12
12
  var widthRef = useRef(0);
@@ -44,7 +44,7 @@ export var SegmentButton = function (_a) {
44
44
  // and 1.1 for the multiple row ones.
45
45
  yRef.current - heightRef.current / (multipleRows ? 1.1 : 3), widthRef.current);
46
46
  };
47
- return (_jsx(Pressable, { onLayout: handleLayout, onPress: handlePress, accessibilityRole: "checkbox", accessibilityState: { selected: isSelected }, hitSlop: {
47
+ return (_jsx(Pressable, { onLayout: handleLayout, onPress: handlePress, accessible: true, accessibilityRole: "checkbox", accessibilityState: { selected: isSelected }, accessibilityLabel: accessibilityLabel, hitSlop: {
48
48
  top: hitslopVal,
49
49
  bottom: hitslopVal,
50
50
  }, style: { flexGrow: inline || multipleRows ? undefined : 1 }, children: _jsxs(SSegmentsWrapper, { "$isSelected": isSelected, "$size": size, children: [_jsx(SSegmentText, { style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ovotech/element-native",
3
- "version": "4.0.2-canary-e5d087a-257",
3
+ "version": "4.0.2-canary-9474c73-259",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@backpackapp-io/react-native-toast": "^0.10.0",
17
- "@ovotech/element-core": "3.0.1-canary-e5d087a-257",
17
+ "@ovotech/element-core": "3.0.1-canary-9474c73-259",
18
18
  "deepmerge": "^4.2.2",
19
19
  "lodash.groupby": "^4.6.0",
20
20
  "react-native-reanimated-carousel": "^3.5.1"
@@ -1,33 +0,0 @@
1
- export type EnergyUseFilters = 'total' | 'electricity' | 'gas';
2
- export type PeriodFilters = 'day' | 'week' | 'month' | 'year';
3
- export type MeasurementFilters = 'consumption' | 'cost';
4
- export type ComparisonFilters = 'similar' | 'previous' | 'none';
5
- export type MeasurementUnit = '£' | 'kWh';
6
- export type SegmentTypes = {
7
- ENERGY_USE: {
8
- key: EnergyUseFilters;
9
- label: string;
10
- mainScreenLabel?: string;
11
- }[];
12
- PERIOD: {
13
- key: PeriodFilters;
14
- label: string;
15
- mainScreenLabel?: string;
16
- }[];
17
- MEASUREMENT: {
18
- key: MeasurementFilters;
19
- label: string;
20
- mainScreenLabel?: string;
21
- unit: MeasurementUnit;
22
- }[];
23
- COMPARISON: {
24
- key: ComparisonFilters;
25
- label: string;
26
- mainScreenLabel?: string;
27
- }[];
28
- CUSTOM: {
29
- key: string;
30
- label: string;
31
- mainScreenLabel?: string;
32
- }[];
33
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export {};