@ovotech/element-native 5.3.0-canary-9e22bfd-413 → 5.3.0-canary-7e7bf5d-415
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/esm/src/components/CurrencyField/CurrencyField.js +2 -2
- package/dist/esm/src/components/EmailField/EmailField.js +2 -2
- package/dist/esm/src/components/PasswordField/PasswordField.js +2 -2
- package/dist/esm/src/components/PasswordInput/PasswordInput.js +1 -1
- package/dist/esm/src/components/PhoneField/PhoneField.js +2 -2
- package/dist/esm/src/components/SegmentedControls/components/SegmentButton.js +1 -1
- package/dist/esm/src/components/SelectField/Select.js +5 -4
- package/dist/esm/src/components/SelectField/SelectField.js +1 -1
- package/dist/esm/src/components/TextField/TextField.js +2 -2
- package/dist/esm/src/components/TextInput/TextInput.js +1 -1
- package/dist/esm/src/components/TextareaField/TextareaField.js +2 -2
- package/dist/esm/src/components/Toggle/styles.js +1 -1
- package/dist/src/components/CurrencyField/CurrencyField.d.ts +1 -1
- package/dist/src/components/CurrencyField/CurrencyField.js +2 -2
- package/dist/src/components/EmailField/EmailField.d.ts +1 -1
- package/dist/src/components/EmailField/EmailField.js +2 -2
- package/dist/src/components/PasswordField/PasswordField.d.ts +1 -1
- package/dist/src/components/PasswordField/PasswordField.js +2 -2
- package/dist/src/components/PasswordInput/PasswordInput.js +1 -1
- package/dist/src/components/PhoneField/PhoneField.d.ts +1 -1
- package/dist/src/components/PhoneField/PhoneField.js +2 -2
- package/dist/src/components/SegmentedControls/components/SegmentButton.js +1 -1
- package/dist/src/components/SelectField/Select.d.ts +3 -1
- package/dist/src/components/SelectField/Select.js +5 -4
- package/dist/src/components/SelectField/SelectField.d.ts +4 -1
- package/dist/src/components/SelectField/SelectField.js +1 -1
- package/dist/src/components/TextField/TextField.d.ts +1 -1
- package/dist/src/components/TextField/TextField.js +2 -2
- package/dist/src/components/TextInput/TextInput.d.ts +5 -3
- package/dist/src/components/TextInput/TextInput.js +1 -1
- package/dist/src/components/TextareaField/TextareaField.d.ts +1 -1
- package/dist/src/components/TextareaField/TextareaField.js +2 -2
- package/dist/src/components/Toggle/styles.js +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { CurrencyInput } from '../CurrencyInput';
|
|
3
3
|
import { Field } from '../Field';
|
|
4
|
-
export const CurrencyField = ({ ...props }) => {
|
|
5
|
-
return (_jsx(Field, { affixWidth: 40, ...props, children: _jsx(CurrencyInput, { ref:
|
|
4
|
+
export const CurrencyField = ({ ref, ...props }) => {
|
|
5
|
+
return (_jsx(Field, { affixWidth: 40, ...props, children: _jsx(CurrencyInput, { ref: ref }) }));
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { EmailInput } from '../EmailInput';
|
|
3
3
|
import { Field } from '../Field';
|
|
4
|
-
export const EmailField = ({ ...rest }) => {
|
|
5
|
-
return (_jsx(Field, { ...rest, children: _jsx(EmailInput, {}) }));
|
|
4
|
+
export const EmailField = ({ ref, ...rest }) => {
|
|
5
|
+
return (_jsx(Field, { ...rest, children: _jsx(EmailInput, { ref: ref }) }));
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Field } from '../Field';
|
|
3
3
|
import { PasswordInput } from '../PasswordInput';
|
|
4
|
-
export const PasswordField = ({ hasVisibilityToggle, ...rest }) => {
|
|
5
|
-
return (_jsx(Field, { ...rest, children: _jsx(PasswordInput, { hasVisibilityToggle: hasVisibilityToggle }) }));
|
|
4
|
+
export const PasswordField = ({ hasVisibilityToggle, ref, ...rest }) => {
|
|
5
|
+
return (_jsx(Field, { ...rest, children: _jsx(PasswordInput, { ref: ref, hasVisibilityToggle: hasVisibilityToggle }) }));
|
|
6
6
|
};
|
|
@@ -3,6 +3,6 @@ import { Input } from '../Input/Input';
|
|
|
3
3
|
import { PasswordVisibilityToggle, useTogglePasswordVisibility, } from './PasswordVisibilityToggle';
|
|
4
4
|
const PasswordInput = (props) => {
|
|
5
5
|
const { isPasswordVisible, handlePasswordVisibility } = useTogglePasswordVisibility();
|
|
6
|
-
return (_jsx(Input, { rightSlot: props.hasVisibilityToggle ? (_jsx(PasswordVisibilityToggle, { iconName: isPasswordVisible ? 'hide' : 'show', visibilityToggleLabel: isPasswordVisible ? 'Hide password' : 'Show password', handlePasswordVisibility: handlePasswordVisibility })) : null, keyboardType: "default", autoCapitalize: "none", autoCorrect: false,
|
|
6
|
+
return (_jsx(Input, { rightSlot: props.hasVisibilityToggle ? (_jsx(PasswordVisibilityToggle, { iconName: isPasswordVisible ? 'hide' : 'show', visibilityToggleLabel: isPasswordVisible ? 'Hide password' : 'Show password', handlePasswordVisibility: handlePasswordVisibility })) : null, keyboardType: "default", autoCapitalize: "none", autoCorrect: false, submitBehavior: "submit", secureTextEntry: !isPasswordVisible, ...props }));
|
|
7
7
|
};
|
|
8
8
|
export { PasswordInput };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Field } from '../Field';
|
|
3
3
|
import { PhoneInput } from '../PhoneInput';
|
|
4
|
-
export const PhoneField = ({ ...props }) => {
|
|
5
|
-
return (_jsx(Field, { ...props, children: _jsx(PhoneInput, {}) }));
|
|
4
|
+
export const PhoneField = ({ ref, ...props }) => {
|
|
5
|
+
return (_jsx(Field, { ...props, children: _jsx(PhoneInput, { ref: ref }) }));
|
|
6
6
|
};
|
|
@@ -47,7 +47,7 @@ export const SegmentButton = ({ accessibilityLabel, accessibilityHint, inline, i
|
|
|
47
47
|
// choices go on the second row. The only way I could get it to work
|
|
48
48
|
// was to hardcode the denominator to 3 for the single row ones
|
|
49
49
|
// and 1.1 for the multiple row ones.
|
|
50
|
-
yRef.current = y - height / (multipleRows ?
|
|
50
|
+
yRef.current = y - height / (multipleRows ? 2.5 : 3 * fontScale);
|
|
51
51
|
heightRef.current = height;
|
|
52
52
|
widthRef.current = width;
|
|
53
53
|
onLayout(width, height, x, yRef.current);
|
|
@@ -2,7 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { numToPx } from '@ovotech/element-core';
|
|
3
3
|
import groupBy from 'lodash.groupby';
|
|
4
4
|
import { Fragment, useState } from 'react';
|
|
5
|
-
import { Dimensions, Modal, ScrollView, View } from 'react-native';
|
|
5
|
+
import { Dimensions, Modal, ScrollView, View, } from 'react-native';
|
|
6
|
+
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
6
7
|
import styled, { css } from '../../styled.native';
|
|
7
8
|
import { Icon } from '../Icon';
|
|
8
9
|
import { P } from '../P';
|
|
@@ -30,7 +31,7 @@ const DropdownWrapper = styled.TouchableOpacity(({ theme }) => css `
|
|
|
30
31
|
/* 80 is an opacity for hex https://gist.github.com/lopspower/03fb1cc0ac9f32ef38f4 */
|
|
31
32
|
background-color: ${theme.color.brand.dark}80;
|
|
32
33
|
`);
|
|
33
|
-
const DropdownContainer = styled
|
|
34
|
+
const DropdownContainer = styled(SafeAreaView)(({ theme }) => css `
|
|
34
35
|
width: 95%;
|
|
35
36
|
max-height: 70%;
|
|
36
37
|
border-radius: ${numToPx(theme.border.radius.sm)};
|
|
@@ -74,7 +75,7 @@ const StyledCategory = styled(P)(({ theme }) => css `
|
|
|
74
75
|
background-color: ${theme.color.surface.surface};
|
|
75
76
|
padding: ${numToPx(theme.space[100])} ${numToPx(theme.space[400])};
|
|
76
77
|
`);
|
|
77
|
-
export const Select = ({ options = [], defaultSelected = { label: '', value: 'default' }, noOptionMessage = 'No option selected', onSelected = () => null, hasError = false, testID = 'select', }) => {
|
|
78
|
+
export const Select = ({ options = [], defaultSelected = { label: '', value: 'default' }, noOptionMessage = 'No option selected', onSelected = () => null, hasError = false, testID = 'select', ref, }) => {
|
|
78
79
|
const [isOpen, setOpen] = useState(false);
|
|
79
80
|
const [selected, setSelected] = useState(defaultSelected);
|
|
80
81
|
const height = Dimensions.get('window').height;
|
|
@@ -89,5 +90,5 @@ export const Select = ({ options = [], defaultSelected = { label: '', value: 'de
|
|
|
89
90
|
label: `-- ${noOptionMessage} --`,
|
|
90
91
|
value: 'default',
|
|
91
92
|
};
|
|
92
|
-
return (_jsxs(View, { children: [_jsxs(SelectInput, { testID: testID, hasError: hasError, onPress: () => setOpen(!isOpen), children: [_jsx(P, { style: { marginTop: 0, marginBottom: 0 }, children: selected.value === 'default' ? '' : selected.label }), _jsx(Icon, { name: "chevron-down", size: 16, style: { marginLeft: 'auto' } })] }), _jsx(Modal, { transparent: true, visible: isOpen, animationType: "fade", onRequestClose: () => setOpen(false), children: _jsx(DropdownWrapper, { onPress: () => setOpen(false), children: _jsx(DropdownContainer, { style: { maxHeight: dropdownContainerMaxHeight }, children: _jsxs(ScrollView, { nestedScrollEnabled: true, testID: `${testID}-OptionsScrollView`, children: [_jsxs(SelectOption, { accessible: true, accessibilityRole: "radio", onPress: () => handleOptionPress(requiredOption), children: [_jsx(StyledP, { children: _jsx(Strong, { children: requiredOption.label }) }), _jsx(Radio, { isChecked: selected.value === requiredOption.value, children: _jsx(RadioDot, { isChecked: selected.value === requiredOption.value }) })] }), Object.keys(optionsByCategories).map(category => (_jsxs(Fragment, { children: [category !== 'undefined' ? (_jsx(StyledCategory, { children: category })) : null, optionsByCategories[category].map((option, i) => (_jsxs(SelectOption, { accessible: true, accessibilityRole: "radio", isLastOption: i === optionsByCategories[category].length - 1, onPress: () => handleOptionPress(option), children: [_jsx(StyledP, { children: _jsx(Strong, { children: option.label }) }), _jsx(Radio, { isChecked: selected.value === option.value, children: _jsx(RadioDot, { isChecked: selected.value === option.value }) })] }, option.label)))] }, category)))] }) }) }) })] }));
|
|
93
|
+
return (_jsxs(View, { children: [_jsxs(SelectInput, { testID: testID, hasError: hasError, onPress: () => setOpen(!isOpen), ref: ref, children: [_jsx(P, { style: { marginTop: 0, marginBottom: 0 }, children: selected.value === 'default' ? '' : selected.label }), _jsx(Icon, { name: "chevron-down", size: 16, style: { marginLeft: 'auto' } })] }), _jsx(Modal, { transparent: true, visible: isOpen, animationType: "fade", onRequestClose: () => setOpen(false), children: _jsx(DropdownWrapper, { onPress: () => setOpen(false), children: _jsx(DropdownContainer, { style: { maxHeight: dropdownContainerMaxHeight }, children: _jsxs(ScrollView, { nestedScrollEnabled: true, testID: `${testID}-OptionsScrollView`, children: [_jsxs(SelectOption, { accessible: true, accessibilityRole: "radio", onPress: () => handleOptionPress(requiredOption), children: [_jsx(StyledP, { children: _jsx(Strong, { children: requiredOption.label }) }), _jsx(Radio, { isChecked: selected.value === requiredOption.value, children: _jsx(RadioDot, { isChecked: selected.value === requiredOption.value }) })] }), Object.keys(optionsByCategories).map(category => (_jsxs(Fragment, { children: [category !== 'undefined' ? (_jsx(StyledCategory, { children: category })) : null, optionsByCategories[category].map((option, i) => (_jsxs(SelectOption, { accessible: true, accessibilityRole: "radio", isLastOption: i === optionsByCategories[category].length - 1, onPress: () => handleOptionPress(option), children: [_jsx(StyledP, { children: _jsx(Strong, { children: option.label }) }), _jsx(Radio, { isChecked: selected.value === option.value, children: _jsx(RadioDot, { isChecked: selected.value === option.value }) })] }, option.label)))] }, category)))] }) }) }) })] }));
|
|
93
94
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Field } from '../Field';
|
|
3
3
|
import { Select } from './Select';
|
|
4
|
-
export const SelectField = ({ error, options, onSelected, noOptionMessage, defaultSelected, testID, ...rest }) => (_jsx(Field, { affixWidth: 20, error: error, ...rest, children: _jsx(_Fragment, { children: _jsx(Select, { onSelected: onSelected, options: options, noOptionMessage: noOptionMessage, defaultSelected: defaultSelected, hasError: Boolean(error), testID: testID }) }) }));
|
|
4
|
+
export const SelectField = ({ error, options, onSelected, noOptionMessage, defaultSelected, testID, ref, ...rest }) => (_jsx(Field, { affixWidth: 20, error: error, ...rest, children: _jsx(_Fragment, { children: _jsx(Select, { onSelected: onSelected, options: options, noOptionMessage: noOptionMessage, defaultSelected: defaultSelected, hasError: Boolean(error), testID: testID, ref: ref }) }) }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Field } from '../Field';
|
|
3
3
|
import { TextInput } from '../TextInput';
|
|
4
|
-
export const TextField = (props) => {
|
|
5
|
-
return (_jsx(Field, { ...props, children: _jsx(TextInput, {}) }));
|
|
4
|
+
export const TextField = ({ ref, ...props }) => {
|
|
5
|
+
return (_jsx(Field, { ...props, children: _jsx(TextInput, { ref: ref }) }));
|
|
6
6
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Input } from '../Input/Input';
|
|
3
|
-
const TextInput = (props) => _jsx(Input, { ...props, keyboardType: "default", ref:
|
|
3
|
+
const TextInput = ({ ref, ...props }) => (_jsx(Input, { ...props, keyboardType: "default", ref: ref }));
|
|
4
4
|
export { TextInput };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Field } from '../Field';
|
|
3
3
|
import { TextareaInput } from '../TextareaInput';
|
|
4
|
-
export const TextareaField = ({ ...props }) => {
|
|
5
|
-
return (_jsx(Field, { ...props, children: _jsx(TextareaInput, {}) }));
|
|
4
|
+
export const TextareaField = ({ ref, ...props }) => {
|
|
5
|
+
return (_jsx(Field, { ...props, children: _jsx(TextareaInput, { ref: ref }) }));
|
|
6
6
|
};
|
|
@@ -16,7 +16,7 @@ export const StyledToggleInputWrapper = styled.View(({ theme, labelPosition }) =
|
|
|
16
16
|
? labelPosition === 'left'
|
|
17
17
|
? 'margin-left: 10px;'
|
|
18
18
|
: 'margin-right: 10px;'
|
|
19
|
-
:
|
|
19
|
+
: ''}
|
|
20
20
|
`;
|
|
21
21
|
});
|
|
22
22
|
export const StyledToggleInput = styled.View(({ theme, checked }) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CurrencyInputProps } from '../CurrencyInput';
|
|
2
2
|
import { FieldProps } from '../Field';
|
|
3
3
|
type Props = Omit<FieldProps, 'children'> & CurrencyInputProps;
|
|
4
|
-
export declare const CurrencyField: ({ ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const CurrencyField: ({ ref, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { CurrencyInput } from '../CurrencyInput';
|
|
3
3
|
import { Field } from '../Field';
|
|
4
|
-
export const CurrencyField = ({ ...props }) => {
|
|
5
|
-
return (_jsx(Field, { affixWidth: 40, ...props, children: _jsx(CurrencyInput, { ref:
|
|
4
|
+
export const CurrencyField = ({ ref, ...props }) => {
|
|
5
|
+
return (_jsx(Field, { affixWidth: 40, ...props, children: _jsx(CurrencyInput, { ref: ref }) }));
|
|
6
6
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldProps } from '../Field';
|
|
2
2
|
import { InputProps } from '../Input/Input';
|
|
3
3
|
type Props = Omit<FieldProps, 'children'> & InputProps;
|
|
4
|
-
export declare const EmailField: ({ ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const EmailField: ({ ref, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { EmailInput } from '../EmailInput';
|
|
3
3
|
import { Field } from '../Field';
|
|
4
|
-
export const EmailField = ({ ...rest }) => {
|
|
5
|
-
return (_jsx(Field, { ...rest, children: _jsx(EmailInput, {}) }));
|
|
4
|
+
export const EmailField = ({ ref, ...rest }) => {
|
|
5
|
+
return (_jsx(Field, { ...rest, children: _jsx(EmailInput, { ref: ref }) }));
|
|
6
6
|
};
|
|
@@ -3,5 +3,5 @@ import { InputProps } from '../Input/Input';
|
|
|
3
3
|
type Props = Omit<FieldProps, 'children'> & InputProps & {
|
|
4
4
|
hasVisibilityToggle?: boolean;
|
|
5
5
|
};
|
|
6
|
-
export declare const PasswordField: ({ hasVisibilityToggle, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const PasswordField: ({ hasVisibilityToggle, ref, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Field } from '../Field';
|
|
3
3
|
import { PasswordInput } from '../PasswordInput';
|
|
4
|
-
export const PasswordField = ({ hasVisibilityToggle, ...rest }) => {
|
|
5
|
-
return (_jsx(Field, { ...rest, children: _jsx(PasswordInput, { hasVisibilityToggle: hasVisibilityToggle }) }));
|
|
4
|
+
export const PasswordField = ({ hasVisibilityToggle, ref, ...rest }) => {
|
|
5
|
+
return (_jsx(Field, { ...rest, children: _jsx(PasswordInput, { ref: ref, hasVisibilityToggle: hasVisibilityToggle }) }));
|
|
6
6
|
};
|
|
@@ -3,6 +3,6 @@ import { Input } from '../Input/Input';
|
|
|
3
3
|
import { PasswordVisibilityToggle, useTogglePasswordVisibility, } from './PasswordVisibilityToggle';
|
|
4
4
|
const PasswordInput = (props) => {
|
|
5
5
|
const { isPasswordVisible, handlePasswordVisibility } = useTogglePasswordVisibility();
|
|
6
|
-
return (_jsx(Input, { rightSlot: props.hasVisibilityToggle ? (_jsx(PasswordVisibilityToggle, { iconName: isPasswordVisible ? 'hide' : 'show', visibilityToggleLabel: isPasswordVisible ? 'Hide password' : 'Show password', handlePasswordVisibility: handlePasswordVisibility })) : null, keyboardType: "default", autoCapitalize: "none", autoCorrect: false,
|
|
6
|
+
return (_jsx(Input, { rightSlot: props.hasVisibilityToggle ? (_jsx(PasswordVisibilityToggle, { iconName: isPasswordVisible ? 'hide' : 'show', visibilityToggleLabel: isPasswordVisible ? 'Hide password' : 'Show password', handlePasswordVisibility: handlePasswordVisibility })) : null, keyboardType: "default", autoCapitalize: "none", autoCorrect: false, submitBehavior: "submit", secureTextEntry: !isPasswordVisible, ...props }));
|
|
7
7
|
};
|
|
8
8
|
export { PasswordInput };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldProps } from '../Field';
|
|
2
2
|
import { InputProps } from '../Input/Input';
|
|
3
3
|
type Props = Omit<FieldProps, 'children'> & InputProps;
|
|
4
|
-
export declare const PhoneField: ({ ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const PhoneField: ({ ref, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Field } from '../Field';
|
|
3
3
|
import { PhoneInput } from '../PhoneInput';
|
|
4
|
-
export const PhoneField = ({ ...props }) => {
|
|
5
|
-
return (_jsx(Field, { ...props, children: _jsx(PhoneInput, {}) }));
|
|
4
|
+
export const PhoneField = ({ ref, ...props }) => {
|
|
5
|
+
return (_jsx(Field, { ...props, children: _jsx(PhoneInput, { ref: ref }) }));
|
|
6
6
|
};
|
|
@@ -47,7 +47,7 @@ export const SegmentButton = ({ accessibilityLabel, accessibilityHint, inline, i
|
|
|
47
47
|
// choices go on the second row. The only way I could get it to work
|
|
48
48
|
// was to hardcode the denominator to 3 for the single row ones
|
|
49
49
|
// and 1.1 for the multiple row ones.
|
|
50
|
-
yRef.current = y - height / (multipleRows ?
|
|
50
|
+
yRef.current = y - height / (multipleRows ? 2.5 : 3 * fontScale);
|
|
51
51
|
heightRef.current = height;
|
|
52
52
|
widthRef.current = width;
|
|
53
53
|
onLayout(width, height, x, yRef.current);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TouchableOpacityProps } from 'react-native';
|
|
1
2
|
type SelectOption = {
|
|
2
3
|
label: string;
|
|
3
4
|
value: string;
|
|
@@ -10,6 +11,7 @@ export type SelectProps = {
|
|
|
10
11
|
hasError?: boolean;
|
|
11
12
|
onSelected?(value: SelectOption): void;
|
|
12
13
|
testID?: string;
|
|
14
|
+
ref?: React.RefObject<TouchableOpacityProps | null>;
|
|
13
15
|
};
|
|
14
16
|
declare const SelectOption: import("styled-components").StyledComponent<typeof import("react-native").TouchableOpacity, {
|
|
15
17
|
color: {
|
|
@@ -586,5 +588,5 @@ declare const SelectOption: import("styled-components").StyledComponent<typeof i
|
|
|
586
588
|
}, {
|
|
587
589
|
isLastOption: boolean;
|
|
588
590
|
}, never>;
|
|
589
|
-
export declare const Select: ({ options, defaultSelected, noOptionMessage, onSelected, hasError, testID, }: SelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
591
|
+
export declare const Select: ({ options, defaultSelected, noOptionMessage, onSelected, hasError, testID, ref, }: SelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
590
592
|
export {};
|
|
@@ -2,7 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { numToPx } from '@ovotech/element-core';
|
|
3
3
|
import groupBy from 'lodash.groupby';
|
|
4
4
|
import { Fragment, useState } from 'react';
|
|
5
|
-
import { Dimensions, Modal, ScrollView, View } from 'react-native';
|
|
5
|
+
import { Dimensions, Modal, ScrollView, View, } from 'react-native';
|
|
6
|
+
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
6
7
|
import styled, { css } from '../../styled.native';
|
|
7
8
|
import { Icon } from '../Icon';
|
|
8
9
|
import { P } from '../P';
|
|
@@ -30,7 +31,7 @@ const DropdownWrapper = styled.TouchableOpacity(({ theme }) => css `
|
|
|
30
31
|
/* 80 is an opacity for hex https://gist.github.com/lopspower/03fb1cc0ac9f32ef38f4 */
|
|
31
32
|
background-color: ${theme.color.brand.dark}80;
|
|
32
33
|
`);
|
|
33
|
-
const DropdownContainer = styled
|
|
34
|
+
const DropdownContainer = styled(SafeAreaView)(({ theme }) => css `
|
|
34
35
|
width: 95%;
|
|
35
36
|
max-height: 70%;
|
|
36
37
|
border-radius: ${numToPx(theme.border.radius.sm)};
|
|
@@ -74,7 +75,7 @@ const StyledCategory = styled(P)(({ theme }) => css `
|
|
|
74
75
|
background-color: ${theme.color.surface.surface};
|
|
75
76
|
padding: ${numToPx(theme.space[100])} ${numToPx(theme.space[400])};
|
|
76
77
|
`);
|
|
77
|
-
export const Select = ({ options = [], defaultSelected = { label: '', value: 'default' }, noOptionMessage = 'No option selected', onSelected = () => null, hasError = false, testID = 'select', }) => {
|
|
78
|
+
export const Select = ({ options = [], defaultSelected = { label: '', value: 'default' }, noOptionMessage = 'No option selected', onSelected = () => null, hasError = false, testID = 'select', ref, }) => {
|
|
78
79
|
const [isOpen, setOpen] = useState(false);
|
|
79
80
|
const [selected, setSelected] = useState(defaultSelected);
|
|
80
81
|
const height = Dimensions.get('window').height;
|
|
@@ -89,5 +90,5 @@ export const Select = ({ options = [], defaultSelected = { label: '', value: 'de
|
|
|
89
90
|
label: `-- ${noOptionMessage} --`,
|
|
90
91
|
value: 'default',
|
|
91
92
|
};
|
|
92
|
-
return (_jsxs(View, { children: [_jsxs(SelectInput, { testID: testID, hasError: hasError, onPress: () => setOpen(!isOpen), children: [_jsx(P, { style: { marginTop: 0, marginBottom: 0 }, children: selected.value === 'default' ? '' : selected.label }), _jsx(Icon, { name: "chevron-down", size: 16, style: { marginLeft: 'auto' } })] }), _jsx(Modal, { transparent: true, visible: isOpen, animationType: "fade", onRequestClose: () => setOpen(false), children: _jsx(DropdownWrapper, { onPress: () => setOpen(false), children: _jsx(DropdownContainer, { style: { maxHeight: dropdownContainerMaxHeight }, children: _jsxs(ScrollView, { nestedScrollEnabled: true, testID: `${testID}-OptionsScrollView`, children: [_jsxs(SelectOption, { accessible: true, accessibilityRole: "radio", onPress: () => handleOptionPress(requiredOption), children: [_jsx(StyledP, { children: _jsx(Strong, { children: requiredOption.label }) }), _jsx(Radio, { isChecked: selected.value === requiredOption.value, children: _jsx(RadioDot, { isChecked: selected.value === requiredOption.value }) })] }), Object.keys(optionsByCategories).map(category => (_jsxs(Fragment, { children: [category !== 'undefined' ? (_jsx(StyledCategory, { children: category })) : null, optionsByCategories[category].map((option, i) => (_jsxs(SelectOption, { accessible: true, accessibilityRole: "radio", isLastOption: i === optionsByCategories[category].length - 1, onPress: () => handleOptionPress(option), children: [_jsx(StyledP, { children: _jsx(Strong, { children: option.label }) }), _jsx(Radio, { isChecked: selected.value === option.value, children: _jsx(RadioDot, { isChecked: selected.value === option.value }) })] }, option.label)))] }, category)))] }) }) }) })] }));
|
|
93
|
+
return (_jsxs(View, { children: [_jsxs(SelectInput, { testID: testID, hasError: hasError, onPress: () => setOpen(!isOpen), ref: ref, children: [_jsx(P, { style: { marginTop: 0, marginBottom: 0 }, children: selected.value === 'default' ? '' : selected.label }), _jsx(Icon, { name: "chevron-down", size: 16, style: { marginLeft: 'auto' } })] }), _jsx(Modal, { transparent: true, visible: isOpen, animationType: "fade", onRequestClose: () => setOpen(false), children: _jsx(DropdownWrapper, { onPress: () => setOpen(false), children: _jsx(DropdownContainer, { style: { maxHeight: dropdownContainerMaxHeight }, children: _jsxs(ScrollView, { nestedScrollEnabled: true, testID: `${testID}-OptionsScrollView`, children: [_jsxs(SelectOption, { accessible: true, accessibilityRole: "radio", onPress: () => handleOptionPress(requiredOption), children: [_jsx(StyledP, { children: _jsx(Strong, { children: requiredOption.label }) }), _jsx(Radio, { isChecked: selected.value === requiredOption.value, children: _jsx(RadioDot, { isChecked: selected.value === requiredOption.value }) })] }), Object.keys(optionsByCategories).map(category => (_jsxs(Fragment, { children: [category !== 'undefined' ? (_jsx(StyledCategory, { children: category })) : null, optionsByCategories[category].map((option, i) => (_jsxs(SelectOption, { accessible: true, accessibilityRole: "radio", isLastOption: i === optionsByCategories[category].length - 1, onPress: () => handleOptionPress(option), children: [_jsx(StyledP, { children: _jsx(Strong, { children: option.label }) }), _jsx(Radio, { isChecked: selected.value === option.value, children: _jsx(RadioDot, { isChecked: selected.value === option.value }) })] }, option.label)))] }, category)))] }) }) }) })] }));
|
|
93
94
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
1
2
|
import { FieldProps } from '../Field';
|
|
2
3
|
import { SelectProps } from './Select';
|
|
4
|
+
import { TouchableOpacityProps } from 'react-native';
|
|
3
5
|
type SelectFieldProps = SelectProps & Omit<FieldProps, 'children'> & {
|
|
4
6
|
testID?: string;
|
|
7
|
+
ref?: RefObject<TouchableOpacityProps | null>;
|
|
5
8
|
};
|
|
6
|
-
export declare const SelectField: ({ error, options, onSelected, noOptionMessage, defaultSelected, testID, ...rest }: SelectFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const SelectField: ({ error, options, onSelected, noOptionMessage, defaultSelected, testID, ref, ...rest }: SelectFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
10
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Field } from '../Field';
|
|
3
3
|
import { Select } from './Select';
|
|
4
|
-
export const SelectField = ({ error, options, onSelected, noOptionMessage, defaultSelected, testID, ...rest }) => (_jsx(Field, { affixWidth: 20, error: error, ...rest, children: _jsx(_Fragment, { children: _jsx(Select, { onSelected: onSelected, options: options, noOptionMessage: noOptionMessage, defaultSelected: defaultSelected, hasError: Boolean(error), testID: testID }) }) }));
|
|
4
|
+
export const SelectField = ({ error, options, onSelected, noOptionMessage, defaultSelected, testID, ref, ...rest }) => (_jsx(Field, { affixWidth: 20, error: error, ...rest, children: _jsx(_Fragment, { children: _jsx(Select, { onSelected: onSelected, options: options, noOptionMessage: noOptionMessage, defaultSelected: defaultSelected, hasError: Boolean(error), testID: testID, ref: ref }) }) }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldProps } from '../Field';
|
|
2
2
|
import { InputProps } from '../Input/Input';
|
|
3
3
|
type Props = Omit<FieldProps, 'children'> & InputProps;
|
|
4
|
-
export declare const TextField: (props: Props) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const TextField: ({ ref, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Field } from '../Field';
|
|
3
3
|
import { TextInput } from '../TextInput';
|
|
4
|
-
export const TextField = (props) => {
|
|
5
|
-
return (_jsx(Field, { ...props, children: _jsx(TextInput, {}) }));
|
|
4
|
+
export const TextField = ({ ref, ...props }) => {
|
|
5
|
+
return (_jsx(Field, { ...props, children: _jsx(TextInput, { ref: ref }) }));
|
|
6
6
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
1
2
|
import { TextInput as RNTextInput } from 'react-native';
|
|
2
3
|
import { InputProps } from '../Input/Input';
|
|
3
|
-
|
|
4
|
-
ref?:
|
|
5
|
-
}
|
|
4
|
+
type Props = InputProps & {
|
|
5
|
+
ref?: Ref<RNTextInput>;
|
|
6
|
+
};
|
|
7
|
+
declare const TextInput: ({ ref, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
6
8
|
export { TextInput };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Input } from '../Input/Input';
|
|
3
|
-
const TextInput = (props) => _jsx(Input, { ...props, keyboardType: "default", ref:
|
|
3
|
+
const TextInput = ({ ref, ...props }) => (_jsx(Input, { ...props, keyboardType: "default", ref: ref }));
|
|
4
4
|
export { TextInput };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldProps } from '../Field';
|
|
2
2
|
import { TextareaInputProps } from '../TextareaInput';
|
|
3
3
|
type Props = Omit<FieldProps, 'children'> & TextareaInputProps;
|
|
4
|
-
export declare const TextareaField: ({ ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const TextareaField: ({ ref, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Field } from '../Field';
|
|
3
3
|
import { TextareaInput } from '../TextareaInput';
|
|
4
|
-
export const TextareaField = ({ ...props }) => {
|
|
5
|
-
return (_jsx(Field, { ...props, children: _jsx(TextareaInput, {}) }));
|
|
4
|
+
export const TextareaField = ({ ref, ...props }) => {
|
|
5
|
+
return (_jsx(Field, { ...props, children: _jsx(TextareaInput, { ref: ref }) }));
|
|
6
6
|
};
|
|
@@ -16,7 +16,7 @@ export const StyledToggleInputWrapper = styled.View(({ theme, labelPosition }) =
|
|
|
16
16
|
? labelPosition === 'left'
|
|
17
17
|
? 'margin-left: 10px;'
|
|
18
18
|
: 'margin-right: 10px;'
|
|
19
|
-
:
|
|
19
|
+
: ''}
|
|
20
20
|
`;
|
|
21
21
|
});
|
|
22
22
|
export const StyledToggleInput = styled.View(({ theme, checked }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ovotech/element-native",
|
|
3
|
-
"version": "5.3.0-canary-
|
|
3
|
+
"version": "5.3.0-canary-7e7bf5d-415",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@backpackapp-io/react-native-toast": "^0.14.0",
|
|
17
|
-
"@ovotech/element-core": "4.2.0-canary-
|
|
17
|
+
"@ovotech/element-core": "4.2.0-canary-7e7bf5d-415",
|
|
18
18
|
"deepmerge": "^4.2.2",
|
|
19
19
|
"lodash.groupby": "^4.6.0",
|
|
20
20
|
"react-native-error-boundary": "^3.0.0",
|