@ovotech/element-native 3.6.0 → 3.7.0-canary-7cc2ffb-179
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/ActionList/ActionList.d.ts +3 -7
- package/dist/components/ActionList/ActionList.js +7 -18
- package/dist/components/ActionList/index.d.ts +1 -1
- package/dist/components/ActionList/index.js +4 -15
- package/dist/components/ActionList/styled.js +1 -1
- package/dist/components/NavHeader/NavHeader.d.ts +3 -2
- package/dist/components/NavHeader/NavHeader.js +32 -5
- package/dist/components/NavHeader/NavHeader.styles.d.ts +238 -3
- package/dist/components/NavHeader/NavHeader.styles.js +16 -12
- package/dist/components/P/P.d.ts +4 -242
- package/dist/components/P/P.js +18 -2
- package/dist/components/SkeletonText/SkeletonText.js +3 -1
- package/dist/components/Spinner/Spinner.d.ts +8 -0
- package/dist/components/Spinner/Spinner.js +82 -0
- package/dist/components/Spinner/index.d.ts +1 -0
- package/dist/components/Spinner/index.js +5 -0
- package/dist/components/Toast/Toast.d.ts +13 -0
- package/dist/components/Toast/Toast.js +168 -0
- package/dist/components/Toast/index.d.ts +1 -0
- package/dist/components/Toast/index.js +6 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/esm/components/ActionList/ActionList.js +8 -19
- package/dist/esm/components/ActionList/index.js +1 -1
- package/dist/esm/components/ActionList/styled.js +1 -1
- package/dist/esm/components/NavHeader/NavHeader.js +34 -7
- package/dist/esm/components/NavHeader/NavHeader.styles.js +15 -11
- package/dist/esm/components/P/P.js +18 -2
- package/dist/esm/components/SkeletonText/SkeletonText.js +3 -1
- package/dist/esm/components/Spinner/Spinner.js +55 -0
- package/dist/esm/components/Spinner/index.js +1 -0
- package/dist/esm/components/Toast/Toast.js +140 -0
- package/dist/esm/components/Toast/index.js +1 -0
- package/dist/esm/components/index.js +2 -0
- package/package.json +9 -4
|
@@ -21,16 +21,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
-
import { Children, cloneElement, } from 'react';
|
|
24
|
+
import { Children, cloneElement, forwardRef, } from 'react';
|
|
25
25
|
import { TouchableOpacity, } from 'react-native';
|
|
26
26
|
import { useBreakpoint } from '../../hooks';
|
|
27
27
|
import { StyledActionInner, StyledActionList, StyledActionText, StyledActionWrapper, StyledLeftIcon, StyledRightIcon, } from './styled';
|
|
28
|
-
var ACTION_TYPES = {
|
|
29
|
-
back: 'chevron-left-small',
|
|
30
|
-
// edit: 'arrow-right', /* TODO: add pencil + paper icon */
|
|
31
|
-
external: 'new-window',
|
|
32
|
-
link: 'chevron-right-small',
|
|
33
|
-
};
|
|
34
28
|
var ActionList = function (_a) {
|
|
35
29
|
var children = _a.children, inverted = _a.inverted, rest = __rest(_a, ["children", "inverted"]);
|
|
36
30
|
var childCount = children.length;
|
|
@@ -45,21 +39,16 @@ var ActionList = function (_a) {
|
|
|
45
39
|
});
|
|
46
40
|
}) })));
|
|
47
41
|
};
|
|
48
|
-
var ActionWrapper = function (_a) {
|
|
42
|
+
var ActionWrapper = forwardRef(function (_a, ref) {
|
|
49
43
|
var children = _a.children, accessibilityRole = _a.accessibilityRole, _b = _a.activeOpacity, activeOpacity = _b === void 0 ? 0.75 : _b, fullWidth = _a.fullWidth, _c = _a.hasBorder, hasBorder = _c === void 0 ? false : _c, _d = _a.inverted, inverted = _d === void 0 ? false : _d, _e = _a.inline, inline = _e === void 0 ? false : _e, inList = _a.inList, onPress = _a.onPress, testID = _a.testID, rest = __rest(_a, ["children", "accessibilityRole", "activeOpacity", "fullWidth", "hasBorder", "inverted", "inline", "inList", "onPress", "testID"]);
|
|
50
|
-
return (_jsx(StyledActionWrapper, __assign({ hasBorder: hasBorder, inverted: inverted, testID: testID }, rest, { children: _jsx(TouchableOpacity, __assign({ hitSlop: inline ? 24 : null, activeOpacity: activeOpacity, accessibilityRole: accessibilityRole, onPress: onPress }, { children: _jsx(StyledActionInner, __assign({ fullWidth: fullWidth, inList: inList, inline: inline }, { children: children })) })) })));
|
|
51
|
-
};
|
|
52
|
-
var Action = function (_a) {
|
|
53
|
-
var _b = _a.accessibilityRole, accessibilityRole = _b === void 0 ? 'link' : _b,
|
|
44
|
+
return (_jsx(StyledActionWrapper, __assign({ ref: ref, hasBorder: hasBorder, inverted: inverted, testID: testID }, rest, { children: _jsx(TouchableOpacity, __assign({ hitSlop: inline ? 24 : null, activeOpacity: activeOpacity, accessibilityRole: accessibilityRole, onPress: onPress }, { children: _jsx(StyledActionInner, __assign({ fullWidth: fullWidth, inList: inList, inline: inline }, { children: children })) })) })));
|
|
45
|
+
});
|
|
46
|
+
var Action = forwardRef(function (_a, ref) {
|
|
47
|
+
var _b = _a.accessibilityRole, accessibilityRole = _b === void 0 ? 'link' : _b, children = _a.children, _c = _a.fullWidth, fullWidth = _c === void 0 ? 'never' : _c, _d = _a.inverted, inverted = _d === void 0 ? false : _d, _e = _a.inline, inline = _e === void 0 ? false : _e, onPress = _a.onPress, testID = _a.testID, iconLeft = _a.iconLeft, iconRight = _a.iconRight, rest = __rest(_a, ["accessibilityRole", "children", "fullWidth", "inverted", "inline", "onPress", "testID", "iconLeft", "iconRight"]);
|
|
54
48
|
var smallAndUp = useBreakpoint().smallAndUp;
|
|
55
|
-
var isBackAction = actionType === 'back';
|
|
56
|
-
var updatedIconRight = null;
|
|
57
|
-
if (!isBackAction) {
|
|
58
|
-
updatedIconRight = ACTION_TYPES[actionType];
|
|
59
|
-
}
|
|
60
49
|
if (fullWidth === 'small') {
|
|
61
50
|
fullWidth = smallAndUp ? 'never' : 'always';
|
|
62
51
|
}
|
|
63
|
-
return (_jsxs(ActionWrapper, __assign({ accessibilityRole: accessibilityRole, fullWidth: fullWidth, inverted: inverted, inline: inline, onPress: onPress, testID: testID }, rest, { children: [
|
|
64
|
-
};
|
|
52
|
+
return (_jsxs(ActionWrapper, __assign({ ref: ref, accessibilityRole: accessibilityRole, fullWidth: fullWidth, inverted: inverted, inline: inline, onPress: onPress, testID: testID }, rest, { children: [iconLeft ? (_jsx(StyledLeftIcon, { inverted: inverted, name: iconLeft, size: 16 })) : null, _jsx(StyledActionText, __assign({ smallAndUp: smallAndUp, inverted: inverted, inList: rest === null || rest === void 0 ? void 0 : rest.inList }, { children: children })), iconRight ? (_jsx(StyledRightIcon, { inverted: inverted, name: iconRight, marginTop: iconRight === 'chevron-right-small' ? 1 : 0, size: 16 })) : null] })));
|
|
53
|
+
});
|
|
65
54
|
export { ActionList, Action };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { Action, ActionList } from './ActionList';
|
|
@@ -33,6 +33,6 @@ export var StyledRightIcon = styled(Icon)(function (_a) {
|
|
|
33
33
|
});
|
|
34
34
|
export var StyledLeftIcon = styled(Icon)(function (_a) {
|
|
35
35
|
var _b = _a.theme, core = _b.core, semantic = _b.semantic, inverted = _a.inverted;
|
|
36
|
-
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n color: ", ";\n margin-right: ", ";\n "], ["\n color: ", ";\n margin-right: ", ";\n "])), inverted ? semantic.inverted.message.base : semantic.message.base, core.space[1]);
|
|
36
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n color: ", ";\n margin-right: ", ";\n margin-top: ", ";\n align-self: start;\n "], ["\n color: ", ";\n margin-right: ", ";\n margin-top: ", ";\n align-self: start;\n "])), inverted ? semantic.inverted.message.base : semantic.message.base, core.space[1], core.space[1]);
|
|
37
37
|
});
|
|
38
38
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -11,20 +11,47 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { theme } from '@ovotech/element-core';
|
|
14
|
-
import
|
|
14
|
+
import { useEffect } from 'react';
|
|
15
|
+
import Animated, { Easing, FadeInDown, FadeInUp, FadeOutDown, FadeOutUp, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated';
|
|
15
16
|
import { Action } from '../ActionList';
|
|
16
17
|
import { IconButton } from './IconButton';
|
|
17
|
-
import { CollapsedTitle, CollapsedTitleWrapper, ExpandedTitle, IconButtonWrapper, NavContainer, } from './NavHeader.styles';
|
|
18
|
-
var FADE_ANIMATION_DURATION =
|
|
18
|
+
import { ActionWrapper, CollapsedTitle, CollapsedTitleWrapper, ExpandedTitle, IconButtonWrapper, NavContainer, } from './NavHeader.styles';
|
|
19
|
+
var FADE_ANIMATION_DURATION = 200;
|
|
20
|
+
var ONLY_TITLE_CONTAINER_HEIGHT = 108;
|
|
21
|
+
var TITLE_AND_BACK_CONTAINER_HEIGHT = 92;
|
|
19
22
|
export var NavHeader = function (_a) {
|
|
20
|
-
var title = _a.title, scrolled = _a.scrolled, rightActionConfig = _a.rightActionConfig, canGoBack = _a.canGoBack,
|
|
21
|
-
|
|
23
|
+
var title = _a.title, scrolled = _a.scrolled, rightActionConfig = _a.rightActionConfig, canGoBack = _a.canGoBack, _b = _a.backButtonText, backButtonText = _b === void 0 ? 'Back' : _b, onBackButtonPress = _a.onBackButtonPress;
|
|
24
|
+
var hasRightAction = !!rightActionConfig;
|
|
25
|
+
var initialContainerHeight = canGoBack
|
|
26
|
+
? TITLE_AND_BACK_CONTAINER_HEIGHT
|
|
27
|
+
: ONLY_TITLE_CONTAINER_HEIGHT;
|
|
28
|
+
var animatedContainerHeight = useSharedValue(initialContainerHeight);
|
|
29
|
+
var animatedHeightStyle = useAnimatedStyle(function () {
|
|
30
|
+
return {
|
|
31
|
+
height: animatedContainerHeight.value,
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
useEffect(function () {
|
|
35
|
+
if (scrolled) {
|
|
36
|
+
animatedContainerHeight.value = withTiming(56, {
|
|
37
|
+
duration: FADE_ANIMATION_DURATION,
|
|
38
|
+
easing: Easing.linear,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
animatedContainerHeight.value = withTiming(initialContainerHeight, {
|
|
43
|
+
duration: FADE_ANIMATION_DURATION,
|
|
44
|
+
easing: Easing.linear,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}, [scrolled]);
|
|
48
|
+
return (_jsxs(NavContainer, __assign({ collapsed: scrolled, style: [animatedHeightStyle] }, { children: [_jsx(Animated.View, __assign({ style: {
|
|
22
49
|
width: scrolled ? '33.3%' : '100%',
|
|
23
50
|
// when back button is off we have small margin top for title, to write less code we can just set height
|
|
24
51
|
height: !canGoBack ? parseInt(theme.core.space[10]) : undefined,
|
|
25
|
-
} }, { children: canGoBack && (_jsx(Action, __assign({
|
|
52
|
+
} }, { children: canGoBack && (_jsx(ActionWrapper, __assign({ collapsed: scrolled }, { children: _jsx(Action, __assign({ iconLeft: "chevron-left-small", inline: true, onPress: onBackButtonPress }, { children: backButtonText })) }))) })), scrolled ? (_jsxs(_Fragment, { children: [_jsx(CollapsedTitleWrapper, { children: _jsx(CollapsedTitle, __assign({ 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
|
|
26
53
|
// if we don't have right action leave more space for the title text in expanded state
|
|
27
54
|
, __assign({
|
|
28
55
|
// if we don't have right action leave more space for the title text in expanded state
|
|
29
|
-
fullWidth: !scrolled && !
|
|
56
|
+
fullWidth: !scrolled && !hasRightAction, numberOfLines: 1, 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) }) })] }))] })));
|
|
30
57
|
};
|
|
@@ -2,38 +2,42 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
2
2
|
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
3
|
return cooked;
|
|
4
4
|
};
|
|
5
|
-
import { View } from 'react-native';
|
|
6
5
|
import Animated from 'react-native-reanimated';
|
|
7
6
|
import styled, { css } from '../../styled.native';
|
|
8
|
-
export var NavContainer = styled(View)(function (_a) {
|
|
9
|
-
var _b = _a.theme, semantic = _b.semantic, core = _b.core;
|
|
10
|
-
return css(
|
|
7
|
+
export var NavContainer = styled(Animated.View)(function (_a) {
|
|
8
|
+
var _b = _a.theme, semantic = _b.semantic, core = _b.core, collapsed = _a.collapsed;
|
|
9
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: 100%;\n background-color: ", ";\n padding: ", ";\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n ", "\n "], ["\n width: 100%;\n background-color: ", ";\n padding: ", ";\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n ", "\n "])), semantic.surface.base, core.space[2], collapsed
|
|
10
|
+
? css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-bottom-width: 1px;\n border-bottom-style: solid;\n border-bottom-color: ", ";\n "], ["\n border-bottom-width: 1px;\n border-bottom-style: solid;\n border-bottom-color: ", ";\n "])), semantic.border.differentiated) : '');
|
|
11
11
|
});
|
|
12
12
|
export var ExpandedTitle = styled(Animated.Text)(function (_a) {
|
|
13
13
|
var _b = _a.theme, core = _b.core, semantic = _b.semantic, hasBackButton = _a.hasBackButton, fullWidth = _a.fullWidth;
|
|
14
|
-
return css(
|
|
14
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: ", ";\n font-family: ", ";\n font-size: ", ";\n line-height: ", ";\n height: ", ";\n color: ", ";\n "], ["\n width: ", ";\n font-family: ", ";\n font-size: ", ";\n line-height: ", ";\n height: ", ";\n color: ", ";\n "])), fullWidth ? '100%' : '65%', core.fontFamily.heading.native, core.fontSize.heading1[hasBackButton ? 'small' : 'large'], hasBackButton
|
|
15
15
|
? core.lineHeight.heading1.small
|
|
16
16
|
: core.space[13], hasBackButton ? core.lineHeight.heading1.small : core.space[13], semantic.message.branded);
|
|
17
17
|
});
|
|
18
|
-
export var CollapsedTitleWrapper = styled(Animated.View)(
|
|
18
|
+
export var CollapsedTitleWrapper = styled(Animated.View)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n align-items: center;\n justify-content: center;\n width: 33.3%;\n height: ", ";\n"], ["\n align-items: center;\n justify-content: center;\n width: 33.3%;\n height: ", ";\n"])), function (_a) {
|
|
19
19
|
var core = _a.theme.core;
|
|
20
20
|
return core.lineHeight.heading4.small;
|
|
21
21
|
});
|
|
22
22
|
export var CollapsedTitle = styled(Animated.Text)(function (_a) {
|
|
23
23
|
var _b = _a.theme, core = _b.core, semantic = _b.semantic;
|
|
24
|
-
return css(
|
|
24
|
+
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, core.fontSize.heading4.small, core.lineHeight.heading4.small, semantic.message.branded);
|
|
25
25
|
});
|
|
26
|
-
export var IconButtonWrapper = styled.View(
|
|
26
|
+
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"])));
|
|
27
27
|
var iconButtonSharedStyles = css(function (_a) {
|
|
28
28
|
var semantic = _a.theme.semantic;
|
|
29
29
|
return "\n border-radius: 100px;\n background-color: ".concat(semantic.inverted.surface, ";\n align-items: center;\n justify-content: center;\n");
|
|
30
30
|
});
|
|
31
|
-
export var StyledIconButtonS = styled(Animated.View)(
|
|
31
|
+
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) {
|
|
32
32
|
var $pressed = _a.$pressed;
|
|
33
33
|
return ($pressed ? 0.8 : 1);
|
|
34
34
|
}, iconButtonSharedStyles);
|
|
35
|
-
export var StyledIconButtonL = styled(Animated.View)(
|
|
35
|
+
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) {
|
|
36
36
|
var $pressed = _a.$pressed;
|
|
37
37
|
return ($pressed ? 0.8 : 1);
|
|
38
38
|
}, iconButtonSharedStyles);
|
|
39
|
-
var
|
|
39
|
+
export var ActionWrapper = styled.View(function (_a) {
|
|
40
|
+
var core = _a.theme.core, collapsed = _a.collapsed;
|
|
41
|
+
return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n margin-bottom: ", ";\n "], ["\n margin-bottom: ", ";\n "])), collapsed ? '0' : core.space[2]);
|
|
42
|
+
});
|
|
43
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9;
|
|
@@ -2,11 +2,27 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
2
2
|
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
3
|
return cooked;
|
|
4
4
|
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
import { forwardRef } from 'react';
|
|
18
|
+
import { useBreakpoint } from '../../hooks';
|
|
5
19
|
import styled, { css } from '../../styled.native';
|
|
6
|
-
import { styledComponentWithBreakpoints } from '../../utils';
|
|
7
20
|
var StyledP = styled.Text(function (_a) {
|
|
8
21
|
var _b = _a.theme, core = _b.core, semantic = _b.semantic, smallAndUp = _a.smallAndUp;
|
|
9
22
|
return css(templateObject_1 || (templateObject_1 = __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.body.native, core.fontSize.body[smallAndUp ? 'large' : 'small'], core.lineHeight.body[smallAndUp ? 'large' : 'small'], semantic.message.base);
|
|
10
23
|
});
|
|
11
|
-
export var P =
|
|
24
|
+
export var P = forwardRef(function (props, ref) {
|
|
25
|
+
var breakpoints = useBreakpoint();
|
|
26
|
+
return _jsx(StyledP, __assign({}, props, breakpoints, { ref: ref }));
|
|
27
|
+
});
|
|
12
28
|
var templateObject_1;
|
|
@@ -36,5 +36,7 @@ export var SkeletonText = function (_a) {
|
|
|
36
36
|
for (var i = 1; i <= lines; i++) {
|
|
37
37
|
generatedLines.push(_jsx(StyledSkeletonText, { short: i === lines, aboveSmallBreakpoint: smallAndUp }, "line-".concat(i)));
|
|
38
38
|
}
|
|
39
|
-
return (
|
|
39
|
+
return (
|
|
40
|
+
// @ts-ignore styled components stuff
|
|
41
|
+
_jsx(P, __assign({ as: SkeletonAnimation }, rest, { children: generatedLines })));
|
|
40
42
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { useContext, useEffect } from 'react';
|
|
14
|
+
import Animated, { cancelAnimation, Easing, useAnimatedStyle, useSharedValue, withRepeat, withTiming, } from 'react-native-reanimated';
|
|
15
|
+
import Svg, { Rect } from 'react-native-svg';
|
|
16
|
+
import { ThemeContext } from '../../styled.native';
|
|
17
|
+
var semanticSizes = {
|
|
18
|
+
large: 65,
|
|
19
|
+
small: 32,
|
|
20
|
+
};
|
|
21
|
+
// based on values in the Figma `y` point is 3.5 times smaller side length, `viewBox` is 1.25 times larger side length
|
|
22
|
+
var calculateSvgProps = function (size) {
|
|
23
|
+
return {
|
|
24
|
+
viewBox: size * 1.25,
|
|
25
|
+
y: size / 3.5,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export var Spinner = function (_a) {
|
|
29
|
+
var _b = _a.inverted, inverted = _b === void 0 ? false : _b, _c = _a.size, size = _c === void 0 ? 'small' : _c, _d = _a.accessibilityLabel, accessibilityLabel = _d === void 0 ? 'Loading' : _d;
|
|
30
|
+
var core = useContext(ThemeContext).core;
|
|
31
|
+
var rotation = useSharedValue(0);
|
|
32
|
+
var animatedStyles = useAnimatedStyle(function () {
|
|
33
|
+
return {
|
|
34
|
+
transform: [
|
|
35
|
+
// needed for correct 3d animation
|
|
36
|
+
{ perspective: 1000 },
|
|
37
|
+
{
|
|
38
|
+
rotateY: "".concat(rotation.value, "deg"),
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
}, [rotation.value]);
|
|
43
|
+
useEffect(function () {
|
|
44
|
+
// rotate svg from right to left on 360deg during 2 seconds and repeat that 200 times
|
|
45
|
+
rotation.value = withRepeat(withTiming(-360, {
|
|
46
|
+
duration: 2000,
|
|
47
|
+
easing: Easing.linear,
|
|
48
|
+
}), 200);
|
|
49
|
+
// cancel animation if component is unmounted
|
|
50
|
+
return function () { return cancelAnimation(rotation); };
|
|
51
|
+
}, []);
|
|
52
|
+
var rectangleSize = size in semanticSizes ? semanticSizes[size] : size;
|
|
53
|
+
var _e = calculateSvgProps(rectangleSize), viewBox = _e.viewBox, y = _e.y;
|
|
54
|
+
return (_jsx(Animated.View, __assign({ style: [{ width: viewBox }, animatedStyles], accessible: true, accessibilityLabel: accessibilityLabel }, { children: _jsx(Svg, __assign({ width: "".concat(viewBox), height: "".concat(viewBox), viewBox: "0 0 ".concat(viewBox, " ").concat(viewBox) }, { children: _jsx(Rect, { y: "".concat(y), width: "".concat(rectangleSize), height: "".concat(rectangleSize), transform: "rotate(-15 0 ".concat(y, ")"), fill: core.color.brand[inverted ? 'white' : 'ovo'] }) })) })));
|
|
55
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Spinner } from './Spinner';
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { toast, ToastPosition, Toasts, } from '@backpackapp-io/react-native-toast';
|
|
18
|
+
import { useEffect, useRef, useState } from 'react';
|
|
19
|
+
import { Dimensions, TouchableOpacity, View } from 'react-native';
|
|
20
|
+
import Animated, { Easing, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated';
|
|
21
|
+
import styled, { css } from '../../styled.native';
|
|
22
|
+
import { Action } from '../ActionList';
|
|
23
|
+
import { Icon } from '../Icon';
|
|
24
|
+
import { P } from '../P';
|
|
25
|
+
export var ToastsContainer = function (_a) {
|
|
26
|
+
var _b = _a.top, top = _b === void 0 ? -80 : _b;
|
|
27
|
+
return (_jsx(Toasts, { extraInsets: { top: top } }));
|
|
28
|
+
};
|
|
29
|
+
var StyledView = styled.View(function (_a) {
|
|
30
|
+
var core = _a.theme.core, variant = _a.variant;
|
|
31
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background-color: ", ";\n overflow: hidden;\n padding-top: ", ";\n padding-bottom: ", ";\n padding-right: ", ";\n padding-left: ", ";\n border-radius: ", ";\n flex-direction: row;\n "], ["\n background-color: ", ";\n overflow: hidden;\n padding-top: ", ";\n padding-bottom: ", ";\n padding-right: ", ";\n padding-left: ", ";\n border-radius: ", ";\n flex-direction: row;\n "])), variant === 'default'
|
|
32
|
+
? core.color.brand.forest
|
|
33
|
+
: core.color.red.darkest, core.space[2], core.space[3], core.space[2], core.space[4], core.radius.max);
|
|
34
|
+
});
|
|
35
|
+
var StyledP = styled(P)(function (_a) {
|
|
36
|
+
var semantic = _a.theme.semantic;
|
|
37
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), semantic.inverted.message.base);
|
|
38
|
+
});
|
|
39
|
+
var StyledThinBorder = styled(Animated.View)(function (_a) {
|
|
40
|
+
var core = _a.theme.core, variant = _a.variant;
|
|
41
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background-color: ", ";\n height: 1px;\n "], ["\n background-color: ", ";\n height: 1px;\n "])), variant === 'default'
|
|
42
|
+
? core.color.brand.energised
|
|
43
|
+
: core.color.red.light);
|
|
44
|
+
});
|
|
45
|
+
var StyledThickBorder = styled(Animated.View)(function (_a) {
|
|
46
|
+
var core = _a.theme.core, variant = _a.variant;
|
|
47
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n background-color: ", ";\n height: 3px;\n "], ["\n background-color: ", ";\n height: 3px;\n "])), variant === 'default'
|
|
48
|
+
? core.color.brand.leaf
|
|
49
|
+
: core.color.red.base);
|
|
50
|
+
});
|
|
51
|
+
var StyledCloseIcon = styled(TouchableOpacity)(function (_a) {
|
|
52
|
+
var _b = _a.theme, core = _b.core, semantic = _b.semantic;
|
|
53
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n background-color: ", ";\n border-radius: ", ";\n width: ", ";\n height: ", ";\n padding: ", ";\n align-items: center;\n justify-content: center;\n "], ["\n background-color: ", ";\n border-radius: ", ";\n width: ", ";\n height: ", ";\n padding: ", ";\n align-items: center;\n justify-content: center;\n "])), semantic.inverted.surface, core.radius.max, core.space[7], core.space[7], core.space[2]);
|
|
54
|
+
});
|
|
55
|
+
export var showToast = function (_a) {
|
|
56
|
+
var message = _a.message, _b = _a.dismissible, dismissible = _b === void 0 ? false : _b, action = _a.action, actionTitle = _a.actionTitle, _c = _a.variant, variant = _c === void 0 ? 'default' : _c, _d = _a.duration, duration = _d === void 0 ? 5000 : _d;
|
|
57
|
+
return action || dismissible
|
|
58
|
+
? toast.loading(message, {
|
|
59
|
+
id: 'clipboard',
|
|
60
|
+
position: ToastPosition.BOTTOM,
|
|
61
|
+
disableShadow: true,
|
|
62
|
+
customToast: function (t) { return (_jsx(CustomToast, __assign({}, t, { dismissible: dismissible, action: action, actionTitle: actionTitle, variant: variant }), message)); },
|
|
63
|
+
})
|
|
64
|
+
: toast(message, {
|
|
65
|
+
id: 'clipboard',
|
|
66
|
+
position: ToastPosition.BOTTOM,
|
|
67
|
+
duration: duration,
|
|
68
|
+
disableShadow: true,
|
|
69
|
+
customToast: function (t) { return (_jsx(CustomToastWithTimeIndicator, __assign({}, t, { variant: variant }), message)); },
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
var CustomToastWithTimeIndicator = function (_a) {
|
|
73
|
+
var message = _a.message, _b = _a.duration, duration = _b === void 0 ? 5000 : _b, variant = _a.variant;
|
|
74
|
+
var toastPadding = 20;
|
|
75
|
+
var textRef = useRef(null);
|
|
76
|
+
var _c = useState(0), textHeight = _c[0], setTextHeight = _c[1];
|
|
77
|
+
var windowWidth = Dimensions.get('window').width;
|
|
78
|
+
var screenPadding = 32;
|
|
79
|
+
var toastWidth = windowWidth - screenPadding;
|
|
80
|
+
var sharedWidth = useSharedValue(toastWidth);
|
|
81
|
+
var style = useAnimatedStyle(function () {
|
|
82
|
+
return {
|
|
83
|
+
width: withTiming(sharedWidth.value, {
|
|
84
|
+
duration: duration,
|
|
85
|
+
easing: Easing.linear,
|
|
86
|
+
}),
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
useEffect(function () {
|
|
90
|
+
sharedWidth.value = 0;
|
|
91
|
+
}, []);
|
|
92
|
+
return (_jsxs(StyledView, __assign({ variant: variant, style: {
|
|
93
|
+
width: toastWidth,
|
|
94
|
+
height: textHeight + toastPadding,
|
|
95
|
+
flexWrap: 'wrap',
|
|
96
|
+
} }, { children: [_jsx(StyledP, __assign({ ref: textRef, onLayout: function () {
|
|
97
|
+
var _a;
|
|
98
|
+
(_a = textRef.current) === null || _a === void 0 ? void 0 : _a.measureInWindow(function (_x, _y, _width, height) {
|
|
99
|
+
setTextHeight(height);
|
|
100
|
+
});
|
|
101
|
+
} }, { children: message })), _jsxs(View, __assign({ style: { position: 'absolute', bottom: 0 } }, { children: [_jsx(StyledThinBorder, { variant: variant, style: style }), _jsx(StyledThickBorder, { variant: variant, style: style })] }))] })));
|
|
102
|
+
};
|
|
103
|
+
var CustomToast = function (_a) {
|
|
104
|
+
var id = _a.id, message = _a.message, dismissible = _a.dismissible, action = _a.action, actionTitle = _a.actionTitle, width = _a.width, variant = _a.variant;
|
|
105
|
+
var toastPadding = 20;
|
|
106
|
+
var textRef = useRef(null);
|
|
107
|
+
var actionRef = useRef(null);
|
|
108
|
+
var _b = useState(0), textHeight = _b[0], setTextHeight = _b[1];
|
|
109
|
+
var _c = useState(0), actionHeight = _c[0], setActionHeight = _c[1];
|
|
110
|
+
var toastHeight = Math.floor(textHeight) === Math.floor(actionHeight) && !dismissible // handling multiline
|
|
111
|
+
? textHeight
|
|
112
|
+
: textHeight + actionHeight;
|
|
113
|
+
var handleAction = function () {
|
|
114
|
+
if (action && actionTitle) {
|
|
115
|
+
action();
|
|
116
|
+
toast.dismiss(id);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
return (_jsxs(StyledView, __assign({ variant: variant, style: {
|
|
120
|
+
width: width,
|
|
121
|
+
height: toastHeight + toastPadding,
|
|
122
|
+
alignItems: action ? 'flex-start' : 'center',
|
|
123
|
+
} }, { children: [_jsxs(View, __assign({ style: {
|
|
124
|
+
flexDirection: 'row',
|
|
125
|
+
flexWrap: 'wrap',
|
|
126
|
+
justifyContent: 'space-between',
|
|
127
|
+
flex: 1,
|
|
128
|
+
} }, { children: [_jsx(StyledP, __assign({ ref: textRef, onLayout: function () {
|
|
129
|
+
var _a;
|
|
130
|
+
(_a = textRef.current) === null || _a === void 0 ? void 0 : _a.measureInWindow(function (_x, _y, _width, height) {
|
|
131
|
+
setTextHeight(height);
|
|
132
|
+
});
|
|
133
|
+
} }, { children: message })), action && actionTitle ? (_jsx(Action, __assign({ ref: actionRef, style: { width: 'auto' }, inverted: true, inline: true, iconRight: "chevron-right-small", onPress: handleAction, onLayout: function () {
|
|
134
|
+
var _a;
|
|
135
|
+
(_a = actionRef.current) === null || _a === void 0 ? void 0 : _a.measureInWindow(function (_x, _y, _width, height) {
|
|
136
|
+
setActionHeight(height);
|
|
137
|
+
});
|
|
138
|
+
} }, { children: actionTitle }))) : null] })), dismissible ? (_jsx(StyledCloseIcon, __assign({ onPress: function () { return toast.dismiss(id); } }, { children: _jsx(Icon, { name: "cross", color: "#fff", size: 14 }) }))) : null] })));
|
|
139
|
+
};
|
|
140
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { showToast, ToastsContainer } from './Toast';
|
|
@@ -46,6 +46,7 @@ export * from './SkeletonCTA';
|
|
|
46
46
|
export * from './SkeletonHeading';
|
|
47
47
|
export * from './SkeletonText';
|
|
48
48
|
export * from './Small';
|
|
49
|
+
export * from './Spinner';
|
|
49
50
|
export * from './Stack';
|
|
50
51
|
export * from './Strong';
|
|
51
52
|
export * from './Tabs';
|
|
@@ -56,3 +57,4 @@ export * from './TextGroup';
|
|
|
56
57
|
export * from './TextInput';
|
|
57
58
|
export * from './TextLink';
|
|
58
59
|
export * from './Toggle';
|
|
60
|
+
export * from './Toast';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ovotech/element-native",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0-canary-7cc2ffb-179",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"url": "@ovotech/element"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@
|
|
16
|
+
"@backpackapp-io/react-native-toast": "^0.10.0",
|
|
17
|
+
"@ovotech/element-core": "^2.2.0-canary-7cc2ffb-179",
|
|
17
18
|
"deepmerge": "^4.2.2",
|
|
18
19
|
"lodash.groupby": "^4.6.0"
|
|
19
20
|
},
|
|
@@ -40,7 +41,9 @@
|
|
|
40
41
|
"react": "18.2.0",
|
|
41
42
|
"react-is": "^16.13.0",
|
|
42
43
|
"react-native": "0.72.3",
|
|
44
|
+
"react-native-gesture-handler": "^2.14.0",
|
|
43
45
|
"react-native-reanimated": "^2.10.0",
|
|
46
|
+
"react-native-safe-area-context": "^4.7.4",
|
|
44
47
|
"react-native-svg": "9.2.4",
|
|
45
48
|
"react-router-dom": "^5.1.2",
|
|
46
49
|
"react-test-renderer": "^18.2.0",
|
|
@@ -50,12 +53,14 @@
|
|
|
50
53
|
"typescript": "^4.8.4"
|
|
51
54
|
},
|
|
52
55
|
"peerDependencies": {
|
|
56
|
+
"@react-native-masked-view/masked-view": "^0.3.0",
|
|
53
57
|
"react": "^16.9.0 || ^17.0.0",
|
|
54
58
|
"react-native": "^0.63.3 || ^0.71.0 || ^0.72.0",
|
|
59
|
+
"react-native-gesture-handler": "^2.14.0",
|
|
55
60
|
"react-native-reanimated": "^2.10.0",
|
|
61
|
+
"react-native-safe-area-context": "^4.7.4",
|
|
56
62
|
"react-native-svg": "^13.5.0",
|
|
57
|
-
"styled-components": "^5.1.3"
|
|
58
|
-
"@react-native-masked-view/masked-view": "^0.3.0"
|
|
63
|
+
"styled-components": "^5.1.3"
|
|
59
64
|
},
|
|
60
65
|
"sideEffects": false,
|
|
61
66
|
"scripts": {
|