@ory/elements-react 1.0.0-next.29 → 1.0.0-next.30

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 (166) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/index.d.mts +3 -6
  3. package/dist/index.d.ts +3 -6
  4. package/dist/index.js +253 -299
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +253 -299
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/theme/default/index.js +258 -248
  9. package/dist/theme/default/index.js.map +1 -1
  10. package/dist/theme/default/index.mjs +215 -205
  11. package/dist/theme/default/index.mjs.map +1 -1
  12. package/package.json +3 -3
  13. package/.storybook/global.css +0 -7
  14. package/.storybook/main.ts +0 -50
  15. package/.storybook/preview-head.html +0 -15
  16. package/.storybook/preview.tsx +0 -68
  17. package/.storybook/public/InterVariable.woff2 +0 -0
  18. package/.storybook/public/inter.css +0 -8
  19. package/.stub-responses/login/1fa/all-methods/initial-form.json +0 -247
  20. package/.stub-responses/login/1fa/all-methods/missing-email.json +0 -265
  21. package/.stub-responses/login/1fa/all-methods/wrong-credentials.json +0 -254
  22. package/.stub-responses/login/1fa/code/code-input.json +0 -135
  23. package/.stub-responses/login/1fa/code/initial-form.json +0 -173
  24. package/.stub-responses/login/1fa/code/invalid-account.json +0 -182
  25. package/.stub-responses/login/1fa/code/missing-email.json +0 -182
  26. package/.stub-responses/login/1fa/code/wrong-credentials.json +0 -124
  27. package/.stub-responses/login/1fa/none/initial-form.json +0 -33
  28. package/.stub-responses/login/1fa/oidc/initial-form.json +0 -279
  29. package/.stub-responses/login/1fa/passkey/initial-form.json +0 -122
  30. package/.stub-responses/login/1fa/password/initial-form.json +0 -154
  31. package/.stub-responses/login/1fa/password/missing-email.json +0 -172
  32. package/.stub-responses/login/1fa/password/wrong-credentials.json +0 -163
  33. package/.stub-responses/login/1fa/webauthn/initial-form.json +0 -76
  34. package/.stub-responses/login/1fa/webauthn/invalid-account.json +0 -83
  35. package/.stub-responses/login/1fa/webauthn/show-trigger.json +0 -105
  36. package/.stub-responses/recovery/disabled/initial-form.json +0 -9
  37. package/.stub-responses/recovery/none/initial-form.json +0 -9
  38. package/.stub-responses/registration/one-step/all-methods/initial-form.json +0 -334
  39. package/.stub-responses/registration/one-step/all-methods/missing-fields.json +0 -343
  40. package/.stub-responses/registration/one-step/disabled/initial-form.json +0 -10
  41. package/.stub-responses/registration/one-step/none/initial-form.json +0 -14
  42. package/.stub-responses/registration/one-step/oidc/initial-form.json +0 -338
  43. package/.stub-responses/registration/one-step/passkey/initial-form.json +0 -177
  44. package/.stub-responses/registration/one-step/password/initial-form.json +0 -154
  45. package/.stub-responses/registration/one-step/password/missing-fields.json +0 -172
  46. package/.stub-responses/registration/one-step/password/second-step.json +0 -164
  47. package/.stub-responses/registration/one-step/webauthn/initial-form.json +0 -185
  48. package/.stub-responses/registration/two-step/all-methods/enter-password.json +0 -242
  49. package/.stub-responses/registration/two-step/all-methods/initial-form.json +0 -180
  50. package/.stub-responses/registration/two-step/all-methods/missing-fields.json +0 -189
  51. package/.stub-responses/registration/two-step/all-methods/password-validation-error.json +0 -244
  52. package/.stub-responses/registration/two-step/password/enter-password.json +0 -108
  53. package/.stub-responses/registration/two-step/password/initial-form.json +0 -134
  54. package/.stub-responses/registration/two-step/password/missing-fields.json +0 -143
  55. package/.stub-responses/registration/two-step/password/password-validation-error.json +0 -110
  56. package/.stub-responses/settings/all-methods/change-password.json +0 -381
  57. package/.stub-responses/settings/all-methods/change-trait.json +0 -377
  58. package/.stub-responses/settings/all-methods/initial-form.json +0 -368
  59. package/.stub-responses/settings/oidc/with-provider.json +0 -230
  60. package/.stub-responses/settings/passkey/initial-form.json +0 -256
  61. package/.stub-responses/settings/webauthn/initial-form.json +0 -263
  62. package/.stub-responses/verification/disabled/initial-form.json +0 -9
  63. package/.stub-responses/verification/none/initial-form.json +0 -9
  64. package/stories/components/login/1fa/all.stories.ts +0 -46
  65. package/stories/components/login/1fa/code.stories.ts +0 -64
  66. package/stories/components/login/1fa/custom.stories.tsx +0 -72
  67. package/stories/components/login/1fa/none.stories.tsx +0 -28
  68. package/stories/components/login/1fa/oidc.stories.tsx +0 -143
  69. package/stories/components/login/1fa/passkey.stories.ts +0 -28
  70. package/stories/components/login/1fa/password.stories.ts +0 -46
  71. package/stories/components/login/1fa/webauthn.stories.ts +0 -46
  72. package/stories/components/registration/one-step/all-methods.stories.ts +0 -37
  73. package/stories/components/registration/one-step/password.stories.ts +0 -37
  74. package/stories/components/registration/one-step/webauthn.stories.ts +0 -28
  75. package/stories/components/registration/two-step/all-methods.stories.ts +0 -55
  76. package/stories/components/registration/two-step/password.stories.ts +0 -55
  77. package/stories/components/settings/all.stories.ts +0 -46
  78. package/stories/components/settings/oidc.stories.ts +0 -28
  79. package/stories/components/settings/passkey.stories.ts +0 -28
  80. package/stories/components/settings/webauthn.stories.ts +0 -28
  81. package/stories/pages/error.tsx +0 -29
  82. package/stories/utils.ts +0 -20
  83. package/storybook-static/InterVariable.woff2 +0 -0
  84. package/storybook-static/assets/Color-ERTF36HU-BdkKyVuV.js +0 -1
  85. package/storybook-static/assets/DocsRenderer-CFRXHY34-YqKt61zP.js +0 -595
  86. package/storybook-static/assets/all-methods.stories-B-rqPBX2.js +0 -11
  87. package/storybook-static/assets/all-methods.stories-CmMlhzsx.js +0 -21
  88. package/storybook-static/assets/all.stories-CtQ0yCQi.js +0 -16
  89. package/storybook-static/assets/all.stories-DgIVCzcZ.js +0 -16
  90. package/storybook-static/assets/chunk-H6MOWX77-DTQOW814.js +0 -1
  91. package/storybook-static/assets/code.stories-BbEryDcA.js +0 -26
  92. package/storybook-static/assets/custom.stories-DH2zHar9.js +0 -6
  93. package/storybook-static/assets/entry-preview-CcFGVifh.js +0 -10
  94. package/storybook-static/assets/entry-preview-docs-CyY-8bLe.js +0 -54
  95. package/storybook-static/assets/iframe-C5GAfuxh.js +0 -2
  96. package/storybook-static/assets/index-BVoBHvaS.js +0 -8
  97. package/storybook-static/assets/index-CfOt2XX2.js +0 -24
  98. package/storybook-static/assets/index-DPRSEdy-.js +0 -1
  99. package/storybook-static/assets/index-DrFu-skq.js +0 -6
  100. package/storybook-static/assets/index-FeUjBnvO.js +0 -1
  101. package/storybook-static/assets/index-uubelm5h.js +0 -9
  102. package/storybook-static/assets/initial-form-DWp_1F-f.js +0 -1
  103. package/storybook-static/assets/jsx-runtime-QvZ8i92b.js +0 -9
  104. package/storybook-static/assets/none.stories-TAeRhzd5.js +0 -6
  105. package/storybook-static/assets/oidc.stories-CniWBy7t.js +0 -58
  106. package/storybook-static/assets/oidc.stories-jhWzAyoQ.js +0 -6
  107. package/storybook-static/assets/passkey.stories-CBtjoVSN.js +0 -6
  108. package/storybook-static/assets/passkey.stories-CQU2Xw_t.js +0 -6
  109. package/storybook-static/assets/password.stories-0s6cDl0o.js +0 -11
  110. package/storybook-static/assets/password.stories-B2Wtckz_.js +0 -16
  111. package/storybook-static/assets/password.stories-DX0gkWjH.js +0 -21
  112. package/storybook-static/assets/preview-BBWR9nbA.js +0 -1
  113. package/storybook-static/assets/preview-BPAmP-pY.js +0 -2
  114. package/storybook-static/assets/preview-BWzBA1C2.js +0 -396
  115. package/storybook-static/assets/preview-BXtF2ySE.js +0 -234
  116. package/storybook-static/assets/preview-Cur_8nCX.css +0 -1
  117. package/storybook-static/assets/preview-D77C14du.js +0 -34
  118. package/storybook-static/assets/preview-DCjDUH0w.js +0 -27
  119. package/storybook-static/assets/preview-DFmD0pui.js +0 -1
  120. package/storybook-static/assets/preview-DGUiP6tS.js +0 -7
  121. package/storybook-static/assets/preview-aVwhiz9X.js +0 -1
  122. package/storybook-static/assets/react-18-CtsMCmcS.js +0 -1
  123. package/storybook-static/assets/settings-BqEFC2-V.css +0 -1
  124. package/storybook-static/assets/settings-Bx4osEmB.js +0 -2304
  125. package/storybook-static/assets/webauthn.stories-BzodmV0c.js +0 -6
  126. package/storybook-static/assets/webauthn.stories-DglGm7Ys.js +0 -6
  127. package/storybook-static/assets/webauthn.stories-G9E76Wjj.js +0 -16
  128. package/storybook-static/favicon.svg +0 -1
  129. package/storybook-static/iframe.html +0 -654
  130. package/storybook-static/index.html +0 -173
  131. package/storybook-static/index.json +0 -1
  132. package/storybook-static/inter.css +0 -8
  133. package/storybook-static/nunito-sans-bold-italic.woff2 +0 -0
  134. package/storybook-static/nunito-sans-bold.woff2 +0 -0
  135. package/storybook-static/nunito-sans-italic.woff2 +0 -0
  136. package/storybook-static/nunito-sans-regular.woff2 +0 -0
  137. package/storybook-static/preview-stats.json +0 -2344
  138. package/storybook-static/sb-addons/essentials-actions-2/manager-bundle.js +0 -3
  139. package/storybook-static/sb-addons/essentials-actions-2/manager-bundle.js.LEGAL.txt +0 -0
  140. package/storybook-static/sb-addons/essentials-backgrounds-3/manager-bundle.js +0 -12
  141. package/storybook-static/sb-addons/essentials-backgrounds-3/manager-bundle.js.LEGAL.txt +0 -0
  142. package/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js +0 -394
  143. package/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js.LEGAL.txt +0 -0
  144. package/storybook-static/sb-addons/essentials-measure-6/manager-bundle.js +0 -3
  145. package/storybook-static/sb-addons/essentials-measure-6/manager-bundle.js.LEGAL.txt +0 -0
  146. package/storybook-static/sb-addons/essentials-outline-7/manager-bundle.js +0 -3
  147. package/storybook-static/sb-addons/essentials-outline-7/manager-bundle.js.LEGAL.txt +0 -0
  148. package/storybook-static/sb-addons/essentials-toolbars-5/manager-bundle.js +0 -3
  149. package/storybook-static/sb-addons/essentials-toolbars-5/manager-bundle.js.LEGAL.txt +0 -0
  150. package/storybook-static/sb-addons/essentials-viewport-4/manager-bundle.js +0 -3
  151. package/storybook-static/sb-addons/essentials-viewport-4/manager-bundle.js.LEGAL.txt +0 -0
  152. package/storybook-static/sb-addons/interactions-8/manager-bundle.js +0 -211
  153. package/storybook-static/sb-addons/interactions-8/manager-bundle.js.LEGAL.txt +0 -0
  154. package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js +0 -3
  155. package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js.LEGAL.txt +0 -0
  156. package/storybook-static/sb-common-assets/favicon.svg +0 -1
  157. package/storybook-static/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
  158. package/storybook-static/sb-common-assets/nunito-sans-bold.woff2 +0 -0
  159. package/storybook-static/sb-common-assets/nunito-sans-italic.woff2 +0 -0
  160. package/storybook-static/sb-common-assets/nunito-sans-regular.woff2 +0 -0
  161. package/storybook-static/sb-manager/globals-module-info.js +0 -1006
  162. package/storybook-static/sb-manager/globals-runtime.js +0 -54400
  163. package/storybook-static/sb-manager/globals.js +0 -48
  164. package/storybook-static/sb-manager/runtime.js +0 -12089
  165. package/storybook-static/sb-preview/globals.js +0 -33
  166. package/storybook-static/sb-preview/runtime.js +0 -9498
