@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,10 +2,15 @@ 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
  jest.mock("../../AtlantisContext", () => (Object.assign({
7
8
  // need to mark this as a module so that we can spy on it
8
9
  __esModule: true }, jest.requireActual("../../AtlantisContext"))));
10
+ // Mock releasedLanguages so that jest.spyOn can reliably intercept calls from
11
+ // inside the hook. Without this, Babel may resolve the named import as a local
12
+ // binding at module load time, bypassing any spy set up afterwards.
13
+ jest.mock("./releasedLanguages", () => (Object.assign({ __esModule: true }, jest.requireActual("./releasedLanguages"))));
9
14
  const spy = jest.spyOn(context, "useAtlantisContext");
10
15
  const testDate = new Date("2020-01-01T00:00:00.000Z");
11
16
  const dateAfterSpringForward = new Date("2020-04-10T00:00:00.000Z");
@@ -22,18 +27,123 @@ describe("useAtlantisI18n", () => {
22
27
  const { result } = renderHook(useAtlantisI18n);
23
28
  expect(result.current.t("FormatFile.preview", { item: "🔱" })).toBe("Preview 🔱");
24
29
  });
30
+ // These tests bypass the release gate via a spy so we can validate Spanish
31
+ // string correctness as the feature is built, independently of RELEASED_LANGUAGES.
25
32
  describe("Español", () => {
33
+ let getReleasedLocaleSpy;
34
+ beforeEach(() => {
35
+ getReleasedLocaleSpy = jest
36
+ .spyOn(releasedLanguages, "getReleasedLocale")
37
+ .mockImplementation(locale => locale);
38
+ });
39
+ afterEach(() => {
40
+ getReleasedLocaleSpy.mockRestore();
41
+ });
26
42
  it("should return español", () => {
27
43
  spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "es" }));
28
44
  const { result } = renderHook(useAtlantisI18n);
29
45
  expect(result.current.t("cancel")).toBe("Cancelar");
30
46
  });
31
- });
32
- describe("Unsupported language", () => {
33
- it("should return the english translation", () => {
34
- spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "fr" }));
47
+ it("should return español for regional variant es-US", () => {
48
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "es-US" }));
35
49
  const { result } = renderHook(useAtlantisI18n);
