@jobber/components-native 0.9.0 → 0.11.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 (66) hide show
  1. package/dist/src/Button/Button.js +78 -0
  2. package/dist/src/Button/Button.style.js +92 -0
  3. package/dist/src/Button/components/InternalButtonLoading/InternalButtonLoading.js +36 -0
  4. package/dist/src/Button/components/InternalButtonLoading/InternalButtonLoading.style.js +4 -0
  5. package/dist/src/Button/components/InternalButtonLoading/index.js +1 -0
  6. package/dist/src/Button/index.js +1 -0
  7. package/dist/src/Button/types.js +1 -0
  8. package/dist/src/InputFieldWrapper/CommonInputStyles.style.js +33 -0
  9. package/dist/src/InputFieldWrapper/InputFieldWrapper.js +88 -0
  10. package/dist/src/InputFieldWrapper/InputFieldWrapper.style.js +79 -0
  11. package/dist/src/InputFieldWrapper/components/ClearAction/ClearAction.js +12 -0
  12. package/dist/src/InputFieldWrapper/components/ClearAction/ClearAction.style.js +25 -0
  13. package/dist/src/InputFieldWrapper/components/ClearAction/index.js +2 -0
  14. package/dist/src/InputFieldWrapper/components/ClearAction/messages.js +8 -0
  15. package/dist/src/InputFieldWrapper/components/Prefix/Prefix.js +34 -0
  16. package/dist/src/InputFieldWrapper/components/Suffix/Suffix.js +35 -0
  17. package/dist/src/InputFieldWrapper/hooks/useShowClear.js +15 -0
  18. package/dist/src/InputFieldWrapper/index.js +3 -0
  19. package/dist/src/index.js +2 -0
  20. package/dist/tsconfig.tsbuildinfo +1 -1
  21. package/dist/types/src/Button/Button.d.ts +71 -0
  22. package/dist/types/src/Button/Button.style.d.ts +86 -0
  23. package/dist/types/src/Button/components/InternalButtonLoading/InternalButtonLoading.d.ts +11 -0
  24. package/dist/types/src/Button/components/InternalButtonLoading/InternalButtonLoading.style.d.ts +4 -0
  25. package/dist/types/src/Button/components/InternalButtonLoading/index.d.ts +1 -0
  26. package/dist/types/src/Button/index.d.ts +2 -0
  27. package/dist/types/src/Button/types.d.ts +3 -0
  28. package/dist/types/src/InputFieldWrapper/CommonInputStyles.style.d.ts +30 -0
  29. package/dist/types/src/InputFieldWrapper/InputFieldWrapper.d.ts +63 -0
  30. package/dist/types/src/InputFieldWrapper/InputFieldWrapper.style.d.ts +82 -0
  31. package/dist/types/src/InputFieldWrapper/components/ClearAction/ClearAction.d.ts +10 -0
  32. package/dist/types/src/InputFieldWrapper/components/ClearAction/ClearAction.style.d.ts +22 -0
  33. package/dist/types/src/InputFieldWrapper/components/ClearAction/index.d.ts +2 -0
  34. package/dist/types/src/InputFieldWrapper/components/ClearAction/messages.d.ts +7 -0
  35. package/dist/types/src/InputFieldWrapper/components/Prefix/Prefix.d.ts +23 -0
  36. package/dist/types/src/InputFieldWrapper/components/Suffix/Suffix.d.ts +25 -0
  37. package/dist/types/src/InputFieldWrapper/hooks/useShowClear.d.ts +10 -0
  38. package/dist/types/src/InputFieldWrapper/index.d.ts +4 -0
  39. package/dist/types/src/index.d.ts +2 -0
  40. package/package.json +5 -2
  41. package/src/Button/Button.style.ts +116 -0
  42. package/src/Button/Button.test.tsx +298 -0
  43. package/src/Button/Button.tsx +223 -0
  44. package/src/Button/components/InternalButtonLoading/InternalButtonLoading.style.ts +5 -0
  45. package/src/Button/components/InternalButtonLoading/InternalButtonLoading.test.tsx +39 -0
  46. package/src/Button/components/InternalButtonLoading/InternalButtonLoading.tsx +77 -0
  47. package/src/Button/components/InternalButtonLoading/index.ts +1 -0
  48. package/src/Button/index.ts +2 -0
  49. package/src/Button/types.ts +3 -0
  50. package/src/InputFieldWrapper/CommonInputStyles.style.ts +37 -0
  51. package/src/InputFieldWrapper/InputFieldWrapper.style.ts +93 -0
  52. package/src/InputFieldWrapper/InputFieldWrapper.test.tsx +243 -0
  53. package/src/InputFieldWrapper/InputFieldWrapper.tsx +317 -0
  54. package/src/InputFieldWrapper/components/ClearAction/ClearAction.style.ts +27 -0
  55. package/src/InputFieldWrapper/components/ClearAction/ClearAction.test.tsx +15 -0
  56. package/src/InputFieldWrapper/components/ClearAction/ClearAction.tsx +32 -0
  57. package/src/InputFieldWrapper/components/ClearAction/index.ts +2 -0
  58. package/src/InputFieldWrapper/components/ClearAction/messages.ts +9 -0
  59. package/src/InputFieldWrapper/components/Prefix/Prefix.test.tsx +221 -0
  60. package/src/InputFieldWrapper/components/Prefix/Prefix.tsx +104 -0
  61. package/src/InputFieldWrapper/components/Suffix/Suffix.test.tsx +101 -0
  62. package/src/InputFieldWrapper/components/Suffix/Suffix.tsx +113 -0
  63. package/src/InputFieldWrapper/hooks/useShowClear.test.ts +158 -0
  64. package/src/InputFieldWrapper/hooks/useShowClear.ts +31 -0
  65. package/src/InputFieldWrapper/index.ts +4 -0
  66. package/src/index.ts +2 -0
