@terreno/ui 0.31.0 → 56.0.0-beta.2

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 (126) hide show
  1. package/dist/ActionSheet.d.ts +1 -1
  2. package/dist/Avatar.js +1 -4
  3. package/dist/Avatar.js.map +1 -1
  4. package/dist/Box.js +45 -9
  5. package/dist/Box.js.map +1 -1
  6. package/dist/Common.d.ts +21 -0
  7. package/dist/Common.js.map +1 -1
  8. package/dist/ConflictSheet.d.ts +53 -0
  9. package/dist/ConflictSheet.js +132 -0
  10. package/dist/ConflictSheet.js.map +1 -0
  11. package/dist/DateTimeActionSheet.d.ts +2 -1
  12. package/dist/DateTimeField.js +5 -21
  13. package/dist/DateTimeField.js.map +1 -1
  14. package/dist/DecimalRangeActionSheet.d.ts +1 -1
  15. package/dist/EmojiSelector.d.ts +1 -1
  16. package/dist/ErrorPage.d.ts +1 -1
  17. package/dist/HeightActionSheet.d.ts +1 -1
  18. package/dist/Hyperlink.d.ts +2 -1
  19. package/dist/Hyperlink.js +2 -1
  20. package/dist/Hyperlink.js.map +1 -1
  21. package/dist/Image.d.ts +1 -1
  22. package/dist/ImageBackground.d.ts +1 -1
  23. package/dist/MobileAddressAutoComplete.d.ts +1 -1
  24. package/dist/NumberPickerActionSheet.d.ts +1 -1
  25. package/dist/Page.d.ts +5 -4
  26. package/dist/Page.js +0 -2
  27. package/dist/Page.js.map +1 -1
  28. package/dist/PickerSelect.d.ts +1 -1
  29. package/dist/SidebarNavigation.js +1 -1
  30. package/dist/SidebarNavigation.js.map +1 -1
  31. package/dist/SidebarNavigation.native.js +1 -1
  32. package/dist/SidebarNavigation.native.js.map +1 -1
  33. package/dist/SplitPage.d.ts +1 -1
  34. package/dist/SplitPage.js +1 -4
  35. package/dist/SplitPage.js.map +1 -1
  36. package/dist/SplitPage.native.d.ts +1 -1
  37. package/dist/SyncStatusBanner.d.ts +46 -0
  38. package/dist/SyncStatusBanner.js +29 -0
  39. package/dist/SyncStatusBanner.js.map +1 -0
  40. package/dist/Theme.d.ts +1 -1
  41. package/dist/Toast.d.ts +9 -1
  42. package/dist/Toast.js +20 -7
  43. package/dist/Toast.js.map +1 -1
  44. package/dist/ToastNotifications.js +23 -1
  45. package/dist/ToastNotifications.js.map +1 -1
  46. package/dist/UnifiedAddressAutoComplete.d.ts +1 -1
  47. package/dist/Unifier.js +1 -1
  48. package/dist/Unifier.js.map +1 -1
  49. package/dist/conflictFieldDiff.d.ts +14 -0
  50. package/dist/conflictFieldDiff.js +62 -0
  51. package/dist/conflictFieldDiff.js.map +1 -0
  52. package/dist/icons/OfflineIcon.d.ts +1 -1
  53. package/dist/icons/OnlineIcon.d.ts +1 -1
  54. package/dist/icons/OutOfficeIcon.d.ts +1 -1
  55. package/dist/index.d.ts +5 -2
  56. package/dist/index.js +5 -2
  57. package/dist/index.js.map +1 -1
  58. package/dist/pdfHtmlTemplate.d.ts +30 -0
  59. package/dist/pdfHtmlTemplate.js +170 -0
  60. package/dist/pdfHtmlTemplate.js.map +1 -0
  61. package/dist/table/TableTitle.js +1 -3
  62. package/dist/table/TableTitle.js.map +1 -1
  63. package/dist/useAppLaunchOrForeground.d.ts +9 -0
  64. package/dist/useAppLaunchOrForeground.js +27 -0
  65. package/dist/useAppLaunchOrForeground.js.map +1 -0
  66. package/package.json +44 -37
  67. package/src/ActionSheet.test.tsx +123 -136
  68. package/src/Box.test.tsx +68 -30
  69. package/src/Box.tsx +46 -7
  70. package/src/Common.ts +21 -3
  71. package/src/ConflictSheet.test.tsx +461 -0
  72. package/src/ConflictSheet.tsx +399 -0
  73. package/src/ConsentFormScreen.test.tsx +22 -0
  74. package/src/DateTimeField.test.tsx +14 -0
  75. package/src/DateTimeField.tsx +5 -19
  76. package/src/Hyperlink.tsx +1 -1
  77. package/src/Page.tsx +2 -3
  78. package/src/SidebarNavigation.native.tsx +1 -1
  79. package/src/SidebarNavigation.tsx +1 -1
  80. package/src/SyncStatusBanner.test.tsx +204 -0
  81. package/src/SyncStatusBanner.tsx +148 -0
  82. package/src/TerrenoProvider.test.tsx +3 -4
  83. package/src/Toast.test.tsx +60 -0
  84. package/src/Toast.tsx +46 -1
  85. package/src/ToastNotifications.test.tsx +82 -0
  86. package/src/ToastNotifications.tsx +25 -1
  87. package/src/Unifier.ts +1 -1
  88. package/src/WebDropdownMenu.test.tsx +128 -0
  89. package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +0 -3
  90. package/src/__snapshots__/Body.test.tsx.snap +0 -16
  91. package/src/__snapshots__/Box.test.tsx.snap +4 -13
  92. package/src/__snapshots__/Page.test.tsx.snap +0 -84
  93. package/src/__snapshots__/SplitPage.test.tsx.snap +24 -120
  94. package/src/__snapshots__/TapToEdit.test.tsx.snap +5 -16
  95. package/src/__snapshots__/Toast.test.tsx.snap +4 -2
  96. package/src/bunSetup.ts +19 -0
  97. package/src/conflictFieldDiff.test.ts +26 -0
  98. package/src/conflictFieldDiff.ts +78 -0
  99. package/src/index.tsx +5 -2
  100. package/src/login/__snapshots__/LoginScreen.test.tsx.snap +0 -9
  101. package/src/pdfHtmlTemplate.ts +219 -0
  102. package/src/signUp/__snapshots__/OAuthButtons.test.tsx.snap +0 -1
  103. package/src/signUp/__snapshots__/PasswordRequirements.test.tsx.snap +2 -16
  104. package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +1 -17
  105. package/src/signUp/__snapshots__/Swiper.test.tsx.snap +0 -1
  106. package/src/table/__snapshots__/Table.test.tsx.snap +22 -87
  107. package/src/table/__snapshots__/TableHeader.test.tsx.snap +10 -50
  108. package/src/table/__snapshots__/TableHeaderCell.test.tsx.snap +10 -84
  109. package/src/table/__snapshots__/TableRow.test.tsx.snap +12 -77
  110. package/src/useAppLaunchOrForeground.test.tsx +54 -0
  111. package/src/useAppLaunchOrForeground.ts +30 -0
  112. package/dist/ConsentHistory.d.ts +0 -9
  113. package/dist/ConsentHistory.js +0 -70
  114. package/dist/ConsentHistory.js.map +0 -1
  115. package/dist/generateConsentHistoryPdf.d.ts +0 -2
  116. package/dist/generateConsentHistoryPdf.js +0 -185
  117. package/dist/generateConsentHistoryPdf.js.map +0 -1
  118. package/dist/useConsentHistory.d.ts +0 -63
  119. package/dist/useConsentHistory.js +0 -40
  120. package/dist/useConsentHistory.js.map +0 -1
  121. package/src/ConsentHistory.test.tsx +0 -224
  122. package/src/ConsentHistory.tsx +0 -249
  123. package/src/generateConsentHistoryPdf.test.ts +0 -253
  124. package/src/generateConsentHistoryPdf.ts +0 -211
  125. package/src/useConsentHistory.test.ts +0 -106
  126. package/src/useConsentHistory.ts +0 -94