package/dist/index.js CHANGED
@@ -92,7 +92,7 @@ function isChoosingMethod(uiNodes) {
92
92
  (node) => node.group === clientFetch.UiNodeGroupEnum.IdentifierFirst && "name" in node.attributes && node.attributes.name === "identifier" && node.attributes.type === "hidden"
93
93
  );
94
94
  }
95
- function filterZeroStepGroups(nodes) {
95
+ function filterOidcOut(nodes) {
96
96
  return nodes.filter((node) => node.group !== clientFetch.UiNodeGroupEnum.Oidc);
97
97
  }
98
98
  function getFinalNodes(uniqueGroups, selectedGroup) {
@@ -153,7 +153,7 @@ function triggerToFunction(trigger) {
153
153
  }
154
154
  return triggerFn;
155
155
  }
156
- function nodesToAuthMethodGroups(nodes, excludeAuthMethods = [clientFetch.UiNodeGroupEnum.Oidc]) {
156
+ function nodesToAuthMethodGroups(nodes, excludeAuthMethods = []) {
157
157
  var _a;
158
158
  const groups = {};
159
159
  for (const node of nodes) {
@@ -341,139 +341,6 @@ function OryCardHeader() {
341
341
  const { Card } = useComponents();
342
342
  return /* @__PURE__ */ jsxRuntime.jsx(Card.Header, {});
343
343
  }
344
- function OryCardFooter() {
345
- const { Card } = useComponents();
346
- return /* @__PURE__ */ jsxRuntime.jsx(Card.Footer, {});
347
- }
348
- var NodeInput = ({
349
- node,
350
- attributes
351
- }) => {
352
- var _a;
353
- const { Node: Node2 } = useComponents();
354
- const { setValue } = reactHookForm.useFormContext();
355
- const {
356
- onloadTrigger,
357
- onclickTrigger,
358
- // These properties do not exist on input fields so we remove them (as we already have handled them).
359
- onclick: _ignoredOnclick,
360
- onload: _ignoredOnload,
361
- //
362
- ...attrs
363
- } = attributes;
364
- const isResendNode = ((_a = node.meta.label) == null ? void 0 : _a.id) === 1070008;
365
- const isScreenSelectionNode = "name" in node.attributes && node.attributes.name === "screen";
366
- const setFormValue = () => {
367
- if (attrs.value && !(isResendNode || isScreenSelectionNode)) {
368
- setValue(attrs.name, attrs.value);
369
- }
370
- };
371
- const hasRun = react.useRef(false);
372
- react.useEffect(
373
- () => {
374
- setFormValue();
375
- if (!hasRun.current && onloadTrigger) {
376
- hasRun.current = true;
377
- triggerToWindowCall(onloadTrigger);
378
- }
379
- },
380
- // TODO(jonas): make sure onloadTrigger is stable
381
- // eslint-disable-next-line react-hooks/exhaustive-deps -- ignore onloadTrigger for now, until we make sure this is stable
382
- []
383
- );
384
- const handleClick = () => {
385
- setFormValue();
386
- if (onclickTrigger) {
387
- triggerToWindowCall(onclickTrigger);
388
- }
389
- };
390
- const isSocial = (attrs.name === "provider" || attrs.name === "link") && node.group === "oidc";
391
- const isPinCodeInput = attrs.name === "code" && node.group === "code" || attrs.name === "totp_code" && node.group === "totp";
392
- switch (attributes.type) {
393
- case clientFetch.UiNodeInputAttributesTypeEnum.Submit:
394
- case clientFetch.UiNodeInputAttributesTypeEnum.Button:
395
- if (isSocial) {
396
- return /* @__PURE__ */ jsxRuntime.jsx(Node2.OidcButton, { attributes: attrs, node });
397
- }
398
- if (isResendNode || isScreenSelectionNode) {
399
- return null;
400
- }
401
- return /* @__PURE__ */ jsxRuntime.jsx(
402
- Node2.Label,
403
- {
404
- attributes: { ...attrs, label: void 0 },
405
- node: { ...node, meta: { ...node.meta, label: void 0 } },
406
- children: /* @__PURE__ */ jsxRuntime.jsx(Node2.Button, { attributes: attrs, node, onClick: handleClick })
407
- }
408
- );
409
- case clientFetch.UiNodeInputAttributesTypeEnum.DatetimeLocal:
410
- throw new Error("Not implemented");
411
- case clientFetch.UiNodeInputAttributesTypeEnum.Checkbox:
412
- return /* @__PURE__ */ jsxRuntime.jsx(
413
- Node2.Label,
414
- {
415
- attributes: { ...attrs, label: void 0 },
416
- node: { ...node, meta: { ...node.meta, label: void 0 } },
417
- children: /* @__PURE__ */ jsxRuntime.jsx(Node2.Checkbox, { attributes: attrs, node, onClick: handleClick })
418
- }
419
- );
420
- case clientFetch.UiNodeInputAttributesTypeEnum.Hidden:
421
- return /* @__PURE__ */ jsxRuntime.jsx(Node2.Input, { attributes: attrs, node, onClick: handleClick });
422
- default:
423
- if (isPinCodeInput) {
424
- return /* @__PURE__ */ jsxRuntime.jsx(Node2.Label, { attributes: attrs, node, children: /* @__PURE__ */ jsxRuntime.jsx(
425
- Node2.CodeInput,
426
- {
427
- attributes: attrs,
428
- node,
429
- onClick: handleClick
430
- }
431
- ) });
432
- }
433
- return /* @__PURE__ */ jsxRuntime.jsx(Node2.Label, { attributes: attrs, node, children: /* @__PURE__ */ jsxRuntime.jsx(Node2.Input, { attributes: attrs, node, onClick: handleClick }) });
434
- }
435
- };
436
- var Node = ({ node, onClick }) => {
437
- const { Node: Node2 } = useComponents();
438
- if (clientFetch.isUiNodeImageAttributes(node.attributes)) {
439
- return /* @__PURE__ */ jsxRuntime.jsx(Node2.Image, { node, attributes: node.attributes });
440
- } else if (clientFetch.isUiNodeTextAttributes(node.attributes)) {
441
- const attrs = node.attributes;
442
- return /* @__PURE__ */ jsxRuntime.jsx(Node2.Text, { attributes: attrs, node });
443
- } else if (clientFetch.isUiNodeInputAttributes(node.attributes)) {
444
- return /* @__PURE__ */ jsxRuntime.jsx(NodeInput, { node, attributes: node.attributes, onClick });
445
- } else if (clientFetch.isUiNodeAnchorAttributes(node.attributes)) {
446
- return /* @__PURE__ */ jsxRuntime.jsx(Node2.Anchor, { attributes: node.attributes, node });
447
- } else if (clientFetch.isUiNodeScriptAttributes(node.attributes)) {
448
- const {
449
- crossorigin,
450
- referrerpolicy,
451
- node_type: _nodeType,
452
- ...attributes
453
- } = node.attributes;
454
- return /* @__PURE__ */ jsxRuntime.jsx(
455
- "script",
456
- {
457
- crossOrigin: crossorigin,
458
- referrerPolicy: referrerpolicy,
459
- ...attributes
460
- }
461
- );
462
- }
463
- return null;
464
- };
465
- function OryFormGroups({ children, groups }) {
466
- const {
467
- flow: { ui }
468
- } = useOryFlow();
469
- const nodeSorter = useNodeSorter();
470
- const { flowType } = useOryFlow();
471
- const { Form } = useComponents();
472
- const nodes = ui.nodes.filter((node) => groups.indexOf(node.group) > -1).sort((a, b) => nodeSorter(a, b, { flowType }));
473
- return /* @__PURE__ */ jsxRuntime.jsx(Form.Group, { children: children != null ? children : nodes.map((node, k) => {
474
- return /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k);
475
- }) });
476
- }
477
344
  function computeDefaultValues(nodes) {
478
345
  return nodes.reduce((acc, node) => {
479
346
  const attrs = node.attributes;
@@ -559,52 +426,22 @@ function OryFormProvider({
559
426
  });
560
427
  return /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.FormProvider, { ...methods, children });
561
428
  }
562
- function OryFormOidcButtons({
563
- children,
564
- hideDivider
565
- }) {
566
- const {
567
- flow: { ui }
568
- } = useOryFlow();
569
- const { setValue } = reactHookForm.useFormContext();
570
- const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
571
- const { Form, Card, Node: Node2 } = useComponents();
572
- if (filteredNodes.length === 0) {
573
- return null;
574
- }
575
- const otherNodes = ui.nodes.filter(
576
- (node) => node.group !== "oidc" && node.group !== "default"
577
- );
578
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
579
- /* @__PURE__ */ jsxRuntime.jsx(Form.OidcRoot, { nodes: filteredNodes, children: children != null ? children : filteredNodes.map((node, k) => {
580
- return /* @__PURE__ */ jsxRuntime.jsx(
581
- Node2.OidcButton,
582
- {
583
- node,
584
- attributes: node.attributes,
585
- onClick: () => {
586
- setValue(
587
- "provider",
588
- node.attributes.value
589
- );
590
- setValue("method", "oidc");
591
- }
592
- },
593
- k
594
- );
595
- }) }),
596
- !hideDivider && filteredNodes.length > 0 && otherNodes.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {})
597
- ] });
429
+ function OryCard({ children }) {
430
+ const { Card } = useComponents();
431
+ return /* @__PURE__ */ jsxRuntime.jsx(Card.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(OryFormProvider, { children }) });
598
432
  }
