@jobber/components-native 0.14.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 (33) 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/index.js +1 -0
  10. package/dist/tsconfig.tsbuildinfo +1 -1
  11. package/dist/types/src/ActionItem/ActionItem.d.ts +41 -0
  12. package/dist/types/src/ActionItem/ActionItem.style.d.ts +21 -0
  13. package/dist/types/src/ActionItem/ActionItemGroup.d.ts +11 -0
  14. package/dist/types/src/ActionItem/components/ActionItemContainer.d.ts +9 -0
  15. package/dist/types/src/ActionItem/components/ActionItemContainer.style.d.ts +10 -0
  16. package/dist/types/src/ActionItem/index.d.ts +2 -0
  17. package/dist/types/src/Card/Card.d.ts +2 -2
  18. package/dist/types/src/Card/index.d.ts +1 -1
  19. package/dist/types/src/index.d.ts +1 -0
  20. package/package.json +2 -2
  21. package/src/ActionItem/ActionItem.style.ts +29 -0
  22. package/src/ActionItem/ActionItem.test.tsx +121 -0
  23. package/src/ActionItem/ActionItem.tsx +131 -0
  24. package/src/ActionItem/ActionItemGroup.test.tsx +34 -0
  25. package/src/ActionItem/ActionItemGroup.tsx +43 -0
  26. package/src/ActionItem/components/ActionItemContainer.style.ts +14 -0
  27. package/src/ActionItem/components/ActionItemContainer.test.tsx +37 -0
  28. package/src/ActionItem/components/ActionItemContainer.tsx +45 -0
  29. package/src/ActionItem/index.ts +2 -0
  30. package/src/Button/Button.tsx +0 -1
  31. package/src/Card/Card.tsx +2 -3
  32. package/src/Card/index.ts +1 -1
  33. package/src/index.ts +1 -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";
package/dist/src/index.js CHANGED
@@ -14,3 +14,4 @@ export * from "./InputFieldWrapper";
14
14
  export * from "./ProgressBar";
15
15
  export * from "./Heading";
16
16
  export * from "./Chip";
17
+ export * from "./ActionItem";