@elevasis/ui 2.36.0 → 2.38.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 (95) hide show
  1. package/dist/api/index.js +4 -3
  2. package/dist/app/index.css +0 -384
  3. package/dist/app/index.d.ts +75 -2
  4. package/dist/app/index.js +22 -21
  5. package/dist/auth/index.d.ts +91 -28
  6. package/dist/auth/index.js +5 -1
  7. package/dist/charts/index.js +9 -3
  8. package/dist/chunk-4O3VAALW.js +349 -0
  9. package/dist/{chunk-O2Q4VMRN.js → chunk-566XWGPP.js} +76 -109
  10. package/dist/chunk-5EYJ2GIN.js +122 -0
  11. package/dist/chunk-6D4LCJ52.js +10 -0
  12. package/dist/chunk-6ROXVZ3L.js +9 -0
  13. package/dist/{chunk-YYX7OPZQ.js → chunk-73EWE2EW.js} +1 -1
  14. package/dist/{chunk-SIQ3P4OR.js → chunk-7GQFIWP4.js} +8 -756
  15. package/dist/{chunk-VKIZUUPM.js → chunk-7YXZFS56.js} +31 -14
  16. package/dist/{chunk-AKW7KISS.js → chunk-7ZWXTH5J.js} +2 -44
  17. package/dist/chunk-A7IG36LB.js +215 -0
  18. package/dist/chunk-B2DZLPDL.js +39 -0
  19. package/dist/chunk-C6BDBZRO.js +422 -0
  20. package/dist/chunk-CLDCYJQT.js +1 -0
  21. package/dist/{chunk-LUYVRATI.js → chunk-DA6I5VEY.js} +5 -213
  22. package/dist/chunk-H2MEFUQD.js +337 -0
  23. package/dist/chunk-I53EX4VU.js +734 -0
  24. package/dist/chunk-IIMU5YAJ.js +53 -0
  25. package/dist/chunk-JXVNHVK7.js +79 -0
  26. package/dist/chunk-M7Q4UBRY.js +85 -0
  27. package/dist/{chunk-K4UZU3TU.js → chunk-P34FFSOX.js} +1 -1
  28. package/dist/chunk-PGWANFNE.js +112 -0
  29. package/dist/{chunk-F6EFC2MJ.js → chunk-Q64E2TZY.js} +440 -2075
  30. package/dist/chunk-S3XR4II4.js +30 -0
  31. package/dist/chunk-SHZT7ULK.js +425 -0
  32. package/dist/{chunk-GX6XBRRF.js → chunk-TYRUKGGD.js} +2 -1
  33. package/dist/{chunk-R3VCBZDC.js → chunk-X4WBGKJQ.js} +3 -50
  34. package/dist/{chunk-GEFWMU26.js → chunk-X66MVMZT.js} +1 -9
  35. package/dist/{chunk-57OZ3AEG.js → chunk-Y3JQBSKQ.js} +1 -1
  36. package/dist/components/index.d.ts +74 -42
  37. package/dist/components/index.js +34 -19
  38. package/dist/components/navigation/index.js +3 -31
  39. package/dist/features/auth/index.d.ts +97 -99
  40. package/dist/features/auth/index.js +37 -99
  41. package/dist/features/clients/index.js +34 -19
  42. package/dist/features/crm/index.d.ts +65 -0
  43. package/dist/features/crm/index.js +34 -19
  44. package/dist/features/dashboard/index.js +34 -19
  45. package/dist/features/delivery/index.d.ts +65 -0
  46. package/dist/features/delivery/index.js +34 -19
  47. package/dist/features/knowledge/index.js +6 -30
  48. package/dist/features/lead-gen/index.d.ts +1096 -1
  49. package/dist/features/lead-gen/index.js +34 -19
  50. package/dist/features/monitoring/index.js +34 -19
  51. package/dist/features/monitoring/requests/index.js +34 -19
  52. package/dist/features/notes/index.d.ts +72 -0
  53. package/dist/features/notes/index.js +621 -0
  54. package/dist/features/operations/index.d.ts +10 -2
  55. package/dist/features/operations/index.js +34 -19
  56. package/dist/features/right-panel-host/index.d.ts +214 -0
  57. package/dist/features/right-panel-host/index.js +639 -0
  58. package/dist/features/seo/index.js +3 -2
  59. package/dist/features/settings/index.d.ts +68 -35
  60. package/dist/features/settings/index.js +34 -19
  61. package/dist/hooks/access/index.d.ts +90 -0
  62. package/dist/hooks/access/index.js +10 -0
  63. package/dist/hooks/delivery/index.d.ts +65 -0
  64. package/dist/hooks/delivery/index.js +34 -19
  65. package/dist/hooks/index.d.ts +1644 -1651
  66. package/dist/hooks/index.js +34 -19
  67. package/dist/hooks/published.d.ts +1644 -1651
  68. package/dist/hooks/published.js +34 -19
  69. package/dist/hooks/user-notes/index.d.ts +57 -0
  70. package/dist/hooks/user-notes/index.js +3 -0
  71. package/dist/index.d.ts +294 -277
  72. package/dist/index.js +35 -20
  73. package/dist/initialization/index.d.ts +65 -19
  74. package/dist/knowledge/index.d.ts +10 -2
  75. package/dist/knowledge/index.js +173 -28
  76. package/dist/layout/index.js +5 -3
  77. package/dist/organization/index.d.ts +0 -19
  78. package/dist/organization/index.js +34 -19
  79. package/dist/profile/index.d.ts +65 -0
  80. package/dist/provider/index.css +0 -384
  81. package/dist/provider/index.d.ts +75 -2
  82. package/dist/provider/index.js +16 -21
  83. package/dist/provider/published.css +0 -523
  84. package/dist/provider/published.d.ts +75 -2
  85. package/dist/provider/published.js +11 -21
  86. package/dist/supabase/index.d.ts +127 -0
  87. package/dist/test-utils/index.d.ts +2 -21
  88. package/dist/test-utils/index.js +5 -18
  89. package/dist/theme/index.js +3 -1
  90. package/dist/types/index.d.ts +115 -59
  91. package/dist/utils/index.js +2 -1
  92. package/package.json +21 -5
  93. package/src/auth/README.md +6 -6
  94. package/dist/components/navigation/index.css +0 -649
  95. package/dist/features/knowledge/index.css +0 -649
