@hero-design/rn 8.78.0 → 8.79.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +12 -0
- package/es/index.js +28 -16
- package/lib/index.js +28 -16
- package/package.json +1 -1
- package/src/components/BottomSheet/index.tsx +14 -15
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +1729 -0
- package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +35 -0
- package/src/components/Select/MultiSelect/index.tsx +5 -1
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +1617 -0
- package/src/components/Select/SingleSelect/__tests__/index.spec.tsx +33 -0
- package/src/components/Select/SingleSelect/index.tsx +5 -1
- package/src/components/Select/types.ts +8 -0
- package/stats/8.78.1/rn-stats.html +4842 -0
- package/stats/8.79.0/rn-stats.html +4844 -0
- package/types/components/BottomSheet/index.d.ts +1 -1
- package/types/components/Select/MultiSelect/index.d.ts +1 -1
- package/types/components/Select/SingleSelect/index.d.ts +1 -1
- package/types/components/Select/index.d.ts +1 -1
- package/types/components/Select/types.d.ts +8 -0
|
@@ -234,6 +234,39 @@ describe('rendering', () => {
|
|
|
234
234
|
|
|
235
235
|
expect(getByText('Selected: Jack')).toBeTruthy();
|
|
236
236
|
});
|
|
237
|
+
|
|
238
|
+
it('renders correct custom bottom sheet header', () => {
|
|
239
|
+
const { getByTestId, getByText } = renderWithTheme(
|
|
240
|
+
<SingleSelect
|
|
241
|
+
label="Allow notifications"
|
|
242
|
+
options={options}
|
|
243
|
+
value="mon"
|
|
244
|
+
onConfirm={jest.fn()}
|
|
245
|
+
bottomSheetConfig={{
|
|
246
|
+
header: <Typography.Body>Custom header</Typography.Body>,
|
|
247
|
+
}}
|
|
248
|
+
/>
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
fireEvent.press(getByTestId('text-input'));
|
|
252
|
+
expect(getByText('Custom header')).toBeTruthy();
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it('renders correct floating bottom sheet variant', () => {
|
|
256
|
+
const { toJSON, getByTestId, getByText } = renderWithTheme(
|
|
257
|
+
<SingleSelect
|
|
258
|
+
label="Allow notifications"
|
|
259
|
+
options={options}
|
|
260
|
+
value="mon"
|
|
261
|
+
onConfirm={jest.fn()}
|
|
262
|
+
bottomSheetConfig={{ variant: 'floating' }}
|
|
263
|
+
/>
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
fireEvent.press(getByTestId('text-input'));
|
|
267
|
+
expect(getByText('Monday')).toBeTruthy();
|
|
268
|
+
expect(toJSON()).toMatchSnapshot();
|
|
269
|
+
});
|
|
237
270
|
});
|
|
238
271
|
|
|
239
272
|
describe('behavior', () => {
|
|
@@ -59,6 +59,7 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
59
59
|
testID,
|
|
60
60
|
value,
|
|
61
61
|
supportedOrientations = ['portrait'],
|
|
62
|
+
bottomSheetConfig = {},
|
|
62
63
|
}: SingleSelectProps<V, T>) => {
|
|
63
64
|
const { isKeyboardVisible, keyboardHeight } = useKeyboard();
|
|
64
65
|
const [open, setOpen] = useState(false);
|
|
@@ -67,6 +68,8 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
67
68
|
const flatOptions = toFlatOptions(options);
|
|
68
69
|
const displayedValue = flatOptions.find((opt) => value === opt.value)?.text;
|
|
69
70
|
const rawValue = value ? String(value) : undefined;
|
|
71
|
+
const { variant: bottomSheetVariant, header: bottomSheetHeader } =
|
|
72
|
+
bottomSheetConfig;
|
|
70
73
|
|
|
71
74
|
return (
|
|
72
75
|
<>
|
|
@@ -103,12 +106,13 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
103
106
|
</TouchableOpacity>
|
|
104
107
|
</View>
|
|
105
108
|
<BottomSheet
|
|
109
|
+
variant={bottomSheetVariant || 'fixed'}
|
|
106
110
|
open={open}
|
|
107
111
|
onRequestClose={() => {
|
|
108
112
|
onDismiss?.();
|
|
109
113
|
setOpen(false);
|
|
110
114
|
}}
|
|
111
|
-
header={label}
|
|
115
|
+
header={bottomSheetHeader || label}
|
|
112
116
|
style={{
|
|
113
117
|
paddingBottom: isKeyboardVisible ? keyboardHeight : 0,
|
|
114
118
|
}}
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
StyleProp,
|
|
7
7
|
ViewStyle,
|
|
8
8
|
} from 'react-native';
|
|
9
|
+
import { BottomSheetProps } from '../BottomSheet';
|
|
9
10
|
import type { TextInputProps } from '../TextInput';
|
|
10
11
|
|
|
11
12
|
export type OptionType<V> = {
|
|
@@ -94,4 +95,11 @@ export interface SelectProps<V, T extends OptionType<V>>
|
|
|
94
95
|
* Testing id of the component.
|
|
95
96
|
*/
|
|
96
97
|
testID?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Config for the bottom sheet.
|
|
100
|
+
*/
|
|
101
|
+
bottomSheetConfig?: {
|
|
102
|
+
variant?: BottomSheetProps['variant'];
|
|
103
|
+
header?: BottomSheetProps['header'];
|
|
104
|
+
};
|
|
97
105
|
}
|