@jobber/components-native 0.9.0 → 0.10.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 (43) hide show
  1. package/dist/src/InputFieldWrapper/CommonInputStyles.style.js +33 -0
  2. package/dist/src/InputFieldWrapper/InputFieldWrapper.js +88 -0
  3. package/dist/src/InputFieldWrapper/InputFieldWrapper.style.js +79 -0
  4. package/dist/src/InputFieldWrapper/components/ClearAction/ClearAction.js +12 -0
  5. package/dist/src/InputFieldWrapper/components/ClearAction/ClearAction.style.js +25 -0
  6. package/dist/src/InputFieldWrapper/components/ClearAction/index.js +2 -0
  7. package/dist/src/InputFieldWrapper/components/ClearAction/messages.js +8 -0
  8. package/dist/src/InputFieldWrapper/components/Prefix/Prefix.js +34 -0
  9. package/dist/src/InputFieldWrapper/components/Suffix/Suffix.js +35 -0
  10. package/dist/src/InputFieldWrapper/hooks/useShowClear.js +15 -0
  11. package/dist/src/InputFieldWrapper/index.js +3 -0
  12. package/dist/src/index.js +1 -0
  13. package/dist/tsconfig.tsbuildinfo +1 -1
  14. package/dist/types/src/InputFieldWrapper/CommonInputStyles.style.d.ts +30 -0
  15. package/dist/types/src/InputFieldWrapper/InputFieldWrapper.d.ts +63 -0
  16. package/dist/types/src/InputFieldWrapper/InputFieldWrapper.style.d.ts +82 -0
  17. package/dist/types/src/InputFieldWrapper/components/ClearAction/ClearAction.d.ts +10 -0
  18. package/dist/types/src/InputFieldWrapper/components/ClearAction/ClearAction.style.d.ts +22 -0
  19. package/dist/types/src/InputFieldWrapper/components/ClearAction/index.d.ts +2 -0
  20. package/dist/types/src/InputFieldWrapper/components/ClearAction/messages.d.ts +7 -0
  21. package/dist/types/src/InputFieldWrapper/components/Prefix/Prefix.d.ts +23 -0
  22. package/dist/types/src/InputFieldWrapper/components/Suffix/Suffix.d.ts +25 -0
  23. package/dist/types/src/InputFieldWrapper/hooks/useShowClear.d.ts +10 -0
  24. package/dist/types/src/InputFieldWrapper/index.d.ts +4 -0
  25. package/dist/types/src/index.d.ts +1 -0
  26. package/package.json +4 -2
  27. package/src/InputFieldWrapper/CommonInputStyles.style.ts +37 -0
  28. package/src/InputFieldWrapper/InputFieldWrapper.style.ts +93 -0
  29. package/src/InputFieldWrapper/InputFieldWrapper.test.tsx +243 -0
  30. package/src/InputFieldWrapper/InputFieldWrapper.tsx +317 -0
  31. package/src/InputFieldWrapper/components/ClearAction/ClearAction.style.ts +27 -0
  32. package/src/InputFieldWrapper/components/ClearAction/ClearAction.test.tsx +15 -0
  33. package/src/InputFieldWrapper/components/ClearAction/ClearAction.tsx +32 -0
  34. package/src/InputFieldWrapper/components/ClearAction/index.ts +2 -0
  35. package/src/InputFieldWrapper/components/ClearAction/messages.ts +9 -0
  36. package/src/InputFieldWrapper/components/Prefix/Prefix.test.tsx +221 -0
  37. package/src/InputFieldWrapper/components/Prefix/Prefix.tsx +104 -0
  38. package/src/InputFieldWrapper/components/Suffix/Suffix.test.tsx +101 -0
  39. package/src/InputFieldWrapper/components/Suffix/Suffix.tsx +113 -0
  40. package/src/InputFieldWrapper/hooks/useShowClear.test.ts +158 -0
  41. package/src/InputFieldWrapper/hooks/useShowClear.ts +31 -0
  42. package/src/InputFieldWrapper/index.ts +4 -0
  43. package/src/index.ts +1 -0
