@jobber/components-native 0.44.2 → 0.45.1

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 (159) hide show
  1. package/dist/package.json +88 -0
  2. package/dist/src/AtlantisContext/AtlantisContext.js +1 -0
  3. package/dist/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.js +3 -3
  4. package/dist/src/AutoLink/utils.js +14 -3
  5. package/dist/src/BottomSheet/BottomSheet.js +3 -4
  6. package/dist/src/ButtonGroup/ButtonGroup.js +3 -4
  7. package/dist/src/ButtonGroup/utils.js +4 -5
  8. package/dist/src/ContentOverlay/ContentOverlay.js +3 -4
  9. package/dist/src/Form/components/FormErrorBanner/FormErrorBanner.js +5 -13
  10. package/dist/src/Form/components/FormMask/FormMask.js +3 -4
  11. package/dist/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.js +4 -5
  12. package/dist/src/Form/components/FormSaveButton/FormSaveButton.js +4 -5
  13. package/dist/src/Form/hooks/useOfflineHandler.js +6 -7
  14. package/dist/src/FormatFile/FormatFile.js +3 -4
  15. package/dist/src/FormatFile/components/FileView/FileView.js +3 -3
  16. package/dist/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.js +6 -7
  17. package/dist/src/FormatFile/components/MediaView/MediaView.js +3 -3
  18. package/dist/src/FormatFile/utils/computeA11yLabel.js +4 -5
  19. package/dist/src/InputCurrency/InputCurrency.js +3 -3
  20. package/dist/src/InputDate/InputDate.js +4 -5
  21. package/dist/src/InputFieldWrapper/components/ClearAction/ClearAction.js +3 -4
  22. package/dist/src/InputFieldWrapper/components/ClearAction/index.js +0 -1
  23. package/dist/src/InputNumber/InputNumber.js +3 -4
  24. package/dist/src/InputPassword/InputPassword.js +3 -4
  25. package/dist/src/InputTime/InputTime.js +3 -4
  26. package/dist/src/Menu/Menu.js +3 -4
  27. package/dist/src/ProgressBar/ProgressBar.js +14 -8
  28. package/dist/src/Select/Select.js +5 -6
  29. package/dist/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.js +3 -4
  30. package/dist/src/Toast/Toast.js +4 -5
  31. package/dist/src/hooks/useAtlantisI18n/index.js +1 -0
  32. package/dist/src/hooks/useAtlantisI18n/locales/en.json +35 -0
  33. package/dist/src/hooks/useAtlantisI18n/locales/es.json +35 -0
  34. package/dist/src/hooks/useAtlantisI18n/useAtlantisI18n.js +22 -0
  35. package/dist/tsconfig.json +38 -0
  36. package/dist/tsconfig.tsbuildinfo +1 -1
  37. package/dist/types/src/AtlantisContext/AtlantisContext.d.ts +8 -0
  38. package/dist/types/src/AutoLink/utils.d.ts +2 -2
  39. package/dist/types/src/FormatFile/utils/computeA11yLabel.d.ts +6 -6
  40. package/dist/types/src/InputFieldWrapper/components/ClearAction/index.d.ts +0 -1
  41. package/dist/types/src/hooks/useAtlantisI18n/index.d.ts +1 -0
  42. package/dist/types/src/hooks/useAtlantisI18n/useAtlantisI18n.d.ts +7 -0
  43. package/package.json +2 -2
  44. package/src/AtlantisContext/AtlantisContext.tsx +10 -0
  45. package/src/AutoLink/AutoLink.test.tsx +3 -4
  46. package/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.tsx +3 -3
  47. package/src/AutoLink/utils.ts +16 -5
  48. package/src/BottomSheet/BottomSheet.test.tsx +3 -4
  49. package/src/BottomSheet/BottomSheet.tsx +3 -4
  50. package/src/ButtonGroup/ButtonGroup.test.tsx +8 -9
  51. package/src/ButtonGroup/ButtonGroup.tsx +3 -4
  52. package/src/ButtonGroup/utils.ts +5 -6
  53. package/src/ContentOverlay/ContentOverlay.test.tsx +1 -11
  54. package/src/ContentOverlay/ContentOverlay.tsx +5 -9
  55. package/src/Form/Form.test.tsx +9 -40
  56. package/src/Form/components/FormErrorBanner/FormErrorBanner.test.tsx +9 -72
  57. package/src/Form/components/FormErrorBanner/FormErrorBanner.tsx +6 -15
  58. package/src/Form/components/FormMask/FormMask.tsx +3 -7
  59. package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.tsx +4 -5
  60. package/src/Form/components/FormSaveButton/FormSaveButton.test.tsx +3 -7
  61. package/src/Form/components/FormSaveButton/FormSaveButton.tsx +4 -5
  62. package/src/Form/hooks/useOfflineHandler.ts +7 -8
  63. package/src/FormatFile/FormatFile.test.tsx +7 -31
  64. package/src/FormatFile/FormatFile.tsx +3 -7
  65. package/src/FormatFile/components/FileView/FileView.tsx +3 -3
  66. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.tsx +2 -9
  67. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.tsx +6 -7
  68. package/src/FormatFile/components/MediaView/MediaView.tsx +3 -3
  69. package/src/FormatFile/utils/computeA11yLabel.ts +9 -12
  70. package/src/InputCurrency/InputCurrency.test.tsx +6 -1
  71. package/src/InputCurrency/InputCurrency.tsx +3 -3
  72. package/src/InputDate/InputDate.tsx +6 -5
  73. package/src/InputFieldWrapper/InputFieldWrapper.test.tsx +4 -15
  74. package/src/InputFieldWrapper/components/ClearAction/ClearAction.test.tsx +1 -5
  75. package/src/InputFieldWrapper/components/ClearAction/ClearAction.tsx +3 -4
  76. package/src/InputFieldWrapper/components/ClearAction/index.ts +0 -1
  77. package/src/InputNumber/InputNumber.test.tsx +10 -18
  78. package/src/InputNumber/InputNumber.tsx +3 -4
  79. package/src/InputPassword/InputPassword.test.tsx +1 -2
  80. package/src/InputPassword/InputPassword.tsx +3 -4
  81. package/src/InputSearch/InputSearch.test.tsx +1 -6
  82. package/src/InputText/InputText.test.tsx +10 -38
  83. package/src/InputTime/InputTime.tsx +3 -4
  84. package/src/Menu/Menu.test.tsx +10 -9
  85. package/src/Menu/Menu.tsx +3 -4
  86. package/src/ProgressBar/ProgressBar.tsx +17 -8
  87. package/src/Select/Select.test.tsx +4 -5
  88. package/src/Select/Select.tsx +5 -8
  89. package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.tsx +3 -4
  90. package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.test.tsx +1 -2
  91. package/src/Toast/Toast.tsx +4 -9
  92. package/src/hooks/useAtlantisI18n/index.ts +1 -0
  93. package/src/hooks/useAtlantisI18n/locales/en.json +35 -0
  94. package/src/hooks/useAtlantisI18n/locales/es.json +35 -0
  95. package/src/hooks/useAtlantisI18n/useAtlantisI18n.test.ts +53 -0
  96. package/src/hooks/useAtlantisI18n/useAtlantisI18n.ts +42 -0
  97. package/dist/src/AutoLink/messages.js +0 -18
  98. package/dist/src/BottomSheet/messages.js +0 -8
  99. package/dist/src/ButtonGroup/messages.js +0 -18
  100. package/dist/src/ContentOverlay/messages.js +0 -8
  101. package/dist/src/Form/components/FormErrorBanner/messages.js +0 -13
  102. package/dist/src/Form/components/FormMessage/components/InternalFormMessage/messages.js +0 -8
  103. package/dist/src/Form/components/FormSaveButton/messages.js +0 -8
  104. package/dist/src/Form/messages.js +0 -28
  105. package/dist/src/FormatFile/components/FormatFileBottomSheet/messages.js +0 -13
  106. package/dist/src/FormatFile/messages.js +0 -23
  107. package/dist/src/InputCurrency/messages.js +0 -8
  108. package/dist/src/InputDate/messages.js +0 -8
  109. package/dist/src/InputFieldWrapper/components/ClearAction/messages.js +0 -8
  110. package/dist/src/InputNumber/messages.js +0 -8
  111. package/dist/src/InputPassword/messages.js +0 -8
  112. package/dist/src/InputTime/messages.js +0 -8
  113. package/dist/src/Menu/messages.js +0 -8
  114. package/dist/src/ProgressBar/messages.js +0 -13
  115. package/dist/src/Select/components/SelectDefaultPicker/messages.js +0 -8
  116. package/dist/src/Select/messages.js +0 -13
  117. package/dist/src/Toast/messages.js +0 -13
  118. package/dist/types/src/AutoLink/messages.d.ts +0 -17
  119. package/dist/types/src/BottomSheet/messages.d.ts +0 -7
  120. package/dist/types/src/ButtonGroup/messages.d.ts +0 -17
  121. package/dist/types/src/ContentOverlay/messages.d.ts +0 -7
  122. package/dist/types/src/Form/components/FormErrorBanner/messages.d.ts +0 -12
  123. package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/messages.d.ts +0 -7
  124. package/dist/types/src/Form/components/FormSaveButton/messages.d.ts +0 -7
  125. package/dist/types/src/Form/messages.d.ts +0 -27
  126. package/dist/types/src/FormatFile/components/FormatFileBottomSheet/messages.d.ts +0 -12
  127. package/dist/types/src/FormatFile/messages.d.ts +0 -22
  128. package/dist/types/src/InputCurrency/messages.d.ts +0 -7
  129. package/dist/types/src/InputDate/messages.d.ts +0 -7
  130. package/dist/types/src/InputFieldWrapper/components/ClearAction/messages.d.ts +0 -7
  131. package/dist/types/src/InputNumber/messages.d.ts +0 -7
  132. package/dist/types/src/InputPassword/messages.d.ts +0 -7
  133. package/dist/types/src/InputTime/messages.d.ts +0 -7
  134. package/dist/types/src/Menu/messages.d.ts +0 -7
  135. package/dist/types/src/ProgressBar/messages.d.ts +0 -12
  136. package/dist/types/src/Select/components/SelectDefaultPicker/messages.d.ts +0 -7
  137. package/dist/types/src/Select/messages.d.ts +0 -12
  138. package/dist/types/src/Toast/messages.d.ts +0 -12
  139. package/src/AutoLink/messages.ts +0 -19
  140. package/src/BottomSheet/messages.ts +0 -9
  141. package/src/ButtonGroup/messages.ts +0 -19
  142. package/src/ContentOverlay/messages.ts +0 -9
  143. package/src/Form/components/FormErrorBanner/messages.ts +0 -14
  144. package/src/Form/components/FormMessage/components/InternalFormMessage/messages.ts +0 -10
  145. package/src/Form/components/FormSaveButton/messages.ts +0 -9
  146. package/src/Form/messages.ts +0 -33
  147. package/src/FormatFile/components/FormatFileBottomSheet/messages.ts +0 -14
  148. package/src/FormatFile/messages.ts +0 -24
  149. package/src/InputCurrency/messages.ts +0 -10
  150. package/src/InputDate/messages.ts +0 -9
  151. package/src/InputFieldWrapper/components/ClearAction/messages.ts +0 -9
  152. package/src/InputNumber/messages.ts +0 -10
  153. package/src/InputPassword/messages.ts +0 -9
  154. package/src/InputTime/messages.ts +0 -9
  155. package/src/Menu/messages.ts +0 -9
  156. package/src/ProgressBar/messages.ts +0 -14
  157. package/src/Select/components/SelectDefaultPicker/messages.ts +0 -9
  158. package/src/Select/messages.ts +0 -14
  159. package/src/Toast/messages.ts +0 -14