599
- function OryFormSocialButtonsForm() {
600
- const {
601
- flow: { ui }
602
- } = useOryFlow();
603
- const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
604
- if (filteredNodes.length === 0) {
605
- return null;
606
- }
607
- return /* @__PURE__ */ jsxRuntime.jsx(OryFormProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(OryForm, { children: /* @__PURE__ */ jsxRuntime.jsx(OryFormOidcButtons, {}) }) });
433
+ function OryCardFooter() {
434
+ const { Card } = useComponents();
435
+ return /* @__PURE__ */ jsxRuntime.jsx(Card.Footer, {});
436
+ }
437
+ function OryCardContent({ children }) {
438
+ const { Card } = useComponents();
439
+ return /* @__PURE__ */ jsxRuntime.jsx(Card.Content, { children });
440
+ }
441
+
442
+ // src/theme/default/utils/form.ts
443
+ function isGroupImmediateSubmit(group) {
444
+ return group === "code";
608
445
  }
609
446
  function frontendClient(sdkUrl, opts = {}) {
610
447
  const config = new clientFetch.Configuration({
@@ -984,7 +821,7 @@ function OryForm({ children, onAfterSubmit }) {
984
821
  const methods = reactHookForm.useFormContext();
985
822
  const intl = reactIntl.useIntl();
986
823
  const onSubmit = useOryFormSubmit(onAfterSubmit);
987
- const hasMethods = flowContainer.flow.ui.nodes.filter((node) => {
824
+ const hasMethods = flowContainer.flow.ui.nodes.some((node) => {
988
825
  if (clientFetch.isUiNodeInputAttributes(node.attributes)) {
989
826
  return node.attributes.name !== "csrf_token";
990
827
  } else if (clientFetch.isUiNodeAnchorAttributes(node.attributes)) {
@@ -995,7 +832,7 @@ function OryForm({ children, onAfterSubmit }) {
995
832
  return true;
996
833
  }
997
834
  return false;
998
- }).length > 0;
835
+ });
999
836
  if (!hasMethods && ((_a = flowContainer.flow.ui.messages) != null ? _a : []).length === 0) {
1000
837
  return intl.formatMessage({
1001
838
  id: `identities.messages.${5000002}`,
@@ -1008,22 +845,7 @@ function OryForm({ children, onAfterSubmit }) {
1008
845
  action: flowContainer.flow.ui.action,
1009
846
  method: flowContainer.flow.ui.method,
1010
847
  onSubmit: (e) => void methods.handleSubmit(onSubmit)(e),
1011
- children: children != null ? children : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1012
- /* @__PURE__ */ jsxRuntime.jsx(OryFormOidcButtons, {}),
1013
- /* @__PURE__ */ jsxRuntime.jsx(
1014
- OryFormGroups,
1015
- {
1016
- groups: [
1017
- "default",
1018
- "password",
1019
- "code",
1020
- "webauthn",
1021
- "passkey",
1022
- "identifier_first"
1023
- ]
1024
- }
1025
- )
1026
- ] })
848
+ children
1027
849
  }
1028
850
  );
1029
851
  }
@@ -1040,88 +862,176 @@ function OryCardValidationMessages({ ...props }) {
1040
862
  }
1041
863
  return /* @__PURE__ */ jsxRuntime.jsx(Message.Root, { ...props, children: messages == null ? void 0 : messages.map((message) => /* @__PURE__ */ jsxRuntime.jsx(Message.Content, { message }, message.id)) });
1042
864
  }
1043
- function OryFormSection({
1044
- children,
1045
- nodes,
1046
- ...rest
1047
- }) {
1048
- return /* @__PURE__ */ jsxRuntime.jsx(OryFormProvider, { nodes, children: /* @__PURE__ */ jsxRuntime.jsx(OryFormSectionInner, { ...rest, children }) });
1049
- }
1050
- function OryFormSectionInner({
1051
- children,
1052
- ...rest
1053
- }) {
1054
- const { Card } = useComponents();
1055
- const flowContainer = useOryFlow();
1056
- const onSubmit = useOryFormSubmit();
1057
- const methods = reactHookForm.useFormContext();
1058
- return /* @__PURE__ */ jsxRuntime.jsx(
1059
- Card.SettingsSection,
1060
- {
1061
- action: flowContainer.flow.ui.action,
1062
- method: flowContainer.flow.ui.method,
1063
- onSubmit: (e) => void methods.handleSubmit(onSubmit)(e),
1064
- ...rest,
1065
- children
865
+ var NodeInput = ({
866
+ node,
867
+ attributes
868
+ }) => {
869
+ var _a;
870
+ const { Node: Node2 } = useComponents();
871
+ const { setValue } = reactHookForm.useFormContext();
872
+ const {
873
+ onloadTrigger,
874
+ onclickTrigger,
875
+ // These properties do not exist on input fields so we remove them (as we already have handled them).
876
+ onclick: _ignoredOnclick,
877
+ onload: _ignoredOnload,
878
+ //
879
+ ...attrs
880
+ } = attributes;
881
+ const isResendNode = ((_a = node.meta.label) == null ? void 0 : _a.id) === 1070008;
882
+ const isScreenSelectionNode = "name" in node.attributes && node.attributes.name === "screen";
883
+ const setFormValue = () => {
884
+ if (attrs.value && !(isResendNode || isScreenSelectionNode)) {
885
+ setValue(attrs.name, attrs.value);
1066
886
  }
887
+ };
888
+ const hasRun = react.useRef(false);
889
+ react.useEffect(
890
+ () => {
891
+ setFormValue();
892
+ if (!hasRun.current && onloadTrigger) {
893
+ hasRun.current = true;
894
+ triggerToWindowCall(onloadTrigger);
895
+ }
896
+ },
897
+ // TODO(jonas): make sure onloadTrigger is stable
898
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- ignore onloadTrigger for now, until we make sure this is stable
899
+ []
1067
900
  );
1068
- }
1069
- function OryCardContent({ children }) {
1070
- const { Card } = useComponents();
1071
- if (children) {
1072
- return /* @__PURE__ */ jsxRuntime.jsx(Card.Content, { children });
1073
- }
1074
- return /* @__PURE__ */ jsxRuntime.jsxs(Card.Content, { children: [
1075
- /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
1076
- /* @__PURE__ */ jsxRuntime.jsxs(OryForm, { children: [
1077
- /* @__PURE__ */ jsxRuntime.jsx(OryFormOidcButtons, {}),
1078
- /* @__PURE__ */ jsxRuntime.jsx(
1079
- OryFormGroups,
901
+ const handleClick = () => {
902
+ setFormValue();
903
+ if (onclickTrigger) {
904
+ triggerToWindowCall(onclickTrigger);
905
+ }
906
+ };
907
+ const isSocial = (attrs.name === "provider" || attrs.name === "link") && node.group === "oidc";
908
+ const isPinCodeInput = attrs.name === "code" && node.group === "code" || attrs.name === "totp_code" && node.group === "totp";
909
+ switch (attributes.type) {
910
+ case clientFetch.UiNodeInputAttributesTypeEnum.Submit:
911
+ case clientFetch.UiNodeInputAttributesTypeEnum.Button:
912
+ if (isSocial) {
913
+ return null;
914
+ }
915
+ if (isResendNode || isScreenSelectionNode) {
916
+ return null;
917
+ }
918
+ return /* @__PURE__ */ jsxRuntime.jsx(
919
+ Node2.Label,
1080
920
  {
1081
- groups: [
1082
- "default",
1083
- "password",
1084
- "passkey",
1085
- "code",
1086
- "webauthn",
1087
- "profile",
1088
- "totp",
1089
- "identifier_first"
1090
- ]
921
+ attributes: { ...attrs, label: void 0 },
922
+ node: { ...node, meta: { ...node.meta, label: void 0 } },
923
+ children: /* @__PURE__ */ jsxRuntime.jsx(Node2.Button, { attributes: attrs, node, onClick: handleClick })
1091
924
  }
1092
- )
1093
- ] })
1094
- ] });
925
+ );
926
+ case clientFetch.UiNodeInputAttributesTypeEnum.DatetimeLocal:
927
+ throw new Error("Not implemented");
928
+ case clientFetch.UiNodeInputAttributesTypeEnum.Checkbox:
929
+ return /* @__PURE__ */ jsxRuntime.jsx(
930
+ Node2.Label,
931
+ {
932
+ attributes: { ...attrs, label: void 0 },
933
+ node: { ...node, meta: { ...node.meta, label: void 0 } },
934
+ children: /* @__PURE__ */ jsxRuntime.jsx(Node2.Checkbox, { attributes: attrs, node, onClick: handleClick })
935
+ }
936
+ );
937
+ case clientFetch.UiNodeInputAttributesTypeEnum.Hidden:
938
+ return /* @__PURE__ */ jsxRuntime.jsx(Node2.Input, { attributes: attrs, node, onClick: handleClick });
939
+ default:
940
+ if (isPinCodeInput) {
941
+ return /* @__PURE__ */ jsxRuntime.jsx(Node2.Label, { attributes: attrs, node, children: /* @__PURE__ */ jsxRuntime.jsx(
942
+ Node2.CodeInput,
943
+ {
944
+ attributes: attrs,
945
+ node,
946
+ onClick: handleClick
947
+ }
948
+ ) });
949
+ }
950
+ return /* @__PURE__ */ jsxRuntime.jsx(Node2.Label, { attributes: attrs, node, children: /* @__PURE__ */ jsxRuntime.jsx(Node2.Input, { attributes: attrs, node, onClick: handleClick }) });
951
+ }
952
+ };
953
+ var Node = ({ node, onClick }) => {
954
+ const { Node: Node2 } = useComponents();
955
+ if (clientFetch.isUiNodeImageAttributes(node.attributes)) {
956
+ return /* @__PURE__ */ jsxRuntime.jsx(Node2.Image, { node, attributes: node.attributes });
957
+ } else if (clientFetch.isUiNodeTextAttributes(node.attributes)) {
958
+ const attrs = node.attributes;
959
+ return /* @__PURE__ */ jsxRuntime.jsx(Node2.Text, { attributes: attrs, node });
960
+ } else if (clientFetch.isUiNodeInputAttributes(node.attributes)) {
961
+ return /* @__PURE__ */ jsxRuntime.jsx(NodeInput, { node, attributes: node.attributes, onClick });
962
+ } else if (clientFetch.isUiNodeAnchorAttributes(node.attributes)) {
963
+ return /* @__PURE__ */ jsxRuntime.jsx(Node2.Anchor, { attributes: node.attributes, node });
964
+ } else if (clientFetch.isUiNodeScriptAttributes(node.attributes)) {
965
+ const {
966
+ crossorigin,
967
+ referrerpolicy,
968
+ node_type: _nodeType,
969
+ ...attributes
970
+ } = node.attributes;
971
+ return /* @__PURE__ */ jsxRuntime.jsx(
972
+ "script",
973
+ {
974
+ crossOrigin: crossorigin,
975
+ referrerPolicy: referrerpolicy,
976
+ ...attributes
977
+ }
978
+ );
979
+ }
980
+ return null;
981
+ };
982
+ function OryFormOidcButtons() {
983
+ const {
984
+ flow: { ui }
985
+ } = useOryFlow();
986
+ const { setValue } = reactHookForm.useFormContext();
987
+ const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
988
+ const { Form, Node: Node2 } = useComponents();
989
+ if (filteredNodes.length === 0) {
990
+ return null;
991
+ }
992
+ return /* @__PURE__ */ jsxRuntime.jsx(Form.OidcRoot, { nodes: filteredNodes, children: filteredNodes.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(
993
+ Node2.OidcButton,
994
+ {
995
+ node,
996
+ attributes: node.attributes,
997
+ onClick: () => {
998
+ setValue(
999
+ "provider",
1000
+ node.attributes.value
1001
+ );
1002
+ setValue("method", "oidc");
1003
+ }
1004
+ },
1005
+ k
1006
+ )) });
1095
1007
  }
1096
- function OryCard({ children }) {
1097
- const { Card } = useComponents();
1098
- if (children) {
1099
- return /* @__PURE__ */ jsxRuntime.jsx(Card.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(OryFormProvider, { children }) });
1008
+ function OryFormSocialButtonsForm() {
1009
+ const {
1010
+ flow: { ui }
1011
+ } = useOryFlow();
1012
+ const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
1013
+ if (filteredNodes.length === 0) {
1014
+ return null;
1100
1015
  }
1101
- return /* @__PURE__ */ jsxRuntime.jsx(Card.Root, { children: /* @__PURE__ */ jsxRuntime.jsxs(OryFormProvider, { children: [
1102
- /* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
1103
- /* @__PURE__ */ jsxRuntime.jsx(OryCardContent, {}),
1104
- /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1105
- ] }) });
1016
+ return /* @__PURE__ */ jsxRuntime.jsx(OryFormProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(OryForm, { children: /* @__PURE__ */ jsxRuntime.jsx(OryFormOidcButtons, {}) }) });
1106
1017
  }
1107
-
1108
- // src/theme/default/utils/form.ts
1109
- function isGroupImmediateSubmit(group) {
1110
- return group === "code";
1018
+ function isUINodeGroupEnum(method) {
1019
+ return Object.values(clientFetch.UiNodeGroupEnum).includes(method);
1111
1020
  }
1112
1021
  function OryTwoStepCard() {
1113
- var _a;
1114
1022
  const {
1115
- flow: { ui }
1023
+ flow: { ui },
1024
+ flowType,
1025
+ formState,
1026
+ dispatchFormState
1116
1027
  } = useOryFlow();
1117
1028
  const { Form, Card } = useComponents();
1118
- const { flowType, formState, dispatchFormState } = useOryFlow();
1119
1029
  const nodeSorter = useNodeSorter();
1120
1030
  const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
1121
1031
  const uniqueGroups = useNodesGroups(ui.nodes);
1122
1032
  const options = Object.values(clientFetch.UiNodeGroupEnum).filter((group) => {
1123
- var _a2;
1124
- return (_a2 = uniqueGroups.groups[group]) == null ? void 0 : _a2.length;
1033
+ var _a;
1034
+ return (_a = uniqueGroups.groups[group]) == null ? void 0 : _a.length;
1125
1035
  }).filter(
1126
1036
  (group) => ![
1127
1037
  clientFetch.UiNodeGroupEnum.Oidc,
@@ -1130,46 +1040,52 @@ function OryTwoStepCard() {
1130
1040
  clientFetch.UiNodeGroupEnum.Profile
1131
1041
  ].includes(group)
1132
1042
  );
1133
- const hasOidc = Boolean((_a = uniqueGroups.groups[clientFetch.UiNodeGroupEnum.Oidc]) == null ? void 0 : _a.length);
1134
- const zeroStepGroups = filterZeroStepGroups(ui.nodes);
1043
+ const nonOidcNodes = filterOidcOut(ui.nodes);
1135
1044
  const finalNodes = formState.current === "method_active" ? getFinalNodes(uniqueGroups.groups, formState.method) : [];
1045
+ const handleAfterFormSubmit = (method) => {
1046
+ if (typeof method !== "string" || !isUINodeGroupEnum(method)) {
1047
+ return;
1048
+ }
1049
+ if (isGroupImmediateSubmit(method)) {
1050
+ dispatchFormState({
1051
+ type: "action_select_method",
1052
+ method
1053
+ });
1054
+ }
1055
+ };
1056
+ const hasOidc = ui.nodes.some((node) => node.group === clientFetch.UiNodeGroupEnum.Oidc);
1057
+ const showOidc = !(formState.current === "method_active" && formState.method !== "oidc");
1136
1058
  return /* @__PURE__ */ jsxRuntime.jsxs(OryCard, { children: [
1137
1059
  /* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
1138
1060
  /* @__PURE__ */ jsxRuntime.jsxs(OryCardContent, { children: [
1139
1061
  /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
1140
- formState.current === "provide_identifier" && hasOidc && /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
1141
- /* @__PURE__ */ jsxRuntime.jsxs(
1142
- OryForm,
1143
- {
1144
- onAfterSubmit: (method) => isGroupImmediateSubmit(method + "") ? dispatchFormState({
1145
- type: "action_select_method",
1146
- method
1147
- }) : void 0,
1148
- children: [
1149
- /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1150
- formState.current === "provide_identifier" && zeroStepGroups.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)),
1151
- formState.current === "select_method" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1152
- /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1153
- /* @__PURE__ */ jsxRuntime.jsx(
1154
- AuthMethodList,
1155
- {
1156
- options,
1157
- setSelectedGroup: (group) => dispatchFormState({
1158
- type: "action_select_method",
1159
- method: group
1160
- })
1161
- }
1162
- )
1163
- ] }),
1164
- formState.current === "method_active" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1165
- ui.nodes.filter((n) => n.type === "script").map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)),
1166
- finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1167
- ] })
1168
- ] }),
1169
- /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1170
- ]
1171
- }
1172
- )
1062
+ showOidc && /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
1063
+ /* @__PURE__ */ jsxRuntime.jsxs(OryForm, { onAfterSubmit: handleAfterFormSubmit, children: [
1064
+ /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1065
+ formState.current === "provide_identifier" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1066
+ hasOidc && /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1067
+ nonOidcNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1068
+ ] }),
1069
+ formState.current === "select_method" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1070
+ /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1071
+ /* @__PURE__ */ jsxRuntime.jsx(
1072
+ AuthMethodList,
1073
+ {
1074
+ options,
1075
+ setSelectedGroup: (group) => dispatchFormState({
1076
+ type: "action_select_method",
1077
+ method: group
1078
+ })
1079
+ }
1080
+ )
1081
+ ] }),
1082
+ formState.current === "method_active" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1083
+ ui.nodes.filter((n) => n.type === "script").map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)),
1084
+ finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1085
+ ] })
1086
+ ] }),
1087
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1088
+ ] })
1173
1089
  ] })
