@stackframe/stack 2.1.2 → 2.2.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/components/avatar.d.ts +1 -0
- package/dist/components/avatar.d.ts.map +1 -0
- package/dist/components/avatar.js +1 -0
- package/dist/components/card-frame.d.ts +0 -1
- package/dist/components/card-frame.d.ts.map +1 -1
- package/dist/components/credential-sign-in.d.ts +0 -1
- package/dist/components/credential-sign-in.d.ts.map +1 -1
- package/dist/components/credential-sign-in.js +8 -20
- package/dist/components/credential-sign-up.d.ts +0 -1
- package/dist/components/credential-sign-up.d.ts.map +1 -1
- package/dist/components/credential-sign-up.js +13 -20
- package/dist/components/dashboard-frame.d.ts +23 -0
- package/dist/components/dashboard-frame.d.ts.map +1 -0
- package/dist/components/dashboard-frame.js +20 -0
- package/dist/components/divider-with-text.d.ts +1 -1
- package/dist/components/divider-with-text.d.ts.map +1 -1
- package/dist/components/divider-with-text.js +3 -3
- package/dist/components/forgot-password.d.ts +0 -1
- package/dist/components/forgot-password.d.ts.map +1 -1
- package/dist/components/forgot-password.js +1 -5
- package/dist/components/form-warning.d.ts +0 -1
- package/dist/components/logo.d.ts +7 -0
- package/dist/components/logo.d.ts.map +1 -0
- package/dist/components/logo.js +7 -0
- package/dist/components/message-card.d.ts +0 -1
- package/dist/components/oauth-button.d.ts +0 -1
- package/dist/components/oauth-button.d.ts.map +1 -1
- package/dist/components/oauth-button.js +1 -2
- package/dist/components/oauth-group.d.ts +0 -1
- package/dist/components/password-field.d.ts +0 -1
- package/dist/components/password-field.d.ts.map +1 -1
- package/dist/components/password-field.js +3 -2
- package/dist/components/password-reset-inner.d.ts +0 -1
- package/dist/components/password-reset-inner.d.ts.map +1 -1
- package/dist/components/password-reset-inner.js +4 -5
- package/dist/components/redirect-message-card.d.ts +0 -1
- package/dist/components/redirect-message-card.d.ts.map +1 -1
- package/dist/components/redirect-message-card.js +8 -1
- package/dist/components/separator-with-text.d.ts +3 -0
- package/dist/components/separator-with-text.d.ts.map +1 -0
- package/dist/components/separator-with-text.js +6 -0
- package/dist/components/user-avatar.d.ts +3 -0
- package/dist/components/user-avatar.d.ts.map +1 -0
- package/dist/components/user-avatar.js +9 -0
- package/dist/components/user-button.d.ts +4 -0
- package/dist/components/user-button.d.ts.map +1 -0
- package/dist/components/user-button.js +25 -0
- package/dist/components-core/avatar.d.ts +6 -0
- package/dist/components-core/avatar.d.ts.map +1 -0
- package/dist/components-core/avatar.js +38 -0
- package/dist/components-core/button.d.ts +4 -4
- package/dist/components-core/button.d.ts.map +1 -1
- package/dist/components-core/button.js +51 -31
- package/dist/components-core/card.d.ts +5 -4
- package/dist/components-core/card.d.ts.map +1 -1
- package/dist/components-core/card.js +28 -9
- package/dist/components-core/collapsble.d.ts +5 -0
- package/dist/components-core/collapsble.d.ts.map +1 -0
- package/dist/components-core/collapsble.js +6 -0
- package/dist/components-core/collapsible.d.ts +6 -0
- package/dist/components-core/collapsible.d.ts.map +1 -0
- package/dist/components-core/collapsible.js +6 -0
- package/dist/components-core/container.d.ts +3 -3
- package/dist/components-core/container.d.ts.map +1 -1
- package/dist/components-core/container.js +1 -1
- package/dist/components-core/divider.d.ts +2 -3
- package/dist/components-core/divider.d.ts.map +1 -1
- package/dist/components-core/divider.js +5 -5
- package/dist/components-core/dropdown.d.ts +13 -0
- package/dist/components-core/dropdown.d.ts.map +1 -0
- package/dist/components-core/dropdown.js +73 -0
- package/dist/components-core/index.d.ts +41 -19
- package/dist/components-core/index.d.ts.map +1 -1
- package/dist/components-core/index.js +80 -4
- package/dist/components-core/input.d.ts +2 -3
- package/dist/components-core/input.d.ts.map +1 -1
- package/dist/components-core/input.js +1 -1
- package/dist/components-core/label.d.ts +1 -3
- package/dist/components-core/label.d.ts.map +1 -1
- package/dist/components-core/label.js +1 -1
- package/dist/components-core/link.d.ts +3 -3
- package/dist/components-core/link.d.ts.map +1 -1
- package/dist/components-core/link.js +3 -3
- package/dist/components-core/loading-indicator.d.ts +6 -0
- package/dist/components-core/loading-indicator.d.ts.map +1 -0
- package/dist/components-core/loading-indicator.js +18 -0
- package/dist/components-core/popover.d.ts +6 -0
- package/dist/components-core/popover.d.ts.map +1 -0
- package/dist/components-core/popover.js +24 -0
- package/dist/components-core/separator.d.ts +4 -0
- package/dist/components-core/separator.d.ts.map +1 -0
- package/dist/components-core/separator.js +20 -0
- package/dist/components-core/text.d.ts +2 -3
- package/dist/components-core/text.d.ts.map +1 -1
- package/dist/components-core/text.js +3 -3
- package/dist/components-core-joy/button.d.ts +2 -3
- package/dist/components-core-joy/button.d.ts.map +1 -1
- package/dist/components-core-joy/button.js +7 -4
- package/dist/components-core-joy/divider.d.ts +2 -2
- package/dist/components-core-joy/divider.d.ts.map +1 -1
- package/dist/components-core-joy/divider.js +5 -5
- package/dist/components-core-joy/input.d.ts +2 -3
- package/dist/components-core-joy/input.d.ts.map +1 -1
- package/dist/components-core-joy/input.js +3 -3
- package/dist/components-core-joy/separator.d.ts +2 -0
- package/dist/components-core-joy/separator.d.ts.map +1 -0
- package/dist/components-core-joy/separator.js +7 -0
- package/dist/components-core-joy/text.d.ts +6 -3
- package/dist/components-core-joy/text.d.ts.map +1 -1
- package/dist/components-core-joy/text.js +4 -3
- package/dist/components-page/account-settings.d.ts +3 -0
- package/dist/components-page/account-settings.d.ts.map +1 -0
- package/dist/components-page/account-settings.js +95 -0
- package/dist/components-page/email-verification.d.ts +1 -2
- package/dist/components-page/email-verification.d.ts.map +1 -1
- package/dist/components-page/email-verification.js +14 -14
- package/dist/components-page/forgot-password.d.ts +0 -1
- package/dist/components-page/oauth-callback.d.ts +0 -1
- package/dist/components-page/password-reset.d.ts +0 -1
- package/dist/components-page/password-reset.d.ts.map +1 -1
- package/dist/components-page/password-reset.js +14 -15
- package/dist/components-page/sign-in.d.ts +0 -1
- package/dist/components-page/sign-in.js +3 -3
- package/dist/components-page/sign-out.d.ts +0 -1
- package/dist/components-page/sign-up.d.ts +0 -1
- package/dist/components-page/sign-up.js +3 -3
- package/dist/components-page/stack-handler.d.ts +0 -1
- package/dist/components-page/stack-handler.d.ts.map +1 -1
- package/dist/components-page/stack-handler.js +5 -0
- package/dist/icons/logo.d.ts +3 -0
- package/dist/icons/logo.d.ts.map +1 -0
- package/dist/icons/logo.js +7 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/lib/auth.d.ts +1 -2
- package/dist/lib/auth.d.ts.map +1 -1
- package/dist/lib/auth.js +8 -7
- package/dist/lib/cookie.d.ts +0 -1
- package/dist/lib/hooks.d.ts +0 -1
- package/dist/lib/stack-app.d.ts +17 -10
- package/dist/lib/stack-app.d.ts.map +1 -1
- package/dist/lib/stack-app.js +97 -35
- package/dist/providers/component-provider.d.ts +74 -20
- package/dist/providers/component-provider.d.ts.map +1 -1
- package/dist/providers/component-provider.js +41 -18
- package/dist/providers/design-provider.d.ts +0 -1
- package/dist/providers/joy-provider.d.ts +8 -11
- package/dist/providers/joy-provider.d.ts.map +1 -1
- package/dist/providers/joy-provider.js +6 -8
- package/dist/providers/stack-provider-client.d.ts +0 -1
- package/dist/providers/stack-provider.d.ts +0 -1
- package/dist/providers/styled-components-registry.d.ts +0 -1
- package/dist/providers/theme-provider.d.ts +0 -1
- package/dist/utils/constants.d.ts +8 -1
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +2 -0
- package/dist/utils/email.d.ts +0 -1
- package/dist/utils/next.d.ts +0 -1
- package/dist/utils/url.d.ts +0 -1
- package/package.json +11 -7
package/dist/lib/stack-app.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { use, useCallback } from "react";
|
|
1
|
+
import React, { use, useCallback, useMemo } from "react";
|
|
2
2
|
import { StackAdminInterface, StackClientInterface, StackServerInterface } from "@stackframe/stack-shared";
|
|
3
3
|
import { getCookie, setOrDeleteCookie } from "./cookie";
|
|
4
|
-
import { throwErr } from "@stackframe/stack-shared/dist/utils/errors";
|
|
4
|
+
import { StackAssertionError, throwErr } from "@stackframe/stack-shared/dist/utils/errors";
|
|
5
5
|
import { generateUuid } from "@stackframe/stack-shared/dist/utils/uuids";
|
|
6
6
|
import { AsyncResult, Result } from "@stackframe/stack-shared/dist/utils/results";
|
|
7
7
|
import { suspendIfSsr } from "@stackframe/stack-shared/dist/utils/react";
|
|
@@ -11,10 +11,10 @@ import { isClient } from "../utils/next";
|
|
|
11
11
|
import { callOAuthCallback, signInWithOAuth } from "./auth";
|
|
12
12
|
import { RedirectType, redirect, useRouter } from "next/navigation";
|
|
13
13
|
import { constructRedirectUrl } from "../utils/url";
|
|
14
|
-
import { filterUndefined } from "@stackframe/stack-shared/dist/utils/objects";
|
|
15
|
-
import { neverResolve, resolved } from "@stackframe/stack-shared/dist/utils/promises";
|
|
14
|
+
import { filterUndefined, omit } from "@stackframe/stack-shared/dist/utils/objects";
|
|
15
|
+
import { neverResolve, resolved, runAsynchronously } from "@stackframe/stack-shared/dist/utils/promises";
|
|
16
16
|
import { AsyncCache } from "@stackframe/stack-shared/dist/utils/caches";
|
|
17
|
-
import { suspend } from "
|
|
17
|
+
import { suspend } from "@stackframe/stack-shared/dist/utils/react";
|
|
18
18
|
function getUrls(partial) {
|
|
19
19
|
const handler = partial.handler ?? "/handler";
|
|
20
20
|
return {
|
|
@@ -30,6 +30,7 @@ function getUrls(partial) {
|
|
|
30
30
|
forgotPassword: `${handler}/forgot-password`,
|
|
31
31
|
oauthCallback: `${handler}/oauth-callback`,
|
|
32
32
|
home: "/",
|
|
33
|
+
accountSettings: `${handler}/account-settings`,
|
|
33
34
|
...filterUndefined(partial),
|
|
34
35
|
};
|
|
35
36
|
}
|
|
@@ -48,7 +49,7 @@ function getDefaultSuperSecretAdminKey() {
|
|
|
48
49
|
function getDefaultBaseUrl() {
|
|
49
50
|
return process.env.NEXT_PUBLIC_STACK_URL || defaultBaseUrl;
|
|
50
51
|
}
|
|
51
|
-
const defaultBaseUrl = "https://app.
|
|
52
|
+
const defaultBaseUrl = "https://app.stack-auth.com";
|
|
52
53
|
function createEmptyTokenStore() {
|
|
53
54
|
const store = new AsyncStore();
|
|
54
55
|
store.set({
|
|
@@ -195,17 +196,36 @@ class _StackClientAppImpl {
|
|
|
195
196
|
this._urlOptions = options.urls ?? {};
|
|
196
197
|
this._uniqueIdentifier = options.uniqueIdentifier ?? generateUuid();
|
|
197
198
|
if (allClientApps.has(this._uniqueIdentifier)) {
|
|
198
|
-
throw new
|
|
199
|
+
throw new StackAssertionError("A Stack client app with the same unique identifier already exists");
|
|
199
200
|
}
|
|
200
201
|
allClientApps.set(this._uniqueIdentifier, [options.checkString ?? "default check string", this]);
|
|
202
|
+
// For some important calls, either use the provided cached values or start fetching them now
|
|
203
|
+
if (options.currentClientUserJson !== undefined) {
|
|
204
|
+
this._currentUserCache.forceSetCachedValue([getTokenStore(this._tokenStoreOptions)], options.currentClientUserJson);
|
|
205
|
+
}
|
|
206
|
+
else if (this.hasPersistentTokenStore()) {
|
|
207
|
+
runAsynchronously(() => this.getUser(), { ignoreErrors: true });
|
|
208
|
+
}
|
|
209
|
+
if (options.currentProjectJson !== undefined) {
|
|
210
|
+
this._currentProjectCache.forceSetCachedValue([], options.currentProjectJson);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
runAsynchronously(this.getProject(), { ignoreErrors: true });
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
hasPersistentTokenStore() {
|
|
217
|
+
return this._tokenStoreOptions !== null;
|
|
201
218
|
}
|
|
202
219
|
_ensurePersistentTokenStore() {
|
|
203
|
-
if (!this.
|
|
220
|
+
if (!this.hasPersistentTokenStore()) {
|
|
204
221
|
throw new Error("Cannot call this function on a Stack app without a persistent token store. Make sure the tokenStore option is set to a non-null value when initializing Stack.");
|
|
205
222
|
}
|
|
206
223
|
}
|
|
224
|
+
isInternalProject() {
|
|
225
|
+
return this.projectId === "internal";
|
|
226
|
+
}
|
|
207
227
|
_ensureInternalProject() {
|
|
208
|
-
if (this.
|
|
228
|
+
if (!this.isInternalProject()) {
|
|
209
229
|
throw new Error("Cannot call this function on a Stack app with a project ID other than 'internal'.");
|
|
210
230
|
}
|
|
211
231
|
}
|
|
@@ -219,6 +239,7 @@ class _StackClientAppImpl {
|
|
|
219
239
|
profileImageUrl: json.profileImageUrl,
|
|
220
240
|
signedUpAt: new Date(json.signedUpAtMillis),
|
|
221
241
|
clientMetadata: json.clientMetadata,
|
|
242
|
+
authMethod: json.authMethod,
|
|
222
243
|
toJson() {
|
|
223
244
|
return json;
|
|
224
245
|
}
|
|
@@ -237,6 +258,12 @@ class _StackClientAppImpl {
|
|
|
237
258
|
signOut() {
|
|
238
259
|
return app._signOut(tokenStore);
|
|
239
260
|
},
|
|
261
|
+
sendVerificationEmail() {
|
|
262
|
+
return app._sendVerificationEmail(tokenStore);
|
|
263
|
+
},
|
|
264
|
+
updatePassword(options) {
|
|
265
|
+
return app._updatePassword(options, tokenStore);
|
|
266
|
+
}
|
|
240
267
|
};
|
|
241
268
|
Object.freeze(res);
|
|
242
269
|
return res;
|
|
@@ -251,6 +278,7 @@ class _StackClientAppImpl {
|
|
|
251
278
|
profileImageUrl: user.profileImageUrl,
|
|
252
279
|
signedUpAtMillis: user.signedUpAt.getTime(),
|
|
253
280
|
clientMetadata: user.clientMetadata,
|
|
281
|
+
authMethod: user.authMethod,
|
|
254
282
|
};
|
|
255
283
|
}
|
|
256
284
|
_projectAdminFromJson(data, adminInterface, onRefresh) {
|
|
@@ -315,12 +343,15 @@ class _StackClientAppImpl {
|
|
|
315
343
|
async redirectToAfterSignIn() { return await this._redirectTo("afterSignIn"); }
|
|
316
344
|
async redirectToAfterSignUp() { return await this._redirectTo("afterSignUp"); }
|
|
317
345
|
async redirectToAfterSignOut() { return await this._redirectTo("afterSignOut"); }
|
|
346
|
+
async redirectToAccountSettings() { return await this._redirectTo("accountSettings"); }
|
|
318
347
|
async sendForgotPasswordEmail(email) {
|
|
319
348
|
const redirectUrl = constructRedirectUrl(this.urls.passwordReset);
|
|
320
|
-
await this._interface.sendForgotPasswordEmail(email, redirectUrl);
|
|
349
|
+
const error = await this._interface.sendForgotPasswordEmail(email, redirectUrl);
|
|
350
|
+
return error;
|
|
321
351
|
}
|
|
322
352
|
async resetPassword(options) {
|
|
323
|
-
|
|
353
|
+
const error = await this._interface.resetPassword(options);
|
|
354
|
+
return error;
|
|
324
355
|
}
|
|
325
356
|
async verifyPasswordResetCode(code) {
|
|
326
357
|
return await this._interface.verifyPasswordResetCode(code);
|
|
@@ -331,7 +362,7 @@ class _StackClientAppImpl {
|
|
|
331
362
|
async getUser(options) {
|
|
332
363
|
this._ensurePersistentTokenStore();
|
|
333
364
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
334
|
-
const userJson = await this._currentUserCache.getOrWait([tokenStore], "
|
|
365
|
+
const userJson = await this._currentUserCache.getOrWait([tokenStore], "write-only");
|
|
335
366
|
if (userJson === null) {
|
|
336
367
|
switch (options?.or) {
|
|
337
368
|
case 'redirect': {
|
|
@@ -358,7 +389,7 @@ class _StackClientAppImpl {
|
|
|
358
389
|
case 'redirect': {
|
|
359
390
|
router.replace(this.urls.signIn);
|
|
360
391
|
suspend();
|
|
361
|
-
throw new Error("suspend should never return!");
|
|
392
|
+
throw new Error("suspend should never return! This is a bug in Stack.");
|
|
362
393
|
}
|
|
363
394
|
case 'throw': {
|
|
364
395
|
throw new Error("User is not signed in but useUser was called with { or: 'throw' }");
|
|
@@ -368,7 +399,9 @@ class _StackClientAppImpl {
|
|
|
368
399
|
}
|
|
369
400
|
}
|
|
370
401
|
}
|
|
371
|
-
return
|
|
402
|
+
return useMemo(() => {
|
|
403
|
+
return this._currentUserFromJson(userJson, tokenStore);
|
|
404
|
+
}, [userJson, tokenStore, options?.or]);
|
|
372
405
|
}
|
|
373
406
|
onUserChange(callback) {
|
|
374
407
|
this._ensurePersistentTokenStore();
|
|
@@ -409,17 +442,25 @@ class _StackClientAppImpl {
|
|
|
409
442
|
this._ensurePersistentTokenStore();
|
|
410
443
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
411
444
|
const result = await callOAuthCallback(this._interface, tokenStore, this.urls.oauthCallback);
|
|
412
|
-
if (result
|
|
413
|
-
|
|
445
|
+
if (result?.newUser) {
|
|
446
|
+
window.location.replace(this.urls.afterSignUp);
|
|
414
447
|
}
|
|
415
448
|
else {
|
|
416
|
-
|
|
449
|
+
window.location.replace(this.urls.afterSignIn);
|
|
417
450
|
}
|
|
451
|
+
await neverResolve();
|
|
418
452
|
}
|
|
419
453
|
async _signOut(tokenStore) {
|
|
420
454
|
await this._interface.signOut(tokenStore);
|
|
421
455
|
window.location.assign(this.urls.afterSignOut);
|
|
422
456
|
}
|
|
457
|
+
async _sendVerificationEmail(tokenStore) {
|
|
458
|
+
const emailVerificationRedirectUrl = constructRedirectUrl(this.urls.emailVerification);
|
|
459
|
+
return await this._interface.sendVerificationEmail(emailVerificationRedirectUrl, tokenStore);
|
|
460
|
+
}
|
|
461
|
+
async _updatePassword(options, tokenStore) {
|
|
462
|
+
return await this._interface.updatePassword(options, tokenStore);
|
|
463
|
+
}
|
|
423
464
|
async signOut() {
|
|
424
465
|
const user = await this.getUser();
|
|
425
466
|
if (user) {
|
|
@@ -427,7 +468,7 @@ class _StackClientAppImpl {
|
|
|
427
468
|
}
|
|
428
469
|
}
|
|
429
470
|
async getProject() {
|
|
430
|
-
return await this._currentProjectCache.getOrWait([], "
|
|
471
|
+
return await this._currentProjectCache.getOrWait([], "write-only");
|
|
431
472
|
}
|
|
432
473
|
useProject() {
|
|
433
474
|
return useCache(this._currentProjectCache, [], "useProject()");
|
|
@@ -438,14 +479,14 @@ class _StackClientAppImpl {
|
|
|
438
479
|
async listOwnedProjects() {
|
|
439
480
|
this._ensureInternalProject();
|
|
440
481
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
441
|
-
const json = await this._ownedProjectsCache.getOrWait([tokenStore], "
|
|
482
|
+
const json = await this._ownedProjectsCache.getOrWait([tokenStore], "write-only");
|
|
442
483
|
return json.map((j) => this._projectAdminFromJson(j, this._createAdminInterface(j.id, tokenStore), () => this._refreshOwnedProjects(tokenStore)));
|
|
443
484
|
}
|
|
444
485
|
useOwnedProjects() {
|
|
445
486
|
this._ensureInternalProject();
|
|
446
487
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
447
488
|
const json = useCache(this._ownedProjectsCache, [tokenStore], "useOwnedProjects()");
|
|
448
|
-
return json.map((j) => this._projectAdminFromJson(j, this._createAdminInterface(j.id, tokenStore), () => this._refreshOwnedProjects(tokenStore)));
|
|
489
|
+
return useMemo(() => json.map((j) => this._projectAdminFromJson(j, this._createAdminInterface(j.id, tokenStore), () => this._refreshOwnedProjects(tokenStore))), [json]);
|
|
449
490
|
}
|
|
450
491
|
onOwnedProjectsChange(callback) {
|
|
451
492
|
this._ensureInternalProject();
|
|
@@ -477,17 +518,18 @@ class _StackClientAppImpl {
|
|
|
477
518
|
static get [stackAppInternalsSymbol]() {
|
|
478
519
|
return {
|
|
479
520
|
fromClientJson: (json) => {
|
|
521
|
+
const providedCheckString = JSON.stringify(omit(json, ["currentClientUserJson", "currentProjectJson"]));
|
|
480
522
|
const existing = allClientApps.get(json.uniqueIdentifier);
|
|
481
523
|
if (existing) {
|
|
482
|
-
const [
|
|
483
|
-
if (
|
|
484
|
-
throw new
|
|
524
|
+
const [existingCheckString, clientApp] = existing;
|
|
525
|
+
if (existingCheckString !== providedCheckString) {
|
|
526
|
+
throw new StackAssertionError("The provided app JSON does not match the configuration of the existing client app with the same unique identifier", { providedObj: json, existingString: existingCheckString });
|
|
485
527
|
}
|
|
486
528
|
return clientApp;
|
|
487
529
|
}
|
|
488
530
|
return new _StackClientAppImpl({
|
|
489
531
|
...json,
|
|
490
|
-
checkString:
|
|
532
|
+
checkString: providedCheckString,
|
|
491
533
|
});
|
|
492
534
|
}
|
|
493
535
|
};
|
|
@@ -499,6 +541,10 @@ class _StackClientAppImpl {
|
|
|
499
541
|
// TODO find a way to do this
|
|
500
542
|
throw Error("Cannot serialize to JSON from an application without a publishable client key");
|
|
501
543
|
}
|
|
544
|
+
const [user, project] = await Promise.all([
|
|
545
|
+
this.getUser(),
|
|
546
|
+
this.getProject(),
|
|
547
|
+
]);
|
|
502
548
|
return {
|
|
503
549
|
baseUrl: this._interface.options.baseUrl,
|
|
504
550
|
projectId: this.projectId,
|
|
@@ -506,6 +552,8 @@ class _StackClientAppImpl {
|
|
|
506
552
|
tokenStore: this._tokenStoreOptions,
|
|
507
553
|
urls: this._urlOptions,
|
|
508
554
|
uniqueIdentifier: this._uniqueIdentifier,
|
|
555
|
+
currentClientUserJson: user?.toJson() ?? null,
|
|
556
|
+
currentProjectJson: project,
|
|
509
557
|
};
|
|
510
558
|
}
|
|
511
559
|
};
|
|
@@ -591,6 +639,12 @@ class _StackServerAppImpl extends _StackClientAppImpl {
|
|
|
591
639
|
getClientUser() {
|
|
592
640
|
return app._currentUserFromJson(json, tokenStore);
|
|
593
641
|
},
|
|
642
|
+
sendVerificationEmail() {
|
|
643
|
+
return app._sendVerificationEmail(tokenStore);
|
|
644
|
+
},
|
|
645
|
+
updatePassword(options) {
|
|
646
|
+
return app._updatePassword(options, tokenStore);
|
|
647
|
+
}
|
|
594
648
|
};
|
|
595
649
|
Object.freeze(res);
|
|
596
650
|
return res;
|
|
@@ -606,22 +660,25 @@ class _StackServerAppImpl extends _StackClientAppImpl {
|
|
|
606
660
|
signedUpAtMillis: user.signedUpAt.getTime(),
|
|
607
661
|
clientMetadata: user.clientMetadata,
|
|
608
662
|
serverMetadata: user.serverMetadata,
|
|
663
|
+
authMethod: user.authMethod,
|
|
609
664
|
};
|
|
610
665
|
}
|
|
611
666
|
async getServerUser() {
|
|
612
667
|
this._ensurePersistentTokenStore();
|
|
613
668
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
614
|
-
const userJson = await this._currentServerUserCache.getOrWait([tokenStore], "
|
|
669
|
+
const userJson = await this._currentServerUserCache.getOrWait([tokenStore], "write-only");
|
|
615
670
|
return this._currentServerUserFromJson(userJson, tokenStore);
|
|
616
671
|
}
|
|
617
672
|
useServerUser(options) {
|
|
618
673
|
this._ensurePersistentTokenStore();
|
|
619
674
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
620
675
|
const userJson = useCache(this._currentServerUserCache, [tokenStore], "useServerUser()");
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
676
|
+
return useMemo(() => {
|
|
677
|
+
if (options?.required && userJson === null) {
|
|
678
|
+
use(this.redirectToSignIn());
|
|
679
|
+
}
|
|
680
|
+
return this._currentServerUserFromJson(userJson, tokenStore);
|
|
681
|
+
}, [userJson, tokenStore, options?.required]);
|
|
625
682
|
}
|
|
626
683
|
onServerUserChange(callback) {
|
|
627
684
|
this._ensurePersistentTokenStore();
|
|
@@ -631,12 +688,14 @@ class _StackServerAppImpl extends _StackClientAppImpl {
|
|
|
631
688
|
});
|
|
632
689
|
}
|
|
633
690
|
async listServerUsers() {
|
|
634
|
-
const json = await this._serverUsersCache.getOrWait([], "
|
|
691
|
+
const json = await this._serverUsersCache.getOrWait([], "write-only");
|
|
635
692
|
return json.map((j) => this._serverUserFromJson(j));
|
|
636
693
|
}
|
|
637
694
|
useServerUsers() {
|
|
638
695
|
const json = useCache(this._serverUsersCache, [], "useServerUsers()");
|
|
639
|
-
return
|
|
696
|
+
return useMemo(() => {
|
|
697
|
+
return json.map((j) => this._serverUserFromJson(j));
|
|
698
|
+
}, [json]);
|
|
640
699
|
}
|
|
641
700
|
onServerUsersChange(callback) {
|
|
642
701
|
return this._serverUsersCache.onChange([], (users) => {
|
|
@@ -722,10 +781,11 @@ class _StackAdminAppImpl extends _StackServerAppImpl {
|
|
|
722
781
|
};
|
|
723
782
|
}
|
|
724
783
|
async getProjectAdmin() {
|
|
725
|
-
return this._projectAdminFromJson(await this._adminProjectCache.getOrWait([], "
|
|
784
|
+
return this._projectAdminFromJson(await this._adminProjectCache.getOrWait([], "write-only"), this._interface, () => this._refreshProject());
|
|
726
785
|
}
|
|
727
786
|
useProjectAdmin() {
|
|
728
|
-
|
|
787
|
+
const json = useCache(this._adminProjectCache, [], "useProjectAdmin()");
|
|
788
|
+
return useMemo(() => this._projectAdminFromJson(json, this._interface, () => this._refreshProject()), [json]);
|
|
729
789
|
}
|
|
730
790
|
onProjectAdminChange(callback) {
|
|
731
791
|
return this._adminProjectCache.onChange([], (project) => {
|
|
@@ -733,12 +793,14 @@ class _StackAdminAppImpl extends _StackServerAppImpl {
|
|
|
733
793
|
});
|
|
734
794
|
}
|
|
735
795
|
async listApiKeySets() {
|
|
736
|
-
const json = await this._apiKeySetsCache.getOrWait([], "
|
|
796
|
+
const json = await this._apiKeySetsCache.getOrWait([], "write-only");
|
|
737
797
|
return json.map((j) => this._createApiKeySetFromJson(j));
|
|
738
798
|
}
|
|
739
799
|
useApiKeySets() {
|
|
740
800
|
const json = useCache(this._apiKeySetsCache, [], "useApiKeySets()");
|
|
741
|
-
return
|
|
801
|
+
return useMemo(() => {
|
|
802
|
+
return json.map((j) => this._createApiKeySetFromJson(j));
|
|
803
|
+
}, [json]);
|
|
742
804
|
}
|
|
743
805
|
onApiKeySetsChange(callback) {
|
|
744
806
|
return this._apiKeySetsCache.onChange([], (apiKeySets) => {
|
|
@@ -1,27 +1,81 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
import { Container } from '../components-core/container';
|
|
3
|
+
import { Link } from '../components-core/link';
|
|
4
|
+
export declare const Components: {
|
|
5
|
+
readonly Input: React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement> & Pick<React.HTMLProps<HTMLInputElement>, "ref">, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
6
|
+
readonly Button: React.ForwardRefExoticComponent<Omit<import("../components-core/button").ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
7
|
+
readonly Container: typeof Container;
|
|
8
|
+
readonly Separator: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-separator").SeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
readonly Label: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-label").LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & React.RefAttributes<HTMLLabelElement>>;
|
|
10
|
+
readonly Link: typeof Link;
|
|
11
|
+
readonly Text: React.ForwardRefExoticComponent<Omit<{
|
|
12
|
+
variant?: "primary" | "secondary" | "warning" | "success" | undefined;
|
|
13
|
+
as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | undefined;
|
|
14
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
|
|
15
|
+
} & Omit<React.HTMLProps<HTMLParagraphElement>, "size">, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
|
|
16
|
+
readonly Popover: React.FC<import("@radix-ui/react-popover").PopoverProps>;
|
|
17
|
+
readonly PopoverTrigger: React.ForwardRefExoticComponent<import("@radix-ui/react-popover").PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
18
|
+
readonly PopoverContent: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-popover").PopoverContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
19
|
+
readonly DropdownMenu: React.FC<import("@radix-ui/react-dropdown-menu").DropdownMenuProps>;
|
|
20
|
+
readonly DropdownMenuTrigger: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-dropdown-menu").DropdownMenuTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
21
|
+
readonly DropdownMenuContent: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-dropdown-menu").DropdownMenuContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
22
|
+
readonly DropdownMenuItem: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-dropdown-menu").DropdownMenuItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
23
|
+
inset?: boolean | undefined;
|
|
24
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
25
|
+
readonly DropdownMenuLabel: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-dropdown-menu").DropdownMenuLabelProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
26
|
+
inset?: boolean | undefined;
|
|
27
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
28
|
+
readonly DropdownMenuSeparator: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-dropdown-menu").DropdownMenuSeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
29
|
+
readonly Avatar: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-avatar").AvatarProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
30
|
+
readonly AvatarFallback: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-avatar").AvatarFallbackProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
31
|
+
readonly AvatarImage: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-avatar").AvatarImageProps & React.RefAttributes<HTMLImageElement>, "ref"> & React.RefAttributes<HTMLImageElement>>;
|
|
32
|
+
readonly Collapsible: React.ForwardRefExoticComponent<import("@radix-ui/react-collapsible").CollapsibleProps & React.RefAttributes<HTMLDivElement>>;
|
|
33
|
+
readonly CollapsibleTrigger: React.ForwardRefExoticComponent<import("@radix-ui/react-collapsible").CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
34
|
+
readonly CollapsibleContent: React.ForwardRefExoticComponent<import("@radix-ui/react-collapsible").CollapsibleContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
35
|
+
readonly Card: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
36
|
+
readonly CardHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
37
|
+
readonly CardContent: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
38
|
+
readonly CardFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
19
39
|
};
|
|
20
40
|
export type ComponentConfig = {
|
|
21
|
-
components?: Partial<Components>;
|
|
41
|
+
components?: Partial<typeof Components>;
|
|
42
|
+
};
|
|
43
|
+
export declare function useComponents(): {
|
|
44
|
+
readonly Input: React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement> & Pick<React.HTMLProps<HTMLInputElement>, "ref">, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
45
|
+
readonly Button: React.ForwardRefExoticComponent<Omit<import("../components-core/button").ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
46
|
+
readonly Container: typeof Container;
|
|
47
|
+
readonly Separator: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-separator").SeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
48
|
+
readonly Label: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-label").LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & React.RefAttributes<HTMLLabelElement>>;
|
|
49
|
+
readonly Link: typeof Link;
|
|
50
|
+
readonly Text: React.ForwardRefExoticComponent<Omit<{
|
|
51
|
+
variant?: "primary" | "secondary" | "warning" | "success" | undefined;
|
|
52
|
+
as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | undefined;
|
|
53
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
|
|
54
|
+
} & Omit<React.HTMLProps<HTMLParagraphElement>, "size">, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
|
|
55
|
+
readonly Popover: React.FC<import("@radix-ui/react-popover").PopoverProps>;
|
|
56
|
+
readonly PopoverTrigger: React.ForwardRefExoticComponent<import("@radix-ui/react-popover").PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
57
|
+
readonly PopoverContent: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-popover").PopoverContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
58
|
+
readonly DropdownMenu: React.FC<import("@radix-ui/react-dropdown-menu").DropdownMenuProps>;
|
|
59
|
+
readonly DropdownMenuTrigger: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-dropdown-menu").DropdownMenuTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
60
|
+
readonly DropdownMenuContent: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-dropdown-menu").DropdownMenuContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
61
|
+
readonly DropdownMenuItem: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-dropdown-menu").DropdownMenuItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
62
|
+
inset?: boolean | undefined;
|
|
63
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
64
|
+
readonly DropdownMenuLabel: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-dropdown-menu").DropdownMenuLabelProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
65
|
+
inset?: boolean | undefined;
|
|
66
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
67
|
+
readonly DropdownMenuSeparator: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-dropdown-menu").DropdownMenuSeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
68
|
+
readonly Avatar: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-avatar").AvatarProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
69
|
+
readonly AvatarFallback: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-avatar").AvatarFallbackProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
70
|
+
readonly AvatarImage: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-avatar").AvatarImageProps & React.RefAttributes<HTMLImageElement>, "ref"> & React.RefAttributes<HTMLImageElement>>;
|
|
71
|
+
readonly Collapsible: React.ForwardRefExoticComponent<import("@radix-ui/react-collapsible").CollapsibleProps & React.RefAttributes<HTMLDivElement>>;
|
|
72
|
+
readonly CollapsibleTrigger: React.ForwardRefExoticComponent<import("@radix-ui/react-collapsible").CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
73
|
+
readonly CollapsibleContent: React.ForwardRefExoticComponent<import("@radix-ui/react-collapsible").CollapsibleContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
74
|
+
readonly Card: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
75
|
+
readonly CardHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
76
|
+
readonly CardContent: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
77
|
+
readonly CardFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
22
78
|
};
|
|
23
|
-
export declare function useComponents(): Components;
|
|
24
79
|
export declare function StackComponentProvider(props: {
|
|
25
80
|
children?: React.ReactNode;
|
|
26
81
|
} & ComponentConfig): import("react/jsx-runtime").JSX.Element;
|
|
27
|
-
//# sourceMappingURL=component-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-provider.d.ts","sourceRoot":"","sources":["../../src/providers/component-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"component-provider.d.ts","sourceRoot":"","sources":["../../src/providers/component-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGzD,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAgB/C,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Bb,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC,OAAO,UAAU,CAAC,CAAC;CACzC,CAAA;AAID,wBAAgB,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAM5B;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,GAAG,eAAe,2CAM7F"}
|
|
@@ -1,14 +1,46 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { createContext, useContext } from 'react';
|
|
4
|
-
import Button from '../components-core/button';
|
|
5
|
-
import Container from '../components-core/container';
|
|
6
|
-
import
|
|
7
|
-
import Input from '../components-core/input';
|
|
8
|
-
import Link from '../components-core/link';
|
|
9
|
-
import Label from '../components-core/label';
|
|
10
|
-
import Text from '../components-core/text';
|
|
11
|
-
import Card from '../components-core/card';
|
|
4
|
+
import { Button } from '../components-core/button';
|
|
5
|
+
import { Container } from '../components-core/container';
|
|
6
|
+
import { Separator } from '../components-core/separator';
|
|
7
|
+
import { Input } from '../components-core/input';
|
|
8
|
+
import { Link } from '../components-core/link';
|
|
9
|
+
import { Label } from '../components-core/label';
|
|
10
|
+
import { Text } from '../components-core/text';
|
|
11
|
+
import { Card, CardHeader, CardContent, CardFooter } from '../components-core/card';
|
|
12
|
+
import { Popover, PopoverTrigger, PopoverContent } from '../components-core/popover';
|
|
13
|
+
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, } from '../components-core/dropdown';
|
|
14
|
+
import { Avatar, AvatarFallback, AvatarImage } from '../components-core/avatar';
|
|
15
|
+
import { Collapsible, CollapsibleTrigger, CollapsibleContent } from '../components-core/collapsible';
|
|
16
|
+
export const Components = {
|
|
17
|
+
Input,
|
|
18
|
+
Button,
|
|
19
|
+
Container,
|
|
20
|
+
Separator,
|
|
21
|
+
Label,
|
|
22
|
+
Link,
|
|
23
|
+
Text,
|
|
24
|
+
Popover,
|
|
25
|
+
PopoverTrigger,
|
|
26
|
+
PopoverContent,
|
|
27
|
+
DropdownMenu,
|
|
28
|
+
DropdownMenuTrigger,
|
|
29
|
+
DropdownMenuContent,
|
|
30
|
+
DropdownMenuItem,
|
|
31
|
+
DropdownMenuLabel,
|
|
32
|
+
DropdownMenuSeparator,
|
|
33
|
+
Avatar,
|
|
34
|
+
AvatarFallback,
|
|
35
|
+
AvatarImage,
|
|
36
|
+
Collapsible,
|
|
37
|
+
CollapsibleTrigger,
|
|
38
|
+
CollapsibleContent,
|
|
39
|
+
Card,
|
|
40
|
+
CardHeader,
|
|
41
|
+
CardContent,
|
|
42
|
+
CardFooter,
|
|
43
|
+
};
|
|
12
44
|
const ComponentContext = createContext(undefined);
|
|
13
45
|
export function useComponents() {
|
|
14
46
|
const context = useContext(ComponentContext);
|
|
@@ -18,14 +50,5 @@ export function useComponents() {
|
|
|
18
50
|
return context;
|
|
19
51
|
}
|
|
20
52
|
export function StackComponentProvider(props) {
|
|
21
|
-
return (_jsx(ComponentContext.Provider, { value: {
|
|
22
|
-
Button: props.components?.Button || Button,
|
|
23
|
-
Container: props.components?.Container || Container,
|
|
24
|
-
Divider: props.components?.Divider || Divider,
|
|
25
|
-
Input: props.components?.Input || Input,
|
|
26
|
-
Label: props.components?.Label || Label,
|
|
27
|
-
Link: props.components?.Link || Link,
|
|
28
|
-
Text: props.components?.Text || Text,
|
|
29
|
-
Card: props.components?.Card || Card
|
|
30
|
-
}, children: props.children }));
|
|
53
|
+
return (_jsx(ComponentContext.Provider, { value: { ...Components, ...props.components }, children: props.children }));
|
|
31
54
|
}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ThemeConfig } from "./theme-provider";
|
|
3
|
-
import Button from '../components-core-joy/button';
|
|
4
|
-
import Input from '../components-core-joy/input';
|
|
5
|
-
import Text from '../components-core-joy/text';
|
|
6
|
-
import Divider from '../components-core-joy/divider';
|
|
7
|
-
import { Card } from '../components-core-joy/card';
|
|
8
3
|
export declare const defaultComponents: {
|
|
9
|
-
Button:
|
|
10
|
-
Input:
|
|
11
|
-
Text:
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
Button: import("react").ForwardRefExoticComponent<Omit<Omit<Omit<import("../components-core/button").ButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
5
|
+
Input: import("react").ForwardRefExoticComponent<Omit<Omit<Omit<import("react").InputHTMLAttributes<HTMLInputElement> & Pick<import("react").HTMLProps<HTMLInputElement>, "ref">, "ref"> & import("react").RefAttributes<HTMLInputElement>, "ref"> & import("react").RefAttributes<HTMLInputElement>, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
6
|
+
Text: import("react").ForwardRefExoticComponent<Omit<Omit<Omit<{
|
|
7
|
+
variant?: "primary" | "secondary" | "warning" | "success" | undefined;
|
|
8
|
+
as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | undefined;
|
|
9
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
|
|
10
|
+
} & Omit<import("react").HTMLProps<HTMLParagraphElement>, "size">, "ref"> & import("react").RefAttributes<HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
|
|
11
|
+
Separator: import("react").ForwardRefExoticComponent<Omit<Omit<Omit<import("@radix-ui/react-separator").SeparatorProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLHRElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
12
|
};
|
|
15
13
|
export declare function StackJoyTheme(props: {
|
|
16
14
|
theme?: ThemeConfig;
|
|
17
15
|
children?: React.ReactNode;
|
|
18
16
|
}): import("react/jsx-runtime").JSX.Element;
|
|
19
|
-
//# sourceMappingURL=joy-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joy-provider.d.ts","sourceRoot":"","sources":["../../src/providers/joy-provider.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAc,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"joy-provider.d.ts","sourceRoot":"","sources":["../../src/providers/joy-provider.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAc,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAO3D,eAAO,MAAM,iBAAiB;;;;;;;;;CAK7B,CAAC;AAEF,wBAAgB,aAAa,CAAC,KAAK,EAAG;IAAE,KAAK,CAAC,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAiBxF"}
|
|
@@ -2,17 +2,15 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { StackTheme } from "./theme-provider";
|
|
4
4
|
import { useColorScheme } from "@mui/joy";
|
|
5
|
-
import Button from '../components-core-joy/button';
|
|
6
|
-
import Input from '../components-core-joy/input';
|
|
7
|
-
import Text from '../components-core-joy/text';
|
|
8
|
-
import
|
|
9
|
-
import { Card } from '../components-core-joy/card';
|
|
5
|
+
import { Button } from '../components-core-joy/button';
|
|
6
|
+
import { Input } from '../components-core-joy/input';
|
|
7
|
+
import { Text } from '../components-core-joy/text';
|
|
8
|
+
import { Separator } from '../components-core-joy/separator';
|
|
10
9
|
export const defaultComponents = {
|
|
11
10
|
Button,
|
|
12
11
|
Input,
|
|
13
12
|
Text,
|
|
14
|
-
|
|
15
|
-
Card,
|
|
13
|
+
Separator,
|
|
16
14
|
};
|
|
17
15
|
export function StackJoyTheme(props) {
|
|
18
16
|
const { mode, systemMode, setMode } = useColorScheme();
|
|
@@ -21,7 +19,7 @@ export function StackJoyTheme(props) {
|
|
|
21
19
|
...defaultComponents,
|
|
22
20
|
...props.theme?.components,
|
|
23
21
|
},
|
|
24
|
-
colorMode: mode === 'system' ? systemMode : mode,
|
|
22
|
+
colorMode: (mode === 'system' ? systemMode : mode) || 'light',
|
|
25
23
|
setColorMode: setMode,
|
|
26
24
|
...props.theme,
|
|
27
25
|
};
|
|
@@ -8,4 +8,3 @@ export declare function StackTheme({ theme, children, colorModeConfig, }: {
|
|
|
8
8
|
theme?: DesignConfig & ComponentConfig;
|
|
9
9
|
colorModeConfig?: Omit<ComponentProps<typeof NextThemeProvider>, "themes" | "children">;
|
|
10
10
|
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
//# sourceMappingURL=theme-provider.d.ts.map
|