@ovotech/element-native 5.5.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.
- package/dist/components/Accordion/styles.d.ts +3 -1725
- package/dist/components/ActionList/Action.d.ts +23 -0
- package/dist/components/ActionList/Action.js +29 -0
- package/dist/components/ActionList/ActionList.d.ts +11 -27
- package/dist/components/ActionList/ActionList.js +9 -25
- package/dist/components/ActionList/ActionListItems/DataListItem.d.ts +23 -0
- package/dist/components/ActionList/ActionListItems/DataListItem.js +23 -0
- package/dist/components/ActionList/ActionListItems/EditableListItem.d.ts +43 -0
- package/dist/components/ActionList/ActionListItems/EditableListItem.js +134 -0
- package/dist/components/ActionList/ActionListItems/NavigationListItem.d.ts +16 -0
- package/dist/components/ActionList/ActionListItems/NavigationListItem.js +30 -0
- package/dist/components/ActionList/ActionListItems/ProgressRing.d.ts +7 -0
- package/dist/components/ActionList/ActionListItems/ProgressRing.js +66 -0
- package/dist/components/ActionList/ActionListItems/ToggleListItem.d.ts +9 -0
- package/dist/components/ActionList/ActionListItems/ToggleListItem.js +12 -0
- package/dist/components/ActionList/ActionListItems/styles.d.ts +51 -0
- package/dist/components/ActionList/ActionListItems/styles.js +173 -0
- package/dist/components/ActionList/components/ActionListHeading.d.ts +9 -0
- package/dist/components/ActionList/components/ActionListHeading.js +11 -0
- package/dist/components/ActionList/index.d.ts +6 -1
- package/dist/components/ActionList/index.js +11 -2
- package/dist/components/ActionList/styled.d.ts +12 -5756
- package/dist/components/ActionList/styled.js +24 -9
- package/dist/components/Badge/Badge.d.ts +1 -575
- package/dist/components/BottomActionBar/BottomActionBar.d.ts +12 -0
- package/dist/components/BottomActionBar/BottomActionBar.js +80 -0
- package/dist/components/BottomActionBar/OverlayProvider.d.ts +8 -0
- package/dist/components/BottomActionBar/OverlayProvider.js +38 -0
- package/dist/components/BottomActionBar/index.d.ts +2 -0
- package/dist/components/BottomActionBar/index.js +7 -0
- package/dist/components/Button/Button.js +1 -1
- package/dist/components/Button/Button.styles.d.ts +5 -2300
- package/dist/components/Card/Card.d.ts +7 -4
- package/dist/components/Card/Card.js +44 -22
- package/dist/components/Card/Card.styles.d.ts +4 -1725
- package/dist/components/Card/Card.styles.js +7 -11
- package/dist/components/Cards/AccountCard/AccountCard.styles.d.ts +8 -4600
- package/dist/components/Cards/BalanceCard/BalanceCard.styles.d.ts +15 -8625
- package/dist/components/Cards/BalanceCard/BalanceCard.styles.js +2 -2
- package/dist/components/Cards/DisruptiveCard/DisruptiveCard.d.ts +13 -0
- package/dist/components/Cards/DisruptiveCard/DisruptiveCard.js +45 -0
- package/dist/components/Cards/DisruptiveCard/DisruptiveCard.styles.d.ts +3 -0
- package/dist/components/Cards/DisruptiveCard/DisruptiveCard.styles.js +11 -0
- package/dist/components/Cards/DisruptiveCard/index.d.ts +1 -0
- package/dist/components/Cards/DisruptiveCard/index.js +17 -0
- package/dist/components/Cards/HeroImageCard/HeroImageCard.d.ts +12 -0
- package/dist/components/Cards/HeroImageCard/HeroImageCard.js +65 -0
- package/dist/components/Cards/HeroImageCard/HeroImageCard.styles.d.ts +10 -0
- package/dist/components/Cards/HeroImageCard/HeroImageCard.styles.js +27 -0
- package/dist/components/Cards/HeroImageCard/index.d.ts +1 -0
- package/dist/components/Cards/HeroImageCard/index.js +17 -0
- package/dist/components/Cards/IconDataCard/IconDataCard.styles.d.ts +4 -2300
- package/dist/components/Cards/IconTextCard/IconTextCard.js +3 -16
- package/dist/components/Cards/IconTextCard/IconTextCard.styles.d.ts +3 -2300
- package/dist/components/Cards/IconTextCard/IconTextCard.styles.js +1 -6
- package/dist/components/Cards/IllustrationTextCard/IllustrationTextCard.d.ts +14 -0
- package/dist/components/Cards/IllustrationTextCard/IllustrationTextCard.js +26 -0
- package/dist/components/Cards/IllustrationTextCard/IllustrationTextCard.styles.d.ts +18 -0
- package/dist/components/Cards/IllustrationTextCard/IllustrationTextCard.styles.js +33 -0
- package/dist/components/Cards/IllustrationTextCard/index.d.ts +1 -0
- package/dist/components/Cards/IllustrationTextCard/index.js +17 -0
- package/dist/components/Cards/LinkTextCard/LinkTextCard.d.ts +2 -2
- package/dist/components/Cards/LinkTextCard/LinkTextCard.js +7 -6
- package/dist/components/Cards/LinkTextCard/LinkTextCard.styles.d.ts +8 -2875
- package/dist/components/Cards/LinkTextCard/LinkTextCard.styles.js +9 -6
- package/dist/components/Cards/OfferCard/OfferCard.d.ts +22 -0
- package/dist/components/Cards/OfferCard/OfferCard.js +36 -0
- package/dist/components/Cards/OfferCard/OfferCard.styles.d.ts +34 -0
- package/dist/components/Cards/OfferCard/OfferCard.styles.js +61 -0
- package/dist/components/Cards/OfferCard/index.d.ts +1 -0
- package/dist/components/Cards/OfferCard/index.js +17 -0
- package/dist/components/Cards/ProgressBarCard/ProgressBarCard.styles.d.ts +9 -5175
- package/dist/components/Cards/QuickLinkCard/QuickLinkCard.d.ts +12 -0
- package/dist/components/Cards/QuickLinkCard/QuickLinkCard.js +27 -0
- package/dist/components/Cards/QuickLinkCard/QuickLinkCard.styles.d.ts +12 -0
- package/dist/components/Cards/QuickLinkCard/QuickLinkCard.styles.js +31 -0
- package/dist/components/Cards/QuickLinkCard/index.d.ts +1 -0
- package/dist/components/Cards/QuickLinkCard/index.js +17 -0
- package/dist/components/Cards/ServicesImageCard/ServicesImageCard.d.ts +12 -0
- package/dist/components/Cards/ServicesImageCard/ServicesImageCard.js +24 -0
- package/dist/components/Cards/ServicesImageCard/ServicesImageCard.styles.d.ts +17 -0
- package/dist/components/Cards/ServicesImageCard/ServicesImageCard.styles.js +38 -0
- package/dist/components/Cards/ServicesImageCard/index.d.ts +1 -0
- package/dist/components/Cards/ServicesImageCard/index.js +17 -0
- package/dist/components/Cards/components.d.ts +15 -0
- package/dist/components/Cards/components.js +24 -0
- package/dist/components/Cards/index.d.ts +5 -0
- package/dist/components/Cards/index.js +11 -1
- package/dist/components/Cards/shared.styles.d.ts +11 -3451
- package/dist/components/Cards/shared.styles.js +18 -2
- package/dist/components/Cards/utils.d.ts +1 -0
- package/dist/components/Cards/utils.js +13 -1
- package/dist/components/Checkbox/Checkbox.d.ts +2 -13
- package/dist/components/Checkbox/Checkbox.js +3 -49
- package/dist/components/Checkbox/styled.d.ts +21 -0
- package/dist/components/Checkbox/styled.js +52 -0
- package/dist/components/Checkbox/types.d.ts +16 -0
- package/dist/components/Checkbox/types.js +2 -0
- package/dist/components/CurrencyInput/CurrencyInput.d.ts +2 -1
- package/dist/components/CurrencyInput/CurrencyInput.js +11 -4
- package/dist/components/CurrencyInput/styled.d.ts +10 -0
- package/dist/components/CurrencyInput/styled.js +39 -0
- package/dist/components/DataTable/styles.d.ts +13 -7475
- package/dist/components/Disclosure/Disclosure.d.ts +1 -575
- package/dist/components/Divider/Divider.d.ts +1 -1
- package/dist/components/Divider/Divider.js +3 -1
- package/dist/components/Em/Em.d.ts +1 -575
- package/dist/components/EmailInput/EmailInput.d.ts +4 -1
- package/dist/components/EmailInput/EmailInput.js +18 -2
- package/dist/components/EmptyState/EmptyState.d.ts +2 -0
- package/dist/components/EmptyState/EmptyState.js +17 -0
- package/dist/components/EmptyState/EmptyState.test.d.ts +1 -0
- package/dist/components/EmptyState/EmptyState.test.js +92 -0
- package/dist/components/EmptyState/index.d.ts +1 -0
- package/dist/components/EmptyState/index.js +17 -0
- package/dist/components/EmptyState/styles.d.ts +2 -0
- package/dist/components/EmptyState/styles.js +23 -0
- package/dist/components/EmptyState/types.d.ts +18 -0
- package/dist/components/EmptyState/types.js +2 -0
- package/dist/components/ErrorText/ErrorText.d.ts +1 -575
- package/dist/components/Field/Field.d.ts +3 -2
- package/dist/components/Field/Field.js +3 -2
- package/dist/components/Grid/Col.d.ts +1 -575
- package/dist/components/HintText/HintText.d.ts +1 -575
- package/dist/components/Input/Input.d.ts +2 -1
- package/dist/components/Input/Input.js +6 -97
- package/dist/components/Input/styled.d.ts +16 -0
- package/dist/components/Input/styled.js +96 -0
- package/dist/components/LabelText/LabelText.d.ts +1 -575
- package/dist/components/LargeValueReference/LargeValueReference.d.ts +11 -0
- package/dist/components/LargeValueReference/LargeValueReference.js +49 -0
- package/dist/components/LargeValueReference/index.d.ts +1 -0
- package/dist/components/LargeValueReference/index.js +17 -0
- package/dist/components/LargeValueReference/styles.d.ts +10 -0
- package/dist/components/LargeValueReference/styles.js +29 -0
- package/dist/components/LineThrough/LineThrough.d.ts +1 -575
- package/dist/components/List/styled.d.ts +4 -2300
- package/dist/components/Margin/Margin.d.ts +1 -575
- package/dist/components/NavHeader/NavHeader.styles.d.ts +11 -6325
- package/dist/components/Notification/Notification.d.ts +2 -2
- package/dist/components/Notification/Notification.js +20 -12
- package/dist/components/Notification/Notification.styles.d.ts +13 -5175
- package/dist/components/Notification/Notification.styles.js +21 -2
- package/dist/components/PasswordInput/PasswordInput.styled.d.ts +1 -577
- package/dist/components/PasswordInput/PasswordInput.styled.js +5 -3
- package/dist/components/PasswordInput/PasswordVisibilityToggle.js +2 -8
- package/dist/components/Radio/Radio.d.ts +2 -2
- package/dist/components/Radio/Radio.js +5 -43
- package/dist/components/Radio/Radio.styles.d.ts +9 -0
- package/dist/components/Radio/Radio.styles.js +74 -0
- package/dist/components/RadioCard/RadioCard.d.ts +2 -1
- package/dist/components/RadioCard/RadioCard.js +7 -57
- package/dist/components/RadioCard/RadioCard.styles.d.ts +16 -0
- package/dist/components/RadioCard/RadioCard.styles.js +97 -0
- package/dist/components/Rail/Rail.d.ts +12 -0
- package/dist/components/Rail/Rail.js +58 -0
- package/dist/components/Rail/RailIndicator.d.ts +7 -0
- package/dist/components/Rail/RailIndicator.js +81 -0
- package/dist/components/Rail/index.d.ts +1 -0
- package/dist/components/Rail/index.js +5 -0
- package/dist/components/Rail/styles.d.ts +13 -0
- package/dist/components/Rail/styles.js +55 -0
- package/dist/components/Rail/useRailPaging.d.ts +13 -0
- package/dist/components/Rail/useRailPaging.js +95 -0
- package/dist/components/SelectField/Select.d.ts +5 -579
- package/dist/components/SelectField/Select.js +7 -107
- package/dist/components/SelectField/SelectField.d.ts +2 -2
- package/dist/components/SelectField/SelectField.js +2 -2
- package/dist/components/SelectField/styled.d.ts +26 -0
- package/dist/components/SelectField/styled.js +118 -0
- package/dist/components/SkeletonText/SkeletonText.js +4 -4
- package/dist/components/Strong/Strong.d.ts +1 -575
- package/dist/components/SubLabelText/SubLabelText.d.ts +1 -575
- package/dist/components/Tabs/Tab.d.ts +1 -575
- package/dist/components/TextareaInput/TextareaInput.js +12 -6
- package/dist/components/Toast/Toast.d.ts +10 -4
- package/dist/components/Toast/Toast.js +40 -27
- package/dist/components/Toggle/Toggle.d.ts +3 -1
- package/dist/components/Toggle/Toggle.js +4 -6
- package/dist/components/Toggle/styles.d.ts +5 -2300
- package/dist/components/Toggle/styles.js +3 -3
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.js +5 -0
- package/dist/esm/components/ActionList/Action.js +26 -0
- package/dist/esm/components/ActionList/ActionList.js +12 -28
- package/dist/esm/components/ActionList/ActionListItems/DataListItem.js +19 -0
- package/dist/esm/components/ActionList/ActionListItems/EditableListItem.js +131 -0
- package/dist/esm/components/ActionList/ActionListItems/NavigationListItem.js +26 -0
- package/dist/esm/components/ActionList/ActionListItems/ProgressRing.js +29 -0
- package/dist/esm/components/ActionList/ActionListItems/ToggleListItem.js +8 -0
- package/dist/esm/components/ActionList/ActionListItems/styles.js +137 -0
- package/dist/esm/components/ActionList/components/ActionListHeading.js +7 -0
- package/dist/esm/components/ActionList/index.js +6 -1
- package/dist/esm/components/ActionList/styled.js +23 -8
- package/dist/esm/components/BottomActionBar/BottomActionBar.js +40 -0
- package/dist/esm/components/BottomActionBar/OverlayProvider.js +30 -0
- package/dist/esm/components/BottomActionBar/index.js +2 -0
- package/dist/esm/components/Button/Button.js +1 -1
- package/dist/esm/components/Card/Card.js +45 -23
- package/dist/esm/components/Card/Card.styles.js +8 -12
- package/dist/esm/components/Cards/BalanceCard/BalanceCard.styles.js +2 -2
- package/dist/esm/components/Cards/DisruptiveCard/DisruptiveCard.js +41 -0
- package/dist/esm/components/Cards/DisruptiveCard/DisruptiveCard.styles.js +5 -0
- package/dist/esm/components/Cards/DisruptiveCard/index.js +1 -0
- package/dist/esm/components/Cards/HeroImageCard/HeroImageCard.js +28 -0
- package/dist/esm/components/Cards/HeroImageCard/HeroImageCard.styles.js +21 -0
- package/dist/esm/components/Cards/HeroImageCard/index.js +1 -0
- package/dist/esm/components/Cards/IconTextCard/IconTextCard.js +5 -18
- package/dist/esm/components/Cards/IconTextCard/IconTextCard.styles.js +0 -5
- package/dist/esm/components/Cards/IllustrationTextCard/IllustrationTextCard.js +22 -0
- package/dist/esm/components/Cards/IllustrationTextCard/IllustrationTextCard.styles.js +27 -0
- package/dist/esm/components/Cards/IllustrationTextCard/index.js +1 -0
- package/dist/esm/components/Cards/LinkTextCard/LinkTextCard.js +7 -6
- package/dist/esm/components/Cards/LinkTextCard/LinkTextCard.styles.js +9 -6
- package/dist/esm/components/Cards/OfferCard/OfferCard.js +32 -0
- package/dist/esm/components/Cards/OfferCard/OfferCard.styles.js +55 -0
- package/dist/esm/components/Cards/OfferCard/index.js +1 -0
- package/dist/esm/components/Cards/QuickLinkCard/QuickLinkCard.js +23 -0
- package/dist/esm/components/Cards/QuickLinkCard/QuickLinkCard.styles.js +25 -0
- package/dist/esm/components/Cards/QuickLinkCard/index.js +1 -0
- package/dist/esm/components/Cards/ServicesImageCard/ServicesImageCard.js +20 -0
- package/dist/esm/components/Cards/ServicesImageCard/ServicesImageCard.styles.js +32 -0
- package/dist/esm/components/Cards/ServicesImageCard/index.js +1 -0
- package/dist/esm/components/Cards/components.js +19 -0
- package/dist/esm/components/Cards/index.js +5 -0
- package/dist/esm/components/Cards/shared.styles.js +17 -1
- package/dist/esm/components/Cards/utils.js +11 -0
- package/dist/esm/components/Checkbox/Checkbox.js +2 -45
- package/dist/esm/components/Checkbox/styled.js +46 -0
- package/dist/esm/components/Checkbox/types.js +1 -0
- package/dist/esm/components/CurrencyInput/CurrencyInput.js +12 -5
- package/dist/esm/components/CurrencyInput/styled.js +33 -0
- package/dist/esm/components/Divider/Divider.js +3 -1
- package/dist/esm/components/EmailInput/EmailInput.js +18 -2
- package/dist/esm/components/EmptyState/EmptyState.js +13 -0
- package/dist/esm/components/EmptyState/EmptyState.test.js +90 -0
- package/dist/esm/components/EmptyState/index.js +1 -0
- package/dist/esm/components/EmptyState/styles.js +17 -0
- package/dist/esm/components/EmptyState/types.js +1 -0
- package/dist/esm/components/Field/Field.js +3 -2
- package/dist/esm/components/Input/Input.js +6 -64
- package/dist/esm/components/Input/styled.js +60 -0
- package/dist/esm/components/LargeValueReference/LargeValueReference.js +45 -0
- package/dist/esm/components/LargeValueReference/index.js +1 -0
- package/dist/esm/components/LargeValueReference/styles.js +23 -0
- package/dist/esm/components/Notification/Notification.js +21 -13
- package/dist/esm/components/Notification/Notification.styles.js +20 -1
- package/dist/esm/components/PasswordInput/PasswordInput.styled.js +5 -3
- package/dist/esm/components/PasswordInput/PasswordVisibilityToggle.js +2 -8
- package/dist/esm/components/Radio/Radio.js +4 -39
- package/dist/esm/components/Radio/Radio.styles.js +38 -0
- package/dist/esm/components/RadioCard/RadioCard.js +5 -52
- package/dist/esm/components/RadioCard/RadioCard.styles.js +61 -0
- package/dist/esm/components/Rail/Rail.js +21 -0
- package/dist/esm/components/Rail/RailIndicator.js +44 -0
- package/dist/esm/components/Rail/index.js +1 -0
- package/dist/esm/components/Rail/styles.js +49 -0
- package/dist/esm/components/Rail/useRailPaging.js +92 -0
- package/dist/esm/components/SelectField/Select.js +7 -74
- package/dist/esm/components/SelectField/SelectField.js +3 -3
- package/dist/esm/components/SelectField/styled.js +82 -0
- package/dist/esm/components/SkeletonText/SkeletonText.js +4 -4
- package/dist/esm/components/TextareaInput/TextareaInput.js +12 -6
- package/dist/esm/components/Toast/Toast.js +40 -27
- package/dist/esm/components/Toggle/Toggle.js +4 -6
- package/dist/esm/components/Toggle/styles.js +3 -3
- package/dist/esm/components/index.js +5 -0
- package/dist/esm/hooks/use-font-scaling.js +32 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/test/utils.js +12 -0
- package/dist/esm/utils/utils.js +12 -1
- package/dist/hooks/use-font-scaling.d.ts +26 -0
- package/dist/hooks/use-font-scaling.js +35 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/styled.native.d.ts +1 -3445
- package/dist/test/utils.d.ts +4 -0
- package/dist/test/utils.js +28 -0
- package/dist/utils/utils.d.ts +11 -1
- package/dist/utils/utils.js +12 -0
- package/package.json +5 -5
- package/dist/components/ErrorWrapper/styles.d.ts +0 -0
- package/dist/components/ErrorWrapper/styles.js +0 -1
- package/dist/esm/components/ErrorWrapper/styles.js +0 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import styled, { css } from '../../styled.native';
|
|
2
|
+
import { numToPx } from '../../theme';
|
|
3
|
+
import { getShadowCSS } from '../../utils';
|
|
4
|
+
import { Icon } from '../Icon';
|
|
5
|
+
export const ICON_SIZE = 20;
|
|
6
|
+
export const StyledInputWrapper = styled.View(({ theme, focused, hasError, isSelected }) => {
|
|
7
|
+
let borderColor = 'transparent';
|
|
8
|
+
/* prioritise error and selected states for border, even when focused */
|
|
9
|
+
if (hasError) {
|
|
10
|
+
borderColor = theme.color.alert.error;
|
|
11
|
+
}
|
|
12
|
+
else if (isSelected) {
|
|
13
|
+
borderColor = theme.color.surface.onSurface;
|
|
14
|
+
}
|
|
15
|
+
else if (focused) {
|
|
16
|
+
borderColor = theme.color.outline.outer;
|
|
17
|
+
}
|
|
18
|
+
return css `
|
|
19
|
+
align-self: stretch;
|
|
20
|
+
background-color: ${theme.color.surface.bright};
|
|
21
|
+
border-radius: ${numToPx(theme.border.radius.md)};
|
|
22
|
+
border-width: ${numToPx(theme.border.width.md)};
|
|
23
|
+
border-style: solid;
|
|
24
|
+
border-color: ${borderColor};
|
|
25
|
+
flex-direction: row;
|
|
26
|
+
${getShadowCSS({ theme })}
|
|
27
|
+
`;
|
|
28
|
+
});
|
|
29
|
+
export const StyledInput = styled.TextInput(({ theme, smallAndUp, iconLeft, iconRight, hasRightSlot }) => {
|
|
30
|
+
const fontSize = smallAndUp
|
|
31
|
+
? theme.font.size.md.mediaQuery.lg
|
|
32
|
+
: theme.font.size.md.mediaQuery.sm;
|
|
33
|
+
return css `
|
|
34
|
+
position: relative;
|
|
35
|
+
flex: 1;
|
|
36
|
+
padding: ${numToPx(theme.space[400])};
|
|
37
|
+
border-radius: ${numToPx(theme.border.radius.lg)};
|
|
38
|
+
color: ${theme.color.surface.onSurface};
|
|
39
|
+
font-family: ${theme.native.font.family.book};
|
|
40
|
+
font-size: ${numToPx(fontSize)};
|
|
41
|
+
|
|
42
|
+
/* NOTE: height being queried with design, subject to change */
|
|
43
|
+
min-height: ${numToPx(theme.space[1600])};
|
|
44
|
+
|
|
45
|
+
${iconLeft ? `padding-left: ${numToPx(theme.space[800])};` : ''}
|
|
46
|
+
${iconRight || hasRightSlot
|
|
47
|
+
? `padding-right: ${numToPx(theme.space[800])};`
|
|
48
|
+
: ''}
|
|
49
|
+
`;
|
|
50
|
+
});
|
|
51
|
+
export const StyledIcon = styled(Icon)(({ theme, side }) => {
|
|
52
|
+
return css `
|
|
53
|
+
position: absolute;
|
|
54
|
+
z-index: 1;
|
|
55
|
+
top: 50%;
|
|
56
|
+
margin-top: -${ICON_SIZE / 2}px;
|
|
57
|
+
${side === 'left' ? `left: ${numToPx(theme.space[200])}` : ''};
|
|
58
|
+
${side === 'right' ? `right: ${numToPx(theme.space[200])}` : ''};
|
|
59
|
+
`;
|
|
60
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useCallback, useMemo } from 'react';
|
|
14
|
+
import { TouchableOpacity } from 'react-native';
|
|
15
|
+
import { useTheme } from '../../styled.native';
|
|
16
|
+
import { Icon } from '../Icon';
|
|
17
|
+
import { LabelText } from '../LabelText';
|
|
18
|
+
import { Stack } from '../Stack';
|
|
19
|
+
import { LargeValue, LargeValueContainer, StyledLargeValueReferenceWrapper, } from './styles';
|
|
20
|
+
export const LargeValueReference = (_a) => {
|
|
21
|
+
var { value, autoSpacing = false, autoSpacingInterval = 5, label, onCopy, theme = 'bright' } = _a, rest = __rest(_a, ["value", "autoSpacing", "autoSpacingInterval", "label", "onCopy", "theme"]);
|
|
22
|
+
if (value === undefined || value === null || String(value).length === 0)
|
|
23
|
+
return null;
|
|
24
|
+
const elementTheme = useTheme();
|
|
25
|
+
// Normalizes JS's default scientific notation
|
|
26
|
+
const valueAsString = useMemo(() => typeof value === 'number'
|
|
27
|
+
? value.toLocaleString('fullwide', {
|
|
28
|
+
useGrouping: false,
|
|
29
|
+
})
|
|
30
|
+
: value.toString(), [value]);
|
|
31
|
+
const splitValue = useMemo(() => {
|
|
32
|
+
if (autoSpacing && valueAsString.length > autoSpacingInterval) {
|
|
33
|
+
const matches = valueAsString.match(new RegExp(`.{1,${autoSpacingInterval}}`, 'g'));
|
|
34
|
+
return matches || [];
|
|
35
|
+
}
|
|
36
|
+
return [];
|
|
37
|
+
}, [autoSpacing, valueAsString, autoSpacingInterval]);
|
|
38
|
+
const handlePress = useCallback(() => {
|
|
39
|
+
// Call onCopy callback
|
|
40
|
+
if (typeof onCopy === 'function') {
|
|
41
|
+
onCopy(valueAsString);
|
|
42
|
+
}
|
|
43
|
+
}, [valueAsString, onCopy]);
|
|
44
|
+
return (_jsxs(Stack, { spaceBetween: 2, children: [label ? _jsx(LabelText, { children: label }) : null, _jsx(StyledLargeValueReferenceWrapper, Object.assign({ backgroundTheme: theme }, rest, { children: _jsxs(LargeValueContainer, { children: [autoSpacing && splitValue.length > 0 ? (splitValue.map((val, index) => (_jsx(LargeValue, { children: val }, index)))) : (_jsx(LargeValue, { children: valueAsString })), onCopy ? (_jsx(TouchableOpacity, { activeOpacity: 0.8, onPress: handlePress, hitSlop: 10, testID: "large-value-reference-copy-button", children: _jsx(Icon, { name: "copy", size: 20, color: elementTheme.color.surface.onSurface, testID: "large-value-reference-copy-icon" }) })) : null] }) }))] }));
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './LargeValueReference';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { numToPx } from '@ovotech/element-core';
|
|
2
|
+
import styled from '../../styled.native';
|
|
3
|
+
import { P } from '../P';
|
|
4
|
+
export const StyledLargeValueReferenceWrapper = styled.View(({ theme, backgroundTheme }) => `
|
|
5
|
+
align-items: center;
|
|
6
|
+
max-width: ${'100%'};
|
|
7
|
+
gap: ${numToPx(theme.space[200])};
|
|
8
|
+
padding: ${numToPx(theme.space[400])};
|
|
9
|
+
background-color: ${theme.color.surface[backgroundTheme]};
|
|
10
|
+
border-radius: ${numToPx(theme.border.radius.lg)};
|
|
11
|
+
border: ${numToPx(theme.border.width.sm)} solid ${theme.color.surface.borderDim};
|
|
12
|
+
`);
|
|
13
|
+
export const LargeValueContainer = styled.View(({ theme }) => `
|
|
14
|
+
flex-direction: row;
|
|
15
|
+
flex-wrap: wrap;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
gap: ${numToPx(theme.space[200])};
|
|
19
|
+
`);
|
|
20
|
+
export const LargeValue = styled(P)(() => `
|
|
21
|
+
font-family: monospace;
|
|
22
|
+
letter-spacing: 2px;
|
|
23
|
+
`);
|
|
@@ -16,30 +16,38 @@ import { useTheme } from '../../styled.native';
|
|
|
16
16
|
import { Icon } from '../Icon';
|
|
17
17
|
import { P } from '../P';
|
|
18
18
|
import { Strong } from '../Strong';
|
|
19
|
-
import { ContentContainer, DismissButton, NotificationBox, NotificationContentBox, NotificationShadow, StyledIcon, TitleContainer, VariantIconBackground, VariantIconContainer, } from './Notification.styles';
|
|
19
|
+
import { ContentContainer, DismissButton, NotificationBox, NotificationContentBox, NotificationShadow, StyledIcon, TappableNotification, TitleContainer, VariantIconBackground, VariantIconContainer, } from './Notification.styles';
|
|
20
20
|
import { mapVariantToIconName } from './utils';
|
|
21
21
|
export const Notification = (_a) => {
|
|
22
|
-
var { variant = 'info', children, title, subtitle, noMargin,
|
|
22
|
+
var { variant = 'info', children, title, subtitle, noMargin, onPress, dismissible = true, onDismiss, ref } = _a, rest = __rest(_a, ["variant", "children", "title", "subtitle", "noMargin", "onPress", "dismissible", "onDismiss", "ref"]);
|
|
23
23
|
const [dismissed, setDismissed] = useState(false);
|
|
24
24
|
if (dismissed) {
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const isClickable = !!onPress;
|
|
28
|
+
if (isClickable || dismissible) {
|
|
29
|
+
return (_jsx(NotificationShadow, { children: _jsx(NotificationContent, Object.assign({ variant: variant, title: title, subtitle: subtitle, noMargin: noMargin, onPress: isClickable ? onPress : undefined, dismissible: dismissible, onDismiss: onDismiss, setDismissed: setDismissed, ref: ref }, rest, { children: children })) }));
|
|
29
30
|
}
|
|
30
|
-
return (_jsx(NotificationContent, Object.assign({ variant: variant, title: title, subtitle: subtitle, noMargin: noMargin,
|
|
31
|
+
return (_jsx(NotificationContent, Object.assign({ variant: variant, title: title, subtitle: subtitle, noMargin: noMargin, onPress: onPress, dismissible: dismissible, onDismiss: onDismiss, setDismissed: setDismissed, ref: ref }, rest, { children: children })));
|
|
31
32
|
};
|
|
32
33
|
const NotificationContent = (_a) => {
|
|
33
|
-
var { variant = 'info', children, title, subtitle, noMargin, dismissible, onDismiss, setDismissed, ref } = _a, rest = __rest(_a, ["variant", "children", "title", "subtitle", "noMargin", "dismissible", "onDismiss", "setDismissed", "ref"]);
|
|
34
|
+
var { variant = 'info', children, title, subtitle, noMargin, dismissible, onDismiss, setDismissed, onPress, ref } = _a, rest = __rest(_a, ["variant", "children", "title", "subtitle", "noMargin", "dismissible", "onDismiss", "setDismissed", "onPress", "ref"]);
|
|
34
35
|
const theme = useTheme();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
const hasChildren = !!children;
|
|
37
|
+
const handleDismiss = () => {
|
|
38
|
+
if (onDismiss) {
|
|
39
|
+
onDismiss();
|
|
40
|
+
}
|
|
41
|
+
setDismissed(true);
|
|
42
|
+
};
|
|
43
|
+
return (_jsxs(View, Object.assign({ ref: ref }, rest, { children: [!!onPress && (_jsx(TappableNotification, { dismissible: dismissible, hasChildren: hasChildren, onPress: onPress })), _jsxs(NotificationBox, { noMargin: noMargin, testID: "nb-notification", children: [_jsx(VariantIconBackground, { variant: variant, children: _jsx(VariantIconContainer, { children: _jsx(StyledIcon, { variant: variant, size: theme.unit[800], name: mapVariantToIconName(variant) }) }) }), _jsxs(ContentContainer, { children: [_jsxs(TitleContainer, { children: [title && (_jsx(P, { size: "md", children: _jsx(Strong, { children: title }) })), subtitle && _jsx(P, { size: "sm", children: subtitle }), children && (_jsx(NotificationContentBox, { testID: "el-notification-box", children: children }))] }), dismissible ? (_jsx(DismissButton, { accessible: true, accessibilityLabel: "Dismiss", testID: "nb-notification-dismiss", hitSlop: {
|
|
44
|
+
top: theme.space[300],
|
|
45
|
+
right: theme.space[400],
|
|
46
|
+
bottom: theme.space[100],
|
|
47
|
+
left: theme.space[100],
|
|
48
|
+
}, onPress: handleDismiss, children: _jsx(Icon, { color: theme.button.surface.color.fgInverted, name: "cross", size: theme.space[400] }) })) : null] })] })] })));
|
|
41
49
|
};
|
|
42
50
|
export const SuccessNotification = (props) => (_jsx(Notification, Object.assign({ variant: "success" }, props)));
|
|
43
51
|
export const InfoNotification = (props) => (_jsx(Notification, Object.assign({ variant: "info" }, props)));
|
|
44
52
|
export const WarningNotification = (props) => (_jsx(Notification, Object.assign({ variant: "warning" }, props)));
|
|
45
|
-
export const ErrorNotification = (props) => (_jsx(Notification, Object.assign({ variant: "error" }, props)));
|
|
53
|
+
export const ErrorNotification = (props) => (_jsx(Notification, Object.assign({ variant: "error", dismissible: false }, props)));
|
|
@@ -7,7 +7,7 @@ export const NotificationShadow = styled(View)(({ theme }) => {
|
|
|
7
7
|
return css `
|
|
8
8
|
shadow-color: ${theme.color.brand.dark};
|
|
9
9
|
shadow-offset: 0 ${numToPx(theme.space[100])};
|
|
10
|
-
shadow-opacity:
|
|
10
|
+
shadow-opacity: 0.1;
|
|
11
11
|
shadow-radius: ${numToPx(theme.space[100])};
|
|
12
12
|
elevation: 6;
|
|
13
13
|
`;
|
|
@@ -27,6 +27,25 @@ export const NotificationContentBox = styled.View(({ theme }) => {
|
|
|
27
27
|
padding-right: ${numToPx(theme.space[300])};
|
|
28
28
|
`;
|
|
29
29
|
});
|
|
30
|
+
export const TappableNotification = styled.TouchableOpacity(({ dismissible, hasChildren, theme }) => {
|
|
31
|
+
return css `
|
|
32
|
+
position: absolute;
|
|
33
|
+
left: 0;
|
|
34
|
+
height: ${hasChildren ? numToPx(theme.space[1200]) : '80%'};
|
|
35
|
+
width: ${dismissible ? '86%' : '100%'};
|
|
36
|
+
z-index: 1;
|
|
37
|
+
border-top-left-radius: ${numToPx(theme.border.radius.md)};
|
|
38
|
+
border-top-right-radius: ${dismissible
|
|
39
|
+
? 0
|
|
40
|
+
: numToPx(theme.border.radius.md)};
|
|
41
|
+
border-bottom-right-radius: ${dismissible
|
|
42
|
+
? numToPx(theme.border.radius.md)
|
|
43
|
+
: 0};
|
|
44
|
+
border-bottom-left-radius: ${hasChildren
|
|
45
|
+
? 0
|
|
46
|
+
: numToPx(theme.border.radius.md)};
|
|
47
|
+
`;
|
|
48
|
+
});
|
|
30
49
|
export const DismissButton = styled.TouchableOpacity(({ theme }) => {
|
|
31
50
|
return css `
|
|
32
51
|
display: flex;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { numToPx } from '@ovotech/element-core';
|
|
2
2
|
import { Pressable } from 'react-native';
|
|
3
3
|
import styled, { css } from '../../styled.native';
|
|
4
|
-
|
|
4
|
+
import { ICON_SIZE } from '../Input/styled';
|
|
5
|
+
export const StyledPressable = styled(Pressable)(({ theme }) => {
|
|
5
6
|
return css `
|
|
6
7
|
display: flex;
|
|
7
8
|
align-items: center;
|
|
8
9
|
position: absolute;
|
|
9
10
|
width: ${numToPx(theme.space[400])};
|
|
10
11
|
z-index: 1;
|
|
11
|
-
top:
|
|
12
|
-
|
|
12
|
+
top: 50%;
|
|
13
|
+
margin-top: -${numToPx(ICON_SIZE / 2)};
|
|
14
|
+
right: ${numToPx(theme.space[400])};
|
|
13
15
|
`;
|
|
14
16
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { Icon } from '../Icon';
|
|
4
|
+
import { ICON_SIZE } from '../Input/styled';
|
|
4
5
|
import { StyledPressable } from './PasswordInput.styled';
|
|
5
6
|
export const useTogglePasswordVisibility = () => {
|
|
6
7
|
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
|
|
@@ -12,11 +13,4 @@ export const useTogglePasswordVisibility = () => {
|
|
|
12
13
|
handlePasswordVisibility,
|
|
13
14
|
};
|
|
14
15
|
};
|
|
15
|
-
export const PasswordVisibilityToggle = ({ iconName, visibilityToggleLabel, handlePasswordVisibility, }) => {
|
|
16
|
-
const [focused, setFocused] = useState(false);
|
|
17
|
-
return (_jsx(StyledPressable, { testID: "password-input-visibility-toggle", focused: focused, accessible: true, accessibilityRole: "button", accessibilityLabel: visibilityToggleLabel, onPress: handlePasswordVisibility, hitSlop: 16, onFocus: () => {
|
|
18
|
-
setFocused(true);
|
|
19
|
-
}, onBlur: () => {
|
|
20
|
-
setFocused(false);
|
|
21
|
-
}, children: _jsx(Icon, { name: iconName, size: 16, pointerEvents: "none" }) }));
|
|
22
|
-
};
|
|
16
|
+
export const PasswordVisibilityToggle = ({ iconName, visibilityToggleLabel, handlePasswordVisibility, }) => (_jsx(StyledPressable, { testID: "password-input-visibility-toggle", accessible: true, accessibilityRole: "button", accessibilityLabel: visibilityToggleLabel, onPress: handlePasswordVisibility, hitSlop: ICON_SIZE, children: _jsx(Icon, { name: iconName, size: ICON_SIZE, pointerEvents: "none" }) }));
|
|
@@ -10,56 +10,21 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { numToPx } from '@ovotech/element-core';
|
|
14
13
|
import { TouchableOpacity, View, } from 'react-native';
|
|
15
|
-
import
|
|
14
|
+
import { useTheme } from '../../styled.native';
|
|
16
15
|
import { HintText } from '../HintText';
|
|
17
16
|
import { LabelText } from '../LabelText';
|
|
18
|
-
|
|
19
|
-
return `
|
|
20
|
-
width: ${numToPx(theme.space[600])};
|
|
21
|
-
height: ${numToPx(theme.space[600])};
|
|
22
|
-
margin-right: 10px;
|
|
23
|
-
`;
|
|
24
|
-
});
|
|
25
|
-
const StyledRadioInput = styled.View(({ theme, invalid, checked }) => {
|
|
26
|
-
return `
|
|
27
|
-
width: ${numToPx(theme.space[600])};
|
|
28
|
-
height: ${numToPx(theme.space[600])};
|
|
29
|
-
border: ${numToPx(theme.border.width.md)} solid;
|
|
30
|
-
align-items: center;
|
|
31
|
-
justify-content: center;
|
|
32
|
-
border-radius: ${numToPx(theme.space[600])};
|
|
33
|
-
border-color: ${invalid
|
|
34
|
-
? theme.input.color.borderError
|
|
35
|
-
: checked
|
|
36
|
-
? theme.input.color.selected
|
|
37
|
-
: theme.input.color.border};
|
|
38
|
-
background: ${checked ? theme.input.color.selectedTint : 'transparent'};
|
|
39
|
-
`;
|
|
40
|
-
});
|
|
41
|
-
const StyledRadioInputDot = styled.View(({ theme, checked }) => {
|
|
42
|
-
return `
|
|
43
|
-
width: ${numToPx(theme.space[300])};
|
|
44
|
-
height: ${numToPx(theme.space[300])};
|
|
45
|
-
border-radius: ${numToPx(theme.space[300])};
|
|
46
|
-
background: ${theme.input.color.selected};
|
|
47
|
-
opacity: ${checked ? 1 : 0};
|
|
48
|
-
`;
|
|
49
|
-
});
|
|
17
|
+
import { StyledRadioInput, StyledRadioInputDot, StyledRadioInputWrapper, StyledWrapper, } from './Radio.styles';
|
|
50
18
|
const Input = (_a) => {
|
|
51
19
|
var { checked, invalid, testID } = _a, rest = __rest(_a, ["checked", "invalid", "testID"]);
|
|
52
20
|
return (_jsx(StyledRadioInputWrapper, Object.assign({}, rest, { children: _jsx(StyledRadioInput, { invalid: invalid, checked: checked, testID: testID, children: _jsx(StyledRadioInputDot, { checked: checked }) }) })));
|
|
53
21
|
};
|
|
54
|
-
const StyledWrapper = styled.View(({ theme }) => `
|
|
55
|
-
padding-top: ${numToPx(theme.space[300])};
|
|
56
|
-
flex-direction: row;
|
|
57
|
-
`);
|
|
58
22
|
const Radio = (_a) => {
|
|
59
23
|
var { label, hint, checked, invalid,
|
|
60
24
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
61
25
|
value, // "value" is needed for RadioGroup, but isn't actually used in the radio anywhere
|
|
62
26
|
activeOpacity = 0.8, testID, ref } = _a, rest = __rest(_a, ["label", "hint", "checked", "invalid", "value", "activeOpacity", "testID", "ref"]);
|
|
63
|
-
|
|
27
|
+
const theme = useTheme();
|
|
28
|
+
return (_jsx(TouchableOpacity, Object.assign({ ref: ref, accessible: true, accessibilityRole: "radio", activeOpacity: activeOpacity, accessibilityState: { checked } }, rest, { children: _jsxs(StyledWrapper, { children: [_jsx(Input, { checked: checked, invalid: invalid, testID: testID }), _jsxs(View, { style: { flexShrink: 1 }, children: [_jsx(LabelText, { style: { fontFamily: theme.native.font.family.book }, children: label }), hint ? _jsx(HintText, { children: hint }) : null] })] }) })));
|
|
64
29
|
};
|
|
65
30
|
export { Radio };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { numToPx } from '@ovotech/element-core';
|
|
2
|
+
import styled, { css } from '../../styled.native';
|
|
3
|
+
export const StyledWrapper = styled.View(({ theme }) => css `
|
|
4
|
+
padding-top: ${numToPx(theme.space[300])};
|
|
5
|
+
flex-direction: row;
|
|
6
|
+
`);
|
|
7
|
+
export const StyledRadioInputDot = styled.View(({ theme, checked }) => {
|
|
8
|
+
return css `
|
|
9
|
+
width: ${numToPx(theme.space[300])};
|
|
10
|
+
height: ${numToPx(theme.space[300])};
|
|
11
|
+
border-radius: ${numToPx(theme.space[300])};
|
|
12
|
+
background: ${theme.input.color.selected};
|
|
13
|
+
opacity: ${checked ? 1 : 0};
|
|
14
|
+
`;
|
|
15
|
+
});
|
|
16
|
+
export const StyledRadioInput = styled.View(({ theme, invalid, checked }) => {
|
|
17
|
+
return css `
|
|
18
|
+
width: ${numToPx(theme.space[600])};
|
|
19
|
+
height: ${numToPx(theme.space[600])};
|
|
20
|
+
border: ${numToPx(theme.border.width.md)} solid;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
border-radius: ${numToPx(theme.space[600])};
|
|
24
|
+
border-color: ${invalid
|
|
25
|
+
? theme.input.color.borderError
|
|
26
|
+
: checked
|
|
27
|
+
? theme.input.color.selected
|
|
28
|
+
: theme.input.color.border};
|
|
29
|
+
background: ${checked ? theme.input.color.selectedTint : 'transparent'};
|
|
30
|
+
`;
|
|
31
|
+
});
|
|
32
|
+
export const StyledRadioInputWrapper = styled.View(({ theme }) => {
|
|
33
|
+
return css `
|
|
34
|
+
width: ${numToPx(theme.space[600])};
|
|
35
|
+
height: ${numToPx(theme.space[600])};
|
|
36
|
+
margin-right: 10px;
|
|
37
|
+
`;
|
|
38
|
+
});
|
|
@@ -10,61 +10,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { numToPx } from '@ovotech/element-core';
|
|
14
13
|
import { TouchableOpacity, } from 'react-native';
|
|
15
|
-
import { css } from 'styled-components';
|
|
16
|
-
import styled from '../../styled.native';
|
|
17
14
|
import { LabelText } from '../LabelText';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
`;
|
|
24
|
-
});
|
|
25
|
-
const StyledRadioInput = styled.View(({ theme, invalid, checked }) => {
|
|
26
|
-
return `
|
|
27
|
-
width: ${numToPx(theme.space[600])};
|
|
28
|
-
height: ${numToPx(theme.space[600])};
|
|
29
|
-
border: ${numToPx(theme.border.width.md)} solid;
|
|
30
|
-
align-items: center;
|
|
31
|
-
justify-content: center;
|
|
32
|
-
border-radius: ${numToPx(theme.space[600])};
|
|
33
|
-
border-color: ${invalid
|
|
34
|
-
? theme.input.color.borderError
|
|
35
|
-
: checked
|
|
36
|
-
? theme.input.color.selected
|
|
37
|
-
: theme.input.color.border};
|
|
38
|
-
background: ${checked ? theme.input.color.selectedTint : 'transparent'};
|
|
39
|
-
`;
|
|
40
|
-
});
|
|
41
|
-
const StyledRadioInputDot = styled.View(({ theme, checked }) => {
|
|
42
|
-
return `
|
|
43
|
-
width: ${numToPx(theme.space[300])};
|
|
44
|
-
height: ${numToPx(theme.space[300])};
|
|
45
|
-
border-radius: ${numToPx(theme.space[300])};
|
|
46
|
-
background: ${theme.input.color.selected};
|
|
47
|
-
opacity: ${checked ? 1 : 0};
|
|
48
|
-
`;
|
|
49
|
-
});
|
|
15
|
+
import { StyledRadioInput, StyledRadioInputDot, StyledRadioInputWrapper, StyledWrapper, TextContainer, } from './RadioCard.styles';
|
|
16
|
+
export const RadioCard = (_a) => {
|
|
17
|
+
var { label, checked, invalid, activeOpacity = 0.8, testID, alignment = 'center', ref } = _a, rest = __rest(_a, ["label", "checked", "invalid", "activeOpacity", "testID", "alignment", "ref"]);
|
|
18
|
+
return (_jsx(TouchableOpacity, Object.assign({ ref: ref, accessible: true, accessibilityRole: "radio", activeOpacity: activeOpacity, accessibilityState: { checked } }, rest, { children: _jsxs(StyledWrapper, { checked: checked, invalid: invalid, alignment: alignment, children: [_jsx(TextContainer, { children: typeof label === 'string' ? _jsx(LabelText, { children: label }) : label }), _jsx(Input, { checked: checked, invalid: invalid, testID: testID })] }) })));
|
|
19
|
+
};
|
|
50
20
|
const Input = (_a) => {
|
|
51
21
|
var { checked, invalid, testID } = _a, rest = __rest(_a, ["checked", "invalid", "testID"]);
|
|
52
22
|
return (_jsx(StyledRadioInputWrapper, Object.assign({}, rest, { children: _jsx(StyledRadioInput, { invalid: invalid, checked: checked, testID: testID, children: _jsx(StyledRadioInputDot, { checked: checked }) }) })));
|
|
53
23
|
};
|
|
54
|
-
const StyledWrapper = styled.View(({ theme, checked, invalid }) => css `
|
|
55
|
-
align-items: center;
|
|
56
|
-
background: ${theme.color.surface.bright};
|
|
57
|
-
padding: ${numToPx(theme.space[200])};
|
|
58
|
-
min-width: 82px;
|
|
59
|
-
border-radius: ${numToPx(theme.border.radius.lg)};
|
|
60
|
-
border: ${numToPx(theme.border.width.md)} solid;
|
|
61
|
-
border-color: ${invalid
|
|
62
|
-
? theme.input.color.borderError
|
|
63
|
-
: checked
|
|
64
|
-
? theme.input.color.selected
|
|
65
|
-
: 'transparent'};
|
|
66
|
-
`);
|
|
67
|
-
export const RadioCard = (_a) => {
|
|
68
|
-
var { label, checked, invalid, activeOpacity = 0.8, testID, ref } = _a, rest = __rest(_a, ["label", "checked", "invalid", "activeOpacity", "testID", "ref"]);
|
|
69
|
-
return (_jsx(TouchableOpacity, Object.assign({ ref: ref, accessible: true, accessibilityRole: "radio", activeOpacity: activeOpacity, accessibilityState: { checked } }, rest, { children: _jsxs(StyledWrapper, { checked: checked, invalid: invalid, children: [typeof label === 'string' ? _jsx(LabelText, { children: label }) : label, _jsx(Input, { checked: checked, invalid: invalid, testID: testID })] }) })));
|
|
70
|
-
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { numToPx } from '@ovotech/element-core';
|
|
2
|
+
import styled, { css } from '../../styled.native';
|
|
3
|
+
export const StyledRadioInputWrapper = styled.View(({ theme }) => {
|
|
4
|
+
return `
|
|
5
|
+
width: ${numToPx(theme.space[600])};
|
|
6
|
+
height: ${numToPx(theme.space[600])};
|
|
7
|
+
margin-top: ${numToPx(theme.space[200])};
|
|
8
|
+
`;
|
|
9
|
+
});
|
|
10
|
+
export const StyledRadioInput = styled.View(({ theme, invalid, checked }) => {
|
|
11
|
+
return `
|
|
12
|
+
width: ${numToPx(theme.space[600])};
|
|
13
|
+
height: ${numToPx(theme.space[600])};
|
|
14
|
+
border: ${numToPx(theme.border.width.md)} solid;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
border-radius: ${numToPx(theme.space[600])};
|
|
18
|
+
border-color: ${invalid
|
|
19
|
+
? theme.input.color.borderError
|
|
20
|
+
: checked
|
|
21
|
+
? theme.input.color.selected
|
|
22
|
+
: theme.input.color.border};
|
|
23
|
+
background: ${checked ? theme.input.color.selectedTint : 'transparent'};
|
|
24
|
+
`;
|
|
25
|
+
});
|
|
26
|
+
export const StyledRadioInputDot = styled.View(({ theme, checked }) => {
|
|
27
|
+
return `
|
|
28
|
+
width: ${numToPx(theme.space[300])};
|
|
29
|
+
height: ${numToPx(theme.space[300])};
|
|
30
|
+
border-radius: ${numToPx(theme.space[300])};
|
|
31
|
+
background: ${theme.input.color.selected};
|
|
32
|
+
opacity: ${checked ? 1 : 0};
|
|
33
|
+
`;
|
|
34
|
+
});
|
|
35
|
+
export const StyledWrapper = styled.View(({ theme, checked, invalid, alignment }) => css `
|
|
36
|
+
align-items: center;
|
|
37
|
+
text-align: center;
|
|
38
|
+
justify-content: ${alignment === 'center' ? 'center' : 'flex-end'};
|
|
39
|
+
flex-direction: ${alignment === 'left'
|
|
40
|
+
? 'row-reverse'
|
|
41
|
+
: alignment === 'right'
|
|
42
|
+
? 'row'
|
|
43
|
+
: 'column'};
|
|
44
|
+
background: ${theme.color.surface.bright};
|
|
45
|
+
padding: ${alignment === 'center'
|
|
46
|
+
? numToPx(theme.space[200])
|
|
47
|
+
: numToPx(theme.space[400])};
|
|
48
|
+
border-radius: ${numToPx(theme.border.radius.lg)};
|
|
49
|
+
border: ${numToPx(theme.border.width.md)} solid;
|
|
50
|
+
border-color: ${invalid
|
|
51
|
+
? theme.input.color.borderError
|
|
52
|
+
: checked
|
|
53
|
+
? theme.input.color.selected
|
|
54
|
+
: 'transparent'};
|
|
55
|
+
gap: ${alignment === 'center' ? 0 : numToPx(theme.space[400])};
|
|
56
|
+
`);
|
|
57
|
+
export const TextContainer = styled.View(({ alignment }) => css `
|
|
58
|
+
flex-direction: column;
|
|
59
|
+
flex-grow: 1;
|
|
60
|
+
text-align: ${alignment === 'center' ? 'center' : 'left'};
|
|
61
|
+
`);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import { View, } from 'react-native';
|
|
4
|
+
import { Icon } from '../Icon';
|
|
5
|
+
import { P } from '../P';
|
|
6
|
+
import { Strong } from '../Strong';
|
|
7
|
+
import { RailIndicator } from './RailIndicator';
|
|
8
|
+
import { Header, HeadingText, IconContainer, RailItemWrapper, StyledRail, } from './styles';
|
|
9
|
+
import { useRailPaging } from './useRailPaging';
|
|
10
|
+
const DEFAULT_MAX_CHILDREN = 6;
|
|
11
|
+
export const Rail = ({ children, indicator = true, icon, heading, subHeading, maxChildren = DEFAULT_MAX_CHILDREN, }) => {
|
|
12
|
+
const allItems = useMemo(() => React.Children.toArray(children), [children]);
|
|
13
|
+
const items = useMemo(() => allItems.slice(0, Math.max(0, maxChildren)), [allItems, maxChildren]);
|
|
14
|
+
const paging = useRailPaging({ itemCount: items.length });
|
|
15
|
+
const hasIndicator = indicator && paging.isScrollable;
|
|
16
|
+
return (_jsxs(View, { children: [_jsxs(Header, { children: [icon && (_jsx(IconContainer, { children: _jsx(Icon, { name: icon, size: 24 }) })), (heading || subHeading) && (_jsxs(HeadingText, { children: [heading && (_jsx(P, { size: "lg", children: _jsx(Strong, { children: heading }) })), subHeading && _jsx(P, { size: "sm", children: subHeading })] }))] }), _jsxs(View, { onLayout: e => paging.onContainerLayout(e.nativeEvent.layout.width), children: [_jsx(StyledRail, { horizontal: true, hasIndicator: hasIndicator, showsHorizontalScrollIndicator: false, contentContainerStyle: { flexDirection: 'row' }, decelerationRate: "fast", snapToOffsets: paging.snapOffsets, snapToAlignment: "start", disableIntervalMomentum: true, scrollEventThrottle: 16, onMomentumScrollEnd: (e) => paging.onMomentumEnd(e.nativeEvent.contentOffset.x), onContentSizeChange: w => paging.onContentSizeChange(w), children: items.map((child, index) => (_jsx(RailItemWrapper, { onLayout: (e) => {
|
|
17
|
+
if (index !== 0)
|
|
18
|
+
return;
|
|
19
|
+
paging.onItemLayout(e.nativeEvent.layout.width);
|
|
20
|
+
}, children: child }, `Rail-item-${index}`))) }), hasIndicator && (_jsx(RailIndicator, { dotCount: items.length, activeStartIndex: paging.activeStartIndex, visibleCount: paging.visibleCount }))] })] }));
|
|
21
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
3
|
+
import Animated, { useAnimatedStyle, useDerivedValue, withTiming, } from 'react-native-reanimated';
|
|
4
|
+
import { useTheme } from '../../styled.native';
|
|
5
|
+
import { DotContainer, RailIndicatorContainer } from './styles';
|
|
6
|
+
export const RailIndicator = ({ dotCount, activeStartIndex, visibleCount, }) => {
|
|
7
|
+
const theme = useTheme();
|
|
8
|
+
const DOT = theme.space[200];
|
|
9
|
+
const GAP = theme.space[200];
|
|
10
|
+
const PADDING = theme.space[350];
|
|
11
|
+
const [containerWidth, setContainerWidth] = useState(0);
|
|
12
|
+
const onContainerLayout = useCallback((e) => {
|
|
13
|
+
var _a, _b, _c;
|
|
14
|
+
const w = (_c = (_b = (_a = e === null || e === void 0 ? void 0 : e.nativeEvent) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.width) !== null && _c !== void 0 ? _c : 0;
|
|
15
|
+
if (w > 0)
|
|
16
|
+
setContainerWidth(w);
|
|
17
|
+
}, []);
|
|
18
|
+
if (dotCount <= 0)
|
|
19
|
+
return null;
|
|
20
|
+
const start = Math.min(Math.max(0, activeStartIndex), dotCount - 1);
|
|
21
|
+
const visible = Math.max(1, Math.min(visibleCount, dotCount - start));
|
|
22
|
+
const rowWidth = useMemo(() => {
|
|
23
|
+
return dotCount * DOT + (dotCount - 1) * GAP;
|
|
24
|
+
}, [dotCount, DOT, GAP]);
|
|
25
|
+
const step = DOT + GAP;
|
|
26
|
+
const animatedLeft = useDerivedValue(() => {
|
|
27
|
+
if (containerWidth <= 0)
|
|
28
|
+
return 0;
|
|
29
|
+
const innerWidth = Math.max(0, containerWidth - 2 * PADDING);
|
|
30
|
+
const rowLeft = PADDING + Math.max(0, (innerWidth - rowWidth) / 2);
|
|
31
|
+
return withTiming(rowLeft + start * step, { duration: 150 });
|
|
32
|
+
}, [containerWidth, PADDING, rowWidth, start, step]);
|
|
33
|
+
const animatedWidth = useDerivedValue(() => {
|
|
34
|
+
const w = visible * DOT + Math.max(0, visible - 1) * GAP;
|
|
35
|
+
return withTiming(w, { duration: 150 });
|
|
36
|
+
}, [visible, DOT, GAP]);
|
|
37
|
+
const pillStyle = useAnimatedStyle(() => ({
|
|
38
|
+
position: 'absolute',
|
|
39
|
+
left: animatedLeft.value,
|
|
40
|
+
width: animatedWidth.value,
|
|
41
|
+
opacity: containerWidth > 0 ? 1 : 0,
|
|
42
|
+
}));
|
|
43
|
+
return (_jsxs(RailIndicatorContainer, { onLayout: onContainerLayout, children: [Array.from({ length: dotCount }).map((_, index) => (_jsx(DotContainer, { isActive: false }, `dot-${index}`))), _jsx(Animated.View, { pointerEvents: "none", style: pillStyle, children: _jsx(DotContainer, { isActive: true, style: { width: '100%' } }) })] }));
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Rail } from './Rail';
|
|
@@ -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
|
+
}));
|