@ledgerhq/lumen-ui-rnative 0.1.9 → 0.1.11
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/lib/Components/AmountInput/AmountInput.js +16 -10
- package/dist/module/lib/Components/AmountInput/AmountInput.js.map +1 -1
- package/dist/module/lib/Components/BaseInput/BaseInput.js +15 -8
- package/dist/module/lib/Components/BaseInput/BaseInput.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 +45 -49
- 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 +10 -3
- 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/ListItem/ListItem.js +14 -19
- package/dist/module/lib/Components/ListItem/ListItem.js.map +1 -1
- 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/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 +9 -3
- 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/Switch.js +8 -1
- package/dist/module/lib/Components/Switch/Switch.js.map +1 -1
- package/dist/module/lib/Components/TabBar/TabBar.js +4 -3
- 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/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/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 +6 -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/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/package.json +3 -3
- package/src/lib/Components/AmountInput/AmountInput.tsx +15 -7
- package/src/lib/Components/BaseInput/BaseInput.tsx +12 -7
- package/src/lib/Components/Button/BaseButton.tsx +6 -1
- package/src/lib/Components/Card/Card.tsx +45 -50
- 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 +8 -3
- package/src/lib/Components/InteractiveIcon/types.ts +6 -1
- package/src/lib/Components/Label/Label.tsx +7 -2
- package/src/lib/Components/ListItem/ListItem.tsx +15 -12
- 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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileButton.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/Components/TileButton/TileButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TileButton.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/Components/TileButton/TileButton.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAwD1C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU;uGASpB,eAAe;;CA6BjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/lumen-ui-rnative",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"!**/*.tsbuildinfo"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@ledgerhq/lumen-utils-shared": "0.1.
|
|
45
|
+
"@ledgerhq/lumen-utils-shared": "0.1.2",
|
|
46
46
|
"i18next": "^23.7.0",
|
|
47
47
|
"react-i18next": "^14.0.0"
|
|
48
48
|
},
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@types/react": "^19.0.0",
|
|
54
54
|
"@gorhom/bottom-sheet": "^5.0.0",
|
|
55
|
-
"@ledgerhq/lumen-design-core": "0.1.
|
|
55
|
+
"@ledgerhq/lumen-design-core": "0.1.5",
|
|
56
56
|
"react": "^19.0.0",
|
|
57
57
|
"react-native": "~0.79.7",
|
|
58
58
|
"react-native-reanimated": "^3.0.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
|
|
@@ -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 (
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createSafeContext,
|
|
3
|
-
DisabledProvider,
|
|
4
3
|
isTextChildren,
|
|
5
|
-
useDisabledContext,
|
|
6
4
|
} from '@ledgerhq/lumen-utils-shared';
|
|
7
5
|
import React, { ReactNode, Ref, useCallback, useEffect, useMemo } from 'react';
|
|
8
6
|
import { LayoutChangeEvent, StyleSheet, View, ViewStyle } from 'react-native';
|
|
@@ -48,6 +46,7 @@ const resolveCardInnerContext = ({
|
|
|
48
46
|
cardPressable: !!onPress,
|
|
49
47
|
headerPressable: false,
|
|
50
48
|
footerExpanded: true,
|
|
49
|
+
disabled: !!disabled,
|
|
51
50
|
onHeaderPress: undefined,
|
|
52
51
|
};
|
|
53
52
|
case 'expandable':
|
|
@@ -55,6 +54,7 @@ const resolveCardInnerContext = ({
|
|
|
55
54
|
cardPressable: false,
|
|
56
55
|
headerPressable: !!onPress && !disabled,
|
|
57
56
|
footerExpanded: Boolean(expanded),
|
|
57
|
+
disabled: !!disabled,
|
|
58
58
|
onHeaderPress: onPress,
|
|
59
59
|
};
|
|
60
60
|
case 'info':
|
|
@@ -62,6 +62,7 @@ const resolveCardInnerContext = ({
|
|
|
62
62
|
cardPressable: false,
|
|
63
63
|
headerPressable: false,
|
|
64
64
|
footerExpanded: true,
|
|
65
|
+
disabled: !!disabled,
|
|
65
66
|
onHeaderPress: undefined,
|
|
66
67
|
};
|
|
67
68
|
}
|
|
@@ -73,6 +74,7 @@ const [CardProvider, useCardContext] = createSafeContext<CardContextValue>(
|
|
|
73
74
|
cardPressable: false,
|
|
74
75
|
headerPressable: false,
|
|
75
76
|
footerExpanded: true,
|
|
77
|
+
disabled: false,
|
|
76
78
|
},
|
|
77
79
|
);
|
|
78
80
|
|
|
@@ -162,47 +164,43 @@ export const Card = ({
|
|
|
162
164
|
if (innerContext.cardPressable) {
|
|
163
165
|
return (
|
|
164
166
|
<CardProvider value={innerContext}>
|
|
165
|
-
<
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
</Pressable>
|
|
187
|
-
</DisabledProvider>
|
|
167
|
+
<Pressable
|
|
168
|
+
ref={ref}
|
|
169
|
+
lx={lx}
|
|
170
|
+
style={style as ViewStyle}
|
|
171
|
+
onPress={onPress}
|
|
172
|
+
disabled={disabled}
|
|
173
|
+
accessibilityRole='button'
|
|
174
|
+
accessibilityState={{ disabled }}
|
|
175
|
+
{...props}
|
|
176
|
+
>
|
|
177
|
+
{({ pressed }) => (
|
|
178
|
+
<CardInner
|
|
179
|
+
outlined={outlined}
|
|
180
|
+
pressed={pressed}
|
|
181
|
+
disabled={disabled}
|
|
182
|
+
interactive
|
|
183
|
+
>
|
|
184
|
+
{children}
|
|
185
|
+
</CardInner>
|
|
186
|
+
)}
|
|
187
|
+
</Pressable>
|
|
188
188
|
</CardProvider>
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
return (
|
|
193
193
|
<CardProvider value={innerContext}>
|
|
194
|
-
<
|
|
195
|
-
<
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
</Box>
|
|
205
|
-
</DisabledProvider>
|
|
194
|
+
<Box lx={lx} style={style} {...props}>
|
|
195
|
+
<CardInner
|
|
196
|
+
outlined={outlined}
|
|
197
|
+
pressed={false}
|
|
198
|
+
disabled={disabled}
|
|
199
|
+
interactive={false}
|
|
200
|
+
>
|
|
201
|
+
{children}
|
|
202
|
+
</CardInner>
|
|
203
|
+
</Box>
|
|
206
204
|
</CardProvider>
|
|
207
205
|
);
|
|
208
206
|
};
|
|
@@ -255,13 +253,11 @@ export const CardHeader = ({
|
|
|
255
253
|
style,
|
|
256
254
|
...props
|
|
257
255
|
}: CardHeaderProps) => {
|
|
258
|
-
const disabled =
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
contextRequired: false,
|
|
264
|
-
});
|
|
256
|
+
const { disabled, headerPressable, footerExpanded, onHeaderPress } =
|
|
257
|
+
useCardContext({
|
|
258
|
+
consumerName: 'CardHeader',
|
|
259
|
+
contextRequired: false,
|
|
260
|
+
});
|
|
265
261
|
|
|
266
262
|
const chevronStyle = useStyleSheet(
|
|
267
263
|
(t) => ({
|
|
@@ -454,8 +450,9 @@ export const CardContentTitle = ({
|
|
|
454
450
|
style,
|
|
455
451
|
...props
|
|
456
452
|
}: CardContentTitleProps & { ref?: Ref<View> }) => {
|
|
457
|
-
const disabled =
|
|
453
|
+
const { disabled } = useCardContext({
|
|
458
454
|
consumerName: 'CardContentTitle',
|
|
455
|
+
contextRequired: false,
|
|
459
456
|
});
|
|
460
457
|
const { align } = useCardContentAlignContext({
|
|
461
458
|
consumerName: 'CardContentTitle',
|
|
@@ -520,8 +517,9 @@ export const CardContentDescription = ({
|
|
|
520
517
|
style,
|
|
521
518
|
...props
|
|
522
519
|
}: CardContentDescriptionProps & { ref?: Ref<View> }) => {
|
|
523
|
-
const disabled =
|
|
520
|
+
const { disabled } = useCardContext({
|
|
524
521
|
consumerName: 'CardContentDescription',
|
|
522
|
+
contextRequired: false,
|
|
525
523
|
});
|
|
526
524
|
const { align } = useCardContentAlignContext({
|
|
527
525
|
consumerName: 'CardContentDescription',
|
|
@@ -665,10 +663,7 @@ export const CardFooter = ({
|
|
|
665
663
|
style,
|
|
666
664
|
...props
|
|
667
665
|
}: CardFooterProps & { ref?: Ref<View> }) => {
|
|
668
|
-
const disabled =
|
|
669
|
-
consumerName: 'CardFooter',
|
|
670
|
-
});
|
|
671
|
-
const { footerExpanded } = useCardContext({
|
|
666
|
+
const { disabled, footerExpanded } = useCardContext({
|
|
672
667
|
consumerName: 'CardFooter',
|
|
673
668
|
contextRequired: false,
|
|
674
669
|
});
|
|
@@ -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';
|
|
@@ -79,13 +80,17 @@ const useStyles = ({
|
|
|
79
80
|
export const InteractiveIcon = ({
|
|
80
81
|
iconType,
|
|
81
82
|
children,
|
|
82
|
-
disabled = false,
|
|
83
|
+
disabled: disabledProp = false,
|
|
83
84
|
hitSlop: hitSlopProp,
|
|
84
85
|
hitSlopType = 'comfortable',
|
|
85
86
|
style,
|
|
86
87
|
lx,
|
|
87
88
|
...props
|
|
88
89
|
}: InteractiveIconProps) => {
|
|
90
|
+
const disabled = useDisabledContext({
|
|
91
|
+
consumerName: 'InteractiveIcon',
|
|
92
|
+
mergeWith: { disabled: disabledProp },
|
|
93
|
+
});
|
|
89
94
|
const child = Children.only(children);
|
|
90
95
|
|
|
91
96
|
let iconSize: IconSize = 20;
|
|
@@ -100,7 +105,7 @@ export const InteractiveIcon = ({
|
|
|
100
105
|
lx={lx}
|
|
101
106
|
style={[style, { alignItems: 'center', justifyContent: 'center' }]}
|
|
102
107
|
accessibilityRole='button'
|
|
103
|
-
accessibilityState={{ disabled
|
|
108
|
+
accessibilityState={{ disabled }}
|
|
104
109
|
disabled={disabled}
|
|
105
110
|
hitSlop={resolvedHitSlop}
|
|
106
111
|
{...props}
|
|
@@ -109,7 +114,7 @@ export const InteractiveIcon = ({
|
|
|
109
114
|
<InteractiveIconContent
|
|
110
115
|
iconType={iconType}
|
|
111
116
|
pressed={pressed}
|
|
112
|
-
disabled={
|
|
117
|
+
disabled={disabled}
|
|
113
118
|
>
|
|
114
119
|
{children}
|
|
115
120
|
</InteractiveIconContent>
|
|
@@ -42,6 +42,11 @@ 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.
|
|
@@ -55,4 +60,4 @@ export type InteractiveIconProps = {
|
|
|
55
60
|
*/
|
|
56
61
|
hitSlopType?: HitSlopType;
|
|
57
62
|
} & PropsWithChildren &
|
|
58
|
-
Omit<StyledPressableProps, 'children'>;
|
|
63
|
+
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,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
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useDisabledContext } from '@ledgerhq/lumen-utils-shared';
|
|
1
2
|
import Animated from 'react-native-reanimated';
|
|
2
3
|
import { useStyleSheet } from '../../../styles';
|
|
3
4
|
import type { LumenTextStyle, LumenTypographyTokenName } from '../../../styles';
|
|
@@ -111,10 +112,14 @@ export function SegmentedControl({
|
|
|
111
112
|
onSelectedChange,
|
|
112
113
|
accessibilityLabel,
|
|
113
114
|
children,
|
|
114
|
-
disabled,
|
|
115
|
+
disabled: disabledProp,
|
|
115
116
|
appearance = 'background',
|
|
116
117
|
...props
|
|
117
118
|
}: SegmentedControlProps) {
|
|
119
|
+
const disabled = useDisabledContext({
|
|
120
|
+
consumerName: 'SegmentedControl',
|
|
121
|
+
mergeWith: { disabled: disabledProp },
|
|
122
|
+
});
|
|
118
123
|
const styles = useRootStyles({
|
|
119
124
|
disabled: Boolean(disabled),
|
|
120
125
|
appearance,
|
|
@@ -3,7 +3,7 @@ import { createSafeContext } from '@ledgerhq/lumen-utils-shared';
|
|
|
3
3
|
export type SegmentedControlContextValue = {
|
|
4
4
|
selectedValue: string;
|
|
5
5
|
onSelectedChange: (value: string) => void;
|
|
6
|
-
disabled
|
|
6
|
+
disabled: boolean;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
const [SegmentedControlContextProvider, _useSegmentedControlSafeContext] =
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useDisabledContext } from '@ledgerhq/lumen-utils-shared';
|
|
1
2
|
import React, { useState, useEffect, useCallback, useId } from 'react';
|
|
2
3
|
import { StyleSheet, View } from 'react-native';
|
|
3
4
|
import { useStyleSheet } from '../../../styles';
|
|
@@ -57,8 +58,12 @@ export const Select = ({
|
|
|
57
58
|
value: controlledValue,
|
|
58
59
|
defaultValue,
|
|
59
60
|
onValueChange,
|
|
60
|
-
disabled = false,
|
|
61
|
+
disabled: disabledProp = false,
|
|
61
62
|
}: SelectProps) => {
|
|
63
|
+
const disabled = useDisabledContext({
|
|
64
|
+
consumerName: 'Select',
|
|
65
|
+
mergeWith: { disabled: disabledProp },
|
|
66
|
+
});
|
|
62
67
|
const selectId = useId();
|
|
63
68
|
|
|
64
69
|
const [internalOpen, setInternalOpen] = useControllableState({
|