@ovotech/element-native 5.6.0 → 5.7.0

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 (102) hide show
  1. package/dist/components/Accordion/styles.d.ts +3 -1734
  2. package/dist/components/ActionList/ActionListItems/DataListItem.js +3 -1
  3. package/dist/components/ActionList/ActionListItems/ToggleListItem.js +3 -4
  4. package/dist/components/ActionList/ActionListItems/styles.d.ts +22 -10404
  5. package/dist/components/ActionList/ActionListItems/styles.js +18 -16
  6. package/dist/components/ActionList/styled.d.ts +12 -6936
  7. package/dist/components/Badge/Badge.d.ts +1 -578
  8. package/dist/components/BottomActionBar/BottomActionBar.d.ts +12 -0
  9. package/dist/components/BottomActionBar/BottomActionBar.js +80 -0
  10. package/dist/components/BottomActionBar/OverlayProvider.d.ts +8 -0
  11. package/dist/components/BottomActionBar/OverlayProvider.js +38 -0
  12. package/dist/components/BottomActionBar/index.d.ts +2 -0
  13. package/dist/components/BottomActionBar/index.js +7 -0
  14. package/dist/components/Button/Button.styles.d.ts +5 -2312
  15. package/dist/components/Card/Card.styles.d.ts +3 -1734
  16. package/dist/components/Cards/AccountCard/AccountCard.styles.d.ts +8 -4624
  17. package/dist/components/Cards/BalanceCard/BalanceCard.styles.d.ts +15 -8670
  18. package/dist/components/Cards/DisruptiveCard/DisruptiveCard.styles.d.ts +1 -578
  19. package/dist/components/Cards/HeroImageCard/HeroImageCard.styles.d.ts +3 -1734
  20. package/dist/components/Cards/IconDataCard/IconDataCard.styles.d.ts +4 -2312
  21. package/dist/components/Cards/IconTextCard/IconTextCard.styles.d.ts +3 -1734
  22. package/dist/components/Cards/IllustrationTextCard/IllustrationTextCard.styles.d.ts +5 -2890
  23. package/dist/components/Cards/IllustrationTextCard/IllustrationTextCard.styles.js +1 -2
  24. package/dist/components/Cards/LinkTextCard/LinkTextCard.styles.d.ts +5 -2890
  25. package/dist/components/Cards/OfferCard/OfferCard.d.ts +22 -0
  26. package/dist/components/Cards/OfferCard/OfferCard.js +36 -0
  27. package/dist/components/Cards/OfferCard/OfferCard.styles.d.ts +34 -0
  28. package/dist/components/Cards/OfferCard/OfferCard.styles.js +61 -0
  29. package/dist/components/Cards/OfferCard/index.d.ts +1 -0
  30. package/dist/components/Cards/OfferCard/index.js +17 -0
  31. package/dist/components/Cards/ProgressBarCard/ProgressBarCard.styles.d.ts +9 -5202
  32. package/dist/components/Cards/QuickLinkCard/QuickLinkCard.styles.d.ts +5 -2890
  33. package/dist/components/Cards/ServicesImageCard/ServicesImageCard.styles.d.ts +5 -2890
  34. package/dist/components/Cards/shared.styles.d.ts +10 -5780
  35. package/dist/components/Checkbox/styled.d.ts +6 -3468
  36. package/dist/components/CurrencyInput/styled.d.ts +4 -2312
  37. package/dist/components/DataTable/styles.d.ts +13 -7514
  38. package/dist/components/Disclosure/Disclosure.d.ts +1 -578
  39. package/dist/components/Em/Em.d.ts +1 -578
  40. package/dist/components/EmptyState/styles.d.ts +2 -1156
  41. package/dist/components/ErrorText/ErrorText.d.ts +1 -578
  42. package/dist/components/Grid/Col.d.ts +1 -578
  43. package/dist/components/HintText/HintText.d.ts +1 -578
  44. package/dist/components/Input/styled.d.ts +3 -1734
  45. package/dist/components/LabelText/LabelText.d.ts +1 -578
  46. package/dist/components/LargeValueReference/styles.d.ts +3 -1734
  47. package/dist/components/LineThrough/LineThrough.d.ts +1 -578
  48. package/dist/components/List/styled.d.ts +4 -2312
  49. package/dist/components/Margin/Margin.d.ts +1 -578
  50. package/dist/components/NavHeader/NavHeader.styles.d.ts +11 -6358
  51. package/dist/components/Notification/Notification.d.ts +2 -2
  52. package/dist/components/Notification/Notification.js +20 -12
  53. package/dist/components/Notification/Notification.styles.d.ts +13 -5202
  54. package/dist/components/Notification/Notification.styles.js +21 -2
  55. package/dist/components/PasswordInput/PasswordInput.styled.d.ts +1 -578
  56. package/dist/components/Radio/Radio.d.ts +2 -2
  57. package/dist/components/Radio/Radio.js +5 -43
  58. package/dist/components/Radio/Radio.styles.d.ts +9 -0
  59. package/dist/components/Radio/Radio.styles.js +74 -0
  60. package/dist/components/RadioCard/RadioCard.styles.d.ts +5 -2890
  61. package/dist/components/Rail/Rail.d.ts +12 -0
  62. package/dist/components/Rail/Rail.js +58 -0
  63. package/dist/components/Rail/RailIndicator.d.ts +7 -0
  64. package/dist/components/Rail/RailIndicator.js +81 -0
  65. package/dist/components/Rail/index.d.ts +1 -0
  66. package/dist/components/Rail/index.js +5 -0
  67. package/dist/components/Rail/styles.d.ts +13 -0
  68. package/dist/components/Rail/styles.js +55 -0
  69. package/dist/components/Rail/useRailPaging.d.ts +13 -0
  70. package/dist/components/Rail/useRailPaging.js +95 -0
  71. package/dist/components/SelectField/styled.d.ts +8 -4624
  72. package/dist/components/Strong/Strong.d.ts +1 -578
  73. package/dist/components/SubLabelText/SubLabelText.d.ts +1 -578
  74. package/dist/components/Tabs/Tab.d.ts +1 -578
  75. package/dist/components/Toast/Toast.d.ts +10 -4
  76. package/dist/components/Toast/Toast.js +40 -27
  77. package/dist/components/Toggle/styles.d.ts +4 -2312
  78. package/dist/components/index.d.ts +2 -0
  79. package/dist/components/index.js +2 -0
  80. package/dist/esm/components/ActionList/ActionListItems/DataListItem.js +3 -1
  81. package/dist/esm/components/ActionList/ActionListItems/ToggleListItem.js +5 -6
  82. package/dist/esm/components/ActionList/ActionListItems/styles.js +17 -15
  83. package/dist/esm/components/BottomActionBar/BottomActionBar.js +40 -0
  84. package/dist/esm/components/BottomActionBar/OverlayProvider.js +30 -0
  85. package/dist/esm/components/BottomActionBar/index.js +2 -0
  86. package/dist/esm/components/Cards/IllustrationTextCard/IllustrationTextCard.styles.js +1 -2
  87. package/dist/esm/components/Cards/OfferCard/OfferCard.js +32 -0
  88. package/dist/esm/components/Cards/OfferCard/OfferCard.styles.js +55 -0
  89. package/dist/esm/components/Cards/OfferCard/index.js +1 -0
  90. package/dist/esm/components/Notification/Notification.js +21 -13
  91. package/dist/esm/components/Notification/Notification.styles.js +20 -1
  92. package/dist/esm/components/Radio/Radio.js +4 -39
  93. package/dist/esm/components/Radio/Radio.styles.js +38 -0
  94. package/dist/esm/components/Rail/Rail.js +21 -0
  95. package/dist/esm/components/Rail/RailIndicator.js +44 -0
  96. package/dist/esm/components/Rail/index.js +1 -0
  97. package/dist/esm/components/Rail/styles.js +49 -0
  98. package/dist/esm/components/Rail/useRailPaging.js +92 -0
  99. package/dist/esm/components/Toast/Toast.js +40 -27
  100. package/dist/esm/components/index.js +2 -0
  101. package/dist/styled.native.d.ts +1 -3463
  102. package/package.json +2 -2
