bootstrap-rn 0.3.4 → 0.3.6
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/lib/commonjs/components/Image.js.map +1 -1
- package/lib/commonjs/components/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/Text.js.map +1 -1
- package/lib/commonjs/components/dropdown/DropdownMenu.js.map +1 -1
- package/lib/commonjs/components/forms/RadioGroup.js.map +1 -1
- package/lib/commonjs/components/forms/internals/PickerNative.js.map +1 -1
- package/lib/commonjs/components/modal/Modal.js +1 -1
- package/lib/commonjs/components/modal/Modal.js.map +1 -1
- package/lib/commonjs/components/modal/ModalBody.js +1 -1
- package/lib/commonjs/components/modal/ModalBody.js.map +1 -1
- package/lib/commonjs/components/modal/ModalContext.js.map +1 -1
- package/lib/commonjs/components/nav/Nav.js.map +1 -1
- package/lib/commonjs/components/nav/NavContext.js.map +1 -1
- package/lib/commonjs/components/nav/TabContext.js.map +1 -1
- package/lib/commonjs/components/navbar/NavbarContext.js.map +1 -1
- package/lib/commonjs/components/offcanvas/OffcanvasBody.js.map +1 -1
- package/lib/commonjs/components/offcanvas/OffcanvasContext.js.map +1 -1
- package/lib/commonjs/components/popover/injectPopover.js.map +1 -1
- package/lib/commonjs/components/toasts/ToastContainer.js +3 -1
- package/lib/commonjs/components/toasts/ToastContainer.js.map +1 -1
- package/lib/commonjs/components/tooltip/injectTooltip.js +0 -3
- package/lib/commonjs/components/tooltip/injectTooltip.js.map +1 -1
- package/lib/commonjs/index.d.ts +47 -8
- package/lib/commonjs/index.js +0 -56
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/style/StyleSheet.js +4 -2
- package/lib/commonjs/style/StyleSheet.js.map +1 -1
- package/lib/commonjs/style/makeUtilities.js.map +1 -1
- package/lib/commonjs/types.d.ts +6 -3
- package/lib/module/components/Image.js.map +1 -1
- package/lib/module/components/ImageBackground.js.map +1 -1
- package/lib/module/components/Text.js.map +1 -1
- package/lib/module/components/dropdown/DropdownMenu.js.map +1 -1
- package/lib/module/components/forms/RadioGroup.js.map +1 -1
- package/lib/module/components/forms/internals/PickerNative.js.map +1 -1
- package/lib/module/components/modal/Modal.js +1 -1
- package/lib/module/components/modal/Modal.js.map +1 -1
- package/lib/module/components/modal/ModalBody.js +1 -1
- package/lib/module/components/modal/ModalBody.js.map +1 -1
- package/lib/module/components/modal/ModalContext.js.map +1 -1
- package/lib/module/components/nav/Nav.js.map +1 -1
- package/lib/module/components/nav/NavContext.js.map +1 -1
- package/lib/module/components/nav/TabContext.js.map +1 -1
- package/lib/module/components/navbar/NavbarContext.js.map +1 -1
- package/lib/module/components/offcanvas/OffcanvasBody.js.map +1 -1
- package/lib/module/components/offcanvas/OffcanvasContext.js.map +1 -1
- package/lib/module/components/popover/injectPopover.js.map +1 -1
- package/lib/module/components/toasts/ToastContainer.js +3 -1
- package/lib/module/components/toasts/ToastContainer.js.map +1 -1
- package/lib/module/components/tooltip/injectTooltip.js +0 -3
- package/lib/module/components/tooltip/injectTooltip.js.map +1 -1
- package/lib/module/index.d.ts +47 -8
- package/lib/module/index.js +0 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/style/StyleSheet.js +4 -2
- package/lib/module/style/StyleSheet.js.map +1 -1
- package/lib/module/style/makeUtilities.js.map +1 -1
- package/lib/module/types.d.ts +6 -3
- package/lib/types/components/Image.d.ts.map +1 -1
- package/lib/types/components/ImageBackground.d.ts.map +1 -1
- package/lib/types/components/Text.d.ts +1 -1
- package/lib/types/components/Text.d.ts.map +1 -1
- package/lib/types/components/dropdown/Dropdown.d.ts +2 -11
- package/lib/types/components/dropdown/Dropdown.d.ts.map +1 -1
- package/lib/types/components/dropdown/DropdownContext.d.ts +2 -2
- package/lib/types/components/dropdown/DropdownContext.d.ts.map +1 -1
- package/lib/types/components/dropdown/DropdownMenu.d.ts +2 -2
- package/lib/types/components/dropdown/DropdownMenu.d.ts.map +1 -1
- package/lib/types/components/dropdown/DropdownToggle.d.ts +2 -2
- package/lib/types/components/dropdown/DropdownToggle.d.ts.map +1 -1
- package/lib/types/components/forms/Picker.d.ts +4 -4
- package/lib/types/components/forms/Picker.d.ts.map +1 -1
- package/lib/types/components/forms/PickerItem.d.ts +1 -1
- package/lib/types/components/forms/PickerItem.d.ts.map +1 -1
- package/lib/types/components/forms/Radio.d.ts +1 -1
- package/lib/types/components/forms/Radio.d.ts.map +1 -1
- package/lib/types/components/forms/RadioContext.d.ts +2 -2
- package/lib/types/components/forms/RadioContext.d.ts.map +1 -1
- package/lib/types/components/forms/RadioGroup.d.ts +2 -2
- package/lib/types/components/forms/RadioGroup.d.ts.map +1 -1
- package/lib/types/components/forms/internals/PickerNative.d.ts.map +1 -1
- package/lib/types/components/forms/internals/PickerNativeContext.d.ts +2 -2
- package/lib/types/components/forms/internals/PickerNativeContext.d.ts.map +1 -1
- package/lib/types/components/forms/internals/PickerNativeItem.d.ts +1 -1
- package/lib/types/components/forms/internals/PickerNativeItem.d.ts.map +1 -1
- package/lib/types/components/forms/internals/PickerWebItem.d.ts +1 -1
- package/lib/types/components/forms/internals/PickerWebItem.d.ts.map +1 -1
- package/lib/types/components/list-group/ListGroup.d.ts +1 -1
- package/lib/types/components/list-group/ListGroupItem.d.ts +13 -1
- package/lib/types/components/list-group/ListGroupItem.d.ts.map +1 -1
- package/lib/types/components/list-group/ListGroupItemAction.d.ts +2 -2
- package/lib/types/components/list-group/ListGroupItemAction.d.ts.map +1 -1
- package/lib/types/components/modal/Modal.d.ts +4 -7
- package/lib/types/components/modal/Modal.d.ts.map +1 -1
- package/lib/types/components/modal/ModalBody.d.ts +3 -6
- package/lib/types/components/modal/ModalBody.d.ts.map +1 -1
- package/lib/types/components/modal/ModalContext.d.ts +3 -3
- package/lib/types/components/modal/ModalContext.d.ts.map +1 -1
- package/lib/types/components/nav/Nav.d.ts +1 -3
- package/lib/types/components/nav/Nav.d.ts.map +1 -1
- package/lib/types/components/nav/NavContext.d.ts +3 -3
- package/lib/types/components/nav/NavContext.d.ts.map +1 -1
- package/lib/types/components/nav/Tab.d.ts +1 -1
- package/lib/types/components/nav/TabContext.d.ts +3 -3
- package/lib/types/components/nav/TabContext.d.ts.map +1 -1
- package/lib/types/components/navbar/Navbar.d.ts +1 -1
- package/lib/types/components/navbar/NavbarBrand.d.ts +2 -2
- package/lib/types/components/navbar/NavbarBrand.d.ts.map +1 -1
- package/lib/types/components/navbar/NavbarContext.d.ts +2 -2
- package/lib/types/components/navbar/NavbarContext.d.ts.map +1 -1
- package/lib/types/components/offcanvas/Offcanvas.d.ts +1 -3
- package/lib/types/components/offcanvas/Offcanvas.d.ts.map +1 -1
- package/lib/types/components/offcanvas/OffcanvasBody.d.ts +3 -4
- package/lib/types/components/offcanvas/OffcanvasBody.d.ts.map +1 -1
- package/lib/types/components/offcanvas/OffcanvasContext.d.ts +2 -2
- package/lib/types/components/offcanvas/OffcanvasContext.d.ts.map +1 -1
- package/lib/types/components/popover/injectPopover.d.ts +9 -12
- package/lib/types/components/popover/injectPopover.d.ts.map +1 -1
- package/lib/types/components/toasts/ToastContainer.d.ts +4 -2
- package/lib/types/components/toasts/ToastContainer.d.ts.map +1 -1
- package/lib/types/components/tooltip/injectTooltip.d.ts +8 -11
- package/lib/types/components/tooltip/injectTooltip.d.ts.map +1 -1
- package/lib/types/hooks/useBackground.native.d.ts +3 -1
- package/lib/types/hooks/useBackground.native.d.ts.map +1 -1
- package/lib/types/index.d.ts +47 -8
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/style/StyleSheet.d.ts +2 -3
- package/lib/types/style/StyleSheet.d.ts.map +1 -1
- package/lib/types/style/createStyle.d.ts +3 -1
- package/lib/types/style/createStyle.d.ts.map +1 -1
- package/lib/types/style/css.d.ts +3 -1
- package/lib/types/style/css.d.ts.map +1 -1
- package/lib/types/style/makeUtilities.d.ts +6 -2
- package/lib/types/style/makeUtilities.d.ts.map +1 -1
- package/lib/types/theme/variables.d.ts +3 -1
- package/lib/types/theme/variables.d.ts.map +1 -1
- package/lib/types/types.d.ts +6 -3
- package/lib/types/types.d.ts.map +1 -1
- package/package.json +80 -80
- package/src/components/Image.tsx +31 -27
- package/src/components/ImageBackground.tsx +48 -46
- package/src/components/Text.tsx +119 -117
- package/src/components/dropdown/DropdownContext.ts +2 -2
- package/src/components/dropdown/DropdownMenu.tsx +127 -125
- package/src/components/dropdown/DropdownToggle.ts +2 -2
- package/src/components/forms/Picker.tsx +191 -191
- package/src/components/forms/PickerItem.tsx +32 -32
- package/src/components/forms/Radio.tsx +37 -37
- package/src/components/forms/RadioContext.ts +13 -13
- package/src/components/forms/RadioGroup.tsx +42 -40
- package/src/components/forms/internals/PickerNative.tsx +193 -195
- package/src/components/forms/internals/PickerNativeContext.ts +14 -14
- package/src/components/forms/internals/PickerNativeItem.tsx +59 -59
- package/src/components/forms/internals/PickerWebItem.tsx +36 -36
- package/src/components/list-group/ListGroupItemAction.tsx +2 -2
- package/src/components/modal/Modal.tsx +234 -233
- package/src/components/modal/ModalBody.tsx +52 -56
- package/src/components/modal/ModalContext.ts +3 -3
- package/src/components/nav/Nav.tsx +4 -4
- package/src/components/nav/NavContext.ts +3 -3
- package/src/components/nav/TabContext.ts +3 -3
- package/src/components/navbar/NavbarBrand.tsx +2 -2
- package/src/components/navbar/NavbarContext.ts +2 -2
- package/src/components/offcanvas/OffcanvasBody.tsx +64 -66
- package/src/components/offcanvas/OffcanvasContext.ts +4 -2
- package/src/components/popover/injectPopover.tsx +97 -98
- package/src/components/toasts/ToastContainer.tsx +41 -39
- package/src/components/tooltip/injectTooltip.tsx +93 -96
- package/src/index.ts +242 -211
- package/src/style/StyleSheet.ts +149 -138
- package/src/style/makeUtilities.ts +79 -76
- package/src/types.ts +168 -162
|
@@ -1,195 +1,193 @@
|
|
|
1
|
-
import React, { useState, useMemo } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
TextStyle,
|
|
4
|
-
TextInputFocusEventData,
|
|
5
|
-
NativeSyntheticEvent,
|
|
6
|
-
TargetedEvent,
|
|
7
|
-
StyleSheet as StyleUtils,
|
|
8
|
-
} from 'react-native';
|
|
9
|
-
import StyleSheet from '../../../style/StyleSheet';
|
|
10
|
-
import css from '../../../style/css';
|
|
11
|
-
import Pressable, { PressableRef } from '../../Pressable';
|
|
12
|
-
import Text from '../../Text';
|
|
13
|
-
import Offcanvas from '../../offcanvas/Offcanvas';
|
|
14
|
-
import useBackground from '../../../hooks/useBackground';
|
|
15
|
-
import PickerNativeContext from './PickerNativeContext';
|
|
16
|
-
import type { PickerProps, MenuComponentProps } from '../Picker';
|
|
17
|
-
import type { BaseStyle } from '../../../types';
|
|
18
|
-
|
|
19
|
-
export interface PickerNativeProps extends PickerProps {
|
|
20
|
-
style: TextStyle[];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const styles = StyleSheet.create({
|
|
24
|
-
menu: css`
|
|
25
|
-
align-items: center;
|
|
26
|
-
`,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// Ref: https://reactnative.dev/docs/text-style-props
|
|
30
|
-
const textStyleKeys = [
|
|
31
|
-
'color',
|
|
32
|
-
'fontFamily',
|
|
33
|
-
'fontSize',
|
|
34
|
-
'fontStyle',
|
|
35
|
-
'fontWeight',
|
|
36
|
-
'includeFontPaddingAndroid',
|
|
37
|
-
'fontVariant',
|
|
38
|
-
'letterSpacing',
|
|
39
|
-
'lineHeight',
|
|
40
|
-
'textAlign',
|
|
41
|
-
'textAlignVerticalAndroid',
|
|
42
|
-
'textDecorationColoriOS',
|
|
43
|
-
'textDecorationLine',
|
|
44
|
-
'textDecorationStyleiOS',
|
|
45
|
-
'textShadowColor',
|
|
46
|
-
'textShadowOffset',
|
|
47
|
-
'textShadowRadius',
|
|
48
|
-
'textTransform',
|
|
49
|
-
'writingDirection',
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
const extractTextStyles = (style: BaseStyle[]) => {
|
|
53
|
-
const flattenedStyle = StyleUtils.flatten(style);
|
|
54
|
-
const textStyles: { [key: string]: string } = {};
|
|
55
|
-
|
|
56
|
-
Object.entries(flattenedStyle).forEach(([key, value]) => {
|
|
57
|
-
if (textStyleKeys.includes(key)) {
|
|
58
|
-
textStyles[key] = value;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
return textStyles;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
type GetTextProps = {
|
|
66
|
-
children: React.ReactElement | React.ReactElement[];
|
|
67
|
-
selectedValue?:
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const getText = ({ children, selectedValue }: GetTextProps) => {
|
|
71
|
-
const items = React.Children.map(children, (child) => ({
|
|
72
|
-
label: child.props.label,
|
|
73
|
-
value: child.props.value,
|
|
74
|
-
}));
|
|
75
|
-
|
|
76
|
-
const selectedItem = items?.find((item) => item.value === selectedValue);
|
|
77
|
-
|
|
78
|
-
return selectedItem?.label;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
function DefaultMenuComponent({
|
|
82
|
-
children,
|
|
83
|
-
selectedValue,
|
|
84
|
-
onValueChange: handleValueChange,
|
|
85
|
-
onClose: handleClose,
|
|
86
|
-
}: MenuComponentProps) {
|
|
87
|
-
const contextValue = useMemo(
|
|
88
|
-
() => ({
|
|
89
|
-
selectedValue,
|
|
90
|
-
handleValueChange,
|
|
91
|
-
}),
|
|
92
|
-
[selectedValue, handleValueChange],
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
return (
|
|
96
|
-
<Offcanvas placement="bottom" visible onToggle={handleClose}>
|
|
97
|
-
<Offcanvas.Body contentContainerStyle={styles.menu}>
|
|
98
|
-
<PickerNativeContext.Provider value={contextValue}>
|
|
99
|
-
{children}
|
|
100
|
-
</PickerNativeContext.Provider>
|
|
101
|
-
</Offcanvas.Body>
|
|
102
|
-
</Offcanvas>
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
/* eslint-enable */
|
|
106
|
-
|
|
107
|
-
const PickerNative = React.forwardRef<PressableRef, PickerNativeProps>(
|
|
108
|
-
(props, ref) => {
|
|
109
|
-
const {
|
|
110
|
-
children,
|
|
111
|
-
selectedValue,
|
|
112
|
-
onValueChange = () => {},
|
|
113
|
-
onFocus = () => {},
|
|
114
|
-
onBlur = () => {},
|
|
115
|
-
placeholder,
|
|
116
|
-
placeholderTextColor,
|
|
117
|
-
disabled = false,
|
|
118
|
-
MenuComponent = DefaultMenuComponent,
|
|
119
|
-
style,
|
|
120
|
-
...elementProps
|
|
121
|
-
} = props;
|
|
122
|
-
|
|
123
|
-
const background = useBackground(style);
|
|
124
|
-
|
|
125
|
-
const [visible, setVisible] = useState(false);
|
|
126
|
-
|
|
127
|
-
const textStyle = extractTextStyles(background.style);
|
|
128
|
-
|
|
129
|
-
const showPlaceholder =
|
|
130
|
-
selectedValue === undefined || selectedValue === null;
|
|
131
|
-
|
|
132
|
-
const handleValueChange = (
|
|
133
|
-
nextValue
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
>
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
export default PickerNative;
|
|
1
|
+
import React, { useState, useMemo } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
TextStyle,
|
|
4
|
+
TextInputFocusEventData,
|
|
5
|
+
NativeSyntheticEvent,
|
|
6
|
+
TargetedEvent,
|
|
7
|
+
StyleSheet as StyleUtils,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import StyleSheet from '../../../style/StyleSheet';
|
|
10
|
+
import css from '../../../style/css';
|
|
11
|
+
import Pressable, { PressableRef } from '../../Pressable';
|
|
12
|
+
import Text from '../../Text';
|
|
13
|
+
import Offcanvas from '../../offcanvas/Offcanvas';
|
|
14
|
+
import useBackground from '../../../hooks/useBackground';
|
|
15
|
+
import PickerNativeContext from './PickerNativeContext';
|
|
16
|
+
import type { PickerProps, MenuComponentProps } from '../Picker';
|
|
17
|
+
import type { BaseStyle } from '../../../types';
|
|
18
|
+
|
|
19
|
+
export interface PickerNativeProps extends PickerProps {
|
|
20
|
+
style: TextStyle[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const styles = StyleSheet.create({
|
|
24
|
+
menu: css`
|
|
25
|
+
align-items: center;
|
|
26
|
+
`,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Ref: https://reactnative.dev/docs/text-style-props
|
|
30
|
+
const textStyleKeys = [
|
|
31
|
+
'color',
|
|
32
|
+
'fontFamily',
|
|
33
|
+
'fontSize',
|
|
34
|
+
'fontStyle',
|
|
35
|
+
'fontWeight',
|
|
36
|
+
'includeFontPaddingAndroid',
|
|
37
|
+
'fontVariant',
|
|
38
|
+
'letterSpacing',
|
|
39
|
+
'lineHeight',
|
|
40
|
+
'textAlign',
|
|
41
|
+
'textAlignVerticalAndroid',
|
|
42
|
+
'textDecorationColoriOS',
|
|
43
|
+
'textDecorationLine',
|
|
44
|
+
'textDecorationStyleiOS',
|
|
45
|
+
'textShadowColor',
|
|
46
|
+
'textShadowOffset',
|
|
47
|
+
'textShadowRadius',
|
|
48
|
+
'textTransform',
|
|
49
|
+
'writingDirection',
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const extractTextStyles = (style: BaseStyle[]) => {
|
|
53
|
+
const flattenedStyle = StyleUtils.flatten(style);
|
|
54
|
+
const textStyles: { [key: string]: string } = {};
|
|
55
|
+
|
|
56
|
+
Object.entries(flattenedStyle).forEach(([key, value]) => {
|
|
57
|
+
if (textStyleKeys.includes(key)) {
|
|
58
|
+
textStyles[key] = value;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return textStyles;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
type GetTextProps = {
|
|
66
|
+
children: React.ReactElement | React.ReactElement[];
|
|
67
|
+
selectedValue?: string | null | undefined;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const getText = ({ children, selectedValue }: GetTextProps) => {
|
|
71
|
+
const items = React.Children.map(children, (child) => ({
|
|
72
|
+
label: child.props.label,
|
|
73
|
+
value: child.props.value,
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
const selectedItem = items?.find((item) => item.value === selectedValue);
|
|
77
|
+
|
|
78
|
+
return selectedItem?.label;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
function DefaultMenuComponent({
|
|
82
|
+
children,
|
|
83
|
+
selectedValue,
|
|
84
|
+
onValueChange: handleValueChange,
|
|
85
|
+
onClose: handleClose,
|
|
86
|
+
}: MenuComponentProps) {
|
|
87
|
+
const contextValue = useMemo(
|
|
88
|
+
() => ({
|
|
89
|
+
selectedValue,
|
|
90
|
+
handleValueChange,
|
|
91
|
+
}),
|
|
92
|
+
[selectedValue, handleValueChange],
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<Offcanvas placement="bottom" visible onToggle={handleClose}>
|
|
97
|
+
<Offcanvas.Body contentContainerStyle={styles.menu}>
|
|
98
|
+
<PickerNativeContext.Provider value={contextValue}>
|
|
99
|
+
{children}
|
|
100
|
+
</PickerNativeContext.Provider>
|
|
101
|
+
</Offcanvas.Body>
|
|
102
|
+
</Offcanvas>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
/* eslint-enable */
|
|
106
|
+
|
|
107
|
+
const PickerNative = React.forwardRef<PressableRef, PickerNativeProps>(
|
|
108
|
+
(props, ref) => {
|
|
109
|
+
const {
|
|
110
|
+
children,
|
|
111
|
+
selectedValue,
|
|
112
|
+
onValueChange = () => {},
|
|
113
|
+
onFocus = () => {},
|
|
114
|
+
onBlur = () => {},
|
|
115
|
+
placeholder,
|
|
116
|
+
placeholderTextColor,
|
|
117
|
+
disabled = false,
|
|
118
|
+
MenuComponent = DefaultMenuComponent,
|
|
119
|
+
style,
|
|
120
|
+
...elementProps
|
|
121
|
+
} = props;
|
|
122
|
+
|
|
123
|
+
const background = useBackground(style);
|
|
124
|
+
|
|
125
|
+
const [visible, setVisible] = useState(false);
|
|
126
|
+
|
|
127
|
+
const textStyle = extractTextStyles(background.style);
|
|
128
|
+
|
|
129
|
+
const showPlaceholder =
|
|
130
|
+
selectedValue === undefined || selectedValue === null;
|
|
131
|
+
|
|
132
|
+
const handleValueChange = (nextValue: string) => {
|
|
133
|
+
onValueChange(nextValue);
|
|
134
|
+
setVisible(false);
|
|
135
|
+
};
|
|
136
|
+
const handleClose = () => {
|
|
137
|
+
setVisible(false);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const handleFocus = (event: NativeSyntheticEvent<TargetedEvent>) => {
|
|
141
|
+
onFocus(event as NativeSyntheticEvent<TextInputFocusEventData>);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const handleBlur = (event: NativeSyntheticEvent<TargetedEvent>) => {
|
|
145
|
+
onBlur(event as NativeSyntheticEvent<TextInputFocusEventData>);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<>
|
|
150
|
+
<Pressable
|
|
151
|
+
{...elementProps}
|
|
152
|
+
ref={ref}
|
|
153
|
+
role="combobox"
|
|
154
|
+
onPress={() => {
|
|
155
|
+
setVisible(true);
|
|
156
|
+
}}
|
|
157
|
+
onFocus={(event: NativeSyntheticEvent<TargetedEvent>) => {
|
|
158
|
+
handleFocus(event);
|
|
159
|
+
}}
|
|
160
|
+
onBlur={(event: NativeSyntheticEvent<TargetedEvent>) => {
|
|
161
|
+
handleBlur(event);
|
|
162
|
+
}}
|
|
163
|
+
disabled={disabled}
|
|
164
|
+
style={background.style}
|
|
165
|
+
>
|
|
166
|
+
{background.element}
|
|
167
|
+
<Text
|
|
168
|
+
numberOfLines={1}
|
|
169
|
+
style={[
|
|
170
|
+
textStyle,
|
|
171
|
+
showPlaceholder && { color: placeholderTextColor },
|
|
172
|
+
]}
|
|
173
|
+
>
|
|
174
|
+
{showPlaceholder
|
|
175
|
+
? placeholder || <Text> </Text>
|
|
176
|
+
: getText({ children, selectedValue })}
|
|
177
|
+
</Text>
|
|
178
|
+
</Pressable>
|
|
179
|
+
{visible && (
|
|
180
|
+
<MenuComponent
|
|
181
|
+
selectedValue={selectedValue}
|
|
182
|
+
onValueChange={handleValueChange}
|
|
183
|
+
onClose={handleClose}
|
|
184
|
+
>
|
|
185
|
+
{children}
|
|
186
|
+
</MenuComponent>
|
|
187
|
+
)}
|
|
188
|
+
</>
|
|
189
|
+
);
|
|
190
|
+
},
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
export default PickerNative;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
type PickerNativeContextType = {
|
|
4
|
-
selectedValue?:
|
|
5
|
-
handleValueChange: (value
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const PickerNativeContext = React.createContext<PickerNativeContextType | null>(
|
|
9
|
-
null,
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
PickerNativeContext.displayName = 'PickerNativeContext';
|
|
13
|
-
|
|
14
|
-
export default PickerNativeContext;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
type PickerNativeContextType = {
|
|
4
|
+
selectedValue?: string | null | undefined;
|
|
5
|
+
handleValueChange: (value: string) => void;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const PickerNativeContext = React.createContext<PickerNativeContextType | null>(
|
|
9
|
+
null,
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
PickerNativeContext.displayName = 'PickerNativeContext';
|
|
13
|
+
|
|
14
|
+
export default PickerNativeContext;
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import StyleSheet from '../../../style/StyleSheet';
|
|
3
|
-
import css from '../../../style/css';
|
|
4
|
-
import Pressable from '../../Pressable';
|
|
5
|
-
import Text from '../../Text';
|
|
6
|
-
import useMedia from '../../../hooks/useMedia';
|
|
7
|
-
import { getStyles } from '../../../utils';
|
|
8
|
-
import useStyle from '../../../hooks/useStyle';
|
|
9
|
-
import useForcedContext from '../../../hooks/useForcedContext';
|
|
10
|
-
import PickerNativeContext from './PickerNativeContext';
|
|
11
|
-
import { ViewProps, ViewRef } from '../../View';
|
|
12
|
-
|
|
13
|
-
export interface PickerNativeItemProps extends ViewProps {
|
|
14
|
-
label: string;
|
|
15
|
-
value
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const styles = StyleSheet.create({
|
|
20
|
-
item: css`
|
|
21
|
-
margin: 0.25rem 1rem;
|
|
22
|
-
padding: 0.25rem;
|
|
23
|
-
`,
|
|
24
|
-
itemDisabled: css``,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const PickerNativeItem = React.forwardRef<ViewRef, PickerNativeItemProps>(
|
|
28
|
-
(props, ref) => {
|
|
29
|
-
const { label, value, disabled = false } = props;
|
|
30
|
-
|
|
31
|
-
const { selectedValue, handleValueChange } =
|
|
32
|
-
useForcedContext(PickerNativeContext);
|
|
33
|
-
const media = useMedia();
|
|
34
|
-
|
|
35
|
-
const classes = getStyles(styles, ['item', disabled && 'itemDisabled']);
|
|
36
|
-
|
|
37
|
-
const resolveStyle = useStyle(classes);
|
|
38
|
-
|
|
39
|
-
const selected = value === selectedValue;
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<Pressable
|
|
43
|
-
ref={ref}
|
|
44
|
-
onPress={() => {
|
|
45
|
-
handleValueChange(value);
|
|
46
|
-
}}
|
|
47
|
-
aria-selected={selected}
|
|
48
|
-
disabled={disabled}
|
|
49
|
-
style={resolveStyle({ media })}
|
|
50
|
-
>
|
|
51
|
-
<Text styleName={selected ? 'text-primary' : undefined}>{label}</Text>
|
|
52
|
-
</Pressable>
|
|
53
|
-
);
|
|
54
|
-
},
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
PickerNativeItem.displayName = 'PickerNativeItem';
|
|
58
|
-
|
|
59
|
-
export default PickerNativeItem;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import StyleSheet from '../../../style/StyleSheet';
|
|
3
|
+
import css from '../../../style/css';
|
|
4
|
+
import Pressable from '../../Pressable';
|
|
5
|
+
import Text from '../../Text';
|
|
6
|
+
import useMedia from '../../../hooks/useMedia';
|
|
7
|
+
import { getStyles } from '../../../utils';
|
|
8
|
+
import useStyle from '../../../hooks/useStyle';
|
|
9
|
+
import useForcedContext from '../../../hooks/useForcedContext';
|
|
10
|
+
import PickerNativeContext from './PickerNativeContext';
|
|
11
|
+
import { ViewProps, ViewRef } from '../../View';
|
|
12
|
+
|
|
13
|
+
export interface PickerNativeItemProps extends ViewProps {
|
|
14
|
+
label: string;
|
|
15
|
+
value: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const styles = StyleSheet.create({
|
|
20
|
+
item: css`
|
|
21
|
+
margin: 0.25rem 1rem;
|
|
22
|
+
padding: 0.25rem;
|
|
23
|
+
`,
|
|
24
|
+
itemDisabled: css``,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const PickerNativeItem = React.forwardRef<ViewRef, PickerNativeItemProps>(
|
|
28
|
+
(props, ref) => {
|
|
29
|
+
const { label, value, disabled = false } = props;
|
|
30
|
+
|
|
31
|
+
const { selectedValue, handleValueChange } =
|
|
32
|
+
useForcedContext(PickerNativeContext);
|
|
33
|
+
const media = useMedia();
|
|
34
|
+
|
|
35
|
+
const classes = getStyles(styles, ['item', disabled && 'itemDisabled']);
|
|
36
|
+
|
|
37
|
+
const resolveStyle = useStyle(classes);
|
|
38
|
+
|
|
39
|
+
const selected = value === selectedValue;
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Pressable
|
|
43
|
+
ref={ref}
|
|
44
|
+
onPress={() => {
|
|
45
|
+
handleValueChange(value);
|
|
46
|
+
}}
|
|
47
|
+
aria-selected={selected}
|
|
48
|
+
disabled={disabled}
|
|
49
|
+
style={resolveStyle({ media })}
|
|
50
|
+
>
|
|
51
|
+
<Text styleName={selected ? 'text-primary' : undefined}>{label}</Text>
|
|
52
|
+
</Pressable>
|
|
53
|
+
);
|
|
54
|
+
},
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
PickerNativeItem.displayName = 'PickerNativeItem';
|
|
58
|
+
|
|
59
|
+
export default PickerNativeItem;
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
// @ts-expect-error web only import
|
|
4
|
-
Picker as WebPicker,
|
|
5
|
-
} from 'react-native';
|
|
6
|
-
import useForcedContext from '../../../hooks/useForcedContext';
|
|
7
|
-
import PickerWebContext from './PickerWebContext';
|
|
8
|
-
import type { ViewProps, ViewRef } from '../../View';
|
|
9
|
-
|
|
10
|
-
export interface PickerWebItemProps extends ViewProps {
|
|
11
|
-
label: string;
|
|
12
|
-
value
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const PickerWebItem = React.forwardRef<ViewRef, PickerWebItemProps>(
|
|
17
|
-
(props, ref) => {
|
|
18
|
-
const { label, value, disabled = false } = props;
|
|
19
|
-
|
|
20
|
-
const { optionColor } = useForcedContext(PickerWebContext);
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<WebPicker.Item
|
|
24
|
-
ref={ref}
|
|
25
|
-
label={label}
|
|
26
|
-
value={value}
|
|
27
|
-
disabled={disabled}
|
|
28
|
-
color={optionColor}
|
|
29
|
-
/>
|
|
30
|
-
);
|
|
31
|
-
},
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
PickerWebItem.displayName = 'PickerWebItem';
|
|
35
|
-
|
|
36
|
-
export default PickerWebItem;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
// @ts-expect-error web only import
|
|
4
|
+
Picker as WebPicker,
|
|
5
|
+
} from 'react-native';
|
|
6
|
+
import useForcedContext from '../../../hooks/useForcedContext';
|
|
7
|
+
import PickerWebContext from './PickerWebContext';
|
|
8
|
+
import type { ViewProps, ViewRef } from '../../View';
|
|
9
|
+
|
|
10
|
+
export interface PickerWebItemProps extends ViewProps {
|
|
11
|
+
label: string;
|
|
12
|
+
value: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const PickerWebItem = React.forwardRef<ViewRef, PickerWebItemProps>(
|
|
17
|
+
(props, ref) => {
|
|
18
|
+
const { label, value, disabled = false } = props;
|
|
19
|
+
|
|
20
|
+
const { optionColor } = useForcedContext(PickerWebContext);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<WebPicker.Item
|
|
24
|
+
ref={ref}
|
|
25
|
+
label={label}
|
|
26
|
+
value={value}
|
|
27
|
+
disabled={disabled}
|
|
28
|
+
color={optionColor}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
},
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
PickerWebItem.displayName = 'PickerWebItem';
|
|
35
|
+
|
|
36
|
+
export default PickerWebItem;
|
|
@@ -13,7 +13,7 @@ import ListContext from '../helpers/ListContext';
|
|
|
13
13
|
import ListGroupContext from './ListGroupContext';
|
|
14
14
|
import type { ThemeVariables, UseTabbableProps } from '../../types';
|
|
15
15
|
|
|
16
|
-
export interface
|
|
16
|
+
export interface ListGroupItemActionProps
|
|
17
17
|
extends UseTabbableProps,
|
|
18
18
|
PressableProps {
|
|
19
19
|
color?: keyof typeof THEME_COLORS;
|
|
@@ -112,7 +112,7 @@ const actionStyles = StyleSheet.create({
|
|
|
112
112
|
|
|
113
113
|
const ListGroupItemAction = React.forwardRef<
|
|
114
114
|
PressableRef,
|
|
115
|
-
|
|
115
|
+
ListGroupItemActionProps
|
|
116
116
|
>((props, ref) => {
|
|
117
117
|
const [modifierProps, modifierRef] = useModifier('useTabbable', props, ref);
|
|
118
118
|
|