@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
|
@@ -23,13 +23,12 @@ const leftOffset = -1 * offset;
|
|
|
23
23
|
|
|
24
24
|
// looks like deprecation for FlatList in reanimated is cascading down to other exports
|
|
25
25
|
// This is not createAnimatedComponent(FlatList), we are fine
|
|
26
|
-
// eslint-disable-next-line import/no-deprecated
|
|
27
26
|
const AnimatedImage = Animated.createAnimatedComponent(ImageBackground);
|
|
28
27
|
|
|
29
28
|
function InternalButtonLoadingInternal({
|
|
30
29
|
variation,
|
|
31
30
|
type,
|
|
32
|
-
}: InternalButtonLoadingProps)
|
|
31
|
+
}: InternalButtonLoadingProps) {
|
|
33
32
|
const translateX = useSharedValue(0);
|
|
34
33
|
translateX.value = withRepeat(
|
|
35
34
|
withTiming(offset, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { fireEvent, render } from "@testing-library/react-native";
|
|
2
|
+
import { fireEvent, render, waitFor } from "@testing-library/react-native";
|
|
3
3
|
import { Host } from "react-native-portalize";
|
|
4
4
|
import { Alert } from "react-native";
|
|
5
5
|
import type { ButtonGroupProps } from "./ButtonGroup";
|
|
@@ -168,11 +168,11 @@ it("fires the press handlers when the primary action buttons are pressed", () =>
|
|
|
168
168
|
expect(editAction).toHaveBeenCalled();
|
|
169
169
|
});
|
|
170
170
|
|
|
171
|
-
it("opens the secondary action menu when the More button is pressed", () => {
|
|
171
|
+
it("opens the secondary action menu when the More button is pressed", async () => {
|
|
172
172
|
const createAction = jest.fn();
|
|
173
173
|
const editAction = jest.fn();
|
|
174
174
|
const deleteAction = jest.fn();
|
|
175
|
-
const {
|
|
175
|
+
const { findByText, queryByText, getByLabelText } = render(
|
|
176
176
|
<ButtonGroupForTest>
|
|
177
177
|
<ButtonGroup.PrimaryAction
|
|
178
178
|
label="Create"
|
|
@@ -196,14 +196,14 @@ it("opens the secondary action menu when the More button is pressed", () => {
|
|
|
196
196
|
|
|
197
197
|
fireEvent.press(getByLabelText("More"));
|
|
198
198
|
|
|
199
|
-
expect(
|
|
200
|
-
expect(
|
|
199
|
+
expect(await findByText("Edit")).not.toBeNull();
|
|
200
|
+
expect(await findByText("Delete")).not.toBeNull();
|
|
201
201
|
});
|
|
202
202
|
|
|
203
|
-
it("renders heading and cancel options if passed in", () => {
|
|
203
|
+
it("renders heading and cancel options if passed in", async () => {
|
|
204
204
|
const createAction = jest.fn();
|
|
205
205
|
const editAction = jest.fn();
|
|
206
|
-
const {
|
|
206
|
+
const { findByText, getByLabelText } = render(
|
|
207
207
|
<ButtonGroupForTest
|
|
208
208
|
bottomSheetHeading={"Heading"}
|
|
209
209
|
showCancelInBottomSheet={true}
|
|
@@ -223,8 +223,8 @@ it("renders heading and cancel options if passed in", () => {
|
|
|
223
223
|
|
|
224
224
|
fireEvent.press(getByLabelText("More"));
|
|
225
225
|
|
|
226
|
-
expect(
|
|
227
|
-
expect(
|
|
226
|
+
expect(await findByText("Heading")).not.toBeNull();
|
|
227
|
+
expect(await findByText("Cancel")).not.toBeNull();
|
|
228
228
|
});
|
|
229
229
|
|
|
230
230
|
it("renders custom button for primary action if passed in", () => {
|
|
@@ -249,7 +249,7 @@ it("renders custom button for primary action if passed in", () => {
|
|
|
249
249
|
expect(queryByText("Create")).toBeNull();
|
|
250
250
|
});
|
|
251
251
|
|
|
252
|
-
it("calls onOpenBottomSheet when the secondary actions are opened", () => {
|
|
252
|
+
it("calls onOpenBottomSheet when the secondary actions are opened", async () => {
|
|
253
253
|
const createAction = jest.fn();
|
|
254
254
|
const editAction = jest.fn();
|
|
255
255
|
const deleteAction = jest.fn();
|
|
@@ -275,7 +275,9 @@ it("calls onOpenBottomSheet when the secondary actions are opened", () => {
|
|
|
275
275
|
|
|
276
276
|
fireEvent.press(getByLabelText("More"));
|
|
277
277
|
|
|
278
|
-
|
|
278
|
+
await waitFor(() => {
|
|
279
|
+
expect(mockOnOpen).toHaveBeenCalledTimes(1);
|
|
280
|
+
});
|
|
279
281
|
});
|
|
280
282
|
|
|
281
283
|
describe("ButtonGroup Offline/Online", () => {
|
|
@@ -45,10 +45,10 @@ export function ButtonGroup({
|
|
|
45
45
|
onOpenBottomSheet,
|
|
46
46
|
onCloseBottomSheet,
|
|
47
47
|
allowTapWhenOffline = false,
|
|
48
|
-
}: ButtonGroupProps)
|
|
48
|
+
}: ButtonGroupProps) {
|
|
49
49
|
const { t } = useAtlantisI18n();
|
|
50
50
|
const { handlePress } = usePreventTapWhenOffline();
|
|
51
|
-
const secondaryActionsRef = useRef<BottomSheetRef>();
|
|
51
|
+
const secondaryActionsRef = useRef<BottomSheetRef>(null);
|
|
52
52
|
const { primaryActions, secondaryActions } = getActions(children);
|
|
53
53
|
const styles = useStyles();
|
|
54
54
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IconColorNames, IconNames } from "@jobber/design";
|
|
2
|
-
import React from "react";
|
|
2
|
+
import React, { type ReactElement } from "react";
|
|
3
3
|
import type { ButtonType, ButtonVariation } from "../Button";
|
|
4
4
|
|
|
5
5
|
export interface ButtonGroupActionProps {
|
|
@@ -49,18 +49,18 @@ export interface ButtonGroupPrimaryActionProps extends ButtonGroupActionProps {
|
|
|
49
49
|
/**
|
|
50
50
|
* Optional custom button that can be rendered in place of the primary action button
|
|
51
51
|
*/
|
|
52
|
-
customButton?:
|
|
52
|
+
customButton?: ReactElement;
|
|
53
53
|
loading?: boolean;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
57
|
-
export function PrimaryAction(_: ButtonGroupPrimaryActionProps)
|
|
57
|
+
export function PrimaryAction(_: ButtonGroupPrimaryActionProps) {
|
|
58
58
|
return <></>;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export function SecondaryAction(
|
|
62
62
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
63
63
|
_: ButtonGroupSecondaryActionProps,
|
|
64
|
-
)
|
|
64
|
+
) {
|
|
65
65
|
return <></>;
|
|
66
66
|
}
|
|
@@ -9,7 +9,7 @@ import { BottomSheet } from "../../../BottomSheet/BottomSheet";
|
|
|
9
9
|
|
|
10
10
|
interface SecondaryActionSheetProps {
|
|
11
11
|
readonly actions: ButtonGroupSecondaryActionProps[];
|
|
12
|
-
readonly secondaryActionsRef: RefObject<BottomSheetRef>;
|
|
12
|
+
readonly secondaryActionsRef: RefObject<BottomSheetRef | null>;
|
|
13
13
|
readonly showCancel?: boolean;
|
|
14
14
|
readonly heading?: string;
|
|
15
15
|
readonly onOpenBottomSheet?: () => void;
|
|
@@ -23,7 +23,7 @@ export function SecondaryActionSheet({
|
|
|
23
23
|
showCancel,
|
|
24
24
|
onOpenBottomSheet,
|
|
25
25
|
onCloseBottomSheet,
|
|
26
|
-
}: SecondaryActionSheetProps)
|
|
26
|
+
}: SecondaryActionSheetProps) {
|
|
27
27
|
return (
|
|
28
28
|
<Portal>
|
|
29
29
|
<BottomSheet
|
package/src/Card/Card.tsx
CHANGED
|
@@ -15,7 +15,7 @@ export function InternalCardHeader({
|
|
|
15
15
|
children,
|
|
16
16
|
testID,
|
|
17
17
|
collapsable,
|
|
18
|
-
}: InternalCardHeaderProps)
|
|
18
|
+
}: InternalCardHeaderProps) {
|
|
19
19
|
const styles = useStyles();
|
|
20
20
|
|
|
21
21
|
const conditionalChildStyling = collapsable ? undefined : styles.noChildren;
|
|
@@ -79,7 +79,7 @@ export type CheckboxProps = XOR<
|
|
|
79
79
|
UncontrolledCheckboxProps
|
|
80
80
|
>;
|
|
81
81
|
|
|
82
|
-
export function Checkbox(props: CheckboxProps)
|
|
82
|
+
export function Checkbox(props: CheckboxProps) {
|
|
83
83
|
if (props.checked !== undefined && props.onChange !== undefined) {
|
|
84
84
|
return <CheckboxInternal {...props} />;
|
|
85
85
|
} else if (props.name) {
|
|
@@ -113,7 +113,7 @@ function CheckboxInternal({
|
|
|
113
113
|
assistiveText,
|
|
114
114
|
onChange,
|
|
115
115
|
accessibilityLabel,
|
|
116
|
-
}: CheckboxProps)
|
|
116
|
+
}: CheckboxProps) {
|
|
117
117
|
const internalValue = checked ?? !!defaultChecked;
|
|
118
118
|
|
|
119
119
|
const iconName = indeterminate ? "minus2" : "checkmark";
|
|
@@ -66,7 +66,7 @@ function SetupWithForm({
|
|
|
66
66
|
}: {
|
|
67
67
|
readonly initialValues: CheckboxGroupFormData;
|
|
68
68
|
readonly onChangeHandlers?: CheckboxGroupFormOnChangeHandlers;
|
|
69
|
-
})
|
|
69
|
+
}) {
|
|
70
70
|
const formMethods = useForm({ defaultValues: initialValues });
|
|
71
71
|
|
|
72
72
|
return (
|
|
@@ -172,12 +172,8 @@ describe("when the parent checkbox does not have a label", () => {
|
|
|
172
172
|
it("does not render the parent checkbox", async () => {
|
|
173
173
|
const { checkboxGroup } = setup(undefined);
|
|
174
174
|
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
};
|
|
178
|
-
expect(findParentCheckbox).toThrow(
|
|
179
|
-
"Unable to find an element with accessibilityLabel: all condiments",
|
|
180
|
-
);
|
|
175
|
+
const parentCheckbox = checkboxGroup.queryByLabelText(parentCheckboxLabel);
|
|
176
|
+
expect(parentCheckbox).toBeNull();
|
|
181
177
|
});
|
|
182
178
|
});
|
|
183
179
|
|
|
@@ -46,7 +46,7 @@ export function CheckboxGroup({
|
|
|
46
46
|
onChange,
|
|
47
47
|
name,
|
|
48
48
|
...rest
|
|
49
|
-
}: CheckboxGroupProps)
|
|
49
|
+
}: CheckboxGroupProps) {
|
|
50
50
|
if (state !== undefined && onChange !== undefined) {
|
|
51
51
|
return (
|
|
52
52
|
<CheckboxGroupInternal
|
|
@@ -92,7 +92,7 @@ function CheckboxGroupInternal({
|
|
|
92
92
|
accessibilityLabel,
|
|
93
93
|
onChange,
|
|
94
94
|
name: parentName,
|
|
95
|
-
}: ControlledCheckboxGroupProps)
|
|
95
|
+
}: ControlledCheckboxGroupProps) {
|
|
96
96
|
const childrenNames = React.Children.map(children, child => {
|
|
97
97
|
const name = throwErrorIfItHasNoName(child.props.name);
|
|
98
98
|
|
package/src/Chip/Chip.tsx
CHANGED
|
@@ -68,7 +68,7 @@ export function Chip({
|
|
|
68
68
|
accessibilityLabel,
|
|
69
69
|
accessibilityRole = "radio",
|
|
70
70
|
accent,
|
|
71
|
-
}: ChipProps)
|
|
71
|
+
}: ChipProps) {
|
|
72
72
|
const styles = useStyles();
|
|
73
73
|
const { tokens } = useAtlantisTheme();
|
|
74
74
|
const defaultAccentColor = tokens["color-surface--reverse"];
|
package/src/Content/Content.tsx
CHANGED
|
@@ -51,7 +51,7 @@ export function Content({
|
|
|
51
51
|
childSpacing = "base",
|
|
52
52
|
direction = "vertical",
|
|
53
53
|
UNSAFE_style,
|
|
54
|
-
}: ContentProps)
|
|
54
|
+
}: ContentProps) {
|
|
55
55
|
const horizontalStyles = useHorizontalStyles();
|
|
56
56
|
const verticalStyles = useVerticalStyles();
|
|
57
57
|
const spaceAroundStyles = useSpaceAroundStyles();
|
|
@@ -4,7 +4,7 @@ import { AccessibilityInfo, View } from "react-native";
|
|
|
4
4
|
import { Host } from "react-native-portalize";
|
|
5
5
|
import type { ReactTestInstance } from "react-test-renderer";
|
|
6
6
|
import { act } from "react-test-renderer";
|
|
7
|
-
import type { ContentOverlayRef, ModalBackgroundColor } from "./
|
|
7
|
+
import type { ContentOverlayRef, ModalBackgroundColor } from "./types";
|
|
8
8
|
import { ContentOverlay } from "./ContentOverlay";
|
|
9
9
|
import { tokens } from "../utils/design";
|
|
10
10
|
import { Button } from "../Button";
|
|
@@ -106,23 +106,30 @@ function renderContentOverlay(
|
|
|
106
106
|
return renderResult;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
function renderAndOpenContentOverlay(
|
|
109
|
+
async function renderAndOpenContentOverlay(
|
|
110
|
+
defaultOptions = getDefaultOptions(),
|
|
111
|
+
) {
|
|
110
112
|
const rendered = renderContentOverlay(defaultOptions);
|
|
111
113
|
|
|
112
|
-
act(() => {
|
|
114
|
+
await act(async () => {
|
|
113
115
|
fireEvent.press(rendered.getByLabelText(defaultOptions.buttonLabel));
|
|
114
116
|
});
|
|
115
117
|
|
|
118
|
+
// Wait for the modal to open asynchronously (due to requestAnimationFrame)
|
|
119
|
+
await waitFor(() => {
|
|
120
|
+
expect(rendered.getByTestId("ATL-Overlay-Header")).toBeDefined();
|
|
121
|
+
});
|
|
122
|
+
|
|
116
123
|
return rendered;
|
|
117
124
|
}
|
|
118
125
|
|
|
119
126
|
describe("when open is called on the content overlay ref", () => {
|
|
120
|
-
it("should open the content overlay, exposing the content to the user", () => {
|
|
127
|
+
it("should open the content overlay, exposing the content to the user", async () => {
|
|
121
128
|
const options: testRendererOptions = {
|
|
122
129
|
...getDefaultOptions(),
|
|
123
130
|
text: "I am text within the content overlay",
|
|
124
131
|
};
|
|
125
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
132
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
126
133
|
|
|
127
134
|
expect(contentOverlayScreen.getByText(options.text)).toBeDefined();
|
|
128
135
|
});
|
|
@@ -135,9 +142,9 @@ describe("when the close button is clicked on an open content overlay", () => {
|
|
|
135
142
|
text: "I am text within the content overlay",
|
|
136
143
|
showDismiss: true,
|
|
137
144
|
};
|
|
138
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
145
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
139
146
|
|
|
140
|
-
act(() => {
|
|
147
|
+
await act(async () => {
|
|
141
148
|
fireEvent.press(
|
|
142
149
|
contentOverlayScreen.getByTestId("ATL-Overlay-CloseButton"),
|
|
143
150
|
);
|
|
@@ -156,9 +163,9 @@ describe("when the close button is clicked on an open content overlay with a def
|
|
|
156
163
|
onCloseCallback: jest.fn(),
|
|
157
164
|
showDismiss: true,
|
|
158
165
|
};
|
|
159
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
166
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
160
167
|
|
|
161
|
-
act(() => {
|
|
168
|
+
await act(async () => {
|
|
162
169
|
fireEvent.press(
|
|
163
170
|
contentOverlayScreen.getByTestId("ATL-Overlay-CloseButton"),
|
|
164
171
|
);
|
|
@@ -191,7 +198,7 @@ describe("when the content overlay is created with a defined onOpen prop", () =>
|
|
|
191
198
|
...getDefaultOptions(),
|
|
192
199
|
onOpenCallback: jest.fn(),
|
|
193
200
|
};
|
|
194
|
-
renderAndOpenContentOverlay(options);
|
|
201
|
+
await renderAndOpenContentOverlay(options);
|
|
195
202
|
|
|
196
203
|
await waitFor(() => {
|
|
197
204
|
expect(options.onOpenCallback).toHaveBeenCalled();
|
|
@@ -201,25 +208,25 @@ describe("when the content overlay is created with a defined onOpen prop", () =>
|
|
|
201
208
|
});
|
|
202
209
|
|
|
203
210
|
describe("when title prop passed to content overlay", () => {
|
|
204
|
-
it("should set the header title", () => {
|
|
211
|
+
it("should set the header title", async () => {
|
|
205
212
|
const options: testRendererOptions = {
|
|
206
213
|
...getDefaultOptions(),
|
|
207
214
|
title: "Awesome Title",
|
|
208
215
|
};
|
|
209
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
216
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
210
217
|
|
|
211
218
|
expect(contentOverlayScreen.getByText(options.title)).toBeDefined();
|
|
212
219
|
});
|
|
213
220
|
});
|
|
214
221
|
|
|
215
222
|
describe("when accessibilityLabel prop passed to content overlay", () => {
|
|
216
|
-
it("should set the header accessibilityLabel", () => {
|
|
223
|
+
it("should set the header accessibilityLabel", async () => {
|
|
217
224
|
const options: testRendererOptions = {
|
|
218
225
|
...getDefaultOptions(),
|
|
219
226
|
a11yLabel: "Awesome a11y Label",
|
|
220
227
|
showDismiss: true,
|
|
221
228
|
};
|
|
222
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
229
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
223
230
|
|
|
224
231
|
expect(
|
|
225
232
|
contentOverlayScreen.getByLabelText(options.a11yLabel || "ohno"),
|
|
@@ -228,13 +235,13 @@ describe("when accessibilityLabel prop passed to content overlay", () => {
|
|
|
228
235
|
});
|
|
229
236
|
|
|
230
237
|
describe("when accessibilityLabel prop NOT passed to content overlay", () => {
|
|
231
|
-
it("should use default accessibilityLabel", () => {
|
|
238
|
+
it("should use default accessibilityLabel", async () => {
|
|
232
239
|
const options: testRendererOptions = {
|
|
233
240
|
...getDefaultOptions(),
|
|
234
241
|
title: "Awesome Title",
|
|
235
242
|
showDismiss: true,
|
|
236
243
|
};
|
|
237
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
244
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
238
245
|
|
|
239
246
|
expect(
|
|
240
247
|
contentOverlayScreen.getAllByLabelText(`Close ${options.title} modal`),
|
|
@@ -251,7 +258,7 @@ describe("when there is a screen reader enabled", () => {
|
|
|
251
258
|
const options: testRendererOptions = {
|
|
252
259
|
...getDefaultOptions(),
|
|
253
260
|
};
|
|
254
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
261
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
255
262
|
|
|
256
263
|
expect(
|
|
257
264
|
await contentOverlayScreen.findByTestId("ATL-Overlay-CloseButton"),
|
|
@@ -260,12 +267,12 @@ describe("when there is a screen reader enabled", () => {
|
|
|
260
267
|
});
|
|
261
268
|
|
|
262
269
|
describe("when fullScreen is set to true", () => {
|
|
263
|
-
it("should show the dismiss button", () => {
|
|
270
|
+
it("should show the dismiss button", async () => {
|
|
264
271
|
const options: testRendererOptions = {
|
|
265
272
|
...getDefaultOptions(),
|
|
266
273
|
fullScreen: true,
|
|
267
274
|
};
|
|
268
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
275
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
269
276
|
expect(
|
|
270
277
|
contentOverlayScreen.getByTestId("ATL-Overlay-CloseButton"),
|
|
271
278
|
).toBeDefined();
|
|
@@ -273,12 +280,12 @@ describe("when fullScreen is set to true", () => {
|
|
|
273
280
|
});
|
|
274
281
|
|
|
275
282
|
describe("when showDismiss is set to true", () => {
|
|
276
|
-
it("should show the dismiss button", () => {
|
|
283
|
+
it("should show the dismiss button", async () => {
|
|
277
284
|
const options: testRendererOptions = {
|
|
278
285
|
...getDefaultOptions(),
|
|
279
286
|
showDismiss: true,
|
|
280
287
|
};
|
|
281
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
288
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
282
289
|
expect(
|
|
283
290
|
contentOverlayScreen.getByTestId("ATL-Overlay-CloseButton"),
|
|
284
291
|
).toBeDefined();
|
|
@@ -292,9 +299,9 @@ describe("when the close button is clicked on an open content overlay with a def
|
|
|
292
299
|
onBeforeExitCallback: jest.fn(),
|
|
293
300
|
showDismiss: true,
|
|
294
301
|
};
|
|
295
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
302
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
296
303
|
|
|
297
|
-
act(() => {
|
|
304
|
+
await act(async () => {
|
|
298
305
|
fireEvent.press(
|
|
299
306
|
contentOverlayScreen.getByTestId("ATL-Overlay-CloseButton"),
|
|
300
307
|
);
|
|
@@ -308,11 +315,11 @@ describe("when the close button is clicked on an open content overlay with a def
|
|
|
308
315
|
|
|
309
316
|
describe("modalBackgroundColor prop", () => {
|
|
310
317
|
describe("when using the default surface value", () => {
|
|
311
|
-
it("renders the component with the color-surface color", () => {
|
|
318
|
+
it("renders the component with the color-surface color", async () => {
|
|
312
319
|
const options: testRendererOptions = {
|
|
313
320
|
...getDefaultOptions(),
|
|
314
321
|
};
|
|
315
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
322
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
316
323
|
const OverlayHeader = contentOverlayScreen.getByTestId(
|
|
317
324
|
"ATL-Overlay-Header",
|
|
318
325
|
).children[0] as ReactTestInstance;
|
|
@@ -337,12 +344,12 @@ describe("modalBackgroundColor prop", () => {
|
|
|
337
344
|
});
|
|
338
345
|
|
|
339
346
|
describe("when set to background", () => {
|
|
340
|
-
it("changes the backround color of the modal to color-surface--background", () => {
|
|
347
|
+
it("changes the backround color of the modal to color-surface--background", async () => {
|
|
341
348
|
const options: testRendererOptions = {
|
|
342
349
|
...getDefaultOptions(),
|
|
343
350
|
modalBackgroundColor: "background",
|
|
344
351
|
};
|
|
345
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
352
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
346
353
|
const OverlayHeader = contentOverlayScreen.getByTestId(
|
|
347
354
|
"ATL-Overlay-Header",
|
|
348
355
|
).children[0] as ReactTestInstance;
|
|
@@ -7,7 +7,7 @@ import React, {
|
|
|
7
7
|
useRef,
|
|
8
8
|
useState,
|
|
9
9
|
} from "react";
|
|
10
|
-
import { Modalize } from "react-native-modalize";
|
|
10
|
+
import type { Modalize } from "react-native-modalize";
|
|
11
11
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
12
12
|
import type { NativeScrollEvent, NativeSyntheticEvent } from "react-native";
|
|
13
13
|
import {
|
|
@@ -26,6 +26,7 @@ import type {
|
|
|
26
26
|
ContentOverlayRef,
|
|
27
27
|
ModalBackgroundColor,
|
|
28
28
|
} from "./types";
|
|
29
|
+
import { UNSAFE_WrappedModalize } from "./UNSAFE_WrappedModalize";
|
|
29
30
|
import { useIsScreenReaderEnabled } from "../hooks";
|
|
30
31
|
import { IconButton } from "../IconButton";
|
|
31
32
|
import { Heading } from "../Heading";
|
|
@@ -56,7 +57,7 @@ function ContentOverlayInternal(
|
|
|
56
57
|
avoidKeyboardLikeIOS,
|
|
57
58
|
}: ContentOverlayProps,
|
|
58
59
|
ref: Ref<ContentOverlayRef>,
|
|
59
|
-
)
|
|
60
|
+
) {
|
|
60
61
|
isDraggable = onBeforeExit ? false : isDraggable;
|
|
61
62
|
const isCloseableOnOverlayTap = onBeforeExit ? false : true;
|
|
62
63
|
const { t } = useAtlantisI18n();
|
|
@@ -70,9 +71,9 @@ function ContentOverlayInternal(
|
|
|
70
71
|
const shouldShowDismiss =
|
|
71
72
|
showDismiss || isScreenReaderEnabled || isFullScreenOrTopPosition;
|
|
72
73
|
const [showHeaderShadow, setShowHeaderShadow] = useState<boolean>(false);
|
|
73
|
-
const overlayHeader = useRef<View>();
|
|
74
|
+
const overlayHeader = useRef<View>(null);
|
|
74
75
|
|
|
75
|
-
const internalRef = useRef<Modalize>();
|
|
76
|
+
const internalRef = useRef<Modalize>(null);
|
|
76
77
|
const [modalizeMethods, setModalizeMethods] = useState<ContentOverlayRef>();
|
|
77
78
|
const callbackInternalRef = useCallback((instance: Modalize) => {
|
|
78
79
|
if (instance && !internalRef.current) {
|
|
@@ -153,7 +154,7 @@ function ContentOverlayInternal(
|
|
|
153
154
|
return (
|
|
154
155
|
<>
|
|
155
156
|
{headerHeightKnown && childrenHeightKnown && (
|
|
156
|
-
<
|
|
157
|
+
<UNSAFE_WrappedModalize
|
|
157
158
|
ref={callbackInternalRef}
|
|
158
159
|
overlayStyle={styles.overlay}
|
|
159
160
|
handleStyle={styles.handle}
|
|
@@ -196,7 +197,7 @@ function ContentOverlayInternal(
|
|
|
196
197
|
>
|
|
197
198
|
{Platform.OS === "android" ? renderedHeader : undefined}
|
|
198
199
|
{renderedChildren}
|
|
199
|
-
</
|
|
200
|
+
</UNSAFE_WrappedModalize>
|
|
200
201
|
)}
|
|
201
202
|
{!childrenHeightKnown && (
|
|
202
203
|
<View style={[styles.hiddenContent, modalStyle]}>
|
|
@@ -243,7 +244,6 @@ function ContentOverlayInternal(
|
|
|
243
244
|
{shouldShowDismiss && (
|
|
244
245
|
<View
|
|
245
246
|
style={styles.dismissButton}
|
|
246
|
-
// @ts-expect-error tsc-ci
|
|
247
247
|
ref={overlayHeader}
|
|
248
248
|
accessibilityLabel={accessibilityLabel || closeOverlayA11YLabel}
|
|
249
249
|
accessible={true}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useImperativeHandle,
|
|
4
|
+
useRef,
|
|
5
|
+
useState,
|
|
6
|
+
} from "react";
|
|
7
|
+
import { Modalize } from "react-native-modalize";
|
|
8
|
+
import type { IHandles } from "react-native-modalize/lib/options";
|
|
9
|
+
|
|
10
|
+
type Props = React.ComponentProps<typeof Modalize>;
|
|
11
|
+
|
|
12
|
+
export const UNSAFE_WrappedModalize = forwardRef<IHandles | undefined, Props>(
|
|
13
|
+
(props, ref) => {
|
|
14
|
+
const innerRef = useRef<IHandles | null>(null);
|
|
15
|
+
const [openRenderId, setOpenRenderId] = useState(0);
|
|
16
|
+
|
|
17
|
+
useImperativeHandle(
|
|
18
|
+
ref,
|
|
19
|
+
() => ({
|
|
20
|
+
open(dest) {
|
|
21
|
+
setOpenRenderId(id => id + 1);
|
|
22
|
+
// Open on a fresh tick for additional safety
|
|
23
|
+
requestAnimationFrame(() => {
|
|
24
|
+
innerRef.current?.open(dest);
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
close(dest) {
|
|
28
|
+
innerRef.current?.close(dest);
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
[],
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
// Use a unique key to force a remount, ensuring we get fresh gesture handler nodes within modalize
|
|
35
|
+
return (
|
|
36
|
+
<Modalize key={`modalize-${openRenderId}`} ref={innerRef} {...props} />
|
|
37
|
+
);
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
UNSAFE_WrappedModalize.displayName = "UNSAFE_WrappedModalize";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { act, renderHook } from "@testing-library/react-
|
|
1
|
+
import { act, renderHook } from "@testing-library/react-native";
|
|
2
2
|
import type { KeyboardEvent } from "react-native";
|
|
3
3
|
import { DeviceEventEmitter } from "react-native";
|
|
4
4
|
import { useKeyboardVisibility } from "./useKeyboardVisibility";
|
|
@@ -8,19 +8,19 @@ const keyboardEvent: Partial<KeyboardEvent> = {
|
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
describe("when the user is typing", () => {
|
|
11
|
-
it("sets the isKeyboardVisible to true", () => {
|
|
11
|
+
it("sets the isKeyboardVisible to true", async () => {
|
|
12
12
|
const { result } = renderHook(() => useKeyboardVisibility());
|
|
13
13
|
|
|
14
|
-
act(() => {
|
|
14
|
+
await act(async () => {
|
|
15
15
|
DeviceEventEmitter.emit("keyboardDidShow", keyboardEvent);
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
expect(result.current.isKeyboardVisible).toBe(true);
|
|
19
19
|
});
|
|
20
|
-
it("the keyboardDidShow event emits the keyboard height", () => {
|
|
20
|
+
it("the keyboardDidShow event emits the keyboard height", async () => {
|
|
21
21
|
const { result } = renderHook(() => useKeyboardVisibility());
|
|
22
22
|
|
|
23
|
-
act(() => {
|
|
23
|
+
await act(async () => {
|
|
24
24
|
DeviceEventEmitter.emit("keyboardDidShow", keyboardEvent);
|
|
25
25
|
});
|
|
26
26
|
|
|
@@ -31,10 +31,10 @@ describe("when the user is typing", () => {
|
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
describe("when the user not typing", () => {
|
|
34
|
-
it("sets the isKeyboardVisible to false", () => {
|
|
34
|
+
it("sets the isKeyboardVisible to false", async () => {
|
|
35
35
|
const { result } = renderHook(() => useKeyboardVisibility());
|
|
36
36
|
|
|
37
|
-
act(() => {
|
|
37
|
+
await act(async () => {
|
|
38
38
|
DeviceEventEmitter.emit("keyboardDidHide");
|
|
39
39
|
});
|
|
40
40
|
|
package/src/Divider/Divider.tsx
CHANGED