@@ -1,2 +1 @@
1
1
  export { ClearAction } from "./ClearAction";
2
- export { messages } from "./messages";
@@ -1,10 +1,9 @@
1
1
  import React, { forwardRef, useState } from "react";
2
2
  import { Platform } from "react-native";
3
- import { useIntl } from "react-intl";
4
3
  import flow from "lodash/flow";
5
4
  import identity from "lodash/identity";
6
- import { messages } from "./messages";
7
5
  import { InputText } from "../InputText";
6
+ import { useAtlantisI18n } from "../hooks/useAtlantisI18n";
8
7
  const NUMBER_VALIDATION_REGEX = /^[-+]?(([0-9]*\.[0-9]+)|([0-9]+)|([0-9]+(\.?[0-9]+)?e[-+]?[0-9]+))$/;
9
8
  export const InputNumber = forwardRef(InputNumberInternal);
10
9
  function InputNumberInternal(props, ref) {
@@ -19,7 +18,7 @@ function InputNumberInternal(props, ref) {
19
18
  return "numeric";
20
19
  }
21
20
  };
22
- const { formatMessage } = useIntl();
21
+ const { t } = useAtlantisI18n();
23
22
  const handleChange = (newValue) => {
24
23
  var _a;
25
24
  (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, newValue);
@@ -30,7 +29,7 @@ function InputNumberInternal(props, ref) {
30
29
  output: flow(convertToNumber, ((_b = props.transform) === null || _b === void 0 ? void 0 : _b.output) || identity),
31
30
  }, ref: ref, value: (_c = props.value) === null || _c === void 0 ? void 0 : _c.toString(), defaultValue: (_d = props.defaultValue) === null || _d === void 0 ? void 0 : _d.toString(), onChangeText: handleChange, validations: Object.assign({ pattern: {
32
31
  value: NUMBER_VALIDATION_REGEX,
33
- message: formatMessage(messages.notANumberError),
32
+ message: t("errors.notANumber"),
34
33
  } }, props.validations) })));