@@ -0,0 +1,30 @@
1
+ export declare const commonInputStyles: {
2
+ input: {
3
+ width: string;
4
+ flexShrink: number;
5
+ flexGrow: number;
6
+ color: string;
7
+ fontFamily: string | undefined;
8
+ fontSize: number | undefined;
9
+ letterSpacing: number | undefined;
10
+ minHeight: number;
11
+ padding: number;
12
+ };
13
+ inputEmpty: {
14
+ paddingTop: number;
15
+ };
16
+ inputDisabled: {
17
+ color: import("react-native").ColorValue | undefined;
18
+ };
19
+ container: {
20
+ marginVertical: number;
21
+ backgroundColor: string;
22
+ minHeight: number;
23
+ flexDirection: "row";
24
+ justifyContent: "space-between";
25
+ width: string;
26
+ borderColor: string;
27
+ borderStyle: "solid";
28
+ borderBottomWidth: number;
29
+ };
30
+ };
@@ -0,0 +1,63 @@
1
+ import React from "react";
2
+ import { StyleProp, TextStyle, ViewStyle } from "react-native";
3
+ import { FieldError } from "react-hook-form";
4
+ import { IconNames } from "@jobber/design";
5
+ export type Clearable = "never" | "while-editing" | "always";
6
+ export interface InputFieldStyleOverride {
7
+ prefixLabel?: StyleProp<TextStyle>;
8
+ suffixLabel?: StyleProp<TextStyle>;
9
+ container?: StyleProp<ViewStyle>;
10
+ placeholderText?: StyleProp<TextStyle>;
11
+ }
12
+ export interface InputFieldWrapperProps {
13
+ /**
14
+ * Highlights the field red and shows message below (if string) to indicate an error
15
+ */
16
+ readonly invalid?: boolean | string;
17
+ /**
18
+ * Disable the input
19
+ */
20
+ readonly disabled?: boolean;
21
+ /**
22
+ * Hint text that goes above the value once the field is filled out
23
+ */
24
+ readonly placeholder?: string;
25
+ /**
26
+ * Text that goes below the input to help the user understand the input
27
+ */
28
+ readonly assistiveText?: string;
29
+ readonly hasMiniLabel?: boolean;
30
+ readonly hasValue?: boolean;
31
+ /**
32
+ * Symbol to display before the text input
33
+ */
34
+ readonly prefix?: {
35
+ icon?: IconNames;
36
+ label?: string;
37
+ };
38
+ /**
39
+ * Symbol to display after the text input
40
+ */
41
+ readonly suffix?: {
42
+ icon?: IconNames;
43
+ label?: string;
44
+ onPress?: () => void;
45
+ };
46
+ readonly error?: FieldError;
47
+ readonly focused?: boolean;
48
+ readonly children: React.ReactNode;
49
+ /**
50
+ * Adds the ClearAction that will call the onClear handler when pressed
51
+ */
52
+ readonly showClearAction?: boolean;
53
+ /**
54
+ * Callback called when the user clicks the ClearAction button. Should clear the value passed.
55
+ * To disallow clearing set the clearable prop to never
56
+ */
57
+ readonly onClear?: () => void;
58
+ /**
59
+ * Custom styling to override default style of the input field
60
+ */
61
+ readonly styleOverride?: InputFieldStyleOverride;
62
+ }
63
+ export declare function InputFieldWrapper({ invalid, disabled, placeholder, assistiveText, prefix, suffix, hasMiniLabel, hasValue, error, focused, children, onClear, showClearAction, styleOverride, }: InputFieldWrapperProps): JSX.Element;
@@ -0,0 +1,82 @@
1
+ export declare const styles: {
2
+ container: {
3
+ marginVertical: number;
4
+ backgroundColor: string;
5
+ minHeight: number;
6
+ flexDirection: "row";
7
+ justifyContent: "space-between";
8
+ width: string;
9
+ borderColor: string;
10
+ borderStyle: "solid";
11
+ borderBottomWidth: number;
12
+ };
13
+ inputContainer: {
14
+ flexDirection: "row";
15
+ flex: number;
16
+ justifyContent: "flex-start";
17
+ };
18
+ inputFocused: {
19
+ borderColor: string;
20
+ };
21
+ inputInvalid: {
22
+ borderColor: string;
23
+ };
24
+ label: {
25
+ position: "absolute";
26
+ top: number | undefined;
27
+ right: number;
28
+ bottom: number;
29
+ left: number;
30
+ };
31
+ miniLabel: {
32
+ top: number;
33
+ paddingTop: number;
34
+ backgroundColor: string;
35
+ maxHeight: number;
36
+ zIndex: number;
37
+ };
38
+ miniLabelShowClearAction: {
39
+ backgroundColor: string;
40
+ };
41
+ disabled: {
42
+ backgroundColor: string;
43
+ borderTopLeftRadius: number;
44
+ borderTopRightRadius: number;
45
+ };
46
+ fieldAffix: {
47
+ flexDirection: "row";
48
+ };
49
+ fieldAffixMiniLabel: {
50
+ paddingTop: number;
51
+ top: number;
52
+ right: number;
53
+ bottom: number;
54
+ left: number;
55
+ };
56
+ prefixIcon: {
57
+ justifyContent: "center";
58
+ paddingRight: number;
59
+ };
60
+ prefixLabel: {
61
+ justifyContent: "center";
62
+ paddingTop: number;
63
+ paddingRight: number;
64
+ };
65
+ suffixIcon: {
66
+ justifyContent: "center";
67
+ };
68
+ suffixLabel: {
69
+ justifyContent: "center";
70
+ paddingTop: number;
71
+ };
72
+ suffixIconMargin: {
73
+ marginLeft: number;
74
+ };
75
+ suffixLabelMargin: {
76
+ marginLeft: number;
77
+ };
78
+ inputEndContainer: {
79
+ flexDirection: "row";
80
+ zIndex: number;
81
+ };
82
+ };
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ interface ClearActionProps {
3
+ /**
4
+ * Press handler
5
+ */
6
+ readonly onPress: () => void;
7
+ readonly hasMarginRight?: boolean;
8
+ }
9
+ export declare function ClearAction({ onPress, hasMarginRight, }: ClearActionProps): JSX.Element;
10
+ export {};
@@ -0,0 +1,22 @@
1
+ export declare const styles: {
2
+ container: {
3
+ width: number;
4
+ height: string;
5
+ flexDirection: "row";
6
+ justifyContent: "center";
7
+ alignItems: "center";
8
+ alignSelf: "center";
9
+ };
10
+ circle: {
11
+ backgroundColor: string;
12
+ borderRadius: number;
13
+ width: number;
14
+ height: number;
15
+ flexDirection: "row";
16
+ justifyContent: "center";
17
+ alignItems: "center";
18
+ };
19
+ addedMargin: {
20
+ marginRight: number;
21
+ };
22
+ };
@@ -0,0 +1,2 @@
1
+ export { ClearAction } from "./ClearAction";
2
+ export { messages } from "./messages";
@@ -0,0 +1,7 @@
1
+ export declare const messages: {
2
+ clearTextLabel: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ };
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" />
2
+ import { StyleProp, TextStyle, ViewStyle } from "react-native";
3
+ import { IconNames } from "@jobber/design";
4
+ export interface PrefixLabelProps {
5
+ focused: boolean;
6
+ disabled?: boolean;
7
+ hasMiniLabel: boolean;
8
+ inputInvalid: boolean;
9
+ label: string;
10
+ styleOverride?: StyleProp<TextStyle>;
11
+ }
12
+ export declare const prefixLabelTestId = "ATL-InputFieldWrapper-PrefixLabel";
13
+ export declare const prefixIconTestId = "ATL-InputFieldWrapper-PrefixIcon";
14
+ export declare function PrefixLabel({ focused, disabled, hasMiniLabel, inputInvalid, label, styleOverride, }: PrefixLabelProps): JSX.Element;
15
+ export interface PrefixIconProps {
16
+ focused: boolean;
17
+ disabled?: boolean;
18
+ hasMiniLabel: boolean;
19
+ inputInvalid?: boolean;
20
+ icon: IconNames;
21
+ styleOverride?: StyleProp<ViewStyle>;
22
+ }
23
+ export declare function PrefixIcon({ focused, disabled, inputInvalid, icon, }: PrefixIconProps): JSX.Element;
@@ -0,0 +1,25 @@
1
+ /// <reference types="react" />
2
+ import { StyleProp, TextStyle } from "react-native";
3
+ import { IconNames } from "@jobber/design";
4
+ export interface SuffixLabelProps {
5
+ focused: boolean;
6
+ disabled?: boolean;
7
+ hasMiniLabel: boolean;
8
+ inputInvalid?: boolean;
9
+ label: string;
10
+ hasLeftMargin?: boolean;
11
+ styleOverride?: StyleProp<TextStyle>;
12
+ }
13
+ export declare const suffixLabelTestId = "ATL-InputFieldWrapper-SuffixLabel";
14
+ export declare const suffixIconTestId = "ATL-InputFieldWrapper-SuffixIcon";
15
+ export declare function SuffixLabel({ focused, disabled, hasMiniLabel, inputInvalid, label, hasLeftMargin, styleOverride, }: SuffixLabelProps): JSX.Element;
16
+ export interface SuffixIconProps {
17
+ focused: boolean;
18
+ disabled?: boolean;
19
+ hasMiniLabel: boolean;
20
+ inputInvalid?: boolean;
21
+ icon: IconNames;
22
+ hasLeftMargin?: boolean;
23
+ onPress?: () => void;
24
+ }
25
+ export declare function SuffixIcon({ focused, disabled, inputInvalid, icon, hasLeftMargin, onPress, }: SuffixIconProps): JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { Clearable } from "../InputFieldWrapper";
2
+ interface UseShowClearParameters {
3
+ clearable: Clearable;
4
+ multiline: boolean;
5
+ focused: boolean;
6
+ hasValue: boolean;
7
+ disabled?: boolean;
8
+ }
9
+ export declare function useShowClear({ clearable, multiline, focused, hasValue, disabled, }: UseShowClearParameters): boolean | undefined;
10
+ export {};
@@ -0,0 +1,4 @@
1
+ export { commonInputStyles } from "./CommonInputStyles.style";
2
+ export { InputFieldWrapper } from "./InputFieldWrapper";
3
+ export type { InputFieldWrapperProps, Clearable } from "./InputFieldWrapper";
4
+ export { useShowClear } from "./hooks/useShowClear";
@@ -9,3 +9,4 @@ export * from "./ActivityIndicator";
9
9
  export * from "./Card";
