@ory/elements-react 0.0.0-pr.f1435f4 → 0.0.0-pr.f1d09ee2

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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { UiNodeGroupEnum, isUiNodeInputAttributes, isUiNodeAnchorAttributes, isUiNodeImageAttributes, isUiNodeScriptAttributes, FlowType, UiNodeInputAttributesTypeEnum, isUiNodeTextAttributes, handleContinueWith, handleFlowError, settingsUrl, isResponseError, loginUrl, recoveryUrl, verificationUrl, registrationUrl, Configuration, FrontendApi, instanceOfContinueWithRecoveryUi } from '@ory/client-fetch';
1
+ import { UiNodeGroupEnum, isUiNodeInputAttributes, isUiNodeAnchorAttributes, isUiNodeImageAttributes, isUiNodeScriptAttributes, FlowType, getNodeId, isUiNodeTextAttributes, UiNodeInputAttributesTypeEnum, handleContinueWith, handleFlowError, settingsUrl, isResponseError, loginUrl, recoveryUrl, verificationUrl, registrationUrl, Configuration, FrontendApi, instanceOfContinueWithRecoveryUi } from '@ory/client-fetch';
2
2
  import { createContext, useContext, useState, useMemo, useReducer, useRef, useEffect } from 'react';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { useIntl, IntlProvider as IntlProvider$1 } from 'react-intl';
@@ -92,28 +92,10 @@ function OryComponentProvider({
92
92
  }
93
93
  );
94
94
  }