35
34
  }
36
35
  function hasPeriodAtEnd(value) {
@@ -10,13 +10,12 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import React, { forwardRef, useState } from "react";
13
- import { useIntl } from "react-intl";
14
- import { messages } from "./messages";
15
13
  import { InputText } from "../InputText";
14
+ import { useAtlantisI18n } from "../hooks/useAtlantisI18n";
16
15
  export const InputPassword = forwardRef(InputPasswordInternal);
17
16
  function InputPasswordInternal(_a, ref) {
18
17
  var { usePrivacyEye = true } = _a, props = __rest(_a, ["usePrivacyEye"]);
19
- const { formatMessage } = useIntl();
18
+ const { t } = useAtlantisI18n();
20
19
  const [passwordHidden, setPasswordHidden] = useState(true);
21
20
  const [privacyEye, setPrivacyEye] = useState("eye");
22
21
  const handleOnPress = () => {
@@ -40,6 +39,6 @@ function InputPasswordInternal(_a, ref) {
40
39
  };
41
40
  return (React.createElement(InputText, Object.assign({}, props, { ref: ref, keyboard: "default", secureTextEntry: passwordHidden, textContentType: "password", clearable: "never", suffix: privacyEyeSuffix(), validations: Object.assign({ required: {
42
41
  value: true,
43
- message: formatMessage(messages.passwordRequired),
42
+ message: t("InputPassword.enterPassword"),
44
43
  } }, props.validations) })));
45
44
  }
@@ -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,35 @@
1
+ {
2
+ "AutoLink.emailCopied": "Email copied",
3
+ "AutoLink.phoneCopied": "Phone number copied",
4
+ "AutoLink.urlCopied": "URL copied",
5
+ "cancel": "Cancel",
6
+ "confirm": "Confirm",
7
+ "copied": "Copied",
8
+ "date": "Date",
9
+ "dismiss": "Dismiss",
10
+ "done": "Done",
11
+ "ContentOverlay.close": "Close {title} modal",
12
+ "errors.couldNotSave": "Could not save changes",
13
+ "errors.notANumber": "Enter a number",
14
+ "FormatFile.label": "Attachment Preview",
15
+ "FormatFile.hint": "Select for more options",
16
+ "FormatFile.preview": "Preview {item}",
17
+ "FormatFile.remove": "Remove {item}",
18
+ "goBack": "Go back",
19
+ "InputFieldWrapper.clear": "Clear input",
20
+ "InputPassword.enterPassword": "Enter a password",
21
+ "loading": "Loading",
22
+ "menu": "Menu",
23
+ "more": "More",
24
+ "networkUnavailableTitle": "Network Unavailable",
25
+ "networkUnavailableDescription": "Check your internet connection and try again later.",
26
+ "ProgressBar.complete": "{current} of {total} complete",
27
+ "ProgressBar.inProgress": "{current} of {total} complete, {inProgress} in progress",
28
+ "save": "Save",
29
+ "Select.a11yHint": "Select to open the picker",
30
+ "Select.emptyValue": "Select an option",
31
+ "time": "Time",
32
+ "tryAgain": "Try again",
33
+ "upload.failed": "Failed to upload.",
34
+ "upload.inProgress": "Upload in progress."
35
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "AutoLink.emailCopied": "Correo electrónico copiado",
3
+ "AutoLink.phoneCopied": "Número de teléfono copiado",
4
+ "AutoLink.urlCopied": "URL copiada",
5
+ "cancel": "Cancelar",
6
+ "confirm": "Confirmar",
7
+ "copied": "Copiado",
8
+ "date": "Fecha",
9
+ "dismiss": "Descartar",
10
+ "done": "Listo",
11
+ "ContentOverlay.close": "Close {title} modal",
12
+ "errors.couldNotSave": "No se pudieron guardar los cambios",
13
+ "errors.notANumber": "Escriba un número",
14
+ "FormatFile.label": "Attachment Preview",
15
+ "FormatFile.hint": "Select for more options",
16
+ "FormatFile.preview": "Vista previa de {item}",
17
+ "FormatFile.remove": "Eliminar {item}",
18
+ "goBack": "Volver",
19
+ "InputFieldWrapper.clear": "Borrar",
20
+ "InputPassword.enterPassword": "Escriba una contraseña",
21
+ "loading": "Cargando",
22
+ "menu": "Menú",
23
+ "more": "Más",
24
+ "networkUnavailableTitle": "Red no disponible",
25
+ "networkUnavailableDescription": "Compruebe su conexión a Internet e inténtelo de nuevo más adelante.",
26
+ "ProgressBar.complete": "{current} de {total} completo",
27
+ "ProgressBar.inProgress": "{current} de {total} completo, {inProgress} en progreso",
28
+ "save": "Guardar",
29
+ "Select.a11yHint": "Seleccionar para abrir el selector",
30
+ "Select.emptyValue": "Seleccione una opción",
31
+ "time": "Hora",
32
+ "tryAgain": "Intentar de nuevo",
33
+ "upload.failed": "No se pudo adjuntar el archivo.",
34
+ "upload.inProgress": "Carga de archivo en curso."
35
+ }
@@ -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
+ }