@@ -0,0 +1,49 @@
1
+ import { View } from 'react-native';
2
+ import Animated from 'react-native-reanimated';
3
+ import styled from '../../styled.native';
4
+ export const StyledRail = styled(Animated.ScrollView)(({ theme, hasIndicator }) => ({
5
+ paddingVertical: theme.space[350],
6
+ paddingHorizontal: theme.space[50],
7
+ marginBottom: hasIndicator ? 0 : theme.space[900],
8
+ }));
9
+ export const RailItemWrapper = styled.View(({ theme }) => ({
10
+ paddingHorizontal: theme.space[100],
11
+ }));
12
+ export const RailIndicatorContainer = styled.View(({ theme }) => ({
13
+ flexDirection: 'row',
14
+ alignItems: 'center',
15
+ justifyContent: 'center',
16
+ alignSelf: 'center',
17
+ backgroundColor: theme.color.surface.dim,
18
+ borderRadius: theme.border.radius['2xl'],
19
+ padding: theme.space[350],
20
+ gap: theme.space[200],
21
+ }));
22
+ export const DotContainer = styled(Animated.View)(({ theme, isActive }) => ({
23
+ height: theme.space[200],
24
+ width: theme.space[200],
25
+ borderRadius: 9999,
26
+ backgroundColor: isActive
27
+ ? theme.color.surface.onSurface
28
+ : theme.color.surface.onSurfaceVariant,
29
+ }));
30
+ export const Header = styled(View)(({ theme }) => ({
31
+ flexDirection: 'row',
32
+ gap: theme.space[300],
33
+ marginBottom: -theme.space[100],
34
+ marginLeft: theme.space[100],
35
+ }));
36
+ export const HeadingText = styled(View)({
37
+ flex: 1,
38
+ flexShrink: 1,
39
+ });
40
+ export const IconContainer = styled(View)(({ theme }) => ({
41
+ borderRadius: theme.border.radius['2xl'],
42
+ backgroundColor: theme.color.surface.bright,
43
+ borderWidth: 0,
44
+ padding: theme.space[200],
45
+ width: theme.space[1100],
46
+ height: theme.space[1100],
47
+ alignItems: 'center',
48
+ justifyContent: 'center',
49
+ }));
@@ -0,0 +1,92 @@
1
+ import { useCallback, useEffect, useMemo, useState } from 'react';
2
+ //Epsilon allowable margin for nearly equal comparisons
3
+ const EPS = 0.5;
4
+ function nearlyEqual(a, b, eps = EPS) {
5
+ return Math.abs(a - b) <= eps;
6
+ }
7
+ function clamp(n, lo, hi) {
8
+ return Math.max(lo, Math.min(n, hi));
9
+ }
10
+ function uniqueNearlyEqual(values, eps = EPS) {
11
+ const out = [];
12
+ for (const v of values) {
13
+ if (out.length === 0 || !nearlyEqual(out[out.length - 1], v, eps))
14
+ out.push(v);
15
+ }
16
+ return out;
17
+ }
18
+ export function useRailPaging({ itemCount }) {
19
+ const safeItemCount = Math.max(0, itemCount);
20
+ const [containerWidth, setContainerWidth] = useState(0);
21
+ const [contentWidth, setContentWidth] = useState(0);
22
+ const [itemWidth, setItemWidth] = useState(0);
23
+ const [activeStartIndex, setActiveStartIndex] = useState(0);
24
+ const stride = itemWidth;
25
+ const isScrollable = containerWidth > 0 && contentWidth > containerWidth + 1;
26
+ const visibleCount = useMemo(() => {
27
+ const maxVisible = Math.max(1, safeItemCount);
28
+ if (safeItemCount === 0)
29
+ return 1;
30
+ if (containerWidth <= 0 || stride <= 0)
31
+ return 1;
32
+ return clamp(Math.ceil(containerWidth / stride), 1, maxVisible);
33
+ }, [containerWidth, stride, safeItemCount]);
34
+ const maxStartIndex = useMemo(() => {
35
+ if (safeItemCount <= 0)
36
+ return 0;
37
+ return clamp(safeItemCount - visibleCount, 0, safeItemCount - 1);
38
+ }, [safeItemCount, visibleCount]);
39
+ useEffect(() => {
40
+ setActiveStartIndex(prev => clamp(prev, 0, maxStartIndex));
41
+ }, [maxStartIndex]);
42
+ useEffect(() => {
43
+ setActiveStartIndex(0);
44
+ }, [safeItemCount]);
45
+ const snapOffsets = useMemo(() => {
46
+ var _a;
47
+ if (safeItemCount === 0)
48
+ return [0];
49
+ if (containerWidth <= 0 || contentWidth <= 0 || stride <= 0)
50
+ return [0];
51
+ const maxScrollX = Math.max(0, contentWidth - containerWidth);
52
+ const offsets = [];
53
+ for (let index = 0; index <= maxStartIndex; index++) {
54
+ offsets.push(index * stride);
55
+ }
56
+ const last = (_a = offsets[offsets.length - 1]) !== null && _a !== void 0 ? _a : 0;
57
+ if (!nearlyEqual(last, maxScrollX))
58
+ offsets.push(maxScrollX);
59
+ return uniqueNearlyEqual(offsets);
60
+ }, [safeItemCount, containerWidth, contentWidth, stride, maxStartIndex]);
61
+ const onContainerLayout = useCallback((width) => {
62
+ setContainerWidth(width > 0 ? width : 0);
63
+ }, []);
64
+ const onContentSizeChange = useCallback((width) => {
65
+ setContentWidth(width > 0 ? width : 0);
66
+ }, []);
67
+ /**
68
+ * NOTE: This measures ONE item width (e.g. the first child) and assumes all
69
+ * items are the same width.
70
+ */
71
+ const onItemLayout = useCallback((width) => {
72
+ if (width > 0)
73
+ setItemWidth(width);
74
+ }, []);
75
+ const onMomentumEnd = useCallback((offsetX) => {
76
+ if (stride <= 0)
77
+ return;
78
+ const raw = Math.round(offsetX / stride);
79
+ const nextStart = clamp(raw, 0, maxStartIndex);
80
+ setActiveStartIndex(prev => (prev === nextStart ? prev : nextStart));
81
+ }, [stride, maxStartIndex]);
82
+ return {
83
+ snapOffsets,
84
+ isScrollable,
85
+ activeStartIndex,
86
+ visibleCount,
87
+ onContainerLayout,
88
+ onContentSizeChange,
89
+ onItemLayout,
90
+ onMomentumEnd,
91
+ };
92
+ }
@@ -1,3 +1,14 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
13
  import { toast, ToastPosition, Toasts, } from '@backpackapp-io/react-native-toast';