@@ -0,0 +1,337 @@
1
+ import { FeatureUnavailableState } from './chunk-I53EX4VU.js';
2
+ import { SubshellContainer, SubshellSidebar, SubshellRightSideContainer } from './chunk-A7IG36LB.js';
3
+ import { ApiClientProvider, useApiClient } from './chunk-Y3JQBSKQ.js';
4
+ import { useRouterContext } from './chunk-Q7DJKLEN.js';
5
+ import { getErrorInfo, getErrorTitle, formatErrorMessage } from './chunk-X66MVMZT.js';
6
+ import { useElevasisSystems } from './chunk-C6BDBZRO.js';
7
+ import { InitializationProvider } from './chunk-533DUEQY.js';
8
+ import { OrganizationContext, useOrganization } from './chunk-DD3CCMCZ.js';
9
+ import { useProfile, ProfileProvider } from './chunk-2Q2JQSQO.js';
10
+ import { ElevasisServiceProvider } from './chunk-KJ3QUBNU.js';
11
+ import { useAuthContext } from './chunk-BRJ3QZ4E.js';
12
+ import { createContext, lazy, useState, useRef, useEffect, useCallback, createElement, useContext, Suspense } from 'react';
13
+ import { useQueryClient, QueryClientProvider, QueryClient } from '@tanstack/react-query';
14
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
15
+
16
+ function OrganizationProvider({ apiRequest, children }) {
17
+ const { user, organizationId: workosOrgId } = useAuthContext();
18
+ const { profile, error: profileError } = useProfile();
19
+ const queryClient = useQueryClient();
20
+ const [memberships, setMemberships] = useState([]);
21
+ const [currentWorkOSOrganizationId, setCurrentWorkOSOrganizationId] = useState(null);
22
+ const [currentSupabaseOrganizationId, setCurrentSupabaseOrganizationId] = useState(null);
23
+ const [currentMembership, setCurrentMembership] = useState(null);
24
+ const [isInitializing, setIsInitializing] = useState(true);
25
+ const [isOrgRefreshing, setIsOrgRefreshing] = useState(false);
26
+ const [error, setError] = useState(null);
27
+ const hasInitializedRef = useRef(false);
28
+ const [profileLoaded, setProfileLoaded] = useState(false);
29
+ useEffect(() => {
30
+ if (profile !== void 0 && profile !== null) {
31
+ setProfileLoaded(true);
32
+ }
33
+ }, [profile]);
34
+ useEffect(() => {
35
+ if (profileError && isInitializing && !hasInitializedRef.current) {
36
+ setIsInitializing(false);
37
+ }
38
+ }, [profileError, isInitializing]);
39
+ useEffect(() => {
40
+ if (!user) {
41
+ setMemberships([]);
42
+ setCurrentWorkOSOrganizationId(null);
43
+ setCurrentSupabaseOrganizationId(null);
44
+ setCurrentMembership(null);
45
+ setIsInitializing(false);
46
+ setIsOrgRefreshing(false);
47
+ setError(null);
48
+ hasInitializedRef.current = false;
49
+ setProfileLoaded(false);
50
+ }
51
+ }, [user]);
52
+ const applyMembership = useCallback((membership) => {
53
+ setCurrentMembership(membership);
54
+ setCurrentSupabaseOrganizationId(membership?.organization?.id ?? null);
55
+ setCurrentWorkOSOrganizationId(membership?.organization?.workos_org_id ?? null);
56
+ }, []);
57
+ const selectOrganization = useCallback(
58
+ (data) => {
59
+ let selected = null;
60
+ if (profile?.last_visited_org) {
61
+ selected = data.find((m) => m.organizationId === profile.last_visited_org) ?? null;
62
+ }
63
+ if (!selected && workosOrgId) {
64
+ selected = data.find((m) => m.organization?.workos_org_id === workosOrgId) ?? null;
65
+ }
66
+ if (!selected && data.length > 0) {
67
+ selected = data[0];
68
+ }
69
+ if (selected) {
70
+ applyMembership(selected);
71
+ }
72
+ },
73
+ [profile?.last_visited_org, workosOrgId, applyMembership]
74
+ );
75
+ const fetchAndInitialize = useCallback(async () => {
76
+ if (!user?.id || !profileLoaded) return;
77
+ setError(null);
78
+ if (memberships.length === 0) {
79
+ setIsInitializing(true);
80
+ } else {
81
+ setIsOrgRefreshing(true);
82
+ }
83
+ try {
84
+ const data = await apiRequest("/memberships/my-memberships");
85
+ if (!Array.isArray(data)) {
86
+ throw new Error("Invalid memberships response");
87
+ }
88
+ setMemberships(data);
89
+ if (data.length === 0) {
90
+ hasInitializedRef.current = true;
91
+ return;
92
+ }
93
+ if (!currentWorkOSOrganizationId) {
94
+ selectOrganization(data);
95
+ } else {
96
+ const stillPresent = data.find((m) => m.organization?.workos_org_id === currentWorkOSOrganizationId);
97
+ if (!stillPresent) {
98
+ applyMembership(data[0] ?? null);
99
+ } else {
100
+ applyMembership(stillPresent);
101
+ }
102
+ }
103
+ hasInitializedRef.current = true;
104
+ } catch (err) {
105
+ setError(err instanceof Error ? err.message : "Failed to load organizations");
106
+ } finally {
107
+ setIsInitializing(false);
108
+ setIsOrgRefreshing(false);
109
+ }
110
+ }, [
111
+ user?.id,
112
+ profileLoaded,
113
+ memberships.length,
114
+ apiRequest,
115
+ currentWorkOSOrganizationId,
116
+ selectOrganization,
117
+ applyMembership
118
+ ]);
119
+ useEffect(() => {
120
+ if (!user?.id || !profileLoaded || hasInitializedRef.current) return;
121
+ fetchAndInitialize();
122
+ }, [user?.id, profileLoaded, fetchAndInitialize]);
123
+ useEffect(() => {
124
+ if (!hasInitializedRef.current) return;
125
+ if (!workosOrgId) return;
126
+ if (workosOrgId === currentWorkOSOrganizationId) return;
127
+ const target = memberships.find((m) => m.organization?.workos_org_id === workosOrgId);
128
+ if (!target) return;
129
+ applyMembership(target);
130
+ void queryClient.invalidateQueries();
131
+ }, [workosOrgId, currentWorkOSOrganizationId, memberships, applyMembership, queryClient]);
132
+ const switchOrganization = useCallback(
133
+ (workosOrgId2) => {
134
+ const target = memberships.find((m) => m.organization?.workos_org_id === workosOrgId2);
135
+ if (!target) return;
136
+ applyMembership(target);
137
+ void queryClient.invalidateQueries();
138
+ void apiRequest("/users/me", {
139
+ method: "PATCH",
140
+ headers: { "Content-Type": "application/json" },
141
+ body: JSON.stringify({ last_visited_org: target.organizationId })
142
+ }).catch((err) => {
143
+ console.warn("Failed to persist last_visited_org preference:", err);
144
+ });
145
+ },
146
+ [memberships, applyMembership, queryClient, apiRequest]
147
+ );
148
+ const retry = useCallback(async () => {
149
+ hasInitializedRef.current = false;
150
+ setError(null);
151
+ await fetchAndInitialize();
152
+ }, [fetchAndInitialize]);
153
+ const value = {
154
+ currentWorkOSOrganizationId,
155
+ currentSupabaseOrganizationId,
156
+ currentMembership,
157
+ memberships,
158
+ isInitializing,
159
+ isOrgRefreshing,
160
+ error,
161
+ switchOrganization,
162
+ retry
163
+ };
164
+ return createElement(OrganizationContext.Provider, { value }, children);
165
+ }
166
+ var consoleAdapter = {
167
+ success(title, message) {
168
+ console.log(`[Notification][Success] ${title}: ${message}`);
169
+ },
170
+ error(title, message) {
171
+ console.warn(`[Notification][Error] ${title}: ${message}`);
172
+ },
173
+ info(title, message) {
174
+ console.log(`[Notification][Info] ${title}: ${message}`);
175
+ },
176
+ warning(title, message) {
177
+ console.warn(`[Notification][Warning] ${title}: ${message}`);
178
+ },
179
+ apiError(error) {
180
+ const { message, code, requestId, fields, retryAfter } = getErrorInfo(error);
181
+ const title = getErrorTitle(code);
182
+ const formatted = formatErrorMessage(message, requestId, fields, retryAfter);
183
+ console.warn(`[Notification][API Error] ${title}: ${formatted}`);
184
+ }
185
+ };
186
+ var NotificationContext = createContext(consoleAdapter);
187
+ function NotificationProvider({ adapter, children }) {
188
+ return /* @__PURE__ */ jsx(NotificationContext.Provider, { value: adapter, children });
189
+ }
190
+ function useNotificationAdapter() {
191
+ return useContext(NotificationContext);
192
+ }
193
+ var CrmActionsContext = createContext([]);
194
+ function CrmActionsProvider({ actions, children }) {
195
+ return /* @__PURE__ */ jsx(CrmActionsContext.Provider, { value: actions, children });
196
+ }
197
+ function useCrmActions() {
198
+ return useContext(CrmActionsContext);
199
+ }
200
+ var EMPTY_LIST_ACTIONS = Object.freeze([]);
201
+ var ListActionsContext = createContext(EMPTY_LIST_ACTIONS);
202
+ function ListActionsProvider({
203
+ registry = EMPTY_LIST_ACTIONS,
204
+ children
205
+ }) {
206
+ return /* @__PURE__ */ jsx(ListActionsContext.Provider, { value: registry, children });
207
+ }
208
+ function useListActions() {
209
+ return useContext(ListActionsContext);
210
+ }
211
+ function findListActionByAction(registry, actionKey) {
212
+ return registry.find((action) => action.actionKey === actionKey);
213
+ }
214
+ function getListActionWorkflowId(action) {
215
+ return action.workflowId ?? action.resourceId;
216
+ }
217
+ var LazyCoreAuthKitInner = lazy(() => import('./CoreAuthKitInner-QC62UHTZ.js').then((m) => ({ default: m.CoreAuthKitInner })));
218
+ var defaultQueryClient = null;
219
+ function getDefaultQueryClient() {
220
+ if (!defaultQueryClient) {
221
+ defaultQueryClient = new QueryClient({
222
+ defaultOptions: { queries: { retry: 1 } }
223
+ });
224
+ }
225
+ return defaultQueryClient;
226
+ }
227
+ var consoleNotificationAdapter = {
228
+ success(title, message) {
229
+ console.log(`[Notification][Success] ${title}: ${message}`);
230
+ },
231
+ error(title, message) {
232
+ console.warn(`[Notification][Error] ${title}: ${message}`);
233
+ },
234
+ info(title, message) {
235
+ console.log(`[Notification][Info] ${title}: ${message}`);
236
+ },
237
+ warning(title, message) {
238
+ console.warn(`[Notification][Warning] ${title}: ${message}`);
239
+ },
240
+ apiError(error) {
241
+ console.warn(`[Notification][API Error]`, error);
242
+ }
243
+ };
244
+ function ElevasisCoreProvider({
245
+ auth,
246
+ queryClient,
247
+ apiUrl,
248
+ onError,
249
+ notifications,
250
+ crmActions,
251
+ listActions,
252
+ children
253
+ }) {
254
+ if (auth.mode === "apiKey") {
255
+ throw new Error(
256
+ `ElevasisCoreProvider: auth mode 'apiKey' is not yet implemented. Only 'authkit' mode is supported.`
257
+ );
258
+ }
259
+ const resolvedQueryClient = queryClient ?? getDefaultQueryClient();
260
+ const resolvedCrmActions = crmActions ?? [];
261
+ const resolvedListActions = listActions ?? EMPTY_LIST_ACTIONS;
262
+ const content = apiUrl ? /* @__PURE__ */ jsx(ServiceStack, { apiUrl, onError, notifications, children }) : children;
263
+ const AuthInner = /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(LazyCoreAuthKitInner, { auth, children: content }) });
264
+ return /* @__PURE__ */ jsx(QueryClientProvider, { client: resolvedQueryClient, children: /* @__PURE__ */ jsx(CrmActionsProvider, { actions: resolvedCrmActions, children: /* @__PURE__ */ jsx(ListActionsProvider, { registry: resolvedListActions, children: AuthInner }) }) });
265
+ }
266
+ function ServiceStack({
267
+ apiUrl,
268
+ onError,
269
+ notifications,
270
+ children
271
+ }) {
272
+ const { getAccessToken } = useAuthContext();
273
+ const orgIdRef = useRef(null);
274
+ const getOrganizationId = useRef(() => orgIdRef.current).current;
275
+ return /* @__PURE__ */ jsx(
276
+ ApiClientProvider,
277
+ {
278
+ getAccessToken,
279
+ getOrganizationId,
280
+ isOrganizationReady: false,
281
+ onError,
282
+ children: /* @__PURE__ */ jsx(ServiceStackInner, { apiUrl, orgIdRef, notifications, children })
283
+ }
284
+ );
285
+ }
286
+ function ServiceStackInner({
287
+ apiUrl,
288
+ orgIdRef,
289
+ notifications,
290
+ children
291
+ }) {
292
+ const { apiRequest } = useApiClient(apiUrl);
293
+ const resolvedNotifications = notifications ?? consoleNotificationAdapter;
294
+ return /* @__PURE__ */ jsx(ProfileProvider, { apiRequest, children: /* @__PURE__ */ jsx(OrganizationProvider, { apiRequest, children: /* @__PURE__ */ jsx(OrgServiceBridge, { orgIdRef, apiRequest, notifications: resolvedNotifications, children }) }) });
295
+ }
296
+ function OrgServiceBridge({
297
+ orgIdRef,
298
+ apiRequest,
299
+ notifications,
300
+ children
301
+ }) {
302
+ const { currentWorkOSOrganizationId, isInitializing, isOrgRefreshing } = useOrganization();
303
+ orgIdRef.current = currentWorkOSOrganizationId;
304
+ const isReady = !!currentWorkOSOrganizationId && !isInitializing && !isOrgRefreshing;
305
+ return /* @__PURE__ */ jsx(
306
+ ElevasisServiceProvider,
307
+ {
308
+ apiRequest,
309
+ workOSOrganizationId: currentWorkOSOrganizationId,
310
+ isReady,
311
+ children: /* @__PURE__ */ jsx(NotificationProvider, { adapter: notifications, children: /* @__PURE__ */ jsx(InitializationProvider, { children }) })
312
+ }
313
+ );
314
+ }
315
+ var defaultSystemSidebarWidth = 250;
316
+ function SystemShell({ children }) {
317
+ const { shellRuntime } = useElevasisSystems();
318
+ const { currentPath } = useRouterContext();
319
+ const routeMatch = shellRuntime.resolveRoute(currentPath);
320
+ if (routeMatch.status === "hidden") {
321
+ return /* @__PURE__ */ jsx(FeatureUnavailableState, { path: currentPath });
322
+ }
323
+ if (routeMatch.status !== "matched" || !routeMatch.system?.sidebar) {
324
+ return /* @__PURE__ */ jsx(Fragment, { children });
325
+ }
326
+ const SidebarComponent = routeMatch.system.sidebar;
327
+ const sidebarWidth = typeof routeMatch.system.sidebarWidth === "function" ? routeMatch.system.sidebarWidth({ currentPath }) : routeMatch.system.sidebarWidth ?? defaultSystemSidebarWidth;
328
+ if (sidebarWidth === 0) {
329
+ return /* @__PURE__ */ jsx(Fragment, { children });
330
+ }
331
+ return /* @__PURE__ */ jsxs(SubshellContainer, { children: [
332
+ /* @__PURE__ */ jsx(SubshellSidebar, { width: sidebarWidth, children: /* @__PURE__ */ jsx(SidebarComponent, {}) }),
333
+ /* @__PURE__ */ jsx(SubshellRightSideContainer, { children })
334
+ ] });
335
+ }
336
+
337
+ export { CrmActionsProvider, EMPTY_LIST_ACTIONS, ElevasisCoreProvider, ListActionsProvider, NotificationProvider, OrganizationProvider, SystemShell, findListActionByAction, getListActionWorkflowId, useCrmActions, useListActions, useNotificationAdapter };