@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.mjs CHANGED
@@ -90,7 +90,7 @@ function isChoosingMethod(uiNodes) {
90
90
  (node) => node.group === UiNodeGroupEnum.IdentifierFirst && "name" in node.attributes && node.attributes.name === "identifier" && node.attributes.type === "hidden"
91
91
  );
92
92
  }
93
- function filterZeroStepGroups(nodes) {
93
+ function filterOidcOut(nodes) {
94
94
  return nodes.filter((node) => node.group !== UiNodeGroupEnum.Oidc);
95
95
  }
96
96
  function getFinalNodes(uniqueGroups, selectedGroup) {
@@ -151,7 +151,7 @@ function triggerToFunction(trigger) {
151
151
  }
152
152
  return triggerFn;
153
153
  }
154
- function nodesToAuthMethodGroups(nodes, excludeAuthMethods = [UiNodeGroupEnum.Oidc]) {
154
+ function nodesToAuthMethodGroups(nodes, excludeAuthMethods = []) {
155
155
  var _a;
156
156
  const groups = {};
157
157
  for (const node of nodes) {
@@ -339,139 +339,6 @@ function OryCardHeader() {
339
339
  const { Card } = useComponents();
340
340
  return /* @__PURE__ */ jsx(Card.Header, {});
341
341
  }
342
- function OryCardFooter() {
343
- const { Card } = useComponents();
344
- return /* @__PURE__ */ jsx(Card.Footer, {});
345
- }
346
- var NodeInput = ({
347
- node,
348
- attributes
349
- }) => {
350
- var _a;
351
- const { Node: Node2 } = useComponents();
352
- const { setValue } = useFormContext();
353
- const {
354
- onloadTrigger,
355
- onclickTrigger,
356
- // These properties do not exist on input fields so we remove them (as we already have handled them).
357
- onclick: _ignoredOnclick,
358
- onload: _ignoredOnload,
359
- //
360
- ...attrs
361
- } = attributes;
362
- const isResendNode = ((_a = node.meta.label) == null ? void 0 : _a.id) === 1070008;
363
- const isScreenSelectionNode = "name" in node.attributes && node.attributes.name === "screen";
364
- const setFormValue = () => {
365
- if (attrs.value && !(isResendNode || isScreenSelectionNode)) {
366
- setValue(attrs.name, attrs.value);
367
- }
368
- };
369
- const hasRun = useRef(false);
370
- useEffect(
371
- () => {
372
- setFormValue();
373
- if (!hasRun.current && onloadTrigger) {
374
- hasRun.current = true;
375
- triggerToWindowCall(onloadTrigger);
376
- }
377
- },
378
- // TODO(jonas): make sure onloadTrigger is stable
379
- // eslint-disable-next-line react-hooks/exhaustive-deps -- ignore onloadTrigger for now, until we make sure this is stable
380
- []
381
- );
382
- const handleClick = () => {
383
- setFormValue();
384
- if (onclickTrigger) {
385
- triggerToWindowCall(onclickTrigger);
386
- }
387
- };
388
- const isSocial = (attrs.name === "provider" || attrs.name === "link") && node.group === "oidc";
389
- const isPinCodeInput = attrs.name === "code" && node.group === "code" || attrs.name === "totp_code" && node.group === "totp";
390
- switch (attributes.type) {
391
- case UiNodeInputAttributesTypeEnum.Submit:
392
- case UiNodeInputAttributesTypeEnum.Button:
393
- if (isSocial) {
394
- return /* @__PURE__ */ jsx(Node2.OidcButton, { attributes: attrs, node });
395
- }
396
- if (isResendNode || isScreenSelectionNode) {
397
- return null;
398
- }
399
- return /* @__PURE__ */ jsx(
400
- Node2.Label,
401
- {
402
- attributes: { ...attrs, label: void 0 },
403
- node: { ...node, meta: { ...node.meta, label: void 0 } },
404
- children: /* @__PURE__ */ jsx(Node2.Button, { attributes: attrs, node, onClick: handleClick })
405
- }
406
- );
407
- case UiNodeInputAttributesTypeEnum.DatetimeLocal:
408
- throw new Error("Not implemented");
409
- case UiNodeInputAttributesTypeEnum.Checkbox:
410
- return /* @__PURE__ */ jsx(
411
- Node2.Label,
412
- {
413
- attributes: { ...attrs, label: void 0 },
414
- node: { ...node, meta: { ...node.meta, label: void 0 } },
415
- children: /* @__PURE__ */ jsx(Node2.Checkbox, { attributes: attrs, node, onClick: handleClick })
416
- }
417
- );
418
- case UiNodeInputAttributesTypeEnum.Hidden:
419
- return /* @__PURE__ */ jsx(Node2.Input, { attributes: attrs, node, onClick: handleClick });
420
- default:
421
- if (isPinCodeInput) {
422
- return /* @__PURE__ */ jsx(Node2.Label, { attributes: attrs, node, children: /* @__PURE__ */ jsx(
423
- Node2.CodeInput,
424
- {
425
- attributes: attrs,
426
- node,
427
- onClick: handleClick
428
- }
429
- ) });
430
- }
431
- return /* @__PURE__ */ jsx(Node2.Label, { attributes: attrs, node, children: /* @__PURE__ */ jsx(Node2.Input, { attributes: attrs, node, onClick: handleClick }) });
432
- }
433
- };
434
- var Node = ({ node, onClick }) => {
435
- const { Node: Node2 } = useComponents();
436
- if (isUiNodeImageAttributes(node.attributes)) {
437
- return /* @__PURE__ */ jsx(Node2.Image, { node, attributes: node.attributes });
438
- } else if (isUiNodeTextAttributes(node.attributes)) {
439
- const attrs = node.attributes;
440
- return /* @__PURE__ */ jsx(Node2.Text, { attributes: attrs, node });
441
- } else if (isUiNodeInputAttributes(node.attributes)) {
442
- return /* @__PURE__ */ jsx(NodeInput, { node, attributes: node.attributes, onClick });
443
- } else if (isUiNodeAnchorAttributes(node.attributes)) {
444
- return /* @__PURE__ */ jsx(Node2.Anchor, { attributes: node.attributes, node });
445
- } else if (isUiNodeScriptAttributes(node.attributes)) {
446
- const {
447
- crossorigin,
448
- referrerpolicy,
449
- node_type: _nodeType,
450
- ...attributes
451
- } = node.attributes;
452
- return /* @__PURE__ */ jsx(
453
- "script",
454
- {
455
- crossOrigin: crossorigin,
456
- referrerPolicy: referrerpolicy,
457
- ...attributes
458
- }
459
- );
460
- }
461
- return null;
462
- };
463
- function OryFormGroups({ children, groups }) {
464
- const {
465
- flow: { ui }
466
- } = useOryFlow();
467
- const nodeSorter = useNodeSorter();
468
- const { flowType } = useOryFlow();
469
- const { Form } = useComponents();
470
- const nodes = ui.nodes.filter((node) => groups.indexOf(node.group) > -1).sort((a, b) => nodeSorter(a, b, { flowType }));
471
- return /* @__PURE__ */ jsx(Form.Group, { children: children != null ? children : nodes.map((node, k) => {
472
- return /* @__PURE__ */ jsx(Node, { node }, k);
473
- }) });
474
- }
475
342
  function computeDefaultValues(nodes) {
476
343
  return nodes.reduce((acc, node) => {
477
344
  const attrs = node.attributes;
@@ -557,52 +424,22 @@ function OryFormProvider({
557
424
  });
558
425
  return /* @__PURE__ */ jsx(FormProvider, { ...methods, children });
559
426
  }
560
- function OryFormOidcButtons({
561
- children,
562
- hideDivider
563
- }) {
564
- const {
565
- flow: { ui }
566
- } = useOryFlow();
567
- const { setValue } = useFormContext();
568
- const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
569
- const { Form, Card, Node: Node2 } = useComponents();
570
- if (filteredNodes.length === 0) {
571
- return null;
572
- }
573
- const otherNodes = ui.nodes.filter(
574
- (node) => node.group !== "oidc" && node.group !== "default"
575
- );
576
- return /* @__PURE__ */ jsxs(Fragment, { children: [
577
- /* @__PURE__ */ jsx(Form.OidcRoot, { nodes: filteredNodes, children: children != null ? children : filteredNodes.map((node, k) => {
578
- return /* @__PURE__ */ jsx(
579
- Node2.OidcButton,
580
- {
581
- node,
582
- attributes: node.attributes,
583
- onClick: () => {
584
- setValue(
585
- "provider",
586
- node.attributes.value
587
- );
588
- setValue("method", "oidc");
589
- }
590
- },
591
- k
592
- );
593
- }) }),
594
- !hideDivider && filteredNodes.length > 0 && otherNodes.length > 0 && /* @__PURE__ */ jsx(Card.Divider, {})
595
- ] });
427
+ function OryCard({ children }) {
428
+ const { Card } = useComponents();
429
+ return /* @__PURE__ */ jsx(Card.Root, { children: /* @__PURE__ */ jsx(OryFormProvider, { children }) });
596
430
  }
597
- function OryFormSocialButtonsForm() {
598
- const {
599
- flow: { ui }
600
- } = useOryFlow();
601
- const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
602
- if (filteredNodes.length === 0) {
603
- return null;
604
- }
605
- return /* @__PURE__ */ jsx(OryFormProvider, { children: /* @__PURE__ */ jsx(OryForm, { children: /* @__PURE__ */ jsx(OryFormOidcButtons, {}) }) });
431
+ function OryCardFooter() {
432
+ const { Card } = useComponents();
433
+ return /* @__PURE__ */ jsx(Card.Footer, {});
434
+ }
435
+ function OryCardContent({ children }) {
436
+ const { Card } = useComponents();
437
+ return /* @__PURE__ */ jsx(Card.Content, { children });
438
+ }
439
+
440
+ // src/theme/default/utils/form.ts
441
+ function isGroupImmediateSubmit(group) {
442
+ return group === "code";
606
443
  }
607
444
  function frontendClient(sdkUrl, opts = {}) {
608
445
  const config = new Configuration({
@@ -982,7 +819,7 @@ function OryForm({ children, onAfterSubmit }) {
982
819
  const methods = useFormContext();
983
820
  const intl = useIntl();
984
821
  const onSubmit = useOryFormSubmit(onAfterSubmit);
985
- const hasMethods = flowContainer.flow.ui.nodes.filter((node) => {
822
+ const hasMethods = flowContainer.flow.ui.nodes.some((node) => {
986
823
  if (isUiNodeInputAttributes(node.attributes)) {
987
824
  return node.attributes.name !== "csrf_token";
988
825
  } else if (isUiNodeAnchorAttributes(node.attributes)) {
@@ -993,7 +830,7 @@ function OryForm({ children, onAfterSubmit }) {
993
830
  return true;
994
831
  }
995
832
  return false;
996
- }).length > 0;
833
+ });
997
834
  if (!hasMethods && ((_a = flowContainer.flow.ui.messages) != null ? _a : []).length === 0) {
998
835
  return intl.formatMessage({
999
836
  id: `identities.messages.${5000002}`,
@@ -1006,22 +843,7 @@ function OryForm({ children, onAfterSubmit }) {
1006
843
  action: flowContainer.flow.ui.action,
1007
844
  method: flowContainer.flow.ui.method,
1008
845
  onSubmit: (e) => void methods.handleSubmit(onSubmit)(e),
1009
- children: children != null ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
1010
- /* @__PURE__ */ jsx(OryFormOidcButtons, {}),
1011
- /* @__PURE__ */ jsx(
1012
- OryFormGroups,
1013
- {
1014
- groups: [
1015
- "default",
1016
- "password",
1017
- "code",
1018
- "webauthn",
1019
- "passkey",
1020
- "identifier_first"
1021
- ]
1022
- }
1023
- )
1024
- ] })
846
+ children
1025
847
  }
1026
848
  );
1027
849
  }
@@ -1038,88 +860,176 @@ function OryCardValidationMessages({ ...props }) {
1038
860
  }
1039
861
  return /* @__PURE__ */ jsx(Message.Root, { ...props, children: messages == null ? void 0 : messages.map((message) => /* @__PURE__ */ jsx(Message.Content, { message }, message.id)) });
1040
862
  }
1041
- function OryFormSection({
1042
- children,
1043
- nodes,
1044
- ...rest
1045
- }) {
1046
- return /* @__PURE__ */ jsx(OryFormProvider, { nodes, children: /* @__PURE__ */ jsx(OryFormSectionInner, { ...rest, children }) });
1047
- }
1048
- function OryFormSectionInner({
1049
- children,
1050
- ...rest
1051
- }) {
1052
- const { Card } = useComponents();
1053
- const flowContainer = useOryFlow();
1054
- const onSubmit = useOryFormSubmit();
1055
- const methods = useFormContext();
1056
- return /* @__PURE__ */ jsx(
1057
- Card.SettingsSection,
1058
- {
1059
- action: flowContainer.flow.ui.action,
1060
- method: flowContainer.flow.ui.method,
1061
- onSubmit: (e) => void methods.handleSubmit(onSubmit)(e),
1062
- ...rest,
1063
- children
863
+ var NodeInput = ({
864
+ node,
865
+ attributes
866
+ }) => {
867
+ var _a;
868
+ const { Node: Node2 } = useComponents();
869
+ const { setValue } = useFormContext();
870
+ const {
871
+ onloadTrigger,
872
+ onclickTrigger,
873
+ // These properties do not exist on input fields so we remove them (as we already have handled them).
874
+ onclick: _ignoredOnclick,
875
+ onload: _ignoredOnload,
876
+ //
877
+ ...attrs
878
+ } = attributes;
879
+ const isResendNode = ((_a = node.meta.label) == null ? void 0 : _a.id) === 1070008;
880
+ const isScreenSelectionNode = "name" in node.attributes && node.attributes.name === "screen";
881
+ const setFormValue = () => {
882
+ if (attrs.value && !(isResendNode || isScreenSelectionNode)) {
883
+ setValue(attrs.name, attrs.value);
1064
884
  }
885
+ };
886
+ const hasRun = useRef(false);
887
+ useEffect(
888
+ () => {
889
+ setFormValue();
890
+ if (!hasRun.current && onloadTrigger) {
891
+ hasRun.current = true;
892
+ triggerToWindowCall(onloadTrigger);
893
+ }
894
+ },
895
+ // TODO(jonas): make sure onloadTrigger is stable
896
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- ignore onloadTrigger for now, until we make sure this is stable
897
+ []
1065
898
  );
1066
- }
1067
- function OryCardContent({ children }) {
1068
- const { Card } = useComponents();
1069
- if (children) {
1070
- return /* @__PURE__ */ jsx(Card.Content, { children });
1071
- }
1072
- return /* @__PURE__ */ jsxs(Card.Content, { children: [
1073
- /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1074
- /* @__PURE__ */ jsxs(OryForm, { children: [
1075
- /* @__PURE__ */ jsx(OryFormOidcButtons, {}),
1076
- /* @__PURE__ */ jsx(
1077
- OryFormGroups,
899
+ const handleClick = () => {
900
+ setFormValue();
901
+ if (onclickTrigger) {
902
+ triggerToWindowCall(onclickTrigger);
903
+ }
904
+ };
905
+ const isSocial = (attrs.name === "provider" || attrs.name === "link") && node.group === "oidc";
906
+ const isPinCodeInput = attrs.name === "code" && node.group === "code" || attrs.name === "totp_code" && node.group === "totp";
907
+ switch (attributes.type) {
908
+ case UiNodeInputAttributesTypeEnum.Submit:
909
+ case UiNodeInputAttributesTypeEnum.Button:
910
+ if (isSocial) {
911
+ return null;
912
+ }
913
+ if (isResendNode || isScreenSelectionNode) {
914
+ return null;
915
+ }
916
+ return /* @__PURE__ */ jsx(
917
+ Node2.Label,
1078
918
  {
1079
- groups: [
1080
- "default",
1081
- "password",
1082
- "passkey",
1083
- "code",
1084
- "webauthn",
1085
- "profile",
1086
- "totp",
1087
- "identifier_first"
1088
- ]
919
+ attributes: { ...attrs, label: void 0 },
920
+ node: { ...node, meta: { ...node.meta, label: void 0 } },
921
+ children: /* @__PURE__ */ jsx(Node2.Button, { attributes: attrs, node, onClick: handleClick })
1089
922
  }
1090
- )
1091
- ] })
1092
- ] });
923
+ );
924
+ case UiNodeInputAttributesTypeEnum.DatetimeLocal:
925
+ throw new Error("Not implemented");
926
+ case UiNodeInputAttributesTypeEnum.Checkbox:
927
+ return /* @__PURE__ */ jsx(
928
+ Node2.Label,
929
+ {
930
+ attributes: { ...attrs, label: void 0 },
931
+ node: { ...node, meta: { ...node.meta, label: void 0 } },
932
+ children: /* @__PURE__ */ jsx(Node2.Checkbox, { attributes: attrs, node, onClick: handleClick })
933
+ }
934
+ );
935
+ case UiNodeInputAttributesTypeEnum.Hidden:
936
+ return /* @__PURE__ */ jsx(Node2.Input, { attributes: attrs, node, onClick: handleClick });
937
+ default:
938
+ if (isPinCodeInput) {
939
+ return /* @__PURE__ */ jsx(Node2.Label, { attributes: attrs, node, children: /* @__PURE__ */ jsx(
940
+ Node2.CodeInput,
941
+ {
942
+ attributes: attrs,
943
+ node,
944
+ onClick: handleClick
945
+ }
946
+ ) });
947
+ }
948
+ return /* @__PURE__ */ jsx(Node2.Label, { attributes: attrs, node, children: /* @__PURE__ */ jsx(Node2.Input, { attributes: attrs, node, onClick: handleClick }) });
949
+ }
950
+ };
951
+ var Node = ({ node, onClick }) => {
952
+ const { Node: Node2 } = useComponents();
953
+ if (isUiNodeImageAttributes(node.attributes)) {
954
+ return /* @__PURE__ */ jsx(Node2.Image, { node, attributes: node.attributes });
955
+ } else if (isUiNodeTextAttributes(node.attributes)) {
956
+ const attrs = node.attributes;
957
+ return /* @__PURE__ */ jsx(Node2.Text, { attributes: attrs, node });
958
+ } else if (isUiNodeInputAttributes(node.attributes)) {
959
+ return /* @__PURE__ */ jsx(NodeInput, { node, attributes: node.attributes, onClick });
960
+ } else if (isUiNodeAnchorAttributes(node.attributes)) {
961
+ return /* @__PURE__ */ jsx(Node2.Anchor, { attributes: node.attributes, node });
962
+ } else if (isUiNodeScriptAttributes(node.attributes)) {
963
+ const {
964
+ crossorigin,
965
+ referrerpolicy,
966
+ node_type: _nodeType,
967
+ ...attributes
968
+ } = node.attributes;
969
+ return /* @__PURE__ */ jsx(
970
+ "script",
971
+ {
972
+ crossOrigin: crossorigin,
973
+ referrerPolicy: referrerpolicy,
974
+ ...attributes
975
+ }
976
+ );
977
+ }
978
+ return null;
979
+ };
980
+ function OryFormOidcButtons() {
981
+ const {
982
+ flow: { ui }
983
+ } = useOryFlow();
984
+ const { setValue } = useFormContext();
985
+ const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
986
+ const { Form, Node: Node2 } = useComponents();
987
+ if (filteredNodes.length === 0) {
988
+ return null;
989
+ }
990
+ return /* @__PURE__ */ jsx(Form.OidcRoot, { nodes: filteredNodes, children: filteredNodes.map((node, k) => /* @__PURE__ */ jsx(
991
+ Node2.OidcButton,
992
+ {
993
+ node,
994
+ attributes: node.attributes,
995
+ onClick: () => {
996
+ setValue(
997
+ "provider",
998
+ node.attributes.value
999
+ );
1000
+ setValue("method", "oidc");
1001
+ }
1002
+ },
1003
+ k
1004
+ )) });
1093
1005
  }
1094
- function OryCard({ children }) {
1095
- const { Card } = useComponents();
1096
- if (children) {
1097
- return /* @__PURE__ */ jsx(Card.Root, { children: /* @__PURE__ */ jsx(OryFormProvider, { children }) });
1006
+ function OryFormSocialButtonsForm() {
1007
+ const {
1008
+ flow: { ui }
1009
+ } = useOryFlow();
1010
+ const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
1011
+ if (filteredNodes.length === 0) {
1012
+ return null;
1098
1013
  }
1099
- return /* @__PURE__ */ jsx(Card.Root, { children: /* @__PURE__ */ jsxs(OryFormProvider, { children: [
1100
- /* @__PURE__ */ jsx(OryCardHeader, {}),
1101
- /* @__PURE__ */ jsx(OryCardContent, {}),
1102
- /* @__PURE__ */ jsx(OryCardFooter, {})
1103
- ] }) });
1014
+ return /* @__PURE__ */ jsx(OryFormProvider, { children: /* @__PURE__ */ jsx(OryForm, { children: /* @__PURE__ */ jsx(OryFormOidcButtons, {}) }) });
1104
1015
  }
1105
-
1106
- // src/theme/default/utils/form.ts
1107
- function isGroupImmediateSubmit(group) {
1108
- return group === "code";
1016
+ function isUINodeGroupEnum(method) {
1017
+ return Object.values(UiNodeGroupEnum).includes(method);
1109
1018
  }
1110
1019
  function OryTwoStepCard() {
1111
- var _a;
1112
1020
  const {
1113
- flow: { ui }
1021
+ flow: { ui },
1022
+ flowType,
1023
+ formState,
1024
+ dispatchFormState
1114
1025
  } = useOryFlow();
1115
1026
  const { Form, Card } = useComponents();
1116
- const { flowType, formState, dispatchFormState } = useOryFlow();
1117
1027
  const nodeSorter = useNodeSorter();
1118
1028
  const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
1119
1029
  const uniqueGroups = useNodesGroups(ui.nodes);
1120
1030
  const options = Object.values(UiNodeGroupEnum).filter((group) => {
1121
- var _a2;
1122
- return (_a2 = uniqueGroups.groups[group]) == null ? void 0 : _a2.length;
1031
+ var _a;
1032
+ return (_a = uniqueGroups.groups[group]) == null ? void 0 : _a.length;
1123
1033
  }).filter(
1124
1034
  (group) => ![
1125
1035
  UiNodeGroupEnum.Oidc,
@@ -1128,46 +1038,52 @@ function OryTwoStepCard() {
1128
1038
  UiNodeGroupEnum.Profile
1129
1039
  ].includes(group)
1130
1040
  );
1131
- const hasOidc = Boolean((_a = uniqueGroups.groups[UiNodeGroupEnum.Oidc]) == null ? void 0 : _a.length);
1132
- const zeroStepGroups = filterZeroStepGroups(ui.nodes);
1041
+ const nonOidcNodes = filterOidcOut(ui.nodes);
1133
1042
  const finalNodes = formState.current === "method_active" ? getFinalNodes(uniqueGroups.groups, formState.method) : [];
1043
+ const handleAfterFormSubmit = (method) => {
1044
+ if (typeof method !== "string" || !isUINodeGroupEnum(method)) {
1045
+ return;
1046
+ }
1047
+ if (isGroupImmediateSubmit(method)) {
1048
+ dispatchFormState({
1049
+ type: "action_select_method",
1050
+ method
1051
+ });
1052
+ }
1053
+ };
1054
+ const hasOidc = ui.nodes.some((node) => node.group === UiNodeGroupEnum.Oidc);
1055
+ const showOidc = !(formState.current === "method_active" && formState.method !== "oidc");
1134
1056
  return /* @__PURE__ */ jsxs(OryCard, { children: [
1135
1057
  /* @__PURE__ */ jsx(OryCardHeader, {}),
1136
1058
  /* @__PURE__ */ jsxs(OryCardContent, { children: [
1137
1059
  /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1138
- formState.current === "provide_identifier" && hasOidc && /* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
1139
- /* @__PURE__ */ jsxs(
1140
- OryForm,
1141
- {
1142
- onAfterSubmit: (method) => isGroupImmediateSubmit(method + "") ? dispatchFormState({
1143
- type: "action_select_method",
1144
- method
1145
- }) : void 0,
1146
- children: [
1147
- /* @__PURE__ */ jsxs(Form.Group, { children: [
1148
- formState.current === "provide_identifier" && zeroStepGroups.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
1149
- formState.current === "select_method" && /* @__PURE__ */ jsxs(Fragment, { children: [
1150
- /* @__PURE__ */ jsx(Card.Divider, {}),
1151
- /* @__PURE__ */ jsx(
1152
- AuthMethodList,
1153
- {
1154
- options,
1155
- setSelectedGroup: (group) => dispatchFormState({
1156
- type: "action_select_method",
1157
- method: group
1158
- })
1159
- }
1160
- )
1161
- ] }),
1162
- formState.current === "method_active" && /* @__PURE__ */ jsxs(Fragment, { children: [
1163
- ui.nodes.filter((n) => n.type === "script").map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
1164
- finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1165
- ] })
1166
- ] }),
1167
- /* @__PURE__ */ jsx(OryCardFooter, {})
1168
- ]
1169
- }
1170
- )
1060
+ showOidc && /* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
1061
+ /* @__PURE__ */ jsxs(OryForm, { onAfterSubmit: handleAfterFormSubmit, children: [
1062
+ /* @__PURE__ */ jsxs(Form.Group, { children: [
1063
+ formState.current === "provide_identifier" && /* @__PURE__ */ jsxs(Fragment, { children: [
1064
+ hasOidc && /* @__PURE__ */ jsx(Card.Divider, {}),
1065
+ nonOidcNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1066
+ ] }),
1067
+ formState.current === "select_method" && /* @__PURE__ */ jsxs(Fragment, { children: [
1068
+ /* @__PURE__ */ jsx(Card.Divider, {}),
1069
+ /* @__PURE__ */ jsx(
1070
+ AuthMethodList,
1071
+ {
1072
+ options,
1073
+ setSelectedGroup: (group) => dispatchFormState({
1074
+ type: "action_select_method",
1075
+ method: group
1076
+ })
1077
+ }
1078
+ )
1079
+ ] }),
1080
+ formState.current === "method_active" && /* @__PURE__ */ jsxs(Fragment, { children: [
1081
+ ui.nodes.filter((n) => n.type === "script").map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
1082
+ finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1083
+ ] })
1084
+ ] }),
1085
+ /* @__PURE__ */ jsx(OryCardFooter, {})
1086
+ ] })
1171
1087
  ] })
1172
1088
  ] });
1173
1089
  }
@@ -1190,6 +1106,44 @@ function AuthMethodList({ options, setSelectedGroup }) {
1190
1106
  option
1191
1107
  )) });
1192
1108
  }
1109
+ function OryFormGroups({ groups }) {
1110
+ const {
1111
+ flow: { ui }
1112
+ } = useOryFlow();
1113
+ const nodeSorter = useNodeSorter();
1114
+ const { flowType } = useOryFlow();
1115
+ const { Form } = useComponents();
1116
+ const nodes = ui.nodes.filter((node) => groups.indexOf(node.group) > -1).sort((a, b) => nodeSorter(a, b, { flowType }));
1117
+ return /* @__PURE__ */ jsx(Form.Group, { children: nodes.map((node, k) => {
1118
+ return /* @__PURE__ */ jsx(Node, { node }, k);
1119
+ }) });
1120
+ }
1121
+ function OryFormSection({
1122
+ children,
1123
+ nodes,
1124
+ ...rest
1125
+ }) {
1126
+ return /* @__PURE__ */ jsx(OryFormProvider, { nodes, children: /* @__PURE__ */ jsx(OryFormSectionInner, { ...rest, children }) });
1127
+ }
1128
+ function OryFormSectionInner({
1129
+ children,
1130
+ ...rest
1131
+ }) {
1132
+ const { Card } = useComponents();
1133
+ const flowContainer = useOryFlow();
1134
+ const onSubmit = useOryFormSubmit();
1135
+ const methods = useFormContext();
1136
+ return /* @__PURE__ */ jsx(
1137
+ Card.SettingsSection,
1138
+ {
1139
+ action: flowContainer.flow.ui.action,
1140
+ method: flowContainer.flow.ui.method,
1141
+ onSubmit: (e) => void methods.handleSubmit(onSubmit)(e),
1142
+ ...rest,
1143
+ children
1144
+ }
1145
+ );
1146
+ }
1193
1147
  function OryFormGroupDivider() {
1194
1148
  const { Card } = useComponents();
1195
1149
  const {