95
- function isChoosingMethod(flow) {
96
- return flow.flow.ui.nodes.some(
97
- (node) => "name" in node.attributes && node.attributes.name === "screen" && "value" in node.attributes && node.attributes.value === "previous"
98
- ) || flow.flow.ui.nodes.some(
99
- (node) => node.group === UiNodeGroupEnum.IdentifierFirst && "name" in node.attributes && node.attributes.name === "identifier" && node.attributes.type === "hidden"
100
- ) || flow.flowType === FlowType.Login && flow.flow.requested_aal === "aal2";
101
- }
102
- function removeSsoNodes(nodes) {
103
- return nodes.filter(
104
- (node) => !(node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml)
105
- );
106
- }
107
- function getFinalNodes(uniqueGroups, selectedGroup) {
108
- var _a, _b, _c, _d;
109
- const selectedNodes = selectedGroup ? (_a = uniqueGroups[selectedGroup]) != null ? _a : [] : [];
110
- return [
111
- ...(_b = uniqueGroups == null ? void 0 : uniqueGroups.identifier_first) != null ? _b : [],
112
- ...(_c = uniqueGroups == null ? void 0 : uniqueGroups.default) != null ? _c : [],
113
- ...(_d = uniqueGroups == null ? void 0 : uniqueGroups.captcha) != null ? _d : []
114
- ].flat().filter(
115
- (node) => "type" in node.attributes && node.attributes.type === "hidden"
116
- ).concat(selectedNodes);
95
+
96
+ // src/theme/default/utils/form.ts
97
+ function isGroupImmediateSubmit(group) {
98
+ return group === "code";
117
99
  }
118
100
  function triggerToWindowCall(trigger) {
119
101
  if (!trigger) {
@@ -225,6 +207,93 @@ function useNodesGroups(nodes, { omit } = {}) {
225
207
  var findNode = (nodes, opt) => nodes.find((n) => {
226
208
  return n.attributes.node_type === opt.node_type && (opt.group instanceof RegExp ? n.group.match(opt.group) : n.group === opt.group) && (opt.name && n.attributes.node_type === "input" ? opt.name instanceof RegExp ? n.attributes.name.match(opt.name) : n.attributes.name === opt.name : !opt.name);
227
209
  });
210
+ function useFunctionalNodes(nodes) {
211
+ return nodes.filter(
212
+ ({ group }) => [
213
+ UiNodeGroupEnum.Default,
214
+ UiNodeGroupEnum.IdentifierFirst,
215
+ UiNodeGroupEnum.Profile,
216
+ UiNodeGroupEnum.Captcha
217
+ ].includes(group)
218
+ );
219
+ }
220
+ function isUiNodeGroupEnum(method) {
221
+ return Object.values(UiNodeGroupEnum).includes(method);
222
+ }
223
+ function isSingleSignOnNode(node) {
224
+ return node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml;
225
+ }
226
+ function hasSingleSignOnNodes(nodes) {
227
+ return nodes.some(isSingleSignOnNode);
228
+ }
229
+ function withoutSingleSignOnNodes(nodes) {
230
+ return nodes.filter((node) => !isSingleSignOnNode(node));
231
+ }
232
+ function isNodeVisible(node) {
233
+ if (isUiNodeScriptAttributes(node.attributes)) {
234
+ return false;
235
+ } else if (isUiNodeInputAttributes(node.attributes)) {
236
+ if (node.attributes.type === "hidden") {
237
+ return false;
238
+ }
239
+ }
240
+ return true;
241
+ }
242
+ function useNodeGroupsWithVisibleNodes(nodes) {
243
+ return useMemo(() => {
244
+ var _a, _b;
245
+ const groups = {};
246
+ const groupRetained = {};
247
+ for (const node of nodes) {
248
+ const groupNodes = (_a = groups[node.group]) != null ? _a : [];
249
+ const groupCount = (_b = groupRetained[node.group]) != null ? _b : 0;
250
+ groupNodes.push(node);
251
+ groups[node.group] = groupNodes;
252
+ if (!isNodeVisible(node)) {
253
+ continue;
254
+ }
255
+ groupRetained[node.group] = groupCount + 1;
256
+ }
257
+ const finalGroups = {};
258
+ for (const [group, count] of Object.entries(groupRetained)) {
259
+ if (count > 0) {
260
+ finalGroups[group] = groups[group];
261
+ }
262
+ }
263
+ return finalGroups;
264
+ }, [nodes]);
265
+ }
266
+
267
+ // src/components/card/two-step/utils.ts
268
+ function isChoosingMethod(flow) {
269
+ return flow.flow.ui.nodes.some(
270
+ (node) => "name" in node.attributes && node.attributes.name === "screen" && "value" in node.attributes && node.attributes.value === "previous"
271
+ ) || flow.flow.ui.nodes.some(
272
+ (node) => node.group === UiNodeGroupEnum.IdentifierFirst && "name" in node.attributes && node.attributes.name === "identifier" && node.attributes.type === "hidden"
273
+ ) || flow.flowType === FlowType.Login && flow.flow.requested_aal === "aal2";
274
+ }
275
+ function getFinalNodes(uniqueGroups, selectedGroup) {
276
+ var _a, _b, _c, _d;
277
+ const selectedNodes = selectedGroup ? (_a = uniqueGroups[selectedGroup]) != null ? _a : [] : [];
278
+ return [
279
+ ...(_b = uniqueGroups == null ? void 0 : uniqueGroups.identifier_first) != null ? _b : [],
280
+ ...(_c = uniqueGroups == null ? void 0 : uniqueGroups.default) != null ? _c : [],
281
+ ...(_d = uniqueGroups == null ? void 0 : uniqueGroups.captcha) != null ? _d : []
282
+ ].flat().filter(
283
+ (node) => "type" in node.attributes && node.attributes.type === "hidden"
284
+ ).concat(selectedNodes);
285
+ }
286
+ var handleAfterFormSubmit = (dispatchFormState) => (method) => {
287
+ if (typeof method !== "string" || !isUiNodeGroupEnum(method)) {
288
+ return;
289
+ }
290
+ if (isGroupImmediateSubmit(method)) {
291
+ dispatchFormState({
292
+ type: "action_select_method",
293
+ method
294
+ });
295
+ }
296
+ };
228
297
 
229
298
  // src/context/form-state.ts
230
299
  function findMethodWithMessage(nodes) {
@@ -490,11 +559,6 @@ function OryCardContent({ children }) {
490
559
  const { Card } = useComponents();
491
560
  return /* @__PURE__ */ jsx(Card.Content, { children });
492
561
  }
493
-
494
- // src/theme/default/utils/form.ts
495
- function isGroupImmediateSubmit(group) {
496
- return group === "code";
497
- }
498
562
  function frontendClient(sdkUrl, opts = {}) {
499
563
  const config = new Configuration({
500
564
  ...opts,
@@ -892,6 +956,9 @@ function OryForm({
892
956
  const onSubmit = useOryFormSubmit(onAfterSubmit);
893
957
  const hasMethods = flowContainer.flow.ui.nodes.some((node) => {
894
958
  if (isUiNodeInputAttributes(node.attributes)) {
959
+ if (node.attributes.type === "hidden") {
960
+ return false;
961
+ }
895
962
  return node.attributes.name !== "csrf_token";
896
963
  } else if (isUiNodeAnchorAttributes(node.attributes)) {
897
964
  return true;
@@ -913,7 +980,7 @@ function OryForm({
913
980
  };
914
981
  return /* @__PURE__ */ jsx("div", { "data-testid": dataTestId, children: /* @__PURE__ */ jsx(Message.Root, { children: /* @__PURE__ */ jsx(Message.Content, { message: m }, m.id) }) });
915
982
  }
916
- if (flowContainer.flowType === FlowType.Login && flowContainer.formState.current === "method_active" && flowContainer.formState.method === "code") {
983
+ if ((flowContainer.flowType === FlowType.Login || flowContainer.flowType === FlowType.Registration) && flowContainer.formState.current === "method_active" && flowContainer.formState.method === "code") {
917
984
  methods.setValue("method", "code");
918
985
  }
919
986
  return /* @__PURE__ */ jsx(
@@ -966,9 +1033,15 @@ var NodeInput = ({
966
1033
  } = attributes;
967
1034
  const isResendNode = ((_a = node.meta.label) == null ? void 0 : _a.id) === 1070008;
968
1035
  const isScreenSelectionNode = "name" in node.attributes && node.attributes.name === "screen";
1036
+ const setFormValue = () => {
1037
+ if (attrs.value && !(isResendNode || isScreenSelectionNode || node.group === UiNodeGroupEnum.Oauth2Consent)) {
1038
+ setValue(attrs.name, attrs.value);
1039
+ }
1040
+ };
969
1041
  const hasRun = useRef(false);
970
1042
  useEffect(
971
1043
  () => {
1044
+ setFormValue();
972
1045
  if (!hasRun.current && onloadTrigger) {
973
1046
  hasRun.current = true;
974
1047
  triggerToWindowCall(onloadTrigger);
@@ -979,6 +1052,7 @@ var NodeInput = ({
979
1052
  []
980
1053
  );
981
1054
  const handleClick = () => {
1055
+ setFormValue();
982
1056
  if (onclickTrigger) {
983
1057
  triggerToWindowCall(onclickTrigger);
984
1058
  }
@@ -1104,7 +1178,7 @@ function OryFormOidcButtons() {
1104
1178
  if (filteredNodes.length === 0) {
1105
1179
  return null;
1106
1180
  }
1107
- return /* @__PURE__ */ jsx(Form.OidcRoot, { nodes: filteredNodes, children: filteredNodes.map((node, k) => /* @__PURE__ */ jsx(
1181
+ return /* @__PURE__ */ jsx(Form.OidcRoot, { nodes: filteredNodes, children: filteredNodes.map((node) => /* @__PURE__ */ jsx(
1108
1182
  Node2.OidcButton,
1109
1183
  {
1110
1184
  node,
@@ -1117,7 +1191,7 @@ function OryFormOidcButtons() {
1117
1191
  setValue("method", node.group);
1118
1192
  }
1119
1193
  },
1120
- k
1194
+ getNodeId(node)
1121
1195
  )) });
1122
1196
  }
1123
1197
  function OryFormSocialButtonsForm() {
@@ -1132,24 +1206,104 @@ function OryFormSocialButtonsForm() {
1132
1206
  }
1133
1207
  return /* @__PURE__ */ jsx(OryFormProvider, { children: /* @__PURE__ */ jsx(OryForm, { "data-testid": `ory/form/methods/oidc-saml`, children: /* @__PURE__ */ jsx(OryFormOidcButtons, {}) }) });
1134
1208
  }
1135
- function isUINodeGroupEnum(method) {
1136
- return Object.values(UiNodeGroupEnum).includes(method);
1209
+ function OryTwoStepCardStateMethodActive({
1210
+ formState
1211
+ }) {
1212
+ const { Form } = useComponents();
1213
+ const { flow, flowType, dispatchFormState } = useOryFlow();
1214
+ const { ui } = flow;
1215
+ const nodeSorter = useNodeSorter();
1216
+ const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
1217
+ const groupsToShow = useNodeGroupsWithVisibleNodes(ui.nodes);
1218
+ const finalNodes = getFinalNodes(groupsToShow, formState.method);
1219
+ const selectedMethodIsSocial = formState.method === UiNodeGroupEnum.Oidc || formState.method === UiNodeGroupEnum.Saml;
1220
+ return /* @__PURE__ */ jsxs(OryCard, { children: [
1221
+ /* @__PURE__ */ jsx(OryCardHeader, {}),
1222
+ /* @__PURE__ */ jsxs(OryCardContent, { children: [
1223
+ /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1224
+ selectedMethodIsSocial && /* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
1225
+ /* @__PURE__ */ jsx(
1226
+ OryForm,
1227
+ {
1228
+ "data-testid": `ory/form/methods/local`,
1229
+ onAfterSubmit: handleAfterFormSubmit(dispatchFormState),
1230
+ children: /* @__PURE__ */ jsxs(Form.Group, { children: [
1231
+ ui.nodes.filter(
1232
+ (n) => isUiNodeScriptAttributes(n.attributes) || n.group === UiNodeGroupEnum.Captcha || n.group === UiNodeGroupEnum.Default || n.group === UiNodeGroupEnum.Profile
1233
+ ).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
1234
+ finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1235
+ ] })
1236
+ }
1237
+ )
1238
+ ] }),
1239
+ /* @__PURE__ */ jsx(OryCardFooter, {})
1240
+ ] });
1137
1241
  }
1138
- function OryTwoStepCard() {
1139
- var _a, _b, _c, _d;
1242
+ function OryTwoStepCardStateProvideIdentifier() {
1140
1243
  const { Form, Card } = useComponents();
1141
- const { flow, flowType, formState, dispatchFormState } = useOryFlow();
1142
- const { ui } = flow;
1244
+ const { flowType, flow, dispatchFormState } = useOryFlow();
1143
1245
  const nodeSorter = useNodeSorter();
1144
1246
  const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
1145
- const groupsToShow = useNodesGroups(ui.nodes, {
1146
- // We only want to render groups that have visible elements.
1147
- omit: ["script", "input_hidden"]
1148
- });
1149
- const authMethodBlocks = Object.fromEntries(
1247
+ const nonSsoNodes = withoutSingleSignOnNodes(flow.ui.nodes).sort(sortNodes);
1248
+ const hasSso = flow.ui.nodes.filter(isNodeVisible).some(
1249
+ (node) => node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml
1250
+ );
1251
+ const showSsoDivider = hasSso && nonSsoNodes.some(isNodeVisible);
1252
+ return /* @__PURE__ */ jsxs(OryCard, { children: [
1253
+ /* @__PURE__ */ jsx(OryCardHeader, {}),
1254
+ /* @__PURE__ */ jsxs(OryCardContent, { children: [
1255
+ /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1256
+ /* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
1257
+ /* @__PURE__ */ jsx(
1258
+ OryForm,
1259
+ {
1260
+ "data-testid": `ory/form/methods/local`,
1261
+ onAfterSubmit: handleAfterFormSubmit(dispatchFormState),
1262
+ children: /* @__PURE__ */ jsxs(Form.Group, { children: [
1263
+ showSsoDivider && /* @__PURE__ */ jsx(Card.Divider, {}),
1264
+ nonSsoNodes.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1265
+ ] })
1266
+ }
1267
+ )
1268
+ ] }),
1269
+ /* @__PURE__ */ jsx(OryCardFooter, {})
1270
+ ] });
1271
+ }
1272
+ function AuthMethodList({
1273
+ options,
1274
+ setSelectedGroup
1275
+ }) {
1276
+ const { Card } = useComponents();
1277
+ const { setValue, getValues } = useFormContext();
1278
+ if (Object.entries(options).length === 0) {
1279
+ return null;
1280
+ }
1281
+ const handleClick = (group, options2) => {
1282
+ var _a, _b, _c, _d;
1283
+ if (isGroupImmediateSubmit(group)) {
1284
+ if (group === "code" && !getValues("identifier") && ((_b = (_a = options2 == null ? void 0 : options2.title) == null ? void 0 : _a.values) == null ? void 0 : _b.address)) {
1285
+ setValue("identifier", (_d = (_c = options2 == null ? void 0 : options2.title) == null ? void 0 : _c.values) == null ? void 0 : _d.address);
1286
+ }
1287
+ setValue("method", group);
1288
+ } else {
1289
+ setSelectedGroup(group);
1290
+ }
1291
+ };
1292
+ return /* @__PURE__ */ jsx(Card.AuthMethodListContainer, { children: Object.entries(options).map(([group, options2]) => /* @__PURE__ */ jsx(
1293
+ Card.AuthMethodListItem,
1294
+ {
1295
+ group,
1296
+ title: options2.title,
1297
+ onClick: () => handleClick(group, options2)
1298
+ },
1299
+ group
1300
+ )) });
1301
+ }
1302
+ function toAuthMethodPickerOptions(visibleGroups) {
1303
+ return Object.fromEntries(
1150
1304
  Object.values(UiNodeGroupEnum).filter((group) => {
1151
- var _a2;
1152
- return (_a2 = groupsToShow.groups[group]) == null ? void 0 : _a2.length;
1305
+ var _a;
1306
+ return (_a = visibleGroups[group]) == null ? void 0 : _a.length;
1153
1307
  }).filter(
1154
1308
  (group) => ![
1155
1309
  UiNodeGroupEnum.Oidc,
@@ -1161,16 +1315,18 @@ function OryTwoStepCard() {
1161
1315
  ].includes(group)
1162
1316
  ).map((g) => [g, {}])
1163
1317
  );
1164
- const authMethodAdditionalNodes = ui.nodes.filter(
1165
- ({ group }) => [
1166
- UiNodeGroupEnum.Oidc,
1167
- UiNodeGroupEnum.Saml,
1168
- UiNodeGroupEnum.Default,
1169
- UiNodeGroupEnum.IdentifierFirst,
1170
- UiNodeGroupEnum.Profile,
1171
- UiNodeGroupEnum.Captcha
1172
- ].includes(group)
1173
- );
1318
+ }
1319
+ function OryTwoStepCardStateSelectMethod() {
1320
+ var _a, _b, _c, _d;
1321
+ const { Form, Card, Message } = useComponents();
1322
+ const { flow, flowType, dispatchFormState } = useOryFlow();
1323
+ const { ui } = flow;
1324
+ const intl = useIntl();
1325
+ const nodeSorter = useNodeSorter();
1326
+ const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
1327
+ const visibleGroups = useNodeGroupsWithVisibleNodes(ui.nodes);
1328
+ const authMethodBlocks = toAuthMethodPickerOptions(visibleGroups);
1329
+ const authMethodAdditionalNodes = useFunctionalNodes(ui.nodes);
1174
1330
  if (UiNodeGroupEnum.Code in authMethodBlocks) {
1175
1331
  let identifier = (_b = (_a = findNode(ui.nodes, {
1176
1332
  group: "identifier_first",
@@ -1191,137 +1347,59 @@ function OryTwoStepCard() {
1191
1347
  };
1192
1348
  }
1193
1349
  }
1194
- const nonSsoNodes = removeSsoNodes(ui.nodes);
1195
- const finalNodes = formState.current === "method_active" ? getFinalNodes(groupsToShow.groups, formState.method) : [];
1196
- const handleAfterFormSubmit = (method) => {
1197
- if (typeof method !== "string" || !isUINodeGroupEnum(method)) {
1198
- return;
1199
- }
1200
- if (isGroupImmediateSubmit(method)) {
1201
- dispatchFormState({
1202
- type: "action_select_method",
1203
- method
1204
- });
1205
- }
1350
+ const noMethods = {
1351
+ id: 5000002,
1352
+ text: intl.formatMessage({
1353
+ id: `identities.messages.5000002`,
1354
+ defaultMessage: "No authentication methods are available for this request. Please contact the site or app owner."
1355
+ }),
1356
+ type: "error"
1206
1357
  };
1207
- const hasSso = ui.nodes.some(
1208
- (node) => node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml
1209
- );
1210
- const showSso = !(formState.current === "method_active" && !(formState.method === UiNodeGroupEnum.Oidc || formState.method === UiNodeGroupEnum.Saml));
1211
- const showSsoDivider = hasSso && nonSsoNodes.some((n) => {
1212
- if (isUiNodeInputAttributes(n.attributes)) {
1213
- return n.attributes.type !== UiNodeInputAttributesTypeEnum.Hidden;
1214
- } else if (isUiNodeScriptAttributes(n.attributes)) {
1215
- return false;
1216
- }
1217
- return true;
1218
- });
1358
+ return /* @__PURE__ */ jsxs(OryCard, { children: [
1359
+ /* @__PURE__ */ jsx(OryCardHeader, {}),
1360
+ /* @__PURE__ */ jsxs(OryCardContent, { children: [
1361
+ /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1362
+ /* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
1363
+ Object.entries(authMethodBlocks).length > 0 ? /* @__PURE__ */ jsx(
1364
+ OryForm,
1365
+ {
1366
+ "data-testid": `ory/form/methods/local`,
1367
+ onAfterSubmit: handleAfterFormSubmit(dispatchFormState),
1368
+ children: /* @__PURE__ */ jsxs(Form.Group, { children: [
1369
+ /* @__PURE__ */ jsx(Card.Divider, {}),
1370
+ /* @__PURE__ */ jsx(
1371
+ AuthMethodList,
1372
+ {
1373
+ options: authMethodBlocks,
1374
+ setSelectedGroup: (group) => dispatchFormState({
1375
+ type: "action_select_method",
1376
+ method: group
1377
+ })
1378
+ }
1379
+ ),
1380
+ authMethodAdditionalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1381
+ ] })
1382
+ }
1383
+ ) : !hasSingleSignOnNodes(ui.nodes) && /* @__PURE__ */ jsx("div", { "data-testid": `ory/form/methods/local`, children: /* @__PURE__ */ jsx(Message.Root, { children: /* @__PURE__ */ jsx(Message.Content, { message: noMethods }, noMethods.id) }) })
1384
+ ] }),
1385
+ /* @__PURE__ */ jsx(OryCardFooter, {})
1386
+ ] });
1387
+ }
1388
+ function OryTwoStepCard() {
1389
+ const { formState } = useOryFlow();
1219
1390
  switch (formState.current) {
1220
1391
  case "provide_identifier":
1221
- return /* @__PURE__ */ jsxs(OryCard, { children: [
1222
- /* @__PURE__ */ jsx(OryCardHeader, {}),
1223
- /* @__PURE__ */ jsxs(OryCardContent, { children: [
1224
- /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1225
- showSso && /* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
1226
- /* @__PURE__ */ jsx(
1227
- OryForm,
1228
- {
1229
- "data-testid": `ory/form/methods/local`,
1230
- onAfterSubmit: handleAfterFormSubmit,
1231
- children: /* @__PURE__ */ jsxs(Form.Group, { children: [
1232
- showSsoDivider && /* @__PURE__ */ jsx(Card.Divider, {}),
1233
- nonSsoNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1234
- ] })
1235
- }
1236
- )
1237
- ] }),
1238
- /* @__PURE__ */ jsx(OryCardFooter, {})
1239
- ] });
1392
+ return /* @__PURE__ */ jsx(OryTwoStepCardStateProvideIdentifier, {});
1240
1393
  case "select_method":
1241
- return /* @__PURE__ */ jsxs(OryCard, { children: [
1242
- /* @__PURE__ */ jsx(OryCardHeader, {}),
1243
- /* @__PURE__ */ jsxs(OryCardContent, { children: [
1244
- /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1245
- showSso && /* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
1246
- Object.entries(authMethodBlocks).length > 0 && /* @__PURE__ */ jsx(
1247
- OryForm,
1248
- {
1249
- "data-testid": `ory/form/methods/local`,
1250
- onAfterSubmit: handleAfterFormSubmit,
1251
- children: /* @__PURE__ */ jsxs(Form.Group, { children: [
1252
- /* @__PURE__ */ jsx(Card.Divider, {}),
1253
- /* @__PURE__ */ jsx(
1254
- AuthMethodList,
1255
- {
1256
- options: authMethodBlocks,
1257
- setSelectedGroup: (group) => dispatchFormState({
1258
- type: "action_select_method",
1259
- method: group
1260
- })
1261
- }
1262
- ),
1263
- authMethodAdditionalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1264
- ] })
1265
- }
1266
- )
1267
- ] }),
1268
- /* @__PURE__ */ jsx(OryCardFooter, {})
1269
- ] });
1394
+ return /* @__PURE__ */ jsx(OryTwoStepCardStateSelectMethod, {});
1270
1395
  case "method_active":
1271
- return /* @__PURE__ */ jsxs(OryCard, { children: [
1272
- /* @__PURE__ */ jsx(OryCardHeader, {}),
1273
- /* @__PURE__ */ jsxs(OryCardContent, { children: [
1274
- /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1275
- showSso && /* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
1276
- /* @__PURE__ */ jsx(
1277
- OryForm,
1278
- {
1279
- "data-testid": `ory/form/methods/local`,
1280
- onAfterSubmit: handleAfterFormSubmit,
1281
- children: /* @__PURE__ */ jsxs(Form.Group, { children: [
1282
- ui.nodes.filter(
1283
- (n) => isUiNodeScriptAttributes(n.attributes) || n.group === UiNodeGroupEnum.Captcha || n.group === UiNodeGroupEnum.Default || n.group === UiNodeGroupEnum.Profile
1284
- ).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
1285
- finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1286
- ] })
1287
- }
1288
- )
1289
- ] }),
1290
- /* @__PURE__ */ jsx(OryCardFooter, {})
1291
- ] });
1396
+ return /* @__PURE__ */ jsx(OryTwoStepCardStateMethodActive, { formState });
1292
1397
  }
1293
1398
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1294
1399
  "unknown form state: ",
1295
1400
  formState.current
1296
1401
  ] });
1297
1402
  }
1298
- function AuthMethodList({ options, setSelectedGroup }) {
1299
- const { Card } = useComponents();
1300
- const { setValue, getValues } = useFormContext();
1301
- if (Object.entries(options).length === 0) {
1302
- return null;
1303
- }
1304
- const handleClick = (group, options2) => {
1305
- var _a, _b, _c, _d;
1306
- if (isGroupImmediateSubmit(group)) {
1307
- if (group === "code" && !getValues("identifier") && ((_b = (_a = options2 == null ? void 0 : options2.title) == null ? void 0 : _a.values) == null ? void 0 : _b.address)) {
1308
- setValue("identifier", (_d = (_c = options2 == null ? void 0 : options2.title) == null ? void 0 : _c.values) == null ? void 0 : _d.address);
1309
- }
1310
- setValue("method", group);
1311
- } else {
1312
- setSelectedGroup(group);
1313
- }
1314
- };
1315
- return /* @__PURE__ */ jsx(Card.AuthMethodListContainer, { children: Object.entries(options).map(([group, options2]) => /* @__PURE__ */ jsx(
1316
- Card.AuthMethodListItem,
1317
- {
1318
- group,
1319
- title: options2.title,
1320
- onClick: () => handleClick(group, options2)
1321
- },
1322
- group
1323
- )) });
1324
- }
1325
1403
  function OryFormGroups({ groups }) {
1326
1404
  const {
1327
1405
  flow: { ui }
@@ -1330,8 +1408,8 @@ function OryFormGroups({ groups }) {
1330
1408
  const { flowType } = useOryFlow();
1331
1409
  const { Form } = useComponents();
1332
1410
  const nodes = ui.nodes.filter((node) => groups.indexOf(node.group) > -1).sort((a, b) => nodeSorter(a, b, { flowType }));
1333
- return /* @__PURE__ */ jsx(Form.Group, { children: nodes.map((node, k) => {
1334
- return /* @__PURE__ */ jsx(Node, { node }, k);
1411
+ return /* @__PURE__ */ jsx(Form.Group, { children: nodes.map((node) => {
1412
+ return /* @__PURE__ */ jsx(Node, { node }, getNodeId(node));
1335
1413
  }) });
1336
1414
  }
1337
1415
  function OryFormSection({
@@ -1367,7 +1445,7 @@ function OryConsentCard() {
1367
1445
  /* @__PURE__ */ jsx(OryCardHeader, {}),
1368
1446
  /* @__PURE__ */ jsx(OryCardContent, { children: /* @__PURE__ */ jsxs(OryForm, { children: [
1369
1447
  /* @__PURE__ */ jsx(Card.Divider, {}),
1370
- /* @__PURE__ */ jsx(Form.Group, { children: flow.flow.ui.nodes.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)) }),
1448
+ /* @__PURE__ */ jsx(Form.Group, { children: flow.flow.ui.nodes.map((node) => /* @__PURE__ */ jsx(Node, { node }, getNodeId(node))) }),
1371
1449
  /* @__PURE__ */ jsx(Card.Divider, {}),
1372
1450
  /* @__PURE__ */ jsx(OryCardFooter, {})
1373
1451
  ] }) })
@@ -1738,7 +1816,7 @@ function SettingsSectionContent({ group, nodes }) {
1738
1816
  "data-testid": "ory/screen/settings/group/totp",
1739
1817
  children: [
1740
1818
  /* @__PURE__ */ jsx(OrySettingsTotp, { nodes: (_a = groupedNodes.groups.totp) != null ? _a : [] }),
1741
- (_b = groupedNodes.groups.default) == null ? void 0 : _b.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1819
+ (_b = groupedNodes.groups.default) == null ? void 0 : _b.map((node) => /* @__PURE__ */ jsx(Node, { node }, getNodeId(node)))
1742
1820
  ]
1743
1821
  }
1744
1822
  );
@@ -1756,7 +1834,7 @@ function SettingsSectionContent({ group, nodes }) {
1756
1834
  nodes: (_c = groupedNodes.groups.lookup_secret) != null ? _c : []
1757
1835
  }
1758
1836
  ),
1759
- (_d = groupedNodes.groups.default) == null ? void 0 : _d.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1837
+ (_d = groupedNodes.groups.default) == null ? void 0 : _d.map((node) => /* @__PURE__ */ jsx(Node, { node }, getNodeId(node)))
1760
1838
  ]
1761
1839
  }
1762
1840
  );
@@ -1769,7 +1847,7 @@ function SettingsSectionContent({ group, nodes }) {
1769
1847
  "data-testid": "ory/screen/settings/group/oidc",
1770
1848
  children: [
1771
1849
  /* @__PURE__ */ jsx(OrySettingsOidc, { nodes: (_e = groupedNodes.groups.oidc) != null ? _e : [] }),
1772
- (_f = groupedNodes.groups.default) == null ? void 0 : _f.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1850
+ (_f = groupedNodes.groups.default) == null ? void 0 : _f.map((node) => /* @__PURE__ */ jsx(Node, { node }, getNodeId(node)))
1773
1851
  ]
1774
1852
  }
1775
1853
  );
@@ -1782,7 +1860,7 @@ function SettingsSectionContent({ group, nodes }) {
1782
1860
  "data-testid": "ory/screen/settings/group/webauthn",
1783
1861
  children: [
1784
1862
  /* @__PURE__ */ jsx(OrySettingsWebauthn, { nodes: (_g = groupedNodes.groups.webauthn) != null ? _g : [] }),
1785
- (_h = groupedNodes.groups.default) == null ? void 0 : _h.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1863
+ (_h = groupedNodes.groups.default) == null ? void 0 : _h.map((node) => /* @__PURE__ */ jsx(Node, { node }, getNodeId(node)))
1786
1864
  ]
1787
1865
  }
1788
1866
  );
@@ -1795,7 +1873,7 @@ function SettingsSectionContent({ group, nodes }) {
1795
1873
  "data-testid": "ory/screen/settings/group/passkey",
1796
1874
  children: [
1797
1875
  /* @__PURE__ */ jsx(OrySettingsPasskey, { nodes: (_i = groupedNodes.groups.passkey) != null ? _i : [] }),
1798
- (_j = groupedNodes.groups.default) == null ? void 0 : _j.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1876
+ (_j = groupedNodes.groups.default) == null ? void 0 : _j.map((node) => /* @__PURE__ */ jsx(Node, { node }, getNodeId(node)))
1799
1877
  ]
1800
1878
  }
1801
1879
  );
@@ -1816,16 +1894,16 @@ function SettingsSectionContent({ group, nodes }) {
1816
1894
  id: `settings.${group}.description`
1817
1895
  }),
1818
1896
  children: [
1819
- (_k = groupedNodes.groups.default) == null ? void 0 : _k.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
1897
+ (_k = groupedNodes.groups.default) == null ? void 0 : _k.map((node) => /* @__PURE__ */ jsx(Node, { node }, getNodeId(node))),
1820
1898
  nodes.filter(
1821
1899
  (node) => "type" in node.attributes && node.attributes.type !== "submit"
1822
- ).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1900
+ ).map((node) => /* @__PURE__ */ jsx(Node, { node }, getNodeId(node)))
1823
1901
  ]
1824
1902
  }
1825
1903
  ),
1826
1904
  /* @__PURE__ */ jsx(Card.SettingsSectionFooter, { children: nodes.filter(
1827
1905
  (node) => "type" in node.attributes && node.attributes.type === "submit"
1828
- ).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)) })
1906
+ ).map((node) => /* @__PURE__ */ jsx(Node, { node }, getNodeId(node))) })
1829
1907
  ]
1830
1908
  }
1831
1909
  );
@@ -1839,7 +1917,7 @@ function OrySettingsCard() {
1839
1917
  const scriptNodes = onlyScriptNodes(flow.ui.nodes);
1840
1918
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1841
1919
  /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1842
- scriptNodes.map((n) => /* @__PURE__ */ jsx(Node, { node: n })),
1920
+ scriptNodes.map((n) => /* @__PURE__ */ jsx(Node, { node: n }, getNodeId(n))),
1843
1921
  uniqueGroups.entries.map(([group, nodes]) => {
1844
1922
  if (group === UiNodeGroupEnum.Default) {
1845
1923
  return null;