@@ -1,106 +0,0 @@
1
- import {describe, expect, it, mock} from "bun:test";
2
- import {renderHook} from "@testing-library/react-native";
3
-
4
- import type {ConsentHistoryEntry} from "./useConsentHistory";
5
- import {useConsentHistory} from "./useConsentHistory";
6
-
7
- type ConsentHistoryApi = Parameters<typeof useConsentHistory>[0];
8
-
9
- interface MockQueryDef {
10
- query: () => string;
11
- providesTags: string[];
12
- }
13
-
14
- interface MockInjectOpts {
15
- endpoints: (build: {query: (def: MockQueryDef) => string}) => Record<string, unknown>;
16
- }
17
-
18
- describe("useConsentHistory", () => {
19
- const buildApi = (queryResult: {data?: unknown; error?: unknown; isLoading?: boolean}) => {
20
- const refetch = mock(() => {});
21
- const useGetMyConsentsQuery = mock(() => ({
22
- data: queryResult.data,
23
- error: queryResult.error,
24
- isLoading: queryResult.isLoading ?? false,
25
- refetch,
26
- }));
27
- const api = {
28
- enhanceEndpoints: mock((opts: {addTagTypes: string[]}) => {
29
- expect(opts.addTagTypes).toContain("MyConsents");
30
- return {
31
- injectEndpoints: mock((injectOpts: MockInjectOpts) => {
32
- const build = {
33
- query: mock((def: MockQueryDef) => {
34
- // Exercise the URL builder so the closure captures `base`
35
- const url = def.query();
36
- expect(url).toContain("/consents/my");
37
- return "my-consents-query";
38
- }),
39
- };
40
- injectOpts.endpoints(build);
41
- return {useGetMyConsentsQuery};
42
- }),
43
- };
44
- }),
45
- };
46
- return {api, refetch};
47
- };
48
-
49
- it("returns an array of entries when response is an array", () => {
50
- const {api} = buildApi({
51
- data: [{_id: "1", agreed: true} as unknown as ConsentHistoryEntry],
52
- });
53
- const {result} = renderHook(() => useConsentHistory(api as unknown as ConsentHistoryApi));
54
- expect(Array.isArray(result.current.entries)).toBe(true);
55
- expect(result.current.entries).toHaveLength(1);
56
- });
57
-
58
- it("unwraps .data property when response is object shape", () => {
59
- const {api} = buildApi({
60
- data: {data: [{_id: "2", agreed: false} as unknown as ConsentHistoryEntry]},
61
- });
62
- const {result} = renderHook(() =>
63
- useConsentHistory(api as unknown as ConsentHistoryApi, "/api")
64
- );
65
- expect(Array.isArray(result.current.entries)).toBe(true);
66
- expect(result.current.entries).toHaveLength(1);
67
- });
68
-
69
- it("returns empty array when no data is present", () => {
70
- const {api} = buildApi({data: undefined, isLoading: true});
71
- const {result} = renderHook(() => useConsentHistory(api as unknown as ConsentHistoryApi));
72
- expect(result.current.entries).toEqual([]);
73
- expect(result.current.isLoading).toBe(true);
74
- });
75
-
76
- it("surfaces error from the query hook", () => {
77
- const {api} = buildApi({data: undefined, error: "boom"});
78
- const {result} = renderHook(() => useConsentHistory(api as unknown as ConsentHistoryApi));
79
- expect(result.current.error).toBe("boom");
80
- });
81
-
82
- it("injects the my-consents endpoint only once per (api, baseUrl)", () => {
83
- let injectCallCount = 0;
84
- const refetch = mock(() => {});
85
- const useGetMyConsentsQuery = mock(() => ({
86
- data: undefined,
87
- error: undefined,
88
- isLoading: false,
89
- refetch,
90
- }));
91
- const api = {
92
- enhanceEndpoints: () => ({
93
- injectEndpoints: () => {
94
- injectCallCount += 1;
95
- return {useGetMyConsentsQuery};
96
- },
97
- }),
98
- };
99
- const {rerender} = renderHook(() => useConsentHistory(api as unknown as ConsentHistoryApi));
100
- rerender(undefined);
101
- rerender(undefined);
102
- // The hook reuses the cached enhanced api after the first render so the
103
- // dev-mode RTK warning about re-injecting endpoints never fires.
104
- expect(injectCallCount).toBe(1);
105
- });
106
- });
@@ -1,94 +0,0 @@
1
- export interface ConsentHistoryEntry {
2
- _id: string;
3
- agreed: boolean;
4
- agreedAt: string;
5
- checkboxValues?: Record<string, boolean>;
6
- contentSnapshot?: string;
7
- form: {
8
- captureSignature: boolean;
9
- checkboxes: Array<{label: string; required: boolean; confirmationPrompt?: string}>;
10
- slug: string;
11
- title: string;
12
- type: string;
13
- version: number;
14
- } | null;
15
- formVersionSnapshot?: number;
16
- ipAddress?: string;
17
- locale?: string;
18
- signature?: string;
19
- signedAt?: string;
20
- userAgent?: string;
21
- }
22
-
23
- interface ConsentHistoryResponse {
24
- data?: ConsentHistoryEntry[];
25
- }
26
-
27
- interface ConsentHistoryQueryBuilder {
28
- query: (options: {providesTags: string[]; query: () => string}) => unknown;
29
- }
30
-
31
- interface ConsentHistoryHookState {
32
- data?: ConsentHistoryEntry[] | ConsentHistoryResponse;
33
- error: unknown;
34
- isLoading: boolean;
35
- refetch: () => void | Promise<void>;
36
- }
37
-
38
- interface ConsentHistoryEnhancedApi {
39
- useGetMyConsentsQuery: () => ConsentHistoryHookState;
40
- }
41
-
42
- interface ConsentHistoryApiWithTags {
43
- injectEndpoints: (options: {
44
- endpoints: (build: ConsentHistoryQueryBuilder) => {getMyConsents: unknown};
45
- overrideExisting: boolean;
46
- }) => ConsentHistoryEnhancedApi;
47
- }
48
-
49
- interface ConsentHistoryApi {
50
- enhanceEndpoints: (options: {addTagTypes: string[]}) => ConsentHistoryApiWithTags;
51
- }
52
-
53
- /**
54
- * Cache the enhanced api per (api, baseUrl). `injectEndpoints` logs a console
55
- * error in development whenever an endpoint with the same name is re-injected
56
- * (with `overrideExisting: false`), so calling it on every render of every
57
- * consumer would flood the console. WeakMap-by-api lets the GC reclaim entries
58
- * when the api object is unreachable.
59
- */
60
- const enhancedApiCache = new WeakMap<ConsentHistoryApi, Map<string, ConsentHistoryEnhancedApi>>();
61
-
62
- const getEnhancedApi = (api: ConsentHistoryApi, base: string): ConsentHistoryEnhancedApi => {
63
- let byBase = enhancedApiCache.get(api);
64
- if (!byBase) {
65
- byBase = new Map();
66
- enhancedApiCache.set(api, byBase);
67
- }
68
- const cached = byBase.get(base);
69
- if (cached) {
70
- return cached;
71
- }
72
- const apiWithConsentTags = api.enhanceEndpoints({addTagTypes: ["MyConsents"]});
73
- const enhanced = apiWithConsentTags.injectEndpoints({
74
- endpoints: (build) => ({
75
- getMyConsents: build.query({
76
- providesTags: ["MyConsents"],
77
- query: () => `${base}/consents/my`,
78
- }),
79
- }),
80
- overrideExisting: false,
81
- });
82
- byBase.set(base, enhanced);
83
- return enhanced;
84
- };
85
-
86
- export const useConsentHistory = (api: ConsentHistoryApi, baseUrl?: string) => {
87
- const base = baseUrl || "";
88
- const enhancedApi = getEnhancedApi(api, base);
89
-
90
- const {data, isLoading, error, refetch} = enhancedApi.useGetMyConsentsQuery();
91
- const entries: ConsentHistoryEntry[] = Array.isArray(data) ? data : (data?.data ?? []);
92
-
93
- return {entries, error, isLoading, refetch};
94
- };