@elevasis/ui 1.2.0 → 1.3.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.
- package/dist/api/hooks/useApiClient.d.ts +54 -0
- package/dist/api/hooks/useApiClient.d.ts.map +1 -0
- package/dist/api/hooks/useApiClient.js +185 -0
- package/dist/api/index.d.ts +49 -11
- package/dist/api/index.js +3 -2
- package/dist/auth/index.d.ts +88 -2
- package/dist/auth/index.js +6 -2
- package/dist/{chunk-5UWFGBFM.js → chunk-4KAG5U7A.js} +18 -4
- package/dist/chunk-4VGWQ5AN.js +91 -0
- package/dist/{chunk-JKERRYVS.js → chunk-BLO4SISK.js} +7 -3
- package/dist/chunk-BWCC6ZJC.js +202 -0
- package/dist/{chunk-WNWKOCGJ.js → chunk-BZTA7IIL.js} +1 -1
- package/dist/chunk-DD3CCMCZ.js +15 -0
- package/dist/{chunk-GEFB5YIR.js → chunk-EZMRFWZQ.js} +1 -1
- package/dist/chunk-FDCVFCOQ.js +105 -0
- package/dist/chunk-FLJXZ7YC.js +150 -0
- package/dist/{chunk-7AI5ZYJ4.js → chunk-JVAZHVNV.js} +2 -94
- package/dist/{chunk-ZGHDPDTF.js → chunk-JYSYHVLU.js} +3 -3
- package/dist/{chunk-J3FALDQE.js → chunk-NXHL23JW.js} +7 -13
- package/dist/{chunk-OUHGHTE7.js → chunk-O3PY6B6E.js} +3 -2
- package/dist/chunk-OLD3NQLI.js +91 -0
- package/dist/{chunk-XVPEDNIM.js → chunk-PCBXNHKY.js} +325 -152
- package/dist/chunk-QQOLC46E.js +75 -0
- package/dist/{chunk-KSG4C5DD.js → chunk-QSVZP2NU.js} +2 -1
- package/dist/chunk-RNP5R5I3.js +1 -0
- package/dist/{chunk-YULUKCS6.js → chunk-SITSZUFW.js} +1 -1
- package/dist/chunk-TIRMFDM4.js +33 -0
- package/dist/{chunk-PYL4XW6H.js → chunk-TMFCNFLW.js} +1 -1
- package/dist/{chunk-S66I2PYB.js → chunk-TN3PU2WK.js} +1 -1
- package/dist/components/command-queue/index.js +6 -4
- package/dist/components/index.js +9 -7
- package/dist/components/notifications/index.js +4 -3
- package/dist/display/index.js +3 -2
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +5 -4
- package/dist/hooks/published.d.ts +1 -1
- package/dist/hooks/published.js +4 -3
- package/dist/index.d.ts +458 -120
- package/dist/index.js +23 -17
- package/dist/initialization/index.d.ts +49 -1
- package/dist/initialization/index.js +5 -2
- package/dist/organization/index.d.ts +61 -2
- package/dist/organization/index.js +5 -2
- package/dist/profile/index.d.ts +30 -2
- package/dist/profile/index.js +2 -1
- package/dist/provider/index.d.ts +123 -30
- package/dist/provider/index.js +11 -6
- package/dist/provider/published.d.ts +96 -16
- package/dist/provider/published.js +10 -4
- package/dist/utils/index.js +2 -1
- package/package.json +17 -4
- package/dist/chunk-GDV44UWF.js +0 -138
- package/dist/chunk-HBRMWW6V.js +0 -43
- package/dist/chunk-QGEFP2EU.js +0 -399
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { OrganizationProvider } from './chunk-FLJXZ7YC.js';
|
|
2
|
+
import { ApiClientProvider, createUseApiClient } from './chunk-BWCC6ZJC.js';
|
|
3
|
+
import { NotificationProvider } from './chunk-TIRMFDM4.js';
|
|
4
|
+
import { OAuthProvider } from './chunk-QSVZP2NU.js';
|
|
5
|
+
import { InitializationProvider } from './chunk-QQOLC46E.js';
|
|
6
|
+
import { useOrganization } from './chunk-DD3CCMCZ.js';
|
|
7
|
+
import { ProfileProvider } from './chunk-4KAG5U7A.js';
|
|
8
|
+
import { ElevasisServiceProvider } from './chunk-KA7LO7U5.js';
|
|
9
|
+
import { useAuthContext } from './chunk-7PLEQFHO.js';
|
|
10
|
+
import { lazy, Suspense, useRef } from 'react';
|
|
11
|
+
import { QueryClientProvider, QueryClient } from '@tanstack/react-query';
|
|
12
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
13
|
+
|
|
14
|
+
var LazyCoreAuthKitInner = lazy(() => import('./CoreAuthKitInner-KM72EYJS.js').then((m) => ({ default: m.CoreAuthKitInner })));
|
|
15
|
+
var defaultQueryClient = null;
|
|
16
|
+
function getDefaultQueryClient() {
|
|
17
|
+
if (!defaultQueryClient) {
|
|
18
|
+
defaultQueryClient = new QueryClient({
|
|
19
|
+
defaultOptions: { queries: { retry: 1 } }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return defaultQueryClient;
|
|
23
|
+
}
|
|
24
|
+
var defaultUseOrganizations = () => ({ isInitializing: false, isOrgRefreshing: false });
|
|
25
|
+
function ElevasisCoreProvider({
|
|
26
|
+
auth,
|
|
27
|
+
queryClient,
|
|
28
|
+
apiUrl,
|
|
29
|
+
onError,
|
|
30
|
+
notifications,
|
|
31
|
+
children
|
|
32
|
+
}) {
|
|
33
|
+
if (auth.mode === "apiKey") {
|
|
34
|
+
throw new Error(
|
|
35
|
+
`ElevasisCoreProvider: auth mode 'apiKey' is not yet implemented. Only 'authkit' and 'oauth' modes are supported.`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
const resolvedQueryClient = queryClient ?? getDefaultQueryClient();
|
|
39
|
+
const content = apiUrl ? /* @__PURE__ */ jsx(CoreServiceBridge, { apiUrl, onError, notifications, children }) : children;
|
|
40
|
+
const AuthInner = auth.mode === "authkit" ? /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(LazyCoreAuthKitInner, { auth, children: content }) }) : /* @__PURE__ */ jsx(CoreOAuthInner, { auth, children: content });
|
|
41
|
+
return /* @__PURE__ */ jsx(QueryClientProvider, { client: resolvedQueryClient, children: AuthInner });
|
|
42
|
+
}
|
|
43
|
+
function CoreOAuthInner({ auth, children }) {
|
|
44
|
+
return /* @__PURE__ */ jsx(OAuthProvider, { config: auth, children });
|
|
45
|
+
}
|
|
46
|
+
function CoreServiceBridge({
|
|
47
|
+
apiUrl,
|
|
48
|
+
onError,
|
|
49
|
+
notifications,
|
|
50
|
+
children
|
|
51
|
+
}) {
|
|
52
|
+
const { getAccessToken } = useAuthContext();
|
|
53
|
+
const orgIdRef = useRef(null);
|
|
54
|
+
const getOrganizationId = useRef(() => orgIdRef.current).current;
|
|
55
|
+
return /* @__PURE__ */ jsx(
|
|
56
|
+
ApiClientProvider,
|
|
57
|
+
{
|
|
58
|
+
getAccessToken,
|
|
59
|
+
getOrganizationId,
|
|
60
|
+
isOrganizationReady: false,
|
|
61
|
+
onError,
|
|
62
|
+
children: /* @__PURE__ */ jsx(CoreServiceBridgeInner, { apiUrl, orgIdRef, notifications, children })
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
function CoreServiceBridgeInner({
|
|
67
|
+
apiUrl,
|
|
68
|
+
orgIdRef,
|
|
69
|
+
notifications,
|
|
70
|
+
children
|
|
71
|
+
}) {
|
|
72
|
+
const useApiClient = useRef(createUseApiClient(defaultUseOrganizations, apiUrl)).current;
|
|
73
|
+
const { apiRequest } = useApiClient();
|
|
74
|
+
return /* @__PURE__ */ jsx(ElevasisServiceProvider, { apiRequest, organizationId: null, isReady: false, children: /* @__PURE__ */ jsx(ProfileProvider, { children: /* @__PURE__ */ jsx(OrganizationProvider, { children: /* @__PURE__ */ jsx(OrgIdBridge, { orgIdRef, children: /* @__PURE__ */ jsx(CoreNotificationLayer, { notifications, children: /* @__PURE__ */ jsx(InitializationProvider, { children }) }) }) }) }) });
|
|
75
|
+
}
|
|
76
|
+
function OrgIdBridge({ orgIdRef, children }) {
|
|
77
|
+
const { currentWorkOSOrganizationId } = useOrganization();
|
|
78
|
+
orgIdRef.current = currentWorkOSOrganizationId;
|
|
79
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
80
|
+
}
|
|
81
|
+
function CoreNotificationLayer({
|
|
82
|
+
notifications,
|
|
83
|
+
children
|
|
84
|
+
}) {
|
|
85
|
+
if (notifications) {
|
|
86
|
+
return /* @__PURE__ */ jsx(NotificationProvider, { adapter: notifications, children });
|
|
87
|
+
}
|
|
88
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { ElevasisCoreProvider };
|
|
@@ -1,11 +1,262 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import { ElevasisCoreProvider } from './chunk-OLD3NQLI.js';
|
|
2
|
+
import { getErrorInfo, formatErrorMessage, getErrorTitle } from './chunk-4VGWQ5AN.js';
|
|
3
|
+
import { useMemo, useEffect } from 'react';
|
|
4
|
+
import { Tooltip, Text, Tabs, Table, Stack, SimpleGrid, Select, Combobox, SegmentedControl, ScrollArea, Paper, Popover, Notification, Modal, Menu, Input, HoverCard, Group, Grid, Flex, Code, Divider, Card, Button, Accordion, createTheme, mergeThemeOverrides, MantineProvider } from '@mantine/core';
|
|
5
|
+
import '@mantine/core/styles.css';
|
|
6
|
+
import '@mantine/notifications/styles.css';
|
|
7
|
+
import { notifications } from '@mantine/notifications';
|
|
7
8
|
import { jsx } from 'react/jsx-runtime';
|
|
8
9
|
|
|
10
|
+
var DEFAULT_SIZE = "sm";
|
|
11
|
+
var glassBase = {
|
|
12
|
+
backdropFilter: "var(--glass-blur)",
|
|
13
|
+
WebkitBackdropFilter: "var(--glass-blur)",
|
|
14
|
+
border: "1px solid var(--color-border)"
|
|
15
|
+
};
|
|
16
|
+
var componentThemes = {
|
|
17
|
+
Accordion: Accordion.extend({
|
|
18
|
+
styles: {
|
|
19
|
+
item: {
|
|
20
|
+
borderColor: "var(--color-border)"
|
|
21
|
+
},
|
|
22
|
+
content: {
|
|
23
|
+
backgroundColor: "var(--color-surface)"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}),
|
|
27
|
+
Button: Button.extend({
|
|
28
|
+
styles: {
|
|
29
|
+
root: {
|
|
30
|
+
transition: `all var(--duration-fast) var(--easing)`
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}),
|
|
34
|
+
Card: Card.extend({
|
|
35
|
+
defaultProps: {
|
|
36
|
+
p: DEFAULT_SIZE
|
|
37
|
+
},
|
|
38
|
+
styles: {
|
|
39
|
+
root: {
|
|
40
|
+
backgroundColor: "var(--glass-background)",
|
|
41
|
+
...glassBase,
|
|
42
|
+
boxShadow: "var(--card-shadow)"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}),
|
|
46
|
+
// Checkbox styles are in custom.css to support :checked pseudo-selector
|
|
47
|
+
Divider: Divider.extend({
|
|
48
|
+
styles: {
|
|
49
|
+
root: {
|
|
50
|
+
borderColor: "var(--color-border)"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}),
|
|
54
|
+
Code: Code.extend({
|
|
55
|
+
styles: {
|
|
56
|
+
root: {
|
|
57
|
+
backgroundColor: "var(--color-surface)",
|
|
58
|
+
border: "1px solid var(--color-border)"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}),
|
|
62
|
+
Flex: Flex.extend({
|
|
63
|
+
defaultProps: {
|
|
64
|
+
gap: DEFAULT_SIZE
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
Grid: Grid.extend({
|
|
68
|
+
defaultProps: {
|
|
69
|
+
gutter: DEFAULT_SIZE
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
Group: Group.extend({
|
|
73
|
+
defaultProps: {
|
|
74
|
+
gap: DEFAULT_SIZE
|
|
75
|
+
}
|
|
76
|
+
}),
|
|
77
|
+
HoverCard: HoverCard.extend({
|
|
78
|
+
styles: {
|
|
79
|
+
dropdown: {
|
|
80
|
+
backgroundColor: "var(--color-surface)",
|
|
81
|
+
border: "1px solid var(--color-border)",
|
|
82
|
+
boxShadow: "var(--standard-box-shadow)"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}),
|
|
86
|
+
Input: Input.extend({
|
|
87
|
+
styles: {
|
|
88
|
+
input: {
|
|
89
|
+
backgroundColor: "var(--color-surface)",
|
|
90
|
+
border: "none",
|
|
91
|
+
borderBottom: "1px solid var(--color-border)",
|
|
92
|
+
borderRadius: "0"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}),
|
|
96
|
+
Menu: Menu.extend({
|
|
97
|
+
styles: {
|
|
98
|
+
dropdown: {
|
|
99
|
+
background: "var(--color-surface)",
|
|
100
|
+
border: "1px solid var(--color-border)"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}),
|
|
104
|
+
Modal: Modal.extend({
|
|
105
|
+
styles: {
|
|
106
|
+
content: {
|
|
107
|
+
backgroundColor: "var(--color-surface)",
|
|
108
|
+
border: "1px solid var(--color-border)"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}),
|
|
112
|
+
Notification: Notification.extend({
|
|
113
|
+
styles: {
|
|
114
|
+
root: {
|
|
115
|
+
backgroundColor: "color-mix(in srgb, var(--color-surface) 90%, transparent)",
|
|
116
|
+
...glassBase
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}),
|
|
120
|
+
Popover: Popover.extend({
|
|
121
|
+
styles: {
|
|
122
|
+
dropdown: {
|
|
123
|
+
backgroundColor: "var(--color-surface)",
|
|
124
|
+
...glassBase,
|
|
125
|
+
boxShadow: "var(--standard-box-shadow)"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}),
|
|
129
|
+
Paper: Paper.extend({
|
|
130
|
+
styles: {
|
|
131
|
+
root: {
|
|
132
|
+
backgroundColor: "var(--glass-background)",
|
|
133
|
+
...glassBase,
|
|
134
|
+
boxShadow: "var(--card-shadow)",
|
|
135
|
+
padding: `var(--mantine-spacing-${DEFAULT_SIZE})`
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}),
|
|
139
|
+
ScrollArea: ScrollArea.extend({
|
|
140
|
+
defaultProps: {
|
|
141
|
+
scrollbarSize: 8
|
|
142
|
+
},
|
|
143
|
+
styles: {
|
|
144
|
+
scrollbar: {
|
|
145
|
+
background: "transparent",
|
|
146
|
+
'&[data-orientation="vertical"]': {
|
|
147
|
+
width: "8px"
|
|
148
|
+
},
|
|
149
|
+
'&[data-orientation="horizontal"]': {
|
|
150
|
+
height: "8px"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
thumb: {
|
|
154
|
+
borderRadius: "var(--mantine-radius-default)",
|
|
155
|
+
background: "color-mix(in srgb, var(--color-text-subtle) 50%, var(--color-border))",
|
|
156
|
+
"&:hover": {
|
|
157
|
+
background: "var(--color-text-subtle)"
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}),
|
|
162
|
+
SegmentedControl: SegmentedControl.extend({
|
|
163
|
+
styles: {
|
|
164
|
+
root: {
|
|
165
|
+
backgroundColor: "var(--color-surface)"
|
|
166
|
+
},
|
|
167
|
+
indicator: {
|
|
168
|
+
backgroundColor: "var(--color-surface-hover)",
|
|
169
|
+
boxShadow: "var(--standard-box-shadow)"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}),
|
|
173
|
+
Combobox: Combobox.extend({
|
|
174
|
+
styles: {
|
|
175
|
+
dropdown: {
|
|
176
|
+
backgroundColor: "red"
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}),
|
|
180
|
+
Select: Select.extend({
|
|
181
|
+
styles: {
|
|
182
|
+
dropdown: {
|
|
183
|
+
backgroundColor: "var(--color-surface)"
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}),
|
|
187
|
+
// Switch styles are in custom.css to support [data-checked] attribute selector
|
|
188
|
+
SimpleGrid: SimpleGrid.extend({
|
|
189
|
+
defaultProps: {
|
|
190
|
+
spacing: DEFAULT_SIZE,
|
|
191
|
+
verticalSpacing: DEFAULT_SIZE
|
|
192
|
+
}
|
|
193
|
+
}),
|
|
194
|
+
Stack: Stack.extend({
|
|
195
|
+
defaultProps: {
|
|
196
|
+
gap: DEFAULT_SIZE
|
|
197
|
+
}
|
|
198
|
+
}),
|
|
199
|
+
Table: Table.extend({
|
|
200
|
+
defaultProps: {
|
|
201
|
+
highlightOnHover: true
|
|
202
|
+
},
|
|
203
|
+
styles: {
|
|
204
|
+
table: {
|
|
205
|
+
"--table-border-color": "var(--color-border)",
|
|
206
|
+
"--table-highlight-on-hover-color": "var(--color-surface-hover)"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}),
|
|
210
|
+
Tabs: Tabs.extend({}),
|
|
211
|
+
Text: Text.extend({
|
|
212
|
+
styles: {
|
|
213
|
+
root: {
|
|
214
|
+
fontFamily: 'Roboto, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}),
|
|
218
|
+
// Timeline styles are in custom.css to override color-scheme-specific selectors
|
|
219
|
+
Tooltip: Tooltip.extend({
|
|
220
|
+
styles: {
|
|
221
|
+
tooltip: {
|
|
222
|
+
backgroundColor: "var(--color-surface)",
|
|
223
|
+
color: "var(--color-text)",
|
|
224
|
+
border: "1px solid var(--color-border)"
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
})
|
|
228
|
+
// Pagination styles are in custom.css to support :not([data-active]) selector
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// src/theme/MantineThemeOverride.ts
|
|
232
|
+
var mantineThemeOverride = createTheme({
|
|
233
|
+
defaultRadius: "xs",
|
|
234
|
+
fontFamily: 'Roboto, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
|
|
235
|
+
cursorType: "pointer",
|
|
236
|
+
spacing: {
|
|
237
|
+
xs: "0.5rem",
|
|
238
|
+
sm: "0.75rem",
|
|
239
|
+
md: "1rem",
|
|
240
|
+
lg: "1.5rem",
|
|
241
|
+
xl: "2rem"
|
|
242
|
+
},
|
|
243
|
+
radius: {
|
|
244
|
+
xs: "0.25rem",
|
|
245
|
+
sm: "0.5rem",
|
|
246
|
+
md: "0.75rem",
|
|
247
|
+
lg: "1rem",
|
|
248
|
+
xl: "1.5rem"
|
|
249
|
+
},
|
|
250
|
+
fontSizes: {
|
|
251
|
+
xs: "0.75rem",
|
|
252
|
+
sm: "0.875rem",
|
|
253
|
+
md: "1rem",
|
|
254
|
+
lg: "1.125rem",
|
|
255
|
+
xl: "1.25rem"
|
|
256
|
+
},
|
|
257
|
+
components: componentThemes
|
|
258
|
+
});
|
|
259
|
+
|
|
9
260
|
// src/theme/presets/utils.ts
|
|
10
261
|
function hexToRgb(hex) {
|
|
11
262
|
const h = hex.replace("#", "");
|
|
@@ -1111,107 +1362,57 @@ function createCssVariablesResolver(tokens, preset) {
|
|
|
1111
1362
|
dark: { ...darkShades, ...darkDefaults, ...flat, ...dark }
|
|
1112
1363
|
});
|
|
1113
1364
|
}
|
|
1114
|
-
var
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1365
|
+
var mantineNotificationAdapter = {
|
|
1366
|
+
success(title, message) {
|
|
1367
|
+
notifications.show({
|
|
1368
|
+
title,
|
|
1369
|
+
message,
|
|
1370
|
+
autoClose: 5e3,
|
|
1371
|
+
color: "green",
|
|
1372
|
+
position: "top-right"
|
|
1373
|
+
});
|
|
1374
|
+
},
|
|
1375
|
+
error(title, message) {
|
|
1376
|
+
notifications.show({
|
|
1377
|
+
title,
|
|
1378
|
+
message,
|
|
1379
|
+
autoClose: 5e3,
|
|
1380
|
+
color: "red",
|
|
1381
|
+
position: "top-right"
|
|
1382
|
+
});
|
|
1383
|
+
},
|
|
1384
|
+
info(title, message) {
|
|
1385
|
+
notifications.show({
|
|
1386
|
+
title,
|
|
1387
|
+
message,
|
|
1388
|
+
autoClose: 5e3,
|
|
1389
|
+
color: "blue",
|
|
1390
|
+
position: "top-right"
|
|
1391
|
+
});
|
|
1392
|
+
},
|
|
1393
|
+
warning(title, message) {
|
|
1394
|
+
notifications.show({
|
|
1395
|
+
title,
|
|
1396
|
+
message,
|
|
1397
|
+
autoClose: 5e3,
|
|
1398
|
+
color: "orange",
|
|
1399
|
+
position: "top-right"
|
|
1400
|
+
});
|
|
1401
|
+
},
|
|
1402
|
+
apiError(error) {
|
|
1403
|
+
const { message, code, requestId, fields, retryAfter } = getErrorInfo(error);
|
|
1404
|
+
notifications.show({
|
|
1405
|
+
title: getErrorTitle(code),
|
|
1406
|
+
message: formatErrorMessage(message, requestId, fields, retryAfter),
|
|
1407
|
+
autoClose: retryAfter ? retryAfter * 1e3 : 5e3,
|
|
1408
|
+
color: "red",
|
|
1409
|
+
position: "top-right"
|
|
1120
1410
|
});
|
|
1121
1411
|
}
|
|
1122
|
-
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
function useResolvedColorScheme(scheme) {
|
|
1126
|
-
const [resolved, setResolved] = useState(() => {
|
|
1127
|
-
if (scheme && scheme !== "auto") return scheme;
|
|
1128
|
-
if (typeof window === "undefined") return "dark";
|
|
1129
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
1130
|
-
});
|
|
1131
|
-
useEffect(() => {
|
|
1132
|
-
if (scheme && scheme !== "auto") {
|
|
1133
|
-
setResolved(scheme);
|
|
1134
|
-
return;
|
|
1135
|
-
}
|
|
1136
|
-
const mql = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1137
|
-
const handler = (e) => setResolved(e.matches ? "dark" : "light");
|
|
1138
|
-
setResolved(mql.matches ? "dark" : "light");
|
|
1139
|
-
mql.addEventListener("change", handler);
|
|
1140
|
-
return () => mql.removeEventListener("change", handler);
|
|
1141
|
-
}, [scheme]);
|
|
1142
|
-
return resolved;
|
|
1143
|
-
}
|
|
1144
|
-
function buildCssVarStyles(theme) {
|
|
1145
|
-
const preset = getPreset(theme?.preset ?? "default");
|
|
1146
|
-
const tokens = theme?.tokens;
|
|
1147
|
-
function toVarDeclarations(overrides) {
|
|
1148
|
-
const lines = [];
|
|
1149
|
-
for (const [key, varName] of Object.entries(TOKEN_VAR_MAP)) {
|
|
1150
|
-
const value = overrides[key];
|
|
1151
|
-
if (value) lines.push(` ${varName}: ${value};`);
|
|
1152
|
-
}
|
|
1153
|
-
return lines.join("\n");
|
|
1154
|
-
}
|
|
1155
|
-
const flatTokens = {};
|
|
1156
|
-
if (tokens) {
|
|
1157
|
-
for (const key of Object.keys(TOKEN_VAR_MAP)) {
|
|
1158
|
-
if (tokens[key] !== void 0) flatTokens[key] = tokens[key];
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
const darkMerged = { ...preset.dark, ...flatTokens, ...tokens?.dark };
|
|
1162
|
-
const lightMerged = { ...preset.light, ...flatTokens, ...tokens?.light };
|
|
1163
|
-
const darkBlock = toVarDeclarations(darkMerged);
|
|
1164
|
-
const lightBlock = toVarDeclarations(lightMerged);
|
|
1165
|
-
return [
|
|
1166
|
-
`:root[data-elevasis-scheme="dark"] {
|
|
1167
|
-
${darkBlock}
|
|
1168
|
-
}`,
|
|
1169
|
-
`:root[data-elevasis-scheme="light"] {
|
|
1170
|
-
${lightBlock}
|
|
1171
|
-
}`
|
|
1172
|
-
].join("\n\n");
|
|
1173
|
-
}
|
|
1174
|
-
function ElevasisCoreProvider({
|
|
1175
|
-
auth,
|
|
1176
|
-
theme,
|
|
1177
|
-
organizationId = null,
|
|
1178
|
-
queryClient,
|
|
1179
|
-
apiUrl,
|
|
1180
|
-
onError,
|
|
1181
|
-
isOrganizationReady,
|
|
1182
|
-
children
|
|
1183
|
-
}) {
|
|
1184
|
-
if (auth.mode === "apiKey") {
|
|
1185
|
-
throw new Error(
|
|
1186
|
-
`ElevasisCoreProvider: auth mode 'apiKey' is not yet implemented. Only 'authkit' and 'oauth' modes are supported.`
|
|
1187
|
-
);
|
|
1188
|
-
}
|
|
1189
|
-
const resolvedQueryClient = queryClient ?? getDefaultQueryClient();
|
|
1190
|
-
const resolvedScheme = useResolvedColorScheme(theme?.colorScheme);
|
|
1412
|
+
};
|
|
1413
|
+
function ElevasisUIProvider({ theme, children, ...coreProps }) {
|
|
1414
|
+
const resolvedColorScheme = theme?.colorScheme ?? "dark";
|
|
1191
1415
|
const preset = useMemo(() => getPreset(theme?.preset ?? "default"), [theme?.preset]);
|
|
1192
|
-
useEffect(() => {
|
|
1193
|
-
document.documentElement.setAttribute("data-elevasis-scheme", resolvedScheme);
|
|
1194
|
-
return () => {
|
|
1195
|
-
document.documentElement.removeAttribute("data-elevasis-scheme");
|
|
1196
|
-
};
|
|
1197
|
-
}, [resolvedScheme]);
|
|
1198
|
-
const styleRef = useRef(null);
|
|
1199
|
-
useEffect(() => {
|
|
1200
|
-
const css = buildCssVarStyles(theme);
|
|
1201
|
-
if (!styleRef.current) {
|
|
1202
|
-
const el = document.createElement("style");
|
|
1203
|
-
el.setAttribute("data-elevasis-vars", "");
|
|
1204
|
-
document.head.appendChild(el);
|
|
1205
|
-
styleRef.current = el;
|
|
1206
|
-
}
|
|
1207
|
-
styleRef.current.textContent = css;
|
|
1208
|
-
return () => {
|
|
1209
|
-
if (styleRef.current) {
|
|
1210
|
-
styleRef.current.remove();
|
|
1211
|
-
styleRef.current = null;
|
|
1212
|
-
}
|
|
1213
|
-
};
|
|
1214
|
-
}, [theme?.preset, theme?.tokens, resolvedScheme]);
|
|
1215
1416
|
useEffect(() => {
|
|
1216
1417
|
if (!preset.fontImports?.length) return;
|
|
1217
1418
|
const links = [];
|
|
@@ -1230,58 +1431,30 @@ function ElevasisCoreProvider({
|
|
|
1230
1431
|
document.documentElement.style.removeProperty("--elevasis-font-family-subtitle");
|
|
1231
1432
|
};
|
|
1232
1433
|
}, [preset.fontImports, preset.subtitleFontFamily, preset.mantine?.headings?.fontFamily, preset.mantine?.fontFamily]);
|
|
1233
|
-
const
|
|
1234
|
-
|
|
1235
|
-
{
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
const
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
function CoreOAuthInner({ auth, children }) {
|
|
1247
|
-
return /* @__PURE__ */ jsx(OAuthProvider, { config: auth, children });
|
|
1248
|
-
}
|
|
1249
|
-
function CoreServiceBridge({
|
|
1250
|
-
apiUrl,
|
|
1251
|
-
organizationId,
|
|
1252
|
-
isOrganizationReady,
|
|
1253
|
-
onError,
|
|
1254
|
-
children
|
|
1255
|
-
}) {
|
|
1256
|
-
const { getAccessToken } = useAuthContext();
|
|
1257
|
-
return /* @__PURE__ */ jsx(
|
|
1258
|
-
ApiClientProvider,
|
|
1259
|
-
{
|
|
1260
|
-
getAccessToken,
|
|
1261
|
-
organizationId,
|
|
1262
|
-
isOrganizationReady: isOrganizationReady ?? !!organizationId,
|
|
1263
|
-
onError,
|
|
1264
|
-
children: /* @__PURE__ */ jsx(CoreServiceBridgeInner, { apiUrl, organizationId, isOrganizationReady, children })
|
|
1265
|
-
}
|
|
1434
|
+
const resolvedTheme = useMemo(() => {
|
|
1435
|
+
const primaryHex = theme?.tokens?.primary ?? preset.dark.primary;
|
|
1436
|
+
const primaryOverride = {
|
|
1437
|
+
primaryColor: "primary",
|
|
1438
|
+
colors: { primary: generateShades(primaryHex) }
|
|
1439
|
+
};
|
|
1440
|
+
let base = mergeThemeOverrides(mantineThemeOverride, primaryOverride);
|
|
1441
|
+
if (preset.mantine) base = mergeThemeOverrides(base, preset.mantine);
|
|
1442
|
+
return theme?.mantine ? mergeThemeOverrides(base, theme.mantine) : base;
|
|
1443
|
+
}, [theme?.mantine, preset, theme?.tokens?.primary]);
|
|
1444
|
+
const cssVariablesResolver = useMemo(
|
|
1445
|
+
() => createCssVariablesResolver(theme?.tokens, theme?.preset),
|
|
1446
|
+
[theme?.tokens, theme?.preset]
|
|
1266
1447
|
);
|
|
1267
|
-
}
|
|
1268
|
-
function CoreServiceBridgeInner({
|
|
1269
|
-
apiUrl,
|
|
1270
|
-
organizationId,
|
|
1271
|
-
isOrganizationReady,
|
|
1272
|
-
children
|
|
1273
|
-
}) {
|
|
1274
|
-
const useApiClient = useRef(createUseApiClient(defaultUseOrganizations, apiUrl)).current;
|
|
1275
|
-
const { apiRequest } = useApiClient();
|
|
1276
1448
|
return /* @__PURE__ */ jsx(
|
|
1277
|
-
|
|
1449
|
+
MantineProvider,
|
|
1278
1450
|
{
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
children
|
|
1451
|
+
theme: resolvedTheme,
|
|
1452
|
+
defaultColorScheme: resolvedColorScheme,
|
|
1453
|
+
cssVariablesResolver,
|
|
1454
|
+
children: /* @__PURE__ */ jsx(ElevasisCoreProvider, { notifications: mantineNotificationAdapter, ...coreProps, children })
|
|
1283
1455
|
}
|
|
1284
1456
|
);
|
|
1285
1457
|
}
|
|
1458
|
+
var ElevasisProvider = ElevasisUIProvider;
|
|
1286
1459
|
|
|
1287
|
-
export {
|
|
1460
|
+
export { ElevasisProvider, ElevasisUIProvider, createCssVariablesResolver, generateShades, getPreset, mantineNotificationAdapter, mantineThemeOverride };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { useOrganization } from './chunk-DD3CCMCZ.js';
|
|
2
|
+
import { useProfile } from './chunk-4KAG5U7A.js';
|
|
3
|
+
import { useAuthContext } from './chunk-7PLEQFHO.js';
|
|
4
|
+
import { createContext, useContext, useMemo, useCallback, createElement } from 'react';
|
|
5
|
+
|
|
6
|
+
var InitializationContext = createContext(null);
|
|
7
|
+
function useInitialization() {
|
|
8
|
+
const ctx = useContext(InitializationContext);
|
|
9
|
+
if (!ctx) {
|
|
10
|
+
throw new Error(
|
|
11
|
+
"useInitialization must be used within an InitializationProvider. Wrap your app (or the relevant subtree) with <InitializationProvider>."
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
return ctx;
|
|
15
|
+
}
|
|
16
|
+
function InitializationProvider({ children }) {
|
|
17
|
+
const { user, isLoading: authLoading } = useAuthContext();
|
|
18
|
+
const { profile, loading: profileLoading, error: profileError, refetch } = useProfile();
|
|
19
|
+
const {
|
|
20
|
+
isInitializing: orgInitializing,
|
|
21
|
+
isOrgRefreshing: orgLoading,
|
|
22
|
+
error: orgErrorMsg,
|
|
23
|
+
currentWorkOSOrganizationId,
|
|
24
|
+
memberships,
|
|
25
|
+
retry: orgRetry
|
|
26
|
+
} = useOrganization();
|
|
27
|
+
const isInitializing = authLoading || profileLoading || orgInitializing || orgLoading;
|
|
28
|
+
const userReady = !authLoading && !profileLoading && !!user && !!profile && !profileError;
|
|
29
|
+
const organizationReady = userReady && !orgInitializing && !orgLoading && !!currentWorkOSOrganizationId && !orgErrorMsg;
|
|
30
|
+
const allReady = organizationReady;
|
|
31
|
+
const error = useMemo(() => {
|
|
32
|
+
if (profileError) {
|
|
33
|
+
return {
|
|
34
|
+
layer: "profile",
|
|
35
|
+
message: "Failed to load user profile",
|
|
36
|
+
originalError: profileError
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (orgErrorMsg) {
|
|
40
|
+
return {
|
|
41
|
+
layer: "organization",
|
|
42
|
+
message: orgErrorMsg,
|
|
43
|
+
originalError: new Error(orgErrorMsg)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (userReady && !orgInitializing && !orgLoading && !currentWorkOSOrganizationId && memberships.length > 0) {
|
|
47
|
+
return {
|
|
48
|
+
layer: "organization",
|
|
49
|
+
message: "No organization membership found. Please contact your administrator for an invitation."
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}, [profileError, orgErrorMsg, userReady, orgInitializing, orgLoading, currentWorkOSOrganizationId, memberships]);
|
|
54
|
+
const retry = useCallback(async () => {
|
|
55
|
+
if (profileError && refetch) {
|
|
56
|
+
await refetch();
|
|
57
|
+
}
|
|
58
|
+
await orgRetry();
|
|
59
|
+
}, [profileError, refetch, orgRetry]);
|
|
60
|
+
const value = useMemo(
|
|
61
|
+
() => ({
|
|
62
|
+
userReady,
|
|
63
|
+
organizationReady,
|
|
64
|
+
allReady,
|
|
65
|
+
isInitializing,
|
|
66
|
+
error,
|
|
67
|
+
retry,
|
|
68
|
+
profile
|
|
69
|
+
}),
|
|
70
|
+
[userReady, organizationReady, allReady, isInitializing, error, retry, profile]
|
|
71
|
+
);
|
|
72
|
+
return createElement(InitializationContext.Provider, { value }, children);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { InitializationContext, InitializationProvider, useInitialization };
|
|
@@ -150,6 +150,7 @@ function OAuthProvider({ config, children }) {
|
|
|
150
150
|
client_id: config.clientId,
|
|
151
151
|
redirect_uri: config.redirectUri,
|
|
152
152
|
response_type: "code",
|
|
153
|
+
provider: config.provider ?? "authkit",
|
|
153
154
|
code_challenge: challenge,
|
|
154
155
|
code_challenge_method: "S256",
|
|
155
156
|
state: oauthState
|
|
@@ -160,7 +161,7 @@ function OAuthProvider({ config, children }) {
|
|
|
160
161
|
window.location.href = `https://api.workos.com/user_management/authorize?${params.toString()}`;
|
|
161
162
|
};
|
|
162
163
|
void start();
|
|
163
|
-
}, [config.clientId, config.redirectUri, config.organizationId]);
|
|
164
|
+
}, [config.clientId, config.redirectUri, config.organizationId, config.provider]);
|
|
164
165
|
useEffect(() => {
|
|
165
166
|
const url = new URL(window.location.href);
|
|
166
167
|
const code = url.searchParams.get("code");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|