@ledgerhq/lumen-ui-rnative 0.1.10 → 0.1.12
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/module/i18n/locales/de.json +3 -0
- package/dist/module/i18n/locales/en.json +3 -0
- package/dist/module/i18n/locales/es.json +3 -0
- package/dist/module/i18n/locales/fr.json +3 -0
- package/dist/module/i18n/locales/ja.json +3 -0
- package/dist/module/i18n/locales/ko.json +3 -0
- package/dist/module/i18n/locales/pt.json +3 -0
- package/dist/module/i18n/locales/ru.json +3 -0
- package/dist/module/i18n/locales/th.json +3 -0
- package/dist/module/i18n/locales/tr.json +3 -0
- package/dist/module/i18n/locales/zh.json +3 -0
- package/dist/module/lib/Animations/Pulse/Pulse.js +1 -1
- package/dist/module/lib/Animations/Spin/Spin.js +1 -1
- package/dist/module/lib/Components/AmountDisplay/AmountDisplay.js +21 -21
- package/dist/module/lib/Components/AmountDisplay/AmountDisplay.js.map +1 -1
- package/dist/module/lib/Components/AmountInput/AmountInput.js +19 -13
- package/dist/module/lib/Components/AmountInput/AmountInput.js.map +1 -1
- package/dist/module/lib/Components/BaseInput/BaseInput.js +16 -9
- package/dist/module/lib/Components/BaseInput/BaseInput.js.map +1 -1
- package/dist/module/lib/Components/BottomSheet/BottomSheet.stories.js.map +1 -1
- package/dist/module/lib/Components/Button/BaseButton.js +8 -1
- package/dist/module/lib/Components/Button/BaseButton.js.map +1 -1
- package/dist/module/lib/Components/Card/Card.js +20 -14
- package/dist/module/lib/Components/Card/Card.js.map +1 -1
- package/dist/module/lib/Components/CardButton/CardButton.js +8 -1
- package/dist/module/lib/Components/CardButton/CardButton.js.map +1 -1
- package/dist/module/lib/Components/Checkbox/Checkbox.js +8 -1
- package/dist/module/lib/Components/Checkbox/Checkbox.js.map +1 -1
- package/dist/module/lib/Components/InteractiveIcon/InteractiveIcon.js +32 -5
- package/dist/module/lib/Components/InteractiveIcon/InteractiveIcon.js.map +1 -1
- package/dist/module/lib/Components/Label/Label.js +9 -2
- package/dist/module/lib/Components/Label/Label.js.map +1 -1
- package/dist/module/lib/Components/Link/Link.mdx +1 -0
- package/dist/module/lib/Components/ListItem/ListItem.js +14 -19
- package/dist/module/lib/Components/ListItem/ListItem.js.map +1 -1
- package/dist/module/lib/Components/MediaCard/MediaCard.js +183 -0
- package/dist/module/lib/Components/MediaCard/MediaCard.js.map +1 -0
- package/dist/module/lib/Components/MediaCard/MediaCard.mdx +111 -0
- package/dist/module/lib/Components/MediaCard/MediaCard.stories.js +199 -0
- package/dist/module/lib/Components/MediaCard/MediaCard.stories.js.map +1 -0
- package/dist/module/lib/Components/MediaCard/MediaCard.test.js +140 -0
- package/dist/module/lib/Components/MediaCard/MediaCard.test.js.map +1 -0
- package/dist/module/lib/Components/MediaCard/index.js +5 -0
- package/dist/module/lib/Components/MediaCard/index.js.map +1 -0
- package/dist/module/lib/Components/MediaCard/types.js +4 -0
- package/dist/module/lib/Components/MediaCard/types.js.map +1 -0
- package/dist/module/lib/Components/PageIndicator/PageIndicator.js +2 -2
- package/dist/module/lib/Components/SegmentedControl/SegmentedControl.js +8 -1
- package/dist/module/lib/Components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/module/lib/Components/SegmentedControl/usePillLayout.js +1 -1
- package/dist/module/lib/Components/Select/Select.js +8 -1
- package/dist/module/lib/Components/Select/Select.js.map +1 -1
- package/dist/module/lib/Components/Spot/Spot.js +4 -4
- package/dist/module/lib/Components/Spot/Spot.js.map +1 -1
- package/dist/module/lib/Components/Stepper/Stepper.js +10 -4
- package/dist/module/lib/Components/Stepper/Stepper.js.map +1 -1
- package/dist/module/lib/Components/Subheader/Subheader.js +1 -34
- package/dist/module/lib/Components/Subheader/Subheader.js.map +1 -1
- package/dist/module/lib/Components/Subheader/Subheader.mdx +26 -61
- package/dist/module/lib/Components/Subheader/Subheader.stories.js +23 -12
- package/dist/module/lib/Components/Subheader/Subheader.stories.js.map +1 -1
- package/dist/module/lib/Components/Subheader/Subheader.test.js +2 -26
- package/dist/module/lib/Components/Subheader/Subheader.test.js.map +1 -1
- package/dist/module/lib/Components/Subheader/index.js +1 -1
- package/dist/module/lib/Components/Subheader/index.js.map +1 -1
- package/dist/module/lib/Components/Switch/BaseSwitch.js +1 -1
- package/dist/module/lib/Components/Switch/Switch.js +8 -1
- package/dist/module/lib/Components/Switch/Switch.js.map +1 -1
- package/dist/module/lib/Components/TabBar/TabBar.js +8 -7
- package/dist/module/lib/Components/TabBar/TabBar.js.map +1 -1
- package/dist/module/lib/Components/Tag/Tag.js +9 -2
- package/dist/module/lib/Components/Tag/Tag.js.map +1 -1
- package/dist/module/lib/Components/ThemeProvider/ThemeProvider.test.js +22 -20
- package/dist/module/lib/Components/ThemeProvider/ThemeProvider.test.js.map +1 -1
- package/dist/module/lib/Components/Tile/Tile.js +27 -48
- package/dist/module/lib/Components/Tile/Tile.js.map +1 -1
- package/dist/module/lib/Components/Tile/Tile.mdx +34 -26
- package/dist/module/lib/Components/Tile/Tile.stories.js +31 -28
- package/dist/module/lib/Components/Tile/Tile.stories.js.map +1 -1
- package/dist/module/lib/Components/Tile/Tile.test.js +33 -188
- package/dist/module/lib/Components/Tile/Tile.test.js.map +1 -1
- package/dist/module/lib/Components/Tile/index.js +1 -1
- package/dist/module/lib/Components/Tile/index.js.map +1 -1
- package/dist/module/lib/Components/TileButton/TileButton.js +8 -2
- package/dist/module/lib/Components/TileButton/TileButton.js.map +1 -1
- package/dist/module/lib/Components/TriggerButton/TriggerButton.js +197 -0
- package/dist/module/lib/Components/TriggerButton/TriggerButton.js.map +1 -0
- package/dist/module/lib/Components/TriggerButton/TriggerButton.mdx +44 -0
- package/dist/module/lib/Components/TriggerButton/TriggerButton.stories.js +170 -0
- package/dist/module/lib/Components/TriggerButton/TriggerButton.stories.js.map +1 -0
- package/dist/module/lib/Components/TriggerButton/TriggerButton.test.js +146 -0
- package/dist/module/lib/Components/TriggerButton/TriggerButton.test.js.map +1 -0
- package/dist/module/lib/Components/TriggerButton/index.js +5 -0
- package/dist/module/lib/Components/TriggerButton/index.js.map +1 -0
- package/dist/module/lib/Components/TriggerButton/types.js +4 -0
- package/dist/module/lib/Components/TriggerButton/types.js.map +1 -0
- package/dist/module/lib/Components/Utility/Gradient/RadialGradient/RadialGradient.stories.js.map +1 -1
- package/dist/module/lib/Components/index.js +2 -0
- package/dist/module/lib/Components/index.js.map +1 -1
- package/dist/module/lib/Symbols/Icons/NanoGen5.js +49 -0
- package/dist/module/lib/Symbols/Icons/NanoGen5.js.map +1 -0
- package/dist/module/lib/Symbols/index.js +1 -0
- package/dist/module/lib/Symbols/index.js.map +1 -1
- package/dist/typescript/src/lib/Components/AmountInput/AmountInput.d.ts +1 -1
- package/dist/typescript/src/lib/Components/AmountInput/AmountInput.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/BaseInput/BaseInput.d.ts +1 -1
- package/dist/typescript/src/lib/Components/BaseInput/BaseInput.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Button/BaseButton.d.ts +1 -1
- package/dist/typescript/src/lib/Components/Button/BaseButton.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Card/Card.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Card/types.d.ts +1 -3
- package/dist/typescript/src/lib/Components/Card/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/CardButton/CardButton.d.ts +1 -1
- package/dist/typescript/src/lib/Components/CardButton/CardButton.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/typescript/src/lib/Components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/InteractiveIcon/InteractiveIcon.d.ts +1 -1
- package/dist/typescript/src/lib/Components/InteractiveIcon/InteractiveIcon.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/InteractiveIcon/types.d.ts +14 -1
- package/dist/typescript/src/lib/Components/InteractiveIcon/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Label/Label.d.ts +1 -1
- package/dist/typescript/src/lib/Components/Label/Label.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/ListItem/ListItem.d.ts +1 -1
- package/dist/typescript/src/lib/Components/ListItem/ListItem.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/MediaCard/MediaCard.d.ts +32 -0
- package/dist/typescript/src/lib/Components/MediaCard/MediaCard.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/MediaCard/index.d.ts +3 -0
- package/dist/typescript/src/lib/Components/MediaCard/index.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/MediaCard/types.d.ts +38 -0
- package/dist/typescript/src/lib/Components/MediaCard/types.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/SegmentedControl/SegmentedControl.d.ts +1 -1
- package/dist/typescript/src/lib/Components/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/SegmentedControl/SegmentedControlContext.d.ts +1 -1
- package/dist/typescript/src/lib/Components/SegmentedControl/SegmentedControlContext.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Select/Select.d.ts +1 -1
- package/dist/typescript/src/lib/Components/Select/Select.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Stepper/Stepper.d.ts +1 -1
- package/dist/typescript/src/lib/Components/Stepper/Stepper.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Subheader/Subheader.d.ts +2 -7
- package/dist/typescript/src/lib/Components/Subheader/Subheader.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Subheader/index.d.ts +1 -1
- package/dist/typescript/src/lib/Components/Subheader/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Subheader/types.d.ts +1 -11
- package/dist/typescript/src/lib/Components/Subheader/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Switch/Switch.d.ts +1 -1
- package/dist/typescript/src/lib/Components/Switch/Switch.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/TabBar/TabBar.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Tag/Tag.d.ts +1 -1
- package/dist/typescript/src/lib/Components/Tag/Tag.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Tile/Tile.d.ts +17 -23
- package/dist/typescript/src/lib/Components/Tile/Tile.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Tile/index.d.ts +1 -1
- package/dist/typescript/src/lib/Components/Tile/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Tile/types.d.ts +0 -9
- package/dist/typescript/src/lib/Components/Tile/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/TileButton/TileButton.d.ts +1 -1
- package/dist/typescript/src/lib/Components/TileButton/TileButton.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/TriggerButton/TriggerButton.d.ts +26 -0
- package/dist/typescript/src/lib/Components/TriggerButton/TriggerButton.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/TriggerButton/index.d.ts +3 -0
- package/dist/typescript/src/lib/Components/TriggerButton/index.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/TriggerButton/types.d.ts +38 -0
- package/dist/typescript/src/lib/Components/TriggerButton/types.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/index.d.ts +2 -0
- package/dist/typescript/src/lib/Components/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Symbols/Icons/NanoGen5.d.ts +35 -0
- package/dist/typescript/src/lib/Symbols/Icons/NanoGen5.d.ts.map +1 -0
- package/dist/typescript/src/lib/Symbols/index.d.ts +1 -0
- package/dist/typescript/src/lib/Symbols/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/i18n/locales/de.json +3 -0
- package/src/i18n/locales/en.json +3 -0
- package/src/i18n/locales/es.json +3 -0
- package/src/i18n/locales/fr.json +3 -0
- package/src/i18n/locales/ja.json +3 -0
- package/src/i18n/locales/ko.json +3 -0
- package/src/i18n/locales/pt.json +3 -0
- package/src/i18n/locales/ru.json +3 -0
- package/src/i18n/locales/th.json +3 -0
- package/src/i18n/locales/tr.json +3 -0
- package/src/i18n/locales/zh.json +3 -0
- package/src/lib/Components/AmountDisplay/AmountDisplay.tsx +20 -20
- package/src/lib/Components/AmountInput/AmountInput.tsx +15 -7
- package/src/lib/Components/BaseInput/BaseInput.tsx +12 -7
- package/src/lib/Components/BottomSheet/BottomSheet.stories.tsx +9 -9
- package/src/lib/Components/Button/BaseButton.tsx +6 -1
- package/src/lib/Components/Card/Card.tsx +16 -16
- package/src/lib/Components/Card/types.ts +1 -4
- package/src/lib/Components/CardButton/CardButton.tsx +7 -1
- package/src/lib/Components/Checkbox/Checkbox.tsx +7 -1
- package/src/lib/Components/InteractiveIcon/InteractiveIcon.tsx +34 -7
- package/src/lib/Components/InteractiveIcon/types.ts +14 -1
- package/src/lib/Components/Label/Label.tsx +7 -2
- package/src/lib/Components/Link/Link.mdx +1 -0
- package/src/lib/Components/ListItem/ListItem.tsx +15 -12
- package/src/lib/Components/MediaCard/MediaCard.mdx +111 -0
- package/src/lib/Components/MediaCard/MediaCard.stories.tsx +190 -0
- package/src/lib/Components/MediaCard/MediaCard.test.tsx +125 -0
- package/src/lib/Components/MediaCard/MediaCard.tsx +203 -0
- package/src/lib/Components/MediaCard/index.ts +2 -0
- package/src/lib/Components/MediaCard/types.ts +39 -0
- package/src/lib/Components/SegmentedControl/SegmentedControl.tsx +6 -1
- package/src/lib/Components/SegmentedControl/SegmentedControlContext.tsx +1 -1
- package/src/lib/Components/Select/Select.tsx +6 -1
- package/src/lib/Components/Spot/Spot.tsx +4 -4
- package/src/lib/Components/Stepper/Stepper.tsx +9 -2
- package/src/lib/Components/Subheader/Subheader.mdx +26 -61
- package/src/lib/Components/Subheader/Subheader.stories.tsx +16 -10
- package/src/lib/Components/Subheader/Subheader.test.tsx +0 -22
- package/src/lib/Components/Subheader/Subheader.tsx +1 -42
- package/src/lib/Components/Subheader/index.ts +0 -1
- package/src/lib/Components/Subheader/types.ts +1 -16
- package/src/lib/Components/Switch/Switch.tsx +6 -1
- package/src/lib/Components/TabBar/TabBar.tsx +5 -2
- package/src/lib/Components/Tag/Tag.tsx +7 -2
- package/src/lib/Components/ThemeProvider/ThemeProvider.test.tsx +16 -18
- package/src/lib/Components/Tile/Tile.mdx +34 -26
- package/src/lib/Components/Tile/Tile.stories.tsx +26 -26
- package/src/lib/Components/Tile/Tile.test.tsx +17 -137
- package/src/lib/Components/Tile/Tile.tsx +28 -40
- package/src/lib/Components/Tile/index.ts +0 -1
- package/src/lib/Components/Tile/types.ts +0 -11
- package/src/lib/Components/TileButton/TileButton.tsx +9 -2
- package/src/lib/Components/TriggerButton/TriggerButton.mdx +44 -0
- package/src/lib/Components/TriggerButton/TriggerButton.stories.tsx +132 -0
- package/src/lib/Components/TriggerButton/TriggerButton.test.tsx +157 -0
- package/src/lib/Components/TriggerButton/TriggerButton.tsx +228 -0
- package/src/lib/Components/TriggerButton/index.ts +2 -0
- package/src/lib/Components/TriggerButton/types.ts +38 -0
- package/src/lib/Components/Utility/Gradient/RadialGradient/RadialGradient.stories.tsx +1 -1
- package/src/lib/Components/index.ts +2 -0
- package/src/lib/Symbols/Icons/NanoGen5.tsx +44 -0
- package/src/lib/Symbols/index.ts +1 -0
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getFontSize,
|
|
3
|
+
textFormatter,
|
|
4
|
+
useDisabledContext,
|
|
5
|
+
} from '@ledgerhq/lumen-utils-shared';
|
|
2
6
|
import { useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
3
7
|
import { Pressable, StyleSheet, TextInput } from 'react-native';
|
|
4
8
|
import Animated, {
|
|
@@ -23,7 +27,7 @@ export const AmountInput = ({
|
|
|
23
27
|
style,
|
|
24
28
|
currencyText,
|
|
25
29
|
currencyPosition = 'left',
|
|
26
|
-
editable = true,
|
|
30
|
+
editable: editableProp = true,
|
|
27
31
|
maxIntegerLength = 9,
|
|
28
32
|
maxDecimalLength = 9,
|
|
29
33
|
allowDecimals = true,
|
|
@@ -37,6 +41,10 @@ export const AmountInput = ({
|
|
|
37
41
|
const inputRef = useRef<TextInput>(null);
|
|
38
42
|
const inputValue = String(value);
|
|
39
43
|
const [isFocused, setIsFocused] = useState(false);
|
|
44
|
+
const disabled = useDisabledContext({
|
|
45
|
+
consumerName: 'AmountInput',
|
|
46
|
+
mergeWith: { disabled: !editableProp },
|
|
47
|
+
});
|
|
40
48
|
|
|
41
49
|
const translateX = useSharedValue(0);
|
|
42
50
|
const animatedFontSize = useSharedValue(getFontSize(inputValue));
|
|
@@ -46,7 +54,7 @@ export const AmountInput = ({
|
|
|
46
54
|
|
|
47
55
|
const styles = useStyles({
|
|
48
56
|
hasValue: !!inputValue,
|
|
49
|
-
isEditable:
|
|
57
|
+
isEditable: !disabled,
|
|
50
58
|
isInvalid,
|
|
51
59
|
});
|
|
52
60
|
|
|
@@ -93,7 +101,7 @@ export const AmountInput = ({
|
|
|
93
101
|
}, [inputValue, animatedFontSize, translateX]);
|
|
94
102
|
|
|
95
103
|
useEffect(() => {
|
|
96
|
-
if (isFocused &&
|
|
104
|
+
if (isFocused && !disabled) {
|
|
97
105
|
caretOpacity.value = withRepeat(
|
|
98
106
|
withSequence(
|
|
99
107
|
withTiming(1, { duration: 150, easing: Easing.ease }),
|
|
@@ -107,7 +115,7 @@ export const AmountInput = ({
|
|
|
107
115
|
} else {
|
|
108
116
|
caretOpacity.value = 0;
|
|
109
117
|
}
|
|
110
|
-
}, [isFocused,
|
|
118
|
+
}, [isFocused, disabled, caretOpacity]);
|
|
111
119
|
|
|
112
120
|
const handleChangeText = (text: string) => {
|
|
113
121
|
const formatted = textFormatter(text, {
|
|
@@ -127,7 +135,7 @@ export const AmountInput = ({
|
|
|
127
135
|
) : null;
|
|
128
136
|
|
|
129
137
|
const handlePress = () => {
|
|
130
|
-
if (
|
|
138
|
+
if (!disabled) {
|
|
131
139
|
inputRef.current?.focus();
|
|
132
140
|
}
|
|
133
141
|
};
|
|
@@ -138,7 +146,7 @@ export const AmountInput = ({
|
|
|
138
146
|
<TextInput
|
|
139
147
|
ref={inputRef}
|
|
140
148
|
keyboardType='decimal-pad'
|
|
141
|
-
editable={
|
|
149
|
+
editable={!disabled}
|
|
142
150
|
value={inputValue}
|
|
143
151
|
onChangeText={handleChangeText}
|
|
144
152
|
onFocus={(e) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useDisabledContext } from '@ledgerhq/lumen-utils-shared';
|
|
1
2
|
import {
|
|
2
3
|
useCallback,
|
|
3
4
|
useEffect,
|
|
@@ -32,12 +33,16 @@ export const BaseInput = ({
|
|
|
32
33
|
errorMessage,
|
|
33
34
|
hideClearButton,
|
|
34
35
|
onChangeText: onChangeTextProp,
|
|
35
|
-
editable = true,
|
|
36
|
+
editable: editableProp = true,
|
|
36
37
|
prefix,
|
|
37
38
|
suffix,
|
|
38
39
|
ref,
|
|
39
40
|
...props
|
|
40
41
|
}: BaseInputProps) => {
|
|
42
|
+
const disabled = useDisabledContext({
|
|
43
|
+
consumerName: 'BaseInput',
|
|
44
|
+
mergeWith: { disabled: !editableProp },
|
|
45
|
+
});
|
|
41
46
|
const { t } = useCommonTranslation();
|
|
42
47
|
const { theme } = useTheme();
|
|
43
48
|
const inputRef = useRef<TextInput>(null);
|
|
@@ -55,7 +60,7 @@ export const BaseInput = ({
|
|
|
55
60
|
? !!props.value && props.value.length > 0
|
|
56
61
|
: uncontrolledValue.length > 0;
|
|
57
62
|
|
|
58
|
-
const showClearButton = hasContent &&
|
|
63
|
+
const showClearButton = hasContent && !disabled && !hideClearButton;
|
|
59
64
|
|
|
60
65
|
const handleChangeText = useCallback(
|
|
61
66
|
(text: string) => {
|
|
@@ -79,7 +84,7 @@ export const BaseInput = ({
|
|
|
79
84
|
const styles = useStyles({
|
|
80
85
|
hasError: !!errorMessage,
|
|
81
86
|
isFocused,
|
|
82
|
-
isEditable:
|
|
87
|
+
isEditable: !disabled,
|
|
83
88
|
hasLabel: !!label,
|
|
84
89
|
});
|
|
85
90
|
|
|
@@ -88,7 +93,7 @@ export const BaseInput = ({
|
|
|
88
93
|
isFocused,
|
|
89
94
|
showClearButton,
|
|
90
95
|
hasError: !!errorMessage,
|
|
91
|
-
isEditable:
|
|
96
|
+
isEditable: !disabled,
|
|
92
97
|
});
|
|
93
98
|
|
|
94
99
|
return (
|
|
@@ -96,7 +101,7 @@ export const BaseInput = ({
|
|
|
96
101
|
<Pressable
|
|
97
102
|
style={StyleSheet.flatten([styles.container, containerStyle])}
|
|
98
103
|
onPress={() => inputRef.current?.focus()}
|
|
99
|
-
disabled={
|
|
104
|
+
disabled={disabled}
|
|
100
105
|
>
|
|
101
106
|
{prefix}
|
|
102
107
|
|
|
@@ -107,7 +112,7 @@ export const BaseInput = ({
|
|
|
107
112
|
onFocus={() => setIsFocused(true)}
|
|
108
113
|
onBlur={() => setIsFocused(false)}
|
|
109
114
|
onChangeText={handleChangeText}
|
|
110
|
-
editable={
|
|
115
|
+
editable={!disabled}
|
|
111
116
|
autoCapitalize='none'
|
|
112
117
|
autoCorrect={false}
|
|
113
118
|
selectionColor={theme.colors.text.active}
|
|
@@ -128,7 +133,7 @@ export const BaseInput = ({
|
|
|
128
133
|
</Animated.Text>
|
|
129
134
|
)}
|
|
130
135
|
|
|
131
|
-
{(suffix || (!hideClearButton &&
|
|
136
|
+
{(suffix || (!hideClearButton && !disabled)) && (
|
|
132
137
|
<View style={styles.suffixContainer}>
|
|
133
138
|
{showClearButton ? (
|
|
134
139
|
<InteractiveIcon
|
|
@@ -416,9 +416,9 @@ export const VirtualList: Story = {
|
|
|
416
416
|
/>
|
|
417
417
|
<BottomSheetFlatList
|
|
418
418
|
data={data}
|
|
419
|
-
keyExtractor={(item) =>
|
|
420
|
-
renderItem={({ item }) => {
|
|
421
|
-
const typedItem = item
|
|
419
|
+
keyExtractor={(item: ListItem) => item.id}
|
|
420
|
+
renderItem={({ item }: { item: ListItem }) => {
|
|
421
|
+
const typedItem = item;
|
|
422
422
|
return (
|
|
423
423
|
<Box
|
|
424
424
|
lx={{
|
|
@@ -496,7 +496,7 @@ export const StickyHeaderContent: Story = {
|
|
|
496
496
|
/>
|
|
497
497
|
<BottomSheetFlatList
|
|
498
498
|
data={filteredData}
|
|
499
|
-
keyExtractor={(item) =>
|
|
499
|
+
keyExtractor={(item: ListItem) => item.id}
|
|
500
500
|
stickyHeaderIndices={[0]}
|
|
501
501
|
ListHeaderComponent={
|
|
502
502
|
<Box
|
|
@@ -513,7 +513,7 @@ export const StickyHeaderContent: Story = {
|
|
|
513
513
|
/>
|
|
514
514
|
</Box>
|
|
515
515
|
}
|
|
516
|
-
renderItem={({ item }) => {
|
|
516
|
+
renderItem={({ item }: { item: ListItem }) => {
|
|
517
517
|
const typedItem = item as ListItem;
|
|
518
518
|
|
|
519
519
|
return (
|
|
@@ -618,16 +618,16 @@ export const VirtualizedList: Story = {
|
|
|
618
618
|
/>
|
|
619
619
|
<BottomSheetVirtualizedList
|
|
620
620
|
data={data}
|
|
621
|
-
getItem={(items, index) => {
|
|
621
|
+
getItem={(items: ListItem[], index: number) => {
|
|
622
622
|
const typedData = items as ListItem[];
|
|
623
623
|
return typedData[index];
|
|
624
624
|
}}
|
|
625
|
-
getItemCount={(items) => {
|
|
625
|
+
getItemCount={(items: ListItem[]) => {
|
|
626
626
|
const typedData = items as ListItem[];
|
|
627
627
|
return typedData.length;
|
|
628
628
|
}}
|
|
629
|
-
keyExtractor={(item) =>
|
|
630
|
-
renderItem={({ item }) => {
|
|
629
|
+
keyExtractor={(item: ListItem) => item.id}
|
|
630
|
+
renderItem={({ item }: { item: ListItem }) => {
|
|
631
631
|
const typedItem = item as ListItem;
|
|
632
632
|
return (
|
|
633
633
|
<Box
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useDisabledContext } from '@ledgerhq/lumen-utils-shared';
|
|
1
2
|
import { PropsWithChildren } from 'react';
|
|
2
3
|
import { StyleSheet, Text, View } from 'react-native';
|
|
3
4
|
import { useStyleSheet } from '../../../styles';
|
|
@@ -147,10 +148,14 @@ export const BaseButton = ({
|
|
|
147
148
|
isFull = false,
|
|
148
149
|
loading = false,
|
|
149
150
|
icon: IconProp,
|
|
150
|
-
disabled = false,
|
|
151
|
+
disabled: disabledProp = false,
|
|
151
152
|
ref,
|
|
152
153
|
...props
|
|
153
154
|
}: BaseButtonProps) => {
|
|
155
|
+
const disabled = useDisabledContext({
|
|
156
|
+
consumerName: 'BaseButton',
|
|
157
|
+
mergeWith: { disabled: disabledProp },
|
|
158
|
+
});
|
|
154
159
|
const rootStyles = useRootStyles({ isFull });
|
|
155
160
|
|
|
156
161
|
return (
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
createSafeContext,
|
|
3
3
|
DisabledProvider,
|
|
4
4
|
isTextChildren,
|
|
5
|
-
useDisabledContext,
|
|
6
5
|
} from '@ledgerhq/lumen-utils-shared';
|
|
7
6
|
import React, { ReactNode, Ref, useCallback, useEffect, useMemo } from 'react';
|
|
8
7
|
import { LayoutChangeEvent, StyleSheet, View, ViewStyle } from 'react-native';
|
|
@@ -48,6 +47,7 @@ const resolveCardInnerContext = ({
|
|
|
48
47
|
cardPressable: !!onPress,
|
|
49
48
|
headerPressable: false,
|
|
50
49
|
footerExpanded: true,
|
|
50
|
+
disabled: !!disabled,
|
|
51
51
|
onHeaderPress: undefined,
|
|
52
52
|
};
|
|
53
53
|
case 'expandable':
|
|
@@ -55,6 +55,7 @@ const resolveCardInnerContext = ({
|
|
|
55
55
|
cardPressable: false,
|
|
56
56
|
headerPressable: !!onPress && !disabled,
|
|
57
57
|
footerExpanded: Boolean(expanded),
|
|
58
|
+
disabled: !!disabled,
|
|
58
59
|
onHeaderPress: onPress,
|
|
59
60
|
};
|
|
60
61
|
case 'info':
|
|
@@ -62,6 +63,7 @@ const resolveCardInnerContext = ({
|
|
|
62
63
|
cardPressable: false,
|
|
63
64
|
headerPressable: false,
|
|
64
65
|
footerExpanded: true,
|
|
66
|
+
disabled: !!disabled,
|
|
65
67
|
onHeaderPress: undefined,
|
|
66
68
|
};
|
|
67
69
|
}
|
|
@@ -73,6 +75,7 @@ const [CardProvider, useCardContext] = createSafeContext<CardContextValue>(
|
|
|
73
75
|
cardPressable: false,
|
|
74
76
|
headerPressable: false,
|
|
75
77
|
footerExpanded: true,
|
|
78
|
+
disabled: false,
|
|
76
79
|
},
|
|
77
80
|
);
|
|
78
81
|
|
|
@@ -255,13 +258,11 @@ export const CardHeader = ({
|
|
|
255
258
|
style,
|
|
256
259
|
...props
|
|
257
260
|
}: CardHeaderProps) => {
|
|
258
|
-
const disabled =
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
contextRequired: false,
|
|
264
|
-
});
|
|
261
|
+
const { disabled, headerPressable, footerExpanded, onHeaderPress } =
|
|
262
|
+
useCardContext({
|
|
263
|
+
consumerName: 'CardHeader',
|
|
264
|
+
contextRequired: false,
|
|
265
|
+
});
|
|
265
266
|
|
|
266
267
|
const chevronStyle = useStyleSheet(
|
|
267
268
|
(t) => ({
|
|
@@ -374,11 +375,11 @@ export const CardContent = ({
|
|
|
374
375
|
(t) => ({
|
|
375
376
|
container: StyleSheet.flatten([
|
|
376
377
|
{
|
|
377
|
-
flexDirection: 'column'
|
|
378
|
+
flexDirection: 'column',
|
|
378
379
|
gap: t.spacings.s4,
|
|
379
380
|
},
|
|
380
381
|
isTrailing
|
|
381
|
-
? { flexShrink: 1, minWidth: 0, alignItems: 'flex-end'
|
|
382
|
+
? { flexShrink: 1, minWidth: 0, alignItems: 'flex-end' }
|
|
382
383
|
: { flex: 1, minWidth: 0 },
|
|
383
384
|
]),
|
|
384
385
|
}),
|
|
@@ -454,8 +455,9 @@ export const CardContentTitle = ({
|
|
|
454
455
|
style,
|
|
455
456
|
...props
|
|
456
457
|
}: CardContentTitleProps & { ref?: Ref<View> }) => {
|
|
457
|
-
const disabled =
|
|
458
|
+
const { disabled } = useCardContext({
|
|
458
459
|
consumerName: 'CardContentTitle',
|
|
460
|
+
contextRequired: false,
|
|
459
461
|
});
|
|
460
462
|
const { align } = useCardContentAlignContext({
|
|
461
463
|
consumerName: 'CardContentTitle',
|
|
@@ -520,8 +522,9 @@ export const CardContentDescription = ({
|
|
|
520
522
|
style,
|
|
521
523
|
...props
|
|
522
524
|
}: CardContentDescriptionProps & { ref?: Ref<View> }) => {
|
|
523
|
-
const disabled =
|
|
525
|
+
const { disabled } = useCardContext({
|
|
524
526
|
consumerName: 'CardContentDescription',
|
|
527
|
+
contextRequired: false,
|
|
525
528
|
});
|
|
526
529
|
const { align } = useCardContentAlignContext({
|
|
527
530
|
consumerName: 'CardContentDescription',
|
|
@@ -665,10 +668,7 @@ export const CardFooter = ({
|
|
|
665
668
|
style,
|
|
666
669
|
...props
|
|
667
670
|
}: CardFooterProps & { ref?: Ref<View> }) => {
|
|
668
|
-
const disabled =
|
|
669
|
-
consumerName: 'CardFooter',
|
|
670
|
-
});
|
|
671
|
-
const { footerExpanded } = useCardContext({
|
|
671
|
+
const { disabled, footerExpanded } = useCardContext({
|
|
672
672
|
consumerName: 'CardFooter',
|
|
673
673
|
contextRequired: false,
|
|
674
674
|
});
|
|
@@ -8,6 +8,7 @@ export type CardContextValue = {
|
|
|
8
8
|
cardPressable: boolean;
|
|
9
9
|
headerPressable: boolean;
|
|
10
10
|
footerExpanded: boolean;
|
|
11
|
+
disabled: boolean;
|
|
11
12
|
onHeaderPress?: (event: GestureResponderEvent) => void;
|
|
12
13
|
};
|
|
13
14
|
|
|
@@ -15,10 +16,6 @@ export type CardContentAlignContextValue = {
|
|
|
15
16
|
align?: 'left' | 'right';
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
export type CardDisabledContextValue = {
|
|
19
|
-
disabled: boolean;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
19
|
export type CardProps = {
|
|
23
20
|
/**
|
|
24
21
|
* The interaction mode of the card.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useDisabledContext } from '@ledgerhq/lumen-utils-shared';
|
|
1
2
|
import { StyleSheet, Text, View } from 'react-native';
|
|
2
3
|
import { useStyleSheet } from '../../../styles';
|
|
3
4
|
import { ChevronRight } from '../../Symbols';
|
|
@@ -128,10 +129,15 @@ export const CardButton = ({
|
|
|
128
129
|
title,
|
|
129
130
|
description,
|
|
130
131
|
hideChevron,
|
|
131
|
-
disabled = false,
|
|
132
|
+
disabled: disabledProp = false,
|
|
132
133
|
ref,
|
|
133
134
|
...props
|
|
134
135
|
}: CardButtonProps) => {
|
|
136
|
+
const disabled = useDisabledContext({
|
|
137
|
+
consumerName: 'CardButton',
|
|
138
|
+
mergeWith: { disabled: disabledProp },
|
|
139
|
+
});
|
|
140
|
+
|
|
135
141
|
return (
|
|
136
142
|
<Pressable
|
|
137
143
|
ref={ref}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useDisabledContext } from '@ledgerhq/lumen-utils-shared';
|
|
1
2
|
import { useStyleSheet } from '../../../styles';
|
|
2
3
|
import { Check } from '../../Symbols';
|
|
3
4
|
import { useControllableState } from '../../utils';
|
|
@@ -37,11 +38,16 @@ export const Checkbox = ({
|
|
|
37
38
|
checked: checkedProp,
|
|
38
39
|
onCheckedChange: onCheckedChangeProp,
|
|
39
40
|
defaultChecked = false,
|
|
40
|
-
disabled = false,
|
|
41
|
+
disabled: disabledProp = false,
|
|
41
42
|
label,
|
|
42
43
|
ref,
|
|
43
44
|
...props
|
|
44
45
|
}: CheckboxProps) => {
|
|
46
|
+
const disabled = useDisabledContext({
|
|
47
|
+
consumerName: 'Checkbox',
|
|
48
|
+
mergeWith: { disabled: disabledProp },
|
|
49
|
+
});
|
|
50
|
+
|
|
45
51
|
const [checked, onCheckedChange] = useControllableState({
|
|
46
52
|
prop: checkedProp,
|
|
47
53
|
onChange: onCheckedChangeProp,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useDisabledContext } from '@ledgerhq/lumen-utils-shared';
|
|
1
2
|
import { Children, isValidElement, PropsWithChildren } from 'react';
|
|
2
3
|
import { StyleSheet, View } from 'react-native';
|
|
3
4
|
import { useStyleSheet } from '../../../styles';
|
|
@@ -8,13 +9,16 @@ import { Pressable } from '../Utility';
|
|
|
8
9
|
import { HIT_SLOP_MAP, InteractiveIconProps } from './types';
|
|
9
10
|
|
|
10
11
|
type IconType = InteractiveIconProps['iconType'];
|
|
12
|
+
type Appearance = NonNullable<InteractiveIconProps['appearance']>;
|
|
11
13
|
|
|
12
14
|
const useStyles = ({
|
|
13
15
|
iconType,
|
|
16
|
+
appearance,
|
|
14
17
|
pressed,
|
|
15
18
|
disabled,
|
|
16
19
|
}: {
|
|
17
20
|
iconType: IconType;
|
|
21
|
+
appearance: Appearance;
|
|
18
22
|
pressed: boolean;
|
|
19
23
|
disabled: boolean;
|
|
20
24
|
}) => {
|
|
@@ -24,6 +28,21 @@ const useStyles = ({
|
|
|
24
28
|
filled: { backgroundColor: t.colors.bg.base },
|
|
25
29
|
stroked: { backgroundColor: t.colors.bg.baseTransparent },
|
|
26
30
|
};
|
|
31
|
+
const appearanceColors = {
|
|
32
|
+
base: {
|
|
33
|
+
default: t.colors.text.base,
|
|
34
|
+
pressed: t.colors.text.basePressed,
|
|
35
|
+
},
|
|
36
|
+
muted: {
|
|
37
|
+
default: t.colors.text.muted,
|
|
38
|
+
pressed: t.colors.text.mutedPressed,
|
|
39
|
+
},
|
|
40
|
+
white: {
|
|
41
|
+
default: t.colors.text.white,
|
|
42
|
+
pressed: t.colors.text.whitePressed,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
const colorSet = appearanceColors[appearance];
|
|
27
46
|
|
|
28
47
|
return {
|
|
29
48
|
container: StyleSheet.flatten([
|
|
@@ -38,12 +57,12 @@ const useStyles = ({
|
|
|
38
57
|
color: disabled
|
|
39
58
|
? t.colors.text.disabled
|
|
40
59
|
: pressed
|
|
41
|
-
?
|
|
42
|
-
:
|
|
60
|
+
? colorSet.pressed
|
|
61
|
+
: colorSet.default,
|
|
43
62
|
},
|
|
44
63
|
};
|
|
45
64
|
},
|
|
46
|
-
[iconType, pressed, disabled],
|
|
65
|
+
[iconType, appearance, pressed, disabled],
|
|
47
66
|
);
|
|
48
67
|
};
|
|
49
68
|
|
|
@@ -79,13 +98,18 @@ const useStyles = ({
|
|
|
79
98
|
export const InteractiveIcon = ({
|
|
80
99
|
iconType,
|
|
81
100
|
children,
|
|
82
|
-
disabled = false,
|
|
101
|
+
disabled: disabledProp = false,
|
|
83
102
|
hitSlop: hitSlopProp,
|
|
84
103
|
hitSlopType = 'comfortable',
|
|
104
|
+
appearance = 'muted',
|
|
85
105
|
style,
|
|
86
106
|
lx,
|
|
87
107
|
...props
|
|
88
108
|
}: InteractiveIconProps) => {
|
|
109
|
+
const disabled = useDisabledContext({
|
|
110
|
+
consumerName: 'InteractiveIcon',
|
|
111
|
+
mergeWith: { disabled: disabledProp },
|
|
112
|
+
});
|
|
89
113
|
const child = Children.only(children);
|
|
90
114
|
|
|
91
115
|
let iconSize: IconSize = 20;
|
|
@@ -100,7 +124,7 @@ export const InteractiveIcon = ({
|
|
|
100
124
|
lx={lx}
|
|
101
125
|
style={[style, { alignItems: 'center', justifyContent: 'center' }]}
|
|
102
126
|
accessibilityRole='button'
|
|
103
|
-
accessibilityState={{ disabled
|
|
127
|
+
accessibilityState={{ disabled }}
|
|
104
128
|
disabled={disabled}
|
|
105
129
|
hitSlop={resolvedHitSlop}
|
|
106
130
|
{...props}
|
|
@@ -108,8 +132,9 @@ export const InteractiveIcon = ({
|
|
|
108
132
|
{({ pressed }) => (
|
|
109
133
|
<InteractiveIconContent
|
|
110
134
|
iconType={iconType}
|
|
135
|
+
appearance={appearance}
|
|
111
136
|
pressed={pressed}
|
|
112
|
-
disabled={
|
|
137
|
+
disabled={disabled}
|
|
113
138
|
>
|
|
114
139
|
{children}
|
|
115
140
|
</InteractiveIconContent>
|
|
@@ -120,15 +145,17 @@ export const InteractiveIcon = ({
|
|
|
120
145
|
|
|
121
146
|
const InteractiveIconContent = ({
|
|
122
147
|
iconType,
|
|
148
|
+
appearance,
|
|
123
149
|
pressed,
|
|
124
150
|
disabled,
|
|
125
151
|
children,
|
|
126
152
|
}: PropsWithChildren<{
|
|
127
153
|
iconType: IconType;
|
|
154
|
+
appearance: Appearance;
|
|
128
155
|
pressed: boolean;
|
|
129
156
|
disabled: boolean;
|
|
130
157
|
}>) => {
|
|
131
|
-
const styles = useStyles({ iconType, pressed, disabled });
|
|
158
|
+
const styles = useStyles({ iconType, appearance, pressed, disabled });
|
|
132
159
|
|
|
133
160
|
return (
|
|
134
161
|
<View style={styles.container}>
|
|
@@ -42,11 +42,24 @@ export type HitSlopType =
|
|
|
42
42
|
| 'compact-vertical';
|
|
43
43
|
|
|
44
44
|
export type InteractiveIconProps = {
|
|
45
|
+
/**
|
|
46
|
+
* Whether the icon is disabled.
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
disabled?: boolean;
|
|
45
50
|
/**
|
|
46
51
|
* The visual style of the icon button.
|
|
47
52
|
* Choose 'filled' for icons with solid backgrounds or 'stroked' for outlined icons.
|
|
48
53
|
*/
|
|
49
54
|
iconType: 'filled' | 'stroked';
|
|
55
|
+
/**
|
|
56
|
+
* The color appearance of the icon.
|
|
57
|
+
* - `base`: Default high-contrast color.
|
|
58
|
+
* - `muted`: Subdued color for secondary actions.
|
|
59
|
+
* - `white`: White color for use on dark backgrounds.
|
|
60
|
+
* @default 'muted'
|
|
61
|
+
*/
|
|
62
|
+
appearance?: 'base' | 'muted' | 'white';
|
|
50
63
|
/**
|
|
51
64
|
* Preset for the touchable area. Ignored if `hitSlop` is passed explicitly.
|
|
52
65
|
* Automatically applies insets based on the child's icon size.
|
|
@@ -55,4 +68,4 @@ export type InteractiveIconProps = {
|
|
|
55
68
|
*/
|
|
56
69
|
hitSlopType?: HitSlopType;
|
|
57
70
|
} & PropsWithChildren &
|
|
58
|
-
Omit<StyledPressableProps, 'children'>;
|
|
71
|
+
Omit<StyledPressableProps, 'children' | 'disabled'>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useDisabledContext } from '@ledgerhq/lumen-utils-shared';
|
|
1
2
|
import { useStyleSheet } from '../../../styles';
|
|
2
3
|
import { Text } from '../Utility';
|
|
3
4
|
import { LabelProps } from './types';
|
|
@@ -23,14 +24,18 @@ const useStyles = ({ disabled }: { disabled: boolean }) => {
|
|
|
23
24
|
export const Label = ({
|
|
24
25
|
style,
|
|
25
26
|
lx = {},
|
|
26
|
-
disabled = false,
|
|
27
|
+
disabled: disabledProp = false,
|
|
27
28
|
children,
|
|
28
29
|
onPress,
|
|
29
30
|
onLongPress,
|
|
30
31
|
ref,
|
|
31
32
|
...props
|
|
32
33
|
}: LabelProps) => {
|
|
33
|
-
const
|
|
34
|
+
const disabled = useDisabledContext({
|
|
35
|
+
consumerName: 'Label',
|
|
36
|
+
mergeWith: { disabled: disabledProp },
|
|
37
|
+
});
|
|
38
|
+
const styles = useStyles({ disabled: !!disabled });
|
|
34
39
|
|
|
35
40
|
return (
|
|
36
41
|
<Text
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks';
|
|
2
2
|
import * as LinkStories from './Link.stories';
|
|
3
3
|
import { Link } from './Link';
|
|
4
|
+
import { Box } from '../Utility';
|
|
4
5
|
import { CustomTabs, Tab } from '../../../../.storybook/components';
|
|
5
6
|
import { DoVsDontRow, DoBlockItem, DontBlockItem } from '../../../../.storybook/components/DoVsDont';
|
|
6
7
|
import CommonRulesDoAndDont from '../../../../.storybook/components/DoVsDont/CommonRulesDoAndDont.mdx';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createSafeContext,
|
|
3
|
+
DisabledProvider,
|
|
3
4
|
isTextChildren,
|
|
5
|
+
useDisabledContext,
|
|
4
6
|
} from '@ledgerhq/lumen-utils-shared';
|
|
5
7
|
import React, { Ref } from 'react';
|
|
6
8
|
import { StyleSheet, View } from 'react-native';
|
|
@@ -9,7 +11,6 @@ import { Spot } from '../Spot';
|
|
|
9
11
|
import { Box, Pressable, Text } from '../Utility';
|
|
10
12
|
import {
|
|
11
13
|
ListItemContentProps,
|
|
12
|
-
ListItemContextValue,
|
|
13
14
|
ListItemDescriptionProps,
|
|
14
15
|
ListItemIconProps,
|
|
15
16
|
ListItemLeadingProps,
|
|
@@ -20,9 +21,6 @@ import {
|
|
|
20
21
|
ListItemTruncateProps,
|
|
21
22
|
} from './types';
|
|
22
23
|
|
|
23
|
-
const [ListItemProvider, useListItemContext] =
|
|
24
|
-
createSafeContext<ListItemContextValue>('ListItem', {});
|
|
25
|
-
|
|
26
24
|
const [ListItemTrailingProvider, useListItemTrailingContext] =
|
|
27
25
|
createSafeContext<{ isInTrailing: boolean }>('ListItemTrailing', {
|
|
28
26
|
isInTrailing: false,
|
|
@@ -91,12 +89,17 @@ export const ListItem = ({
|
|
|
91
89
|
children,
|
|
92
90
|
lx = {},
|
|
93
91
|
style,
|
|
94
|
-
disabled = false,
|
|
92
|
+
disabled: disabledProp = false,
|
|
95
93
|
ref,
|
|
96
94
|
...pressableProps
|
|
97
95
|
}: ListItemProps) => {
|
|
96
|
+
const disabled = useDisabledContext({
|
|
97
|
+
consumerName: 'ListItem',
|
|
98
|
+
mergeWith: { disabled: disabledProp },
|
|
99
|
+
});
|
|
100
|
+
|
|
98
101
|
return (
|
|
99
|
-
<
|
|
102
|
+
<DisabledProvider value={{ disabled }}>
|
|
100
103
|
<Pressable
|
|
101
104
|
ref={ref}
|
|
102
105
|
lx={lx}
|
|
@@ -110,7 +113,7 @@ export const ListItem = ({
|
|
|
110
113
|
<ListItemInner pressed={pressed}>{children}</ListItemInner>
|
|
111
114
|
)}
|
|
112
115
|
</Pressable>
|
|
113
|
-
</
|
|
116
|
+
</DisabledProvider>
|
|
114
117
|
);
|
|
115
118
|
};
|
|
116
119
|
|
|
@@ -224,7 +227,7 @@ export const ListItemTitle = ({
|
|
|
224
227
|
ref,
|
|
225
228
|
...viewProps
|
|
226
229
|
}: ListItemTitleProps & { ref?: Ref<View> }) => {
|
|
227
|
-
const
|
|
230
|
+
const disabled = useDisabledContext({
|
|
228
231
|
consumerName: 'ListItemTitle',
|
|
229
232
|
contextRequired: true,
|
|
230
233
|
});
|
|
@@ -302,7 +305,7 @@ export const ListItemDescription = ({
|
|
|
302
305
|
ref,
|
|
303
306
|
...viewProps
|
|
304
307
|
}: ListItemDescriptionProps & { ref?: Ref<View> }) => {
|
|
305
|
-
const
|
|
308
|
+
const disabled = useDisabledContext({
|
|
306
309
|
consumerName: 'ListItemDescription',
|
|
307
310
|
contextRequired: true,
|
|
308
311
|
});
|
|
@@ -411,7 +414,7 @@ ListItemTrailing.displayName = 'ListItemTrailing';
|
|
|
411
414
|
* Fixed at size 48 for consistent list item appearance.
|
|
412
415
|
*/
|
|
413
416
|
export const ListItemSpot = (props: ListItemSpotProps) => {
|
|
414
|
-
const
|
|
417
|
+
const disabled = useDisabledContext({
|
|
415
418
|
consumerName: 'ListItemSpot',
|
|
416
419
|
contextRequired: true,
|
|
417
420
|
});
|
|
@@ -433,7 +436,7 @@ export const ListItemIcon = ({
|
|
|
433
436
|
...viewProps
|
|
434
437
|
}: ListItemIconProps) => {
|
|
435
438
|
const { theme } = useTheme();
|
|
436
|
-
const
|
|
439
|
+
const disabled = useDisabledContext({
|
|
437
440
|
consumerName: 'ListItemIcon',
|
|
438
441
|
contextRequired: true,
|
|
439
442
|
});
|
|
@@ -471,7 +474,7 @@ export const ListItemTruncate = ({
|
|
|
471
474
|
ref,
|
|
472
475
|
...textProps
|
|
473
476
|
}: ListItemTruncateProps & { ref?: Ref<React.ElementRef<typeof Text>> }) => {
|
|
474
|
-
const
|
|
477
|
+
const disabled = useDisabledContext({
|
|
475
478
|
consumerName: 'ListItemTruncate',
|
|
476
479
|
contextRequired: true,
|
|
477
480
|
});
|