@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.
Files changed (150) hide show
  1. package/dist/package.json +88 -0
  2. package/dist/src/AtlantisContext/AtlantisContext.js +1 -0
  3. package/dist/src/BottomSheet/BottomSheet.js +3 -4
  4. package/dist/src/ButtonGroup/ButtonGroup.js +3 -4
  5. package/dist/src/ButtonGroup/utils.js +4 -5
  6. package/dist/src/ContentOverlay/ContentOverlay.js +3 -4
  7. package/dist/src/Form/components/FormErrorBanner/FormErrorBanner.js +5 -13
  8. package/dist/src/Form/components/FormMask/FormMask.js +3 -4
  9. package/dist/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.js +4 -5
  10. package/dist/src/Form/components/FormSaveButton/FormSaveButton.js +4 -5
  11. package/dist/src/Form/hooks/useOfflineHandler.js +6 -7
  12. package/dist/src/FormatFile/FormatFile.js +3 -4
  13. package/dist/src/FormatFile/components/FileView/FileView.js +3 -3
  14. package/dist/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.js +6 -7
  15. package/dist/src/FormatFile/components/MediaView/MediaView.js +3 -3
  16. package/dist/src/FormatFile/utils/computeA11yLabel.js +4 -5
  17. package/dist/src/InputCurrency/InputCurrency.js +3 -3
  18. package/dist/src/InputDate/InputDate.js +4 -5
  19. package/dist/src/InputFieldWrapper/components/ClearAction/ClearAction.js +3 -4
  20. package/dist/src/InputFieldWrapper/components/ClearAction/index.js +0 -1
  21. package/dist/src/InputNumber/InputNumber.js +3 -4
  22. package/dist/src/InputPassword/InputPassword.js +3 -4
  23. package/dist/src/InputTime/InputTime.js +3 -4
  24. package/dist/src/Menu/Menu.js +3 -4
  25. package/dist/src/ProgressBar/ProgressBar.js +14 -8
  26. package/dist/src/Select/Select.js +5 -6
  27. package/dist/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.js +3 -4
  28. package/dist/src/Toast/Toast.js +4 -5
  29. package/dist/src/hooks/useAtlantisI18n/index.js +1 -0
  30. package/dist/src/hooks/useAtlantisI18n/locales/en.json +31 -0
  31. package/dist/src/hooks/useAtlantisI18n/locales/es.json +31 -0
  32. package/dist/src/hooks/useAtlantisI18n/useAtlantisI18n.js +22 -0
  33. package/dist/tsconfig.json +38 -0
  34. package/dist/tsconfig.tsbuildinfo +1 -1
  35. package/dist/types/src/AtlantisContext/AtlantisContext.d.ts +8 -0
  36. package/dist/types/src/FormatFile/utils/computeA11yLabel.d.ts +6 -6
  37. package/dist/types/src/InputFieldWrapper/components/ClearAction/index.d.ts +0 -1
  38. package/dist/types/src/hooks/useAtlantisI18n/index.d.ts +1 -0
  39. package/dist/types/src/hooks/useAtlantisI18n/useAtlantisI18n.d.ts +6 -0
  40. package/package.json +2 -2
  41. package/src/AtlantisContext/AtlantisContext.tsx +10 -0
  42. package/src/BottomSheet/BottomSheet.test.tsx +3 -4
  43. package/src/BottomSheet/BottomSheet.tsx +3 -4
  44. package/src/ButtonGroup/ButtonGroup.test.tsx +8 -9
  45. package/src/ButtonGroup/ButtonGroup.tsx +3 -4
  46. package/src/ButtonGroup/utils.ts +5 -6
  47. package/src/ContentOverlay/ContentOverlay.test.tsx +1 -11
  48. package/src/ContentOverlay/ContentOverlay.tsx +5 -9
  49. package/src/Form/Form.test.tsx +9 -40
  50. package/src/Form/components/FormErrorBanner/FormErrorBanner.test.tsx +9 -72
  51. package/src/Form/components/FormErrorBanner/FormErrorBanner.tsx +6 -15
  52. package/src/Form/components/FormMask/FormMask.tsx +3 -7
  53. package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.tsx +4 -5
  54. package/src/Form/components/FormSaveButton/FormSaveButton.test.tsx +3 -7
  55. package/src/Form/components/FormSaveButton/FormSaveButton.tsx +4 -5
  56. package/src/Form/hooks/useOfflineHandler.ts +7 -8
  57. package/src/FormatFile/FormatFile.test.tsx +7 -31
  58. package/src/FormatFile/FormatFile.tsx +3 -7
  59. package/src/FormatFile/components/FileView/FileView.tsx +3 -3
  60. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.tsx +2 -9
  61. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.tsx +6 -7
  62. package/src/FormatFile/components/MediaView/MediaView.tsx +3 -3
  63. package/src/FormatFile/utils/computeA11yLabel.ts +9 -12
  64. package/src/InputCurrency/InputCurrency.test.tsx +6 -1
  65. package/src/InputCurrency/InputCurrency.tsx +3 -3
  66. package/src/InputDate/InputDate.tsx +6 -5
  67. package/src/InputFieldWrapper/InputFieldWrapper.test.tsx +4 -15
  68. package/src/InputFieldWrapper/components/ClearAction/ClearAction.test.tsx +1 -5
  69. package/src/InputFieldWrapper/components/ClearAction/ClearAction.tsx +3 -4
  70. package/src/InputFieldWrapper/components/ClearAction/index.ts +0 -1
  71. package/src/InputNumber/InputNumber.test.tsx +10 -18
  72. package/src/InputNumber/InputNumber.tsx +3 -4
  73. package/src/InputPassword/InputPassword.test.tsx +1 -2
  74. package/src/InputPassword/InputPassword.tsx +3 -4
  75. package/src/InputSearch/InputSearch.test.tsx +1 -6
  76. package/src/InputText/InputText.test.tsx +10 -38
  77. package/src/InputTime/InputTime.tsx +3 -4
  78. package/src/Menu/Menu.test.tsx +10 -9
  79. package/src/Menu/Menu.tsx +3 -4
  80. package/src/ProgressBar/ProgressBar.tsx +17 -8
  81. package/src/Select/Select.test.tsx +4 -5
  82. package/src/Select/Select.tsx +5 -8
  83. package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.tsx +3 -4
  84. package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.test.tsx +1 -2
  85. package/src/Toast/Toast.tsx +4 -9
  86. package/src/hooks/useAtlantisI18n/index.ts +1 -0
  87. package/src/hooks/useAtlantisI18n/locales/en.json +31 -0
  88. package/src/hooks/useAtlantisI18n/locales/es.json +31 -0
  89. package/src/hooks/useAtlantisI18n/useAtlantisI18n.test.ts +53 -0
  90. package/src/hooks/useAtlantisI18n/useAtlantisI18n.ts +43 -0
  91. package/dist/src/BottomSheet/messages.js +0 -8
  92. package/dist/src/ButtonGroup/messages.js +0 -18
  93. package/dist/src/ContentOverlay/messages.js +0 -8
  94. package/dist/src/Form/components/FormErrorBanner/messages.js +0 -13
  95. package/dist/src/Form/components/FormMessage/components/InternalFormMessage/messages.js +0 -8
  96. package/dist/src/Form/components/FormSaveButton/messages.js +0 -8
  97. package/dist/src/Form/messages.js +0 -28
  98. package/dist/src/FormatFile/components/FormatFileBottomSheet/messages.js +0 -13
  99. package/dist/src/FormatFile/messages.js +0 -23
  100. package/dist/src/InputCurrency/messages.js +0 -8
  101. package/dist/src/InputDate/messages.js +0 -8
  102. package/dist/src/InputFieldWrapper/components/ClearAction/messages.js +0 -8
  103. package/dist/src/InputNumber/messages.js +0 -8
  104. package/dist/src/InputPassword/messages.js +0 -8
  105. package/dist/src/InputTime/messages.js +0 -8
  106. package/dist/src/Menu/messages.js +0 -8
  107. package/dist/src/ProgressBar/messages.js +0 -13
  108. package/dist/src/Select/components/SelectDefaultPicker/messages.js +0 -8
  109. package/dist/src/Select/messages.js +0 -13
  110. package/dist/src/Toast/messages.js +0 -13
  111. package/dist/types/src/BottomSheet/messages.d.ts +0 -7
  112. package/dist/types/src/ButtonGroup/messages.d.ts +0 -17
  113. package/dist/types/src/ContentOverlay/messages.d.ts +0 -7
  114. package/dist/types/src/Form/components/FormErrorBanner/messages.d.ts +0 -12
  115. package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/messages.d.ts +0 -7
  116. package/dist/types/src/Form/components/FormSaveButton/messages.d.ts +0 -7
  117. package/dist/types/src/Form/messages.d.ts +0 -27
  118. package/dist/types/src/FormatFile/components/FormatFileBottomSheet/messages.d.ts +0 -12
  119. package/dist/types/src/FormatFile/messages.d.ts +0 -22
  120. package/dist/types/src/InputCurrency/messages.d.ts +0 -7
  121. package/dist/types/src/InputDate/messages.d.ts +0 -7
  122. package/dist/types/src/InputFieldWrapper/components/ClearAction/messages.d.ts +0 -7
  123. package/dist/types/src/InputNumber/messages.d.ts +0 -7
  124. package/dist/types/src/InputPassword/messages.d.ts +0 -7
  125. package/dist/types/src/InputTime/messages.d.ts +0 -7
  126. package/dist/types/src/Menu/messages.d.ts +0 -7
  127. package/dist/types/src/ProgressBar/messages.d.ts +0 -12
  128. package/dist/types/src/Select/components/SelectDefaultPicker/messages.d.ts +0 -7
  129. package/dist/types/src/Select/messages.d.ts +0 -12
  130. package/dist/types/src/Toast/messages.d.ts +0 -12
  131. package/src/BottomSheet/messages.ts +0 -9
  132. package/src/ButtonGroup/messages.ts +0 -19
  133. package/src/ContentOverlay/messages.ts +0 -9
  134. package/src/Form/components/FormErrorBanner/messages.ts +0 -14
  135. package/src/Form/components/FormMessage/components/InternalFormMessage/messages.ts +0 -10
  136. package/src/Form/components/FormSaveButton/messages.ts +0 -9
  137. package/src/Form/messages.ts +0 -33
  138. package/src/FormatFile/components/FormatFileBottomSheet/messages.ts +0 -14
  139. package/src/FormatFile/messages.ts +0 -24
  140. package/src/InputCurrency/messages.ts +0 -10
  141. package/src/InputDate/messages.ts +0 -9
  142. package/src/InputFieldWrapper/components/ClearAction/messages.ts +0 -9
  143. package/src/InputNumber/messages.ts +0 -10
  144. package/src/InputPassword/messages.ts +0 -9
  145. package/src/InputTime/messages.ts +0 -9
  146. package/src/Menu/messages.ts +0 -9
  147. package/src/ProgressBar/messages.ts +0 -14
  148. package/src/Select/components/SelectDefaultPicker/messages.ts +0 -9
  149. package/src/Select/messages.ts +0 -14
  150. 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 { formatMessage } = useIntl();
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 : formatMessage(messages.time), prefix: showIcon ? { icon: "timer" } : undefined, value: formattedTime, onClear: handleClear, onPress: showDatePicker }),
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);
@@ -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 { formatMessage } = useIntl();
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: formatMessage(messages.more), variation: "cancel", type: "tertiary", onPress: () => {
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 { formatMessage } = useIntl();
10
- const accessibilityLabel = [];
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 { formatMessage } = useIntl();
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: formatMessage(messages.a11yHint), accessibilityRole: "button", accessibilityState: { disabled: disabled } },
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 || formatMessage(messages.emptyValue),
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 ((activeValue === null || activeValue === void 0 ? void 0 : activeValue.label) || placeholder || formatMessage(messages.emptyValue));
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 { formatMessage } = useIntl();
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: formatMessage(messages.done), onPress: hidePicker })),
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 })))))))));
@@ -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 { formatMessage } = useIntl();
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", accessibilityLabel: formatMessage(messages.toastNotificationLabel) },
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: formatMessage(messages.dismissA11yLabel) })))));
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
+ }