@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.
Files changed (35) hide show
  1. package/dist/components/ActionList/ActionList.d.ts +3 -7
  2. package/dist/components/ActionList/ActionList.js +7 -18
  3. package/dist/components/ActionList/index.d.ts +1 -1
  4. package/dist/components/ActionList/index.js +4 -15
  5. package/dist/components/ActionList/styled.js +1 -1
  6. package/dist/components/NavHeader/NavHeader.d.ts +3 -2
  7. package/dist/components/NavHeader/NavHeader.js +32 -5
  8. package/dist/components/NavHeader/NavHeader.styles.d.ts +238 -3
  9. package/dist/components/NavHeader/NavHeader.styles.js +16 -12
  10. package/dist/components/P/P.d.ts +4 -242
  11. package/dist/components/P/P.js +18 -2
  12. package/dist/components/SkeletonText/SkeletonText.js +3 -1
  13. package/dist/components/Spinner/Spinner.d.ts +8 -0
  14. package/dist/components/Spinner/Spinner.js +82 -0
  15. package/dist/components/Spinner/index.d.ts +1 -0
  16. package/dist/components/Spinner/index.js +5 -0
  17. package/dist/components/Toast/Toast.d.ts +13 -0
  18. package/dist/components/Toast/Toast.js +168 -0
  19. package/dist/components/Toast/index.d.ts +1 -0
  20. package/dist/components/Toast/index.js +6 -0
  21. package/dist/components/index.d.ts +2 -0
  22. package/dist/components/index.js +2 -0
  23. package/dist/esm/components/ActionList/ActionList.js +8 -19
  24. package/dist/esm/components/ActionList/index.js +1 -1
  25. package/dist/esm/components/ActionList/styled.js +1 -1
  26. package/dist/esm/components/NavHeader/NavHeader.js +34 -7
  27. package/dist/esm/components/NavHeader/NavHeader.styles.js +15 -11
  28. package/dist/esm/components/P/P.js +18 -2
  29. package/dist/esm/components/SkeletonText/SkeletonText.js +3 -1
  30. package/dist/esm/components/Spinner/Spinner.js +55 -0
  31. package/dist/esm/components/Spinner/index.js +1 -0
  32. package/dist/esm/components/Toast/Toast.js +140 -0
  33. package/dist/esm/components/Toast/index.js +1 -0
  34. package/dist/esm/components/index.js +2 -0
  35. package/package.json +9 -4
