@jobber/components-native 0.13.0 → 0.15.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 (53) hide show
  1. package/dist/src/ActionItem/ActionItem.js +37 -0
  2. package/dist/src/ActionItem/ActionItem.style.js +23 -0
  3. package/dist/src/ActionItem/ActionItemGroup.js +19 -0
  4. package/dist/src/ActionItem/components/ActionItemContainer.js +14 -0
  5. package/dist/src/ActionItem/components/ActionItemContainer.style.js +12 -0
  6. package/dist/src/ActionItem/index.js +2 -0
  7. package/dist/src/Button/Button.js +0 -1
  8. package/dist/src/Card/Card.js +0 -1
  9. package/dist/src/ProgressBar/ProgressBar.js +21 -0
  10. package/dist/src/ProgressBar/ProgressBar.style.js +24 -0
  11. package/dist/src/ProgressBar/ProgressBarInner.js +29 -0
  12. package/dist/src/ProgressBar/index.js +1 -0
  13. package/dist/src/ProgressBar/messages.js +13 -0
  14. package/dist/src/ProgressBar/types.js +1 -0
  15. package/dist/src/index.js +2 -0
  16. package/dist/tsconfig.tsbuildinfo +1 -1
  17. package/dist/types/src/ActionItem/ActionItem.d.ts +41 -0
  18. package/dist/types/src/ActionItem/ActionItem.style.d.ts +21 -0
  19. package/dist/types/src/ActionItem/ActionItemGroup.d.ts +11 -0
  20. package/dist/types/src/ActionItem/components/ActionItemContainer.d.ts +9 -0
  21. package/dist/types/src/ActionItem/components/ActionItemContainer.style.d.ts +10 -0
  22. package/dist/types/src/ActionItem/index.d.ts +2 -0
  23. package/dist/types/src/Card/Card.d.ts +2 -2
  24. package/dist/types/src/Card/index.d.ts +1 -1
  25. package/dist/types/src/ProgressBar/ProgressBar.d.ts +3 -0
  26. package/dist/types/src/ProgressBar/ProgressBar.style.d.ts +22 -0
  27. package/dist/types/src/ProgressBar/ProgressBarInner.d.ts +9 -0
  28. package/dist/types/src/ProgressBar/index.d.ts +2 -0
  29. package/dist/types/src/ProgressBar/messages.d.ts +12 -0
  30. package/dist/types/src/ProgressBar/types.d.ts +28 -0
  31. package/dist/types/src/index.d.ts +2 -0
  32. package/package.json +2 -2
  33. package/src/ActionItem/ActionItem.style.ts +29 -0
  34. package/src/ActionItem/ActionItem.test.tsx +121 -0
  35. package/src/ActionItem/ActionItem.tsx +131 -0
  36. package/src/ActionItem/ActionItemGroup.test.tsx +34 -0
  37. package/src/ActionItem/ActionItemGroup.tsx +43 -0
  38. package/src/ActionItem/components/ActionItemContainer.style.ts +14 -0
  39. package/src/ActionItem/components/ActionItemContainer.test.tsx +37 -0
  40. package/src/ActionItem/components/ActionItemContainer.tsx +45 -0
  41. package/src/ActionItem/index.ts +2 -0
  42. package/src/Button/Button.tsx +0 -1
  43. package/src/Card/Card.tsx +2 -3
  44. package/src/Card/index.ts +1 -1
  45. package/src/ProgressBar/ProgressBar.style.ts +25 -0
  46. package/src/ProgressBar/ProgressBar.test.tsx +41 -0
  47. package/src/ProgressBar/ProgressBar.tsx +58 -0
  48. package/src/ProgressBar/ProgressBarInner.tsx +47 -0
  49. package/src/ProgressBar/__snapshots__/ProgressBar.test.tsx.snap +138 -0
  50. package/src/ProgressBar/index.tsx +2 -0
  51. package/src/ProgressBar/messages.ts +14 -0
  52. package/src/ProgressBar/types.ts +34 -0
  53. package/src/index.ts +2 -0
