@jobber/components-native 0.109.1 → 0.111.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 (56) hide show
  1. package/dist/docs/ProgressBar/ProgressBar.md +1 -1
  2. package/dist/docs/ProgressIndicator/ProgressIndicator.md +117 -0
  3. package/dist/docs/index.md +1 -0
  4. package/dist/package.json +2 -2
  5. package/dist/src/ProgressBar/ProgressBar.js +6 -0
  6. package/dist/src/ProgressBar/ProgressBar.test.js +2 -0
  7. package/dist/src/ProgressIndicator/ProgressIndicator.js +106 -0
  8. package/dist/src/ProgressIndicator/ProgressIndicator.size.style.js +15 -0
  9. package/dist/src/ProgressIndicator/ProgressIndicator.style.js +51 -0
  10. package/dist/src/ProgressIndicator/ProgressIndicator.test.js +138 -0
  11. package/dist/src/ProgressIndicator/index.js +1 -0
  12. package/dist/src/ProgressIndicator/types.js +1 -0
  13. package/dist/src/hooks/useAtlantisI18n/locales/en.json +3 -0
  14. package/dist/src/hooks/useAtlantisI18n/locales/es.json +3 -0
  15. package/dist/src/hooks/useAtlantisI18n/releasedLanguages.js +21 -0
  16. package/dist/src/hooks/useAtlantisI18n/useAtlantisI18n.js +4 -2
  17. package/dist/src/hooks/useAtlantisI18n/useAtlantisI18n.test.js +115 -15
  18. package/dist/src/index.js +1 -0
  19. package/dist/src/utils/meta/meta.json +1 -0
  20. package/dist/tsconfig.build.tsbuildinfo +1 -1
  21. package/dist/types/src/ProgressBar/ProgressBar.d.ts +3 -0
  22. package/dist/types/src/ProgressBar/types.d.ts +3 -0
  23. package/dist/types/src/ProgressIndicator/ProgressIndicator.d.ts +3 -0
  24. package/dist/types/src/ProgressIndicator/ProgressIndicator.size.style.d.ts +19 -0
  25. package/dist/types/src/ProgressIndicator/ProgressIndicator.style.d.ts +48 -0
  26. package/dist/types/src/ProgressIndicator/ProgressIndicator.test.d.ts +1 -0
  27. package/dist/types/src/ProgressIndicator/index.d.ts +2 -0
  28. package/dist/types/src/ProgressIndicator/types.d.ts +44 -0
  29. package/dist/types/src/hooks/useAtlantisI18n/releasedLanguages.d.ts +18 -0
  30. package/dist/types/src/hooks/useAtlantisI18n/useAtlantisI18n.d.ts +3 -1
  31. package/dist/types/src/index.d.ts +1 -0
  32. package/package.json +2 -2
  33. package/src/ProgressBar/ProgressBar.stories.tsx +2 -0
  34. package/src/ProgressBar/ProgressBar.test.tsx +2 -0
  35. package/src/ProgressBar/ProgressBar.tsx +6 -0
  36. package/src/ProgressBar/docs/ProgressBarBasic.tsx +2 -0
  37. package/src/ProgressBar/docs/ProgressBarWithHeader.tsx +2 -0
  38. package/src/ProgressBar/types.ts +3 -0
  39. package/src/ProgressIndicator/ProgressIndicator.size.style.ts +20 -0
  40. package/src/ProgressIndicator/ProgressIndicator.stories.tsx +154 -0
  41. package/src/ProgressIndicator/ProgressIndicator.style.ts +53 -0
  42. package/src/ProgressIndicator/ProgressIndicator.test.tsx +214 -0
  43. package/src/ProgressIndicator/ProgressIndicator.tsx +198 -0
  44. package/src/ProgressIndicator/docs/ProgressIndicatorBasic.tsx +22 -0
  45. package/src/ProgressIndicator/docs/ProgressIndicatorPending.tsx +22 -0
  46. package/src/ProgressIndicator/docs/index.ts +2 -0
  47. package/src/ProgressIndicator/guide.md +104 -0
  48. package/src/ProgressIndicator/index.ts +2 -0
  49. package/src/ProgressIndicator/types.ts +51 -0
  50. package/src/hooks/useAtlantisI18n/locales/en.json +3 -0
  51. package/src/hooks/useAtlantisI18n/locales/es.json +3 -0
  52. package/src/hooks/useAtlantisI18n/releasedLanguages.ts +23 -0
  53. package/src/hooks/useAtlantisI18n/useAtlantisI18n.test.ts +202 -25
  54. package/src/hooks/useAtlantisI18n/useAtlantisI18n.ts +13 -3
  55. package/src/index.ts +1 -0
  56. package/src/utils/meta/meta.json +1 -0