@@ -1,243 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { Text } from 'react-native';
3
- export declare const P: import("react").ForwardRefExoticComponent<Pick<Omit<{
4
- [x: string]: any;
5
- [x: number]: any;
6
- [x: symbol]: any;
7
- } & {
8
- theme?: {
9
- core: {
10
- radius: Record<"small" | "medium" | "large" | "max", string>;
11
- borderWidth: Record<"small" | "medium" | "large", string>;
12
- breakpoint: Record<"small" | "medium" | "large", string | number>;
13
- mediaQuery: Record<"small" | "medium" | "large", string>;
14
- space: Record<0 | 2 | 1 | 3 | 4 | 5 | 10 | 6 | 7 | 8 | 9 | 11 | 12 | 13 | 14 | 15, string>;
15
- transition: Record<"medium" | "slow" | "fast", string>;
16
- opacity: Record<"solid" | "transparent" | "translucent", string | number>;
17
- color: Record<"neutral" | "red" | "orange" | "yellow" | "green" | "blue", {
18
- lightest: string;
19
- lighter: string;
20
- light: string;
21
- base: string;
22
- dark: string;
23
- darker: string;
24
- darkest: string;
25
- }> & {
26
- brand: Record<string, string>;
27
- };
28
- fontFamily: Record<"body" | "mono" | "heading" | "bodyBold", {
29
- native: string;
30
- web: string;
31
- }>;
32
- fontWeight: Record<"bold" | "book" | "black", string | number>;
33
- fontSize: Record<"small" | "body" | "label" | "heading1" | "heading2" | "heading3" | "heading4" | "lead", {
34
- small: string | number;
35
- large: string | number;
36
- }>;
37
- lineHeight: Record<"small" | "body" | "label" | "heading1" | "heading2" | "heading3" | "heading4" | "lead", {
38
- small: string | number;
39
- large: string | number;
40
- }>;
41
- letterSpacing: Record<"base" | "compressed" | "extraCompressed", number>;
42
- };
43
- semantic: {
44
- surface: Record<"base" | "cutout" | "elevated", string>;
45
- message: Record<"base" | "link" | "secondary" | "error" | "branded", string>;
46
- border: Record<"graphic" | "differentiated" | "functional", string>;
47
- focus: Record<"surface" | "outline" | "hover", string>;
48
- inverted: Record<"surface" | "border", string> & {
49
- message: Record<"base" | "link" | "secondary" | "branded", string>;
50
- };
51
- success: {
52
- border: string;
53
- surface: string;
54
- surfaceEmphasis: string;
55
- message: string;
56
- messageOnEmphasis: string;
57
- };
58
- warning: {
59
- border: string;
60
- surface: string;
61
- surfaceEmphasis: string;
62
- message: string;
63
- messageOnEmphasis: string;
64
- };
65
- error: {
66
- border: string;
67
- surface: string;
68
- surfaceEmphasis: string;
69
- message: string;
70
- messageOnEmphasis: string;
71
- };
72
- info: {
73
- border: string;
74
- surface: string;
75
- surfaceEmphasis: string;
76
- message: string;
77
- messageOnEmphasis: string;
78
- };
79
- data: Record<"branded" | "gas" | "electric", Record<2 | 1 | 3 | 4, string>>;
80
- };
81
- component: {
82
- heading1: {
83
- fontFamily: string;
84
- fontWeight: string | number;
85
- fontSize: {
86
- small: string | number;
87
- large: string | number;
88
- };
89
- lineHeight: {
90
- small: string | number;
91
- large: string | number;
92
- };
93
- };
94
- heading2: {
95
- fontFamily: string;
96
- fontWeight: string | number;
97
- fontSize: {
98
- small: string | number;
99
- large: string | number;
100
- };
101
- lineHeight: {
102
- small: string | number;
103
- large: string | number;
104
- };
105
- };
106
- heading3: {
107
- fontFamily: string;
108
- fontWeight: string | number;
109
- fontSize: {
110
- small: string | number;
111
- large: string | number;
112
- };
113
- lineHeight: {
114
- small: string | number;
115
- large: string | number;
116
- };
117
- };
118
- heading4: {
119
- fontFamily: string;
120
- fontWeight: string | number;
121
- fontSize: {
122
- small: string | number;
123
- large: string | number;
124
- };
125
- lineHeight: {
126
- small: string | number;
127
- large: string | number;
128
- };
129
- };
130
- lead: {
131
- fontFamily: string;
132
- fontWeight: string | number;
133
- fontSize: {
134
- small: string | number;
135
- large: string | number;
136
- };
137
- lineHeight: {
138
- small: string | number;
139
- large: string | number;
140
- };
141
- };
142
- body: {
143
- fontFamily: string;
144
- fontWeight: string | number;
145
- fontSize: {
146
- small: string | number;
147
- large: string | number;
148
- };
149
- lineHeight: {
150
- small: string | number;
151
- large: string | number;
152
- };
153
- };
154
- small: {
155
- fontFamily: string;
156
- fontWeight: string | number;
157
- fontSize: {
158
- small: string | number;
159
- large: string | number;
160
- };
161
- lineHeight: {
162
- small: string | number;
163
- large: string | number;
164
- };
165
- };
166
- label: {
167
- fontFamily: string;
168
- fontWeight: string | number;
169
- fontSize: {
170
- small: string | number;
171
- large: string | number;
172
- };
173
- lineHeight: {
174
- small: string | number;
175
- large: string | number;
176
- };
177
- };
178
- cta: {
179
- primary: {
180
- message: string;
181
- surface: string;
182
- messageHover: string;
183
- surfaceHover: string;
184
- messageFocused: string;
185
- surfaceFocused: string;
186
- outlineFocused: string;
187
- backgroundFocused: string;
188
- };
189
- secondary: {
190
- message: string;
191
- surface: string;
192
- messageHover: string;
193
- surfaceHover: string;
194
- messageFocused: string;
195
- surfaceFocused: string;
196
- outlineFocused: string;
197
- backgroundFocused: string;
198
- };
199
- destructive: {
200
- message: string;
201
- surface: string;
202
- messageHover: string;
203
- surfaceHover: string;
204
- messageFocused: string;
205
- surfaceFocused: string;
206
- outlineFocused: string;
207
- backgroundFocused: string;
208
- };
209
- };
210
- badge: {
211
- variants: {
212
- neutral: {
213
- foreground: string;
214
- background: string;
215
- };
216
- red: {
217
- foreground: string;
218
- background: string;
219
- };
220
- orange: {
221
- foreground: string;
222
- background: string;
223
- };
224
- yellow: {
225
- foreground: string;
226
- background: string;
227
- };
228
- green: {
229
- foreground: string;
230
- background: string;
231
- };
232
- blue: {
233
- foreground: string;
234
- background: string;
235
- };
236
- };
237
- };
238
- };
239
- } | undefined;
240
- } & {
241
- as?: string | import("react").ComponentType<any> | undefined;
242
- forwardedAs?: string | import("react").ComponentType<any> | undefined;
243
- }, import("../../hooks").BreakpointNames>, string | number | symbol> & import("react").RefAttributes<Text>>;
2
+ import { TextProps } from 'react-native';
3
+ export declare const P: import("react").ForwardRefExoticComponent<TextProps & {
4
+ children?: import("react").ReactNode;
5
+ } & import("react").RefAttributes<unknown>>;
@@ -3,6 +3,17 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
3
3
  if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