3
14
  import { numToPx } from '@ovotech/element-core';
@@ -8,7 +19,13 @@ import styled, { css } from '../../styled.native';
8
19
  import { Action } from '../ActionList';
9
20
  import { Icon } from '../Icon';
10
21
  import { P } from '../P';
11
- export const ToastsContainer = ({ top = -80 }) => (_jsx(Toasts, { extraInsets: { top } }));
22
+ const TOAST_PADDING = 20;
23
+ export const ToastsContainer = (_a) => {
24
+ var { top = -80, left, inModal = false } = _a, rest = __rest(_a, ["top", "left", "inModal"]);
25
+ // Extra right inset if in modal, unless it's been explicitly passed
26
+ const leftInset = inModal ? -20 : left !== null && left !== void 0 ? left : 0;
27
+ return _jsx(Toasts, Object.assign({ extraInsets: { top, left: leftInset } }, rest));
28
+ };
12
29
  const StyledView = styled.View(({ theme, variant }) => css `
13
30
  background-color: ${variant === 'default'
14
31
  ? theme.color.alert.success
@@ -39,29 +56,24 @@ const StyledCloseIcon = styled(TouchableOpacity)(({ theme }) => css `
39
56
  align-items: center;
40
57
  justify-content: center;
41
58
  `);
42
- export const showToast = ({ message, dismissible = false, action, actionTitle, variant = 'default', duration = 5000, }) => {
43
- return action || dismissible
44
- ? toast.loading(message, {
45
- id: 'clipboard',
46
- position: ToastPosition.BOTTOM,
47
- disableShadow: true,
48
- customToast: t => (_jsx(CustomToast, Object.assign({}, t, { dismissible: dismissible, action: action, actionTitle: actionTitle, variant: variant }), message)),
49
- })
50
- : toast(message, {
51
- id: 'clipboard',
52
- position: ToastPosition.BOTTOM,
53
- duration,
54
- disableShadow: true,
55
- customToast: t => (_jsx(CustomToastWithTimeIndicator, Object.assign({}, t, { variant: variant }), message)),
56
- });
59
+ export const showToast = ({ message, dismissible = false, action, actionTitle, inlineContent, variant = 'default', duration = 5000, providerKey = 'DEFAULT', }) => {
60
+ const baseToastProps = {
61
+ id: 'clipboard',
62
+ position: ToastPosition.BOTTOM,
63
+ disableShadow: true,
64
+ providerKey,
65
+ };
66
+ // Uses toast.loading for manual dismissal with action or dismiss
67
+ // Otherwise, use regular toast for auto-hiding with time indicator.
68
+ action || dismissible
69
+ ? toast.loading(message, Object.assign(Object.assign({}, baseToastProps), { duration: 0, customToast: t => (_jsx(CustomToast, Object.assign({}, t, { dismissible: dismissible, action: action, actionTitle: actionTitle, variant: variant, inline: inlineContent }), message)) }))
70
+ : toast(message, Object.assign(Object.assign({}, baseToastProps), { duration, customToast: t => (_jsx(CustomToastWithTimeIndicator, Object.assign({}, t, { variant: variant, inline: inlineContent }), message)) }));
57
71
  };
58
- const CustomToastWithTimeIndicator = ({ message, duration = 5000, variant, }) => {
59
- const toastPadding = 20;
72
+ const CustomToastWithTimeIndicator = ({ message, duration = 5000, variant, inline = false, }) => {
60
73
  const textRef = useRef(null);
61
74
  const [textHeight, setTextHeight] = useState(0);
62
75
  const windowWidth = Dimensions.get('window').width;
63
- const screenPadding = 32;
64
- const toastWidth = windowWidth - screenPadding;
76
+ const toastWidth = windowWidth - TOAST_PADDING * 2;
65
77
  const sharedWidth = useSharedValue(toastWidth);
66
78
  const style = useAnimatedStyle(() => {
67
79
  return {
@@ -76,8 +88,9 @@ const CustomToastWithTimeIndicator = ({ message, duration = 5000, variant, }) =>
76
88
  }, []);
77
89
  return (_jsxs(StyledView, { variant: variant, style: {
78
90
  width: toastWidth,
79
- height: textHeight + toastPadding,
91
+ height: textHeight + TOAST_PADDING,
80
92
  flexWrap: 'wrap',
93
+ flexDirection: inline ? 'row' : 'column',
81
94
  }, children: [_jsx(StyledP, { ref: textRef, onLayout: () => {
82
95
  var _a;
83
96
  (_a = textRef.current) === null || _a === void 0 ? void 0 : _a.measureInWindow((_x, _y, _width, height) => {
@@ -85,13 +98,13 @@ const CustomToastWithTimeIndicator = ({ message, duration = 5000, variant, }) =>
85
98
  });
86
99
  }, children: message }), _jsx(View, { style: { position: 'absolute', bottom: 0 }, children: _jsx(StyledBorder, { variant: variant, style: style }) })] }));
87
100
  };
88
- const CustomToast = ({ id, message, dismissible, action, actionTitle, width, variant, }) => {
89
- const toastPadding = 20;
101
+ const CustomToast = ({ id, message, dismissible, action, actionTitle, inline = false, width, variant, }) => {
90
102
  const textRef = useRef(null);
91
103
  const actionRef = useRef(null);
92
104
  const [textHeight, setTextHeight] = useState(0);
93
105
  const [actionHeight, setActionHeight] = useState(0);
94
106
  const toastHeight = textHeight + actionHeight;
107
+ const hasAction = action && actionTitle;
95
108
  const handleAction = () => {
96
109
  if (action && actionTitle) {
97
110
  action();
@@ -100,10 +113,10 @@ const CustomToast = ({ id, message, dismissible, action, actionTitle, width, var
100
113
  };
101
114
  return (_jsxs(StyledView, { variant: variant, style: {
102
115
  width,
103
- height: toastHeight + toastPadding,
104
- alignItems: action ? 'flex-start' : 'center',
116
+ height: toastHeight + TOAST_PADDING,
117
+ alignItems: dismissible ? 'flex-start' : 'center',
105
118
  }, children: [_jsxs(View, { style: {
106
- flexDirection: 'row',
119
+ flexDirection: inline ? 'row' : 'column',
107
120
  flexWrap: 'wrap',
108
121
  justifyContent: 'space-between',
109
122
  flex: 1,
@@ -112,7 +125,7 @@ const CustomToast = ({ id, message, dismissible, action, actionTitle, width, var
112
125
  (_a = textRef.current) === null || _a === void 0 ? void 0 : _a.measureInWindow((_x, _y, _width, height) => {
113
126
  setTextHeight(height);
114
127
  });
115
- }, children: message }), action && actionTitle ? (_jsx(Action, { ref: actionRef, style: { width: 'auto' }, inverted: true, standalone: true, iconRight: "chevron-right-small", onPress: handleAction, onLayout: () => {
128
+ }, children: message }), hasAction ? (_jsx(Action, { ref: actionRef, style: Object.assign({ width: 'auto', paddingBottom: 0 }, (inline ? { paddingTop: 0 } : {})), inverted: true, standalone: true, iconRight: "chevron-right-small", onPress: handleAction, onLayout: () => {
116
129
  var _a;
117
130
  (_a = actionRef.current) === null || _a === void 0 ? void 0 : _a.measureInWindow((_x, _y, _width, height) => {
118
131
  setActionHeight(height);
@@ -2,6 +2,7 @@ export * from './Accordion';
2
2
  export * from './ActionCard';
3
3
  export * from './ActionList';
4
4
  export * from './Badge';
5
+ export * from './BottomActionBar';
5
6
  export * from './Button';
6
7
  export * from './Card';
7
8
  export * from './Cards';
@@ -40,6 +41,7 @@ export * from './PhoneInput';
40
41
  export * from './Pictogram';
41
42
  export * from './Radio';
42
43
  export * from './RadioCard';
44
+ export * from './Rail';
43
45
  export * from './RemoteImage';
44
46
  export * from './ScreenView';
45
47
  export * from './SegmentedControls';