@ory/elements-react 1.0.0-next.16 → 1.0.0-next.18
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/CHANGELOG.md +44 -0
- package/api-report/elements-react-client.api.json +144 -16
- package/api-report/elements-react-client.api.md +19 -8
- package/api-report/elements-react-theme.api.json +197 -0
- package/api-report/elements-react-theme.api.md +17 -2
- package/api-report/elements-react.api.json +7 -3
- package/api-report/elements-react.api.md +4 -2
- package/api-report/temp/elements-react-client.api.md +33 -0
- package/api-report/temp/elements-react-theme.api.md +149 -0
- package/api-report/temp/elements-react.api.md +423 -0
- package/dist/client/config.d.mts +21 -0
- package/dist/client/config.d.ts +21 -0
- package/dist/client/config.js +77 -0
- package/dist/client/config.js.map +1 -0
- package/dist/client/config.mjs +51 -0
- package/dist/client/config.mjs.map +1 -0
- package/dist/client/frontendClient.d.mts +3 -1
- package/dist/client/frontendClient.d.ts +3 -1
- package/dist/client/frontendClient.js +14 -2
- package/dist/client/frontendClient.js.map +1 -1
- package/dist/client/frontendClient.mjs +14 -2
- package/dist/client/frontendClient.mjs.map +1 -1
- package/dist/client/index.d.mts +3 -1
- package/dist/client/index.d.ts +3 -1
- package/dist/client/index.js +4 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +5 -0
- package/dist/client/index.mjs.map +1 -1
- package/dist/client/session-provider.d.mts +62 -0
- package/dist/client/session-provider.d.ts +62 -0
- package/dist/client/session-provider.js +96 -0
- package/dist/client/session-provider.js.map +1 -0
- package/dist/client/session-provider.mjs +71 -0
- package/dist/client/session-provider.mjs.map +1 -0
- package/dist/client/useSession.d.mts +22 -31
- package/dist/client/useSession.d.ts +22 -31
- package/dist/client/useSession.js +7 -49
- package/dist/client/useSession.js.map +1 -1
- package/dist/client/useSession.mjs +8 -49
- package/dist/client/useSession.mjs.map +1 -1
- package/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +148 -62
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +151 -65
- package/dist/index.mjs.map +1 -1
- package/dist/theme/default/index.css +358 -251
- package/dist/theme/default/index.css.map +1 -1
- package/dist/theme/default/index.d.mts +14 -3
- package/dist/theme/default/index.d.ts +14 -3
- package/dist/theme/default/index.js +932 -837
- package/dist/theme/default/index.js.map +1 -1
- package/dist/theme/default/index.mjs +815 -715
- package/dist/theme/default/index.mjs.map +1 -1
- package/jest.config.ts +7 -1
- package/package.json +2 -1
- package/postcss.config.ts +1 -0
- package/tailwind.config.ts +14 -13
- package/tsconfig.json +4 -3
- package/variables-processed.json +385 -187
- package/.eslintrc.js +0 -63
|
@@ -1,41 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { SessionContextData } from './session-provider.js';
|
|
2
|
+
import 'react/jsx-runtime';
|
|
3
|
+
import 'react';
|
|
4
|
+
import '@ory/client-fetch';
|
|
3
5
|
|
|
4
|
-
type SessionStore = {
|
|
5
|
-
setIsLoading: (loading: boolean) => void;
|
|
6
|
-
setSession: (session: Session) => void;
|
|
7
|
-
isLoading: boolean;
|
|
8
|
-
session: Session | undefined;
|
|
9
|
-
error: string | undefined;
|
|
10
|
-
setError: (error: string | undefined) => void;
|
|
11
|
-
};
|
|
12
|
-
declare const sessionStore: zustand.UseBoundStore<Omit<zustand.StoreApi<SessionStore>, "subscribe"> & {
|
|
13
|
-
subscribe: {
|
|
14
|
-
(listener: (selectedState: SessionStore, previousSelectedState: SessionStore) => void): () => void;
|
|
15
|
-
<U>(selector: (state: SessionStore) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
16
|
-
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
17
|
-
fireImmediately?: boolean | undefined;
|
|
18
|
-
} | undefined): () => void;
|
|
19
|
-
};
|
|
20
|
-
}>;
|
|
21
6
|
/**
|
|
22
7
|
* A hook to get the current session from the Ory Network.
|
|
23
8
|
*
|
|
24
9
|
* Usage:
|
|
25
10
|
* ```ts
|
|
26
|
-
* const
|
|
11
|
+
* const session = useSession()
|
|
12
|
+
*
|
|
13
|
+
* if (session.state == "loading") {
|
|
14
|
+
* return <div>Loading...</div>
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* if (session.state == "authenticated") {
|
|
18
|
+
* return <div>Session: {session.session.id}</div>
|
|
19
|
+
* }
|
|
27
20
|
* ```
|
|
28
21
|
*
|
|
29
|
-
*
|
|
22
|
+
* :::note
|
|
23
|
+
* This is a client-side hook and must be used within a React component.
|
|
24
|
+
* On the server, you can use the getServerSession function from `@ory/nextjs`
|
|
25
|
+
* and hydrate SessionProvider with the session.
|
|
26
|
+
* :::
|
|
27
|
+
*
|
|
28
|
+
* @returns The current session, and error or loading state.
|
|
30
29
|
*/
|
|
31
|
-
declare
|
|
32
|
-
sdk: {
|
|
33
|
-
url: string;
|
|
34
|
-
};
|
|
35
|
-
}) => {
|
|
36
|
-
session: Session | undefined;
|
|
37
|
-
error: string | undefined;
|
|
38
|
-
isLoading: boolean;
|
|
39
|
-
};
|
|
30
|
+
declare function useSession(): SessionContextData;
|
|
40
31
|
|
|
41
|
-
export {
|
|
32
|
+
export { useSession };
|
|
@@ -19,61 +19,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
var useSession_exports = {};
|
|
21
21
|
__export(useSession_exports, {
|
|
22
|
-
sessionStore: () => sessionStore,
|
|
23
22
|
useSession: () => useSession
|
|
24
23
|
});
|
|
25
24
|
module.exports = __toCommonJS(useSession_exports);
|
|
26
25
|
var import_react = require("react");
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
session: void 0,
|
|
35
|
-
setSession: (session) => set({ session }),
|
|
36
|
-
error: void 0,
|
|
37
|
-
setError: (error) => set({ error })
|
|
38
|
-
}))
|
|
39
|
-
);
|
|
40
|
-
const useSession = (config) => {
|
|
41
|
-
const store = (0, import_zustand.useStore)(sessionStore);
|
|
42
|
-
const fetchSession = (0, import_react.useCallback)(async () => {
|
|
43
|
-
var _a;
|
|
44
|
-
const { session, isLoading, setSession, setIsLoading, setError } = sessionStore.getState();
|
|
45
|
-
if (!!session || isLoading) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
setIsLoading(true);
|
|
49
|
-
try {
|
|
50
|
-
const sessionData = await (0, import_frontendClient.frontendClient)(
|
|
51
|
-
(_a = config == null ? void 0 : config.sdk.url) != null ? _a : window.location.protocol + "//" + window.location.host
|
|
52
|
-
).toSession();
|
|
53
|
-
setSession(sessionData);
|
|
54
|
-
} catch (e) {
|
|
55
|
-
setError(e instanceof Error ? e.message : "Unknown error occurred");
|
|
56
|
-
if (!(config == null ? void 0 : config.sdk.url)) {
|
|
57
|
-
console.error(
|
|
58
|
-
"Could not fetch session. Make sure you have set the SDK URL in the config."
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
} finally {
|
|
62
|
-
setIsLoading(false);
|
|
63
|
-
}
|
|
64
|
-
}, [config == null ? void 0 : config.sdk.url]);
|
|
65
|
-
(0, import_react.useEffect)(() => {
|
|
66
|
-
void fetchSession();
|
|
67
|
-
}, [fetchSession]);
|
|
68
|
-
return {
|
|
69
|
-
session: store.session,
|
|
70
|
-
error: store.error,
|
|
71
|
-
isLoading: store.isLoading
|
|
72
|
-
};
|
|
73
|
-
};
|
|
26
|
+
var import_session_provider = require("./session-provider");
|
|
27
|
+
function useSession() {
|
|
28
|
+
if (!import_session_provider.SessionContext) {
|
|
29
|
+
throw new Error("[Ory/Elements] useSession must be used on the client");
|
|
30
|
+
}
|
|
31
|
+
return (0, import_react.useContext)(import_session_provider.SessionContext);
|
|
32
|
+
}
|
|
74
33
|
// Annotate the CommonJS export names for ESM import in node:
|
|
75
34
|
0 && (module.exports = {
|
|
76
|
-
sessionStore,
|
|
77
35
|
useSession
|
|
78
36
|
});
|
|
79
37
|
//# sourceMappingURL=useSession.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/useSession.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\"use client\"\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/client/useSession.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\"use client\"\n\nimport { useContext } from \"react\"\nimport { SessionContext } from \"./session-provider\"\n\n/**\n * A hook to get the current session from the Ory Network.\n *\n * Usage:\n * ```ts\n * const session = useSession()\n *\n * if (session.state == \"loading\") {\n * return <div>Loading...</div>\n * }\n *\n * if (session.state == \"authenticated\") {\n * return <div>Session: {session.session.id}</div>\n * }\n * ```\n *\n * :::note\n * This is a client-side hook and must be used within a React component.\n * On the server, you can use the getServerSession function from `@ory/nextjs`\n * and hydrate SessionProvider with the session.\n * :::\n *\n * @returns The current session, and error or loading state.\n */\n\nexport function useSession() {\n if (!SessionContext) {\n throw new Error(\"[Ory/Elements] useSession must be used on the client\")\n }\n return useContext(SessionContext)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,mBAA2B;AAC3B,8BAA+B;AA2BxB,SAAS,aAAa;AAC3B,MAAI,CAAC,wCAAgB;AACnB,UAAM,IAAI,MAAM,sDAAsD;AAAA,EACxE;AACA,aAAO,yBAAW,sCAAc;AAClC;","names":[]}
|
|
@@ -1,54 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
session: void 0,
|
|
11
|
-
setSession: (session) => set({ session }),
|
|
12
|
-
error: void 0,
|
|
13
|
-
setError: (error) => set({ error })
|
|
14
|
-
}))
|
|
15
|
-
);
|
|
16
|
-
const useSession = (config) => {
|
|
17
|
-
const store = useStore(sessionStore);
|
|
18
|
-
const fetchSession = useCallback(async () => {
|
|
19
|
-
var _a;
|
|
20
|
-
const { session, isLoading, setSession, setIsLoading, setError } = sessionStore.getState();
|
|
21
|
-
if (!!session || isLoading) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
setIsLoading(true);
|
|
25
|
-
try {
|
|
26
|
-
const sessionData = await frontendClient(
|
|
27
|
-
(_a = config == null ? void 0 : config.sdk.url) != null ? _a : window.location.protocol + "//" + window.location.host
|
|
28
|
-
).toSession();
|
|
29
|
-
setSession(sessionData);
|
|
30
|
-
} catch (e) {
|
|
31
|
-
setError(e instanceof Error ? e.message : "Unknown error occurred");
|
|
32
|
-
if (!(config == null ? void 0 : config.sdk.url)) {
|
|
33
|
-
console.error(
|
|
34
|
-
"Could not fetch session. Make sure you have set the SDK URL in the config."
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
} finally {
|
|
38
|
-
setIsLoading(false);
|
|
39
|
-
}
|
|
40
|
-
}, [config == null ? void 0 : config.sdk.url]);
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
void fetchSession();
|
|
43
|
-
}, [fetchSession]);
|
|
44
|
-
return {
|
|
45
|
-
session: store.session,
|
|
46
|
-
error: store.error,
|
|
47
|
-
isLoading: store.isLoading
|
|
48
|
-
};
|
|
49
|
-
};
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { SessionContext } from "./session-provider";
|
|
4
|
+
function useSession() {
|
|
5
|
+
if (!SessionContext) {
|
|
6
|
+
throw new Error("[Ory/Elements] useSession must be used on the client");
|
|
7
|
+
}
|
|
8
|
+
return useContext(SessionContext);
|
|
9
|
+
}
|
|
50
10
|
export {
|
|
51
|
-
sessionStore,
|
|
52
11
|
useSession
|
|
53
12
|
};
|
|
54
13
|
//# sourceMappingURL=useSession.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/useSession.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\"use client\"\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/client/useSession.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\"use client\"\n\nimport { useContext } from \"react\"\nimport { SessionContext } from \"./session-provider\"\n\n/**\n * A hook to get the current session from the Ory Network.\n *\n * Usage:\n * ```ts\n * const session = useSession()\n *\n * if (session.state == \"loading\") {\n * return <div>Loading...</div>\n * }\n *\n * if (session.state == \"authenticated\") {\n * return <div>Session: {session.session.id}</div>\n * }\n * ```\n *\n * :::note\n * This is a client-side hook and must be used within a React component.\n * On the server, you can use the getServerSession function from `@ory/nextjs`\n * and hydrate SessionProvider with the session.\n * :::\n *\n * @returns The current session, and error or loading state.\n */\n\nexport function useSession() {\n if (!SessionContext) {\n throw new Error(\"[Ory/Elements] useSession must be used on the client\")\n }\n return useContext(SessionContext)\n}\n"],"mappings":";AAIA,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AA2BxB,SAAS,aAAa;AAC3B,MAAI,CAAC,gBAAgB;AACnB,UAAM,IAAI,MAAM,sDAAsD;AAAA,EACxE;AACA,SAAO,WAAW,cAAc;AAClC;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -7,8 +7,7 @@ import { IntlShape } from 'react-intl';
|
|
|
7
7
|
|
|
8
8
|
declare const buttonStyles: (props?: ({
|
|
9
9
|
intent?: "primary" | "secondary" | null | undefined;
|
|
10
|
-
|
|
11
|
-
defaultVariants?: "intent" | "size" | null | undefined;
|
|
10
|
+
defaultVariants?: "intent" | null | undefined;
|
|
12
11
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
13
12
|
type ButtonVariants = VariantProps<typeof buttonStyles>;
|
|
14
13
|
|
|
@@ -57,7 +56,9 @@ type OryFormSectionContentProps = PropsWithChildren<{
|
|
|
57
56
|
title?: string;
|
|
58
57
|
description?: string;
|
|
59
58
|
}>;
|
|
60
|
-
type OryFormSectionFooterProps = PropsWithChildren
|
|
59
|
+
type OryFormSectionFooterProps = PropsWithChildren<{
|
|
60
|
+
text?: string;
|
|
61
|
+
}>;
|
|
61
62
|
|
|
62
63
|
type OryCardHeaderProps = Record<string, never>;
|
|
63
64
|
declare function OryCardHeader(): react_jsx_runtime.JSX.Element;
|
|
@@ -266,7 +267,7 @@ type OryFlowComponents = {
|
|
|
266
267
|
/**
|
|
267
268
|
* The SettingsSectionFooter component is rendered around the footer of each section of the settings.
|
|
268
269
|
*/
|
|
269
|
-
SettingsSectionFooter: ComponentType<
|
|
270
|
+
SettingsSectionFooter: ComponentType<OryFormSectionFooterProps>;
|
|
270
271
|
};
|
|
271
272
|
Form: {
|
|
272
273
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -7,8 +7,7 @@ import { IntlShape } from 'react-intl';
|
|
|
7
7
|
|
|
8
8
|
declare const buttonStyles: (props?: ({
|
|
9
9
|
intent?: "primary" | "secondary" | null | undefined;
|
|
10
|
-
|
|
11
|
-
defaultVariants?: "intent" | "size" | null | undefined;
|
|
10
|
+
defaultVariants?: "intent" | null | undefined;
|
|
12
11
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
13
12
|
type ButtonVariants = VariantProps<typeof buttonStyles>;
|
|
14
13
|
|
|
@@ -57,7 +56,9 @@ type OryFormSectionContentProps = PropsWithChildren<{
|
|
|
57
56
|
title?: string;
|
|
58
57
|
description?: string;
|
|
59
58
|
}>;
|
|
60
|
-
type OryFormSectionFooterProps = PropsWithChildren
|
|
59
|
+
type OryFormSectionFooterProps = PropsWithChildren<{
|
|
60
|
+
text?: string;
|
|
61
|
+
}>;
|
|
61
62
|
|
|
62
63
|
type OryCardHeaderProps = Record<string, never>;
|
|
63
64
|
declare function OryCardHeader(): react_jsx_runtime.JSX.Element;
|
|
@@ -266,7 +267,7 @@ type OryFlowComponents = {
|
|
|
266
267
|
/**
|
|
267
268
|
* The SettingsSectionFooter component is rendered around the footer of each section of the settings.
|
|
268
269
|
*/
|
|
269
|
-
SettingsSectionFooter: ComponentType<
|
|
270
|
+
SettingsSectionFooter: ComponentType<OryFormSectionFooterProps>;
|
|
270
271
|
};
|
|
271
272
|
Form: {
|
|
272
273
|
/**
|