4
  return cooked;
5
5
  };
6
+ var __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
6
17
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
18
  if (k2 === undefined) k2 = k;
8
19
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -28,11 +39,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
28
39
  };
29
40
  Object.defineProperty(exports, "__esModule", { value: true });
30
41
  exports.P = void 0;
42
+ var jsx_runtime_1 = require("react/jsx-runtime");
43
+ var react_1 = require("react");
44
+ var hooks_1 = require("../../hooks");
31
45
  var styled_native_1 = __importStar(require("../../styled.native"));
32
- var utils_1 = require("../../utils");
33
46
  var StyledP = styled_native_1.default.Text(function (_a) {
34
47
  var _b = _a.theme, core = _b.core, semantic = _b.semantic, smallAndUp = _a.smallAndUp;
35
48
  return (0, styled_native_1.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);
36
49
  });
37
- exports.P = (0, utils_1.styledComponentWithBreakpoints)(StyledP);
50
+ exports.P = (0, react_1.forwardRef)(function (props, ref) {
51
+ var breakpoints = (0, hooks_1.useBreakpoint)();
52
+ return (0, jsx_runtime_1.jsx)(StyledP, __assign({}, props, breakpoints, { ref: ref }));
53
+ });
38
54
  var templateObject_1;
@@ -42,6 +42,8 @@ var SkeletonText = function (_a) {
42
42
  for (var i = 1; i <= lines; i++) {
43
43
  generatedLines.push((0, jsx_runtime_1.jsx)(StyledSkeletonText, { short: i === lines, aboveSmallBreakpoint: smallAndUp }, "line-".concat(i)));
44
44
  }
45
- return ((0, jsx_runtime_1.jsx)(P_1.P, __assign({ as: SkeletonAnimation_1.SkeletonAnimation }, rest, { children: generatedLines })));
45
+ return (
46
+ // @ts-ignore styled components stuff
47
+ (0, jsx_runtime_1.jsx)(P_1.P, __assign({ as: SkeletonAnimation_1.SkeletonAnimation }, rest, { children: generatedLines })));
46
48
  };
47
49
  exports.SkeletonText = SkeletonText;