10
10
  export * from "./StatusLabel";
11
11
  export * from "./AtlantisContext";
12
+ export * from "./InputFieldWrapper";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components-native",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/src/index.js",
6
6
  "module": "dist/src/index.js",
@@ -22,6 +22,8 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@jobber/design": "^0.39.0",
25
+ "react-hook-form": "^7.30.0",
26
+ "react-intl": "^6.4.2",
25
27
  "react-native-gesture-handler": "^2.5.0",
26
28
  "react-native-localize": "^2.2.6",
27
29
  "react-native-svg": "^13.9.0",
@@ -44,5 +46,5 @@
44
46
  "react": "^18",
45
47
  "react-native": ">=0.69.2"
46
48
  },
47
- "gitHead": "f884bf403f42a1c85f7bf840a6317ae1642653e1"
49
+ "gitHead": "d363c516d3f72dc510c7b0ad002fdbf479bf9292"
48
50
  }
@@ -0,0 +1,37 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { typographyStyles } from "../Typography";
3
+ import { tokens } from "../utils/design";
4
+
5
+ export const commonInputStyles = StyleSheet.create({
6
+ input: {
7
+ width: "100%",
8
+ flexShrink: 1,
9
+ flexGrow: 1,
10
+ color: tokens["color-text"],
11
+ fontFamily: typographyStyles.baseRegularRegular.fontFamily,
12
+ fontSize: typographyStyles.defaultSize.fontSize,
13
+ letterSpacing: typographyStyles.baseLetterSpacing.letterSpacing,
14
+ minHeight: tokens["space-largest"],
15
+ padding: 0,
16
+ },
17
+
18
+ inputEmpty: {
19
+ paddingTop: 0,
20
+ },
21
+
22
+ inputDisabled: {
23
+ color: typographyStyles.disabled.color,
24
+ },
25
+
26
+ container: {
27
+ marginVertical: tokens["space-smaller"],
28
+ backgroundColor: tokens["color-surface"],
29
+ minHeight: tokens["space-largest"],
30
+ flexDirection: "row",
31
+ justifyContent: "space-between",
32
+ width: "100%",
33
+ borderColor: tokens["color-grey"],
34
+ borderStyle: "solid",
35
+ borderBottomWidth: tokens["border-base"],
36
+ },
37
+ });
@@ -0,0 +1,93 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { commonInputStyles } from "./CommonInputStyles.style";
3
+ import { tokens } from "../utils/design";
4
+ import { typographyStyles } from "../Typography";
5
+
6
+ export const styles = StyleSheet.create({
7
+ container: StyleSheet.flatten([commonInputStyles.container]),
8
+
9
+ inputContainer: {
10
+ flexDirection: "row",
11
+ flex: 1,
12
+ justifyContent: "flex-start",
13
+ },
14
+
15
+ inputFocused: {
16
+ borderColor: tokens["color-interactive"],
17
+ },
18
+
19
+ inputInvalid: {
20
+ borderColor: tokens["color-critical"],
21
+ },
22
+
23
+ label: {
24
+ // for placeholder
25
+ position: "absolute",
26
+ top: typographyStyles.smallSize.fontSize,
27
+ right: 0,
28
+ bottom: 0,
29
+ left: 0,
30
+ },
31
+
32
+ miniLabel: {
33
+ top: 0,
34
+ paddingTop: tokens["space-smallest"],
35
+ backgroundColor: tokens["color-surface"],
36
+ maxHeight:
37
+ (typographyStyles.smallSize.lineHeight || 0) + tokens["space-smaller"],
38
+ zIndex: 1,
39
+ },
40
+ // Prevents the miniLabel from cutting off the ClearAction button
41
+ miniLabelShowClearAction: {
42
+ backgroundColor: "transparent",
43
+ },
44
+
45
+ disabled: {
46
+ backgroundColor: tokens["color-disabled--secondary"],
47
+ borderTopLeftRadius: tokens["radius-large"],
48
+ borderTopRightRadius: tokens["radius-large"],
49
+ },
50
+
51
+ fieldAffix: {
52
+ flexDirection: "row",
53
+ },
54
+
55
+ fieldAffixMiniLabel: {
56
+ paddingTop: 0,
57
+ // @ts-expect-error tsc-ci
58
+ top: typographyStyles.smallSize.fontSize / 2,
59
+ right: 0,
60
+ bottom: 0,
61
+ left: 0,
62
+ },
63
+
64
+ prefixIcon: {
65
+ justifyContent: "center",
66
+ paddingRight: tokens["space-small"],
67
+ },
68
+
69
+ prefixLabel: {
70
+ justifyContent: "center",
71
+ paddingTop: tokens["space-minuscule"],
72
+ paddingRight: tokens["space-minuscule"],
73
+ },
74
+
75
+ suffixIcon: {
76
+ justifyContent: "center",
77
+ },
78
+
79
+ suffixLabel: {
80
+ justifyContent: "center",
81
+ paddingTop: tokens["space-minuscule"],
82
+ },
83
+ suffixIconMargin: {
84
+ marginLeft: tokens["space-small"] + tokens["space-smaller"],
85
+ },
86
+ suffixLabelMargin: {
87
+ marginLeft: tokens["space-smallest"],
88
+ },
89
+ inputEndContainer: {
90
+ flexDirection: "row",
91
+ zIndex: 1,
92
+ },
93
+ });