@ovotech/element-native 5.5.0 → 5.6.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 +9 -0
- 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 +21 -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 +13 -0
- package/dist/components/ActionList/ActionListItems/styles.d.ts +10433 -0
- package/dist/components/ActionList/ActionListItems/styles.js +171 -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 +1187 -7
- package/dist/components/ActionList/styled.js +24 -9
- package/dist/components/Badge/Badge.d.ts +3 -0
- package/dist/components/Button/Button.js +1 -1
- package/dist/components/Button/Button.styles.d.ts +12 -0
- 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 +11 -1
- package/dist/components/Card/Card.styles.js +7 -11
- package/dist/components/Cards/AccountCard/AccountCard.styles.d.ts +24 -0
- package/dist/components/Cards/BalanceCard/BalanceCard.styles.d.ts +46 -1
- 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 +580 -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 +1741 -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 +12 -0
- package/dist/components/Cards/IconTextCard/IconTextCard.js +3 -16
- package/dist/components/Cards/IconTextCard/IconTextCard.styles.d.ts +10 -576
- 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 +2903 -0
- package/dist/components/Cards/IllustrationTextCard/IllustrationTextCard.styles.js +34 -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 +20 -2
- package/dist/components/Cards/LinkTextCard/LinkTextCard.styles.js +9 -6
- package/dist/components/Cards/ProgressBarCard/ProgressBarCard.styles.d.ts +28 -1
- 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 +2897 -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 +2902 -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 +2835 -505
- 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 +3483 -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 +2318 -0
- package/dist/components/CurrencyInput/styled.js +39 -0
- package/dist/components/DataTable/styles.d.ts +39 -0
- package/dist/components/Disclosure/Disclosure.d.ts +3 -0
- package/dist/components/Divider/Divider.d.ts +1 -1
- package/dist/components/Divider/Divider.js +3 -1
- package/dist/components/Em/Em.d.ts +3 -0
- 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 +1156 -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 +3 -0
- package/dist/components/Field/Field.d.ts +3 -2
- package/dist/components/Field/Field.js +3 -2
- package/dist/components/Grid/Col.d.ts +3 -0
- package/dist/components/HintText/HintText.d.ts +3 -0
- package/dist/components/Input/Input.d.ts +2 -1
- package/dist/components/Input/Input.js +6 -97
- package/dist/components/Input/styled.d.ts +1747 -0
- package/dist/components/Input/styled.js +96 -0
- package/dist/components/LabelText/LabelText.d.ts +3 -0
- 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 +1741 -0
- package/dist/components/LargeValueReference/styles.js +29 -0
- package/dist/components/LineThrough/LineThrough.d.ts +3 -0
- package/dist/components/List/styled.d.ts +12 -0
- package/dist/components/Margin/Margin.d.ts +3 -0
- package/dist/components/NavHeader/NavHeader.styles.d.ts +33 -0
- package/dist/components/Notification/Notification.styles.d.ts +27 -0
- package/dist/components/PasswordInput/PasswordInput.styled.d.ts +4 -3
- package/dist/components/PasswordInput/PasswordInput.styled.js +5 -3
- package/dist/components/PasswordInput/PasswordVisibilityToggle.js +2 -8
- 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 +2901 -0
- package/dist/components/RadioCard/RadioCard.styles.js +97 -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 +4642 -0
- package/dist/components/SelectField/styled.js +118 -0
- package/dist/components/SkeletonText/SkeletonText.js +4 -4
- package/dist/components/Strong/Strong.d.ts +3 -0
- package/dist/components/SubLabelText/SubLabelText.d.ts +3 -0
- package/dist/components/Tabs/Tab.d.ts +3 -0
- package/dist/components/TextareaInput/TextareaInput.js +12 -6
- package/dist/components/Toggle/Toggle.d.ts +3 -1
- package/dist/components/Toggle/Toggle.js +4 -6
- package/dist/components/Toggle/styles.d.ts +13 -0
- package/dist/components/Toggle/styles.js +3 -3
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +3 -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 +17 -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 +9 -0
- package/dist/esm/components/ActionList/ActionListItems/styles.js +135 -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/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 +28 -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/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/PasswordInput/PasswordInput.styled.js +5 -3
- package/dist/esm/components/PasswordInput/PasswordVisibilityToggle.js +2 -8
- package/dist/esm/components/RadioCard/RadioCard.js +5 -52
- package/dist/esm/components/RadioCard/RadioCard.styles.js +61 -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/Toggle/Toggle.js +4 -6
- package/dist/esm/components/Toggle/styles.js +3 -3
- package/dist/esm/components/index.js +3 -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 +18 -0
- 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 +4 -4
- 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,131 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useImperativeHandle, useMemo, useRef, useState, } from 'react';
|
|
3
|
+
import { CurrencyInput } from '../../CurrencyInput';
|
|
4
|
+
import { EmailInput } from '../../EmailInput';
|
|
5
|
+
import { Input } from '../../Input/Input';
|
|
6
|
+
import { TextLink } from '../../Link';
|
|
7
|
+
import { Margin } from '../../Margin';
|
|
8
|
+
import { NumberInput } from '../../NumberInput';
|
|
9
|
+
import { P } from '../../P';
|
|
10
|
+
import { SelectField } from '../../SelectField';
|
|
11
|
+
import { Strong } from '../../Strong';
|
|
12
|
+
import { TextareaInput } from '../../TextareaInput';
|
|
13
|
+
import { ActionListItemWrapper, EditableListContainer, EditButtonsContainer, InitialStateContainer, ValueText, } from './styles';
|
|
14
|
+
const getInitialValue = (input) => {
|
|
15
|
+
var _a, _b, _c;
|
|
16
|
+
switch (input.type) {
|
|
17
|
+
case 'number':
|
|
18
|
+
case 'currency':
|
|
19
|
+
return (_a = input.defaultValue) !== null && _a !== void 0 ? _a : null;
|
|
20
|
+
case 'select':
|
|
21
|
+
return (_b = input.defaultValue) !== null && _b !== void 0 ? _b : null;
|
|
22
|
+
case 'text':
|
|
23
|
+
case 'location':
|
|
24
|
+
case 'email':
|
|
25
|
+
case 'textarea':
|
|
26
|
+
return (_c = input.defaultValue) !== null && _c !== void 0 ? _c : '';
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
function acceptNumericInput(nextText, prevText) {
|
|
30
|
+
var _a;
|
|
31
|
+
if (nextText === '')
|
|
32
|
+
return '';
|
|
33
|
+
if (!/^[0-9.]*$/.test(nextText))
|
|
34
|
+
return prevText;
|
|
35
|
+
if (((_a = nextText.match(/\./g)) !== null && _a !== void 0 ? _a : []).length > 1)
|
|
36
|
+
return prevText;
|
|
37
|
+
return nextText;
|
|
38
|
+
}
|
|
39
|
+
function parseDraftNumericText(text) {
|
|
40
|
+
if (text === '' || text === '.' || text.endsWith('.'))
|
|
41
|
+
return null;
|
|
42
|
+
const n = Number(text);
|
|
43
|
+
return Number.isFinite(n) ? n : null;
|
|
44
|
+
}
|
|
45
|
+
export const EditableListItem = forwardRef(({ heading, input, onSave }, ref) => {
|
|
46
|
+
const inputRef = useRef(null);
|
|
47
|
+
const initialValue = useMemo(() => getInitialValue(input), [input]);
|
|
48
|
+
const [editState, setEditState] = useState('initial');
|
|
49
|
+
const [value, setValue] = useState(initialValue);
|
|
50
|
+
const [draft, setDraft] = useState(initialValue);
|
|
51
|
+
const [numericInputText, setNumericInputText] = useState('');
|
|
52
|
+
useImperativeHandle(ref, () => ({
|
|
53
|
+
getValue: () => value,
|
|
54
|
+
}));
|
|
55
|
+
const handleNumericChange = (nextText) => {
|
|
56
|
+
const accepted = acceptNumericInput(nextText, numericInputText);
|
|
57
|
+
if (accepted === numericInputText)
|
|
58
|
+
return;
|
|
59
|
+
setNumericInputText(accepted);
|
|
60
|
+
};
|
|
61
|
+
const startEditing = () => {
|
|
62
|
+
setDraft(value);
|
|
63
|
+
setEditState('editing');
|
|
64
|
+
if (input.type === 'number' || input.type === 'currency') {
|
|
65
|
+
const n = value;
|
|
66
|
+
setNumericInputText(n === null ? '' : String(n));
|
|
67
|
+
}
|
|
68
|
+
requestAnimationFrame(() => {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
(_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const saveEditing = () => {
|
|
74
|
+
const nextValue = input.type === 'number' || input.type === 'currency'
|
|
75
|
+
? parseDraftNumericText(numericInputText)
|
|
76
|
+
: draft;
|
|
77
|
+
setValue(nextValue);
|
|
78
|
+
setEditState('initial');
|
|
79
|
+
onSave === null || onSave === void 0 ? void 0 : onSave(nextValue);
|
|
80
|
+
};
|
|
81
|
+
const cancelEditing = () => {
|
|
82
|
+
setDraft(value);
|
|
83
|
+
if (input.type === 'number' || input.type === 'currency') {
|
|
84
|
+
const n = value;
|
|
85
|
+
setNumericInputText(n === null ? '' : String(n));
|
|
86
|
+
}
|
|
87
|
+
setEditState('initial');
|
|
88
|
+
};
|
|
89
|
+
const displayValue = useMemo(() => {
|
|
90
|
+
var _a, _b;
|
|
91
|
+
switch (input.type) {
|
|
92
|
+
case 'select':
|
|
93
|
+
return (_a = value === null || value === void 0 ? void 0 : value.label) !== null && _a !== void 0 ? _a : '-';
|
|
94
|
+
case 'number':
|
|
95
|
+
case 'currency':
|
|
96
|
+
return (_b = value === null || value === void 0 ? void 0 : value.toString()) !== null && _b !== void 0 ? _b : '-';
|
|
97
|
+
default: {
|
|
98
|
+
const v = value;
|
|
99
|
+
return v === '' ? '-' : v;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}, [input.type, value]);
|
|
103
|
+
const renderEditingInput = () => {
|
|
104
|
+
var _a;
|
|
105
|
+
if (editState !== 'editing')
|
|
106
|
+
return null;
|
|
107
|
+
switch (input.type) {
|
|
108
|
+
case 'text':
|
|
109
|
+
return (_jsx(Input, { ref: inputRef, value: draft, onChangeText: v => setDraft(v) }));
|
|
110
|
+
case 'location':
|
|
111
|
+
return (_jsx(Input, { ref: inputRef, value: draft, onChangeText: v => setDraft(v), iconLeft: "address" }));
|
|
112
|
+
case 'email':
|
|
113
|
+
return (_jsx(EmailInput, { ref: inputRef, value: draft, onChangeText: v => setDraft(v) }));
|
|
114
|
+
case 'textarea':
|
|
115
|
+
return (_jsx(TextareaInput, { ref: inputRef, value: draft, onChangeText: v => setDraft(v) }));
|
|
116
|
+
case 'number':
|
|
117
|
+
return (_jsx(NumberInput, { ref: inputRef, value: numericInputText, onChangeText: handleNumericChange }));
|
|
118
|
+
case 'currency':
|
|
119
|
+
return (_jsx(CurrencyInput, { ref: inputRef, value: numericInputText, onChangeText: handleNumericChange }));
|
|
120
|
+
case 'select': {
|
|
121
|
+
const selected = (_a = draft) !== null && _a !== void 0 ? _a : {
|
|
122
|
+
label: 'None',
|
|
123
|
+
value: 'default',
|
|
124
|
+
};
|
|
125
|
+
return (_jsx(SelectField, { ref: inputRef, label: "", options: input.options, onSelected: opt => setDraft(opt.value === 'default' ? null : opt), defaultSelected: selected }));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
return (_jsx(ActionListItemWrapper, { children: _jsxs(EditableListContainer, { children: [heading && (_jsx(P, { children: _jsx(Strong, { children: heading }) })), editState === 'initial' ? (_jsxs(InitialStateContainer, { children: [_jsx(ValueText, { children: displayValue }), _jsx(TextLink, { onPress: startEditing, children: _jsx(P, { size: "md", children: displayValue === '-' ? 'Add' : 'Change' }) })] })) : (_jsxs(_Fragment, { children: [renderEditingInput(), _jsx(Margin, { top: 2 }), _jsxs(EditButtonsContainer, { children: [_jsx(TextLink, { onPress: saveEditing, children: _jsx(P, { children: "Save" }) }), _jsx(TextLink, { onPress: cancelEditing, children: _jsx(P, { children: "Cancel" }) })] })] }))] }) }));
|
|
130
|
+
});
|
|
131
|
+
EditableListItem.displayName = 'EditableListItem';
|
|
@@ -0,0 +1,26 @@
|
|
|
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 { TouchableOpacity, View, } from 'react-native';
|
|
14
|
+
import { useTheme } from '../../../styled.native';
|
|
15
|
+
import { Icon } from '../../Icon';
|
|
16
|
+
import { P } from '../../P';
|
|
17
|
+
import { ActionListItemWrapper, SubHeading, TextContainer } from './styles';
|
|
18
|
+
export const NavigationListItem = (_a) => {
|
|
19
|
+
var { testID, iconLeft, iconRight, heading, subHeading, onPress, accessibilityRole, accessibilityLabel, accessibilityHint, activeOpacity = 0.75, disabled } = _a, touchableProps = __rest(_a, ["testID", "iconLeft", "iconRight", "heading", "subHeading", "onPress", "accessibilityRole", "accessibilityLabel", "accessibilityHint", "activeOpacity", "disabled"]);
|
|
20
|
+
const theme = useTheme();
|
|
21
|
+
const isPressable = !!onPress && !disabled;
|
|
22
|
+
const Wrapper = isPressable ? TouchableOpacity : View;
|
|
23
|
+
return (_jsx(Wrapper, Object.assign({ testID: testID }, (isPressable && Object.assign({ activeOpacity,
|
|
24
|
+
onPress,
|
|
25
|
+
disabled, accessible: true, accessibilityRole: accessibilityRole !== null && accessibilityRole !== void 0 ? accessibilityRole : 'button', accessibilityLabel: accessibilityLabel !== null && accessibilityLabel !== void 0 ? accessibilityLabel : heading, accessibilityHint }, touchableProps)), { children: _jsxs(ActionListItemWrapper, { children: [iconLeft && (_jsx(Icon, { name: iconLeft, size: 24, color: theme.color.brand.brand })), (heading || subHeading) && (_jsxs(TextContainer, { children: [heading && _jsx(P, { children: heading }), subHeading && _jsx(SubHeading, { size: "sm", children: subHeading })] })), iconRight && _jsx(Icon, { name: iconRight, size: 20 })] }) })));
|
|
26
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import Svg, { Circle } from 'react-native-svg';
|
|
4
|
+
import styled, { css, useTheme } from '../../../styled.native';
|
|
5
|
+
import { PROGESS_RING_INNER } from './styles';
|
|
6
|
+
const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
7
|
+
const Outer = styled(View)(({ outerSize }) => css `
|
|
8
|
+
width: ${outerSize}px;
|
|
9
|
+
height: ${outerSize}px;
|
|
10
|
+
position: relative;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
align-items: center;
|
|
13
|
+
`);
|
|
14
|
+
const RingSvg = styled(Svg) `
|
|
15
|
+
position: absolute;
|
|
16
|
+
top: 0;
|
|
17
|
+
left: 0;
|
|
18
|
+
`;
|
|
19
|
+
export const ProgressRing = ({ percentage, children, }) => {
|
|
20
|
+
const theme = useTheme();
|
|
21
|
+
const innerSize = PROGESS_RING_INNER;
|
|
22
|
+
const strokeWidth = 2;
|
|
23
|
+
const outerSize = innerSize + 2 * strokeWidth;
|
|
24
|
+
const pct = clamp(percentage, 0, 100);
|
|
25
|
+
const radius = (outerSize - strokeWidth) / 2;
|
|
26
|
+
const circumference = 2 * Math.PI * radius;
|
|
27
|
+
const dashOffset = circumference * (1 - pct / 100);
|
|
28
|
+
return (_jsxs(Outer, { outerSize: outerSize, children: [_jsxs(RingSvg, { width: outerSize, height: outerSize, viewBox: `0 0 ${outerSize} ${outerSize}`, children: [_jsx(Circle, { cx: outerSize / 2, cy: outerSize / 2, r: radius, stroke: theme.color.surface.border, strokeWidth: strokeWidth, fill: "none" }), _jsx(Circle, { cx: outerSize / 2, cy: outerSize / 2, r: radius, stroke: theme.color.brand.brand, strokeWidth: strokeWidth, fill: "none", strokeDasharray: `${circumference} ${circumference}`, strokeDashoffset: dashOffset, transform: `rotate(-90 ${outerSize / 2} ${outerSize / 2})` })] }), children] }));
|
|
29
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme } from '../../../styled.native';
|
|
3
|
+
import { P } from '../../P';
|
|
4
|
+
import { Toggle } from '../../Toggle';
|
|
5
|
+
import { ActionListItemWrapper } from './styles';
|
|
6
|
+
export const ToggleListItem = ({ testID, heading, hintText, checked, onToggle, }) => {
|
|
7
|
+
const theme = useTheme();
|
|
8
|
+
return (_jsx(ActionListItemWrapper, { testID: testID ? `${testID}-toggle` : undefined, children: _jsx(Toggle, { checked: checked, onPress: onToggle, accessibilityLabel: typeof heading === 'string' ? heading : undefined, label: _jsx(P, { children: heading }), hint: hintText, toggleBackgroundColor: theme.color.brand.brand }) }));
|
|
9
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { numToPx } from '@ovotech/element-core';
|
|
2
|
+
import { Image, ImageBackground, View } from 'react-native';
|
|
3
|
+
import styled, { css } from '../../../styled.native';
|
|
4
|
+
import { P } from '../../P';
|
|
5
|
+
export const ActionListItemWrapper = styled(View)(({ theme }) => {
|
|
6
|
+
return css `
|
|
7
|
+
flex-direction: row;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: space-between;
|
|
10
|
+
gap: ${numToPx(theme.space[300])};
|
|
11
|
+
padding: ${numToPx(theme.space[400])} 0;
|
|
12
|
+
`;
|
|
13
|
+
});
|
|
14
|
+
// Editable List Item
|
|
15
|
+
export const EditableListContainer = styled(View)(({ theme }) => {
|
|
16
|
+
return css `
|
|
17
|
+
flex: 1;
|
|
18
|
+
gap: ${numToPx(theme.space[100])};
|
|
19
|
+
`;
|
|
20
|
+
});
|
|
21
|
+
export const InitialStateContainer = styled(View)(() => {
|
|
22
|
+
return css `
|
|
23
|
+
flex-direction: row;
|
|
24
|
+
justify-content: space-between;
|
|
25
|
+
align-items: center;
|
|
26
|
+
`;
|
|
27
|
+
});
|
|
28
|
+
export const ValueText = styled(P)(({ theme }) => {
|
|
29
|
+
return css `
|
|
30
|
+
color: ${theme.color.surface.onSurfaceVariant};
|
|
31
|
+
`;
|
|
32
|
+
});
|
|
33
|
+
export const EditButtonsContainer = styled(View)(({ theme }) => {
|
|
34
|
+
return css `
|
|
35
|
+
gap: ${numToPx(theme.space[300])};
|
|
36
|
+
flex-direction: row;
|
|
37
|
+
justify-content: flex-end;
|
|
38
|
+
`;
|
|
39
|
+
});
|
|
40
|
+
// Navigation List Item
|
|
41
|
+
export const NavigationListContainer = styled(View)(({ theme }) => {
|
|
42
|
+
return css `
|
|
43
|
+
flex-direction: row;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: space-between;
|
|
46
|
+
gap: ${numToPx(theme.space[100])};
|
|
47
|
+
`;
|
|
48
|
+
});
|
|
49
|
+
export const TextContainer = styled(View)(() => {
|
|
50
|
+
return css `
|
|
51
|
+
flex: 1;
|
|
52
|
+
`;
|
|
53
|
+
});
|
|
54
|
+
export const SubHeading = styled(P)(({ theme }) => {
|
|
55
|
+
return css `
|
|
56
|
+
color: ${theme.color.alert.info};
|
|
57
|
+
`;
|
|
58
|
+
});
|
|
59
|
+
// Data List Item
|
|
60
|
+
export const LeftTextContainer = styled(View)(({ theme }) => {
|
|
61
|
+
return css `
|
|
62
|
+
flex: 1;
|
|
63
|
+
gap: ${numToPx(theme.space[100])};
|
|
64
|
+
`;
|
|
65
|
+
});
|
|
66
|
+
export const RightTextContainer = styled(View)(({ theme }) => {
|
|
67
|
+
return css `
|
|
68
|
+
flex: 1;
|
|
69
|
+
gap: ${numToPx(theme.space[100])};
|
|
70
|
+
align-items: flex-end;
|
|
71
|
+
`;
|
|
72
|
+
});
|
|
73
|
+
export const StyledImage = styled(Image)(() => {
|
|
74
|
+
return css `
|
|
75
|
+
width: 100%;
|
|
76
|
+
height: 100%;
|
|
77
|
+
`;
|
|
78
|
+
});
|
|
79
|
+
export const StatusText = styled(P)(({ theme, isError, }) => {
|
|
80
|
+
return css `
|
|
81
|
+
color: ${isError ? theme.color.alert.error : theme.color.alert.info};
|
|
82
|
+
`;
|
|
83
|
+
});
|
|
84
|
+
export const ValueTextContainer = styled(View)(({ theme }) => {
|
|
85
|
+
return css `
|
|
86
|
+
min-width: ${numToPx(theme.space[2400])};
|
|
87
|
+
align-items: flex-end;
|
|
88
|
+
`;
|
|
89
|
+
});
|
|
90
|
+
export const DataValueText = styled(P)(({ theme, isError, }) => {
|
|
91
|
+
return css `
|
|
92
|
+
color: ${isError ? theme.color.alert.error : theme.color.surface.onSurface};
|
|
93
|
+
`;
|
|
94
|
+
});
|
|
95
|
+
export const DirectionLabelContainer = styled(View)(({ theme }) => {
|
|
96
|
+
return css `
|
|
97
|
+
min-width: ${numToPx(theme.space[600])};
|
|
98
|
+
align-items: flex-end;
|
|
99
|
+
`;
|
|
100
|
+
});
|
|
101
|
+
export const OnSurfaceP = styled(P)(({ theme }) => {
|
|
102
|
+
return css `
|
|
103
|
+
color: ${theme.color.surface.onSurfaceVariant};
|
|
104
|
+
`;
|
|
105
|
+
});
|
|
106
|
+
export const DirectionAndValueTextContainer = styled(View)(({ theme }) => {
|
|
107
|
+
return css `
|
|
108
|
+
align-items: flex-end;
|
|
109
|
+
justify-content: space-between;
|
|
110
|
+
width: 100%;
|
|
111
|
+
flex-direction: row;
|
|
112
|
+
margin-left: ${numToPx(theme.space[300])};
|
|
113
|
+
`;
|
|
114
|
+
});
|
|
115
|
+
export const PROGESS_RING_INNER = 42;
|
|
116
|
+
export const GraphicContainer = styled(ImageBackground)(({ theme, isIcon, hasProgress }) => {
|
|
117
|
+
return css `
|
|
118
|
+
border-radius: ${numToPx(theme.border.radius['2xl'])};
|
|
119
|
+
background-color: ${hasProgress
|
|
120
|
+
? theme.color.surface.bright
|
|
121
|
+
: theme.color.surface.surface};
|
|
122
|
+
border-width: 0;
|
|
123
|
+
padding: ${isIcon ? numToPx(theme.space[200]) : 0};
|
|
124
|
+
width: ${hasProgress
|
|
125
|
+
? `${PROGESS_RING_INNER}px`
|
|
126
|
+
: numToPx(theme.space[1100])};
|
|
127
|
+
height: ${hasProgress
|
|
128
|
+
? `${PROGESS_RING_INNER}px`
|
|
129
|
+
: numToPx(theme.space[1100])};
|
|
130
|
+
flex-shrink: 0;
|
|
131
|
+
overflow: hidden;
|
|
132
|
+
align-items: center;
|
|
133
|
+
justify-content: center;
|
|
134
|
+
`;
|
|
135
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { Icon } from '../../Icon';
|
|
4
|
+
import { P } from '../../P';
|
|
5
|
+
import { Strong } from '../../Strong';
|
|
6
|
+
import { GraphicContainer, InfoRowWrapper } from '../styled';
|
|
7
|
+
export const ActionListHeading = ({ iconName, iconColor = 'surface.surface', heading, subheading, }) => (_jsxs(InfoRowWrapper, { children: [iconName && (_jsx(GraphicContainer, { children: _jsx(Icon, { name: iconName, size: 24, color: iconColor }) })), _jsxs(View, { children: [heading && (_jsx(P, { size: "xl", children: _jsx(Strong, { children: heading }) })), subheading && _jsx(P, { children: subheading })] })] }));
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
export { Action
|
|
1
|
+
export { Action } from './Action';
|
|
2
|
+
export { ActionList } from './ActionList';
|
|
3
|
+
export { DataListItem } from './ActionListItems/DataListItem';
|
|
4
|
+
export { EditableListItem } from './ActionListItems/EditableListItem';
|
|
5
|
+
export { NavigationListItem } from './ActionListItems/NavigationListItem';
|
|
6
|
+
export { ToggleListItem } from './ActionListItems/ToggleListItem';
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { numToPx } from '@ovotech/element-core';
|
|
2
2
|
import styled, { css } from '../../styled.native';
|
|
3
3
|
import { styledComponentWithBreakpoints } from '../../utils';
|
|
4
|
+
import { Card } from '../Card';
|
|
4
5
|
import { HintText } from '../HintText';
|
|
5
6
|
import { Icon } from '../Icon';
|
|
6
|
-
const StyledList = styled
|
|
7
|
+
const StyledList = styled(Card)(({ theme, smallAndUp, inverted }) => css `
|
|
7
8
|
flex-direction: column;
|
|
9
|
+
padding-top: ${numToPx(theme.space[0])};
|
|
10
|
+
padding-bottom: ${numToPx(theme.space[0])};
|
|
8
11
|
margin-top: ${numToPx(smallAndUp ? theme.space[300] : theme.space[200])};
|
|
9
12
|
margin-bottom: ${numToPx(smallAndUp ? theme.space[300] : theme.space[200])};
|
|
13
|
+
background-color: ${inverted && theme.color.neutral.black};
|
|
10
14
|
`);
|
|
11
15
|
export const StyledActionList = styledComponentWithBreakpoints(StyledList);
|
|
12
|
-
export const StyledActionWrapper = styled.View(({ theme
|
|
16
|
+
export const StyledActionWrapper = styled.View(({ theme }) => css `
|
|
13
17
|
width: 100%;
|
|
14
18
|
align-self: flex-start;
|
|
15
|
-
|
|
16
|
-
border-bottom-style: solid;
|
|
17
|
-
border-bottom-color: ${inverted
|
|
18
|
-
? theme.color.surface.dim
|
|
19
|
-
: theme.color.brand.fixed.onBrand};
|
|
20
|
-
padding: ${inList && (hint || badgeText) ? numToPx(theme.space[200]) : 0} 0;
|
|
19
|
+
padding: ${numToPx(theme.space[400])} 0 ${numToPx(theme.space[400])} 0;
|
|
21
20
|
`);
|
|
22
21
|
export const StyledActionInner = styled.View(({ fullWidth, standalone }) => css `
|
|
23
22
|
flex-direction: row;
|
|
@@ -72,3 +71,19 @@ export const StyledHintText = styled(HintText)(({ theme, inverted = false }) =>
|
|
|
72
71
|
: theme.color.surface.onSurfaceVariant};
|
|
73
72
|
`;
|
|
74
73
|
});
|
|
74
|
+
// Action List Heading
|
|
75
|
+
export const GraphicContainer = styled.View(({ theme }) => css `
|
|
76
|
+
width: ${numToPx(theme.unit[1100])};
|
|
77
|
+
height: ${numToPx(theme.unit[1100])};
|
|
78
|
+
background-color: ${theme.color.surface.bright};
|
|
79
|
+
display: flex;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
align-items: center;
|
|
82
|
+
border-radius: ${numToPx(theme.border.radius['2xl'])};
|
|
83
|
+
padding: ${numToPx(theme.space[200])};
|
|
84
|
+
`);
|
|
85
|
+
export const InfoRowWrapper = styled.View(({ theme }) => css `
|
|
86
|
+
flex-direction: row;
|
|
87
|
+
align-items: center;
|
|
88
|
+
gap: ${numToPx(theme.space[300])};
|
|
89
|
+
`);
|
|
@@ -11,17 +11,26 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { useEffect, useRef, useState } from 'react';
|
|
14
|
-
import { Animated } from 'react-native';
|
|
14
|
+
import { Animated, Pressable, View, } from 'react-native';
|
|
15
15
|
import { useBreakpoint } from '../../hooks';
|
|
16
16
|
import { useTheme } from '../../styled.native';
|
|
17
17
|
import { AnimatedStyledCard, BackgroundImage, TappableWrapper, } from './Card.styles';
|
|
18
18
|
export const getCardFlags = (props) => {
|
|
19
|
-
const { background, onPress, displayStyle } = props;
|
|
20
|
-
const
|
|
21
|
-
const
|
|
19
|
+
const { background, onPress, onSelect, displayStyle } = props;
|
|
20
|
+
const hasBackground = !!background;
|
|
21
|
+
const hasBgImage = hasBackground && typeof background !== 'string';
|
|
22
|
+
const selectable = Boolean(onSelect) && !onPress;
|
|
23
|
+
const pressable = Boolean(onPress) && !onSelect;
|
|
22
24
|
const isDefault = displayStyle === 'default';
|
|
23
25
|
const isOutline = displayStyle === 'outline';
|
|
24
|
-
return {
|
|
26
|
+
return {
|
|
27
|
+
hasBackground,
|
|
28
|
+
hasBgImage,
|
|
29
|
+
pressable,
|
|
30
|
+
selectable,
|
|
31
|
+
isDefault,
|
|
32
|
+
isOutline,
|
|
33
|
+
};
|
|
25
34
|
};
|
|
26
35
|
function useAnimatedBorder(baseColor, selectedColor, isSelected, duration) {
|
|
27
36
|
const borderAnim = useRef(new Animated.Value(0)).current;
|
|
@@ -31,45 +40,58 @@ function useAnimatedBorder(baseColor, selectedColor, isSelected, duration) {
|
|
|
31
40
|
duration,
|
|
32
41
|
useNativeDriver: false,
|
|
33
42
|
}).start();
|
|
34
|
-
}, [isSelected, duration]);
|
|
43
|
+
}, [isSelected, duration, borderAnim]);
|
|
35
44
|
return borderAnim.interpolate({
|
|
36
45
|
inputRange: [0, 1],
|
|
37
46
|
outputRange: [baseColor, selectedColor],
|
|
38
47
|
});
|
|
39
48
|
}
|
|
40
49
|
export const Card = (_a) => {
|
|
41
|
-
var { children, displayStyle = 'default', background, onPress } = _a, rest = __rest(_a, ["children", "displayStyle", "background", "onPress"]);
|
|
50
|
+
var { children, displayStyle = 'default', background, onPress, onSelect } = _a, rest = __rest(_a, ["children", "displayStyle", "background", "onPress", "onSelect"]);
|
|
42
51
|
const theme = useTheme();
|
|
43
52
|
const [isFocused, setFocused] = useState(false);
|
|
44
53
|
const [isSelected, setSelected] = useState(false);
|
|
45
54
|
const { largeAndUp } = useBreakpoint();
|
|
46
|
-
const { hasBgImage,
|
|
55
|
+
const { hasBackground, hasBgImage, pressable, selectable, isDefault, isOutline, } = getCardFlags({
|
|
47
56
|
background,
|
|
48
57
|
onPress,
|
|
49
58
|
displayStyle,
|
|
59
|
+
onSelect,
|
|
50
60
|
});
|
|
51
61
|
let baseBorderColor = theme.color.surface.bright;
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
else if (isDefault) {
|
|
56
|
-
if (hasBgImage)
|
|
62
|
+
if (isDefault) {
|
|
63
|
+
if (hasBgImage) {
|
|
57
64
|
baseBorderColor = 'transparent';
|
|
58
|
-
|
|
65
|
+
}
|
|
66
|
+
else if (typeof background === 'string') {
|
|
59
67
|
baseBorderColor = background;
|
|
60
|
-
|
|
61
|
-
baseBorderColor = theme.color.surface.bright;
|
|
68
|
+
}
|
|
62
69
|
}
|
|
63
70
|
const selectedBorderColor = theme.color.surface.onSurface;
|
|
64
|
-
const
|
|
71
|
+
const shouldHideBorder = hasBackground && !isOutline && !pressable && !selectable;
|
|
72
|
+
const animatedBorderColor = useAnimatedBorder(baseBorderColor, selectedBorderColor, selectable && isSelected, theme.transition.duration.fast);
|
|
65
73
|
const handlePress = () => {
|
|
66
|
-
setSelected(prev => !prev);
|
|
67
74
|
onPress === null || onPress === void 0 ? void 0 : onPress();
|
|
68
75
|
};
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
const handleSelect = () => {
|
|
77
|
+
setSelected(prev => !prev);
|
|
78
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect();
|
|
79
|
+
};
|
|
80
|
+
const CardContent = (_jsxs(AnimatedStyledCard, Object.assign({ displayStyle: displayStyle, background: background, largeAndUp: largeAndUp, onPress: onPress, onSelect: onSelect }, rest, { style: [
|
|
81
|
+
{
|
|
82
|
+
borderWidth: shouldHideBorder ? 0 : theme.border.width.md,
|
|
83
|
+
borderColor: animatedBorderColor,
|
|
84
|
+
},
|
|
85
|
+
rest === null || rest === void 0 ? void 0 : rest.style,
|
|
86
|
+
], children: [hasBgImage && (_jsx(BackgroundImage, { source: background, resizeMode: "cover", largeAndUp: largeAndUp })), children] })));
|
|
87
|
+
const isInteractive = pressable || selectable;
|
|
88
|
+
return (_jsx(TappableWrapper, Object.assign({ as: isInteractive ? Pressable : View, largeAndUp: largeAndUp, tappable: isInteractive, focused: isInteractive ? isFocused : false }, (isInteractive && {
|
|
89
|
+
onPress: pressable ? handlePress : handleSelect,
|
|
90
|
+
onFocus: () => setFocused(true),
|
|
91
|
+
onBlur: () => setFocused(false),
|
|
92
|
+
accessibilityRole: 'button',
|
|
93
|
+
style: ({ pressed }) => ({
|
|
73
94
|
opacity: pressed ? 0.9 : 1,
|
|
74
|
-
}),
|
|
95
|
+
}),
|
|
96
|
+
}), { children: CardContent })));
|
|
75
97
|
};
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { Animated, ImageBackground,
|
|
1
|
+
import { Animated, ImageBackground, View } from 'react-native';
|
|
2
2
|
import styled from '../../styled.native';
|
|
3
3
|
import { styledComponentWithBreakpoints } from '../../utils';
|
|
4
4
|
import { getCardFlags } from './Card';
|
|
5
|
-
const StyledCardBase = styled(View)(({ theme, displayStyle, background, onPress, largeAndUp, size, }) => {
|
|
6
|
-
const { hasBgImage,
|
|
5
|
+
const StyledCardBase = styled(View)(({ theme, displayStyle, background, onPress, onSelect, largeAndUp, size, }) => {
|
|
6
|
+
const { hasBgImage, pressable, selectable, isDefault } = getCardFlags({
|
|
7
7
|
background,
|
|
8
8
|
onPress,
|
|
9
|
+
onSelect,
|
|
9
10
|
displayStyle,
|
|
10
11
|
});
|
|
11
12
|
const backgroundColor = hasBgImage
|
|
12
13
|
? 'transparent'
|
|
13
14
|
: typeof background === 'string'
|
|
14
15
|
? background
|
|
15
|
-
: isDefault ||
|
|
16
|
+
: isDefault || pressable || selectable
|
|
16
17
|
? theme.color.surface.bright
|
|
17
18
|
: 'transparent';
|
|
18
|
-
return Object.assign(Object.assign({}, (size || {})), { padding: theme.space[400], position: 'relative',
|
|
19
|
+
return Object.assign(Object.assign({}, (size || {})), { padding: theme.space[400], position: 'relative', borderStyle: 'solid', borderRadius: theme.border.radius[largeAndUp ? '2xl' : 'lg'], overflow: 'hidden', backgroundColor });
|
|
19
20
|
});
|
|
20
21
|
const CardBase = styledComponentWithBreakpoints(StyledCardBase);
|
|
21
22
|
export const AnimatedStyledCard = Animated.createAnimatedComponent(CardBase);
|
|
@@ -28,15 +29,10 @@ export const BackgroundImage = styled(ImageBackground)(({ theme, largeAndUp }) =
|
|
|
28
29
|
borderRadius: theme.border.radius[largeAndUp ? '2xl' : 'lg'],
|
|
29
30
|
overflow: 'hidden',
|
|
30
31
|
}));
|
|
31
|
-
export const TappableWrapper = styled(
|
|
32
|
-
backgroundColor: 'transparent',
|
|
33
|
-
borderColor: focused ? theme.color.outline.outer : 'transparent',
|
|
34
|
-
borderWidth: theme.border.width.md,
|
|
35
|
-
borderRadius: largeAndUp ? 26 : theme.border.radius.xl,
|
|
36
|
-
padding: theme.space[50],
|
|
32
|
+
export const TappableWrapper = styled(View)(({ theme, focused, tappable, largeAndUp }) => (Object.assign(Object.assign({}, (tappable && {
|
|
37
33
|
shadowColor: '#000',
|
|
38
34
|
shadowOffset: { width: 0, height: theme.space[100] },
|
|
39
35
|
shadowOpacity: 0.1,
|
|
40
36
|
shadowRadius: theme.space[250],
|
|
41
37
|
elevation: theme.space[150],
|
|
42
|
-
}));
|
|
38
|
+
})), { backgroundColor: 'transparent', borderColor: focused ? theme.color.outline.outer : 'transparent', borderWidth: theme.border.width.md, borderRadius: largeAndUp ? 26 : theme.border.radius.xl, padding: theme.space[50] })));
|
|
@@ -70,10 +70,10 @@ export const CreditContainer = styled(View)(({ theme }) => ({
|
|
|
70
70
|
paddingBottom: theme.space[200],
|
|
71
71
|
}));
|
|
72
72
|
export const StyledDisplay4 = styled(Display4)(({ theme }) => ({
|
|
73
|
-
lineHeight: theme.font.lineHeight.d3.mediaQuery.sm
|
|
73
|
+
lineHeight: `${theme.font.lineHeight.d3.mediaQuery.sm}px`,
|
|
74
74
|
}));
|
|
75
75
|
export const StyledHeading1 = styled(Heading1)(({ theme }) => ({
|
|
76
|
-
lineHeight: theme.font.lineHeight.d4.mediaQuery.sm
|
|
76
|
+
lineHeight: `${theme.font.lineHeight.d4.mediaQuery.sm}px`,
|
|
77
77
|
}));
|
|
78
78
|
export const ErrorContainer = styled(View)(({ theme }) => ({
|
|
79
79
|
flexDirection: 'column',
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { Heading2, Heading3, Icon, P, Stack } from '../..';
|
|
4
|
+
import { useTheme } from '../../../styled.native';
|
|
5
|
+
import { checkIsSmall } from '../utils';
|
|
6
|
+
import { CardDisruptive } from './DisruptiveCard.styles';
|
|
7
|
+
const CARD_ICONS = {
|
|
8
|
+
success: 'check-circle',
|
|
9
|
+
info: 'info',
|
|
10
|
+
warning: 'info',
|
|
11
|
+
};
|
|
12
|
+
const getVariantStyles = (variant, theme) => {
|
|
13
|
+
switch (variant) {
|
|
14
|
+
case 'success':
|
|
15
|
+
return {
|
|
16
|
+
iconTextColor: theme.color.alert.success,
|
|
17
|
+
background: theme.color.brand.bright,
|
|
18
|
+
};
|
|
19
|
+
case 'info':
|
|
20
|
+
return {
|
|
21
|
+
iconTextColor: theme.color.alert.info,
|
|
22
|
+
background: theme.color.alert.infoTint,
|
|
23
|
+
};
|
|
24
|
+
case 'warning':
|
|
25
|
+
default:
|
|
26
|
+
return {
|
|
27
|
+
iconTextColor: theme.color.alert.warning,
|
|
28
|
+
background: theme.color.alert.warningTint,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const DisruptiveHeading = ({ heading, size = 'default', color, }) => {
|
|
33
|
+
const HeadingComponent = checkIsSmall(size) ? Heading3 : Heading2;
|
|
34
|
+
const headingStyle = useMemo(() => ({ color }), [color]);
|
|
35
|
+
return _jsx(HeadingComponent, { style: headingStyle, children: heading });
|
|
36
|
+
};
|
|
37
|
+
export const DisruptiveCard = ({ variant = 'success', icon, heading, subHeading, size = 'default', }) => {
|
|
38
|
+
const theme = useTheme();
|
|
39
|
+
const { iconTextColor, background } = getVariantStyles(variant, theme);
|
|
40
|
+
return (_jsx(CardDisruptive, { background: background, isSmall: true, children: _jsxs(Stack, { spaceBetween: 1, children: [_jsx(Icon, { name: icon !== null && icon !== void 0 ? icon : CARD_ICONS[variant], size: 32, color: iconTextColor }), _jsx(DisruptiveHeading, { color: iconTextColor, heading: heading, size: size }), subHeading && !checkIsSmall(size) && (_jsx(P, { style: { color: iconTextColor }, children: subHeading }))] }) }));
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DisruptiveCard';
|