@jobber/components-native 0.54.4 → 0.56.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 (29) hide show
  1. package/dist/package.json +2 -2
  2. package/dist/src/Banner/Banner.js +32 -11
  3. package/dist/src/Banner/Banner.style.js +13 -11
  4. package/dist/src/Banner/components/BannerIcon/BannerIcon.js +4 -5
  5. package/dist/src/Banner/components/BannerIcon/BannerIcon.style.js +17 -0
  6. package/dist/src/ButtonGroup/ButtonGroup.js +1 -1
  7. package/dist/src/ButtonGroup/ButtonGroup.style.js +1 -1
  8. package/dist/src/TextList/TextList.style.js +1 -1
  9. package/dist/tsconfig.tsbuildinfo +1 -1
  10. package/dist/types/src/Banner/Banner.style.d.ts +12 -10
  11. package/dist/types/src/Banner/components/BannerIcon/BannerIcon.d.ts +4 -2
  12. package/dist/types/src/Banner/components/BannerIcon/BannerIcon.style.d.ts +15 -0
  13. package/dist/types/src/Banner/types.d.ts +2 -2
  14. package/dist/types/src/ButtonGroup/ButtonGroup.style.d.ts +1 -1
  15. package/dist/types/src/TextList/TextList.style.d.ts +1 -1
  16. package/package.json +2 -2
  17. package/src/Banner/Banner.style.ts +13 -11
  18. package/src/Banner/Banner.test.tsx +144 -36
  19. package/src/Banner/Banner.tsx +57 -20
  20. package/src/Banner/components/BannerIcon/BannerIcon.style.ts +18 -0
  21. package/src/Banner/components/BannerIcon/BannerIcon.tsx +8 -6
  22. package/src/Banner/types.ts +2 -2
  23. package/src/ButtonGroup/ButtonGroup.style.ts +1 -1
  24. package/src/ButtonGroup/ButtonGroup.tsx +1 -0
  25. package/src/TextList/TextList.style.ts +1 -1
  26. package/src/TextList/__snapshots__/TextList.test.tsx.snap +1 -1
  27. package/dist/src/Banner/constants.js +0 -12
  28. package/dist/types/src/Banner/constants.d.ts +0 -2
  29. package/src/Banner/constants.ts +0 -14
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components-native",
3
- "version": "0.54.4",
3
+ "version": "0.56.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": "4780cde621bb770d24f6bd324ee868b302afc579"
87
+ "gitHead": "7bf4c5d39fb393fca61366ad250d02706b5aa93b"
88
88
  }
@@ -1,30 +1,51 @@
1
1
  import React from "react";
2
- import { Pressable, View } from "react-native";
3
- import { BannerTypeStyles } from "./constants";
2
+ import { Pressable, Text as RNText, View } from "react-native";
4
3
  import { styles } from "./Banner.style";
5
4
  import { BannerIcon } from "./components/BannerIcon/BannerIcon";
6
5
  import { Content } from "../Content";
7
6
  import { Text } from "../Text";
8
7
  import { TextList } from "../TextList";
9
8
  import { ActionLabel } from "../ActionLabel";
9
+ import { Typography } from "../Typography";
10
10
  export function Banner({ action, details, text, type, children, icon, }) {
11
- return (React.createElement(Pressable, { style: [styles.container, BannerTypeStyles[type].styles], accessibilityRole: "alert", onPress: action === null || action === void 0 ? void 0 : action.onPress },
11
+ const bannerIcon = icon || getBannerIcon(type);
12
+ const shouldFlow = Boolean(React.Children.count(children) === 1 && !text && !details) ||
13
+ Boolean(text && !details && !children);
14
+ return (React.createElement(Pressable, { style: [styles.container], accessibilityRole: "alert", onPress: action === null || action === void 0 ? void 0 : action.onPress },
12
15
  React.createElement(Content, { childSpacing: "small" },
13
16
  React.createElement(View, { style: styles.bannerContent },
14
- icon && React.createElement(BannerIcon, { icon: icon }),
17
+ bannerIcon && React.createElement(BannerIcon, { icon: bannerIcon, type: type }),
15
18
  React.createElement(View, { style: styles.contentContainer },
16
19
  React.createElement(View, { style: styles.childrenContainer },
17
- React.createElement(BannerChildren, null, children)),
18
- text && (React.createElement(View, { style: styles.textContainer },
19
- React.createElement(Text, { level: "textSupporting" }, text))),
20
- details && React.createElement(TextList, { items: details, level: "textSupporting" }))),
21
- action && React.createElement(ActionLabel, { align: "start" }, action.label))));
20
+ React.createElement(WrappingElement, { shouldFlow: shouldFlow },
21
+ React.createElement(BannerChildren, null, children),
22
+ text && React.createElement(Text, { level: "text" }, text),
23
+ details && React.createElement(TextList, { items: details, level: "text" }),
24
+ action && (React.createElement(RNText, null,
25
+ shouldFlow && React.createElement(Typography, { color: "subdued" }, " | "),
26
+ React.createElement(ActionLabel, { align: "start" }, action.label))))))))));
22
27
  }
