@ovotech/element-native 3.3.1 → 3.3.2-canary-51af19f-615
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Accordion/Accordion.js +2 -2
- package/dist/components/List/List.js +3 -3
- package/dist/components/NavHeader/NavHeader.d.ts +9 -11
- package/dist/components/NavHeader/NavHeader.js +45 -47
- package/dist/components/NavHeader/NavHeader.styles.d.ts +1833 -0
- package/dist/components/NavHeader/NavHeader.styles.js +72 -0
- package/dist/components/SummaryList/SummaryList.d.ts +14 -0
- package/dist/components/SummaryList/SummaryList.js +47 -0
- package/dist/components/SummaryList/index.d.ts +1 -0
- package/dist/components/SummaryList/index.js +6 -0
- package/dist/esm/components/Accordion/Accordion.js +1 -1
- package/dist/esm/components/List/List.js +3 -3
- package/dist/esm/components/NavHeader/NavHeader.js +48 -50
- package/dist/esm/components/NavHeader/NavHeader.styles.js +43 -0
- package/dist/esm/components/SummaryList/SummaryList.js +43 -0
- package/dist/esm/components/SummaryList/index.js +1 -0
- package/dist/esm/hooks/use-layout.js +16 -0
- package/dist/esm/theme/create-theme.js +330 -0
- package/dist/esm/theme/index.js +19 -0
- package/dist/esm/theme/theme.js +1 -0
- package/dist/hooks/use-layout.d.ts +6 -0
- package/dist/hooks/use-layout.js +20 -0
- package/dist/providers/types.d.ts +1 -1
- package/dist/theme/create-theme.d.ts +18 -0
- package/dist/theme/create-theme.js +337 -0
- package/dist/theme/index.d.ts +231 -0
- package/dist/theme/index.js +37 -0
- package/dist/theme/theme.d.ts +193 -0
- package/dist/theme/theme.js +2 -0
- package/package.json +3 -2
|
@@ -53,12 +53,12 @@ exports.Accordion = exports.withAnimated = void 0;
|
|
|
53
53
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
54
54
|
var react_1 = require("react");
|
|
55
55
|
var react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
|
|
56
|
+
var use_layout_1 = require("../../hooks/use-layout");
|
|
56
57
|
var styled_native_1 = require("../../styled.native");
|
|
57
58
|
var utils_1 = require("../../utils");
|
|
58
59
|
var Heading_1 = require("../Heading");
|
|
59
60
|
var Group_1 = require("./Group");
|
|
60
61
|
var Icon_1 = require("./Icon");
|
|
61
|
-
var hooks_1 = require("./hooks");
|
|
62
62
|
var styles_1 = require("./styles");
|
|
63
63
|
function withAnimated(WrappedComponent) {
|
|
64
64
|
var displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
|
@@ -85,7 +85,7 @@ var Accordion = function (_a) {
|
|
|
85
85
|
var AnimatedHeading = (0, react_1.useMemo)(function () { return withAnimated(AccordionHeading); }, [
|
|
86
86
|
AccordionHeading,
|
|
87
87
|
]);
|
|
88
|
-
var _d = (0,
|
|
88
|
+
var _d = (0, use_layout_1.useLayout)(0), layout = _d[0], onLayout = _d[1];
|
|
89
89
|
var _e = (0, react_1.useState)(expanded), open = _e[0], setOpen = _e[1];
|
|
90
90
|
var handleHeightContent = (0, react_1.useMemo)(function () { return layout.height || 100; }, [
|
|
91
91
|
layout.height,
|
|
@@ -98,14 +98,14 @@ var Ul = function (_a) {
|
|
|
98
98
|
var renderList = function (arrayChildren, level) {
|
|
99
99
|
if (level === void 0) { level = 0; }
|
|
100
100
|
return react_1.Children.map(arrayChildren, function (child) {
|
|
101
|
-
var _a, _b;
|
|
101
|
+
var _a, _b, _c;
|
|
102
102
|
// @ts-ignore It complains that child props doesn't exist. Weird.
|
|
103
|
-
if (Array.isArray((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.children)) {
|
|
103
|
+
if (Array.isArray((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.children) && ((_b = child === null || child === void 0 ? void 0 : child.type) === null || _b === void 0 ? void 0 : _b.name) === 'Ul') {
|
|
104
104
|
var lvl = level;
|
|
105
105
|
var PADDING = 3;
|
|
106
106
|
lvl = lvl + PADDING;
|
|
107
107
|
// @ts-ignore It complains that child props doesn't exist. Weird.
|
|
108
|
-
return renderList((
|
|
108
|
+
return renderList((_c = child === null || child === void 0 ? void 0 : child.props) === null || _c === void 0 ? void 0 : _c.children, lvl);
|
|
109
109
|
}
|
|
110
110
|
else {
|
|
111
111
|
return ((0, jsx_runtime_1.jsx)(ListBulletItem, __assign({ showBullets: showBullets, level: level }, { children: child })));
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
declare type
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { IconNameExtended } from '../../providers';
|
|
2
|
+
declare type RightActionConfig = {
|
|
3
|
+
iconName?: IconNameExtended;
|
|
4
|
+
onActionPress?: () => void;
|
|
5
5
|
};
|
|
6
|
-
declare type
|
|
6
|
+
declare type NavHeaderProps = {
|
|
7
7
|
title?: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
headerRight?(): React.ReactNode;
|
|
12
|
-
canGoBack(): boolean;
|
|
8
|
+
scrolled: boolean;
|
|
9
|
+
rightActionConfig?: RightActionConfig;
|
|
10
|
+
canGoBack: boolean;
|
|
13
11
|
goBack(): void;
|
|
14
12
|
};
|
|
15
|
-
export declare const NavHeader: ({
|
|
13
|
+
export declare const NavHeader: ({ title, scrolled, rightActionConfig, canGoBack, goBack, }: NavHeaderProps) => JSX.Element;
|
|
16
14
|
export {};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
2
|
var __assign = (this && this.__assign) || function () {
|
|
7
3
|
__assign = Object.assign || function(t) {
|
|
8
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -40,51 +36,53 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
40
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
37
|
exports.NavHeader = void 0;
|
|
42
38
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
39
|
+
var element_core_1 = require("@ovotech/element-core");
|
|
40
|
+
var react_1 = require("react");
|
|
43
41
|
var react_native_1 = require("react-native");
|
|
44
42
|
var react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var
|
|
52
|
-
var _b = _a.theme, core = _b.core, semantic = _b.semantic;
|
|
53
|
-
return (0, styled_native_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: ", ";\n font-size: ", ";\n font-family: ", ";\n "], ["\n color: ", ";\n font-size: ", ";\n font-family: ", ";\n "])), semantic.inverted.message.base, core.fontSize.small.small, core.fontFamily.body.native);
|
|
54
|
-
});
|
|
55
|
-
var LeftHeaderText = (0, styled_native_1.default)(StyledText)(function (_a) {
|
|
56
|
-
var core = _a.theme.core;
|
|
57
|
-
return (0, styled_native_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding-left: ", ";\n "], ["\n padding-left: ", ";\n "])), core.space[2]);
|
|
58
|
-
});
|
|
59
|
-
var HeadlineView = (0, styled_native_1.default)(react_native_reanimated_1.default.View)(function (_a) {
|
|
60
|
-
var core = _a.theme.core;
|
|
61
|
-
return (0, styled_native_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding: 0 ", " ", ";\n "], ["\n padding: 0 ", " ", ";\n "])), core.space[3], core.space[3]);
|
|
62
|
-
});
|
|
63
|
-
var RootView = styled_native_1.default.View(function (_a) {
|
|
64
|
-
var semantic = _a.theme.semantic;
|
|
65
|
-
return (0, styled_native_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n background-color: ", ";\n overflow: hidden;\n "], ["\n background-color: ", ";\n overflow: hidden;\n "])), semantic.message.branded);
|
|
66
|
-
});
|
|
67
|
-
var StyledView = (0, styled_native_1.default)(react_native_reanimated_1.default.View)(function (_a) {
|
|
68
|
-
var core = _a.theme.core, marginTop = _a.marginTop;
|
|
69
|
-
return (0, styled_native_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding: ", ";\n padding-bottom: ", ";\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n margin-top: ", ";\n "], ["\n padding: ", ";\n padding-bottom: ", ";\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n margin-top: ", ";\n "])), core.space[3], core.space[2], marginTop !== null && marginTop !== void 0 ? marginTop : 0);
|
|
70
|
-
});
|
|
71
|
-
var StyledHeading4 = (0, styled_native_1.default)(Heading_1.Heading4)(function (_a) {
|
|
72
|
-
var _b = _a.theme, core = _b.core, semantic = _b.semantic, textAlign = _a.textAlign;
|
|
73
|
-
return (0, styled_native_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n font-family: ", ";\n margin-top: 0;\n margin-bottom: 0;\n color: ", ";\n text-align: ", ";\n "], ["\n font-family: ", ";\n margin-top: 0;\n margin-bottom: 0;\n color: ", ";\n text-align: ", ";\n "])), core.fontFamily.bodyBold.native, semantic.inverted.message.base, textAlign);
|
|
74
|
-
});
|
|
75
|
-
var StyledHeading3 = (0, styled_native_1.default)(Heading_1.Heading3)(function (_a) {
|
|
76
|
-
var semantic = _a.theme.semantic;
|
|
77
|
-
return (0, styled_native_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n margin-top: 0;\n margin-bottom: 0;\n padding-top: 0;\n color: ", ";\n text-align: left;\n "], ["\n margin-top: 0;\n margin-bottom: 0;\n padding-top: 0;\n color: ", ";\n text-align: left;\n "])), semantic.inverted.message.base);
|
|
78
|
-
});
|
|
43
|
+
var use_layout_1 = require("../../hooks/use-layout");
|
|
44
|
+
var ActionList_1 = require("../ActionList");
|
|
45
|
+
var Icon_1 = require("../Icon");
|
|
46
|
+
var NavHeader_styles_1 = require("./NavHeader.styles");
|
|
47
|
+
// calculated based on layout with maximum possible height
|
|
48
|
+
var INITIAL_HEADER_HEIGHT = 115;
|
|
49
|
+
var FADE_ANIMATION_DURATION = 250; // ms
|
|
79
50
|
var NavHeader = function (_a) {
|
|
80
|
-
var
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
51
|
+
var title = _a.title, scrolled = _a.scrolled, rightActionConfig = _a.rightActionConfig, canGoBack = _a.canGoBack, goBack = _a.goBack;
|
|
52
|
+
var _b = (0, use_layout_1.useLayout)(INITIAL_HEADER_HEIGHT), layout = _b[0], onLayout = _b[1];
|
|
53
|
+
var navHeight = (0, react_native_reanimated_1.useSharedValue)(layout.height); // initial value
|
|
54
|
+
var animatedNavHeight = (0, react_native_reanimated_1.useAnimatedStyle)(function () {
|
|
55
|
+
return {
|
|
56
|
+
height: navHeight.value,
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
// take children calculated height and change NavContainer height accordingly but with animation
|
|
60
|
+
(0, react_1.useEffect)(function () {
|
|
61
|
+
(0, react_native_reanimated_1.runOnUI)(function () {
|
|
62
|
+
'worklet';
|
|
63
|
+
navHeight.value = (0, react_native_reanimated_1.withTiming)(Math.floor(layout.height), {
|
|
64
|
+
duration: FADE_ANIMATION_DURATION,
|
|
65
|
+
});
|
|
66
|
+
})();
|
|
67
|
+
}, [layout.height]);
|
|
68
|
+
// NavContainer is animated view, height transition will be smooth
|
|
69
|
+
// in order to tell NavContainer which height it children have we need another NavWrapper
|
|
70
|
+
// back-button, title and right-action has wrappers with 33.3% and they are always rendered
|
|
71
|
+
// we need it for correct placing of the title when either back-button or right-action missing
|
|
72
|
+
return ((0, jsx_runtime_1.jsx)(NavHeader_styles_1.NavContainer, __assign({ style: animatedNavHeight }, { children: (0, jsx_runtime_1.jsxs)(NavHeader_styles_1.NavWrapper, __assign({ onLayout: onLayout }, { children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, __assign({ style: {
|
|
73
|
+
width: scrolled ? '33.3%' : '100%',
|
|
74
|
+
height: !canGoBack ? parseInt(element_core_1.theme.core.space[10]) : undefined,
|
|
75
|
+
}, layout: react_native_reanimated_1.Layout.delay(FADE_ANIMATION_DURATION) }, { children: canGoBack && ((0, jsx_runtime_1.jsx)(ActionList_1.Action, __assign({ actionType: "back", onPress: goBack }, { children: "Back" }))) })), 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, __assign({ 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, { 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, __assign({ fullWidth: !scrolled && !rightActionConfig, numberOfLines: 1, 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, { rightActionConfig: rightActionConfig, size: "large", animation: react_native_reanimated_1.FadeInUp.delay(FADE_ANIMATION_DURATION) }) })] }))] })) })));
|
|
88
76
|
};
|
|
89
77
|
exports.NavHeader = NavHeader;
|
|
90
|
-
var
|
|
78
|
+
var IconButton = function (_a) {
|
|
79
|
+
var size = _a.size, animation = _a.animation, rightActionConfig = _a.rightActionConfig;
|
|
80
|
+
var ButtonStyled = size === 'small' ? NavHeader_styles_1.StyledIconButtonS : NavHeader_styles_1.StyledIconButtonL;
|
|
81
|
+
if (!rightActionConfig || !(rightActionConfig === null || rightActionConfig === void 0 ? void 0 : rightActionConfig.iconName)) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, __assign({ hitSlop: 44, pressRetentionOffset: 44, onPress: rightActionConfig === null || rightActionConfig === void 0 ? void 0 : rightActionConfig.onActionPress }, { children: function (_a) {
|
|
85
|
+
var pressed = _a.pressed;
|
|
86
|
+
return ((0, jsx_runtime_1.jsx)(ButtonStyled, __assign({ entering: animation, "$pressed": pressed }, { children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: rightActionConfig.iconName, size: size === 'small' ? 16 : 18, color: element_core_1.theme.semantic.inverted.message.base }) })));
|
|
87
|
+
} })));
|
|
88
|
+
};
|