@ory/elements-react 1.0.0-next.11 → 1.0.0-next.13

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 (47) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/api-report/elements-react-client.api.json +228 -0
  3. package/api-report/elements-react-client.api.md +22 -0
  4. package/api-report/elements-react-theme.api.json +47 -24
  5. package/api-report/elements-react-theme.api.md +6 -5
  6. package/api-report/elements-react.api.json +710 -86
  7. package/api-report/elements-react.api.md +86 -11
  8. package/api-report/temp/elements-react-client.api.md +22 -0
  9. package/api-report/temp/elements-react-theme.api.md +6 -5
  10. package/api-report/temp/elements-react.api.md +86 -11
  11. package/config/api-extractor-client.json +463 -0
  12. package/dist/client/frontendClient.d.mts +5 -0
  13. package/dist/client/frontendClient.d.ts +5 -0
  14. package/dist/client/frontendClient.js +40 -0
  15. package/dist/client/frontendClient.js.map +1 -0
  16. package/dist/client/frontendClient.mjs +19 -0
  17. package/dist/client/frontendClient.mjs.map +1 -0
  18. package/dist/client/index.d.mts +3 -0
  19. package/dist/client/index.d.ts +3 -0
  20. package/dist/client/index.js +29 -0
  21. package/dist/client/index.js.map +1 -0
  22. package/dist/client/index.mjs +5 -0
  23. package/dist/client/index.mjs.map +1 -0
  24. package/dist/client/useSession.d.mts +41 -0
  25. package/dist/client/useSession.d.ts +41 -0
  26. package/dist/client/useSession.js +79 -0
  27. package/dist/client/useSession.js.map +1 -0
  28. package/dist/client/useSession.mjs +54 -0
  29. package/dist/client/useSession.mjs.map +1 -0
  30. package/dist/index.d.mts +97 -21
  31. package/dist/index.d.ts +97 -21
  32. package/dist/index.js +718 -5691
  33. package/dist/index.js.map +1 -1
  34. package/dist/index.mjs +712 -5687
  35. package/dist/index.mjs.map +1 -1
  36. package/dist/theme/default/index.css +295 -29
  37. package/dist/theme/default/index.css.map +1 -1
  38. package/dist/theme/default/index.d.mts +3 -3
  39. package/dist/theme/default/index.d.ts +3 -3
  40. package/dist/theme/default/index.js +1058 -292
  41. package/dist/theme/default/index.js.map +1 -1
  42. package/dist/theme/default/index.mjs +1030 -256
  43. package/dist/theme/default/index.mjs.map +1 -1
  44. package/jest.config.ts +4 -3
  45. package/package.json +17 -8
  46. package/tailwind.config.ts +6 -1
  47. package/tsconfig.json +5 -5