1174
1090
  ] });
1175
1091
  }
@@ -1192,6 +1108,44 @@ function AuthMethodList({ options, setSelectedGroup }) {
1192
1108
  option
1193
1109
  )) });
1194
1110
  }
1111
+ function OryFormGroups({ groups }) {
1112
+ const {
1113
+ flow: { ui }
1114
+ } = useOryFlow();
1115
+ const nodeSorter = useNodeSorter();
1116
+ const { flowType } = useOryFlow();
1117
+ const { Form } = useComponents();
1118
+ const nodes = ui.nodes.filter((node) => groups.indexOf(node.group) > -1).sort((a, b) => nodeSorter(a, b, { flowType }));
1119
+ return /* @__PURE__ */ jsxRuntime.jsx(Form.Group, { children: nodes.map((node, k) => {
1120
+ return /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k);
1121
+ }) });
1122
+ }
1123
+ function OryFormSection({
1124
+ children,
1125
+ nodes,
1126
+ ...rest
1127
+ }) {
1128
+ return /* @__PURE__ */ jsxRuntime.jsx(OryFormProvider, { nodes, children: /* @__PURE__ */ jsxRuntime.jsx(OryFormSectionInner, { ...rest, children }) });
1129
+ }
1130
+ function OryFormSectionInner({
1131
+ children,
1132
+ ...rest
1133
+ }) {
1134
+ const { Card } = useComponents();
1135
+ const flowContainer = useOryFlow();
1136
+ const onSubmit = useOryFormSubmit();
1137
+ const methods = reactHookForm.useFormContext();
1138
+ return /* @__PURE__ */ jsxRuntime.jsx(
1139
+ Card.SettingsSection,
1140
+ {
1141
+ action: flowContainer.flow.ui.action,
1142
+ method: flowContainer.flow.ui.method,
1143
+ onSubmit: (e) => void methods.handleSubmit(onSubmit)(e),
1144
+ ...rest,
1145
+ children
1146
+ }
1147
+ );
1148
+ }
1195
1149
  function OryFormGroupDivider() {
1196
1150
  const { Card } = useComponents();
1197
1151
  const {