@jobber/components-native 0.84.4-match-mobi-55ef4ec.7 → 0.84.4-match-mobi-540af48.10
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 +26 -15
- 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 +58 -32
- package/dist/src/BottomSheet/BottomSheet.style.js +8 -9
- package/dist/src/BottomSheet/hooks/useBottomSheetBackHandler.js +26 -0
- package/dist/src/Button/components/InternalButtonLoading/InternalButtonLoading.js +0 -1
- package/dist/src/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/src/Chip/Chip.js +12 -1
- package/dist/src/Chip/Chip.style.js +1 -1
- package/dist/src/Content/ContentHorizontal.style.js +15 -0
- package/dist/src/Content/ContentSpaceAround.style.js +15 -0
- package/dist/src/Content/ContentVertical.style.js +15 -0
- 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 +24 -13
- 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/ProgressBar/ProgressBar.js +10 -6
- package/dist/src/ProgressBar/ProgressBarInner.js +3 -12
- package/dist/src/ProgressBar/ProgressBarStepped.js +7 -2
- package/dist/src/Select/Select.style.js +1 -0
- package/dist/src/Select/components/SelectPressable/SelectPressable.js +1 -1
- package/dist/src/StatusLabel/StatusLabel.style.js +2 -2
- 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 +6 -15
- 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 +7 -3
- package/dist/types/src/BottomSheet/BottomSheet.style.d.ts +7 -14
- package/dist/types/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.d.ts +2 -1
- package/dist/types/src/BottomSheet/hooks/useBottomSheetBackHandler.d.ts +8 -0
- 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 +3 -2
- package/dist/types/src/Content/ContentHorizontal.style.d.ts +15 -0
- package/dist/types/src/Content/ContentSpaceAround.style.d.ts +15 -0
- package/dist/types/src/Content/ContentVertical.style.d.ts +15 -0
- 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 +5 -4
- package/dist/types/src/Form/hooks/useFormViewRefs.d.ts +2 -2
- package/dist/types/src/Form/hooks/useInternalForm.d.ts +7 -7
- 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 +11 -3
- 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 +5 -1
- package/dist/types/src/ProgressBar/ProgressBarStepped.d.ts +3 -1
- package/dist/types/src/ProgressBar/types.d.ts +20 -0
- 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/StatusLabel/StatusLabel.style.d.ts +1 -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 +26 -15
- 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.stories.tsx +128 -0
- package/src/BottomSheet/BottomSheet.style.ts +7 -14
- package/src/BottomSheet/BottomSheet.test.tsx +34 -39
- package/src/BottomSheet/BottomSheet.tsx +112 -92
- package/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.tsx +1 -1
- package/src/BottomSheet/hooks/useBottomSheetBackHandler.test.ts +90 -0
- package/src/BottomSheet/hooks/useBottomSheetBackHandler.ts +41 -0
- 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.test.tsx +118 -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.style.ts +1 -1
- package/src/Chip/Chip.tsx +20 -2
- package/src/Content/Content.tsx +7 -2
- package/src/Content/ContentHorizontal.style.ts +20 -0
- package/src/Content/ContentSpaceAround.style.ts +20 -0
- package/src/Content/ContentVertical.style.ts +20 -0
- 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 +5 -4
- package/src/Form/hooks/useFormViewRefs.ts +4 -5
- package/src/Form/hooks/useInternalForm.ts +14 -6
- 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 +190 -1
- package/src/InputText/InputText.tsx +37 -20
- 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.test.tsx +109 -0
- package/src/ProgressBar/ProgressBar.tsx +18 -2
- package/src/ProgressBar/ProgressBarInner.tsx +8 -11
- package/src/ProgressBar/ProgressBarStepped.tsx +12 -1
- package/src/ProgressBar/__snapshots__/ProgressBar.test.tsx.snap +14 -0
- package/src/ProgressBar/types.ts +22 -0
- 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.style.ts +2 -2
- package/src/StatusLabel/StatusLabel.tsx +1 -1
- package/src/StatusLabel/__snapshots__/StatusLabel.test.tsx.snap +14 -14
- 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/ThumbnailList/__snapshots__/ThumbnailList.test.tsx.snap +199 -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 +7 -14
- package/src/utils/test/MockSafeAreaProvider.tsx +1 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { createRef } from "react";
|
|
2
|
+
import type { RefObject } from "react";
|
|
3
|
+
import { act, renderHook } from "@testing-library/react-native";
|
|
4
|
+
import { BackHandler } from "react-native";
|
|
5
|
+
import type BottomSheet from "@gorhom/bottom-sheet";
|
|
6
|
+
import { useBottomSheetBackHandler } from "./useBottomSheetBackHandler";
|
|
7
|
+
|
|
8
|
+
describe("useBottomSheetBackHandler", () => {
|
|
9
|
+
let mockRemove: jest.Mock;
|
|
10
|
+
let mockAddEventListener: jest.SpyInstance;
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
mockRemove = jest.fn();
|
|
14
|
+
mockAddEventListener = jest.spyOn(BackHandler, "addEventListener");
|
|
15
|
+
mockAddEventListener.mockReturnValue({ remove: mockRemove });
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
mockAddEventListener.mockRestore();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should register BackHandler listener when sheet becomes visible", async () => {
|
|
23
|
+
const bottomSheetRef = createRef<BottomSheet | null>();
|
|
24
|
+
const { result } = renderHook(() =>
|
|
25
|
+
useBottomSheetBackHandler(bottomSheetRef),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
await act(async () => {
|
|
29
|
+
result.current.handleSheetPositionChange(0);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
expect(mockAddEventListener).toHaveBeenCalledWith(
|
|
33
|
+
"hardwareBackPress",
|
|
34
|
+
expect.any(Function),
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("should call close() when back button is pressed", async () => {
|
|
39
|
+
const mockClose = jest.fn();
|
|
40
|
+
const bottomSheetRef = {
|
|
41
|
+
current: {
|
|
42
|
+
close: mockClose,
|
|
43
|
+
} as unknown as BottomSheet,
|
|
44
|
+
} as RefObject<BottomSheet | null>;
|
|
45
|
+
|
|
46
|
+
const { result } = renderHook(() =>
|
|
47
|
+
useBottomSheetBackHandler(bottomSheetRef),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
await act(async () => {
|
|
51
|
+
result.current.handleSheetPositionChange(0);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const registeredCallback = mockAddEventListener.mock.calls[0][1];
|
|
55
|
+
const returnValue = registeredCallback();
|
|
56
|
+
|
|
57
|
+
expect(mockClose).toHaveBeenCalled();
|
|
58
|
+
expect(returnValue).toBe(true);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("should remove listener when sheet is dismissed", async () => {
|
|
62
|
+
const bottomSheetRef = createRef<BottomSheet | null>();
|
|
63
|
+
const { result } = renderHook(() =>
|
|
64
|
+
useBottomSheetBackHandler(bottomSheetRef),
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
await act(async () => {
|
|
68
|
+
result.current.handleSheetPositionChange(0);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
await act(async () => {
|
|
72
|
+
result.current.handleSheetPositionChange(-1);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
expect(mockRemove).toHaveBeenCalled();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("should not register listener when index is negative", async () => {
|
|
79
|
+
const bottomSheetRef = createRef<BottomSheet | null>();
|
|
80
|
+
const { result } = renderHook(() =>
|
|
81
|
+
useBottomSheetBackHandler(bottomSheetRef),
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
await act(async () => {
|
|
85
|
+
result.current.handleSheetPositionChange(-1);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
expect(mockAddEventListener).not.toHaveBeenCalled();
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useCallback, useRef } from "react";
|
|
2
|
+
import { BackHandler, type NativeEventSubscription } from "react-native";
|
|
3
|
+
import type BottomSheet from "@gorhom/bottom-sheet";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Hook that closes the bottom sheet on the hardware back button press if it is visible
|
|
7
|
+
* @param bottomSheetRef ref to the bottom sheet component
|
|
8
|
+
*/
|
|
9
|
+
export function useBottomSheetBackHandler(
|
|
10
|
+
bottomSheetRef: React.RefObject<BottomSheet | null>,
|
|
11
|
+
): {
|
|
12
|
+
handleSheetPositionChange: (index: number) => void;
|
|
13
|
+
} {
|
|
14
|
+
const backHandlerSubscriptionRef = useRef<NativeEventSubscription | null>(
|
|
15
|
+
null,
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const handleSheetPositionChange = useCallback(
|
|
19
|
+
(index: number) => {
|
|
20
|
+
const isBottomSheetVisible = index >= 0;
|
|
21
|
+
|
|
22
|
+
if (isBottomSheetVisible && !backHandlerSubscriptionRef.current) {
|
|
23
|
+
// Setup the back handler if the bottom sheet is right in front of the user
|
|
24
|
+
backHandlerSubscriptionRef.current = BackHandler.addEventListener(
|
|
25
|
+
"hardwareBackPress",
|
|
26
|
+
() => {
|
|
27
|
+
bottomSheetRef.current?.close();
|
|
28
|
+
|
|
29
|
+
return true;
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
} else if (!isBottomSheetVisible) {
|
|
33
|
+
backHandlerSubscriptionRef.current?.remove();
|
|
34
|
+
backHandlerSubscriptionRef.current = null;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
[bottomSheetRef],
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return { handleSheetPositionChange };
|
|
41
|
+
}
|
package/src/Button/Button.tsx
CHANGED
|
@@ -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;
|
|
@@ -1,5 +1,7 @@
|
|
|
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
|
+
import { FormProvider, useForm } from "react-hook-form";
|
|
4
|
+
import { Button } from "react-native";
|
|
3
5
|
import { Checkbox } from "./Checkbox";
|
|
4
6
|
|
|
5
7
|
const accessibilityLabel = "testA11y";
|
|
@@ -102,3 +104,118 @@ describe("Checkbox", () => {
|
|
|
102
104
|
expect(getByTestId("minus2")).toBeDefined();
|
|
103
105
|
});
|
|
104
106
|
});
|
|
107
|
+
|
|
108
|
+
describe("Checkbox with FormProvider", () => {
|
|
109
|
+
const mockOnSubmit = jest.fn();
|
|
110
|
+
const checkboxName = "testCheckbox";
|
|
111
|
+
const checkboxLabel = "Test Checkbox";
|
|
112
|
+
const saveButtonText = "Save";
|
|
113
|
+
|
|
114
|
+
function FormWithProvider({
|
|
115
|
+
defaultChecked,
|
|
116
|
+
}: {
|
|
117
|
+
readonly defaultChecked?: boolean;
|
|
118
|
+
}) {
|
|
119
|
+
const formMethods = useForm();
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<FormProvider {...formMethods}>
|
|
123
|
+
<Checkbox
|
|
124
|
+
name={checkboxName}
|
|
125
|
+
label={checkboxLabel}
|
|
126
|
+
defaultChecked={defaultChecked}
|
|
127
|
+
accessibilityLabel={accessibilityLabel}
|
|
128
|
+
/>
|
|
129
|
+
<Button
|
|
130
|
+
onPress={formMethods.handleSubmit(values => mockOnSubmit(values))}
|
|
131
|
+
title={saveButtonText}
|
|
132
|
+
accessibilityLabel={saveButtonText}
|
|
133
|
+
/>
|
|
134
|
+
</FormProvider>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
beforeEach(() => {
|
|
139
|
+
mockOnSubmit.mockClear();
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
describe("defaultChecked prop sets form value", () => {
|
|
143
|
+
it("sets form value to true when defaultChecked is true", async () => {
|
|
144
|
+
const { getByLabelText } = render(
|
|
145
|
+
<FormWithProvider defaultChecked={true} />,
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
const saveButton = getByLabelText(saveButtonText);
|
|
149
|
+
await waitFor(() => {
|
|
150
|
+
fireEvent.press(saveButton);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
expect(mockOnSubmit).toHaveBeenCalledWith({
|
|
154
|
+
[checkboxName]: true,
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("sets form value to false when defaultChecked is false", async () => {
|
|
159
|
+
const { getByLabelText } = render(
|
|
160
|
+
<FormWithProvider defaultChecked={false} />,
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
const saveButton = getByLabelText(saveButtonText);
|
|
164
|
+
await waitFor(() => {
|
|
165
|
+
fireEvent.press(saveButton);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
expect(mockOnSubmit).toHaveBeenCalledWith({
|
|
169
|
+
[checkboxName]: false,
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it("sets form value to undefined when defaultChecked is undefined", async () => {
|
|
174
|
+
const { getByLabelText } = render(<FormWithProvider />);
|
|
175
|
+
|
|
176
|
+
const saveButton = getByLabelText(saveButtonText);
|
|
177
|
+
await waitFor(() => {
|
|
178
|
+
fireEvent.press(saveButton);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
expect(mockOnSubmit).toHaveBeenCalledWith({
|
|
182
|
+
[checkboxName]: undefined,
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
describe("checkbox value updates form value", () => {
|
|
188
|
+
it("updates form value when checkbox is toggled", async () => {
|
|
189
|
+
const { getByLabelText } = render(
|
|
190
|
+
<FormWithProvider defaultChecked={false} />,
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
const checkbox = getByLabelText(accessibilityLabel);
|
|
194
|
+
fireEvent.press(checkbox);
|
|
195
|
+
|
|
196
|
+
const saveButton = getByLabelText(saveButtonText);
|
|
197
|
+
await waitFor(() => {
|
|
198
|
+
fireEvent.press(saveButton);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
expect(mockOnSubmit).toHaveBeenCalledWith({
|
|
202
|
+
[checkboxName]: true,
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it("preserves defaultChecked value when checkbox is not interacted with", async () => {
|
|
207
|
+
const { getByLabelText } = render(
|
|
208
|
+
<FormWithProvider defaultChecked={true} />,
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
const saveButton = getByLabelText(saveButtonText);
|
|
212
|
+
await waitFor(() => {
|
|
213
|
+
fireEvent.press(saveButton);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
expect(mockOnSubmit).toHaveBeenCalledWith({
|
|
217
|
+
[checkboxName]: true,
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
});
|
|
@@ -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.style.ts
CHANGED
|
@@ -12,7 +12,7 @@ export const useStyles = buildThemedStyles(tokens => {
|
|
|
12
12
|
justifyContent: "center",
|
|
13
13
|
marginHorizontal: tokens["space-smaller"],
|
|
14
14
|
marginTop: tokens["space-small"],
|
|
15
|
-
paddingHorizontal: tokens["space-
|
|
15
|
+
paddingHorizontal: tokens["space-base"],
|
|
16
16
|
},
|
|
17
17
|
iconLeft: {
|
|
18
18
|
marginHorizontal: tokens["space-smallest"],
|
package/src/Chip/Chip.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import type { IconNames } from "@jobber/design";
|
|
|
5
5
|
import { useStyles } from "./Chip.style";
|
|
6
6
|
import { Icon } from "../Icon";
|
|
7
7
|
import { Typography } from "../Typography";
|
|
8
|
+
import type { AtlantisThemeContextValue } from "../AtlantisThemeContext";
|
|
8
9
|
import { useAtlantisTheme } from "../AtlantisThemeContext";
|
|
9
10
|
|
|
10
11
|
export type AccentType = "client" | "invoice" | "job" | "request" | "quote";
|
|
@@ -68,7 +69,7 @@ export function Chip({
|
|
|
68
69
|
accessibilityLabel,
|
|
69
70
|
accessibilityRole = "radio",
|
|
70
71
|
accent,
|
|
71
|
-
}: ChipProps)
|
|
72
|
+
}: ChipProps) {
|
|
72
73
|
const styles = useStyles();
|
|
73
74
|
const { tokens } = useAtlantisTheme();
|
|
74
75
|
const defaultAccentColor = tokens["color-surface--reverse"];
|
|
@@ -86,6 +87,7 @@ export function Chip({
|
|
|
86
87
|
: tokens["color-interactive--background"],
|
|
87
88
|
},
|
|
88
89
|
isActive && { backgroundColor: accentColor },
|
|
90
|
+
getBorderStyle(inactiveBackgroundColor, tokens),
|
|
89
91
|
];
|
|
90
92
|
const dismiss =
|
|
91
93
|
(isActive || inactiveBackgroundColor === "surface") &&
|
|
@@ -96,7 +98,7 @@ export function Chip({
|
|
|
96
98
|
iconCustomColor: iconColor,
|
|
97
99
|
dismissColor: dismiss,
|
|
98
100
|
};
|
|
99
|
-
}, [accent, isActive, inactiveBackgroundColor]);
|
|
101
|
+
}, [accent, isActive, inactiveBackgroundColor, getBorderStyle, styles]);
|
|
100
102
|
|
|
101
103
|
const accessibilityState = useMemo(() => {
|
|
102
104
|
const checkableRoles = ["radio", "switch", "togglebutton", "checkbox"];
|
|
@@ -145,3 +147,19 @@ export function Chip({
|
|
|
145
147
|
</Pressable>
|
|
146
148
|
);
|
|
147
149
|
}
|
|
150
|
+
|
|
151
|
+
function getBorderStyle(
|
|
152
|
+
inactiveBackgroundColor: "surface" | "background",
|
|
153
|
+
tokens: AtlantisThemeContextValue["tokens"],
|
|
154
|
+
) {
|
|
155
|
+
let borderColor = "transparent";
|
|
156
|
+
|
|
157
|
+
if (inactiveBackgroundColor === "surface") {
|
|
158
|
+
borderColor = tokens["color-border"];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
borderColor,
|
|
163
|
+
borderWidth: tokens["border-base"],
|
|
164
|
+
};
|
|
165
|
+
}
|
package/src/Content/Content.tsx
CHANGED
|
@@ -9,10 +9,15 @@ import { useSpaceAroundStyles } from "./ContentSpaceAround.style";
|
|
|
9
9
|
export type Spacing =
|
|
10
10
|
| "none"
|
|
11
11
|
| "base"
|
|
12
|
+
| "slim"
|
|
12
13
|
| "small"
|
|
13
14
|
| "smaller"
|
|
14
15
|
| "smallest"
|
|
15
|
-
| "
|
|
16
|
+
| "minuscule"
|
|
17
|
+
| "large"
|
|
18
|
+
| "larger"
|
|
19
|
+
| "largest"
|
|
20
|
+
| "extravagant";
|
|
16
21
|
|
|
17
22
|
export interface ContentUnsafeStyle {
|
|
18
23
|
container?: StyleProp<ViewStyle>;
|
|
@@ -51,7 +56,7 @@ export function Content({
|
|
|
51
56
|
childSpacing = "base",
|
|
52
57
|
direction = "vertical",
|
|
53
58
|
UNSAFE_style,
|
|
54
|
-
}: ContentProps)
|
|
59
|
+
}: ContentProps) {
|
|
55
60
|
const horizontalStyles = useHorizontalStyles();
|
|
56
61
|
const verticalStyles = useVerticalStyles();
|
|
57
62
|
const spaceAroundStyles = useSpaceAroundStyles();
|
|
@@ -16,6 +16,10 @@ export const useHorizontalStyles = buildThemedStyles(tokens => {
|
|
|
16
16
|
padding: 0,
|
|
17
17
|
},
|
|
18
18
|
|
|
19
|
+
minusculeChildSpace: {
|
|
20
|
+
paddingLeft: tokens["space-minuscule"],
|
|
21
|
+
},
|
|
22
|
+
|
|
19
23
|
smallestChildSpace: {
|
|
20
24
|
paddingLeft: tokens["space-smallest"],
|
|
21
25
|
},
|
|
@@ -28,6 +32,10 @@ export const useHorizontalStyles = buildThemedStyles(tokens => {
|
|
|
28
32
|
paddingLeft: tokens["space-small"],
|
|
29
33
|
},
|
|
30
34
|
|
|
35
|
+
slimChildSpace: {
|
|
36
|
+
paddingLeft: tokens["space-slim"],
|
|
37
|
+
},
|
|
38
|
+
|
|
31
39
|
baseChildSpace: {
|
|
32
40
|
paddingLeft: tokens["space-base"],
|
|
33
41
|
},
|
|
@@ -35,5 +43,17 @@ export const useHorizontalStyles = buildThemedStyles(tokens => {
|
|
|
35
43
|
largeChildSpace: {
|
|
36
44
|
paddingLeft: tokens["space-large"],
|
|
37
45
|
},
|
|
46
|
+
|
|
47
|
+
largerChildSpace: {
|
|
48
|
+
paddingLeft: tokens["space-larger"],
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
largestChildSpace: {
|
|
52
|
+
paddingLeft: tokens["space-largest"],
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
extravagantChildSpace: {
|
|
56
|
+
paddingLeft: tokens["space-extravagant"],
|
|
57
|
+
},
|
|
38
58
|
};
|
|
39
59
|
});
|
|
@@ -6,6 +6,10 @@ export const useSpaceAroundStyles = buildThemedStyles(tokens => {
|
|
|
6
6
|
padding: 0,
|
|
7
7
|
},
|
|
8
8
|
|
|
9
|
+
minusculeSpace: {
|
|
10
|
+
padding: tokens["space-minuscule"],
|
|
11
|
+
},
|
|
12
|
+
|
|
9
13
|
smallestSpace: {
|
|
10
14
|
padding: tokens["space-smallest"],
|
|
11
15
|
},
|
|
@@ -18,6 +22,10 @@ export const useSpaceAroundStyles = buildThemedStyles(tokens => {
|
|
|
18
22
|
padding: tokens["space-small"],
|
|
19
23
|
},
|
|
20
24
|
|
|
25
|
+
slimSpace: {
|
|
26
|
+
padding: tokens["space-slim"],
|
|
27
|
+
},
|
|
28
|
+
|
|
21
29
|
baseSpace: {
|
|
22
30
|
padding: tokens["space-base"],
|
|
23
31
|
},
|
|
@@ -25,5 +33,17 @@ export const useSpaceAroundStyles = buildThemedStyles(tokens => {
|
|
|
25
33
|
largeSpace: {
|
|
26
34
|
padding: tokens["space-large"],
|
|
27
35
|
},
|
|
36
|
+
|
|
37
|
+
largerSpace: {
|
|
38
|
+
padding: tokens["space-larger"],
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
largestSpace: {
|
|
42
|
+
padding: tokens["space-largest"],
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
extravagantSpace: {
|
|
46
|
+
padding: tokens["space-extravagant"],
|
|
47
|
+
},
|
|
28
48
|
};
|
|
29
49
|
});
|