36
- expect(result.current.t("cancel")).toBe("Cancel");
50
+ expect(result.current.t("cancel")).toBe("Cancelar");
51
+ });
52
+ describe("formatDate", () => {
53
+ it("should return the date formatted for es", () => {
54
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "es" }));
55
+ const { result } = renderHook(useAtlantisI18n);
56
+ expect(result.current.formatDate(testDate)).toBe("1 ene 2020");
57
+ });
58
+ });
59
+ describe("formatTime", () => {
60
+ it("should return the time formatted for es", () => {
61
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "es" }));
62
+ const { result } = renderHook(useAtlantisI18n);
63
+ expect(result.current.formatTime(testDate)).toBe("00:00");
64
+ });
65
+ });
66
+ });
67
+ describe("RELEASED_LANGUAGES fallback", () => {
68
+ describe("unsupported language (fr)", () => {
69
+ it("should return 'en' as the locale", () => {
70
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "fr" }));
71
+ const { result } = renderHook(useAtlantisI18n);
72
+ expect(result.current.locale).toBe("en");
73
+ });
74
+ it("should return english translations", () => {
75
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "fr" }));
76
+ const { result } = renderHook(useAtlantisI18n);
77
+ expect(result.current.t("cancel")).toBe("Cancel");
78
+ });
79
+ });
80
+ describe("es-US (unreleased locale variant)", () => {
81
+ it("should return 'en' as the locale", () => {
82
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "es-US" }));
83
+ const { result } = renderHook(useAtlantisI18n);
84
+ expect(result.current.locale).toBe("en");
85
+ });
86
+ it("should return english translations", () => {
87
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "es-US" }));
88
+ const { result } = renderHook(useAtlantisI18n);
89
+ expect(result.current.t("cancel")).toBe("Cancel");
90
+ });
91
+ it("should format date using english locale", () => {
92
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "es-US" }));
93
+ const { result } = renderHook(useAtlantisI18n);
94
+ expect(result.current.formatDate(testDate)).toBe("Jan 1, 2020");
95
+ });
96
+ it("should format time using english locale", () => {
97
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "es-US" }));
98
+ const { result } = renderHook(useAtlantisI18n);
99
+ expect(result.current.formatTime(testDate)).toBe("12:00 AM");
100
+ });
101
+ });
102
+ describe("es (not yet released)", () => {
103
+ it("should return 'en' as the locale", () => {
104
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "es" }));
105
+ const { result } = renderHook(useAtlantisI18n);
106
+ expect(result.current.locale).toBe("en");
107
+ });
108
+ it("should return english translations", () => {
109
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "es" }));
110
+ const { result } = renderHook(useAtlantisI18n);
111
+ expect(result.current.t("cancel")).toBe("Cancel");
112
+ });
113
+ it("should format date using english locale", () => {
114
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "es" }));
115
+ const { result } = renderHook(useAtlantisI18n);
116
+ expect(result.current.formatDate(testDate)).toBe("Jan 1, 2020");
117
+ });
118
+ it("should format time using english locale", () => {
119
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "es" }));
120
+ const { result } = renderHook(useAtlantisI18n);
121
+ expect(result.current.formatTime(testDate)).toBe("12:00 AM");
122
+ });
123
+ });
124
+ describe("en-CA (released language, regional variant)", () => {
125
+ it("should preserve the full locale for date formatting", () => {
126
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "en-CA" }));
127
+ const { result } = renderHook(useAtlantisI18n);
128
+ expect(result.current.locale).toBe("en-CA");
129
+ });
130
+ it("should return english translations", () => {
131
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "en-CA" }));
132
+ const { result } = renderHook(useAtlantisI18n);
133
+ expect(result.current.t("cancel")).toBe("Cancel");
134
+ });
135
+ });
136
+ describe("en-GB (released language, regional variant)", () => {
137
+ it("should preserve the full locale for date formatting", () => {
138
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "en-GB" }));
139
+ const { result } = renderHook(useAtlantisI18n);
140
+ expect(result.current.locale).toBe("en-GB");
141
+ });
142
+ it("should return english translations", () => {
143
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "en-GB" }));
144
+ const { result } = renderHook(useAtlantisI18n);
145
+ expect(result.current.t("cancel")).toBe("Cancel");
146
+ });
37
147
  });
38
148
  });
39
149
  describe("Translation files", () => {
@@ -46,11 +156,6 @@ describe("useAtlantisI18n", () => {
46
156
  const { result } = renderHook(useAtlantisI18n);
47
157
  expect(result.current.formatDate(testDate)).toBe("Jan 1, 2020");
48
158
  });
49
- it("should return the date formatted for es", () => {
50
- spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "es" }));
51
- const { result } = renderHook(useAtlantisI18n);
52
- expect(result.current.formatDate(testDate)).toBe("1 ene 2020");
53
- });
54
159
  describe("Timezone", () => {
55
160
  it.each([
56
161
  ["America/New_York", "Dec 31, 2019"],
@@ -70,11 +175,6 @@ describe("useAtlantisI18n", () => {
70
175
  const { result } = renderHook(useAtlantisI18n);
71
176
  expect(result.current.formatTime(testDate)).toBe("12:00 AM");
72
177
  });
73
- it("should return the date formatted for es", () => {
74
- spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "es" }));
75
- const { result } = renderHook(useAtlantisI18n);
76
- expect(result.current.formatTime(testDate)).toBe("00:00");
77
- });
78
178
  describe("Timezone", () => {
79
179
  it.each([
80
180
  ["America/New_York", "7:00 PM"],
package/dist/src/index.js 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",