@ory/elements-react 1.0.0-rc.5 → 1.0.0-rc.6

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/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { UiNodeInputAttributes, UiNode, UiNodeAnchorAttributes, UiNodeTextAttributes, UiNodeImageAttributes, UiNodeGroupEnum, UiText, FlowType, LoginFlow, RegistrationFlow, RecoveryFlow, VerificationFlow, SettingsFlow, UiContainer, OAuth2ConsentRequest, Session, FlowError, ConfigurationParameters, AccountExperienceConfiguration, UpdateLoginFlowBody, UpdateRegistrationFlowBody, UpdateVerificationFlowBody, UpdateRecoveryFlowBody, UpdateSettingsFlowBody, OnRedirectHandler, FrontendApi } from '@ory/client-fetch';
2
- import { ComponentPropsWithoutRef, FormEventHandler, MouseEventHandler, PropsWithChildren, DetailedHTMLProps, HTMLAttributes, ComponentType, Dispatch } from 'react';
1
+ import { UiNodeInputAttributes, UiNode, UiNodeAnchorAttributes, UiNodeTextAttributes, UiNodeImageAttributes, UiText, FlowType, LoginFlow, RegistrationFlow, RecoveryFlow, VerificationFlow, SettingsFlow, UiContainer, OAuth2ConsentRequest, Session, FlowError, ConfigurationParameters, AccountExperienceConfiguration, UpdateLoginFlowBody, UpdateRegistrationFlowBody, UpdateVerificationFlowBody, UpdateRecoveryFlowBody, UpdateSettingsFlowBody, OnRedirectHandler, UiNodeGroupEnum, FrontendApi } from '@ory/client-fetch';
2
+ import { ComponentPropsWithoutRef, PropsWithChildren, FormEventHandler, MouseEventHandler, ComponentType, Dispatch } from 'react';
3
3
  import * as class_variance_authority_types from 'class-variance-authority/types';
4
4
  import { VariantProps } from 'class-variance-authority';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -31,6 +31,10 @@ type OryCardLogoProps = Record<string, never>;
31
31
  type OryNodeCaptchaProps = {
32
32
  node: UiNode;
33
33
  };
34
+ /**
35
+ * Props for the Form.Group component.
36
+ */
37
+ type OryFormGroupProps = PropsWithChildren;
34
38
  /**
35
39
  * Props for the AuthMethodListItem component. This component is used
36
40
  * to render a single auth method in the AuthMethodList component.
@@ -51,9 +55,11 @@ type OryNodeImageProps = {
51
55
  * A generic type for the form values.
52
56
  */
53
57
  type FormValues = Record<string, string | boolean | number | undefined>;
58
+ /**
59
+ * Props for the Form.Root component.
60
+ */
54
61
  type OryFormRootProps = ComponentPropsWithoutRef<"form"> & {
55
62
  onSubmit: FormEventHandler<HTMLFormElement>;
56
- "data-testid"?: string;
57
63
  };