@@ -0,0 +1,41 @@
1
+ import * as zustand from 'zustand';
2
+ import { Session } from '@ory/client-fetch';
3
+
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
+ /**
22
+ * A hook to get the current session from the Ory Network.
23
+ *
24
+ * Usage:
25
+ * ```ts
26
+ * const { session, error, isLoading } = useSession()
27
+ * ```
28
+ *
29
+ * @returns The current session, error and loading state.
30
+ */
31
+ declare const useSession: (config?: {
32
+ sdk: {
33
+ url: string;
34
+ };
35
+ }) => {
36
+ session: Session | undefined;
37
+ error: string | undefined;
38
+ isLoading: boolean;
39
+ };
40
+
41
+ export { sessionStore, useSession };
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var useSession_exports = {};
21
+ __export(useSession_exports, {
22
+ sessionStore: () => sessionStore,
23
+ useSession: () => useSession
24
+ });
25
+ module.exports = __toCommonJS(useSession_exports);
26
+ var import_react = require("react");
27
+ var import_zustand = require("zustand");
28
+ var import_middleware = require("zustand/middleware");
29
+ var import_frontendClient = require("./frontendClient");
30
+ const sessionStore = (0, import_zustand.create)()(
31
+ (0, import_middleware.subscribeWithSelector)((set) => ({
32
+ isLoading: false,
33
+ setIsLoading: (isLoading) => set({ isLoading }),
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
+ };
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ sessionStore,
77
+ useSession
78
+ });
79
+ //# sourceMappingURL=useSession.js.map
@@ -0,0 +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 { Session } from \"@ory/client-fetch\"\nimport { useCallback, useEffect } from \"react\"\nimport { create, useStore } from \"zustand\"\nimport { subscribeWithSelector } from \"zustand/middleware\"\nimport { frontendClient } from \"./frontendClient\"\n\ntype SessionStore = {\n setIsLoading: (loading: boolean) => void\n setSession: (session: Session) => void\n isLoading: boolean\n session: Session | undefined\n error: string | undefined\n setError: (error: string | undefined) => void\n}\n\nexport const sessionStore = create<SessionStore>()(\n subscribeWithSelector((set) => ({\n isLoading: false,\n setIsLoading: (isLoading: boolean) => set({ isLoading }),\n session: undefined,\n setSession: (session: Session) => set({ session }),\n error: undefined,\n setError: (error: string | undefined) => set({ error }),\n })),\n)\n\n/**\n * A hook to get the current session from the Ory Network.\n *\n * Usage:\n * ```ts\n * const { session, error, isLoading } = useSession()\n * ```\n *\n * @returns The current session, error and loading state.\n */\nexport const useSession = (config?: { sdk: { url: string } }) => {\n const store = useStore(sessionStore)\n\n const fetchSession = useCallback(async () => {\n const { session, isLoading, setSession, setIsLoading, setError } =\n sessionStore.getState()\n\n if (!!session || isLoading) {\n return\n }\n\n setIsLoading(true)\n\n try {\n const sessionData = await frontendClient(\n config?.sdk.url ??\n window.location.protocol + \"//\" + window.location.host,\n ).toSession()\n setSession(sessionData)\n } catch (e) {\n setError(e instanceof Error ? e.message : \"Unknown error occurred\")\n if (!config?.sdk.url) {\n console.error(\n \"Could not fetch session. Make sure you have set the SDK URL in the config.\",\n )\n }\n } finally {\n setIsLoading(false)\n }\n }, [config?.sdk.url])\n\n useEffect(() => {\n void fetchSession()\n }, [fetchSession])\n\n return {\n session: store.session,\n error: store.error,\n isLoading: store.isLoading,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,mBAAuC;AACvC,qBAAiC;AACjC,wBAAsC;AACtC,4BAA+B;AAWxB,MAAM,mBAAe,uBAAqB;AAAA,MAC/C,yCAAsB,CAAC,SAAS;AAAA,IAC9B,WAAW;AAAA,IACX,cAAc,CAAC,cAAuB,IAAI,EAAE,UAAU,CAAC;AAAA,IACvD,SAAS;AAAA,IACT,YAAY,CAAC,YAAqB,IAAI,EAAE,QAAQ,CAAC;AAAA,IACjD,OAAO;AAAA,IACP,UAAU,CAAC,UAA8B,IAAI,EAAE,MAAM,CAAC;AAAA,EACxD,EAAE;AACJ;AAYO,MAAM,aAAa,CAAC,WAAsC;AAC/D,QAAM,YAAQ,yBAAS,YAAY;AAEnC,QAAM,mBAAe,0BAAY,YAAY;AA3C/C;AA4CI,UAAM,EAAE,SAAS,WAAW,YAAY,cAAc,SAAS,IAC7D,aAAa,SAAS;AAExB,QAAI,CAAC,CAAC,WAAW,WAAW;AAC1B;AAAA,IACF;AAEA,iBAAa,IAAI;AAEjB,QAAI;AACF,YAAM,cAAc,UAAM;AAAA,SACxB,sCAAQ,IAAI,QAAZ,YACE,OAAO,SAAS,WAAW,OAAO,OAAO,SAAS;AAAA,MACtD,EAAE,UAAU;AACZ,iBAAW,WAAW;AAAA,IACxB,SAAS,GAAG;AACV,eAAS,aAAa,QAAQ,EAAE,UAAU,wBAAwB;AAClE,UAAI,EAAC,iCAAQ,IAAI,MAAK;AACpB,gBAAQ;AAAA,UACN;AAAA,QACF;AAAA,MACF;AAAA,IACF,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,iCAAQ,IAAI,GAAG,CAAC;AAEpB,8BAAU,MAAM;AACd,SAAK,aAAa;AAAA,EACpB,GAAG,CAAC,YAAY,CAAC;AAEjB,SAAO;AAAA,IACL,SAAS,MAAM;AAAA,IACf,OAAO,MAAM;AAAA,IACb,WAAW,MAAM;AAAA,EACnB;AACF;","names":[]}
@@ -0,0 +1,54 @@
1
+ "use client";
2
+ import { useCallback, useEffect } from "react";
3
+ import { create, useStore } from "zustand";
4
+ import { subscribeWithSelector } from "zustand/middleware";
5
+ import { frontendClient } from "./frontendClient";
6
+ const sessionStore = create()(
7
+ subscribeWithSelector((set) => ({
8
+ isLoading: false,
9
+ setIsLoading: (isLoading) => set({ isLoading }),
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
+ };
50
+ export {
51
+ sessionStore,
52
+ useSession
53
+ };
54
+ //# sourceMappingURL=useSession.mjs.map
@@ -0,0 +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 { Session } from \"@ory/client-fetch\"\nimport { useCallback, useEffect } from \"react\"\nimport { create, useStore } from \"zustand\"\nimport { subscribeWithSelector } from \"zustand/middleware\"\nimport { frontendClient } from \"./frontendClient\"\n\ntype SessionStore = {\n setIsLoading: (loading: boolean) => void\n setSession: (session: Session) => void\n isLoading: boolean\n session: Session | undefined\n error: string | undefined\n setError: (error: string | undefined) => void\n}\n\nexport const sessionStore = create<SessionStore>()(\n subscribeWithSelector((set) => ({\n isLoading: false,\n setIsLoading: (isLoading: boolean) => set({ isLoading }),\n session: undefined,\n setSession: (session: Session) => set({ session }),\n error: undefined,\n setError: (error: string | undefined) => set({ error }),\n })),\n)\n\n/**\n * A hook to get the current session from the Ory Network.\n *\n * Usage:\n * ```ts\n * const { session, error, isLoading } = useSession()\n * ```\n *\n * @returns The current session, error and loading state.\n */\nexport const useSession = (config?: { sdk: { url: string } }) => {\n const store = useStore(sessionStore)\n\n const fetchSession = useCallback(async () => {\n const { session, isLoading, setSession, setIsLoading, setError } =\n sessionStore.getState()\n\n if (!!session || isLoading) {\n return\n }\n\n setIsLoading(true)\n\n try {\n const sessionData = await frontendClient(\n config?.sdk.url ??\n window.location.protocol + \"//\" + window.location.host,\n ).toSession()\n setSession(sessionData)\n } catch (e) {\n setError(e instanceof Error ? e.message : \"Unknown error occurred\")\n if (!config?.sdk.url) {\n console.error(\n \"Could not fetch session. Make sure you have set the SDK URL in the config.\",\n )\n }\n } finally {\n setIsLoading(false)\n }\n }, [config?.sdk.url])\n\n useEffect(() => {\n void fetchSession()\n }, [fetchSession])\n\n return {\n session: store.session,\n error: store.error,\n isLoading: store.isLoading,\n }\n}\n"],"mappings":";AAKA,SAAS,aAAa,iBAAiB;AACvC,SAAS,QAAQ,gBAAgB;AACjC,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAWxB,MAAM,eAAe,OAAqB;AAAA,EAC/C,sBAAsB,CAAC,SAAS;AAAA,IAC9B,WAAW;AAAA,IACX,cAAc,CAAC,cAAuB,IAAI,EAAE,UAAU,CAAC;AAAA,IACvD,SAAS;AAAA,IACT,YAAY,CAAC,YAAqB,IAAI,EAAE,QAAQ,CAAC;AAAA,IACjD,OAAO;AAAA,IACP,UAAU,CAAC,UAA8B,IAAI,EAAE,MAAM,CAAC;AAAA,EACxD,EAAE;AACJ;AAYO,MAAM,aAAa,CAAC,WAAsC;AAC/D,QAAM,QAAQ,SAAS,YAAY;AAEnC,QAAM,eAAe,YAAY,YAAY;AA3C/C;AA4CI,UAAM,EAAE,SAAS,WAAW,YAAY,cAAc,SAAS,IAC7D,aAAa,SAAS;AAExB,QAAI,CAAC,CAAC,WAAW,WAAW;AAC1B;AAAA,IACF;AAEA,iBAAa,IAAI;AAEjB,QAAI;AACF,YAAM,cAAc,MAAM;AAAA,SACxB,sCAAQ,IAAI,QAAZ,YACE,OAAO,SAAS,WAAW,OAAO,OAAO,SAAS;AAAA,MACtD,EAAE,UAAU;AACZ,iBAAW,WAAW;AAAA,IACxB,SAAS,GAAG;AACV,eAAS,aAAa,QAAQ,EAAE,UAAU,wBAAwB;AAClE,UAAI,EAAC,iCAAQ,IAAI,MAAK;AACpB,gBAAQ;AAAA,UACN;AAAA,QACF;AAAA,MACF;AAAA,IACF,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,iCAAQ,IAAI,GAAG,CAAC;AAEpB,YAAU,MAAM;AACd,SAAK,aAAa;AAAA,EACpB,GAAG,CAAC,YAAY,CAAC;AAEjB,SAAO;AAAA,IACL,SAAS,MAAM;AAAA,IACf,OAAO,MAAM;AAAA,IACb,WAAW,MAAM;AAAA,EACnB;AACF;","names":[]}
package/dist/index.d.mts CHANGED
@@ -1,12 +1,21 @@
1
- import { UiNodeInputAttributes, UiNode, UiNodeAnchorAttributes, UiNodeTextAttributes, UiNodeImageAttributes, UiNodeGroupEnum, UiText, ConfigurationParameters, FlowType, LoginFlow, RegistrationFlow, RecoveryFlow, VerificationFlow, SettingsFlow, FlowError, UpdateLoginFlowBody, UpdateRegistrationFlowBody, UpdateVerificationFlowBody, UpdateRecoveryFlowBody, UpdateSettingsFlowBody, OnRedirectHandler, Session } from '@ory/client-fetch';
1
+ import { UiNodeInputAttributes, UiNode, UiNodeAnchorAttributes, UiNodeTextAttributes, UiNodeImageAttributes, UiNodeGroupEnum, UiText, ConfigurationParameters, FlowType, LoginFlow, RegistrationFlow, RecoveryFlow, VerificationFlow, SettingsFlow, FlowError, UpdateLoginFlowBody, UpdateRegistrationFlowBody, UpdateVerificationFlowBody, UpdateRecoveryFlowBody, UpdateSettingsFlowBody, OnRedirectHandler } from '@ory/client-fetch';
2
2
  import { ComponentPropsWithoutRef, FormEventHandler, MouseEventHandler, PropsWithChildren, DetailedHTMLProps, HTMLAttributes, ComponentType, Dispatch } from 'react';
3
+ import * as class_variance_authority_types from 'class-variance-authority/types';
4
+ import { VariantProps } from 'class-variance-authority';
3
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
6
  import { IntlShape } from 'react-intl';
5
7
 
8
+ declare const buttonStyles: (props?: ({
9
+ intent?: "primary" | "secondary" | null | undefined;
10
+ size?: "default" | "large" | null | undefined;
11
+ defaultVariants?: "intent" | "size" | null | undefined;
12
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
13
+ type ButtonVariants = VariantProps<typeof buttonStyles>;
14
+
6
15
  type OryNodeButtonProps = {
7
16
  attributes: UiNodeInputAttributes;
8
17
  node: UiNode;
9
- } & Omit<ComponentPropsWithoutRef<"button">, "children">;
18
+ } & Omit<ComponentPropsWithoutRef<"button">, "children"> & ButtonVariants;
10
19
  type OryCurrentIdentifierProps = {
11
20
  attributes: UiNodeInputAttributes;
12
21
  node: UiNode;
@@ -50,6 +59,11 @@ type OryNodeInputProps = {
50
59
  node: UiNode;
51
60
  onClick?: MouseEventHandler;
52
61
  };
62
+ type OryFormSectionContentProps = PropsWithChildren<{
63
+ title?: string;
64
+ description?: string;
65
+ }>;
66
+ type OryFormSectionFooterProps = PropsWithChildren;
53
67
 
54
68
  type OryCardHeaderProps = Record<string, never>;
55
69
  declare function OryCardHeader(): react_jsx_runtime.JSX.Element;
@@ -130,6 +144,46 @@ type OryNodeOidcButtonProps = {
130
144
  declare function OryFormOidcButtons({ children, hideDivider, }: OryFormOidcButtonsProps): react_jsx_runtime.JSX.Element | null;
131
145
  declare function OryFormSocialButtonsForm(): react_jsx_runtime.JSX.Element | null;
132
146
 
147
+ type OryPageHeaderProps = Record<never, never>;
148
+ declare const HeadlessPageHeader: () => react_jsx_runtime.JSX.Element;
149
+
150
+ type OryFormSectionProps = PropsWithChildren<{
151
+ nodes?: UiNode[];
152
+ }>;
153
+ declare function OryFormSection({ children, nodes }: OryFormSectionProps): react_jsx_runtime.JSX.Element;
154
+
155
+ declare function OrySettingsCard(): react_jsx_runtime.JSX.Element;
156
+
157
+ type OrySettingsRecoveryCodesProps = {
158
+ codes: string[];
159
+ regnerateButton?: UiNode;
160
+ revealButton?: UiNode;
161
+ };
162
+ type OrySettingsTotpProps = {
163
+ totpImage: UiNode;
164
+ totpSecret: UiNode;
165
+ totpInput: UiNode;
166
+ } | {
167
+ totpUnlink: UiNode;
168
+ };
169
+ type OrySettingsOidcProps = {
170
+ linkButtons: UiNode[];
171
+ unlinkButtons: UiNode[];
172
+ };
173
+ type OrySettingsWebauthnProps = {
174
+ nameInput: UiNode;
175
+ triggerButton: UiNode & {
176
+ onClick: () => void;
177
+ };
178
+ removeButtons: UiNode[];
179
+ };
180
+ type OrySettingsPasskeyProps = {
181
+ triggerButton: UiNode & {
182
+ onClick: () => void;
183
+ };
184
+ removeButtons: UiNode[];
185
+ };
186
+
133
187
  /**
134
188
  * A record of all the components that are used in the OryForm component.
135
189
  */
@@ -213,6 +267,18 @@ type OryFlowComponents = {
213
267
  * This is only used, if login is configured to use identifier_first authentication.
214
268
  */
215
269
  AuthMethodListItem: ComponentType<OryCardAuthMethodListItemProps>;
270
+ /**
271
+ * The SettingsSection component is rendered around each section of the settings.
272
+ */
273
+ SettingsSection: ComponentType<OryFormSectionProps>;
274
+ /**
275
+ * The SettingsSectionContent component is rendered around the content of each section of the settings.
276
+ */
277
+ SettingsSectionContent: ComponentType<OryFormSectionContentProps>;
278
+ /**
279
+ * The SettingsSectionFooter component is rendered around the footer of each section of the settings.
280
+ */
281
+ SettingsSectionFooter: ComponentType<OryFormSectionContentProps>;
216
282
  };
217
283
  Form: {
218
284
  /**
@@ -235,6 +301,26 @@ type OryFlowComponents = {
235
301
  * The FormGroup is rendered around each group of nodes in the UI nodes.
236
302
  */
237
303
  Group: ComponentType<OryFormGroupProps>;
304
+ /**
305
+ * The section on the settings page, rendering the OIDC settings
306
+ */
307
+ OidcSettings: ComponentType<OrySettingsOidcProps>;
308
+ /**
309
+ * The section on the settings page, rendering the Webauthn settings
310
+ */
311
+ WebauthnSettings: ComponentType<OrySettingsWebauthnProps>;
312
+ /**
313
+ * The section on the settings page, rendering the Passkey settings
314
+ */
315
+ PasskeySettings: ComponentType<OrySettingsPasskeyProps>;
316
+ /**
317
+ * The section on the settings page, rendering the TOTP settings
318
+ */
319
+ TotpSettings: ComponentType<OrySettingsTotpProps>;
320
+ /**
321
+ * The section on the settings page, rendering the recovery code settings
322
+ */
323
+ RecoveryCodesSettings: ComponentType<OrySettingsRecoveryCodesProps>;
238
324
  };
239
325
  Message: {
240
326
  /**
@@ -246,6 +332,9 @@ type OryFlowComponents = {
246
332
  */
247
333
  Content: ComponentType<OryMessageContentProps>;
248
334
  };
335
+ Page: {
336
+ Header: ComponentType<OryPageHeaderProps>;
337
+ };
249
338
  };
250
339
  type DeepPartialTwoLevels<T> = {
251
340
  [P in keyof T]?: T[P] extends object ? {
@@ -253,8 +342,11 @@ type DeepPartialTwoLevels<T> = {
253
342
  } : T[P];
254
343
  };
255
344
  type OryFlowComponentOverrides = DeepPartialTwoLevels<OryFlowComponents>;
256
- type OryFormProps = PropsWithChildren;
257
- declare function OryForm({ children }: OryFormProps): string | react_jsx_runtime.JSX.Element;
345
+ type OryFormProps = PropsWithChildren<{
346
+ onAfterSubmit?: (method: string | number | boolean | undefined) => void;
347
+ nodes?: UiNode[];
348
+ }>;
349
+ declare function OryForm({ children, onAfterSubmit, nodes }: OryFormProps): string | react_jsx_runtime.JSX.Element;
258
350
 
259
351
  declare function useComponents(): OryFlowComponents;
260
352
  declare function useNodeSorter(): (a: UiNode, b: UiNode, ctx: {
@@ -454,20 +546,4 @@ declare function messageTestId(message: UiText): {
454
546
  "data-testid": string;
455
547
  };
456
548
 
457
- /**
458
- * A hook to get the current session from the Ory Network.
459
- *
460
- * Usage:
461
- * ```ts
462
- * const { session, error, isLoading } = useSession()
463
- * ```
464
- *
465
- * @returns The current session, error and loading state.
466
- */
467
- declare const useSession: () => {
468
- session: Session | undefined;
469
- error: string | undefined;
470
- isLoading: boolean;
471
- };
472
-
473
- export { type ErrorFlowContainer, type FlowContainerSetter, type FlowContextValue, type FormValues, type IntlConfig, type LoginFlowContainer, type OnSubmitHandlerProps, OryCard, type OryCardAuthMethodListItemProps, OryCardContent, type OryCardContentProps, type OryCardDividerProps, OryCardFooter, type OryCardFooterProps, OryCardHeader, type OryCardHeaderProps, type OryCardLogoProps, type OryCardRootProps as OryCardProps, OryCardValidationMessages, type OryClientConfiguration, type OryCurrentIdentifierProps, type OryFlowComponentOverrides, type OryFlowComponents, type OryFlowContainer, OryForm, OryFormGroupDivider, type OryFormGroupProps, OryFormGroups, type OryFormGroupsProps, OryFormOidcButtons, type OryFormOidcButtonsProps, type OryFormOidcRootProps, type OryFormProps, type OryFormRootProps, OryFormSocialButtonsForm, locales as OryLocales, type OryMessageContentProps, type OryMessageRootProps, type OryNodeAnchorProps, type OryNodeButtonProps, type OryNodeImageProps, type OryNodeInputProps, type OryNodeLabelProps, type OryNodeOidcButtonProps, type OryNodeTextProps, OryProvider, type OryProviderProps, OryTwoStepCard, type RecoveryFlowContainer, type RegistrationFlowContainer, type SettingsFlowContainer, type VerificationFlowContainer, messageTestId, uiTextToFormattedMessage, useComponents, useNodeSorter, useOryFlow, useSession };
549
+ export { type ErrorFlowContainer, type FlowContainerSetter, type FlowContextValue, type FormValues, HeadlessPageHeader, type IntlConfig, type LoginFlowContainer, type OnSubmitHandlerProps, OryCard, type OryCardAuthMethodListItemProps, OryCardContent, type OryCardContentProps, type OryCardDividerProps, OryCardFooter, type OryCardFooterProps, OryCardHeader, type OryCardHeaderProps, type OryCardLogoProps, type OryCardRootProps as OryCardProps, OryCardValidationMessages, type OryClientConfiguration, type OryCurrentIdentifierProps, type OryFlowComponentOverrides, type OryFlowComponents, type OryFlowContainer, OryForm, OryFormGroupDivider, type OryFormGroupProps, OryFormGroups, type OryFormGroupsProps, OryFormOidcButtons, type OryFormOidcButtonsProps, type OryFormOidcRootProps, type OryFormProps, type OryFormRootProps, OryFormSection, type OryFormSectionContentProps, type OryFormSectionFooterProps, type OryFormSectionProps, OryFormSocialButtonsForm, locales as OryLocales, type OryMessageContentProps, type OryMessageRootProps, type OryNodeAnchorProps, type OryNodeButtonProps, type OryNodeImageProps, type OryNodeInputProps, type OryNodeLabelProps, type OryNodeOidcButtonProps, type OryNodeTextProps, type OryPageHeaderProps, OryProvider, type OryProviderProps, OrySettingsCard, type OrySettingsOidcProps, type OrySettingsPasskeyProps, type OrySettingsRecoveryCodesProps, type OrySettingsTotpProps, type OrySettingsWebauthnProps, OryTwoStepCard, type RecoveryFlowContainer, type RegistrationFlowContainer, type SettingsFlowContainer, type VerificationFlowContainer, messageTestId, uiTextToFormattedMessage, useComponents, useNodeSorter, useOryFlow };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,21 @@
1
- import { UiNodeInputAttributes, UiNode, UiNodeAnchorAttributes, UiNodeTextAttributes, UiNodeImageAttributes, UiNodeGroupEnum, UiText, ConfigurationParameters, FlowType, LoginFlow, RegistrationFlow, RecoveryFlow, VerificationFlow, SettingsFlow, FlowError, UpdateLoginFlowBody, UpdateRegistrationFlowBody, UpdateVerificationFlowBody, UpdateRecoveryFlowBody, UpdateSettingsFlowBody, OnRedirectHandler, Session } from '@ory/client-fetch';
1
+ import { UiNodeInputAttributes, UiNode, UiNodeAnchorAttributes, UiNodeTextAttributes, UiNodeImageAttributes, UiNodeGroupEnum, UiText, ConfigurationParameters, FlowType, LoginFlow, RegistrationFlow, RecoveryFlow, VerificationFlow, SettingsFlow, FlowError, UpdateLoginFlowBody, UpdateRegistrationFlowBody, UpdateVerificationFlowBody, UpdateRecoveryFlowBody, UpdateSettingsFlowBody, OnRedirectHandler } from '@ory/client-fetch';
2
2
  import { ComponentPropsWithoutRef, FormEventHandler, MouseEventHandler, PropsWithChildren, DetailedHTMLProps, HTMLAttributes, ComponentType, Dispatch } from 'react';
3
+ import * as class_variance_authority_types from 'class-variance-authority/types';
4
+ import { VariantProps } from 'class-variance-authority';
3
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
6
  import { IntlShape } from 'react-intl';
5
7
 
8
+ declare const buttonStyles: (props?: ({
9
+ intent?: "primary" | "secondary" | null | undefined;
10
+ size?: "default" | "large" | null | undefined;
11
+ defaultVariants?: "intent" | "size" | null | undefined;
12
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
13
+ type ButtonVariants = VariantProps<typeof buttonStyles>;
14
+
6
15
  type OryNodeButtonProps = {
7
16
  attributes: UiNodeInputAttributes;
8
17
  node: UiNode;
9
- } & Omit<ComponentPropsWithoutRef<"button">, "children">;
18
+ } & Omit<ComponentPropsWithoutRef<"button">, "children"> & ButtonVariants;
10
19
  type OryCurrentIdentifierProps = {
11
20
  attributes: UiNodeInputAttributes;
12
21
  node: UiNode;
@@ -50,6 +59,11 @@ type OryNodeInputProps = {
50
59
  node: UiNode;
51
60
  onClick?: MouseEventHandler;
52
61
  };
62
+ type OryFormSectionContentProps = PropsWithChildren<{
63
+ title?: string;
64
+ description?: string;
65
+ }>;
66
+ type OryFormSectionFooterProps = PropsWithChildren;
53
67
 
54
68
  type OryCardHeaderProps = Record<string, never>;
55
69
  declare function OryCardHeader(): react_jsx_runtime.JSX.Element;
@@ -130,6 +144,46 @@ type OryNodeOidcButtonProps = {
130
144
  declare function OryFormOidcButtons({ children, hideDivider, }: OryFormOidcButtonsProps): react_jsx_runtime.JSX.Element | null;
131
145
  declare function OryFormSocialButtonsForm(): react_jsx_runtime.JSX.Element | null;
132
146
 
147
+ type OryPageHeaderProps = Record<never, never>;
148
+ declare const HeadlessPageHeader: () => react_jsx_runtime.JSX.Element;
149
+
150
+ type OryFormSectionProps = PropsWithChildren<{
151
+ nodes?: UiNode[];
152
+ }>;
153
+ declare function OryFormSection({ children, nodes }: OryFormSectionProps): react_jsx_runtime.JSX.Element;
154
+
155
+ declare function OrySettingsCard(): react_jsx_runtime.JSX.Element;
156
+
157
+ type OrySettingsRecoveryCodesProps = {
158
+ codes: string[];
159
+ regnerateButton?: UiNode;
160
+ revealButton?: UiNode;
161
+ };
162
+ type OrySettingsTotpProps = {
163
+ totpImage: UiNode;
164
+ totpSecret: UiNode;
165
+ totpInput: UiNode;
166
+ } | {
167
+ totpUnlink: UiNode;
168
+ };
169
+ type OrySettingsOidcProps = {
170
+ linkButtons: UiNode[];
171
+ unlinkButtons: UiNode[];
172
+ };
173
+ type OrySettingsWebauthnProps = {
174
+ nameInput: UiNode;
175
+ triggerButton: UiNode & {
176
+ onClick: () => void;
177
+ };
178
+ removeButtons: UiNode[];
179
+ };
180
+ type OrySettingsPasskeyProps = {
181
+ triggerButton: UiNode & {
182
+ onClick: () => void;
183
+ };
184
+ removeButtons: UiNode[];
185
+ };
186
+
133
187
  /**
134
188
  * A record of all the components that are used in the OryForm component.
135
189
  */
@@ -213,6 +267,18 @@ type OryFlowComponents = {
213
267
  * This is only used, if login is configured to use identifier_first authentication.
214
268
  */
215
269
  AuthMethodListItem: ComponentType<OryCardAuthMethodListItemProps>;
270
+ /**
271
+ * The SettingsSection component is rendered around each section of the settings.
272
+ */
273
+ SettingsSection: ComponentType<OryFormSectionProps>;
274
+ /**
275
+ * The SettingsSectionContent component is rendered around the content of each section of the settings.
276
+ */
277
+ SettingsSectionContent: ComponentType<OryFormSectionContentProps>;
278
+ /**
279
+ * The SettingsSectionFooter component is rendered around the footer of each section of the settings.
280
+ */
281
+ SettingsSectionFooter: ComponentType<OryFormSectionContentProps>;
216
282
  };
217
283
  Form: {
218
284
  /**
@@ -235,6 +301,26 @@ type OryFlowComponents = {
235
301
  * The FormGroup is rendered around each group of nodes in the UI nodes.
236
302
  */
237
303
  Group: ComponentType<OryFormGroupProps>;
304
+ /**
305
+ * The section on the settings page, rendering the OIDC settings
306
+ */
307
+ OidcSettings: ComponentType<OrySettingsOidcProps>;
308
+ /**
309
+ * The section on the settings page, rendering the Webauthn settings
310
+ */
311
+ WebauthnSettings: ComponentType<OrySettingsWebauthnProps>;
312
+ /**
313
+ * The section on the settings page, rendering the Passkey settings
314
+ */
315
+ PasskeySettings: ComponentType<OrySettingsPasskeyProps>;
316
+ /**
317
+ * The section on the settings page, rendering the TOTP settings
318
+ */
319
+ TotpSettings: ComponentType<OrySettingsTotpProps>;
320
+ /**
321
+ * The section on the settings page, rendering the recovery code settings
322
+ */
323
+ RecoveryCodesSettings: ComponentType<OrySettingsRecoveryCodesProps>;
238
324
  };
239
325
  Message: {
240
326
  /**
@@ -246,6 +332,9 @@ type OryFlowComponents = {
246
332
  */
247
333
  Content: ComponentType<OryMessageContentProps>;
248
334
  };
335
+ Page: {
336
+ Header: ComponentType<OryPageHeaderProps>;
337
+ };
249
338
  };
250
339
  type DeepPartialTwoLevels<T> = {
251
340
  [P in keyof T]?: T[P] extends object ? {
@@ -253,8 +342,11 @@ type DeepPartialTwoLevels<T> = {
253
342
  } : T[P];
254
343
  };
255
344
  type OryFlowComponentOverrides = DeepPartialTwoLevels<OryFlowComponents>;
256
- type OryFormProps = PropsWithChildren;
257
- declare function OryForm({ children }: OryFormProps): string | react_jsx_runtime.JSX.Element;
345
+ type OryFormProps = PropsWithChildren<{
346
+ onAfterSubmit?: (method: string | number | boolean | undefined) => void;
347
+ nodes?: UiNode[];
348
+ }>;
349
+ declare function OryForm({ children, onAfterSubmit, nodes }: OryFormProps): string | react_jsx_runtime.JSX.Element;
258
350
 
259
351
  declare function useComponents(): OryFlowComponents;
260
352
  declare function useNodeSorter(): (a: UiNode, b: UiNode, ctx: {
@@ -454,20 +546,4 @@ declare function messageTestId(message: UiText): {
454
546
  "data-testid": string;
455
547
  };
456
548
 
457
- /**
458
- * A hook to get the current session from the Ory Network.
459
- *
460
- * Usage:
461
- * ```ts
462
- * const { session, error, isLoading } = useSession()
463
- * ```
464
- *
465
- * @returns The current session, error and loading state.
466
- */
467
- declare const useSession: () => {
468
- session: Session | undefined;
469
- error: string | undefined;
470
- isLoading: boolean;
471
- };
472
-
473
- export { type ErrorFlowContainer, type FlowContainerSetter, type FlowContextValue, type FormValues, type IntlConfig, type LoginFlowContainer, type OnSubmitHandlerProps, OryCard, type OryCardAuthMethodListItemProps, OryCardContent, type OryCardContentProps, type OryCardDividerProps, OryCardFooter, type OryCardFooterProps, OryCardHeader, type OryCardHeaderProps, type OryCardLogoProps, type OryCardRootProps as OryCardProps, OryCardValidationMessages, type OryClientConfiguration, type OryCurrentIdentifierProps, type OryFlowComponentOverrides, type OryFlowComponents, type OryFlowContainer, OryForm, OryFormGroupDivider, type OryFormGroupProps, OryFormGroups, type OryFormGroupsProps, OryFormOidcButtons, type OryFormOidcButtonsProps, type OryFormOidcRootProps, type OryFormProps, type OryFormRootProps, OryFormSocialButtonsForm, locales as OryLocales, type OryMessageContentProps, type OryMessageRootProps, type OryNodeAnchorProps, type OryNodeButtonProps, type OryNodeImageProps, type OryNodeInputProps, type OryNodeLabelProps, type OryNodeOidcButtonProps, type OryNodeTextProps, OryProvider, type OryProviderProps, OryTwoStepCard, type RecoveryFlowContainer, type RegistrationFlowContainer, type SettingsFlowContainer, type VerificationFlowContainer, messageTestId, uiTextToFormattedMessage, useComponents, useNodeSorter, useOryFlow, useSession };
549
+ export { type ErrorFlowContainer, type FlowContainerSetter, type FlowContextValue, type FormValues, HeadlessPageHeader, type IntlConfig, type LoginFlowContainer, type OnSubmitHandlerProps, OryCard, type OryCardAuthMethodListItemProps, OryCardContent, type OryCardContentProps, type OryCardDividerProps, OryCardFooter, type OryCardFooterProps, OryCardHeader, type OryCardHeaderProps, type OryCardLogoProps, type OryCardRootProps as OryCardProps, OryCardValidationMessages, type OryClientConfiguration, type OryCurrentIdentifierProps, type OryFlowComponentOverrides, type OryFlowComponents, type OryFlowContainer, OryForm, OryFormGroupDivider, type OryFormGroupProps, OryFormGroups, type OryFormGroupsProps, OryFormOidcButtons, type OryFormOidcButtonsProps, type OryFormOidcRootProps, type OryFormProps, type OryFormRootProps, OryFormSection, type OryFormSectionContentProps, type OryFormSectionFooterProps, type OryFormSectionProps, OryFormSocialButtonsForm, locales as OryLocales, type OryMessageContentProps, type OryMessageRootProps, type OryNodeAnchorProps, type OryNodeButtonProps, type OryNodeImageProps, type OryNodeInputProps, type OryNodeLabelProps, type OryNodeOidcButtonProps, type OryNodeTextProps, type OryPageHeaderProps, OryProvider, type OryProviderProps, OrySettingsCard, type OrySettingsOidcProps, type OrySettingsPasskeyProps, type OrySettingsRecoveryCodesProps, type OrySettingsTotpProps, type OrySettingsWebauthnProps, OryTwoStepCard, type RecoveryFlowContainer, type RegistrationFlowContainer, type SettingsFlowContainer, type VerificationFlowContainer, messageTestId, uiTextToFormattedMessage, useComponents, useNodeSorter, useOryFlow };