@utilitywarehouse/hearth-react-native 0.11.0 → 0.13.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 +1 -1
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +16 -0
- package/build/components/Accordion/AccordionTrigger.js +1 -1
- package/build/components/Banner/Banner.context.d.ts +7 -0
- package/build/components/Banner/Banner.context.js +8 -0
- package/build/components/Banner/Banner.js +10 -40
- package/build/components/Banner/Banner.props.d.ts +3 -5
- package/build/components/Banner/BannerIllustration.d.ts +4 -0
- package/build/components/Banner/BannerIllustration.js +53 -0
- package/build/components/Banner/BannerImage.d.ts +4 -0
- package/build/components/Banner/BannerImage.js +53 -0
- package/build/components/Banner/index.d.ts +2 -0
- package/build/components/Banner/index.js +2 -0
- package/build/components/Card/CardAction/CardAction.props.d.ts +2 -3
- package/build/components/Card/CardAction/CardActionRoot.js +1 -2
- package/build/components/Checkbox/Checkbox.js +1 -2
- package/build/components/Checkbox/Checkbox.props.d.ts +3 -3
- package/build/components/Checkbox/CheckboxImage.d.ts +2 -1
- package/build/components/Checkbox/CheckboxImage.js +8 -1
- package/build/components/Checkbox/CheckboxIndicator.js +3 -3
- package/build/components/DatePicker/DatePickerDay.js +3 -3
- package/build/components/ExpandableCard/ExpandableCard.props.d.ts +1 -2
- package/build/components/ExpandableCard/ExpandableCardTrigger.props.d.ts +4 -5
- package/build/components/ExpandableCard/ExpandableCardTriggerRoot.js +1 -14
- package/build/components/HighlightBanner/HighlightBanner.js +2 -6
- package/build/components/HighlightBanner/HighlightBanner.props.d.ts +2 -3
- package/build/components/HighlightBanner/HighlightBannerImage.d.ts +4 -0
- package/build/components/HighlightBanner/HighlightBannerImage.js +18 -0
- package/build/components/HighlightBanner/index.d.ts +1 -0
- package/build/components/HighlightBanner/index.js +1 -0
- package/build/components/Input/Input.d.ts +5 -7
- package/build/components/Input/Input.js +11 -4
- package/build/components/Input/InputField.d.ts +4 -7
- package/build/components/Input/InputField.js +6 -5
- package/build/components/List/ListItem/ListItem.props.d.ts +2 -2
- package/build/components/List/ListItem/ListItemRoot.js +1 -2
- package/build/components/Modal/Modal.js +2 -6
- package/build/components/Modal/Modal.props.d.ts +3 -2
- package/build/components/Modal/Modal.web.js +2 -6
- package/build/components/Modal/ModalImage.d.ts +4 -0
- package/build/components/Modal/ModalImage.js +18 -0
- package/build/components/Modal/index.d.ts +1 -0
- package/build/components/Modal/index.js +1 -0
- package/build/components/PillGroup/Pill.js +2 -2
- package/build/components/Radio/Radio.js +1 -2
- package/build/components/Radio/Radio.props.d.ts +3 -3
- package/build/components/Radio/RadioImage.d.ts +2 -1
- package/build/components/Radio/RadioImage.js +8 -1
- package/build/components/Radio/RadioIndicator.js +3 -3
- package/build/components/RadioCard/RadioCardIndicator.js +3 -3
- package/build/components/RadioCard/RadioCardRoot.js +3 -3
- package/build/components/Tabs/Tab.js +5 -5
- package/build/components/ToggleButton/ToggleButtonRoot.js +2 -2
- package/build/components/ToggleButtonCard/ToggleButtonCardRoot.js +3 -3
- package/build/components/UnstyledIconButton/UnstyledIconButtonRoot.js +1 -1
- package/build/components/VerificationInput/VerificationInput.d.ts +6 -0
- package/build/components/VerificationInput/VerificationInput.js +35 -0
- package/build/components/VerificationInput/VerificationInput.props.d.ts +49 -0
- package/build/components/VerificationInput/VerificationInput.props.js +1 -0
- package/build/components/VerificationInput/VerificationInputSlot.d.ts +9 -0
- package/build/components/VerificationInput/VerificationInputSlot.js +72 -0
- package/build/components/VerificationInput/index.d.ts +4 -0
- package/build/components/VerificationInput/index.js +3 -0
- package/build/components/VerificationInput/useVerificationInput.d.ts +14 -0
- package/build/components/VerificationInput/useVerificationInput.js +58 -0
- package/build/components/index.d.ts +1 -0
- package/build/components/index.js +1 -0
- package/build/utils/index.d.ts +2 -1
- package/build/utils/index.js +2 -1
- package/build/utils/isThemedImageProps.d.ts +4 -0
- package/build/utils/isThemedImageProps.js +4 -0
- package/docs/components/AllComponents.web.tsx +9 -0
- package/package.json +11 -12
- package/src/components/Accordion/Accordion.figma.tsx +23 -0
- package/src/components/Accordion/AccordionItemRoot.figma.tsx +47 -0
- package/src/components/Accordion/AccordionTrigger.tsx +1 -1
- package/src/components/Alert/Alert.figma.tsx +47 -0
- package/src/components/Avatar/Avatar.figma.tsx +33 -0
- package/src/components/Badge/Badge.figma.tsx +48 -24
- package/src/components/Banner/Banner.context.ts +11 -0
- package/src/components/Banner/Banner.docs.mdx +55 -37
- package/src/components/Banner/Banner.figma.tsx +15 -0
- package/src/components/Banner/Banner.props.ts +3 -5
- package/src/components/Banner/Banner.stories.tsx +86 -57
- package/src/components/Banner/Banner.tsx +24 -67
- package/src/components/Banner/BannerIllustration.figma.tsx +30 -0
- package/src/components/Banner/BannerIllustration.tsx +63 -0
- package/src/components/Banner/BannerImage.tsx +63 -0
- package/src/components/Banner/index.ts +2 -0
- package/src/components/BottomSheet/BottomSheetModal.figma.tsx +20 -0
- package/src/components/Button/Button.figma.tsx +60 -229
- package/src/components/Card/Card.docs.mdx +4 -4
- package/src/components/Card/Card.figma.tsx +43 -71
- package/src/components/Card/CardAction/CardAction.figma.tsx +44 -0
- package/src/components/Card/CardAction/CardAction.props.ts +2 -3
- package/src/components/Card/CardAction/CardAction.stories.tsx +5 -4
- package/src/components/Card/CardAction/CardActionRoot.tsx +4 -5
- package/src/components/Carousel/Carousel.figma.tsx +19 -0
- package/src/components/Checkbox/Checkbox.docs.mdx +23 -4
- package/src/components/Checkbox/Checkbox.figma.tsx +26 -41
- package/src/components/Checkbox/Checkbox.props.ts +3 -3
- package/src/components/Checkbox/Checkbox.stories.tsx +14 -8
- package/src/components/Checkbox/Checkbox.tsx +1 -2
- package/src/components/Checkbox/CheckboxGroup.figma.tsx +20 -0
- package/src/components/Checkbox/CheckboxImage.figma.tsx +27 -0
- package/src/components/Checkbox/CheckboxImage.tsx +8 -3
- package/src/components/Checkbox/CheckboxIndicator.tsx +3 -3
- package/src/components/Checkbox/CheckboxTileRoot.figma.tsx +32 -0
- package/src/components/CurrencyInput/CurrencyInput.figma.tsx +56 -0
- package/src/components/DateInput/DateInput.figma.tsx +75 -0
- package/src/components/DatePicker/DatePickerCalendar.figma.tsx +34 -0
- package/src/components/DatePicker/DatePickerDay.tsx +3 -3
- package/src/components/DatePickerInput/DatePickerInput.figma.tsx +62 -0
- package/src/components/DescriptionList/DescriptionList.figma.tsx +23 -0
- package/src/components/Divider/Divider.figma.tsx +23 -18
- package/src/components/ExpandableCard/ExpandableCard.docs.mdx +2 -2
- package/src/components/ExpandableCard/ExpandableCard.figma.tsx +54 -0
- package/src/components/ExpandableCard/ExpandableCard.props.ts +1 -2
- package/src/components/ExpandableCard/ExpandableCard.stories.tsx +3 -3
- package/src/components/ExpandableCard/ExpandableCardGroup.figma.tsx +23 -0
- package/src/components/ExpandableCard/ExpandableCardTrigger.props.ts +4 -5
- package/src/components/ExpandableCard/ExpandableCardTriggerRoot.tsx +2 -17
- package/src/components/FormField/FormField.figma.tsx +23 -0
- package/src/components/Helper/HelperText.figma.tsx +23 -0
- package/src/components/HighlightBanner/HighlightBanner.docs.mdx +73 -42
- package/src/components/HighlightBanner/HighlightBanner.props.ts +2 -3
- package/src/components/HighlightBanner/HighlightBanner.stories.tsx +85 -60
- package/src/components/HighlightBanner/HighlightBanner.tsx +3 -10
- package/src/components/HighlightBanner/HighlightBannerImage.tsx +20 -0
- package/src/components/HighlightBanner/index.ts +1 -0
- package/src/components/IconButton/IconButton.figma.tsx +55 -161
- package/src/components/IconContainer/IconContainer.figma.tsx +50 -0
- package/src/components/InlineLink/InlineLink.figma.tsx +33 -0
- package/src/components/Input/Input.figma.tsx +52 -110
- package/src/components/Input/Input.stories.tsx +76 -3
- package/src/components/Input/Input.tsx +110 -98
- package/src/components/Input/InputField.tsx +27 -26
- package/src/components/Label/Label.figma.tsx +24 -0
- package/src/components/Link/Link.figma.tsx +42 -0
- package/src/components/List/List.docs.mdx +15 -9
- package/src/components/List/List.figma.tsx +29 -108
- package/src/components/List/List.stories.tsx +2 -2
- package/src/components/List/ListAction/ListAction.figma.tsx +29 -0
- package/src/components/List/ListItem/ListItem.figma.tsx +40 -220
- package/src/components/List/ListItem/ListItem.props.ts +2 -2
- package/src/components/List/ListItem/ListItemLeadingContent.figma.tsx +29 -0
- package/src/components/List/ListItem/ListItemRoot.tsx +2 -3
- package/src/components/List/ListItem/ListItemTrailingContent.figma.tsx +27 -0
- package/src/components/Menu/Menu.figma.tsx +30 -0
- package/src/components/Menu/MenuItem.figma.tsx +31 -0
- package/src/components/Modal/Modal.docs.mdx +16 -4
- package/src/components/Modal/Modal.figma.tsx +56 -0
- package/src/components/Modal/Modal.props.ts +3 -2
- package/src/components/Modal/Modal.stories.tsx +2 -5
- package/src/components/Modal/Modal.tsx +2 -6
- package/src/components/Modal/Modal.web.tsx +2 -6
- package/src/components/Modal/ModalImage.tsx +20 -0
- package/src/components/Modal/index.ts +1 -0
- package/src/components/PillGroup/Pill.figma.tsx +25 -0
- package/src/components/PillGroup/Pill.tsx +3 -3
- package/src/components/PillGroup/PillGroup.figma.tsx +21 -0
- package/src/components/PillGroup/PillGroup.stories.tsx +1 -1
- package/src/components/ProgressStepper/ProgressStep.figma.tsx +30 -0
- package/src/components/ProgressStepper/ProgressStepper.figma.tsx +20 -0
- package/src/components/Radio/Radio.docs.mdx +21 -8
- package/src/components/Radio/Radio.figma.tsx +22 -42
- package/src/components/Radio/Radio.props.ts +3 -3
- package/src/components/Radio/Radio.stories.tsx +15 -11
- package/src/components/Radio/Radio.tsx +1 -2
- package/src/components/Radio/RadioGroup.figma.tsx +54 -0
- package/src/components/Radio/RadioImage.figma.tsx +27 -0
- package/src/components/Radio/RadioImage.tsx +8 -3
- package/src/components/Radio/RadioIndicator.tsx +3 -3
- package/src/components/Radio/RadioTileRoot.figma.tsx +31 -0
- package/src/components/RadioCard/RadioCardIndicator.tsx +3 -3
- package/src/components/RadioCard/RadioCardRoot.tsx +3 -3
- package/src/components/SectionHeader/SectionHeader.figma.tsx +30 -16
- package/src/components/Select/Select.figma.tsx +55 -0
- package/src/components/Select/SelectOption.figma.tsx +36 -0
- package/src/components/Spinner/Spinner.figma.tsx +20 -12
- package/src/components/Switch/Switch.figma.tsx +31 -23
- package/src/components/Tabs/Tab.tsx +5 -5
- package/src/components/Tabs/Tabs.figma.tsx +29 -0
- package/src/components/ThemedImage/ThemedImage.stories.tsx +1 -1
- package/src/components/Toast/ToastItem.figma.tsx +22 -0
- package/src/components/ToggleButton/ToggleButtonRoot.tsx +2 -2
- package/src/components/ToggleButtonCard/ToggleButtonCardRoot.tsx +3 -3
- package/src/components/UnstyledIconButton/UnstyledIconButton.figma.tsx +49 -0
- package/src/components/UnstyledIconButton/UnstyledIconButtonRoot.tsx +1 -1
- package/src/components/VerificationInput/VerificationInput.docs.mdx +68 -0
- package/src/components/VerificationInput/VerificationInput.props.ts +52 -0
- package/src/components/VerificationInput/VerificationInput.stories.tsx +140 -0
- package/src/components/VerificationInput/VerificationInput.tsx +89 -0
- package/src/components/VerificationInput/VerificationInputSlot.tsx +94 -0
- package/src/components/VerificationInput/index.ts +5 -0
- package/src/components/VerificationInput/useVerificationInput.ts +72 -0
- package/src/components/index.ts +1 -0
- package/src/utils/index.ts +2 -1
- package/src/utils/isThemedImageProps.ts +8 -0
- package/src/components/Checkbox/CheckboxIndicator.figma.tsx +0 -19
- package/src/components/Radio/RadioIndicator.figma.tsx +0 -21
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createInput } from '@gluestack-ui/input';
|
|
3
|
-
import { useState } from 'react';
|
|
3
|
+
import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
|
|
4
4
|
import { CloseSmallIcon, EyeOffSmallIcon, EyeSmallIcon, SearchMediumIcon, } from '@utilitywarehouse/hearth-react-native-icons';
|
|
5
5
|
import { useTheme } from '../../hooks';
|
|
6
6
|
import { useFormFieldContext } from '../FormField';
|
|
@@ -19,13 +19,16 @@ export const InputComponent = createInput({
|
|
|
19
19
|
export const InputSlot = InputComponent.Slot;
|
|
20
20
|
export const InputField = InputComponent.Input;
|
|
21
21
|
export const InputIcon = InputComponent.Icon;
|
|
22
|
-
const Input = ({ validationStatus = 'initial', children, disabled, focused, readonly, leadingIcon, trailingIcon, type, showPasswordToggle = true, onClear, format, loading, clearable = false, required, inBottomSheet = false, ...props }) => {
|
|
22
|
+
const Input = forwardRef(({ validationStatus = 'initial', children, disabled, focused, readonly, leadingIcon, trailingIcon, type, showPasswordToggle = true, onClear, format, loading, clearable = false, required, inBottomSheet = false, ...props }, ref) => {
|
|
23
23
|
const formFieldContext = useFormFieldContext();
|
|
24
24
|
const { disabled: formFieldDisabled } = formFieldContext;
|
|
25
25
|
const validationStatusFromContext = formFieldContext?.validationStatus ?? validationStatus;
|
|
26
26
|
const isRequired = formFieldContext?.required ?? required;
|
|
27
27
|
const [fieldType, setFieldType] = useState(type === 'password' ? 'password' : 'text');
|
|
28
28
|
const { color } = useTheme();
|
|
29
|
+
const inputRef = useRef(null);
|
|
30
|
+
// Expose TextInput methods to parent components
|
|
31
|
+
useImperativeHandle(ref, () => inputRef.current, []);
|
|
29
32
|
const shouldShowPasswordToggle = type === 'password' && showPasswordToggle;
|
|
30
33
|
const shouldShowClear = clearable && !!props?.value;
|
|
31
34
|
const toggleFieldType = () => {
|
|
@@ -43,7 +46,11 @@ const Input = ({ validationStatus = 'initial', children, disabled, focused, read
|
|
|
43
46
|
}
|
|
44
47
|
return undefined;
|
|
45
48
|
})();
|
|
46
|
-
return (_jsx(InputComponent, { ...(children ? props : {}), validationStatus: validationStatusFromContext, isInvalid: validationStatusFromContext === 'invalid', isReadOnly: readonly, isDisabled: formFieldDisabled ?? disabled, isFocused: focused, type: type, isRequired: isRequired, children: children ? (_jsx(_Fragment, { children: children })) : (_jsxs(_Fragment, { children: [!!leadingIconComponent && (_jsx(InputSlot, { children: _jsx(InputIcon, { as: leadingIconComponent }) })), _jsx(InputField
|
|
47
|
-
|
|
49
|
+
return (_jsx(InputComponent, { ...(children ? props : {}), validationStatus: validationStatusFromContext, isInvalid: validationStatusFromContext === 'invalid', isReadOnly: readonly, isDisabled: formFieldDisabled ?? disabled, isFocused: focused, type: type, isRequired: isRequired, children: children ? (_jsx(_Fragment, { children: children })) : (_jsxs(_Fragment, { children: [!!leadingIconComponent && (_jsx(InputSlot, { children: _jsx(InputIcon, { as: leadingIconComponent }) })), _jsx(InputField
|
|
50
|
+
// @ts-expect-error - ref forwarding issue
|
|
51
|
+
, {
|
|
52
|
+
// @ts-expect-error - ref forwarding issue
|
|
53
|
+
ref: inputRef, type: fieldType, inputMode: getInputMode, inBottomSheet: inBottomSheet, ...props }), shouldShowClear && (_jsx(InputSlot, { children: _jsx(UnstyledIconButton, { onPress: onClear, icon: CloseSmallIcon }) })), loading && (_jsx(InputSlot, { children: _jsx(Spinner, { size: "xs", color: color.icon.primary }) })), shouldShowPasswordToggle && (_jsx(InputSlot, { children: _jsx(UnstyledIconButton, { onPress: toggleFieldType, icon: fieldType === 'password' ? EyeSmallIcon : EyeOffSmallIcon }) })), !!trailingIcon && (_jsx(InputSlot, { children: _jsx(InputIcon, { as: trailingIcon }) }))] })) }));
|
|
54
|
+
});
|
|
48
55
|
Input.displayName = 'Input';
|
|
49
56
|
export default Input;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { TextInputProps } from 'react-native';
|
|
2
|
-
declare const InputField: {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
displayName: string;
|
|
7
|
-
};
|
|
1
|
+
import { TextInput as RNTextInput, TextInputProps } from 'react-native';
|
|
2
|
+
declare const InputField: import("react").ForwardRefExoticComponent<TextInputProps & {
|
|
3
|
+
inBottomSheet?: boolean;
|
|
4
|
+
} & import("react").RefAttributes<RNTextInput>>;
|
|
8
5
|
export default InputField;
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { BottomSheetTextInput } from '@gorhom/bottom-sheet';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
3
4
|
import { TextInput as RNTextInput } from 'react-native';
|
|
4
5
|
import { StyleSheet } from 'react-native-unistyles';
|
|
5
6
|
import { useTheme } from '../../hooks';
|
|
6
7
|
import { useInputContext } from './Input.context';
|
|
7
|
-
const InputField = ({ style, inBottomSheet = false, ...props }) => {
|
|
8
|
+
const InputField = forwardRef(({ style, inBottomSheet = false, ...props }, ref) => {
|
|
8
9
|
const { disabled, focused = false, type } = useInputContext();
|
|
9
10
|
styles.useVariants({ focused, type });
|
|
10
11
|
const { color } = useTheme();
|
|
11
12
|
if (inBottomSheet) {
|
|
12
13
|
return (
|
|
13
|
-
// @ts-expect-error - BottomSheetTextInput
|
|
14
|
-
_jsx(BottomSheetTextInput, { placeholderTextColor: color.text.secondary, selectionColor: color.
|
|
14
|
+
// @ts-expect-error - BottomSheetTextInput has incompatible event types with TextInput
|
|
15
|
+
_jsx(BottomSheetTextInput, { ref: ref, placeholderTextColor: color.text.secondary, selectionColor: color.surface.brand.default, cursorColor: color.surface.brand.default, verticalAlign: "middle", "aria-disabled": disabled, ...props, style: [styles.input, style] }));
|
|
15
16
|
}
|
|
16
|
-
return (_jsx(RNTextInput, { placeholderTextColor: color.text.secondary, selectionColor: color.
|
|
17
|
-
};
|
|
17
|
+
return (_jsx(RNTextInput, { ref: ref, placeholderTextColor: color.text.secondary, selectionColor: color.surface.brand.default, cursorColor: color.surface.brand.default, verticalAlign: "middle", "aria-disabled": disabled, ...props, style: [styles.input, style] }));
|
|
18
|
+
});
|
|
18
19
|
InputField.displayName = 'InputField';
|
|
19
20
|
const styles = StyleSheet.create(theme => ({
|
|
20
21
|
input: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import type { PressableProps, ViewProps } from 'react-native';
|
|
2
|
-
import BadgeProps from '../../Badge/Badge.props';
|
|
3
3
|
interface ListItemBaseProps extends Omit<PressableProps, 'children'> {
|
|
4
4
|
loading?: boolean;
|
|
5
5
|
disabled?: boolean;
|
|
@@ -23,7 +23,7 @@ export interface ListItemWithoutChildren extends ListItemBaseProps {
|
|
|
23
23
|
leadingContent?: ViewProps['children'];
|
|
24
24
|
trailingContent?: ViewProps['children'];
|
|
25
25
|
numericValue?: string | number;
|
|
26
|
-
badge?:
|
|
26
|
+
badge?: ReactNode;
|
|
27
27
|
badgePosition?: 'top' | 'bottom';
|
|
28
28
|
}
|
|
29
29
|
type ListItemProps = ListItemWithChildren | ListItemWithoutChildren;
|
|
@@ -3,7 +3,6 @@ import { ChevronRightSmallIcon } from '@utilitywarehouse/hearth-react-native-ico
|
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { Pressable } from 'react-native';
|
|
5
5
|
import { StyleSheet } from 'react-native-unistyles';
|
|
6
|
-
import { Badge } from '../../Badge';
|
|
7
6
|
import { DetailText } from '../../DetailText';
|
|
8
7
|
import { Skeleton } from '../../Skeleton';
|
|
9
8
|
import { useListContext } from '../List.context';
|
|
@@ -53,7 +52,7 @@ const ListItemRoot = ({ heading, helperText, leadingContent, trailingContent, di
|
|
|
53
52
|
if (loading || listContext?.loading) {
|
|
54
53
|
return (_jsxs(Pressable, { ...props, testID: loadingTestID, style: [styles.container, props.style], disabled: isDisabled, children: [leadingContent ? _jsx(Skeleton, { width: 24, height: 24 }) : null, _jsxs(ListItemContent, { children: [_jsx(Skeleton, { width: "80%", height: 20 }), _jsx(Skeleton, { width: "100%", height: 16 })] }), onPress || trailingContent ? _jsx(Skeleton, { width: 24, height: 24 }) : null] }));
|
|
55
54
|
}
|
|
56
|
-
return (_jsx(ListItemContext.Provider, { value: value, children: _jsx(Pressable, { ...props, testID: testID, style: [styles.container, props.style], disabled: isDisabled, accessibilityRole: onPress ? 'button' : undefined, children: children ? (children) : (_jsxs(_Fragment, { children: [leadingContent ? (_jsx(ListItemLeadingContent, { children: leadingContent })) : null, _jsxs(ListItemContent, { children: [badgePosition === 'top' && badge ?
|
|
55
|
+
return (_jsx(ListItemContext.Provider, { value: value, children: _jsx(Pressable, { ...props, testID: testID, style: [styles.container, props.style], disabled: isDisabled, accessibilityRole: onPress ? 'button' : undefined, children: children ? (children) : (_jsxs(_Fragment, { children: [leadingContent ? (_jsx(ListItemLeadingContent, { children: leadingContent })) : null, _jsxs(ListItemContent, { children: [badgePosition === 'top' && badge ? badge : null, _jsx(ListItemText, { children: heading }), helperText ? _jsx(ListItemHelperText, { children: helperText }) : null, badgePosition === 'bottom' && badge ? badge : null] }), !!numericValue && _jsx(DetailText, { size: "lg", children: numericValue }), trailingContent ? (_jsx(ListItemTrailingContent, { children: trailingContent })) : onPress ? (_jsx(ListItemTrailingContent, { style: styles.centeredTrailingIcon, children: _jsx(ListItemTrailingIcon, { as: ChevronRightSmallIcon }) })) : null] })) }) }));
|
|
57
56
|
};
|
|
58
57
|
ListItemRoot.displayName = 'ListItemRoot';
|
|
59
58
|
const styles = StyleSheet.create(theme => ({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { CloseMediumIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
3
3
|
import { useCallback, useEffect, useImperativeHandle, useRef } from 'react';
|
|
4
|
-
import { AccessibilityInfo,
|
|
4
|
+
import { AccessibilityInfo, Platform, View, findNodeHandle } from 'react-native';
|
|
5
5
|
import Animated, { Easing, useAnimatedStyle, useSharedValue, withDelay, withTiming, } from 'react-native-reanimated';
|
|
6
6
|
import { StyleSheet } from 'react-native-unistyles';
|
|
7
7
|
import { useTheme } from '../../hooks';
|
|
@@ -98,7 +98,7 @@ const Modal = ({ ref, children, heading, description, showCloseButton = true, pr
|
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
styles.useVariants({ loading });
|
|
101
|
-
const content = (_jsx(_Fragment, { children: loading ? (_jsxs(View, { style: styles.loadingContainer, accessible: Platform.OS === 'android' ? true : undefined, accessibilityLabel: Platform.OS === 'android' ? 'Loading' : undefined, screenReaderFocusable: true, ref: viewRef, children: [_jsx(Spinner, { size: "lg" }), _jsx(Heading, { size: "lg", textAlign: "center", children: "Loading..." })] })) : (_jsxs(View, { style: styles.container, accessible: Platform.OS === 'android' ? true : undefined, accessibilityLabel: Platform.OS === 'android' ? 'Modal content' : undefined, screenReaderFocusable: true, ref: viewRef, children: [_jsxs(View, { style: styles.header, children: [_jsxs(View, { style: styles.headerTextContent, children: [heading && !image ? (_jsx(Heading, { size: "lg", accessible: true, children: heading })) : null, description && !image ? _jsx(BodyText, { accessible: true, children: description }) : null] }), showCloseButton ? (_jsx(UnstyledIconButton, { icon: CloseMediumIcon, onPress: handleCloseButtonPress, accessibilityLabel: "Close modal", ...closeButtonProps })) : null] }), image ? (_jsxs(View, { style: styles.imageContainer, children: [
|
|
101
|
+
const content = (_jsx(_Fragment, { children: loading ? (_jsxs(View, { style: styles.loadingContainer, accessible: Platform.OS === 'android' ? true : undefined, accessibilityLabel: Platform.OS === 'android' ? 'Loading' : undefined, screenReaderFocusable: true, ref: viewRef, children: [_jsx(Spinner, { size: "lg" }), _jsx(Heading, { size: "lg", textAlign: "center", children: "Loading..." })] })) : (_jsxs(View, { style: styles.container, accessible: Platform.OS === 'android' ? true : undefined, accessibilityLabel: Platform.OS === 'android' ? 'Modal content' : undefined, screenReaderFocusable: true, ref: viewRef, children: [_jsxs(View, { style: styles.header, children: [_jsxs(View, { style: styles.headerTextContent, children: [heading && !image ? (_jsx(Heading, { size: "lg", accessible: true, children: heading })) : null, description && !image ? _jsx(BodyText, { accessible: true, children: description }) : null] }), showCloseButton ? (_jsx(UnstyledIconButton, { icon: CloseMediumIcon, onPress: handleCloseButtonPress, accessibilityLabel: "Close modal", ...closeButtonProps })) : null] }), image ? (_jsxs(View, { style: styles.imageContainer, children: [image, _jsxs(View, { style: styles.textContent, children: [heading ? (_jsx(Heading, { size: "lg", textAlign: "center", accessible: true, children: heading })) : null, description ? (_jsx(BodyText, { textAlign: "center", accessible: true, children: description })) : null] })] })) : null, children, _jsxs(View, { style: styles.footer, children: [onPressPrimaryButton && primaryButtonText ? (_jsx(Button, { onPress: handlePrimaryButtonPress, text: primaryButtonText, ...primaryButtonProps, variant: primaryButtonProps?.variant ?? 'solid', colorScheme: primaryButtonProps?.colorScheme ?? 'highlight' })) : null, onPressSecondaryButton && secondaryButtonText ? (_jsx(Button, { onPress: handleSecondaryButtonPress, text: secondaryButtonText, ...secondaryButtonProps, variant: secondaryButtonProps?.variant ?? 'outline', colorScheme: secondaryButtonProps?.colorScheme ?? 'functional' })) : null] })] })) }));
|
|
102
102
|
return inNavModal ? (_jsxs(View, { style: { flex: 1, backgroundColor: theme.color.background.primary }, children: [Platform.OS === 'android' ? (_jsx(Animated.View, { style: [styles.androidContainer, animatedBackgroundStyle], children: _jsx(Animated.View, { style: [styles.pretendContent, animatedPretendContentStyle] }) })) : null, _jsx(Animated.View, { style: [styles.inNavModalContainer, Platform.OS === 'android' && animatedInNavModalStyle], children: _jsx(View, { style: styles.inNavModalContent, children: content }) })] })) : (_jsxs(BottomSheetModal, { ref: bottomSheetModalRef, enableDynamicSizing: true, snapPoints: image || fullscreen ? ['90%'] : props.snapPoints, showHandle: typeof loading !== 'undefined' && loading ? false : props.showHandle, accessible: false, style: styles.modal, ...props, onChange: handleChange, children: [loading ? _jsx(View, { style: styles.loadingTop }) : null, _jsx(BottomSheetScrollView, { contentContainerStyle: styles.container, ref: scrollViewRef, children: content })] }));
|
|
103
103
|
};
|
|
104
104
|
const styles = StyleSheet.create((theme, rt) => ({
|
|
@@ -124,10 +124,6 @@ const styles = StyleSheet.create((theme, rt) => ({
|
|
|
124
124
|
flex: 1,
|
|
125
125
|
gap: theme.components.modal.content.gap,
|
|
126
126
|
},
|
|
127
|
-
image: {
|
|
128
|
-
width: 260,
|
|
129
|
-
height: 260,
|
|
130
|
-
},
|
|
131
127
|
imageContainer: {
|
|
132
128
|
alignItems: 'center',
|
|
133
129
|
flex: 1,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ViewProps } from 'react-native';
|
|
2
3
|
import { BottomSheetProps } from '../BottomSheet';
|
|
3
4
|
import { ButtonWithoutChildrenProps } from '../Button/Button.props';
|
|
4
5
|
import { UnstyledIconButtonProps } from '../UnstyledIconButton';
|
|
5
6
|
interface ModalProps extends Omit<BottomSheetProps, 'children'> {
|
|
6
7
|
loading?: boolean;
|
|
7
|
-
image?:
|
|
8
|
+
image?: ReactNode;
|
|
8
9
|
showCloseButton?: boolean;
|
|
9
10
|
heading?: string;
|
|
10
11
|
description?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { CloseMediumIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
3
3
|
import { useCallback, useEffect, useImperativeHandle, useRef } from 'react';
|
|
4
|
-
import { AccessibilityInfo,
|
|
4
|
+
import { AccessibilityInfo, Platform, View, findNodeHandle } from 'react-native';
|
|
5
5
|
import Animated, { Easing, useAnimatedStyle, useSharedValue, withDelay, withTiming, } from 'react-native-reanimated';
|
|
6
6
|
import { StyleSheet } from 'react-native-unistyles';
|
|
7
7
|
import { useTheme } from '../../hooks';
|
|
@@ -97,7 +97,7 @@ const Modal = ({ ref, children, heading, description, showCloseButton = true, pr
|
|
|
97
97
|
bottomSheetModalRef.current?.dismiss();
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
|
-
const content = (_jsx(_Fragment, { children: loading ? (_jsxs(View, { style: styles.loadingContainer, accessible: Platform.OS === 'android' ? true : undefined, accessibilityLabel: Platform.OS === 'android' ? 'Loading' : undefined, screenReaderFocusable: true, ref: viewRef, children: [_jsx(Spinner, { size: "lg" }), _jsx(Heading, { size: "lg", textAlign: "center", children: "Loading..." })] })) : (_jsxs(View, { style: styles.container, accessible: Platform.OS === 'android' ? true : undefined, accessibilityLabel: Platform.OS === 'android' ? 'Modal content' : undefined, screenReaderFocusable: true, ref: viewRef, children: [_jsxs(View, { style: styles.header, children: [_jsxs(View, { style: styles.headerTextContent, children: [heading && !image ? (_jsx(Heading, { size: "lg", accessible: true, children: heading })) : null, description && !image ? _jsx(BodyText, { accessible: true, children: description }) : null] }), showCloseButton ? (_jsx(UnstyledIconButton, { icon: CloseMediumIcon, onPress: handleCloseButtonPress, accessibilityLabel: "Close modal", ...closeButtonProps })) : null] }), image ? (_jsxs(View, { style: styles.imageContainer, children: [
|
|
100
|
+
const content = (_jsx(_Fragment, { children: loading ? (_jsxs(View, { style: styles.loadingContainer, accessible: Platform.OS === 'android' ? true : undefined, accessibilityLabel: Platform.OS === 'android' ? 'Loading' : undefined, screenReaderFocusable: true, ref: viewRef, children: [_jsx(Spinner, { size: "lg" }), _jsx(Heading, { size: "lg", textAlign: "center", children: "Loading..." })] })) : (_jsxs(View, { style: styles.container, accessible: Platform.OS === 'android' ? true : undefined, accessibilityLabel: Platform.OS === 'android' ? 'Modal content' : undefined, screenReaderFocusable: true, ref: viewRef, children: [_jsxs(View, { style: styles.header, children: [_jsxs(View, { style: styles.headerTextContent, children: [heading && !image ? (_jsx(Heading, { size: "lg", accessible: true, children: heading })) : null, description && !image ? _jsx(BodyText, { accessible: true, children: description }) : null] }), showCloseButton ? (_jsx(UnstyledIconButton, { icon: CloseMediumIcon, onPress: handleCloseButtonPress, accessibilityLabel: "Close modal", ...closeButtonProps })) : null] }), image ? (_jsxs(View, { style: styles.imageContainer, children: [image, _jsxs(View, { style: styles.textContent, children: [heading ? (_jsx(Heading, { size: "lg", textAlign: "center", accessible: true, children: heading })) : null, description ? (_jsx(BodyText, { textAlign: "center", accessible: true, children: description })) : null] })] })) : null, children, _jsxs(View, { style: styles.footer, children: [onPressPrimaryButton && primaryButtonText ? (_jsx(Button, { onPress: handlePrimaryButtonPress, text: primaryButtonText, ...primaryButtonProps, variant: primaryButtonProps?.variant ?? 'solid', colorScheme: primaryButtonProps?.colorScheme ?? 'highlight' })) : null, onPressSecondaryButton && secondaryButtonText ? (_jsx(Button, { onPress: handleSecondaryButtonPress, text: secondaryButtonText, ...secondaryButtonProps, variant: secondaryButtonProps?.variant ?? 'outline', colorScheme: secondaryButtonProps?.colorScheme ?? 'functional' })) : null] })] })) }));
|
|
101
101
|
return inNavModal ? (_jsxs(View, { style: { flex: 1, backgroundColor: theme.color.background.primary }, children: [Platform.OS === 'android' ? (_jsx(Animated.View, { style: [styles.androidContainer, animatedBackgroundStyle], children: _jsx(Animated.View, { style: [styles.pretendContent, animatedPretendContentStyle] }) })) : null, _jsx(Animated.View, { style: [styles.inNavModalContainer, Platform.OS === 'android' && animatedInNavModalStyle], children: _jsx(View, { style: styles.inNavModalContent, children: content }) })] })) : (_jsx(BottomSheetModal, { ref: bottomSheetModalRef, enableDynamicSizing: true, snapPoints: image ? ['90%'] : props.snapPoints, showHandle: typeof loading !== 'undefined' && loading ? false : props.showHandle, accessible: false, ...props, onChange: handleChange, children: _jsx(BottomSheetScrollView, { contentContainerStyle: styles.container, ref: scrollViewRef, children: content }) }));
|
|
102
102
|
};
|
|
103
103
|
const styles = StyleSheet.create((theme, rt) => ({
|
|
@@ -113,10 +113,6 @@ const styles = StyleSheet.create((theme, rt) => ({
|
|
|
113
113
|
flex: 1,
|
|
114
114
|
gap: theme.components.modal.content.gap,
|
|
115
115
|
},
|
|
116
|
-
image: {
|
|
117
|
-
width: 260,
|
|
118
|
-
height: 260,
|
|
119
|
-
},
|
|
120
116
|
imageContainer: {
|
|
121
117
|
alignItems: 'center',
|
|
122
118
|
justifyContent: 'center',
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Image } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
import { isThemedImageProps } from '../../utils';
|
|
5
|
+
import { ThemedImage } from '../ThemedImage';
|
|
6
|
+
const ModalImage = (props) => {
|
|
7
|
+
if (isThemedImageProps(props)) {
|
|
8
|
+
return _jsx(ThemedImage, { ...props, style: [styles.image, props.style] });
|
|
9
|
+
}
|
|
10
|
+
return _jsx(Image, { resizeMode: "cover", ...props, style: [styles.image, props.style] });
|
|
11
|
+
};
|
|
12
|
+
const styles = StyleSheet.create({
|
|
13
|
+
image: {
|
|
14
|
+
width: 260,
|
|
15
|
+
height: 260,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
export default ModalImage;
|
|
@@ -2,8 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { createPressable } from '@gluestack-ui/pressable';
|
|
3
3
|
import { Pressable } from 'react-native';
|
|
4
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
-
import { Icon } from '../Icon';
|
|
6
5
|
import { BodyText } from '../BodyText';
|
|
6
|
+
import { Icon } from '../Icon';
|
|
7
7
|
import { usePillGroupContext } from './PillGroup.context';
|
|
8
8
|
const PillRoot = ({ value, label, icon, states = {}, ...props }) => {
|
|
9
9
|
const { active } = states;
|
|
@@ -35,7 +35,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
35
35
|
_hover: {
|
|
36
36
|
backgroundColor: theme.color.interactive.neutral.surface.subtle.hover,
|
|
37
37
|
},
|
|
38
|
-
'_focus-visible': theme.helpers.focusVisible,
|
|
38
|
+
// '_focus-visible': theme.helpers.focusVisible,
|
|
39
39
|
},
|
|
40
40
|
variants: {
|
|
41
41
|
active: {
|
|
@@ -8,7 +8,6 @@ import StyledRadio from './RadioRoot';
|
|
|
8
8
|
import { useFormFieldContext } from '../FormField';
|
|
9
9
|
import { Helper } from '../Helper';
|
|
10
10
|
import { useRadioGroupContext } from './RadioGroup.context';
|
|
11
|
-
import RadioImage from './RadioImage';
|
|
12
11
|
import RadioTextContent from './RadioTextContent';
|
|
13
12
|
import RadioTileRoot from './RadioTileRoot';
|
|
14
13
|
const RadioComponent = createRadio({
|
|
@@ -31,7 +30,7 @@ const Radio = ({ children, label, disabled, helperIcon, helperText, invalidText,
|
|
|
31
30
|
const { validationStatus: groupValidationStatus, type: groupType } = useRadioGroupContext();
|
|
32
31
|
const validationStatus = fieldValidationStatus ?? groupValidationStatus ?? validation ?? 'initial';
|
|
33
32
|
const radioType = groupType ?? type;
|
|
34
|
-
const radioChildren = children ? (children) : (_jsxs(_Fragment, { children: [_jsx(RadioIndicator, { children: _jsx(RadioIcon, {}) }), image ?
|
|
33
|
+
const radioChildren = children ? (children) : (_jsxs(_Fragment, { children: [_jsx(RadioIndicator, { children: _jsx(RadioIcon, {}) }), image ? image : null, _jsxs(RadioTextContent, { children: [!!label && _jsx(RadioLabel, { children: label }), !!helperText && _jsx(Helper, { disabled: disabled, icon: helperIcon, text: helperText }), validationStatus === 'invalid' && !!invalidText && (_jsx(Helper, { showIcon: showValidationIcon, disabled: disabled, validationStatus: "invalid", text: invalidText })), validationStatus === 'valid' && !!validText && (_jsx(Helper, { disabled: disabled, showIcon: showValidationIcon, validationStatus: "valid", text: validText }))] })] }));
|
|
35
34
|
return (_jsx(RadioComponent, { ...props, isDisabled: disabled, children: radioType === 'tile' ? _jsx(RadioTileRoot, { children: radioChildren }) : radioChildren }));
|
|
36
35
|
};
|
|
37
36
|
const RadioTile = ({ type = 'tile', ...props }) => _jsx(Radio, { ...props, type: type });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ComponentType } from 'react';
|
|
2
|
-
import type {
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import type { PressableProps, ViewProps } from 'react-native';
|
|
3
3
|
interface RadioBaseProps extends Omit<PressableProps, 'children'> {
|
|
4
4
|
value: string;
|
|
5
5
|
onChange?: (isSelected: boolean) => void;
|
|
@@ -25,7 +25,7 @@ interface RadioWithoutChildrenProps extends RadioBaseProps {
|
|
|
25
25
|
invalidText?: string;
|
|
26
26
|
validText?: string;
|
|
27
27
|
showValidationIcon?: boolean;
|
|
28
|
-
image?:
|
|
28
|
+
image?: ReactNode;
|
|
29
29
|
}
|
|
30
30
|
type RadioProps = RadioWithChildrenProps | RadioWithoutChildrenProps;
|
|
31
31
|
export default RadioProps;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ImageProps } from 'react-native';
|
|
2
|
+
import { ThemedImageProps } from '../ThemedImage';
|
|
2
3
|
declare const RadioImage: {
|
|
3
|
-
({
|
|
4
|
+
({ ...props }: ImageProps | ThemedImageProps): import("react/jsx-runtime").JSX.Element;
|
|
4
5
|
displayName: string;
|
|
5
6
|
};
|
|
6
7
|
export default RadioImage;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Image } from 'react-native';
|
|
3
|
-
|
|
3
|
+
import { isThemedImageProps } from '../../utils';
|
|
4
|
+
import { ThemedImage } from '../ThemedImage';
|
|
5
|
+
const RadioImage = ({ ...props }) => {
|
|
6
|
+
if (isThemedImageProps(props)) {
|
|
7
|
+
return _jsx(ThemedImage, { ...props });
|
|
8
|
+
}
|
|
9
|
+
return _jsx(Image, { ...props });
|
|
10
|
+
};
|
|
4
11
|
RadioImage.displayName = 'RadioImage';
|
|
5
12
|
export default RadioImage;
|
|
@@ -30,9 +30,9 @@ const styles = StyleSheet.create(theme => ({
|
|
|
30
30
|
_hover: {
|
|
31
31
|
outlineColor: theme.components.radio.outlineColorHover,
|
|
32
32
|
},
|
|
33
|
-
'_focus-within': {
|
|
34
|
-
|
|
35
|
-
},
|
|
33
|
+
// '_focus-within': {
|
|
34
|
+
// ...theme.helpers.focusVisible,
|
|
35
|
+
// },
|
|
36
36
|
_active: {
|
|
37
37
|
outlineColor: theme.components.radio.outlineColorActive,
|
|
38
38
|
},
|
|
@@ -30,9 +30,9 @@ const styles = StyleSheet.create(theme => ({
|
|
|
30
30
|
_hover: {
|
|
31
31
|
outlineColor: theme.components.radio.outlineColorHover,
|
|
32
32
|
},
|
|
33
|
-
'_focus-within': {
|
|
34
|
-
|
|
35
|
-
},
|
|
33
|
+
// '_focus-within': {
|
|
34
|
+
// ...theme.helpers.focusVisible,
|
|
35
|
+
// },
|
|
36
36
|
_active: {
|
|
37
37
|
outlineColor: theme.components.radio.outlineColorActive,
|
|
38
38
|
},
|
|
@@ -38,11 +38,11 @@ const styles = StyleSheet.create(theme => ({
|
|
|
38
38
|
_hover: {
|
|
39
39
|
backgroundColor: theme.color.interactive.neutral.surface.subtle.hover,
|
|
40
40
|
},
|
|
41
|
-
'_focus-visible': {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
},
|
|
41
|
+
// '_focus-visible': {
|
|
42
|
+
// ...theme.helpers.focusVisible,
|
|
43
|
+
// outlineOffset: -2,
|
|
44
|
+
// borderRadius: theme.borderRadius.sm,
|
|
45
|
+
// },
|
|
46
46
|
_active: {
|
|
47
47
|
backgroundColor: theme.color.interactive.neutral.surface.subtle.active,
|
|
48
48
|
},
|
|
@@ -7,7 +7,7 @@ const ButtonRoot = ({ children, onToggle, toggled, states, onPress, ...props })
|
|
|
7
7
|
const { pressed } = useCardPressHandlerContext();
|
|
8
8
|
styles.useVariants({
|
|
9
9
|
toggled,
|
|
10
|
-
active
|
|
10
|
+
active,
|
|
11
11
|
});
|
|
12
12
|
const handlePress = (e) => {
|
|
13
13
|
onPress?.(e);
|
|
@@ -34,7 +34,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
34
34
|
borderColor: theme.color.interactive.neutral.border.subtle,
|
|
35
35
|
height: theme.components.toggleButton.height,
|
|
36
36
|
_web: {
|
|
37
|
-
'_focus-visible': theme.helpers.focusVisible,
|
|
37
|
+
// '_focus-visible': theme.helpers.focusVisible,
|
|
38
38
|
_hover: {
|
|
39
39
|
backgroundColor: theme.color.interactive.neutral.surface.subtle.hover,
|
|
40
40
|
},
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import VerificationInputProps from './VerificationInput.props';
|
|
2
|
+
declare const VerificationInput: {
|
|
3
|
+
({ value, onChangeText, label, helperText, helperIcon, validationStatus, validText, invalidText, disabled, readonly, secureTextEntry, style, ...props }: VerificationInputProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
|
6
|
+
export default VerificationInput;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
import { FormField } from '../FormField';
|
|
5
|
+
import { useVerificationInput } from './useVerificationInput';
|
|
6
|
+
import { VerificationInputSlot } from './VerificationInputSlot';
|
|
7
|
+
const VerificationInput = ({ value = '', onChangeText, label, helperText, helperIcon, validationStatus = 'initial', validText, invalidText, disabled = false, readonly = false, secureTextEntry = false, style, ...props }) => {
|
|
8
|
+
const length = 6;
|
|
9
|
+
const { inputRefs, focusedIndex, handleFocus, handleBlur, handleChangeText, handleKeyPress } = useVerificationInput({
|
|
10
|
+
value,
|
|
11
|
+
onChangeText,
|
|
12
|
+
});
|
|
13
|
+
const slots = Array.from({ length }, (_, index) => index);
|
|
14
|
+
return (_jsx(FormField, { label: label, helperText: helperText, helperIcon: helperIcon, validationStatus: validationStatus, validText: validText, invalidText: invalidText, disabled: disabled, readonly: readonly, style: [styles.root, style], ...props, children: _jsx(View, { style: styles.slotsContainer, children: slots.map(index => {
|
|
15
|
+
const char = value[index] || '';
|
|
16
|
+
const isActive = focusedIndex === index;
|
|
17
|
+
return (_jsx(VerificationInputSlot, { ref: ref => {
|
|
18
|
+
inputRefs.current[index] = ref;
|
|
19
|
+
}, value: char, isActive: isActive, validationStatus: validationStatus, disabled: disabled, readonly: readonly, secureTextEntry: secureTextEntry, onChangeText: text => handleChangeText(text, index), onKeyPress: e => handleKeyPress(e, index), onFocus: () => handleFocus(index), onBlur: handleBlur }, index));
|
|
20
|
+
}) }) }));
|
|
21
|
+
};
|
|
22
|
+
const styles = StyleSheet.create(theme => ({
|
|
23
|
+
root: {
|
|
24
|
+
gap: theme.components.input.verification.gap,
|
|
25
|
+
width: '100%',
|
|
26
|
+
maxWidth: theme.components.input.maxWidth,
|
|
27
|
+
},
|
|
28
|
+
slotsContainer: {
|
|
29
|
+
flexDirection: 'row',
|
|
30
|
+
gap: theme.components.input.verification.gap,
|
|
31
|
+
width: '100%',
|
|
32
|
+
},
|
|
33
|
+
}));
|
|
34
|
+
VerificationInput.displayName = 'VerificationInput';
|
|
35
|
+
export default VerificationInput;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import { ViewProps } from 'react-native';
|
|
3
|
+
export interface VerificationInputProps extends ViewProps {
|
|
4
|
+
/**
|
|
5
|
+
* The value of the input.
|
|
6
|
+
*/
|
|
7
|
+
value?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Callback when the value changes.
|
|
10
|
+
*/
|
|
11
|
+
onChangeText?: (text: string) => void;
|
|
12
|
+
/**
|
|
13
|
+
* The label for the input.
|
|
14
|
+
*/
|
|
15
|
+
label?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Helper text to display below the input.
|
|
18
|
+
*/
|
|
19
|
+
helperText?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Icon to display alongside the helper text.
|
|
22
|
+
*/
|
|
23
|
+
helperIcon?: ComponentType;
|
|
24
|
+
/**
|
|
25
|
+
* The validation status of the input.
|
|
26
|
+
*/
|
|
27
|
+
validationStatus?: 'initial' | 'valid' | 'invalid';
|
|
28
|
+
/**
|
|
29
|
+
* Text to display when validation status is 'valid'.
|
|
30
|
+
*/
|
|
31
|
+
validText?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Text to display when validation status is 'invalid'.
|
|
34
|
+
*/
|
|
35
|
+
invalidText?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Whether the input is disabled.
|
|
38
|
+
*/
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the input is read-only.
|
|
42
|
+
*/
|
|
43
|
+
readonly?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether to obscure the text entry (e.g. for passwords/OTPs).
|
|
46
|
+
*/
|
|
47
|
+
secureTextEntry?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export default VerificationInputProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TextInput, TextInputProps } from 'react-native';
|
|
2
|
+
interface VerificationInputSlotProps extends TextInputProps {
|
|
3
|
+
isActive: boolean;
|
|
4
|
+
validationStatus: 'initial' | 'valid' | 'invalid';
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
readonly?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const VerificationInputSlot: import("react").ForwardRefExoticComponent<VerificationInputSlotProps & import("react").RefAttributes<TextInput>>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
import InputField from '../Input/InputField';
|
|
5
|
+
export const VerificationInputSlot = forwardRef(({ isActive, validationStatus, disabled, readonly, style, ...props }, ref) => {
|
|
6
|
+
styles.useVariants({
|
|
7
|
+
disabled,
|
|
8
|
+
readonly,
|
|
9
|
+
validationStatus,
|
|
10
|
+
active: isActive,
|
|
11
|
+
});
|
|
12
|
+
return (_jsx(InputField, { ref: ref, ...props, editable: !disabled && !readonly, selectTextOnFocus: true, keyboardType: "number-pad", style: [styles.slot, style] }));
|
|
13
|
+
});
|
|
14
|
+
VerificationInputSlot.displayName = 'VerificationInputSlot';
|
|
15
|
+
const styles = StyleSheet.create(theme => ({
|
|
16
|
+
slot: {
|
|
17
|
+
flex: 0,
|
|
18
|
+
width: theme.components.input.height,
|
|
19
|
+
height: theme.components.input.height,
|
|
20
|
+
borderWidth: theme.components.input.borderWidth,
|
|
21
|
+
borderColor: theme.color.border.strong,
|
|
22
|
+
borderRadius: theme.components.input.borderRadius,
|
|
23
|
+
backgroundColor: theme.color.surface.neutral.strong,
|
|
24
|
+
textAlign: 'center',
|
|
25
|
+
padding: 0,
|
|
26
|
+
variants: {
|
|
27
|
+
disabled: {
|
|
28
|
+
true: {
|
|
29
|
+
opacity: theme.opacity.disabled,
|
|
30
|
+
color: theme.color.text.secondary,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
readonly: {
|
|
34
|
+
true: {
|
|
35
|
+
borderColor: theme.color.border.subtle,
|
|
36
|
+
backgroundColor: theme.color.surface.neutral.subtle,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
validationStatus: {
|
|
40
|
+
initial: {},
|
|
41
|
+
valid: {
|
|
42
|
+
borderColor: theme.color.feedback.positive.border,
|
|
43
|
+
},
|
|
44
|
+
invalid: {
|
|
45
|
+
borderColor: theme.color.feedback.danger.border,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
active: {
|
|
49
|
+
true: {
|
|
50
|
+
borderColor: theme.color.border.strong,
|
|
51
|
+
borderWidth: theme.components.input.borderWidthFocused,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
compoundVariants: [
|
|
56
|
+
{
|
|
57
|
+
validationStatus: 'invalid',
|
|
58
|
+
active: true,
|
|
59
|
+
styles: {
|
|
60
|
+
borderColor: theme.color.feedback.danger.border,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
validationStatus: 'valid',
|
|
65
|
+
active: true,
|
|
66
|
+
styles: {
|
|
67
|
+
borderColor: theme.color.border.strong,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
}));
|