@@ -0,0 +1,37 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import { styles } from "./ActionItem.style";
4
+ import { ActionItemContainer } from "./components/ActionItemContainer";
5
+ import { Typography } from "../Typography";
6
+ import { Icon } from "../Icon";
7
+ export function ActionItem({ title, icon, iconColor, children, actionIcon = "edit", actionIconColour = "interactive", actionIconAlignment = "center", onPress, testID = "actionItem", }) {
8
+ const actionIconStyle = {
9
+ justifyContent: actionIconAlignment,
10
+ };
11
+ const addIconOffset = icon || onPress ? styles.offsetForIcons : undefined;
12
+ const titlePadding = children ? styles.titlePadding : undefined;
13
+ return (React.createElement(ActionItemContainer, { onPress: onPress, testID: testID, title: title },
14
+ icon && (React.createElement(View, { style: styles.icon },
15
+ React.createElement(Icon, { name: icon, color: iconColor }))),
16
+ React.createElement(View, { style: [styles.content, addIconOffset] },
17
+ title && (React.createElement(View, { style: titlePadding },
18
+ React.createElement(Typography, { color: "heading", fontFamily: "base", fontWeight: "bold", size: "default", lineHeight: "base", accessibilityRole: "header" }, title))),
19
+ children),
20
+ onPress && (React.createElement(View, { style: [actionIconStyle, styles.actionIcon] },
21
+ React.createElement(Icon, { name: getActionIcon(actionIcon), color: getActionIconColour(actionIconColour) })))));
22
+ }
23
+ function getActionIconColour(actionIconColour) {
24
+ if (actionIconColour === "subtle") {
25
+ return "interactiveSubtle";
26
+ }
27
+ return actionIconColour;
28
+ }
29
+ function getActionIcon(icon) {
30
+ if (icon === "edit") {
31
+ return "arrowRight";
32
+ }
33
+ else if (icon === "editpencil") {
34
+ return "edit";
35
+ }
36
+ return icon;
37
+ }
@@ -0,0 +1,23 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { tokens } from "../utils/design";
3
+ export const styles = StyleSheet.create({
4
+ actionItemHorizontalOffset: {
5
+ paddingHorizontal: tokens["space-base"],
6
+ },
7
+ icon: {
8
+ justifyContent: "flex-start",
9
+ paddingRight: tokens["space-small"],
10
+ },
11
+ titlePadding: {
12
+ paddingBottom: tokens["space-smaller"],
13
+ },
14
+ content: {
15
+ flex: 1,
16
+ },
17
+ offsetForIcons: {
18
+ paddingTop: tokens["space-smallest"],
19
+ },
20
+ actionIcon: {
21
+ paddingLeft: tokens["space-small"],
22
+ },
23
+ });
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import { styles } from "./ActionItem.style";
4
+ import { Divider } from "../Divider";
5
+ export function ActionItemGroup({ children, }) {
6
+ return React.createElement(View, null, renderChildren(children));
7
+ }
8
+ function renderChildren(children) {
9
+ const childArray = React.Children.toArray(children);
10
+ if (childArray.length === 1)
11
+ return children;
12
+ return childArray.map((child, index) => {
13
+ const isSubsequentChild = index !== 0;
14
+ return (React.createElement(View, { key: index },
15
+ isSubsequentChild && (React.createElement(View, { style: styles.actionItemHorizontalOffset },
16
+ React.createElement(Divider, null))),
17
+ child));
18
+ });
19
+ }
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { Pressable, View } from "react-native";
3
+ import { styles } from "./ActionItemContainer.style";
4
+ import { styles as actionItemStyles } from "../ActionItem.style";
5
+ export function ActionItemContainer({ onPress, title, children, testID, }) {
6
+ if (onPress) {
7
+ return (React.createElement(Pressable, { onPress: onPress, style: ({ pressed }) => [
8
+ styles.container,
9
+ actionItemStyles.actionItemHorizontalOffset,
10
+ pressed && styles.pressed,
11
+ ], accessibilityRole: "button", accessibilityLabel: title, testID: testID }, children));
12
+ }
13
+ return (React.createElement(View, { style: [styles.container, actionItemStyles.actionItemHorizontalOffset], testID: testID }, children));
14
+ }
@@ -0,0 +1,12 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { tokens } from "../../utils/design";
3
+ export const styles = StyleSheet.create({
4
+ container: {
5
+ width: "100%",
6
+ flexDirection: "row",
7
+ paddingVertical: tokens["space-base"],
8
+ },
9
+ pressed: {
10
+ opacity: tokens["opacity-pressed"],
11
+ },
12
+ });
@@ -0,0 +1,2 @@
1
+ export { ActionItem } from "./ActionItem";
2
+ export { ActionItemGroup } from "./ActionItemGroup";
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import { TouchableHighlight, View } from "react-native";
3
3
  import { styles } from "./Button.style";
4
- // eslint-disable-next-line import/no-internal-modules
5
4
  import { InternalButtonLoading } from "./components/InternalButtonLoading";
