@jobber/components-native 0.84.4-JOB-134681-8086ad4.25 → 0.84.4-JOB-138679-b1552ab.68
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/package.json +23 -14
- package/dist/src/ActionItem/ActionItemGroup.js +1 -1
- package/dist/src/AutoLink/components/Link/Link.js +1 -1
- package/dist/src/Banner/Banner.js +2 -0
- package/dist/src/Banner/components/BannerIcon/BannerIcon.style.js +3 -0
- package/dist/src/BottomSheet/BottomSheet.js +2 -2
- package/dist/src/Button/components/InternalButtonLoading/InternalButtonLoading.js +0 -1
- package/dist/src/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/src/ContentOverlay/ContentOverlay.js +5 -7
- package/dist/src/ContentOverlay/UNSAFE_WrappedModalize.js +23 -0
- package/dist/src/ErrorMessageWrapper/context/ErrorMessageProvider.js +1 -1
- package/dist/src/Form/Form.js +5 -2
- package/dist/src/Form/components/FormCache/FormCache.js +1 -0
- package/dist/src/Form/components/FormMessageBanner/FormMessageBanner.js +1 -1
- package/dist/src/Form/context/AtlantisFormContext.js +1 -0
- package/dist/src/Form/hooks/useInternalForm.js +6 -3
- package/dist/src/FormatFile/components/MediaView/MediaView.js +22 -5
- package/dist/src/FormatFile/utils/createUseCreateThumbnail.js +1 -1
- package/dist/src/InputCurrency/InputCurrency.js +42 -30
- package/dist/src/InputDate/InputDate.js +2 -2
- package/dist/src/InputEmail/InputEmail.js +12 -4
- package/dist/src/InputFieldWrapper/InputFieldWrapper.js +14 -12
- package/dist/src/InputFieldWrapper/InputFieldWrapper.style.js +1 -1
- package/dist/src/InputFieldWrapper/components/Prefix/Prefix.js +5 -2
- package/dist/src/InputFieldWrapper/components/Suffix/Suffix.js +5 -2
- package/dist/src/InputNumber/InputNumber.js +10 -4
- package/dist/src/InputPressable/InputPressable.js +20 -8
- package/dist/src/InputPressable/InputPressable.style.js +3 -0
- package/dist/src/InputSearch/InputSearch.js +1 -1
- package/dist/src/InputText/InputText.js +22 -11
- package/dist/src/InputText/InputText.style.js +4 -0
- package/dist/src/InputTime/InputTime.js +2 -2
- package/dist/src/Menu/Menu.js +2 -2
- package/dist/src/Select/Select.style.js +1 -0
- package/dist/src/Select/components/SelectPressable/SelectPressable.js +1 -1
- package/dist/src/Switch/components/BaseSwitch/BaseSwitch.js +7 -1
- package/dist/src/Typography/Typography.js +16 -5
- package/dist/src/hooks/useAtlantisI18n/locales/en.json +1 -0
- package/dist/src/hooks/useAtlantisI18n/locales/es.json +1 -0
- package/dist/src/hooks/useFormController.js +5 -14
- package/dist/tsconfig.build.json +7 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/tsconfig.json +4 -6
- package/dist/types/src/ActionItem/ActionItem.d.ts +2 -1
- package/dist/types/src/ActionItem/ActionItemGroup.d.ts +2 -1
- package/dist/types/src/ActionItem/components/ActionItemContainer.d.ts +2 -1
- package/dist/types/src/ActionLabel/ActionLabel.d.ts +4 -3
- package/dist/types/src/ActivityIndicator/ActivityIndicator.d.ts +2 -1
- package/dist/types/src/AutoLink/AutoLink.d.ts +2 -1
- package/dist/types/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.d.ts +2 -1
- package/dist/types/src/AutoLink/components/Link/Link.d.ts +2 -1
- package/dist/types/src/Banner/Banner.d.ts +2 -1
- package/dist/types/src/Banner/components/BannerIcon/BannerIcon.d.ts +2 -1
- package/dist/types/src/Banner/components/BannerIcon/BannerIcon.style.d.ts +3 -0
- package/dist/types/src/Banner/types.d.ts +1 -1
- package/dist/types/src/BottomSheet/BottomSheet.d.ts +1 -1
- package/dist/types/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.d.ts +2 -1
- package/dist/types/src/Button/Button.d.ts +2 -1
- package/dist/types/src/Button/components/InternalButtonLoading/InternalButtonLoading.d.ts +1 -1
- package/dist/types/src/ButtonGroup/ButtonGroup.d.ts +2 -1
- package/dist/types/src/ButtonGroup/ButtonGroupAction.d.ts +4 -3
- package/dist/types/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.d.ts +3 -2
- package/dist/types/src/Card/Card.d.ts +2 -1
- package/dist/types/src/Card/components/InternalCardHeader.d.ts +2 -1
- package/dist/types/src/Checkbox/Checkbox.d.ts +2 -1
- package/dist/types/src/Checkbox/CheckboxGroup.d.ts +2 -1
- package/dist/types/src/Chip/Chip.d.ts +2 -1
- package/dist/types/src/Content/Content.d.ts +2 -1
- package/dist/types/src/ContentOverlay/ContentOverlay.d.ts +1 -1
- package/dist/types/src/ContentOverlay/UNSAFE_WrappedModalize.d.ts +3 -0
- package/dist/types/src/Disclosure/Disclosure.d.ts +1 -1
- package/dist/types/src/Divider/Divider.d.ts +2 -1
- package/dist/types/src/EmptyState/EmptyState.d.ts +2 -1
- package/dist/types/src/ErrorMessageWrapper/ErrorMessageWrapper.d.ts +2 -1
- package/dist/types/src/ErrorMessageWrapper/context/ErrorMessageProvider.d.ts +2 -1
- package/dist/types/src/ErrorMessageWrapper/context/types.d.ts +1 -1
- package/dist/types/src/Flex/Flex.d.ts +2 -1
- package/dist/types/src/Form/Form.d.ts +2 -1
- package/dist/types/src/Form/components/FormActionBar/FormActionBar.d.ts +3 -2
- package/dist/types/src/Form/components/FormBody/FormBody.d.ts +3 -2
- package/dist/types/src/Form/components/FormCache/FormCache.d.ts +4 -3
- package/dist/types/src/Form/components/FormErrorBanner/FormErrorBanner.d.ts +2 -1
- package/dist/types/src/Form/components/FormMask/FormMask.d.ts +2 -1
- package/dist/types/src/Form/components/FormMessage/FormMessage.d.ts +2 -1
- package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.d.ts +2 -1
- package/dist/types/src/Form/components/FormMessageBanner/FormMessageBanner.d.ts +2 -1
- package/dist/types/src/Form/components/FormSaveButton/FormSaveButton.d.ts +2 -1
- package/dist/types/src/Form/context/AtlantisFormContext.d.ts +2 -1
- package/dist/types/src/Form/context/types.d.ts +3 -2
- package/dist/types/src/Form/hooks/useFormViewRefs.d.ts +2 -2
- package/dist/types/src/Form/hooks/useInternalForm.d.ts +5 -5
- package/dist/types/src/Form/types.d.ts +13 -7
- package/dist/types/src/FormField/FormField.d.ts +1 -1
- package/dist/types/src/FormatFile/FormatFile.d.ts +2 -1
- package/dist/types/src/FormatFile/components/ErrorIcon/ErrorIcon.d.ts +2 -1
- package/dist/types/src/FormatFile/components/FileView/FileView.d.ts +2 -1
- package/dist/types/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.d.ts +3 -2
- package/dist/types/src/FormatFile/components/MediaView/MediaView.d.ts +2 -1
- package/dist/types/src/FormatFile/components/ProgressBar/ProgressBar.d.ts +2 -1
- package/dist/types/src/Heading/Heading.d.ts +4 -3
- package/dist/types/src/Icon/Icon.d.ts +2 -1
- package/dist/types/src/IconButton/IconButton.d.ts +1 -1
- package/dist/types/src/InputCurrency/InputCurrency.d.ts +2 -1
- package/dist/types/src/InputDate/InputDate.d.ts +4 -2
- package/dist/types/src/InputFieldWrapper/InputFieldWrapper.d.ts +9 -2
- package/dist/types/src/InputFieldWrapper/InputFieldWrapper.style.d.ts +1 -1
- package/dist/types/src/InputFieldWrapper/components/ClearAction/ClearAction.d.ts +2 -1
- package/dist/types/src/InputFieldWrapper/components/Prefix/Prefix.d.ts +4 -4
- package/dist/types/src/InputFieldWrapper/components/Suffix/Suffix.d.ts +4 -4
- package/dist/types/src/InputPressable/InputPressable.d.ts +9 -1
- package/dist/types/src/InputPressable/InputPressable.style.d.ts +3 -0
- package/dist/types/src/InputSearch/InputSearch.d.ts +1 -1
- package/dist/types/src/InputSearch/components/FilterButton.d.ts +2 -1
- package/dist/types/src/InputText/InputText.d.ts +10 -2
- package/dist/types/src/InputText/InputText.style.d.ts +4 -0
- package/dist/types/src/InputText/context/InputAccessoriesProvider.d.ts +2 -1
- package/dist/types/src/InputTime/InputTime.d.ts +4 -2
- package/dist/types/src/Menu/Menu.d.ts +2 -1
- package/dist/types/src/Menu/components/MenuOption/MenuOption.d.ts +2 -1
- package/dist/types/src/Menu/components/Overlay/Overlay.d.ts +2 -1
- package/dist/types/src/Menu/types.d.ts +6 -1
- package/dist/types/src/ProgressBar/ProgressBar.d.ts +2 -1
- package/dist/types/src/ProgressBar/ProgressBarInner.d.ts +2 -1
- package/dist/types/src/Select/Select.d.ts +3 -2
- package/dist/types/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.d.ts +2 -1
- package/dist/types/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.d.ts +2 -1
- package/dist/types/src/Select/components/SelectInternalPicker/SelectInternalPicker.d.ts +2 -1
- package/dist/types/src/Select/components/SelectPressable/SelectPressable.d.ts +2 -1
- package/dist/types/src/StatusLabel/StatusLabel.d.ts +2 -1
- package/dist/types/src/Switch/Switch.d.ts +2 -1
- package/dist/types/src/Switch/components/BaseSwitch/BaseSwitch.d.ts +2 -1
- package/dist/types/src/Text/Text.d.ts +4 -3
- package/dist/types/src/TextList/TextList.d.ts +2 -1
- package/dist/types/src/ThumbnailList/ThumbnailList.d.ts +2 -1
- package/dist/types/src/Toast/Toast.d.ts +2 -1
- package/dist/types/src/Typography/Typography.d.ts +3 -3
- package/dist/types/src/Typography/TypographyGestureDetector.d.ts +2 -1
- package/dist/types/src/utils/test/MockSafeAreaProvider.d.ts +1 -1
- package/package.json +23 -14
- package/src/ActionItem/ActionItem.tsx +1 -1
- package/src/ActionItem/ActionItemGroup.tsx +1 -3
- package/src/ActionItem/components/ActionItemContainer.tsx +1 -1
- package/src/ActionLabel/ActionLabel.test.tsx +12 -0
- package/src/ActionLabel/ActionLabel.tsx +3 -3
- package/src/ActionLabel/__snapshots__/ActionLabel.test.tsx.snap +66 -0
- package/src/ActivityIndicator/ActivityIndicator.tsx +1 -3
- package/src/AtlantisContext/AtlantisContext.test.tsx +1 -1
- package/src/AtlantisThemeContext/AtlantisThemeContext.test.tsx +5 -5
- package/src/AutoLink/AutoLink.test.tsx +2 -4
- package/src/AutoLink/AutoLink.tsx +1 -1
- package/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.tsx +1 -1
- package/src/AutoLink/components/Link/Link.tsx +1 -5
- package/src/Banner/Banner.test.tsx +12 -0
- package/src/Banner/Banner.tsx +4 -2
- package/src/Banner/components/BannerIcon/BannerIcon.style.ts +3 -0
- package/src/Banner/components/BannerIcon/BannerIcon.tsx +1 -1
- package/src/Banner/types.ts +1 -1
- package/src/BottomSheet/BottomSheet.test.tsx +17 -17
- package/src/BottomSheet/BottomSheet.tsx +4 -3
- package/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.tsx +1 -1
- package/src/Button/Button.tsx +1 -1
- package/src/Button/components/InternalButtonLoading/InternalButtonLoading.tsx +1 -2
- package/src/ButtonGroup/ButtonGroup.test.tsx +13 -11
- package/src/ButtonGroup/ButtonGroup.tsx +2 -2
- package/src/ButtonGroup/ButtonGroupAction.tsx +4 -4
- package/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.tsx +2 -2
- package/src/Card/Card.tsx +1 -1
- package/src/Card/components/InternalCardHeader.tsx +1 -1
- package/src/Checkbox/Checkbox.tsx +2 -2
- package/src/Checkbox/CheckboxGroup.test.tsx +3 -7
- package/src/Checkbox/CheckboxGroup.tsx +2 -2
- package/src/Chip/Chip.tsx +1 -1
- package/src/Content/Content.tsx +1 -1
- package/src/ContentOverlay/ContentOverlay.test.tsx +34 -27
- package/src/ContentOverlay/ContentOverlay.tsx +7 -7
- package/src/ContentOverlay/UNSAFE_WrappedModalize.tsx +41 -0
- package/src/ContentOverlay/hooks/useKeyboardVisibility.test.ts +7 -7
- package/src/ContentOverlay/hooks/useViewLayoutHeight.test.ts +1 -1
- package/src/Disclosure/Disclosure.tsx +1 -1
- package/src/Divider/Divider.tsx +1 -1
- package/src/EmptyState/EmptyState.test.tsx +29 -42
- package/src/EmptyState/EmptyState.tsx +1 -1
- package/src/ErrorMessageWrapper/ErrorMessageWrapper.tsx +1 -1
- package/src/ErrorMessageWrapper/context/ErrorMessageProvider.tsx +3 -5
- package/src/ErrorMessageWrapper/context/types.ts +1 -1
- package/src/Flex/Flex.tsx +2 -2
- package/src/Form/Form.test.tsx +145 -2
- package/src/Form/Form.tsx +8 -1
- package/src/Form/components/FormActionBar/FormActionBar.tsx +3 -3
- package/src/Form/components/FormBody/FormBody.tsx +3 -3
- package/src/Form/components/FormCache/FormCache.tsx +5 -4
- package/src/Form/components/FormErrorBanner/FormErrorBanner.tsx +1 -1
- package/src/Form/components/FormMask/FormMask.tsx +1 -1
- package/src/Form/components/FormMessage/FormMessage.test.tsx +40 -27
- package/src/Form/components/FormMessage/FormMessage.tsx +1 -1
- package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.tsx +1 -1
- package/src/Form/components/FormMessageBanner/FormMessageBanner.tsx +1 -3
- package/src/Form/components/FormSaveButton/FormSaveButton.test.tsx +2 -2
- package/src/Form/components/FormSaveButton/FormSaveButton.tsx +1 -1
- package/src/Form/context/AtlantisFormContext.test.tsx +1 -1
- package/src/Form/context/AtlantisFormContext.tsx +1 -0
- package/src/Form/context/types.ts +3 -2
- package/src/Form/hooks/useFormViewRefs.ts +4 -5
- package/src/Form/hooks/useInternalForm.ts +12 -4
- package/src/Form/hooks/useScrollToError/useScrollToError.test.tsx +2 -1
- package/src/Form/types.ts +14 -8
- package/src/FormField/FormField.tsx +1 -1
- package/src/FormatFile/FormatFile.test.tsx +21 -21
- package/src/FormatFile/FormatFile.tsx +3 -3
- package/src/FormatFile/components/ErrorIcon/ErrorIcon.tsx +1 -1
- package/src/FormatFile/components/FileView/FileView.tsx +1 -1
- package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.tsx +14 -14
- package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.tsx +2 -2
- package/src/FormatFile/components/MediaView/MediaView.test.tsx +283 -0
- package/src/FormatFile/components/MediaView/MediaView.tsx +28 -7
- package/src/FormatFile/components/ProgressBar/ProgressBar.tsx +1 -1
- package/src/FormatFile/utils/createUseCreateThumbnail.ts +1 -1
- package/src/Glimmer/Glimmer.test.tsx +2 -2
- package/src/Heading/Heading.test.tsx +13 -0
- package/src/Heading/Heading.tsx +3 -3
- package/src/Heading/__snapshots__/Heading.test.tsx.snap +65 -0
- package/src/Icon/Icon.tsx +1 -1
- package/src/Icon/__snapshots__/Icon.test.tsx.snap +7 -0
- package/src/IconButton/IconButton.tsx +1 -1
- package/src/InputCurrency/InputCurrency.tsx +72 -58
- package/src/InputDate/InputDate.tsx +7 -3
- package/src/InputEmail/InputEmail.tsx +15 -8
- package/src/InputFieldWrapper/InputFieldWrapper.style.ts +1 -1
- package/src/InputFieldWrapper/InputFieldWrapper.test.tsx +48 -1
- package/src/InputFieldWrapper/InputFieldWrapper.tsx +39 -29
- package/src/InputFieldWrapper/components/ClearAction/ClearAction.tsx +1 -1
- package/src/InputFieldWrapper/components/Prefix/Prefix.test.tsx +8 -16
- package/src/InputFieldWrapper/components/Prefix/Prefix.tsx +8 -6
- package/src/InputFieldWrapper/components/Suffix/Suffix.test.tsx +2 -4
- package/src/InputFieldWrapper/components/Suffix/Suffix.tsx +8 -6
- package/src/InputNumber/InputNumber.tsx +11 -7
- package/src/InputPassword/InputPassword.tsx +1 -1
- package/src/InputPressable/InputPressable.style.ts +4 -0
- package/src/InputPressable/InputPressable.test.tsx +75 -1
- package/src/InputPressable/InputPressable.tsx +34 -8
- package/src/InputSearch/InputSearch.tsx +2 -1
- package/src/InputSearch/components/FilterButton.tsx +1 -1
- package/src/InputText/InputText.style.ts +5 -0
- package/src/InputText/InputText.test.tsx +75 -0
- package/src/InputText/InputText.tsx +34 -17
- package/src/InputText/context/InputAccessoriesProvider.tsx +1 -1
- package/src/InputTime/InputTime.tsx +7 -3
- package/src/Menu/Menu.tsx +3 -3
- package/src/Menu/components/MenuOption/MenuOption.tsx +1 -1
- package/src/Menu/components/Overlay/Overlay.tsx +1 -1
- package/src/Menu/types.ts +7 -1
- package/src/ProgressBar/ProgressBar.tsx +1 -1
- package/src/ProgressBar/ProgressBarInner.tsx +1 -1
- package/src/Select/Select.style.ts +1 -0
- package/src/Select/Select.tsx +2 -2
- package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.tsx +1 -1
- package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.tsx +1 -1
- package/src/Select/components/SelectInternalPicker/SelectInternalPicker.tsx +1 -1
- package/src/Select/components/SelectPressable/SelectPressable.tsx +1 -4
- package/src/StatusLabel/StatusLabel.tsx +1 -1
- package/src/Switch/Switch.tsx +1 -1
- package/src/Switch/components/BaseSwitch/BaseSwitch.tsx +8 -2
- package/src/Text/Text.test.tsx +10 -0
- package/src/Text/Text.tsx +3 -3
- package/src/Text/__snapshots__/Text.test.tsx.snap +66 -0
- package/src/TextList/TextList.tsx +1 -1
- package/src/ThumbnailList/ThumbnailList.test.tsx +5 -5
- package/src/ThumbnailList/ThumbnailList.tsx +1 -1
- package/src/Toast/Toast.tsx +2 -2
- package/src/Typography/Typography.test.tsx +61 -0
- package/src/Typography/Typography.tsx +25 -9
- package/src/Typography/TypographyGestureDetector.tsx +1 -3
- package/src/Typography/__snapshots__/Typography.test.tsx.snap +222 -0
- package/src/hooks/useAtlantisI18n/locales/en.json +1 -0
- package/src/hooks/useAtlantisI18n/locales/es.json +1 -0
- package/src/hooks/useFormController.ts +6 -13
- package/src/utils/test/MockSafeAreaProvider.tsx +1 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -36,6 +36,7 @@ export const useStyles = buildThemedStyles(tokens => {
|
|
|
36
36
|
right: 0,
|
|
37
37
|
bottom: 0,
|
|
38
38
|
left: 0,
|
|
39
|
+
zIndex: 1,
|
|
39
40
|
},
|
|
40
41
|
miniLabel: {
|
|
41
42
|
top: 0,
|
|
@@ -44,7 +45,6 @@ export const useStyles = buildThemedStyles(tokens => {
|
|
|
44
45
|
marginRight: tokens["space-small"],
|
|
45
46
|
maxHeight: (typographyStyles.defaultSize.lineHeight || 0) +
|
|
46
47
|
tokens["space-smaller"],
|
|
47
|
-
zIndex: 1,
|
|
48
48
|
},
|
|
49
49
|
// Prevents the miniLabel from cutting off the ClearAction button
|
|
50
50
|
miniLabelShowClearAction: {
|
|
@@ -7,7 +7,7 @@ import { useTypographyStyles } from "../../../Typography";
|
|
|
7
7
|
import { useStyles } from "../../InputFieldWrapper.style";
|
|
8
8
|
export const prefixLabelTestId = "ATL-InputFieldWrapper-PrefixLabel";
|
|
9
9
|
export const prefixIconTestId = "ATL-InputFieldWrapper-PrefixIcon";
|
|
10
|
-
export function PrefixLabel({ focused, disabled,
|
|
10
|
+
export function PrefixLabel({ focused, disabled, miniLabelActive, inputInvalid, label, styleOverride, }) {
|
|
11
11
|
const styles = useStyles();
|
|
12
12
|
const typographyStyles = useTypographyStyles();
|
|
13
13
|
return (React.createElement(View, { style: [
|
|
@@ -15,7 +15,10 @@ export function PrefixLabel({ focused, disabled, hasMiniLabel, inputInvalid, lab
|
|
|
15
15
|
focused && styles.inputFocused,
|
|
16
16
|
inputInvalid && styles.inputInvalid,
|
|
17
17
|
], testID: prefixLabelTestId },
|
|
18
|
-
React.createElement(View, { style: [
|
|
18
|
+
React.createElement(View, { style: [
|
|
19
|
+
styles.prefixLabel,
|
|
20
|
+
miniLabelActive && styles.fieldAffixMiniLabel,
|
|
21
|
+
] }, !styleOverride ? (React.createElement(Text, { variation: disabled ? "disabled" : "base" }, label)) : (React.createElement(RNText, { allowFontScaling: true, style: [
|
|
19
22
|
typographyStyles.baseRegularRegular,
|
|
20
23
|
typographyStyles.base,
|
|
21
24
|
typographyStyles.defaultSize,
|
|
@@ -7,7 +7,7 @@ import { useAtlantisTheme } from "../../../AtlantisThemeContext";
|
|
|
7
7
|
import { useStyles } from "../../InputFieldWrapper.style";
|
|
8
8
|
export const suffixLabelTestId = "ATL-InputFieldWrapper-SuffixLabel";
|
|
9
9
|
export const suffixIconTestId = "ATL-InputFieldWrapper-SuffixIcon";
|
|
10
|
-
export function SuffixLabel({ focused, disabled,
|
|
10
|
+
export function SuffixLabel({ focused, disabled, miniLabelActive, inputInvalid, label, hasLeftMargin = true, styleOverride, }) {
|
|
11
11
|
const styles = useStyles();
|
|
12
12
|
const typographyStyles = useTypographyStyles();
|
|
13
13
|
return (React.createElement(View, { testID: suffixLabelTestId, style: [
|
|
@@ -16,7 +16,10 @@ export function SuffixLabel({ focused, disabled, hasMiniLabel, inputInvalid, lab
|
|
|
16
16
|
inputInvalid && styles.inputInvalid,
|
|
17
17
|
hasLeftMargin && styles.suffixLabelMargin,
|
|
18
18
|
] },
|
|
19
|
-
React.createElement(View, { style: [
|
|
19
|
+
React.createElement(View, { style: [
|
|
20
|
+
styles.suffixLabel,
|
|
21
|
+
miniLabelActive && styles.fieldAffixMiniLabel,
|
|
22
|
+
] }, !styleOverride ? (React.createElement(Text, { variation: disabled ? "disabled" : "base" }, label)) : (React.createElement(RNText, { allowFontScaling: true, style: [
|
|
20
23
|
typographyStyles.baseRegularRegular,
|
|
21
24
|
typographyStyles.base,
|
|
22
25
|
typographyStyles.defaultSize,
|
|
@@ -24,13 +24,19 @@ function InputNumberInternal(props, ref) {
|
|
|
24
24
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, newValue);
|
|
25
25
|
};
|
|
26
26
|
const { inputTransform: convertToString, outputTransform: convertToNumber } = useNumberTransform(props.value);
|
|
27
|
+
const defaultValidations = {
|
|
28
|
+
pattern: {
|
|
29
|
+
value: NUMBER_VALIDATION_REGEX,
|
|
30
|
+
message: t("errors.notANumber"),
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
const mergedValidations = props.validations
|
|
34
|
+
? Object.assign({}, defaultValidations, props.validations)
|
|
35
|
+
: defaultValidations;
|
|
27
36
|
return (React.createElement(InputText, Object.assign({}, props, { keyboard: getKeyboard(), transform: {
|
|
28
37
|
input: flow(convertToString, ((_a = props.transform) === null || _a === void 0 ? void 0 : _a.input) || identity),
|
|
29
38
|
output: flow(convertToNumber, ((_b = props.transform) === null || _b === void 0 ? void 0 : _b.output) || identity),
|
|
30
|
-
}, ref: ref, value: (_c = props.value) === null || _c === void 0 ? void 0 : _c.toString(), defaultValue: (_d = props.defaultValue) === null || _d === void 0 ? void 0 : _d.toString(), onChangeText: handleChange, validations:
|
|
31
|
-
value: NUMBER_VALIDATION_REGEX,
|
|
32
|
-
message: t("errors.notANumber"),
|
|
33
|
-
} }, props.validations) })));
|
|
39
|
+
}, ref: ref, value: (_c = props.value) === null || _c === void 0 ? void 0 : _c.toString(), defaultValue: (_d = props.defaultValue) === null || _d === void 0 ? void 0 : _d.toString(), onChangeText: handleChange, validations: mergedValidations })));
|
|
34
40
|
}
|
|
35
41
|
function hasPeriodAtEnd(value) {
|
|
36
42
|
// matches patterns like ".", "0.", "12.", "+1.", and "-0."
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import React, { forwardRef
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
2
|
import { Text as NativeText, Pressable } from "react-native";
|
|
3
3
|
import { useShowClear } from "@jobber/hooks";
|
|
4
4
|
import { useStyles } from "./InputPressable.style";
|
|
5
5
|
import { InputFieldWrapper, useCommonInputStyles } from "../InputFieldWrapper";
|
|
6
6
|
export const InputPressable = forwardRef(InputPressableInternal);
|
|
7
|
-
export function InputPressableInternal({ value, placeholder, disabled, invalid, error, onPress, accessibilityLabel, accessibilityHint, prefix, suffix, clearable = "never", onClear, focused, }, ref) {
|
|
7
|
+
export function InputPressableInternal({ value, placeholder, disabled, invalid, error, showMiniLabel = true, onPress, accessibilityLabel, accessibilityHint, prefix, suffix, clearable = "never", onClear, focused, }, ref) {
|
|
8
8
|
const hasValue = !!value;
|
|
9
|
-
const
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
setHasMiniLabel(Boolean(value));
|
|
12
|
-
}, [value]);
|
|
9
|
+
const placeholderMode = getPlaceholderMode(showMiniLabel, value);
|
|
13
10
|
const showClear = useShowClear({
|
|
14
11
|
clearable,
|
|
15
12
|
multiline: false,
|
|
@@ -19,13 +16,28 @@ export function InputPressableInternal({ value, placeholder, disabled, invalid,
|
|
|
19
16
|
});
|
|
20
17
|
const styles = useStyles();
|
|
21
18
|
const commonInputStyles = useCommonInputStyles();
|
|
22
|
-
return (React.createElement(InputFieldWrapper, { prefix: prefix, suffix: suffix, hasValue: hasValue,
|
|
19
|
+
return (React.createElement(InputFieldWrapper, { prefix: prefix, suffix: suffix, hasValue: hasValue, placeholderMode: placeholderMode, focused: focused, error: error, invalid: invalid, placeholder: placeholder, disabled: disabled, showClearAction: showClear, onClear: onClear },
|
|
23
20
|
React.createElement(Pressable, { style: styles.pressable, onPress: onPress, disabled: disabled, accessibilityLabel: accessibilityLabel || placeholder, accessibilityHint: accessibilityHint, accessibilityValue: { text: value } },
|
|
24
21
|
React.createElement(NativeText, { style: [
|
|
25
22
|
commonInputStyles.input,
|
|
26
23
|
styles.inputPressableStyles,
|
|
27
|
-
|
|
24
|
+
placeholderMode === "normal" && commonInputStyles.inputEmpty,
|
|
25
|
+
placeholderMode === "hidden" && styles.withoutMiniLabel,
|
|
28
26
|
disabled && commonInputStyles.inputDisabled,
|
|
29
27
|
(Boolean(invalid) || error) && styles.inputInvalid,
|
|
30
28
|
], testID: "inputPressableText", ref: ref, accessibilityRole: "none", accessible: false, importantForAccessibility: "no-hide-descendants" }, value))));
|
|
31
29
|
}
|
|
30
|
+
function getPlaceholderMode(isMiniLabelAllowed, internalValue) {
|
|
31
|
+
const hasValue = Boolean(internalValue);
|
|
32
|
+
if (hasValue) {
|
|
33
|
+
if (isMiniLabelAllowed) {
|
|
34
|
+
return "mini";
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return "hidden";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return "normal";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import React, { forwardRef, useEffect } from "react";
|
|
13
13
|
import { View } from "react-native";
|
|
14
|
-
import { useDebounce } from "@jobber/hooks
|
|
14
|
+
import { useDebounce } from "@jobber/hooks";
|
|
15
15
|
import { styles } from "./InputSearch.style";
|
|
16
16
|
import { InputText } from "../InputText";
|
|
17
17
|
export const InputSearch = forwardRef(SearchInputInternal);
|
|
@@ -9,7 +9,7 @@ import { InputFieldWrapper } from "../InputFieldWrapper";
|
|
|
9
9
|
import { useCommonInputStyles } from "../InputFieldWrapper/CommonInputStyles.style";
|
|
10
10
|
export const InputText = forwardRef(InputTextInternal);
|
|
11
11
|
// eslint-disable-next-line max-statements
|
|
12
|
-
function InputTextInternal({ invalid, disabled, readonly = false, name, placeholder, assistiveText, keyboard, value: controlledValue, defaultValue, autoFocus, autoComplete = "off", spellCheck, textContentType = "none", validations, onChangeText, onSubmitEditing, onFocus, accessibilityLabel, accessibilityHint, autoCorrect, autoCapitalize, onBlur, multiline = false, prefix, suffix, transform = {}, clearable = multiline ? "never" : "while-editing", testID, secureTextEntry, styleOverride, toolbar, toolbarVisibility, loading, loadingType, }, ref) {
|
|
12
|
+
function InputTextInternal({ invalid, disabled, readonly = false, name, placeholder, assistiveText, showMiniLabel = true, keyboard, value: controlledValue, defaultValue, autoFocus, autoComplete = "off", spellCheck, textContentType = "none", validations, onChangeText, onSubmitEditing, onFocus, accessibilityLabel, accessibilityHint, autoCorrect, autoCapitalize, onBlur, multiline = false, prefix, suffix, transform = {}, clearable = multiline ? "never" : "while-editing", testID, secureTextEntry, styleOverride, toolbar, toolbarVisibility, loading, loadingType, }, ref) {
|
|
13
13
|
var _a;
|
|
14
14
|
const isAndroid = Platform.OS === "android";
|
|
15
15
|
const isIOS = Platform.OS === "ios";
|
|
@@ -22,7 +22,8 @@ function InputTextInternal({ invalid, disabled, readonly = false, name, placehol
|
|
|
22
22
|
const internalValue = controlledValue !== null && controlledValue !== void 0 ? controlledValue : (_a = field.value) === null || _a === void 0 ? void 0 : _a.toString();
|
|
23
23
|
const hasValue = internalValue !== "" && internalValue !== undefined;
|
|
24
24
|
const [focused, setFocused] = useState(false);
|
|
25
|
-
const
|
|
25
|
+
const placeholderMode = getPlaceholderMode(showMiniLabel, internalValue);
|
|
26
|
+
const miniLabelActive = placeholderMode === "mini";
|
|
26
27
|
const textInputRef = useTextInputRef({ ref, onClear: handleClear });
|
|
27
28
|
const showClear = useShowClear({
|
|
28
29
|
clearable,
|
|
@@ -74,15 +75,18 @@ function InputTextInternal({ invalid, disabled, readonly = false, name, placehol
|
|
|
74
75
|
}
|
|
75
76
|
const styles = useStyles();
|
|
76
77
|
const commonInputStyles = useCommonInputStyles();
|
|
77
|
-
return (React.createElement(InputFieldWrapper, { prefix: prefix, suffix: suffix, hasValue: hasValue,
|
|
78
|
+
return (React.createElement(InputFieldWrapper, { prefix: prefix, suffix: suffix, hasValue: hasValue, placeholderMode: placeholderMode, assistiveText: assistiveText, focused: focused, error: error, invalid: invalid, placeholder: placeholder, disabled: disabled, onClear: handleClear, showClearAction: showClear, styleOverride: styleOverride, toolbar: toolbar, toolbarVisibility: toolbarVisibility, loading: loading, loadingType: loadingType },
|
|
78
79
|
React.createElement(TextInput, Object.assign({ inputAccessoryViewID: inputAccessoryID || undefined, testID: testID, autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, spellCheck: spellCheck, style: [
|
|
79
80
|
commonInputStyles.input,
|
|
80
81
|
styles.inputPaddingTop,
|
|
81
|
-
!
|
|
82
|
+
!miniLabelActive && commonInputStyles.inputEmpty,
|
|
82
83
|
disabled && commonInputStyles.inputDisabled,
|
|
83
84
|
multiline && styles.multiLineInput,
|
|
84
85
|
multiline && Platform.OS === "ios" && styles.multilineInputiOS,
|
|
85
|
-
multiline &&
|
|
86
|
+
multiline && miniLabelActive && styles.multiLineInputWithMini,
|
|
87
|
+
multiline &&
|
|
88
|
+
placeholderMode === "hidden" &&
|
|
89
|
+
styles.multilineWithoutMiniLabel,
|
|
86
90
|
styleOverride === null || styleOverride === void 0 ? void 0 : styleOverride.inputText,
|
|
87
91
|
loading && loadingType === "glimmer" && { color: "transparent" },
|
|
88
92
|
], readOnly: readonly, editable: !disabled, keyboardType: keyboard, value: inputTransform(internalValue), autoFocus: autoFocus, autoComplete: autoComplete, multiline: multiline, scrollEnabled: false, textContentType: textContentType, onChangeText: handleChangeText, onSubmitEditing: handleOnSubmitEditing, returnKeyType: returnKeyType, blurOnSubmit: shouldBlurOnSubmit, accessibilityLabel: accessibilityLabel || placeholder, accessibilityHint: accessibilityHint, accessibilityState: { busy: loading }, secureTextEntry: secureTextEntry }, androidA11yProps, { onFocus: event => {
|
|
@@ -149,10 +153,17 @@ function useTextInputRef({ ref, onClear }) {
|
|
|
149
153
|
}), [onClear]);
|
|
150
154
|
return textInputRef;
|
|
151
155
|
}
|
|
152
|
-
function
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
function getPlaceholderMode(isMiniLabelAllowed, internalValue) {
|
|
157
|
+
const hasValue = Boolean(internalValue);
|
|
158
|
+
if (hasValue) {
|
|
159
|
+
if (isMiniLabelAllowed) {
|
|
160
|
+
return "mini";
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
return "hidden";
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
return "normal";
|
|
168
|
+
}
|
|
158
169
|
}
|
|
@@ -20,5 +20,9 @@ export const useStyles = buildThemedStyles(tokens => {
|
|
|
20
20
|
multilineInputiOS: {
|
|
21
21
|
paddingTop: (typographyStyles.defaultSize.fontSize || 0) + tokens["space-smallest"],
|
|
22
22
|
},
|
|
23
|
+
multilineWithoutMiniLabel: {
|
|
24
|
+
paddingTop: tokens["space-base"] + tokens["space-smallest"],
|
|
25
|
+
paddingBottom: tokens["space-base"] + tokens["space-smallest"],
|
|
26
|
+
},
|
|
23
27
|
};
|
|
24
28
|
});
|
|
@@ -28,7 +28,7 @@ export function InputTime(props) {
|
|
|
28
28
|
}
|
|
29
29
|
return React.createElement(InternalInputTime, Object.assign({}, props));
|
|
30
30
|
}
|
|
31
|
-
function InternalInputTime({ clearable = "always", disabled, emptyValueLabel, invalid, placeholder, value, name, type = "scheduling", onChange, showIcon = true, }) {
|
|
31
|
+
function InternalInputTime({ clearable = "always", disabled, emptyValueLabel, invalid, placeholder, value, name, type = "scheduling", showMiniLabel = true, onChange, showIcon = true, }) {
|
|
32
32
|
const [showPicker, setShowPicker] = useState(false);
|
|
33
33
|
const { t, formatTime } = useAtlantisI18n();
|
|
34
34
|
const { timeZone, timeFormat } = useAtlantisContext();
|
|
@@ -42,7 +42,7 @@ function InternalInputTime({ clearable = "always", disabled, emptyValueLabel, in
|
|
|
42
42
|
}, [dateTime, emptyValueLabel]);
|
|
43
43
|
const canClearTime = formattedTime === emptyValueLabel ? "never" : clearable;
|
|
44
44
|
return (React.createElement(View, { style: styles.container },
|
|
45
|
-
React.createElement(InputPressable, { clearable: canClearTime, disabled: disabled, invalid: invalid, focused: showPicker, placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t("time"), prefix: showIcon ? { icon: "timer" } : undefined, value: formattedTime, onClear: handleClear, onPress: showDatePicker }),
|
|
45
|
+
React.createElement(InputPressable, { showMiniLabel: showMiniLabel, clearable: canClearTime, disabled: disabled, invalid: invalid, focused: showPicker, placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t("time"), prefix: showIcon ? { icon: "timer" } : undefined, value: formattedTime, onClear: handleClear, onPress: showDatePicker }),
|
|
46
46
|
React.createElement(DateTimePicker, { testID: "inputTime-Picker", minuteInterval: getMinuteInterval(type), date: getInitialPickerDate(dateTime), timeZoneOffsetInMinutes: getTimeZoneOffsetInMinutes(timeZone, dateTime), isVisible: showPicker, mode: "time", onCancel: handleCancel, onConfirm: handleConfirm, is24Hour: is24Hour, locale: is24Hour ? LOCALE_24_HOURS : LOCALE_12_HOURS })));
|
|
47
47
|
function showDatePicker() {
|
|
48
48
|
Keyboard.dismiss();
|
package/dist/src/Menu/Menu.js
CHANGED
|
@@ -14,8 +14,8 @@ import { useAtlantisTheme } from "../AtlantisThemeContext";
|
|
|
14
14
|
export function Menu({ menuOptions, customActivator }) {
|
|
15
15
|
const [open, setOpen] = useState(false);
|
|
16
16
|
const [menuPosition, setMenuPosition] = useState();
|
|
17
|
-
const activatorLayout = useRef();
|
|
18
|
-
const menuButtonRef = useRef();
|
|
17
|
+
const activatorLayout = useRef(null);
|
|
18
|
+
const menuButtonRef = useRef(null);
|
|
19
19
|
const screenInfo = useScreenInformation();
|
|
20
20
|
const { t } = useAtlantisI18n();
|
|
21
21
|
const styles = useStyles();
|
|
@@ -7,7 +7,7 @@ import { useIsScreenReaderEnabled } from "../../../hooks";
|
|
|
7
7
|
* screen-reader is being used to avoid screen-readers from ignoring the press
|
|
8
8
|
* on the MenuView
|
|
9
9
|
*/
|
|
10
|
-
export function SelectPressable({ children, onPress
|
|
10
|
+
export function SelectPressable({ children, onPress }) {
|
|
11
11
|
const isScreenReaderEnabled = useIsScreenReaderEnabled();
|
|
12
12
|
const styles = useStyles();
|
|
13
13
|
if (isScreenReaderEnabled)
|
|
@@ -4,6 +4,7 @@ import { Switch } from "react-native-gesture-handler";
|
|
|
4
4
|
import { useFormController } from "../../../hooks";
|
|
5
5
|
import { useAtlantisTheme } from "../../../AtlantisThemeContext";
|
|
6
6
|
export function BaseSwitch({ value, defaultValue, onValueChange, disabled = false, accessibilityLabel, name, }) {
|
|
7
|
+
var _a;
|
|
7
8
|
const { field } = useFormController({
|
|
8
9
|
name,
|
|
9
10
|
value: value !== null && value !== void 0 ? value : defaultValue,
|
|
@@ -43,12 +44,17 @@ export function BaseSwitch({ value, defaultValue, onValueChange, disabled = fals
|
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
46
|
}
|
|
47
|
+
// Temporary fix for iOS 26. Remove when we upgrade to RN 0.81.
|
|
48
|
+
// https://github.com/facebook/react-native/pull/53389
|
|
49
|
+
const iOSBackgroundColor = Platform.OS === "ios" && ((_a = Platform.Version) === null || _a === void 0 ? void 0 : _a.startsWith("26."))
|
|
50
|
+
? undefined
|
|
51
|
+
: tokens["color-interactive--background"];
|
|
46
52
|
return (React.createElement(Switch, { value: internalValue, onValueChange: (val) => {
|
|
47
53
|
if (!disabled) {
|
|
48
54
|
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(val);
|
|
49
55
|
field.onChange(val);
|
|
50
56
|
}
|
|
51
|
-
}, disabled: disabled, thumbColor: getThumbColor(), trackColor: getTrackColors(), ios_backgroundColor:
|
|
57
|
+
}, disabled: disabled, thumbColor: getThumbColor(), trackColor: getTrackColors(), ios_backgroundColor: iOSBackgroundColor, accessibilityLabel: accessibilityLabel, accessibilityRole: "switch", accessibilityState: {
|
|
52
58
|
disabled: disabled,
|
|
53
59
|
checked: internalValue,
|
|
54
60
|
} }));
|
|
@@ -38,7 +38,7 @@ function InternalTypography({ fontFamily, fontStyle, fontWeight, transform, colo
|
|
|
38
38
|
style.push(UNSAFE_style.textStyle);
|
|
39
39
|
}
|
|
40
40
|
const numberOfLinesForNativeText = maxNumberOfLines[maxLines];
|
|
41
|
-
const
|
|
41
|
+
const content = transformChildren(children, transform);
|
|
42
42
|
const accessibilityProps = hideFromScreenReader
|
|
43
43
|
? {
|
|
44
44
|
accessibilityRole: "none",
|
|
@@ -50,7 +50,7 @@ function InternalTypography({ fontFamily, fontStyle, fontWeight, transform, colo
|
|
|
50
50
|
const textComponent = (React.createElement(Text, Object.assign({ allowFontScaling,
|
|
51
51
|
adjustsFontSizeToFit,
|
|
52
52
|
style,
|
|
53
|
-
numberOfLines: numberOfLinesForNativeText }, accessibilityProps, { maxFontSizeMultiplier: getScaleMultiplier(maxFontScaleSize, sizeAndHeight.fontSize), selectable: selectable, selectionColor: tokens["color-brand--highlight"], onTextLayout: onTextLayout }),
|
|
53
|
+
numberOfLines: numberOfLinesForNativeText }, accessibilityProps, { maxFontSizeMultiplier: getScaleMultiplier(maxFontScaleSize, sizeAndHeight.fontSize), selectable: selectable, selectionColor: tokens["color-brand--highlight"], onTextLayout: onTextLayout }), content));
|
|
54
54
|
// If text is not selectable, there's no need for TypographyGestureDetector
|
|
55
55
|
// since it only prevents accidental highlighting of selectable text
|
|
56
56
|
if (!selectable) {
|
|
@@ -80,15 +80,26 @@ function getFontStyle(fontFamily = "base", fontStyle = "regular", fontWeight = "
|
|
|
80
80
|
function getTransformedText(text, transform) {
|
|
81
81
|
switch (transform) {
|
|
82
82
|
case "lowercase":
|
|
83
|
-
return text
|
|
83
|
+
return text.toLocaleLowerCase();
|
|
84
84
|
case "uppercase":
|
|
85
|
-
return text
|
|
85
|
+
return text.toLocaleUpperCase();
|
|
86
86
|
case "capitalize":
|
|
87
|
-
return capitalize(text
|
|
87
|
+
return capitalize(text);
|
|
88
88
|
default:
|
|
89
89
|
return text;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
+
function transformChildren(children, transform) {
|
|
93
|
+
if (children == null || !transform || transform === "none")
|
|
94
|
+
return children;
|
|
95
|
+
return React.Children.map(children, child => {
|
|
96
|
+
if (typeof child === "string") {
|
|
97
|
+
return getTransformedText(child, transform);
|
|
98
|
+
}
|
|
99
|
+
// Keep non-string children (numbers, elements, fragments) unchanged
|
|
100
|
+
return child;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
92
103
|
function getColorStyle(styles, color, reverseTheme) {
|
|
93
104
|
if (color === "default" || !color) {
|
|
94
105
|
return styles.greyBlue;
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"goBack": "Go back",
|
|
19
19
|
"InputFieldWrapper.clear": "Clear input",
|
|
20
20
|
"InputPassword.enterPassword": "Enter a password",
|
|
21
|
+
"InputEmail.enterEmail": "Enter a valid email address (email@example.com)",
|
|
21
22
|
"loading": "Loading",
|
|
22
23
|
"menu": "Menu",
|
|
23
24
|
"more": "More",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"goBack": "Volver",
|
|
19
19
|
"InputFieldWrapper.clear": "Borrar",
|
|
20
20
|
"InputPassword.enterPassword": "Escriba una contraseña",
|
|
21
|
+
"InputEmail.enterEmail": "Introduzca una dirección de correo electrónico válida (email@example.com)",
|
|
21
22
|
"loading": "Cargando",
|
|
22
23
|
"menu": "Menú",
|
|
23
24
|
"more": "Más",
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { v1 } from "react-native-uuid";
|
|
2
|
-
import { useController, useForm, useFormContext } from "react-hook-form";
|
|
2
|
+
import { get, useController, useForm, useFormContext } from "react-hook-form";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
export function useFormController({ name, value, validations, }) {
|
|
5
|
-
var _a, _b;
|
|
6
5
|
const fieldName = useControlName(name);
|
|
7
6
|
const form = useForm({
|
|
8
7
|
mode: "onTouched",
|
|
@@ -17,18 +16,10 @@ export function useFormController({ name, value, validations, }) {
|
|
|
17
16
|
defaultValue: value || undefined,
|
|
18
17
|
});
|
|
19
18
|
// The naming convention established by react-hook-form for arrays of fields is, for example, "emails.0.description".
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
let error;
|
|
25
|
-
if (fieldIdentifiers.length === 3) {
|
|
26
|
-
const [section, item, identifier] = fieldIdentifiers;
|
|
27
|
-
error = (_b = (_a = errors[section]) === null || _a === void 0 ? void 0 : _a[item]) === null || _b === void 0 ? void 0 : _b[identifier];
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
error = errors[fieldName];
|
|
31
|
-
}
|
|
19
|
+
// Preserve original behavior: only treat three-part names as nested paths.
|
|
20
|
+
// For anything else, perform a flat lookup to avoid behavioral changes.
|
|
21
|
+
const identifiers = fieldName.split(".");
|
|
22
|
+
const error = identifiers.length === 3 ? get(errors, fieldName) : errors[fieldName];
|
|
32
23
|
return { error, field };
|
|
33
24
|
}
|
|
34
25
|
function useControlName(name) {
|