@@ -2,6 +2,7 @@ import { renderHook } from "@testing-library/react-native";
2
2
  import { useAtlantisI18n } from ".";
3
3
  import en from "./locales/en.json";
4
4
  import es from "./locales/es.json";
5
+ import * as releasedLanguages from "./releasedLanguages";
5
6
  import * as context from "../../AtlantisContext";
6
7
 
7
8
  jest.mock("../../AtlantisContext", () => ({
@@ -10,6 +11,14 @@ jest.mock("../../AtlantisContext", () => ({
10
11
  ...jest.requireActual("../../AtlantisContext"),
11
12
  }));
12
13
 
14
+ // Mock releasedLanguages so that jest.spyOn can reliably intercept calls from
15
+ // inside the hook. Without this, Babel may resolve the named import as a local
16
+ // binding at module load time, bypassing any spy set up afterwards.
17
+ jest.mock("./releasedLanguages", () => ({
18
+ __esModule: true,
19
+ ...jest.requireActual("./releasedLanguages"),
20
+ }));
21
+
13
22
  const spy = jest.spyOn(context, "useAtlantisContext");
14
23
  const testDate = new Date("2020-01-01T00:00:00.000Z");
15
24
  const dateAfterSpringForward = new Date("2020-04-10T00:00:00.000Z");
@@ -34,7 +43,21 @@ describe("useAtlantisI18n", () => {
34
43
  );
35
44
  });
36
45
 
46
+ // These tests bypass the release gate via a spy so we can validate Spanish
47
+ // string correctness as the feature is built, independently of RELEASED_LANGUAGES.
37
48
  describe("Español", () => {
49
+ let getReleasedLocaleSpy: jest.SpyInstance;
50
+
51
+ beforeEach(() => {
52
+ getReleasedLocaleSpy = jest
53
+ .spyOn(releasedLanguages, "getReleasedLocale")
54
+ .mockImplementation(locale => locale);
55
+ });
56
+
57
+ afterEach(() => {
58
+ getReleasedLocaleSpy.mockRestore();
59
+ });
60
+
38
61
  it("should return español", () => {
39
62
  spy.mockReturnValueOnce({
40
63
  ...context.atlantisContextDefaultValues,
@@ -44,17 +67,191 @@ describe("useAtlantisI18n", () => {
44
67
 
45
68
  expect(result.current.t("cancel")).toBe("Cancelar");
46
69
  });
47
- });
48
70
 
49
- describe("Unsupported language", () => {
50
- it("should return the english translation", () => {
71
+ it("should return español for regional variant es-US", () => {
51
72
  spy.mockReturnValueOnce({
52
73
  ...context.atlantisContextDefaultValues,
53
- locale: "fr",
74
+ locale: "es-US",
54
75
  });
55
76
  const { result } = renderHook(useAtlantisI18n);
56
77
 
57
- expect(result.current.t("cancel")).toBe("Cancel");
78
+ expect(result.current.t("cancel")).toBe("Cancelar");
79
+ });
80
+
81
+ describe("formatDate", () => {
82
+ it("should return the date formatted for es", () => {
83
+ spy.mockReturnValueOnce({
84
+ ...context.atlantisContextDefaultValues,
85
+ locale: "es",
86
+ });
87
+
88
+ const { result } = renderHook(useAtlantisI18n);
89
+ expect(result.current.formatDate(testDate)).toBe("1 ene 2020");
90
+ });
91
+ });
92
+
93
+ describe("formatTime", () => {
94
+ it("should return the time formatted for es", () => {
95
+ spy.mockReturnValueOnce({
96
+ ...context.atlantisContextDefaultValues,
97
+ locale: "es",
98
+ });
99
+
100
+ const { result } = renderHook(useAtlantisI18n);
101
+ expect(result.current.formatTime(testDate)).toBe("00:00");
102
+ });
103
+ });
104
+ });
105
+
106
+ describe("RELEASED_LANGUAGES fallback", () => {
107
+ describe("unsupported language (fr)", () => {
108
+ it("should return 'en' as the locale", () => {
109
+ spy.mockReturnValueOnce({
110
+ ...context.atlantisContextDefaultValues,
111
+ locale: "fr",
112
+ });
113
+ const { result } = renderHook(useAtlantisI18n);
114
+
115
+ expect(result.current.locale).toBe("en");
116
+ });
117
+
118
+ it("should return english translations", () => {
119
+ spy.mockReturnValueOnce({
120
+ ...context.atlantisContextDefaultValues,
121
+ locale: "fr",
122
+ });
123
+ const { result } = renderHook(useAtlantisI18n);
124
+
125
+ expect(result.current.t("cancel")).toBe("Cancel");
126
+ });
127
+ });
128
+
129
+ describe("es-US (unreleased locale variant)", () => {
130
+ it("should return 'en' as the locale", () => {
131
+ spy.mockReturnValueOnce({
132
+ ...context.atlantisContextDefaultValues,
133
+ locale: "es-US",
134
+ });
135
+ const { result } = renderHook(useAtlantisI18n);
136
+
137
+ expect(result.current.locale).toBe("en");
138
+ });
139
+
140
+ it("should return english translations", () => {
141
+ spy.mockReturnValueOnce({
142
+ ...context.atlantisContextDefaultValues,
143
+ locale: "es-US",
144
+ });
145
+ const { result } = renderHook(useAtlantisI18n);
146
+
147
+ expect(result.current.t("cancel")).toBe("Cancel");
148
+ });
149
+
150
+ it("should format date using english locale", () => {
151
+ spy.mockReturnValueOnce({
152
+ ...context.atlantisContextDefaultValues,
153
+ locale: "es-US",
154
+ });
155
+ const { result } = renderHook(useAtlantisI18n);
156
+
157
+ expect(result.current.formatDate(testDate)).toBe("Jan 1, 2020");
158
+ });
159
+
160
+ it("should format time using english locale", () => {
161
+ spy.mockReturnValueOnce({
162
+ ...context.atlantisContextDefaultValues,
163
+ locale: "es-US",
164
+ });
165
+ const { result } = renderHook(useAtlantisI18n);
166
+
167
+ expect(result.current.formatTime(testDate)).toBe("12:00 AM");
168
+ });
169
+ });
170
+
171
+ describe("es (not yet released)", () => {
172
+ it("should return 'en' as the locale", () => {
173
+ spy.mockReturnValueOnce({
174
+ ...context.atlantisContextDefaultValues,
175
+ locale: "es",
176
+ });
177
+ const { result } = renderHook(useAtlantisI18n);
178
+
179
+ expect(result.current.locale).toBe("en");
180
+ });
181
+
182
+ it("should return english translations", () => {
183
+ spy.mockReturnValueOnce({
184
+ ...context.atlantisContextDefaultValues,
185
+ locale: "es",
186
+ });
187
+ const { result } = renderHook(useAtlantisI18n);
188
+
189
+ expect(result.current.t("cancel")).toBe("Cancel");
190
+ });
191
+
192
+ it("should format date using english locale", () => {
193
+ spy.mockReturnValueOnce({
194
+ ...context.atlantisContextDefaultValues,
195
+ locale: "es",
196
+ });
197
+ const { result } = renderHook(useAtlantisI18n);
198
+
199
+ expect(result.current.formatDate(testDate)).toBe("Jan 1, 2020");
200
+ });
201
+
202
+ it("should format time using english locale", () => {
203
+ spy.mockReturnValueOnce({
204
+ ...context.atlantisContextDefaultValues,
205
+ locale: "es",
206
+ });
207
+ const { result } = renderHook(useAtlantisI18n);
208
+
209
+ expect(result.current.formatTime(testDate)).toBe("12:00 AM");
210
+ });
211
+ });
212
+
213
+ describe("en-CA (released language, regional variant)", () => {
214
+ it("should preserve the full locale for date formatting", () => {
215
+ spy.mockReturnValueOnce({
216
+ ...context.atlantisContextDefaultValues,
217
+ locale: "en-CA",
218
+ });
219
+ const { result } = renderHook(useAtlantisI18n);
220
+
221
+ expect(result.current.locale).toBe("en-CA");
222
+ });
223
+
224
+ it("should return english translations", () => {
225
+ spy.mockReturnValueOnce({
226
+ ...context.atlantisContextDefaultValues,
227
+ locale: "en-CA",
228
+ });
229
+ const { result } = renderHook(useAtlantisI18n);
230
+
231
+ expect(result.current.t("cancel")).toBe("Cancel");
232
+ });
233
+ });
234
+
235
+ describe("en-GB (released language, regional variant)", () => {
236
+ it("should preserve the full locale for date formatting", () => {
237
+ spy.mockReturnValueOnce({
238
+ ...context.atlantisContextDefaultValues,
239
+ locale: "en-GB",
240
+ });
241
+ const { result } = renderHook(useAtlantisI18n);
242
+
243
+ expect(result.current.locale).toBe("en-GB");
244
+ });
245
+
246
+ it("should return english translations", () => {
247
+ spy.mockReturnValueOnce({
248
+ ...context.atlantisContextDefaultValues,
249
+ locale: "en-GB",
250
+ });
251
+ const { result } = renderHook(useAtlantisI18n);
252
+
253
+ expect(result.current.t("cancel")).toBe("Cancel");
254
+ });
58
255
  });
59
256
  });
60
257
 
@@ -70,16 +267,6 @@ describe("useAtlantisI18n", () => {
70
267
  expect(result.current.formatDate(testDate)).toBe("Jan 1, 2020");
71
268
  });
72
269
 
73
- it("should return the date formatted for es", () => {
74
- spy.mockReturnValueOnce({
75
- ...context.atlantisContextDefaultValues,
76
- locale: "es",
77
- });
78
-
79
- const { result } = renderHook(useAtlantisI18n);
80
- expect(result.current.formatDate(testDate)).toBe("1 ene 2020");
81
- });
82
-
83
270
  describe("Timezone", () => {
84
271
  it.each([
85
272
  ["America/New_York", "Dec 31, 2019"],
@@ -105,16 +292,6 @@ describe("useAtlantisI18n", () => {
105
292
  expect(result.current.formatTime(testDate)).toBe("12:00 AM");
106
293
  });
107
294
 
108
- it("should return the date formatted for es", () => {
109
- spy.mockReturnValueOnce({
110
- ...context.atlantisContextDefaultValues,
111
- locale: "es",
112
- });
113
-
114
- const { result } = renderHook(useAtlantisI18n);
115
- expect(result.current.formatTime(testDate)).toBe("00:00");
116
- });
117
-
118
295
  describe("Timezone", () => {
119
296
  it.each([
120
297
  ["America/New_York", "7:00 PM"],
@@ -1,6 +1,7 @@
1
1
  import { useCallback } from "react";
2
2
  import en from "./locales/en.json";
3
3
  import es from "./locales/es.json";
4
+ import { getReleasedLocale } from "./releasedLanguages";
4
5
  import { dateFormatter } from "./utils/dateFormatter";
5
6
  import { useAtlantisContext } from "../../AtlantisContext";
6
7
 
@@ -8,7 +9,9 @@ export type I18nKeys = keyof typeof en;
8
9
 
9
10
  export interface useAtlantisI18nValue {
10
11
  /**
11
- * The set locale based on the AtlantisContext.
12
+ * The effective locale, resolved from the AtlantisContext locale against the
13
+ * list of released languages. Regional variants (e.g. "en-CA") are preserved
14
+ * when their language is released. Unreleased locales fall back to "en".
12
15
  */
13
16
  readonly locale: string;
14
17
 
@@ -32,7 +35,14 @@ export interface useAtlantisI18nValue {
32
35
  }
33
36
 
34
37
  export function useAtlantisI18n(): useAtlantisI18nValue {
35
- const { locale, dateFormat, timeFormat, timeZone } = useAtlantisContext();
38
+ const {
39
+ locale: contextLocale,
40
+ dateFormat,
41
+ timeFormat,
42
+ timeZone,
43
+ } = useAtlantisContext();
44
+
45
+ const locale = getReleasedLocale(contextLocale);
36
46
 
37
47
  const t = useCallback(
38
48
  (messageKey: keyof typeof en, values?: Record<string, string>) =>
@@ -54,7 +64,7 @@ export function useAtlantisI18n(): useAtlantisI18nValue {
54
64
  }
55
65
 
56
66
  function getLocalizedStrings(locale: string): typeof en {
57
- switch (locale) {
67
+ switch (locale.split("-")[0]) {
58
68
  case "es":
59
69
  return es;
60
70
  default:
package/src/index.ts CHANGED
@@ -37,6 +37,7 @@ export * from "./InputSearch";
37
37
  export * from "./InputText";
38
38
  export * from "./InputTime";
39
39
  export * from "./ProgressBar";
40
+ export * from "./ProgressIndicator";
40
41
  export * from "./Select";
41
42
  export * from "./StatusLabel";
42
43
  export * from "./Switch";
@@ -59,6 +59,7 @@
59
59
  "InputTime",
60
60
  "Option",
61
61
  "ProgressBar",
62
+ "ProgressIndicator",
62
63
  "Select",
63
64
  "Select.Content",
64
65
  "Select.Group",