6
5
  import { ActionLabel } from "../ActionLabel";
7
6
  import { Icon } from "../Icon";
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import { Pressable, View, } from "react-native";
3
3
  import { styles } from "./Card.style";
4
- // eslint-disable-next-line import/no-internal-modules
5
4
  import { InternalCardHeader } from "./components/InternalCardHeader";
6
5
  import { ErrorMessageWrapper } from "../ErrorMessageWrapper";
7
6
  import { ActionLabel } from "../ActionLabel";
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import { useIntl } from "react-intl";
4
+ import { styles } from "./ProgressBar.style";
5
+ import { ProgressBarInner, calculateWidth } from "./ProgressBarInner";
6
+ import { messages } from "./messages";
7
+ import { tokens } from "../utils/design";
8
+ 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(", ") },
15
+ header,
16
+ React.createElement(View, { style: styles.progressBarContainer },
17
+ React.createElement(ProgressBarInner, { width: 100, animationDuration: 0, color: reverseTheme ? undefined : tokens["color-surface--background"] }),
18
+ !loading && (React.createElement(React.Fragment, null,
19
+ inProgress && inProgress > 0 ? (React.createElement(ProgressBarInner, { width: calculateWidth(total, current + inProgress), color: tokens["color-informative"], animationDuration: 800 })) : (React.createElement(React.Fragment, null)),
20
+ React.createElement(ProgressBarInner, { width: calculateWidth(total, current), color: tokens["color-interactive"], animationDuration: 600 }))))));
21
+ }
@@ -0,0 +1,24 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { tokens } from "../utils/design";
3
+ export const styles = StyleSheet.create({
4
+ progressBarContainer: {
5
+ marginTop: tokens["space-small"],
6
+ marginBottom: tokens["space-small"],
7
+ height: 20,
8
+ position: "relative",
9
+ flexDirection: "row",
10
+ },
11
+ progressBarInner: {
12
+ backgroundColor: "rgba(255,255,255,0.3)",
13
+ width: "100%",
14
+ height: "100%",
15
+ position: "absolute",
16
+ left: 0,
17
+ top: 0,
18
+ borderRadius: 100,
19
+ },
20
+ progressInner: {
21
+ height: "100%",
22
+ borderRadius: 100,
23
+ },
24
+ });
@@ -0,0 +1,29 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ // import Reanimated from "react-native-reanimated";
4
+ // import { useTiming } from "utils/reanimated";
5
+ import { styles } from "./ProgressBar.style";
6
+ export function ProgressBarInner({ width,
7
+ // animationDuration = 0,
8
+ color, }) {
9
+ // Animation breaking on Android
10
+ // const [animatedOpacity] = useTiming({
11
+ // duration: animationDuration,
12
+ // fromValue: 0,
13
+ // toValue: 1,
14
+ // });
15
+ return (React.createElement(View, { style: [
16
+ styles.progressBarInner,
17
+ Object.assign({ width: `${width}%` }, (color && { backgroundColor: color })),
18
+ ] }));
19
+ }
20
+ export function calculateWidth(total, current) {
21
+ if (total <= 0)
22
+ return 0;
23
+ if (current >= total)
24
+ return 100;
25
+ const curr = Math.max(0, current);
26
+ if (curr >= total)
27
+ return 100;
28
+ return (curr / total) * 100;
29
+ }
@@ -0,0 +1 @@
1
+ export { ProgressBar } from "./ProgressBar";
@@ -0,0 +1,13 @@
1
+ import { defineMessages } from "react-intl";
2
+ export const messages = defineMessages({
3
+ complete: {
4
+ id: "complete",
5
+ defaultMessage: "{current} of {total} complete",
6
+ description: "Progress bar accessibilityLabel for current/total",
7
+ },
8
+ inProgress: {
9
+ id: "inProgress",
10
+ defaultMessage: "{inProgress} in progress",
11
+ description: "Progress bar accessibilityLabel for inProgress/total",
12
+ },
13
+ });
@@ -0,0 +1 @@
1
+ export {};
package/dist/src/index.js CHANGED
@@ -11,5 +11,7 @@ export * from "./StatusLabel";
11
11
  export * from "./AtlantisContext";
12
12
  export * from "./Button";
13
13
  export * from "./InputFieldWrapper";
14
+ export * from "./ProgressBar";
14
15
  export * from "./Heading";
15
16
  export * from "./Chip";
17
+ export * from "./ActionItem";