@jobber/components-native 0.46.10 → 0.47.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components-native",
3
- "version": "0.46.10",
3
+ "version": "0.47.0",
4
4
  "license": "MIT",
5
5
  "description": "React Native implementation of Atlantis",
6
6
  "repository": {
@@ -84,5 +84,5 @@
84
84
  "react-native-reanimated": "^2.17.0",
85
85
  "react-native-safe-area-context": "^4.5.2"
86
86
  },
87
- "gitHead": "5668739977ce8c578ac682452ea31261d423bf10"
87
+ "gitHead": "a4a664e49538a432df03a593c100ab6055adeca4"
88
88
  }
@@ -5,7 +5,7 @@ import { InternalButtonLoading } from "./components/InternalButtonLoading";
5
5
  import { ActionLabel } from "../ActionLabel";
6
6
  import { Icon } from "../Icon";
7
7
  import { tokens } from "../utils/design";
8
- export function Button({ label, onPress, variation = "work", type = "primary", fullHeight = false, fullWidth = true, disabled = false, loading = false, size = "base", accessibilityLabel, accessibilityHint, icon, }) {
8
+ export function Button({ label, onPress, variation = "work", type = "primary", fullHeight = false, fullWidth = true, disabled = false, loading = false, size = "base", accessibilityLabel, accessibilityHint, icon, testID, }) {
9
9
  const buttonStyle = [
10
10
  styles.button,
11
11
  styles[variation],
@@ -19,7 +19,7 @@ export function Button({ label, onPress, variation = "work", type = "primary", f
19
19
  // an InputText that was focused, it required two presses to activate the
20
20
  // Pressable. Using a TouchableHighlight made things register correctly
21
21
  // in a single press
22
- return (React.createElement(TouchableHighlight, { onPress: onPress, testID: accessibilityLabel || label, accessibilityLabel: accessibilityLabel || label, accessibilityHint: accessibilityHint, accessibilityRole: "button", accessibilityState: { disabled, busy: loading }, disabled: disabled || loading, underlayColor: tokens["color-greyBlue--dark"], activeOpacity: tokens["opacity-pressed"], style: [
22
+ return (React.createElement(TouchableHighlight, { onPress: onPress, testID: buildTestID(testID, label, accessibilityLabel), accessibilityLabel: accessibilityLabel || label, accessibilityHint: accessibilityHint, accessibilityRole: "button", accessibilityState: { disabled, busy: loading }, disabled: disabled || loading, underlayColor: tokens["color-greyBlue--dark"], activeOpacity: tokens["opacity-pressed"], style: [
23
23
  styles.touchable,
24
24
  fullWidth && styles.fullWidth,
25
25
  fullHeight && styles.fullHeight,
@@ -75,3 +75,9 @@ function getContentStyles(label, icon) {
75
75
  !!label && styles.contentWithLabel,
76
76
  ];
77
77
  }
78
+ function buildTestID(testID, label, accessibilityLabel) {
79
+ if (testID) {
80
+ return `ATL-${testID}-Button`;
81
+ }
82
+ return accessibilityLabel || label;
83
+ }
@@ -14,10 +14,10 @@ export function ButtonGroup({ children, showCancelInBottomSheet, bottomSheetHead
14
14
  return (React.createElement(View, { style: styles.buttonGroup },
15
15
  primaryActions.map((action, index) => {
16
16
  const { label, onPress, buttonType, buttonVariation, icon, customButton, loading, } = action.props;
17
- return (React.createElement(View, { style: styles.button, key: index }, customButton || (React.createElement(Button, { label: label, accessibilityLabel: label, onPress: allowTapWhenOffline ? onPress : handlePress(onPress), type: buttonType, variation: buttonVariation, fullHeight: true, icon: icon, loading: loading }))));
17
+ return (React.createElement(View, { style: styles.button, key: index }, customButton || (React.createElement(Button, { label: label, accessibilityLabel: label, onPress: allowTapWhenOffline ? onPress : handlePress(onPress), type: buttonType, variation: buttonVariation, fullHeight: true, icon: icon, loading: loading, testID: `ATL-ButtonGroup-Primary-Action-${index}` }))));
18
18
  }),
19
19
  secondaryActions.length > 0 && (React.createElement(View, { style: styles.moreButton },
20
- React.createElement(Button, { icon: "more", accessibilityLabel: t("more"), onPress: handlePress(openBottomSheet), fullHeight: true }))),
20
+ React.createElement(Button, { icon: "more", accessibilityLabel: t("more"), onPress: handlePress(openBottomSheet), fullHeight: true, testID: "ATL-ButtonGroup-Secondary-Action" }))),
21
21
  React.createElement(SecondaryActionSheet, { heading: bottomSheetHeading, showCancel: showCancelInBottomSheet, secondaryActionsRef: secondaryActionsRef, actions: secondaryActions.map(secondaryAction => secondaryAction.props), onOpenBottomSheet: onOpenBottomSheet, onCloseBottomSheet: onCloseBottomSheet })));
22
22
  function openBottomSheet() {
23
23
  var _a;
@@ -15,15 +15,14 @@ export function FormSaveButton({ primaryAction, loading, label, secondaryActions
15
15
  const { t } = useAtlantisI18n();
16
16
  const formContext = useFormContext();
17
17
  const buttonActions = useButtonGroupAction(secondaryActions);
18
- return (React.createElement(React.Fragment, null,
19
- React.createElement(ButtonGroup, { onOpenBottomSheet: onOpenBottomSheet, onCloseBottomSheet: onCloseBottomSheet, allowTapWhenOffline: true }, buttonActions.map((action, index) => {
20
- if (index === 0) {
21
- return (React.createElement(ButtonGroup.PrimaryAction, { key: index, onPress: primaryAction, label: label !== null && label !== void 0 ? label : t("save"), loading: loading }));
22
- }
23
- else {
24
- return (React.createElement(ButtonGroup.SecondaryAction, { key: index, label: action.label, icon: action.icon, onPress: action.onPress, destructive: action.destructive }));
25
- }
26
- }))));
18
+ return (React.createElement(ButtonGroup, { onOpenBottomSheet: onOpenBottomSheet, onCloseBottomSheet: onCloseBottomSheet, allowTapWhenOffline: true }, buttonActions.map((action, index) => {
19
+ if (index === 0) {
20
+ return (React.createElement(ButtonGroup.PrimaryAction, { key: index, onPress: primaryAction, label: label !== null && label !== void 0 ? label : t("save"), loading: loading }));
21
+ }
22
+ else {
23
+ return (React.createElement(ButtonGroup.SecondaryAction, { key: index, label: action.label, icon: action.icon, onPress: action.onPress, destructive: action.destructive }));
24
+ }
25
+ })));
27
26
  function useButtonGroupAction(array) {
28
27
  const buttonGroupActionProps = array
29
28
  ? array.map(arr => {