@jobber/components-native 0.44.2 → 0.45.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 +88 -0
- package/dist/src/AtlantisContext/AtlantisContext.js +1 -0
- package/dist/src/BottomSheet/BottomSheet.js +3 -4
- package/dist/src/ButtonGroup/ButtonGroup.js +3 -4
- package/dist/src/ButtonGroup/utils.js +4 -5
- package/dist/src/ContentOverlay/ContentOverlay.js +3 -4
- package/dist/src/Form/components/FormErrorBanner/FormErrorBanner.js +5 -13
- package/dist/src/Form/components/FormMask/FormMask.js +3 -4
- package/dist/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.js +4 -5
- package/dist/src/Form/components/FormSaveButton/FormSaveButton.js +4 -5
- package/dist/src/Form/hooks/useOfflineHandler.js +6 -7
- package/dist/src/FormatFile/FormatFile.js +3 -4
- package/dist/src/FormatFile/components/FileView/FileView.js +3 -3
- package/dist/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.js +6 -7
- package/dist/src/FormatFile/components/MediaView/MediaView.js +3 -3
- package/dist/src/FormatFile/utils/computeA11yLabel.js +4 -5
- package/dist/src/InputCurrency/InputCurrency.js +3 -3
- package/dist/src/InputDate/InputDate.js +4 -5
- package/dist/src/InputFieldWrapper/components/ClearAction/ClearAction.js +3 -4
- package/dist/src/InputFieldWrapper/components/ClearAction/index.js +0 -1
- package/dist/src/InputNumber/InputNumber.js +3 -4
- package/dist/src/InputPassword/InputPassword.js +3 -4
- package/dist/src/InputTime/InputTime.js +3 -4
- package/dist/src/Menu/Menu.js +3 -4
- package/dist/src/ProgressBar/ProgressBar.js +14 -8
- package/dist/src/Select/Select.js +5 -6
- package/dist/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.js +3 -4
- package/dist/src/Toast/Toast.js +4 -5
- package/dist/src/hooks/useAtlantisI18n/index.js +1 -0
- package/dist/src/hooks/useAtlantisI18n/locales/en.json +31 -0
- package/dist/src/hooks/useAtlantisI18n/locales/es.json +31 -0
- package/dist/src/hooks/useAtlantisI18n/useAtlantisI18n.js +22 -0
- package/dist/tsconfig.json +38 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/AtlantisContext/AtlantisContext.d.ts +8 -0
- package/dist/types/src/FormatFile/utils/computeA11yLabel.d.ts +6 -6
- package/dist/types/src/InputFieldWrapper/components/ClearAction/index.d.ts +0 -1
- package/dist/types/src/hooks/useAtlantisI18n/index.d.ts +1 -0
- package/dist/types/src/hooks/useAtlantisI18n/useAtlantisI18n.d.ts +6 -0
- package/package.json +2 -2
- package/src/AtlantisContext/AtlantisContext.tsx +10 -0
- package/src/BottomSheet/BottomSheet.test.tsx +3 -4
- package/src/BottomSheet/BottomSheet.tsx +3 -4
- package/src/ButtonGroup/ButtonGroup.test.tsx +8 -9
- package/src/ButtonGroup/ButtonGroup.tsx +3 -4
- package/src/ButtonGroup/utils.ts +5 -6
- package/src/ContentOverlay/ContentOverlay.test.tsx +1 -11
- package/src/ContentOverlay/ContentOverlay.tsx +5 -9
- package/src/Form/Form.test.tsx +9 -40
- package/src/Form/components/FormErrorBanner/FormErrorBanner.test.tsx +9 -72
- package/src/Form/components/FormErrorBanner/FormErrorBanner.tsx +6 -15
- package/src/Form/components/FormMask/FormMask.tsx +3 -7
- package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.tsx +4 -5
- package/src/Form/components/FormSaveButton/FormSaveButton.test.tsx +3 -7
- package/src/Form/components/FormSaveButton/FormSaveButton.tsx +4 -5
- package/src/Form/hooks/useOfflineHandler.ts +7 -8
- package/src/FormatFile/FormatFile.test.tsx +7 -31
- package/src/FormatFile/FormatFile.tsx +3 -7
- package/src/FormatFile/components/FileView/FileView.tsx +3 -3
- package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.tsx +2 -9
- package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.tsx +6 -7
- package/src/FormatFile/components/MediaView/MediaView.tsx +3 -3
- package/src/FormatFile/utils/computeA11yLabel.ts +9 -12
- package/src/InputCurrency/InputCurrency.test.tsx +6 -1
- package/src/InputCurrency/InputCurrency.tsx +3 -3
- package/src/InputDate/InputDate.tsx +6 -5
- package/src/InputFieldWrapper/InputFieldWrapper.test.tsx +4 -15
- package/src/InputFieldWrapper/components/ClearAction/ClearAction.test.tsx +1 -5
- package/src/InputFieldWrapper/components/ClearAction/ClearAction.tsx +3 -4
- package/src/InputFieldWrapper/components/ClearAction/index.ts +0 -1
- package/src/InputNumber/InputNumber.test.tsx +10 -18
- package/src/InputNumber/InputNumber.tsx +3 -4
- package/src/InputPassword/InputPassword.test.tsx +1 -2
- package/src/InputPassword/InputPassword.tsx +3 -4
- package/src/InputSearch/InputSearch.test.tsx +1 -6
- package/src/InputText/InputText.test.tsx +10 -38
- package/src/InputTime/InputTime.tsx +3 -4
- package/src/Menu/Menu.test.tsx +10 -9
- package/src/Menu/Menu.tsx +3 -4
- package/src/ProgressBar/ProgressBar.tsx +17 -8
- package/src/Select/Select.test.tsx +4 -5
- package/src/Select/Select.tsx +5 -8
- package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.tsx +3 -4
- package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.test.tsx +1 -2
- package/src/Toast/Toast.tsx +4 -9
- package/src/hooks/useAtlantisI18n/index.ts +1 -0
- package/src/hooks/useAtlantisI18n/locales/en.json +31 -0
- package/src/hooks/useAtlantisI18n/locales/es.json +31 -0
- package/src/hooks/useAtlantisI18n/useAtlantisI18n.test.ts +53 -0
- package/src/hooks/useAtlantisI18n/useAtlantisI18n.ts +43 -0
- package/dist/src/BottomSheet/messages.js +0 -8
- package/dist/src/ButtonGroup/messages.js +0 -18
- package/dist/src/ContentOverlay/messages.js +0 -8
- package/dist/src/Form/components/FormErrorBanner/messages.js +0 -13
- package/dist/src/Form/components/FormMessage/components/InternalFormMessage/messages.js +0 -8
- package/dist/src/Form/components/FormSaveButton/messages.js +0 -8
- package/dist/src/Form/messages.js +0 -28
- package/dist/src/FormatFile/components/FormatFileBottomSheet/messages.js +0 -13
- package/dist/src/FormatFile/messages.js +0 -23
- package/dist/src/InputCurrency/messages.js +0 -8
- package/dist/src/InputDate/messages.js +0 -8
- package/dist/src/InputFieldWrapper/components/ClearAction/messages.js +0 -8
- package/dist/src/InputNumber/messages.js +0 -8
- package/dist/src/InputPassword/messages.js +0 -8
- package/dist/src/InputTime/messages.js +0 -8
- package/dist/src/Menu/messages.js +0 -8
- package/dist/src/ProgressBar/messages.js +0 -13
- package/dist/src/Select/components/SelectDefaultPicker/messages.js +0 -8
- package/dist/src/Select/messages.js +0 -13
- package/dist/src/Toast/messages.js +0 -13
- package/dist/types/src/BottomSheet/messages.d.ts +0 -7
- package/dist/types/src/ButtonGroup/messages.d.ts +0 -17
- package/dist/types/src/ContentOverlay/messages.d.ts +0 -7
- package/dist/types/src/Form/components/FormErrorBanner/messages.d.ts +0 -12
- package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/messages.d.ts +0 -7
- package/dist/types/src/Form/components/FormSaveButton/messages.d.ts +0 -7
- package/dist/types/src/Form/messages.d.ts +0 -27
- package/dist/types/src/FormatFile/components/FormatFileBottomSheet/messages.d.ts +0 -12
- package/dist/types/src/FormatFile/messages.d.ts +0 -22
- package/dist/types/src/InputCurrency/messages.d.ts +0 -7
- package/dist/types/src/InputDate/messages.d.ts +0 -7
- package/dist/types/src/InputFieldWrapper/components/ClearAction/messages.d.ts +0 -7
- package/dist/types/src/InputNumber/messages.d.ts +0 -7
- package/dist/types/src/InputPassword/messages.d.ts +0 -7
- package/dist/types/src/InputTime/messages.d.ts +0 -7
- package/dist/types/src/Menu/messages.d.ts +0 -7
- package/dist/types/src/ProgressBar/messages.d.ts +0 -12
- package/dist/types/src/Select/components/SelectDefaultPicker/messages.d.ts +0 -7
- package/dist/types/src/Select/messages.d.ts +0 -12
- package/dist/types/src/Toast/messages.d.ts +0 -12
- package/src/BottomSheet/messages.ts +0 -9
- package/src/ButtonGroup/messages.ts +0 -19
- package/src/ContentOverlay/messages.ts +0 -9
- package/src/Form/components/FormErrorBanner/messages.ts +0 -14
- package/src/Form/components/FormMessage/components/InternalFormMessage/messages.ts +0 -10
- package/src/Form/components/FormSaveButton/messages.ts +0 -9
- package/src/Form/messages.ts +0 -33
- package/src/FormatFile/components/FormatFileBottomSheet/messages.ts +0 -14
- package/src/FormatFile/messages.ts +0 -24
- package/src/InputCurrency/messages.ts +0 -10
- package/src/InputDate/messages.ts +0 -9
- package/src/InputFieldWrapper/components/ClearAction/messages.ts +0 -9
- package/src/InputNumber/messages.ts +0 -10
- package/src/InputPassword/messages.ts +0 -9
- package/src/InputTime/messages.ts +0 -9
- package/src/Menu/messages.ts +0 -9
- package/src/ProgressBar/messages.ts +0 -14
- package/src/Select/components/SelectDefaultPicker/messages.ts +0 -9
- package/src/Select/messages.ts +0 -14
- package/src/Toast/messages.ts +0 -14
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import React, { useMemo, useState } from "react";
|
|
2
2
|
import DateTimePicker from "react-native-modal-datetime-picker";
|
|
3
3
|
import { View } from "react-native";
|
|
4
|
-
import { useIntl } from "react-intl";
|
|
5
4
|
import { utcToZonedTime } from "date-fns-tz";
|
|
6
5
|
import { format as formatTime } from "date-fns";
|
|
7
6
|
import { styles } from "./InputTime.style";
|
|
8
|
-
import { messages } from "./messages";
|
|
9
7
|
import { getTimeZoneOffsetInMinutes, roundUpToNearestMinutes } from "./utils";
|
|
10
8
|
import { useAtlantisContext } from "../AtlantisContext";
|
|
11
9
|
import { InputPressable } from "../InputPressable";
|
|
12
10
|
import { FormField } from "../FormField";
|
|
11
|
+
import { useAtlantisI18n } from "../hooks/useAtlantisI18n";
|
|
13
12
|
const LOCALE_24_HOURS = "en_GB";
|
|
14
13
|
const LOCALE_12_HOURS = "en_US";
|
|
15
14
|
function formatInvalidState(error, invalid) {
|
|
@@ -33,7 +32,7 @@ export function InputTime(props) {
|
|
|
33
32
|
}
|
|
34
33
|
function InternalInputTime({ clearable = "always", disabled, emptyValueLabel, invalid, placeholder, value, name, type = "scheduling", onChange, showIcon = true, }) {
|
|
35
34
|
const [showPicker, setShowPicker] = useState(false);
|
|
36
|
-
const {
|
|
35
|
+
const { t } = useAtlantisI18n();
|
|
37
36
|
const { timeZone, timeFormat } = useAtlantisContext();
|
|
38
37
|
const is24Hour = timeFormat === "HH:mm";
|
|
39
38
|
const dateTime = useMemo(() => (typeof value === "string" ? new Date(value) : value), [value]);
|
|
@@ -46,7 +45,7 @@ function InternalInputTime({ clearable = "always", disabled, emptyValueLabel, in
|
|
|
46
45
|
}, [dateTime, emptyValueLabel, timeZone, timeFormat]);
|
|
47
46
|
const canClearTime = formattedTime === emptyValueLabel ? "never" : clearable;
|
|
48
47
|
return (React.createElement(View, { style: styles.container },
|
|
49
|
-
React.createElement(InputPressable, { clearable: canClearTime, disabled: disabled, invalid: invalid, placeholder: placeholder !== null && placeholder !== void 0 ? placeholder :
|
|
48
|
+
React.createElement(InputPressable, { clearable: canClearTime, disabled: disabled, invalid: invalid, placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t("time"), prefix: showIcon ? { icon: "timer" } : undefined, value: formattedTime, onClear: handleClear, onPress: showDatePicker }),
|
|
50
49
|
React.createElement(DateTimePicker, { testID: "inputTime-Picker", minuteInterval: getMinuteInterval(type), date: getInitialPickerDate(dateTime), timeZoneOffsetInMinutes: getTimeZoneOffsetInMinutes(timeZone, dateTime), isVisible: showPicker, mode: "time", onCancel: handleCancel, onConfirm: handleConfirm, is24Hour: is24Hour, locale: is24Hour ? LOCALE_24_HOURS : LOCALE_12_HOURS })));
|
|
51
50
|
function showDatePicker() {
|
|
52
51
|
setShowPicker(true);
|
package/dist/src/Menu/Menu.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import React, { useCallback, useRef, useState } from "react";
|
|
2
2
|
import { Pressable, View, useWindowDimensions, } from "react-native";
|
|
3
3
|
import { Portal } from "react-native-portalize";
|
|
4
|
-
import { useIntl } from "react-intl";
|
|
5
4
|
import { useSafeAreaFrame } from "react-native-safe-area-context";
|
|
6
5
|
import { styles } from "./Menu.style";
|
|
7
|
-
import { messages } from "./messages";
|
|
8
6
|
import { findViewpoint } from "./utils";
|
|
9
7
|
import { MenuOption } from "./components/MenuOption";
|
|
10
8
|
import { Overlay } from "./components/Overlay";
|
|
@@ -12,13 +10,14 @@ import { tokens } from "../utils/design";
|
|
|
12
10
|
import { Button } from "../Button";
|
|
13
11
|
import { Content } from "../Content";
|
|
14
12
|
import { useAtlantisContext } from "../AtlantisContext";
|
|
13
|
+
import { useAtlantisI18n } from "../hooks/useAtlantisI18n";
|
|
15
14
|
export function Menu({ menuOptions, customActivator }) {
|
|
16
15
|
const [open, setOpen] = useState(false);
|
|
17
16
|
const [menuPosition, setMenuPosition] = useState();
|
|
18
17
|
const activatorLayout = useRef();
|
|
19
18
|
const menuButtonRef = useRef();
|
|
20
19
|
const screenInfo = useScreenInformation();
|
|
21
|
-
const {
|
|
20
|
+
const { t } = useAtlantisI18n();
|
|
22
21
|
const findMenuLayout = useCallback(() => {
|
|
23
22
|
if (activatorLayout.current) {
|
|
24
23
|
setMenuPosition(findViewpoint(screenInfo, activatorLayout.current));
|
|
@@ -49,7 +48,7 @@ export function Menu({ menuOptions, customActivator }) {
|
|
|
49
48
|
], pointerEvents: "box-only", onPress: () => {
|
|
50
49
|
activatorOnPress(customActivator.props.onPress);
|
|
51
50
|
}, onLongPress: customActivator.props.onLongPress }, customActivator)),
|
|
52
|
-
!customActivator && (React.createElement(Button, { icon: "more", accessibilityLabel:
|
|
51
|
+
!customActivator && (React.createElement(Button, { icon: "more", accessibilityLabel: t("menu"), variation: "cancel", type: "tertiary", onPress: () => {
|
|
53
52
|
activatorOnPress();
|
|
54
53
|
} }))),
|
|
55
54
|
React.createElement(Portal, null, open && (React.createElement(React.Fragment, null,
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import { useIntl } from "react-intl";
|
|
4
3
|
import { styles } from "./ProgressBar.style";
|
|
5
4
|
import { ProgressBarInner, calculateWidth } from "./ProgressBarInner";
|
|
6
|
-
import { messages } from "./messages";
|
|
7
5
|
import { tokens } from "../utils/design";
|
|
6
|
+
import { useAtlantisI18n } from "../hooks/useAtlantisI18n";
|
|
8
7
|
export function ProgressBar({ loading, total, current, inProgress = 0, reverseTheme = false, header, }) {
|
|
9
|
-
const {
|
|
10
|
-
|
|
11
|
-
accessibilityLabel.push(formatMessage(messages.complete, { current, total }));
|
|
12
|
-
inProgress &&
|
|
13
|
-
accessibilityLabel.push(formatMessage(messages.inProgress, { inProgress }));
|
|
14
|
-
return (React.createElement(View, { accessible: true, accessibilityRole: "progressbar", accessibilityLabel: accessibilityLabel.join(", ") },
|
|
8
|
+
const { t } = useAtlantisI18n();
|
|
9
|
+
return (React.createElement(View, { accessible: true, accessibilityRole: "progressbar", accessibilityLabel: getA11yLabel() },
|
|
15
10
|
header,
|
|
16
11
|
React.createElement(View, { style: styles.progressBarContainer },
|
|
17
12
|
React.createElement(ProgressBarInner, { width: 100, animationDuration: 0, color: reverseTheme ? undefined : tokens["color-surface--background"] }),
|
|
18
13
|
!loading && (React.createElement(React.Fragment, null,
|
|
19
14
|
inProgress && inProgress > 0 ? (React.createElement(ProgressBarInner, { width: calculateWidth(total, current + inProgress), color: tokens["color-informative"], animationDuration: 800 })) : (React.createElement(React.Fragment, null)),
|
|
20
15
|
React.createElement(ProgressBarInner, { width: calculateWidth(total, current), color: tokens["color-interactive"], animationDuration: 600 }))))));
|
|
16
|
+
function getA11yLabel() {
|
|
17
|
+
const a11yLabelValues = {
|
|
18
|
+
current: String(current),
|
|
19
|
+
total: String(total),
|
|
20
|
+
inProgress: String(inProgress),
|
|
21
|
+
};
|
|
22
|
+
if (inProgress) {
|
|
23
|
+
return t("ProgressBar.inProgress", a11yLabelValues);
|
|
24
|
+
}
|
|
25
|
+
return t("ProgressBar.complete", a11yLabelValues);
|
|
26
|
+
}
|
|
21
27
|
}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import { useIntl } from "react-intl";
|
|
4
3
|
import { styles } from "./Select.style";
|
|
5
4
|
import { SelectInternalPicker } from "./components/SelectInternalPicker";
|
|
6
|
-
import { messages } from "./messages";
|
|
7
5
|
import { InputFieldWrapper } from "../InputFieldWrapper";
|
|
8
6
|
import { Icon } from "../Icon";
|
|
9
7
|
import { Text } from "../Text";
|
|
10
8
|
import { useFormController } from "../hooks";
|
|
9
|
+
import { useAtlantisI18n } from "../hooks/useAtlantisI18n";
|
|
11
10
|
export function Select({ value, defaultValue, onChange, children, placeholder, label, assistiveText, disabled, invalid, validations, accessibilityLabel, name, }) {
|
|
12
11
|
const { field, error } = useFormController({
|
|
13
12
|
name,
|
|
14
13
|
validations,
|
|
15
14
|
value: value !== null && value !== void 0 ? value : defaultValue,
|
|
16
15
|
});
|
|
17
|
-
const {
|
|
16
|
+
const { t } = useAtlantisI18n();
|
|
18
17
|
const internalValue = value !== null && value !== void 0 ? value : field.value;
|
|
19
18
|
const textVariation = getTextVariation({
|
|
20
19
|
disabled,
|
|
@@ -25,7 +24,7 @@ export function Select({ value, defaultValue, onChange, children, placeholder, l
|
|
|
25
24
|
return (React.createElement(InputFieldWrapper, { error: error, invalid: invalid || !!error, hasValue: hasValue, styleOverride: {
|
|
26
25
|
container: { borderBottomWidth: undefined },
|
|
27
26
|
} },
|
|
28
|
-
React.createElement(View, { testID: "ATL-Select", accessible: true, accessibilityLabel: getA11yLabel(), accessibilityValue: { text: getValue() }, accessibilityHint:
|
|
27
|
+
React.createElement(View, { testID: "ATL-Select", accessible: true, accessibilityLabel: getA11yLabel(), accessibilityValue: { text: getValue() }, accessibilityHint: t("Select.a11yHint"), accessibilityRole: "button", accessibilityState: { disabled: disabled } },
|
|
29
28
|
React.createElement(SelectInternalPicker, { disabled: disabled, options: getOptions(), onChange: handleChange },
|
|
30
29
|
React.createElement(View, { style: [styles.container, (invalid || !!error) && styles.invalid] },
|
|
31
30
|
label && (React.createElement(Text, { level: "textSupporting", variation: textVariation, hideFromScreenReader: true }, label)),
|
|
@@ -54,7 +53,7 @@ export function Select({ value, defaultValue, onChange, children, placeholder, l
|
|
|
54
53
|
}));
|
|
55
54
|
if (!internalValue || placeholder) {
|
|
56
55
|
options.unshift({
|
|
57
|
-
label: placeholder ||
|
|
56
|
+
label: placeholder || t("Select.emptyValue"),
|
|
58
57
|
value: "",
|
|
59
58
|
isActive: !internalValue,
|
|
60
59
|
});
|
|
@@ -64,7 +63,7 @@ export function Select({ value, defaultValue, onChange, children, placeholder, l
|
|
|
64
63
|
function getValue() {
|
|
65
64
|
const options = getOptions();
|
|
66
65
|
const activeValue = options.find(option => option.isActive);
|
|
67
|
-
return (
|
|
66
|
+
return (activeValue === null || activeValue === void 0 ? void 0 : activeValue.label) || placeholder || t("Select.emptyValue");
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
function getTextVariation({ invalid, disabled, }) {
|
|
@@ -4,20 +4,19 @@ import {
|
|
|
4
4
|
Button, Modal, TouchableOpacity, View, } from "react-native";
|
|
5
5
|
import { Picker } from "@react-native-picker/picker";
|
|
6
6
|
import { SafeAreaView } from "react-native-safe-area-context";
|
|
7
|
-
import { useIntl } from "react-intl";
|
|
8
7
|
import { styles } from "./SelectDefaultPicker.style";
|
|
9
|
-
import { messages } from "./messages";
|
|
10
8
|
import { SelectPressable } from "../SelectPressable/SelectPressable";
|
|
9
|
+
import { useAtlantisI18n } from "../../../hooks/useAtlantisI18n";
|
|
11
10
|
export function SelectDefaultPicker({ children, options, onChange, }) {
|
|
12
11
|
const [show, setShow] = useState(false);
|
|
13
|
-
const {
|
|
12
|
+
const { t } = useAtlantisI18n();
|
|
14
13
|
const selectedLanguage = options.find(option => option.isActive);
|
|
15
14
|
return (React.createElement(React.Fragment, null,
|
|
16
15
|
React.createElement(SelectPressable, { onPress: showPicker }, children),
|
|
17
16
|
React.createElement(Modal, { visible: show, transparent: true, animationType: "slide", onRequestClose: hidePicker },
|
|
18
17
|
React.createElement(TouchableOpacity, { style: styles.overlay, onPress: hidePicker }),
|
|
19
18
|
React.createElement(View, { style: styles.actionBar },
|
|
20
|
-
React.createElement(Button, { title:
|
|
19
|
+
React.createElement(Button, { title: t("done"), onPress: hidePicker })),
|
|
21
20
|
React.createElement(View, { style: styles.pickerContainer, testID: "select-wheel-picker" },
|
|
22
21
|
React.createElement(SafeAreaView, { edges: ["bottom"] },
|
|
23
22
|
React.createElement(Picker, { selectedValue: selectedLanguage === null || selectedLanguage === void 0 ? void 0 : selectedLanguage.value, onValueChange: onChange }, options.map(({ label, value }, i) => (React.createElement(Picker.Item, { key: i, label: label, value: value })))))))));
|
package/dist/src/Toast/Toast.js
CHANGED
|
@@ -2,24 +2,23 @@ import React from "react";
|
|
|
2
2
|
import Toast from "react-native-toast-message";
|
|
3
3
|
import { AccessibilityInfo, TouchableOpacity, View } from "react-native";
|
|
4
4
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
|
-
import { useIntl } from "react-intl";
|
|
6
5
|
import { styles } from "./Toast.styles";
|
|
7
|
-
import { messages } from "./messages";
|
|
8
6
|
import { tokens } from "../utils/design";
|
|
9
7
|
import { Text } from "../Text";
|
|
10
8
|
import { IconButton } from "../IconButton";
|
|
9
|
+
import { useAtlantisI18n } from "../hooks/useAtlantisI18n";
|
|
11
10
|
const MAX_TOAST_MESSAGE_LENGTH = 60;
|
|
12
11
|
const ANNOUNCEMENT_DELAY = 100;
|
|
13
12
|
function DefaultToast({ text1 }) {
|
|
14
13
|
const { bottom } = useSafeAreaInsets();
|
|
15
|
-
const {
|
|
14
|
+
const { t } = useAtlantisI18n();
|
|
16
15
|
const toastContainerStyles = [styles.container, { paddingBottom: bottom }];
|
|
17
16
|
return (React.createElement(View, { style: toastContainerStyles },
|
|
18
17
|
React.createElement(View, { style: styles.toast },
|
|
19
|
-
React.createElement(TouchableOpacity, { style: styles.toastMessage, accessibilityRole: "alert"
|
|
18
|
+
React.createElement(TouchableOpacity, { style: styles.toastMessage, accessibilityRole: "alert" },
|
|
20
19
|
React.createElement(Text, { reverseTheme: true }, text1)),
|
|
21
20
|
React.createElement(View, { style: styles.toastIcon },
|
|
22
|
-
React.createElement(IconButton, { onPress: Toast.hide, name: "remove", customColor: tokens["color-greyBlue--light"], accessibilityLabel:
|
|
21
|
+
React.createElement(IconButton, { onPress: Toast.hide, name: "remove", customColor: tokens["color-greyBlue--light"], accessibilityLabel: t("dismiss") })))));
|
|
23
22
|
}
|
|
24
23
|
const toastConfig = {
|
|
25
24
|
default: DefaultToast,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useAtlantisI18n";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cancel": "Cancel",
|
|
3
|
+
"confirm": "Confirm",
|
|
4
|
+
"date": "Date",
|
|
5
|
+
"dismiss": "Dismiss",
|
|
6
|
+
"done": "Done",
|
|
7
|
+
"ContentOverlay.close": "Close {title} modal",
|
|
8
|
+
"errors.couldNotSave": "Could not save changes",
|
|
9
|
+
"errors.notANumber": "Enter a number",
|
|
10
|
+
"FormatFile.label": "Attachment Preview",
|
|
11
|
+
"FormatFile.hint": "Select for more options",
|
|
12
|
+
"FormatFile.preview": "Preview {item}",
|
|
13
|
+
"FormatFile.remove": "Remove {item}",
|
|
14
|
+
"goBack": "Go back",
|
|
15
|
+
"InputFieldWrapper.clear": "Clear input",
|
|
16
|
+
"InputPassword.enterPassword": "Enter a password",
|
|
17
|
+
"loading": "Loading",
|
|
18
|
+
"menu": "Menu",
|
|
19
|
+
"more": "More",
|
|
20
|
+
"networkUnavailableTitle": "Network Unavailable",
|
|
21
|
+
"networkUnavailableDescription": "Check your internet connection and try again later.",
|
|
22
|
+
"ProgressBar.complete": "{current} of {total} complete",
|
|
23
|
+
"ProgressBar.inProgress": "{current} of {total} complete, {inProgress} in progress",
|
|
24
|
+
"save": "Save",
|
|
25
|
+
"Select.a11yHint": "Select to open the picker",
|
|
26
|
+
"Select.emptyValue": "Select an option",
|
|
27
|
+
"time": "Time",
|
|
28
|
+
"tryAgain": "Try again",
|
|
29
|
+
"upload.failed": "Failed to upload.",
|
|
30
|
+
"upload.inProgress": "Upload in progress."
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cancel": "Cancelar",
|
|
3
|
+
"confirm": "Confirmar",
|
|
4
|
+
"date": "Fecha",
|
|
5
|
+
"dismiss": "Descartar",
|
|
6
|
+
"done": "Listo",
|
|
7
|
+
"ContentOverlay.close": "Close {title} modal",
|
|
8
|
+
"errors.couldNotSave": "No se pudieron guardar los cambios",
|
|
9
|
+
"errors.notANumber": "Escriba un número",
|
|
10
|
+
"FormatFile.label": "Attachment Preview",
|
|
11
|
+
"FormatFile.hint": "Select for more options",
|
|
12
|
+
"FormatFile.preview": "Vista previa de {item}",
|
|
13
|
+
"FormatFile.remove": "Eliminar {item}",
|
|
14
|
+
"goBack": "Volver",
|
|
15
|
+
"InputFieldWrapper.clear": "Borrar",
|
|
16
|
+
"InputPassword.enterPassword": "Escriba una contraseña",
|
|
17
|
+
"loading": "Cargando",
|
|
18
|
+
"menu": "Menú",
|
|
19
|
+
"more": "Más",
|
|
20
|
+
"networkUnavailableTitle": "Red no disponible",
|
|
21
|
+
"networkUnavailableDescription": "Compruebe su conexión a Internet e inténtelo de nuevo más adelante.",
|
|
22
|
+
"ProgressBar.complete": "{current} de {total} completo",
|
|
23
|
+
"ProgressBar.inProgress": "{current} de {total} completo, {inProgress} en progreso",
|
|
24
|
+
"save": "Guardar",
|
|
25
|
+
"Select.a11yHint": "Seleccionar para abrir el selector",
|
|
26
|
+
"Select.emptyValue": "Seleccione una opción",
|
|
27
|
+
"time": "Hora",
|
|
28
|
+
"tryAgain": "Intentar de nuevo",
|
|
29
|
+
"upload.failed": "No se pudo adjuntar el archivo.",
|
|
30
|
+
"upload.inProgress": "Carga de archivo en curso."
|
|
31
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import en from "./locales/en.json";
|
|
2
|
+
import es from "./locales/es.json";
|
|
3
|
+
import { useAtlantisContext } from "../../AtlantisContext";
|
|
4
|
+
export function useAtlantisI18n() {
|
|
5
|
+
const { locale } = useAtlantisContext();
|
|
6
|
+
const t = (messageKey, values) => formatMessage(messageKey, values, locale);
|
|
7
|
+
return { locale, t };
|
|
8
|
+
}
|
|
9
|
+
function getLocalizedStrings(locale) {
|
|
10
|
+
switch (locale) {
|
|
11
|
+
case "es":
|
|
12
|
+
return es;
|
|
13
|
+
default:
|
|
14
|
+
return en;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function formatMessage(messageKey, values, locale = "en") {
|
|
18
|
+
const message = getLocalizedStrings(locale)[messageKey];
|
|
19
|
+
if (!values)
|
|
20
|
+
return message;
|
|
21
|
+
return Object.entries(values).reduce((acc, [key, value]) => acc.replace(`{${key}}`, value), message);
|
|
22
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "./dist",
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationDir": "./dist/types",
|
|
9
|
+
"resolveJsonModule": true,
|
|
10
|
+
"paths": {
|
|
11
|
+
"@jobber/hooks/*": [
|
|
12
|
+
"../../packages/hooks/src/*"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"types": [
|
|
16
|
+
"react-native",
|
|
17
|
+
"jest"
|
|
18
|
+
],
|
|
19
|
+
"lib": [
|
|
20
|
+
"es2019"
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"jsx": "react-native",
|
|
24
|
+
"include": [
|
|
25
|
+
"src",
|
|
26
|
+
"**/*.json"
|
|
27
|
+
],
|
|
28
|
+
"exclude": [
|
|
29
|
+
"node_modules",
|
|
30
|
+
"**/*.test.ts",
|
|
31
|
+
"**/*.test.tsx",
|
|
32
|
+
],
|
|
33
|
+
"references": [
|
|
34
|
+
{
|
|
35
|
+
"path": "../hooks"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|