@@ -0,0 +1,8 @@
1
+ declare type SpinnerSize = 'large' | 'small';
2
+ declare type SpinnerProps = {
3
+ inverted?: boolean;
4
+ size?: SpinnerSize | number;
5
+ accessibilityLabel?: string;
6
+ };
7
+ export declare const Spinner: ({ inverted, size, accessibilityLabel, }: SpinnerProps) => JSX.Element;
8
+ export {};
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.Spinner = void 0;
38
+ var jsx_runtime_1 = require("react/jsx-runtime");
39
+ var react_1 = require("react");
40
+ var react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
41
+ var react_native_svg_1 = __importStar(require("react-native-svg"));
42
+ var styled_native_1 = require("../../styled.native");
43
+ var semanticSizes = {
44
+ large: 65,
45
+ small: 32,
46
+ };
47
+ // based on values in the Figma `y` point is 3.5 times smaller side length, `viewBox` is 1.25 times larger side length
48
+ var calculateSvgProps = function (size) {
49
+ return {
50
+ viewBox: size * 1.25,
51
+ y: size / 3.5,
52
+ };
53
+ };
54
+ var Spinner = function (_a) {
55
+ 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;
56
+ var core = (0, react_1.useContext)(styled_native_1.ThemeContext).core;
57
+ var rotation = (0, react_native_reanimated_1.useSharedValue)(0);
58
+ var animatedStyles = (0, react_native_reanimated_1.useAnimatedStyle)(function () {
59
+ return {
60
+ transform: [
61
+ // needed for correct 3d animation
62
+ { perspective: 1000 },
63
+ {
64
+ rotateY: "".concat(rotation.value, "deg"),
65
+ },
66
+ ],
67
+ };
68
+ }, [rotation.value]);
69
+ (0, react_1.useEffect)(function () {
70
+ // rotate svg from right to left on 360deg during 2 seconds and repeat that 200 times
71
+ rotation.value = (0, react_native_reanimated_1.withRepeat)((0, react_native_reanimated_1.withTiming)(-360, {
72
+ duration: 2000,
73
+ easing: react_native_reanimated_1.Easing.linear,
74
+ }), 200);
75
+ // cancel animation if component is unmounted
76
+ return function () { return (0, react_native_reanimated_1.cancelAnimation)(rotation); };
77
+ }, []);
78
+ var rectangleSize = size in semanticSizes ? semanticSizes[size] : size;
79
+ var _e = calculateSvgProps(rectangleSize), viewBox = _e.viewBox, y = _e.y;
80
+ return ((0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, __assign({ style: [{ width: viewBox }, animatedStyles], accessible: true, accessibilityLabel: accessibilityLabel }, { children: (0, jsx_runtime_1.jsx)(react_native_svg_1.default, __assign({ width: "".concat(viewBox), height: "".concat(viewBox), viewBox: "0 0 ".concat(viewBox, " ").concat(viewBox) }, { children: (0, jsx_runtime_1.jsx)(react_native_svg_1.Rect, { y: "".concat(y), width: "".concat(rectangleSize), height: "".concat(rectangleSize), transform: "rotate(-15 0 ".concat(y, ")"), fill: core.color.brand[inverted ? 'white' : 'ovo'] }) })) })));
81
+ };
82
+ exports.Spinner = Spinner;
@@ -0,0 +1 @@
1
+ export { Spinner } from './Spinner';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Spinner = void 0;
4
+ var Spinner_1 = require("./Spinner");
5
+ Object.defineProperty(exports, "Spinner", { enumerable: true, get: function () { return Spinner_1.Spinner; } });
@@ -0,0 +1,13 @@
1
+ export declare const ToastsContainer: ({ top }: {
2
+ top?: number | undefined;
3
+ }) => JSX.Element;
4
+ declare type ToastVariant = 'default' | 'error';
5
+ export declare const showToast: ({ message, dismissible, action, actionTitle, variant, duration, }: {
6
+ message: string;
7
+ dismissible?: boolean | undefined;
8
+ action?(): void;
9
+ actionTitle?: string | undefined;
10
+ variant?: ToastVariant | undefined;
11
+ duration?: number | undefined;
12
+ }) => string;
13
+ export {};
@@ -0,0 +1,168 @@
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
+ var __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.showToast = exports.ToastsContainer = void 0;
42
+ var jsx_runtime_1 = require("react/jsx-runtime");
43
+ var react_native_toast_1 = require("@backpackapp-io/react-native-toast");
44
+ var react_1 = require("react");
45
+ var react_native_1 = require("react-native");
46
+ var react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
47
+ var styled_native_1 = __importStar(require("../../styled.native"));
48
+ var ActionList_1 = require("../ActionList");
49
+ var Icon_1 = require("../Icon");
50
+ var P_1 = require("../P");
51
+ var ToastsContainer = function (_a) {
52
+ var _b = _a.top, top = _b === void 0 ? -80 : _b;
53
+ return ((0, jsx_runtime_1.jsx)(react_native_toast_1.Toasts, { extraInsets: { top: top } }));
54
+ };
55
+ exports.ToastsContainer = ToastsContainer;
56
+ var StyledView = styled_native_1.default.View(function (_a) {
57
+ var core = _a.theme.core, variant = _a.variant;
58
+ return (0, styled_native_1.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'
59
+ ? core.color.brand.forest
60
+ : core.color.red.darkest, core.space[2], core.space[3], core.space[2], core.space[4], core.radius.max);
61
+ });
62
+ var StyledP = (0, styled_native_1.default)(P_1.P)(function (_a) {
63
+ var semantic = _a.theme.semantic;
64
+ return (0, styled_native_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), semantic.inverted.message.base);
65
+ });
66
+ var StyledThinBorder = (0, styled_native_1.default)(react_native_reanimated_1.default.View)(function (_a) {
67
+ var core = _a.theme.core, variant = _a.variant;
68
+ return (0, styled_native_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background-color: ", ";\n height: 1px;\n "], ["\n background-color: ", ";\n height: 1px;\n "])), variant === 'default'
69
+ ? core.color.brand.energised
70
+ : core.color.red.light);
71
+ });
72
+ var StyledThickBorder = (0, styled_native_1.default)(react_native_reanimated_1.default.View)(function (_a) {
73
+ var core = _a.theme.core, variant = _a.variant;
74
+ return (0, styled_native_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n background-color: ", ";\n height: 3px;\n "], ["\n background-color: ", ";\n height: 3px;\n "])), variant === 'default'
75
+ ? core.color.brand.leaf
76
+ : core.color.red.base);
77
+ });
78
+ var StyledCloseIcon = (0, styled_native_1.default)(react_native_1.TouchableOpacity)(function (_a) {
79
+ var _b = _a.theme, core = _b.core, semantic = _b.semantic;
80
+ return (0, styled_native_1.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]);
81
+ });
82
+ var showToast = function (_a) {
83
+ 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;
84
+ return action || dismissible
85
+ ? react_native_toast_1.toast.loading(message, {
86
+ id: 'clipboard',
87
+ position: react_native_toast_1.ToastPosition.BOTTOM,
88
+ disableShadow: true,
89
+ customToast: function (t) { return ((0, jsx_runtime_1.jsx)(CustomToast, __assign({}, t, { dismissible: dismissible, action: action, actionTitle: actionTitle, variant: variant }), message)); },
90
+ })
91
+ : (0, react_native_toast_1.toast)(message, {
92
+ id: 'clipboard',
93
+ position: react_native_toast_1.ToastPosition.BOTTOM,
94
+ duration: duration,
95
+ disableShadow: true,
96
+ customToast: function (t) { return ((0, jsx_runtime_1.jsx)(CustomToastWithTimeIndicator, __assign({}, t, { variant: variant }), message)); },
97
+ });
98
+ };
99
+ exports.showToast = showToast;
100
+ var CustomToastWithTimeIndicator = function (_a) {
101
+ var message = _a.message, _b = _a.duration, duration = _b === void 0 ? 5000 : _b, variant = _a.variant;
102
+ var toastPadding = 20;
103
+ var textRef = (0, react_1.useRef)(null);
104
+ var _c = (0, react_1.useState)(0), textHeight = _c[0], setTextHeight = _c[1];
105
+ var windowWidth = react_native_1.Dimensions.get('window').width;
106
+ var screenPadding = 32;
107
+ var toastWidth = windowWidth - screenPadding;
108
+ var sharedWidth = (0, react_native_reanimated_1.useSharedValue)(toastWidth);
109
+ var style = (0, react_native_reanimated_1.useAnimatedStyle)(function () {
110
+ return {
111
+ width: (0, react_native_reanimated_1.withTiming)(sharedWidth.value, {
112
+ duration: duration,
113
+ easing: react_native_reanimated_1.Easing.linear,
114
+ }),
115
+ };
116
+ });
117
+ (0, react_1.useEffect)(function () {
118
+ sharedWidth.value = 0;
119
+ }, []);
120
+ return ((0, jsx_runtime_1.jsxs)(StyledView, __assign({ variant: variant, style: {
121
+ width: toastWidth,
122
+ height: textHeight + toastPadding,
123
+ flexWrap: 'wrap',
124
+ } }, { children: [(0, jsx_runtime_1.jsx)(StyledP, __assign({ ref: textRef, onLayout: function () {
125
+ var _a;
126
+ (_a = textRef.current) === null || _a === void 0 ? void 0 : _a.measureInWindow(function (_x, _y, _width, height) {
127
+ setTextHeight(height);
128
+ });
129
+ } }, { children: message })), (0, jsx_runtime_1.jsxs)(react_native_1.View, __assign({ style: { position: 'absolute', bottom: 0 } }, { children: [(0, jsx_runtime_1.jsx)(StyledThinBorder, { variant: variant, style: style }), (0, jsx_runtime_1.jsx)(StyledThickBorder, { variant: variant, style: style })] }))] })));
130
+ };
131
+ var CustomToast = function (_a) {
132
+ var id = _a.id, message = _a.message, dismissible = _a.dismissible, action = _a.action, actionTitle = _a.actionTitle, width = _a.width, variant = _a.variant;
133
+ var toastPadding = 20;
134
+ var textRef = (0, react_1.useRef)(null);
135
+ var actionRef = (0, react_1.useRef)(null);
136
+ var _b = (0, react_1.useState)(0), textHeight = _b[0], setTextHeight = _b[1];
137
+ var _c = (0, react_1.useState)(0), actionHeight = _c[0], setActionHeight = _c[1];
138
+ var toastHeight = Math.floor(textHeight) === Math.floor(actionHeight) && !dismissible // handling multiline
139
+ ? textHeight
140
+ : textHeight + actionHeight;
141
+ var handleAction = function () {
142
+ if (action && actionTitle) {
143
+ action();
144
+ react_native_toast_1.toast.dismiss(id);
145
+ }
146
+ };
147
+ return ((0, jsx_runtime_1.jsxs)(StyledView, __assign({ variant: variant, style: {
148
+ width: width,
149
+ height: toastHeight + toastPadding,
150
+ alignItems: action ? 'flex-start' : 'center',
151
+ } }, { children: [(0, jsx_runtime_1.jsxs)(react_native_1.View, __assign({ style: {
152
+ flexDirection: 'row',
153
+ flexWrap: 'wrap',
154
+ justifyContent: 'space-between',
155
+ flex: 1,
156
+ } }, { children: [(0, jsx_runtime_1.jsx)(StyledP, __assign({ ref: textRef, onLayout: function () {
157
+ var _a;
158
+ (_a = textRef.current) === null || _a === void 0 ? void 0 : _a.measureInWindow(function (_x, _y, _width, height) {
159
+ setTextHeight(height);
160
+ });
161
+ } }, { children: message })), action && actionTitle ? ((0, jsx_runtime_1.jsx)(ActionList_1.Action, __assign({ ref: actionRef, style: { width: 'auto' }, inverted: true, inline: true, iconRight: "chevron-right-small", onPress: handleAction, onLayout: function () {
162
+ var _a;
163
+ (_a = actionRef.current) === null || _a === void 0 ? void 0 : _a.measureInWindow(function (_x, _y, _width, height) {
164
+ setActionHeight(height);
165
+ });
166
+ } }, { children: actionTitle }))) : null] })), dismissible ? ((0, jsx_runtime_1.jsx)(StyledCloseIcon, __assign({ onPress: function () { return react_native_toast_1.toast.dismiss(id); } }, { children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: "cross", color: "#fff", size: 14 }) }))) : null] })));
167
+ };
168
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
@@ -0,0 +1 @@
1
+ export { showToast, ToastsContainer } from './Toast';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ToastsContainer = exports.showToast = void 0;
4
+ var Toast_1 = require("./Toast");
5
+ Object.defineProperty(exports, "showToast", { enumerable: true, get: function () { return Toast_1.showToast; } });
6
+ Object.defineProperty(exports, "ToastsContainer", { enumerable: true, get: function () { return Toast_1.ToastsContainer; } });
@@ -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';
@@ -62,6 +62,7 @@ __exportStar(require("./SkeletonCTA"), exports);
62
62
  __exportStar(require("./SkeletonHeading"), exports);
63
63
  __exportStar(require("./SkeletonText"), exports);
64
64
  __exportStar(require("./Small"), exports);
65
+ __exportStar(require("./Spinner"), exports);
65
66
  __exportStar(require("./Stack"), exports);
66
67
  __exportStar(require("./Strong"), exports);
67
68
  __exportStar(require("./Tabs"), exports);
@@ -72,3 +73,4 @@ __exportStar(require("./TextGroup"), exports);
72
73
  __exportStar(require("./TextInput"), exports);
73
74
  __exportStar(require("./TextLink"), exports);
74
75
  __exportStar(require("./Toggle"), exports);
76
+ __exportStar(require("./Toast"), exports);