58
64
  type OryNodeInputProps = {
59
65
  attributes: UiNodeInputAttributes;
@@ -74,8 +80,17 @@ type OryFormSectionFooterProps = PropsWithChildren<{
74
80
  }>;
75
81
 
76
82
  type OryCardHeaderProps = Record<string, never>;
83
+ /**
84
+ * Returns the header of the Ory Card.
85
+ *
86
+ * @returns The header of the Ory Card.
87
+ * @group Components
88
+ */
77
89
  declare function OryCardHeader(): react_jsx_runtime.JSX.Element;
78
90
 
91
+ /**
92
+ * @interface
93
+ */
79
94
  type OryCardRootProps = PropsWithChildren;
80
95
  /**
81
96
  * The root component of the Ory Card.
@@ -86,10 +101,16 @@ type OryCardRootProps = PropsWithChildren;
86
101
  *
87
102
  * @param props - pass children to render instead of the default Ory Card components
88
103
  * @returns
104
+ * @group Components
89
105
  */
90
106
  declare function OryCard({ children }: PropsWithChildren): react_jsx_runtime.JSX.Element;
91
107
 
92
108
  type OryCardFooterProps = Record<string, never>;
109
+ /**
110
+ *
111
+ * @returns The footer of a card component.
112
+ * @group Components
113
+ */
93
114
  declare function OryCardFooter(): react_jsx_runtime.JSX.Element;
94
115
 
95
116
  /**
@@ -106,11 +127,42 @@ type OryCardContentProps = PropsWithChildren;
106
127
  *
107
128
  * @param props - pass children to render instead of the default Ory Card components
108
129
  * @returns
130
+ * @group Components
109
131
  */
110
132
  declare function OryCardContent({ children }: OryCardContentProps): react_jsx_runtime.JSX.Element;
111
133
 
112
- declare function OryTwoStepCard(): react_jsx_runtime.JSX.Element;
134
+ /**
135
+ * The `OrySelfServiceFlowCard` component is an umbrella component that can render the self-service flows.
136
+ *
137
+ * Note: prefer using the {@link @ory/elements-react/theme!Login | <Login /> component}, etc. directly instead of this component.
138
+ *
139
+ * It renders different forms based on the current flow state, such as providing an identifier,
140
+ * entering a password or one time code or selecting a method for authentication.
141
+ *
142
+ * The component must be use within an {@link OryProvider} that provides the flow context and components to use.
143
+ *
144
+ * @example
145
+ * ```jsx
146
+ * import { OrySelfServiceFlowCard } from "@ory/elements-react";
147
+ *
148
+ * function MyComponent() {
149
+ * return <OryProvider ...>
150
+ * <OrySelfServiceFlowCard />
151
+ * </OryProvider>;
152
+ * }
153
+ * ```
154
+ *
155
+ * @returns The Ory Two-Step Card component that renders different forms based on the current flow state.
156
+ * @group Components
157
+ */
158
+ declare function OrySelfServiceFlowCard(): react_jsx_runtime.JSX.Element;
113
159
 
160
+ /**
161
+ * The `OryConsentCard` component renders a card for displaying the OAuth2 consent flow.
162
+ *
163
+ * @returns The consent card component.
164
+ * @group Components
165
+ */
114
166
  declare function OryConsentCard(): react_jsx_runtime.JSX.Element;
115
167
 
116
168
  /**
@@ -118,19 +170,38 @@ declare function OryConsentCard(): react_jsx_runtime.JSX.Element;
118
170
  */
119
171
  type OryCardDividerProps = Record<string, never>;
120
172
  /**
121
- * Renders the @see Card.Divider between the groups of nodes in the Ory Form.
173
+ * Renders the {@link OryFlowComponents.Card.Divider} between the groups of nodes in the Ory Form.
122
174
  *
123
175
  * You can use this component to build fully custom implementations of the Ory Flows.
124
176
  *
125
177
  * However, you most likely want to override the individual components instead.
126
178
  *
127
179
  * @returns
180
+ * @group Components
128
181
  */
129
182
  declare function OryFormGroupDivider(): react_jsx_runtime.JSX.Element | null;
130
183
 
131
184
  type OryPageHeaderProps = Record<never, never>;
132
- declare const HeadlessPageHeader: () => react_jsx_runtime.JSX.Element;
185
+ /**
186
+ * The OryPageHeader component renders the header of the page.
187
+ *
188
+ * Customize the header by providing a custom {@link OryFlowComponents.Page.Header} component in the `components` prop of the {@link OryProvider}.
189
+ *
190
+ * @returns a React component that renders the page header.
191
+ * @group Components
192
+ */
193
+ declare const OryPageHeader: () => react_jsx_runtime.JSX.Element;
133
194
 
195
+ /**
196
+ * Renders the Ory Settings Card component.
197
+ *
198
+ * This component is used to display the settings flow for the user.
199
+ * It utilizes the `useOryFlow` hook to access the current flow and renders the nodes with components
200
+ * provided by the Ory Elements context.
201
+ *
202
+ * @returns The Ory Settings Card component that renders the settings flow.
203
+ * @group Components
204
+ */
134
205
  declare function OrySettingsCard(): react_jsx_runtime.JSX.Element;
135
206
 
136
207
  type OrySettingsRecoveryCodesProps = {
@@ -147,7 +218,7 @@ type OrySettingsTotpProps = {
147
218
  totpUnlink: UiNode | undefined;
148
219
  onUnlink: () => void;
149
220
  };
150
- type OrySettingsOidcProps = {
221
+ type OrySettingsSsoProps = {
151
222
  linkButtons: (UiNode & {
152
223
  onClick: () => void;
153
224
  })[];
@@ -173,39 +244,106 @@ type OrySettingsPasskeyProps = {
173
244
  })[];
174
245
  };
175
246
 
176
- type OryFormGroupsProps = PropsWithChildren<{
177
- groups: UiNodeGroupEnum[];
178
- }>;
179
- type OryFormGroupProps = PropsWithChildren;
180
- declare function OryFormGroups({ groups }: OryFormGroupsProps): react_jsx_runtime.JSX.Element;
181
-
247
+ /**
248
+ * Props for the OryMessageContent component.
249
+ *
250
+ * @interface
251
+ */
182
252
  type OryMessageContentProps = {
253
+ /**
254
+ * The message to display.
255
+ */
183
256
  message: UiText;
184
257
  };
185
- type OryMessageRootProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
186
- declare function OryCardValidationMessages({ ...props }: OryMessageRootProps): react_jsx_runtime.JSX.Element | null;
258
+ /**
259
+ *
260
+ * @interface
261
+ * @expand
262
+ */
263
+ type OryMessageRootProps = PropsWithChildren;
264
+ /**
265
+ * Props for the {@link OryCardValidationMessages} component.
266
+ *
267
+ * @inline
268
+ * @hidden
269
+ */
270
+ interface OryCardValidationMessagesProps {
271
+ /**
272
+ * An array of message IDs that should be hidden.
273
+ * This is useful for hiding specific messages that are not relevant to the user or are rendered elsewhere.
274
+ * If not provided, the default list of message IDs to hide will be used.
275
+ * @default [1040009, 1060003, 1080003, 1010004, 1010014, 1040005, 1010016, 1010003]
276
+ *
277
+ * @see https://www.ory.sh/docs/kratos/concepts/ui-messages
278
+ */
279
+ hiddenMessageIds?: number[];
280
+ }
281
+ /**
282
+ * Renders the {@link OryFlowComponents.Message.Content} component for each message in the current flow.
283
+ *
284
+ * See also {@link useOryFlow}
285
+ * @returns
286
+ * @group Components
287
+ */
288
+ declare function OryCardValidationMessages({ hiddenMessageIds, }: OryCardValidationMessagesProps): react_jsx_runtime.JSX.Element | null;
187
289
 
188
- type OryFormProps$1 = Omit<ComponentPropsWithoutRef<"form">, "action" | "method" | "onSubmit">;
189
- type OryFormSectionProps = PropsWithChildren<OryFormProps$1 & {
290
+ /**
291
+ * Props for the OrySettingsFormSection component.
292
+ * This type extends the form element props but omits the `action`, `method`, and `onSubmit` properties.
293
+ */
294
+ type OrySettingsFormProps = Omit<ComponentPropsWithoutRef<"form">, "action" | "method" | "onSubmit">;
295
+ /**
296
+ * Props for the OrySettingsFormSection component.
297
+ *
298
+ * @inline
299
+ * @hidden
300
+ */
301
+ interface OryFormSectionProps extends PropsWithChildren, OrySettingsFormProps {
190
302
  nodes?: UiNode[];
191
- }>;
192
- type OryCardSettingsSectionProps = PropsWithChildren & {
303
+ }
304
+ interface OryCardSettingsSectionProps extends PropsWithChildren {
193
305
  action: string;
194
306
  method: string;
195
307
  onSubmit: FormEventHandler<HTMLFormElement>;
196
- };
197
- declare function OryFormSection({ children, nodes, ...rest }: OryFormSectionProps): react_jsx_runtime.JSX.Element;
308
+ }
309
+ /**
310
+ * OrySettingsFormSection is a component that provides a form section for Ory settings.
311
+ *
312
+ * Can be used independently to render a form section with Ory nodes.
313
+ *
314
+ * @param props - The properties for the OrySettingsFormSection component.
315
+ * @returns
316
+ * @group Components
317
+ */
318
+ declare function OrySettingsFormSection({ children, nodes, ...rest }: OryFormSectionProps): react_jsx_runtime.JSX.Element;
198
319
 
199
- type OryFormOidcRootProps = PropsWithChildren<{
320
+ type OryFormSsoRootProps = PropsWithChildren<{
200
321
  nodes: UiNode[];
201
322
  }>;
202
- type OryNodeOidcButtonProps = {
323
+ /**
324
+ * Props for the OryNodeSsoButton component.
325
+ */
326
+ type OryNodeSsoButtonProps = {
203
327
  node: UiNode;
204
328
  attributes: UiNodeInputAttributes;
205
329
  onClick?: () => void;
206
330
  };
207
- declare function OryFormOidcButtons(): react_jsx_runtime.JSX.Element | null;
208
- declare function OryFormSocialButtonsForm(): react_jsx_runtime.JSX.Element | null;
331
+ /**
332
+ * Renders the flow's OIDC buttons.
333
+ *
334
+ * @returns a React component that renders the OIDC buttons.
335
+ * @group Components
336
+ */
337
+ declare function OryFormSsoButtons(): react_jsx_runtime.JSX.Element | null;
338
+ /**
339
+ * The `OryFormSsoForm` component renders the Ory Form for SSO methods (OIDC and SAML).
340
+ *
341
+ * It needs to be its own form, as the OIDC buttons are form submits but are not related to the main form.
342
+ *
343
+ * @returns a React component that renders the Ory Form for SSO methods.
344
+ * @group Components
345
+ */
346
+ declare function OryFormSsoForm(): react_jsx_runtime.JSX.Element | null;
209
347
 
210
348
  /**
211
349
  * A record of all the components that are used in the OryForm component.
@@ -217,11 +355,11 @@ type OryFlowComponents = {
217
355
  */
218
356
  Button: ComponentType<OryNodeButtonProps>;
219
357
  /**
220
- * The SocialButton component is rendered whenever a button of group "oidc" node is encountered.
358
+ * The SsoButton component is rendered whenever a button of group "oidc" or "saml" node is encountered.
221
359
  *
222
360
  * It renders the "Login with Google", "Login with Facebook" etc. buttons.
223
361
  */
224
- OidcButton: ComponentType<OryNodeOidcButtonProps>;
362
+ SsoButton: ComponentType<OryNodeSsoButtonProps>;
225
363
  /**
226
364
  * Anchor component, rendered whenever an "anchor" node is encountered
227
365
  */
@@ -327,7 +465,7 @@ type OryFlowComponents = {
327
465
  *
328
466
  * You most likely don't want to override this component directly.
329
467
  */
330
- OidcRoot: ComponentType<OryFormOidcRootProps>;
468
+ SsoRoot: ComponentType<OryFormSsoRootProps>;
331
469
  /**
332
470
  * The FormGroup is rendered around each group of nodes in the UI nodes.
333
471
  */
@@ -335,7 +473,7 @@ type OryFlowComponents = {
335
473
  /**
336
474
  * The section on the settings page, rendering the OIDC settings
337
475
  */
338
- OidcSettings: ComponentType<OrySettingsOidcProps>;
476
+ SsoSettings: ComponentType<OrySettingsSsoProps>;
339
477
  /**
340
478
  * The section on the settings page, rendering the Webauthn settings
341
479
  */
@@ -362,94 +500,176 @@ type OryFlowComponents = {
362
500
  * The Message component is rendered whenever a message is encountered.
363
501
  */
364
502
  Content: ComponentType<OryMessageContentProps>;
503
+ /**
504
+ * The Toast component is rendered for toast messages.
505
+ *
506
+ * Currently only used in the settings page to display messages.
507
+ */
508
+ Toast: ComponentType<OryToastProps>;
365
509
  };
366
510
  Page: {
367
511
  Header: ComponentType<OryPageHeaderProps>;
368
512
  };
369
513
  };
370
- type DeepPartialTwoLevels<T> = {
371
- [P in keyof T]?: T[P] extends object ? {
372
- [K in keyof T[P]]?: T[P][K];
373
- } : T[P];
514
+ type OryToastProps = {
515
+ message: UiText;
516
+ id: string | number;
517
+ };
518
+ /**
519
+ * Makes the components in OryFlowComponents optional, so that you can override only the components you want to change.
520
+ */
521
+ type OryFlowComponentOverrides = {
522
+ [P in keyof OryFlowComponents]?: OryFlowComponents[P] extends object ? {
523
+ [K in keyof OryFlowComponents[P]]?: OryFlowComponents[P][K];
524
+ } : OryFlowComponents[P];
374
525
  };
375
- type OryFlowComponentOverrides = DeepPartialTwoLevels<OryFlowComponents>;
376
- type OryFormProps = PropsWithChildren<{
526
+ /**
527
+ * The props for the OryForm component.
528
+ * @inline
529
+ * @hidden
530
+ */
531
+ interface OryFormProps extends PropsWithChildren {
532
+ /**
533
+ * A callback function that is called after the form is submitted.
534
+ *
535
+ * It is always called after the form is submitted, unless the form submission is prevented by client side
536
+ * validation or the API response dictated that the client should be redirected
537
+ *
538
+ * @param method - The method that was submitted.
539
+ */
377
540
  onAfterSubmit?: (method: string | number | boolean | undefined) => void;
378
- "data-testid"?: string;
379
- }>;
380
- declare function OryForm({ children, onAfterSubmit, "data-testid": dataTestId, }: OryFormProps): react_jsx_runtime.JSX.Element;
541
+ }
542
+ /**
543
+ * The OryForm component is the main form container for Ory flows.
544
+ *
545
+ * It renders the form with the correct action and method, and handles the submission of the form.
546
+ *
547
+ * @param props - The props for the OryForm component.
548
+ * @returns
549
+ * @group Components
550
+ */
551
+ declare function OryForm({ children, onAfterSubmit }: OryFormProps): react_jsx_runtime.JSX.Element;
381
552
 
553
+ /**
554
+ * The `useComponents` hook provides access to the Ory Flow components provided in the `OryComponentProvider`.
555
+ *
556
+ * You can use this hook to access the components defined in the `components` prop of the `OryComponentProvider`.
557
+ *
558
+ * @returns the current component context value.
559
+ * @group Hooks
560
+ */
382
561
  declare function useComponents(): OryFlowComponents;
562
+ /**
563
+ * The `useNodeSorter` hook provides a way to access the node sorting function
564
+ *
565
+ * The node sorting function is used to determine the order of nodes in a flow based on their attributes and context.
566
+ *
567
+ * To customize the sorting behavior, you can provide a custom `nodeSorter` function to the `OryComponentProvider`.
568
+ *
569
+ * @returns a function that sorts nodes based on the provided context.
570
+ * @group Hooks
571
+ */
383
572
  declare function useNodeSorter(): (a: UiNode, b: UiNode, ctx: {
384
573
  flowType: string;
385
574
  }) => number;
386
575
 
387
576
  /**
388
- * A generic flow container, containing a flowType, the flow itself and the config object
389
- *
390
- * @see OryClientConfiguration
577
+ * A flow container for the {@link LoginFlow}
578
+ * @interface
391
579
  */
392
- type OryFlow<TFlowType extends FlowType, TFlow> = {
393
- flowType: TFlowType;
394
- flow: TFlow;
580
+ type LoginFlowContainer = {
581
+ flowType: FlowType.Login;
582
+ flow: LoginFlow;
395
583
  };
396
584
  /**
397
- * A flow container for the login flow
398
- *
399
- * @see OryFlow
400
- * @see LoginFlow
585
+ * A flow container for the {@link RegistrationFlow}
586
+ * @interface
401
587
  */
402
- type LoginFlowContainer = OryFlow<FlowType.Login, LoginFlow>;
588
+ type RegistrationFlowContainer = {
589
+ flowType: FlowType.Registration;
590
+ flow: RegistrationFlow;
591
+ };
403
592
  /**
404
- * A flow container for the registration flow
405
- *
406
- * @see OryFlow
407
- * @see RegistrationFlow
593
+ * A flow container for the {@link RecoveryFlow}
594
+ * @interface
408
595
  */
409
- type RegistrationFlowContainer = OryFlow<FlowType.Registration, RegistrationFlow>;
596
+ type RecoveryFlowContainer = {
597
+ flowType: FlowType.Recovery;
598
+ flow: RecoveryFlow;
599
+ };
410
600
  /**
411
- * A flow container for the recovery flow
412
- *
413
- * @see OryFlow
414
- * @see RecoveryFlow
601
+ * A flow container for the {@link VerificationFlow}
602
+ * @interface
415
603
  */
416
- type RecoveryFlowContainer = OryFlow<FlowType.Recovery, RecoveryFlow>;
604
+ type VerificationFlowContainer = {
605
+ flowType: FlowType.Verification;
606
+ flow: VerificationFlow;
607
+ };
417
608
  /**
418
- * A flow container for the verification flow
419
- *
420
- * @see OryFlow
421
- * @see VerificationFlow
422
- *
609
+ * A flow container for the {@link SettingsFlow}
610
+ * @interface
423
611
  */
424
- type VerificationFlowContainer = OryFlow<FlowType.Verification, VerificationFlow>;
612
+ type SettingsFlowContainer = {
613
+ flowType: FlowType.Settings;
614
+ flow: SettingsFlow;
615
+ };
425
616
  /**
426
- * A flow container for the settings flow
427
- *
428
- * @see OryFlow
429
- * @see SettingsFlow
617
+ * A flow container for the {@link FlowError}
618
+ * @interface
430
619
  */
431
- type SettingsFlowContainer = OryFlow<FlowType.Settings, SettingsFlow>;
620
+ type ErrorFlowContainer = {
621
+ flowType: FlowType.Error;
622
+ flow: FlowError;
623
+ };
432
624
  /**
433
- * A flow container for the error flow
434
- *
435
- * @see OryFlow
436
- * @see FlowError (Error flow)
625
+ * A flow container for the OAuth2 consent flow
437
626
  *
627
+ * Note: This is a polyfill for the OAuth2 consent flow, which is not yet implemented in the Ory SDK.
628
+ * It tries to mirror the structure of the other flow containers as closely as possible.
629
+ * @interface
438
630
  */
439
- type ErrorFlowContainer = OryFlow<FlowType.Error, FlowError>;
440
631
  type ConsentFlow = {
632
+ /**
633
+ * When the flow was created.
634
+ */
441
635
  created_at: Date;
636
+ /**
637
+ * When the flow expires.
638
+ */
442
639
  expires_at: Date;
443
- id: string;
640
+ /**
641
+ * Always "UNSET" as the consent flow does not have a specific ID.
642
+ */
643
+ id: "UNSET";
644
+ /**
645
+ * When the flow was issued.
646
+ */
444
647
  issued_at: Date;
648
+ /**
649
+ * The state of the consent flow.
650
+ *
651
+ * - "show_form": The form is being shown to the user.
652
+ * - "rejected": The user has rejected the consent request.
653
+ * - "accepted": The user has accepted the consent request.
654
+ */
445
655
  state: "show_form" | "rejected" | "accepted";
446
- active: string;
656
+ /**
657
+ * The active part of the flow, which is always "oauth2_consent" for this flow.
658
+ */
659
+ active: "oauth2_consent";
447
660
  ui: UiContainer;
448
661
  consent_request: OAuth2ConsentRequest;
449
662
  session: Session;
450
663
  return_to?: string;
451
664
  };
452
- type ConsentFlowContainer = OryFlow<FlowType.OAuth2Consent, ConsentFlow>;
665
+ /**
666
+ * A flow container for the OAuth2 {@link ConsentFlow}
667
+ * @interface
668
+ */
669
+ type ConsentFlowContainer = {
670
+ flowType: FlowType.OAuth2Consent;
671
+ flow: ConsentFlow;
672
+ };
453
673
  /**
454
674
  * A union type of all flow containers
455
675
  */
@@ -459,12 +679,25 @@ type LocaleMap = Record<string, Record<string, string>>;
459
679
  declare const OryLocales: LocaleMap;
460
680
 
461
681
  type Locale = keyof typeof OryLocales;
462
- type IntlContextProps = {
682
+
683
+ /**
684
+ * The configuration for internationalization (i18n) in Ory Elements.
685
+ *
686
+ * This configuration is used to set the locale and can be used to provide custom translations.
687
+ * The locale is used to determine the language of the UI.
688
+ */
689
+ type IntlConfig = {
690
+ /**
691
+ * The locale to use for internationalization.
692
+ *
693
+ * @defaultValue "en"
694
+ */
463
695
  locale: Locale;
696
+ /**
697
+ * Provide custom translations for the UI.
698
+ */
464
699
  customTranslations?: Partial<LocaleMap>;
465
700
  };
466
-
467
- type IntlConfig = IntlContextProps;
468
701
  /**
469
702
  * The configuration for Ory Elements.
470
703
  *
@@ -475,13 +708,21 @@ type IntlConfig = IntlContextProps;
475
708
  * You can also set the name of the application, the logo URL, and the SDK configuration.
476
709
  * By default, the name and logo are displayed in the card's header.
477
710
  */
478
- type OryClientConfiguration = {
711
+ interface OryClientConfiguration {
479
712
  /**
480
713
  * The SDK configuration.
481
714
  * This configuration is used to set the URL of the Ory SDK and any additional options used for the SDK client.
482
715
  */
483
716
  sdk?: {
717
+ /**
718
+ * The URL the Ory SDK should connect to.
719
+ * This is typically the base URL of your Ory instance.
720
+ */
484
721
  url?: string;
722
+ /**
723
+ * Additional parameters for the Ory SDK configuration.
724
+ * This can include options like headers, credentials, and other settings.
725
+ */
485
726
  options?: Partial<ConfigurationParameters>;
486
727
  };
487
728
  /**
@@ -495,7 +736,7 @@ type OryClientConfiguration = {
495
736
  * The configuration for the project.
496
737
  */
497
738
  project: AccountExperienceConfiguration;
498
- };
739
+ }
499
740
 
500
741
  /**
501
742
  * Converts a UiText to a FormattedMessage.
@@ -503,41 +744,46 @@ type OryClientConfiguration = {
503
744
  * The context is used to inject values into the message from Ory, e.g. a timestamp.
504
745
  * For example a UI Node from Ory might look like this:
505
746
  *
506
- * \{
747
+ * ```json
748
+ * {
507
749
  * "type":"input",
508
750
  * "group":"default",
509
- * "attributes": \{
751
+ * "attributes": {
510
752
  * "name":"traits.email",
511
753
  * "type":"email",
512
754
  * "required":true,
513
755
  * "autocomplete":"email",
514
756
  * "disabled":false,
515
757
  * "node_type":"input"
516
- * \},
758
+ * },
517
759
  * "messages":[],
518
- * "meta": \{
519
- * "label": \{
760
+ * "meta": {
761
+ * "label": {
520
762
  * "id":1070002,
521
763
  * "text":"E-Mail",
522
764
  * "type":"info",
523
- * "context":\{
765
+ * "context":{
524
766
  * "title":"E-Mail"
525
- * \},
526
- * \}
527
- * \}
528
- * \}
767
+ * },
768
+ * }
769
+ * }
770
+ * }
771
+ * ```
529
772
  *
530
773
  * The context has the key "title" which matches the formatter template name "\{title\}"
531
774
  * An example translation file would look like this:
532
- * \{
533
- * "identities.messages.1070002": "\{title\}"
534
- * \}
775
+ * ```json
776
+ * {
777
+ * "identities.messages.1070002": "{title}"
778
+ * }
779
+ * ```
535
780
  *
536
781
  * The formatter would then take the meta.label.id and look for the translation with the key matching the id.
537
782
  * It would then replace the template "\{title\}" with the value from the context with the key "title".
538
783
  *
539
784
  * @param uiText - The UiText is part of the UiNode object sent by Kratos when performing a flow.
540
785
  * @param intl - The intl object from react-intl
786
+ * @group Utilities
541
787
  */
542
788
  declare const uiTextToFormattedMessage: ({ id, context, text }: Omit<UiText, "type">, intl: IntlShape) => string;
543
789
 
@@ -564,6 +810,7 @@ type OnSubmitHandlerProps<T extends UpdateLoginFlowBody | UpdateRegistrationFlow
564
810
  *
565
811
  * @param message - the UiText message to generate a test id for
566
812
  * @returns a unique, stable test id for the message
813
+ * @group Utilities
567
814
  */
568
815
  declare function messageTestId(message: {
569
816
  id: number | string;
@@ -571,28 +818,87 @@ declare function messageTestId(message: {
571
818
  "data-testid": string;
572
819
  };
573
820
 
821
+ /**
822
+ * Represents the state of the form when selecting an authentication method.
823
+ * This type is used when the user is in the process of selecting an authentication method
824
+ * (e.g., password, passkey, etc.) during the login or registration flow.
825
+ * @inline
826
+ * @hidden
827
+ */
574
828
  type FormStateSelectMethod = {
575
829
  current: "select_method";
576
830
  };
831
+ /**
832
+ * Represents the state of the form when providing an identifier.
833
+ * This type is used when the user is required to provide an identifier (e.g., email or username)
834
+ * before proceeding with the authentication flow.
835
+ * @inline
836
+ * @hidden
837
+ */
577
838
  type FormStateProvideIdentifier = {
578
839
  current: "provide_identifier";
579
840
  };
841
+ /**
842
+ * Represents the state of the form when an authentication method is active.
843
+ * This type is used when the user is interacting with a specific authentication method
844
+ * (e.g., entering a password or entering a code received via email).
845
+ *
846
+ * The `method` field indicates which authentication method is currently active.
847
+ * @inline
848
+ * @hidden
849
+ */
580
850
  type FormStateMethodActive = {
581
851
  current: "method_active";
582
852
  method: UiNodeGroupEnum;
583
853
  };
854
+ /**
855
+ * Represents the state of the form based on the flow type and active method.
856
+ * This type is used to determine which part of the form should be displayed.
857
+ *
858
+ * It can be one of the following:
859
+ * - `select_method`: The user is selecting an authentication method.
860
+ * - `provide_identifier`: The user is providing an identifier (e.g., email or username).
861
+ * - `method_active`: An authentication method is active, and the user is interacting with it.
862
+ * - `success_screen`: The flow has successfully completed (only used in the verification flow).
863
+ * - `settings`: The user is in the settings flow.
864
+ */
584
865
  type FormState = FormStateSelectMethod | FormStateProvideIdentifier | FormStateMethodActive | {
585
866
  current: "success_screen";
586
867
  } | {
587
868
  current: "settings";
588
869
  };
870
+ /**
871
+ * Represents the actions that can be dispatched to update the form state.
872
+ * These actions are used to change the current state of the form based on user interactions or flow updates.
873
+ */
589
874
  type FormStateAction = {
875
+ /**
876
+ * Action to update the flow state.
877
+ * This action is dispatched when the flow is updated, and it will parse the new flow
878
+ * to determine the current form state.
879
+ */
590
880
  type: "action_flow_update";
881
+ /**
882
+ * The updated flow container that contains the new flow data.
883
+ */
591
884
  flow: OryFlowContainer;
592
885
  } | {
886
+ /**
887
+ * Action to select an authentication method.
888
+ * This action is dispatched when the user selects an authentication method
889
+ * (e.g., password, passkey, etc.) from the available options.
890
+ */
593
891
  type: "action_select_method";
892
+ /**
893
+ * The authentication method that the user has selected.
894
+ */
594
895
  method: UiNodeGroupEnum;
595
896
  } | {
897
+ /**
898
+ * Action to clear the active authentication method.
899
+ * This action is dispatched when the user wants to clear the currently active method
900
+ * and return to the method selection state.
901
+ */
596
902
  type: "action_clear_active_method";
597
903
  };
598
904
 
@@ -600,10 +906,12 @@ type FormStateAction = {
600
906
  * Returns an object that contains the current flow and the flow type, as well as the configuration.
601
907
  *
602
908
  * @returns The current flow container
909
+ * @group Hooks
603
910
  */
604
911
  declare function useOryFlow(): FlowContextValue;
605
912
  /**
606
913
  * Function to set the flow container.
914
+ * @interface
607
915
  */
608
916
  type FlowContainerSetter = Dispatch<OryFlowContainer>;
609
917
  /**
@@ -625,16 +933,90 @@ type FlowContextValue = OryFlowContainer & {
625
933
  dispatchFormState: Dispatch<FormStateAction>;
626
934
  };
627
935
 
936
+ /**
937
+ * Props type for the OryProvider component.
938
+ */
628
939
  type OryProviderProps = {
940
+ /**
941
+ * The components to use for rendering Ory flows.
942
+ * You can provide custom components to override the default Ory components.
943
+ */
629
944
  components: OryFlowComponents;
945
+ /**
946
+ * The Ory client configuration.
947
+ * This includes the SDK and project configuration.
948
+ */
630
949
  config: OryClientConfiguration;
631
950
  } & OryFlowContainer & PropsWithChildren;
951
+ /**
952
+ * OryProvider is a React component that provides the necessary context for rendering Ory flows.
953
+ *
954
+ * It wraps the application in several context providers, including {@link OryConfigurationProvider}.
955
+ *
956
+ * You can use this component to set up the Ory SDK, provide custom translations, and specify the components to use for rendering Ory flows.
957
+ *
958
+ * @example
959
+ * ```tsx
960
+ * import { OryProvider, LoginFlow, OryFlowComponents, OryClientConfiguration } from "@ory/elements-react";
961
+ *
962
+ *
963
+ * export type Props = {
964
+ * flow: LoginFlow
965
+ * components: OryFlowComponents
966
+ * config: OryClientConfiguration
967
+ * }
968
+ *
969
+ * function App({
970
+ * flow,
971
+ * config,
972
+ * children,
973
+ * components,
974
+ * }: PropsWithChildren<Props>) {
975
+ * return (
976
+ * <OryProvider
977
+ * config={config}
978
+ * flow={flow}
979
+ * flowType={FlowType.Login}
980
+ * components={components}
981
+ * >
982
+ * {children}
983
+ * </OryProvider>
984
+ * )
985
+ * }
986
+ *
987
+ * ```
988
+ *
989
+ * @param props - The properties for the OryProvider component.
990
+ * @returns
991
+ * @group Components
992
+ */
632
993
  declare function OryProvider({ children, components: Components, config, ...oryFlowProps }: OryProviderProps): react_jsx_runtime.JSX.Element;
633
994
 
995
+ /**
996
+ * The Ory Elements configuration object.
997
+ *
998
+ * @interface
999
+ */
634
1000
  type OryElementsConfiguration = {
1001
+ /**
1002
+ * The Ory SDK configuration.
1003
+ * This includes the URL and options for the Ory SDK.
1004
+ */
635
1005
  sdk: OrySDK;
1006
+ /**
1007
+ * The project configuration.
1008
+ * This includes the project name, URLs, and other settings for the Ory Elements project.
1009
+ */
636
1010
  project: AccountExperienceConfiguration;
637
1011
  };
1012
+ /**
1013
+ * The `useOryConfiguration` hook provides access to the Ory Elements configuration.
1014
+ *
1015
+ * This includes the SDK configuration and the project configuration. To customize the configuration, provide the `sdk` and `project` properties in the `OryConfigurationProvider`.
1016
+ *
1017
+ * @returns the Ory Elements configuration, which includes the SDK and project configuration.
1018
+ * @group Hooks
1019
+ */
638
1020
  declare function useOryConfiguration(): OryElementsConfiguration;
639
1021
  type OrySDK = SDKConfig & {
640
1022
  /**
@@ -651,9 +1033,32 @@ type SDKConfig = {
651
1033
  url: string;
652
1034
  options?: Partial<ConfigurationParameters>;
653
1035
  };
654
- declare function OryConfigurationProvider({ children, sdk: initialConfig, project, }: PropsWithChildren<{
655
- sdk?: Partial<OryClientConfiguration["sdk"]>;
1036
+ /**
1037
+ * Props for the `OryConfigurationProvider` component.
1038
+ *
1039
+ * @hidden
1040
+ * @inline
1041
+ */
1042
+ interface OryConfigurationProviderProps extends PropsWithChildren {
1043
+ /**
1044
+ * The Ory SDK configuration to use.
1045
+ * If not provided, the SDK URL will be determined automatically based on the environment.
1046
+ *
1047
+ * Always required for production environments.
1048
+ */
1049
+ sdk?: OryClientConfiguration["sdk"];
1050
+ /**
1051
+ * This configuration is used to customize the behavior and appearance of Ory Elements.
1052
+ */
656
1053
  project?: Partial<AccountExperienceConfiguration>;
657
- }>): react_jsx_runtime.JSX.Element;
1054
+ }
1055
+ /**
1056
+ * The `OryConfigurationProvider` component provides the Ory Elements configuration to its children.
1057
+ *
1058
+ * @param props - The properties for the OryConfigurationProvider component.
1059
+ * @returns
1060
+ * @group Components
1061
+ */
1062
+ declare function OryConfigurationProvider({ children, sdk: initialConfig, project, }: OryConfigurationProviderProps): react_jsx_runtime.JSX.Element;
658
1063
 
659
- export { type ConsentFlow, type ConsentFlowContainer, type ErrorFlowContainer, type FlowContainerSetter, type FlowContextValue, type FormState, type FormStateAction, type FormStateMethodActive, type FormStateProvideIdentifier, type FormStateSelectMethod, 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, type OryCardSettingsSectionProps, OryCardValidationMessages, type OryClientConfiguration, OryConfigurationProvider, OryConsentCard, type OryElementsConfiguration, type OryFlowComponentOverrides, type OryFlowComponents, type OryFlowContainer, OryForm, OryFormGroupDivider, type OryFormGroupProps, OryFormGroups, type OryFormGroupsProps, OryFormOidcButtons, type OryFormOidcRootProps, type OryFormProps, type OryFormRootProps, OryFormSection, type OryFormSectionContentProps, type OryFormSectionFooterProps, type OryFormSectionProps, OryFormSocialButtonsForm, OryLocales, type OryMessageContentProps, type OryMessageRootProps, type OryNodeAnchorProps, type OryNodeButtonProps, type OryNodeCaptchaProps, type OryNodeConsentScopeCheckboxProps, 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, useOryConfiguration, useOryFlow };
1064
+ export { type ConsentFlow, type ConsentFlowContainer, type ErrorFlowContainer, type FlowContainerSetter, type FlowContextValue, type FormState, type FormStateAction, type FormStateMethodActive, type FormStateProvideIdentifier, type FormStateSelectMethod, 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, type OryCardSettingsSectionProps, OryCardValidationMessages, type OryCardValidationMessagesProps, type OryClientConfiguration, OryConfigurationProvider, OryConsentCard, type OryElementsConfiguration, type OryFlowComponentOverrides, type OryFlowComponents, type OryFlowContainer, OryForm, OryFormGroupDivider, type OryFormGroupProps, type OryFormProps, type OryFormRootProps, type OryFormSectionContentProps, type OryFormSectionFooterProps, type OryFormSectionProps, OryFormSsoButtons, OryFormSsoForm, type OryFormSsoRootProps, OryLocales, type OryMessageContentProps, type OryMessageRootProps, type OryNodeAnchorProps, type OryNodeButtonProps, type OryNodeCaptchaProps, type OryNodeConsentScopeCheckboxProps, type OryNodeImageProps, type OryNodeInputProps, type OryNodeLabelProps, type OryNodeSsoButtonProps, type OryNodeTextProps, OryPageHeader, type OryPageHeaderProps, OryProvider, type OryProviderProps, OrySelfServiceFlowCard, OrySettingsCard, type OrySettingsFormProps, OrySettingsFormSection, type OrySettingsPasskeyProps, type OrySettingsRecoveryCodesProps, type OrySettingsSsoProps, type OrySettingsTotpProps, type OrySettingsWebauthnProps, type OryToastProps, type RecoveryFlowContainer, type RegistrationFlowContainer, type SettingsFlowContainer, type VerificationFlowContainer, messageTestId, uiTextToFormattedMessage, useComponents, useNodeSorter, useOryConfiguration, useOryFlow };