23
- function BannerChildren({ children, }) {
28
+ function BannerChildren({ children }) {
24
29
  if (!children)
25
30
  return React.createElement(React.Fragment, null);
26
31
  if (children && typeof children === "string") {
27
- return React.createElement(Text, { level: "textSupporting" }, children);
32
+ return React.createElement(Text, { level: "text" }, children);
28
33
  }
29
34
  return React.createElement(React.Fragment, null, children);
30
35
  }
36
+ function WrappingElement({ shouldFlow, children, }) {
37
+ if (shouldFlow) {
38
+ return React.createElement(RNText, { testID: "ATL-Banner-RNText" }, children);
39
+ }
40
+ return (React.createElement(View, { testID: "ATL-Banner-View", style: styles.contentSpacing }, children));
41
+ }
42
+ function getBannerIcon(type) {
43
+ switch (type) {
44
+ case "notice":
45
+ return "starburst";
46
+ case "warning":
47
+ return "help";
48
+ case "error":
49
+ return "alert";
50
+ }
51
+ }
@@ -3,19 +3,15 @@ import { tokens } from "../utils/design";
3
3
  export const styles = StyleSheet.create({
4
4
  container: {
5
5
  width: "100%",
6
- },
7
- error: {
8
- backgroundColor: tokens["color-critical--surface"],
9
- },
10
- warning: {
11
- backgroundColor: tokens["color-warning--surface"],
12
- },
13
- notice: {
14
- backgroundColor: tokens["color-informative--surface"],
6
+ borderColor: tokens["color-border"],
7
+ borderStyle: "solid",
8
+ borderBottomWidth: tokens["border-base"],
9
+ backgroundColor: tokens["color-surface"],
15
10
  },
16
11
  bannerContent: {
17
12
  flexDirection: "row",
18
13
  alignItems: "flex-start",
14
+ gap: tokens["space-small"] + tokens["space-smaller"],
19
15
  },
20
16
  contentContainer: {
21
17
  flex: 1,
@@ -26,7 +22,13 @@ export const styles = StyleSheet.create({
26
22
  textContainer: {
27
23
  marginTop: tokens["space-minuscule"],
28
24
  },
29
- bannerIcon: {
30
- paddingRight: tokens["space-small"],
25
+ fullWidth: {
26
+ width: "100%",
27
+ },
28
+ bannerChildrenContent: {
29
+ marginBottom: tokens["space-small"],
30
+ },
31
+ contentSpacing: {
32
+ gap: tokens["space-small"],
31
33
  },
32
34
  });
@@ -1,9 +1,8 @@
1
1
  import React from "react";
2
- import { tokens } from "@jobber/design";
3
2
  import { View } from "react-native";
3
+ import { styles } from "./BannerIcon.style";
4
4
  import { Icon } from "../../../Icon";
5
- import { styles } from "../../Banner.style";
6
- export function BannerIcon({ icon }) {
7
- return (React.createElement(View, { style: styles.bannerIcon },
8
- React.createElement(Icon, { name: icon, customColor: tokens["color-text"] })));
5
+ export function BannerIcon({ icon, type }) {
6
+ return (React.createElement(View, { style: [styles.bannerIcon, styles[type]], testID: "ATL-Banner-Icon" },
7
+ React.createElement(Icon, { name: icon, color: "white", size: "small" })));
9
8
  }
@@ -0,0 +1,17 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { tokens } from "../../../utils/design";
3
+ export const styles = StyleSheet.create({
4
+ bannerIcon: {
5
+ borderRadius: tokens["radius-circle"],
6
+ padding: tokens["space-smaller"],
7
+ },
8
+ error: {
9
+ backgroundColor: tokens["color-destructive"],
10
+ },
11
+ warning: {
12
+ backgroundColor: tokens["color-warning"],
13
+ },
14
+ notice: {
15
+ backgroundColor: tokens["color-informative"],
16
+ },
17
+ });
@@ -17,7 +17,7 @@ export function ButtonGroup({ children, showCancelInBottomSheet, bottomSheetHead
17
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: `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, testID: "ButtonGroup-Secondary-Action" }))),
20
+ React.createElement(Button, { type: "secondary", icon: "more", accessibilityLabel: t("more"), onPress: handlePress(openBottomSheet), fullHeight: true, testID: "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;
@@ -5,11 +5,11 @@ export const styles = StyleSheet.create({
5
5
  width: "100%",
6
6
  flexDirection: "row",
7
7
  justifyContent: "flex-end",
8
+ gap: tokens["space-small"],
8
9
  },
9
10
  button: {
10
11
  flexBasis: tokens["space-largest"],
11
12
  flexGrow: 1,
12
- paddingRight: tokens["space-smaller"],
13
13
  },
14
14
  moreButton: {
15
15
  flexBasis: tokens["space-largest"],
@@ -2,8 +2,8 @@ import { StyleSheet } from "react-native";
2
2
  import { tokens } from "../utils/design";
3
3
  export const styles = StyleSheet.create({
4
4
  details: {
5
+ width: "100%",
5
6
  flexDirection: "column",
6
- marginTop: tokens["space-small"],
7
7
  },
8
8
  detail: {
9
9
  flexDirection: "row",