@@ -0,0 +1,158 @@
1
+ import { useShowClear } from "./useShowClear";
2
+ import { Clearable } from "..";
3
+
4
+ interface UseShowClearParameters {
5
+ clearable: Clearable;
6
+ hasValue: boolean;
7
+ focused: boolean;
8
+ multiline: boolean;
9
+ disabled: boolean;
10
+ expected: boolean;
11
+ }
12
+
13
+ describe("useShowClear", () => {
14
+ describe.each<UseShowClearParameters>([
15
+ {
16
+ clearable: "always",
17
+ hasValue: true,
18
+ focused: false,
19
+ multiline: false,
20
+ disabled: false,
21
+ expected: true,
22
+ },
23
+ {
24
+ clearable: "always",
25
+ hasValue: true,
26
+ focused: true,
27
+ multiline: false,
28
+ disabled: false,
29
+ expected: true,
30
+ },
31
+ {
32
+ clearable: "always",
33
+ hasValue: true,
34
+ focused: false,
35
+ multiline: false,
36
+ disabled: true,
37
+ expected: false,
38
+ },
39
+ {
40
+ clearable: "always",
41
+ hasValue: false,
42
+ focused: false,
43
+ multiline: false,
44
+ disabled: true,
45
+ expected: false,
46
+ },
47
+ {
48
+ clearable: "while-editing",
49
+ hasValue: true,
50
+ focused: false,
51
+ multiline: false,
52
+ disabled: false,
53
+ expected: false,
54
+ },
55
+ {
56
+ clearable: "while-editing",
57
+ hasValue: true,
58
+ focused: true,
59
+ multiline: false,
60
+ disabled: false,
61
+ expected: true,
62
+ },
63
+ {
64
+ clearable: "while-editing",
65
+ hasValue: false,
66
+ focused: false,
67
+ multiline: false,
68
+ disabled: true,
69
+ expected: false,
70
+ },
71
+ {
72
+ clearable: "while-editing",
73
+ hasValue: true,
74
+ focused: false,
75
+ multiline: false,
76
+ disabled: true,
77
+ expected: false,
78
+ },
79
+ {
80
+ clearable: "never",
81
+ hasValue: true,
82
+ focused: false,
83
+ multiline: false,
84
+ disabled: false,
85
+ expected: false,
86
+ },
87
+ {
88
+ clearable: "never",
89
+ hasValue: true,
90
+ focused: true,
91
+ multiline: false,
92
+ disabled: false,
93
+ expected: false,
94
+ },
95
+ {
96
+ clearable: "never",
97
+ hasValue: false,
98
+ focused: false,
99
+ multiline: false,
100
+ disabled: true,
101
+ expected: false,
102
+ },
103
+ {
104
+ clearable: "never",
105
+ hasValue: true,
106
+ focused: false,
107
+ multiline: false,
108
+ disabled: true,
109
+ expected: false,
110
+ },
111
+ ])(
112
+ "%j",
113
+ ({
114
+ clearable,
115
+ hasValue,
116
+ focused,
117
+ multiline,
118
+ disabled,
119
+ expected,
120
+ }: UseShowClearParameters) => {
121
+ it(`returns ${expected}`, () => {
122
+ expect(
123
+ useShowClear({ clearable, multiline, focused, hasValue, disabled }),
124
+ ).toEqual(expected);
125
+ });
126
+ },
127
+ );
128
+
129
+ it("throws an error if multiline is true and clearable isn't never", () => {
130
+ expect(() => {
131
+ useShowClear({
132
+ clearable: "always",
133
+ multiline: true,
134
+ focused: true,
135
+ hasValue: true,
136
+ disabled: false,
137
+ });
138
+ }).toThrow();
139
+ expect(() => {
140
+ useShowClear({
141
+ clearable: "while-editing",
142
+ multiline: true,
143
+ focused: true,
144
+ hasValue: true,
145
+ disabled: false,
146
+ });
147
+ }).toThrow();
148
+ expect(() => {
149
+ useShowClear({
150
+ clearable: "never",
151
+ multiline: true,
152
+ focused: true,
153
+ hasValue: true,
154
+ disabled: false,
155
+ });
156
+ }).not.toThrow();
157
+ });
158
+ });
@@ -0,0 +1,31 @@
1
+ import { Clearable } from "../InputFieldWrapper";
2
+
3
+ interface UseShowClearParameters {
4
+ clearable: Clearable;
5
+ multiline: boolean;
6
+ focused: boolean;
7
+ hasValue: boolean;
8
+ disabled?: boolean;
9
+ }
10
+
11
+ export function useShowClear({
12
+ clearable,
13
+ multiline,
14
+ focused,
15
+ hasValue,
16
+ disabled = false,
17
+ }: UseShowClearParameters): boolean | undefined {
18
+ if (multiline && clearable !== "never") {
19
+ throw new Error("Multiline inputs can not be clearable");
20
+ }
21
+ // Do not show if there is no value
22
+ if (!hasValue || clearable === "never" || disabled) {
23
+ return false;
24
+ }
25
+ switch (clearable) {
26
+ case "while-editing":
27
+ return focused;
28
+ case "always":
29
+ return true;
30
+ }
31
+ }
@@ -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";
package/src/index.ts CHANGED
@@ -9,3 +9,5 @@ export * from "./ActivityIndicator";
9
9
  export * from "./Card";
10
10
  export * from "./StatusLabel";
11
11
  export * from "./AtlantisContext";
12
+ export * from "./Button";
13
+ export * from "./InputFieldWrapper";