@jobber/components-native 0.56.2 → 0.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +4 -4
- package/dist/src/Button/Button.js +2 -2
- package/dist/src/Button/Button.style.js +2 -2
- package/dist/src/Card/Card.js +7 -8
- package/dist/src/InputCurrency/InputCurrency.js +16 -17
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.d.ts +1 -1
- package/dist/types/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.d.ts +6 -6
- package/dist/types/src/Checkbox/CheckboxGroup.d.ts +2 -2
- package/dist/types/src/Form/components/FormBody/FormBody.d.ts +3 -3
- package/dist/types/src/Form/components/FormCache/FormCache.d.ts +4 -4
- package/dist/types/src/Form/components/FormMessageBanner/FormMessageBanner.d.ts +1 -1
- package/dist/types/src/FormField/FormField.d.ts +2 -2
- package/dist/types/src/FormatFile/FormatFile.d.ts +6 -6
- package/dist/types/src/FormatFile/components/FileView/FileView.d.ts +6 -6
- package/dist/types/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.d.ts +4 -4
- package/dist/types/src/FormatFile/components/MediaView/MediaView.d.ts +6 -6
- package/dist/types/src/FormatFile/components/ProgressBar/ProgressBar.d.ts +3 -3
- package/dist/types/src/InputCurrency/InputCurrency.d.ts +3 -3
- package/dist/types/src/InputFieldWrapper/components/Prefix/Prefix.d.ts +12 -12
- package/dist/types/src/InputFieldWrapper/components/Suffix/Suffix.d.ts +14 -14
- package/dist/types/src/InputPassword/InputPassword.d.ts +1 -1
- package/dist/types/src/InputText/context/InputAccessoriesProvider.d.ts +1 -1
- package/dist/types/src/Toast/Toast.d.ts +1 -1
- package/dist/types/src/utils/test/MockSafeAreaProvider.d.ts +3 -3
- package/jestSetup.js +2 -0
- package/package.json +4 -4
- package/src/ActionItem/ActionItem.tsx +2 -0
- package/src/ActionItem/ActionItemGroup.tsx +1 -0
- package/src/AutoLink/hooks/useCreateLinkedText.ts +1 -0
- package/src/AutoLink/hooks/useTokenGenerator.ts +1 -0
- package/src/BottomSheet/BottomSheet.tsx +3 -3
- package/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.tsx +3 -1
- package/src/Button/Button.style.ts +2 -2
- package/src/Button/Button.test.tsx +2 -2
- package/src/Button/Button.tsx +2 -2
- package/src/Button/components/InternalButtonLoading/InternalButtonLoading.tsx +1 -0
- package/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.tsx +7 -6
- package/src/Card/Card.tsx +31 -32
- package/src/Card/components/InternalCardHeader.tsx +1 -0
- package/src/Checkbox/CheckboxGroup.tsx +12 -2
- package/src/Chip/Chip.tsx +2 -0
- package/src/Content/Content.test.tsx +1 -0
- package/src/Content/Content.tsx +1 -0
- package/src/ContentOverlay/ContentOverlay.test.tsx +1 -0
- package/src/Divider/Divider.tsx +1 -0
- package/src/EmptyState/EmptyState.tsx +2 -2
- package/src/Flex/Flex.styles.tsx +1 -0
- package/src/Flex/Flex.test.tsx +2 -0
- package/src/Form/Form.test.tsx +19 -14
- package/src/Form/components/FormBody/FormBody.tsx +4 -3
- package/src/Form/components/FormCache/FormCache.tsx +5 -4
- package/src/Form/components/FormMessage/FormMessage.tsx +1 -0
- package/src/Form/components/FormMessageBanner/FormMessageBanner.tsx +1 -1
- package/src/Form/components/FormSaveButton/FormSaveButton.test.tsx +5 -5
- package/src/Form/context/AtlantisFormContext.tsx +1 -0
- package/src/Form/hooks/useFormViewRefs.ts +1 -0
- package/src/Form/hooks/useOfflineHandler.ts +1 -0
- package/src/Form/hooks/useScrollToError/useScrollToError.ts +2 -0
- package/src/FormField/FormField.test.tsx +6 -8
- package/src/FormField/FormField.tsx +2 -2
- package/src/FormatFile/FormatFile.tsx +15 -14
- package/src/FormatFile/components/FileView/FileView.tsx +9 -6
- package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.tsx +4 -4
- package/src/FormatFile/components/MediaView/MediaView.tsx +15 -14
- package/src/FormatFile/components/ProgressBar/ProgressBar.tsx +3 -3
- package/src/FormatFile/utils/createUseCreateThumbnail.ts +1 -0
- package/src/Icon/Icon.tsx +1 -0
- package/src/InputCurrency/InputCurrency.tsx +40 -38
- package/src/InputCurrency/utils.ts +9 -0
- package/src/InputDate/InputDate.test.tsx +1 -0
- package/src/InputFieldWrapper/components/ClearAction/ClearAction.tsx +1 -0
- package/src/InputFieldWrapper/components/Prefix/Prefix.tsx +12 -12
- package/src/InputFieldWrapper/components/Suffix/Suffix.tsx +14 -14
- package/src/InputNumber/InputNumber.tsx +8 -0
- package/src/InputPassword/InputPassword.test.tsx +1 -0
- package/src/InputPassword/InputPassword.tsx +2 -1
- package/src/InputPressable/InputPressable.test.tsx +1 -0
- package/src/InputSearch/InputSearch.tsx +1 -0
- package/src/InputText/context/InputAccessoriesProvider.test.tsx +6 -1
- package/src/InputText/context/InputAccessoriesProvider.tsx +1 -1
- package/src/InputTime/utils/index.ts +1 -0
- package/src/Menu/components/MenuOption/MenuOption.tsx +1 -0
- package/src/Menu/utils.ts +1 -0
- package/src/ProgressBar/ProgressBarInner.tsx +1 -0
- package/src/Select/components/SelectInternalPicker/SelectInternalPicker.tsx +1 -0
- package/src/Select/components/SelectInternalPicker/utils.ts +1 -0
- package/src/StatusLabel/StatusLabel.tsx +1 -1
- package/src/Switch/components/BaseSwitch/BaseSwitch.tsx +1 -0
- package/src/Text/Text.tsx +1 -0
- package/src/Toast/Toast.tsx +2 -1
- package/src/Typography/Typography.tsx +5 -0
- package/src/hooks/useAtlantisI18n/utils/dateFormatter.ts +1 -0
- package/src/hooks/useFormController.ts +2 -0
- package/src/utils/intl/capitalize.ts +1 -0
- package/src/utils/test/MockSafeAreaProvider.tsx +3 -3
|
@@ -17,9 +17,9 @@ interface CommonCheckboxGroupProps extends Omit<CheckboxProps, "onChange"> {
|
|
|
17
17
|
/**
|
|
18
18
|
* Checkbox items
|
|
19
19
|
*/
|
|
20
|
-
children: CheckboxElement[];
|
|
20
|
+
readonly children: CheckboxElement[];
|
|
21
21
|
|
|
22
|
-
state?: CheckboxGroupState;
|
|
22
|
+
readonly state?: CheckboxGroupState;
|
|
23
23
|
|
|
24
24
|
onChange?(groupChecks: CheckboxGroupState): void;
|
|
25
25
|
}
|
|
@@ -38,6 +38,7 @@ export type CheckboxGroupProps = XOR<
|
|
|
38
38
|
UncontrolledCheckboxGroupProps,
|
|
39
39
|
ControlledCheckboxGroupProps
|
|
40
40
|
>;
|
|
41
|
+
|
|
41
42
|
export function CheckboxGroup({
|
|
42
43
|
children,
|
|
43
44
|
state,
|
|
@@ -57,6 +58,7 @@ export function CheckboxGroup({
|
|
|
57
58
|
</CheckboxGroupInternal>
|
|
58
59
|
);
|
|
59
60
|
}
|
|
61
|
+
|
|
60
62
|
if (name) {
|
|
61
63
|
return (
|
|
62
64
|
<FormField name={name}>
|
|
@@ -114,6 +116,7 @@ function CheckboxGroupInternal({
|
|
|
114
116
|
): React.ReactElement<CheckboxProps> {
|
|
115
117
|
const name = throwErrorIfItHasNoName(checkbox.props.name);
|
|
116
118
|
const childDisabled = disabled || checkbox.props.disabled;
|
|
119
|
+
|
|
117
120
|
const childrenHandleChange = (checked: boolean) => {
|
|
118
121
|
const childrenNextValue = {
|
|
119
122
|
...actualCheckedValues.childrenChecked,
|
|
@@ -126,6 +129,7 @@ function CheckboxGroupInternal({
|
|
|
126
129
|
parentChecked: parentNextValue,
|
|
127
130
|
});
|
|
128
131
|
};
|
|
132
|
+
|
|
129
133
|
return React.cloneElement(checkbox, {
|
|
130
134
|
onChange: childrenHandleChange,
|
|
131
135
|
checked: actualCheckedValues.childrenChecked[name],
|
|
@@ -141,6 +145,7 @@ function CheckboxGroupInternal({
|
|
|
141
145
|
}
|
|
142
146
|
|
|
143
147
|
const name = throwErrorIfItHasNoName(child.props.name);
|
|
148
|
+
|
|
144
149
|
return {
|
|
145
150
|
...childCheckboxObject,
|
|
146
151
|
[name]: cloneChildCheckbox(child),
|
|
@@ -153,9 +158,11 @@ function CheckboxGroupInternal({
|
|
|
153
158
|
childName: string,
|
|
154
159
|
): boolean {
|
|
155
160
|
const currentCheckbox = checkboxObject[childName];
|
|
161
|
+
|
|
156
162
|
if (currentCheckbox?.props?.disabled) {
|
|
157
163
|
return acc;
|
|
158
164
|
}
|
|
165
|
+
|
|
159
166
|
return acc && value;
|
|
160
167
|
}
|
|
161
168
|
|
|
@@ -174,6 +181,7 @@ function CheckboxGroupInternal({
|
|
|
174
181
|
actualCheckedValues.childrenChecked,
|
|
175
182
|
(acc, currentCheckboxValue, childName) => {
|
|
176
183
|
const currentCheckbox = checkboxObject[childName];
|
|
184
|
+
|
|
177
185
|
return currentCheckbox?.props?.disabled
|
|
178
186
|
? {
|
|
179
187
|
...acc,
|
|
@@ -215,11 +223,13 @@ function throwErrorIfItHasNoName(name?: string): string {
|
|
|
215
223
|
"You must provide a name to checkboxes in a checkbox group",
|
|
216
224
|
);
|
|
217
225
|
}
|
|
226
|
+
|
|
218
227
|
return name;
|
|
219
228
|
}
|
|
220
229
|
|
|
221
230
|
function checkIndeterminateStatus(checkedValues: CheckboxGroupState): boolean {
|
|
222
231
|
const checkedValuesAsArray = Object.values(checkedValues.childrenChecked);
|
|
232
|
+
|
|
223
233
|
if (checkedValuesAsArray.length === 1) {
|
|
224
234
|
return false;
|
|
225
235
|
}
|
package/src/Chip/Chip.tsx
CHANGED
|
@@ -97,9 +97,11 @@ export function Chip({
|
|
|
97
97
|
|
|
98
98
|
const accessibilityState = useMemo(() => {
|
|
99
99
|
const checkableRoles = ["radio", "switch", "togglebutton", "checkbox"];
|
|
100
|
+
|
|
100
101
|
if (checkableRoles.includes(accessibilityRole)) {
|
|
101
102
|
return { checked: isActive };
|
|
102
103
|
}
|
|
104
|
+
|
|
103
105
|
return {};
|
|
104
106
|
}, [accessibilityRole, isActive]);
|
|
105
107
|
|
|
@@ -39,6 +39,7 @@ function setupContent(
|
|
|
39
39
|
const parentView = container.getByLabelText("contentView");
|
|
40
40
|
const contentView = getContentComponent(parentView);
|
|
41
41
|
const contentChildren = getContentChildren(contentView);
|
|
42
|
+
|
|
42
43
|
return { ...container, parentView, contentView, contentChildren };
|
|
43
44
|
}
|
|
44
45
|
|
package/src/Content/Content.tsx
CHANGED
|
@@ -56,6 +56,7 @@ export function Content({
|
|
|
56
56
|
// In order to get spacing between the children, we apply the child spacing on each of
|
|
57
57
|
// the children except for the first (top) child
|
|
58
58
|
const childStyle = index !== 0 ? [childContainerStyle] : [];
|
|
59
|
+
|
|
59
60
|
return (
|
|
60
61
|
<View key={index} style={[styles.childWrapper, ...childStyle]}>
|
|
61
62
|
{child}
|
package/src/Divider/Divider.tsx
CHANGED
package/src/Flex/Flex.styles.tsx
CHANGED
package/src/Flex/Flex.test.tsx
CHANGED
|
@@ -17,6 +17,7 @@ function getContentComponent(parentView: ReactTestInstance) {
|
|
|
17
17
|
function getFlexCol(flexRow: ReactTestInstance) {
|
|
18
18
|
return flexRow.children as ReactTestInstance[];
|
|
19
19
|
}
|
|
20
|
+
|
|
20
21
|
function setUp(props?: FlexProps) {
|
|
21
22
|
const container = render(
|
|
22
23
|
<View accessibilityLabel="contentView">
|
|
@@ -33,6 +34,7 @@ function setUp(props?: FlexProps) {
|
|
|
33
34
|
);
|
|
34
35
|
const flexRow = container.getAllByTestId("ATL-Flex-Row");
|
|
35
36
|
const flexCol = getFlexCol(flexRow[0]);
|
|
37
|
+
|
|
36
38
|
return { ...container, contentView, flexRow, flexCol };
|
|
37
39
|
}
|
|
38
40
|
|
package/src/Form/Form.test.tsx
CHANGED
|
@@ -16,6 +16,7 @@ import { InputText } from "../InputText";
|
|
|
16
16
|
jest.mock("lodash/debounce", () => {
|
|
17
17
|
return jest.fn(fn => {
|
|
18
18
|
fn.cancel = jest.fn();
|
|
19
|
+
|
|
19
20
|
return fn;
|
|
20
21
|
});
|
|
21
22
|
});
|
|
@@ -83,24 +84,24 @@ interface FormFields {
|
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
interface FormTestProps {
|
|
86
|
-
onSubmit: jest.Mock;
|
|
87
|
-
sendBannerErrors?: boolean;
|
|
88
|
-
sendNetworkErrors?: boolean;
|
|
89
|
-
saveLabel?: string;
|
|
90
|
-
renderStickySection?: (
|
|
87
|
+
readonly onSubmit: jest.Mock;
|
|
88
|
+
readonly sendBannerErrors?: boolean;
|
|
89
|
+
readonly sendNetworkErrors?: boolean;
|
|
90
|
+
readonly saveLabel?: string;
|
|
91
|
+
readonly renderStickySection?: (
|
|
91
92
|
onSubmit: () => void,
|
|
92
93
|
label: string | undefined,
|
|
93
94
|
isSubmitting: boolean,
|
|
94
95
|
) => JSX.Element;
|
|
95
|
-
initialLoading?: boolean;
|
|
96
|
-
initialValues?: FormFields;
|
|
97
|
-
bannerMessages?: FormBannerMessage[];
|
|
98
|
-
localCacheKey?: string;
|
|
99
|
-
localCacheExclude?: string[];
|
|
100
|
-
localCacheId?: string[] | string;
|
|
101
|
-
onBeforeSubmit?: jest.Mock;
|
|
102
|
-
renderFooter?: React.ReactNode;
|
|
103
|
-
saveButtonOffset?: number;
|
|
96
|
+
readonly initialLoading?: boolean;
|
|
97
|
+
readonly initialValues?: FormFields;
|
|
98
|
+
readonly bannerMessages?: FormBannerMessage[];
|
|
99
|
+
readonly localCacheKey?: string;
|
|
100
|
+
readonly localCacheExclude?: string[];
|
|
101
|
+
readonly localCacheId?: string[] | string;
|
|
102
|
+
readonly onBeforeSubmit?: jest.Mock;
|
|
103
|
+
readonly renderFooter?: React.ReactNode;
|
|
104
|
+
readonly saveButtonOffset?: number;
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
function FormTest(props: FormTestProps) {
|
|
@@ -124,9 +125,11 @@ function MockForm({
|
|
|
124
125
|
saveButtonOffset,
|
|
125
126
|
}: FormTestProps) {
|
|
126
127
|
const formErrors: FormBannerErrors = {};
|
|
128
|
+
|
|
127
129
|
if (sendBannerErrors) {
|
|
128
130
|
formErrors.bannerError = bannerError;
|
|
129
131
|
}
|
|
132
|
+
|
|
130
133
|
if (sendNetworkErrors) {
|
|
131
134
|
formErrors.networkError = "Ouch";
|
|
132
135
|
}
|
|
@@ -408,6 +411,7 @@ describe("Form", () => {
|
|
|
408
411
|
errorType: FormSubmitErrorType.NetworkError,
|
|
409
412
|
}),
|
|
410
413
|
);
|
|
414
|
+
|
|
411
415
|
const setup = () => {
|
|
412
416
|
const view = render(
|
|
413
417
|
<FormTest sendNetworkErrors={true} onSubmit={mockSubmit} />,
|
|
@@ -421,6 +425,7 @@ describe("Form", () => {
|
|
|
421
425
|
newValue,
|
|
422
426
|
);
|
|
423
427
|
fireEvent.press(getByLabelText(saveButtonText));
|
|
428
|
+
|
|
424
429
|
return view;
|
|
425
430
|
};
|
|
426
431
|
|
|
@@ -6,9 +6,9 @@ import { FormActionBar, FormActionBarProps } from "../FormActionBar";
|
|
|
6
6
|
import { tokens } from "../../../utils/design";
|
|
7
7
|
|
|
8
8
|
interface FormBodyProps extends FormActionBarProps {
|
|
9
|
-
children: JSX.Element;
|
|
10
|
-
shouldRenderActionBar?: boolean;
|
|
11
|
-
saveButtonOffset?: number;
|
|
9
|
+
readonly children: JSX.Element;
|
|
10
|
+
readonly shouldRenderActionBar?: boolean;
|
|
11
|
+
readonly saveButtonOffset?: number;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export function FormBody({
|
|
@@ -58,5 +58,6 @@ export function FormBody({
|
|
|
58
58
|
export function useBottomPadding(): number {
|
|
59
59
|
const { insets } = useScreenInformation();
|
|
60
60
|
const extraBottomSpace = insets.bottom - tokens["space-base"];
|
|
61
|
+
|
|
61
62
|
return extraBottomSpace >= 0 ? extraBottomSpace : 0;
|
|
62
63
|
}
|
|
@@ -3,11 +3,12 @@ import { FieldValues, useFormContext, useWatch } from "react-hook-form";
|
|
|
3
3
|
import omit from "lodash/omit";
|
|
4
4
|
|
|
5
5
|
interface FormCacheProps<T extends FieldValues> {
|
|
6
|
-
localCacheId?: string | string[];
|
|
7
|
-
localCacheKey?: string;
|
|
8
|
-
localCacheExclude?: string[];
|
|
9
|
-
setLocalCache: (data: T) => void;
|
|
6
|
+
readonly localCacheId?: string | string[];
|
|
7
|
+
readonly localCacheKey?: string;
|
|
8
|
+
readonly localCacheExclude?: string[];
|
|
9
|
+
readonly setLocalCache: (data: T) => void;
|
|
10
10
|
}
|
|
11
|
+
|
|
11
12
|
export function FormCache<T extends FieldValues>({
|
|
12
13
|
localCacheExclude,
|
|
13
14
|
localCacheKey,
|
|
@@ -3,7 +3,7 @@ import { FormBannerMessage, FormBannerMessageType } from "../../types";
|
|
|
3
3
|
import { Banner, BannerTypes } from "../../../Banner";
|
|
4
4
|
|
|
5
5
|
interface FormMessageBannerProps {
|
|
6
|
-
bannerMessages?: FormBannerMessage[];
|
|
6
|
+
readonly bannerMessages?: FormBannerMessage[];
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function FormMessageBanner({
|
|
@@ -16,11 +16,11 @@ interface TestSecondaryActionProp {
|
|
|
16
16
|
destructive?: boolean;
|
|
17
17
|
}
|
|
18
18
|
interface TestFormSaveButtonProps {
|
|
19
|
-
primaryAction: () => Promise<void>;
|
|
20
|
-
loading: boolean;
|
|
21
|
-
label?: string;
|
|
22
|
-
secondaryAction?: TestSecondaryActionProp[];
|
|
23
|
-
setSecondaryActionLoading: (bool: boolean) => void;
|
|
19
|
+
readonly primaryAction: () => Promise<void>;
|
|
20
|
+
readonly loading: boolean;
|
|
21
|
+
readonly label?: string;
|
|
22
|
+
readonly secondaryAction?: TestSecondaryActionProp[];
|
|
23
|
+
readonly setSecondaryActionLoading: (bool: boolean) => void;
|
|
24
24
|
}
|
|
25
25
|
jest.mock("react-hook-form", () => ({
|
|
26
26
|
...jest.requireActual("react-hook-form"),
|
|
@@ -33,6 +33,7 @@ export function useScrollToError<T extends FieldValues>({
|
|
|
33
33
|
// went up.
|
|
34
34
|
const hasBeenSubmitted = submitCounter < submitCount;
|
|
35
35
|
if (!hasBeenSubmitted) return;
|
|
36
|
+
|
|
36
37
|
if (isScreenReaderEnabled) {
|
|
37
38
|
manuallyScrollToElement();
|
|
38
39
|
Keyboard.dismiss();
|
|
@@ -44,6 +45,7 @@ export function useScrollToError<T extends FieldValues>({
|
|
|
44
45
|
|
|
45
46
|
function defaultAutoScroll() {
|
|
46
47
|
if (isValid) return;
|
|
48
|
+
|
|
47
49
|
try {
|
|
48
50
|
focusInputWithRHF(errors, setFocus);
|
|
49
51
|
} catch {
|
|
@@ -78,14 +78,12 @@ describe("when a component is wrapped in a FormField within a Form", () => {
|
|
|
78
78
|
>
|
|
79
79
|
{field => {
|
|
80
80
|
return (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
/>
|
|
88
|
-
</>
|
|
81
|
+
<InputText
|
|
82
|
+
name={field.name}
|
|
83
|
+
accessibilityLabel={inputAccessibilityLabel}
|
|
84
|
+
value={field.value}
|
|
85
|
+
onChangeText={field.onChange}
|
|
86
|
+
/>
|
|
89
87
|
);
|
|
90
88
|
}}
|
|
91
89
|
</FormField>
|
|
@@ -11,7 +11,7 @@ interface FormFieldProps<T> {
|
|
|
11
11
|
/**
|
|
12
12
|
* Name of the field.
|
|
13
13
|
*/
|
|
14
|
-
name: string;
|
|
14
|
+
readonly name: string;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* The initial value of the form field.
|
|
@@ -21,7 +21,7 @@ interface FormFieldProps<T> {
|
|
|
21
21
|
/**
|
|
22
22
|
* Children to render.
|
|
23
23
|
*/
|
|
24
|
-
children: (
|
|
24
|
+
readonly children: (
|
|
25
25
|
field: ControllerRenderProps<FieldValues, string>,
|
|
26
26
|
error?: FieldError,
|
|
27
27
|
) => React.ReactNode;
|
|
@@ -24,7 +24,7 @@ export interface FormatFileProps<T> {
|
|
|
24
24
|
/**
|
|
25
25
|
* File upload details object. Can be a File or a FileUpload
|
|
26
26
|
*/
|
|
27
|
-
file: T;
|
|
27
|
+
readonly file: T;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Accessibility label
|
|
@@ -38,25 +38,25 @@ export interface FormatFileProps<T> {
|
|
|
38
38
|
/**
|
|
39
39
|
* A function which handles the onTap event.
|
|
40
40
|
*/
|
|
41
|
-
onTap?: (file: T) => void;
|
|
41
|
+
readonly onTap?: (file: T) => void;
|
|
42
42
|
/**
|
|
43
43
|
* A function to be called on "Remove" Bottom Sheet Option press
|
|
44
44
|
*/
|
|
45
|
-
onRemove?: () => void;
|
|
45
|
+
readonly onRemove?: () => void;
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* Handler for the "Preview" Bottom Sheet Option press
|
|
49
49
|
*/
|
|
50
|
-
onPreviewPress?: (formattedFile: FormattedFile) => void;
|
|
50
|
+
readonly onPreviewPress?: (formattedFile: FormattedFile) => void;
|
|
51
51
|
/**
|
|
52
52
|
* A file type to show at Bottom Sheet options
|
|
53
53
|
*/
|
|
54
|
-
bottomSheetOptionsSuffix?: BottomSheetOptionsSuffix;
|
|
54
|
+
readonly bottomSheetOptionsSuffix?: BottomSheetOptionsSuffix;
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* Uses a grid layout when multi-file upload is supported
|
|
58
58
|
*/
|
|
59
|
-
styleInGrid?: boolean;
|
|
59
|
+
readonly styleInGrid?: boolean;
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* A reference to the element in the rendered output
|
|
@@ -75,17 +75,17 @@ type FormatFileInternalProps = Omit<
|
|
|
75
75
|
FormatFileProps<File | FileUpload>,
|
|
76
76
|
"file" | "onTap"
|
|
77
77
|
> & {
|
|
78
|
-
file: FormattedFile;
|
|
79
|
-
onTap: () => void;
|
|
78
|
+
readonly file: FormattedFile;
|
|
79
|
+
readonly onTap: () => void;
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
interface FormatFileContentProps {
|
|
83
|
-
accessibilityLabel?: string;
|
|
84
|
-
file: FormattedFile;
|
|
85
|
-
showOverlay: boolean;
|
|
86
|
-
styleInGrid: boolean;
|
|
87
|
-
onUploadComplete: () => void;
|
|
88
|
-
isMedia: boolean;
|
|
83
|
+
readonly accessibilityLabel?: string;
|
|
84
|
+
readonly file: FormattedFile;
|
|
85
|
+
readonly showOverlay: boolean;
|
|
86
|
+
readonly styleInGrid: boolean;
|
|
87
|
+
readonly onUploadComplete: () => void;
|
|
88
|
+
readonly isMedia: boolean;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
function FormatFileContent({
|
|
@@ -288,6 +288,7 @@ function FormatFileInternal({
|
|
|
288
288
|
function handleOnPress() {
|
|
289
289
|
if (showOverlay || !onRemove) {
|
|
290
290
|
onTap();
|
|
291
|
+
|
|
291
292
|
return;
|
|
292
293
|
}
|
|
293
294
|
|
|
@@ -11,12 +11,12 @@ import { ErrorIcon } from "../ErrorIcon";
|
|
|
11
11
|
import { useAtlantisI18n } from "../../../hooks/useAtlantisI18n";
|
|
12
12
|
|
|
13
13
|
interface FileViewProps {
|
|
14
|
-
accessibilityLabel?: string;
|
|
15
|
-
showOverlay: boolean;
|
|
16
|
-
showError: boolean;
|
|
17
|
-
file: FormattedFile;
|
|
18
|
-
styleInGrid: boolean;
|
|
19
|
-
onUploadComplete: () => void;
|
|
14
|
+
readonly accessibilityLabel?: string;
|
|
15
|
+
readonly showOverlay: boolean;
|
|
16
|
+
readonly showError: boolean;
|
|
17
|
+
readonly file: FormattedFile;
|
|
18
|
+
readonly styleInGrid: boolean;
|
|
19
|
+
readonly onUploadComplete: () => void;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export function FileView({
|
|
@@ -37,6 +37,7 @@ export function FileView({
|
|
|
37
37
|
|
|
38
38
|
const freezeProgressBar =
|
|
39
39
|
file.status !== StatusCode.Completed && file.progress >= 0.9;
|
|
40
|
+
|
|
40
41
|
return (
|
|
41
42
|
<View
|
|
42
43
|
style={[
|
|
@@ -107,6 +108,7 @@ interface FileTypeToIconNameParams {
|
|
|
107
108
|
fileName?: string;
|
|
108
109
|
fileType?: string;
|
|
109
110
|
}
|
|
111
|
+
|
|
110
112
|
function mapFileTypeToIconName({
|
|
111
113
|
fileName,
|
|
112
114
|
fileType,
|
|
@@ -114,6 +116,7 @@ function mapFileTypeToIconName({
|
|
|
114
116
|
if (!fileName && !fileType) {
|
|
115
117
|
return "alert";
|
|
116
118
|
}
|
|
119
|
+
|
|
117
120
|
if (fileType?.includes("pdf") || fileName?.match(/~*.pdf$/)) {
|
|
118
121
|
return "pdf";
|
|
119
122
|
} else if (
|
|
@@ -7,10 +7,10 @@ import { useAtlantisI18n } from "../../../hooks/useAtlantisI18n";
|
|
|
7
7
|
export type BottomSheetOptionsSuffix = "receipt" | "image" | "file" | "video";
|
|
8
8
|
|
|
9
9
|
interface FormatFileBottomSheetProps {
|
|
10
|
-
bottomSheetRef: RefObject<BottomSheetRef>;
|
|
11
|
-
onPreviewPress?: () => void;
|
|
12
|
-
onRemovePress?: () => void;
|
|
13
|
-
bottomSheetOptionsSuffix?: BottomSheetOptionsSuffix;
|
|
10
|
+
readonly bottomSheetRef: RefObject<BottomSheetRef>;
|
|
11
|
+
readonly onPreviewPress?: () => void;
|
|
12
|
+
readonly onRemovePress?: () => void;
|
|
13
|
+
readonly bottomSheetOptionsSuffix?: BottomSheetOptionsSuffix;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export const FormatFileBottomSheet = ({
|
|
@@ -11,12 +11,12 @@ import { useAtlantisFormatFileContext } from "../../context/FormatFileContext";
|
|
|
11
11
|
import { useAtlantisI18n } from "../../../hooks/useAtlantisI18n";
|
|
12
12
|
|
|
13
13
|
interface MediaViewProps {
|
|
14
|
-
accessibilityLabel?: string;
|
|
15
|
-
showOverlay: boolean;
|
|
16
|
-
showError: boolean;
|
|
17
|
-
file: FormattedFile;
|
|
18
|
-
styleInGrid: boolean;
|
|
19
|
-
onUploadComplete: () => void;
|
|
14
|
+
readonly accessibilityLabel?: string;
|
|
15
|
+
readonly showOverlay: boolean;
|
|
16
|
+
readonly showError: boolean;
|
|
17
|
+
readonly file: FormattedFile;
|
|
18
|
+
readonly styleInGrid: boolean;
|
|
19
|
+
readonly onUploadComplete: () => void;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export function MediaView({
|
|
@@ -68,11 +68,11 @@ export function MediaView({
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
interface OverlayProps {
|
|
71
|
-
isLoading: boolean;
|
|
72
|
-
showOverlay: boolean;
|
|
73
|
-
hasError: boolean;
|
|
74
|
-
file: FormattedFile;
|
|
75
|
-
onUploadComplete: () => void;
|
|
71
|
+
readonly isLoading: boolean;
|
|
72
|
+
readonly showOverlay: boolean;
|
|
73
|
+
readonly hasError: boolean;
|
|
74
|
+
readonly file: FormattedFile;
|
|
75
|
+
readonly onUploadComplete: () => void;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
function Overlay({
|
|
@@ -104,9 +104,9 @@ function Overlay({
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
interface ProgressOverlayProps {
|
|
107
|
-
status: StatusCode;
|
|
108
|
-
progress: number;
|
|
109
|
-
onUploadComplete: () => void;
|
|
107
|
+
readonly status: StatusCode;
|
|
108
|
+
readonly progress: number;
|
|
109
|
+
readonly onUploadComplete: () => void;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
function ProgressOverlay({
|
|
@@ -115,6 +115,7 @@ function ProgressOverlay({
|
|
|
115
115
|
onUploadComplete,
|
|
116
116
|
}: ProgressOverlayProps) {
|
|
117
117
|
const freezeProgressBar = status !== StatusCode.Completed && progress >= 0.9;
|
|
118
|
+
|
|
118
119
|
return (
|
|
119
120
|
<View
|
|
120
121
|
style={[styles.imageBackground, styles.overlay]}
|
|
@@ -7,15 +7,15 @@ interface ProgressBarProps {
|
|
|
7
7
|
/**
|
|
8
8
|
* Upload progress value from 0 to 1
|
|
9
9
|
*/
|
|
10
|
-
progress: number;
|
|
10
|
+
readonly progress: number;
|
|
11
11
|
/**
|
|
12
12
|
* Upload status
|
|
13
13
|
*/
|
|
14
|
-
status: StatusCode;
|
|
14
|
+
readonly status: StatusCode;
|
|
15
15
|
/**
|
|
16
16
|
* Function to be called when the progress is finished
|
|
17
17
|
*/
|
|
18
|
-
onComplete?: () => void;
|
|
18
|
+
readonly onComplete?: () => void;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export const ProgressBar = ({
|
package/src/Icon/Icon.tsx
CHANGED