@ory/elements-react 1.0.0-next.44 → 1.0.0-next.45

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
@@ -204,7 +204,7 @@ function useNodesGroups(nodes, { omit } = {}) {
204
204
  groups2[node.group] = groupNodes;
205
205
  }
206
206
  return groups2;
207
- }, [nodes]);
207
+ }, [nodes, omit]);
208
208
  const entries = useMemo(
209
209
  () => Object.entries(groups).sort(([a], [b]) => groupSorter(a, b)),
210
210
  [groups, groupSorter]
@@ -871,7 +871,11 @@ function useOryFormSubmit(onAfterSubmit) {
871
871
  };
872
872
  return onSubmit;
873
873
  }
874
- function OryForm({ children, onAfterSubmit }) {
874
+ function OryForm({
875
+ children,
876
+ onAfterSubmit,
877
+ "data-testid": dataTestId
878
+ }) {
875
879
  const { Form } = useComponents();
876
880
  const flowContainer = useOryFlow();
877
881
  const methods = useFormContext();
@@ -899,7 +903,7 @@ function OryForm({ children, onAfterSubmit }) {
899
903
  }),
900
904
  type: "error"
901
905
  };
902
- return /* @__PURE__ */ jsxs(Fragment, { children: [
906
+ return /* @__PURE__ */ jsxs("div", { className: "grid gap-8", "data-testid": dataTestId, children: [
903
907
  /* @__PURE__ */ jsx(Message.Root, { children: /* @__PURE__ */ jsx(Message.Content, { message: m }, m.id) }),
904
908
  /* @__PURE__ */ jsx(OryCardFooter, {})
905
909
  ] });
@@ -910,6 +914,7 @@ function OryForm({ children, onAfterSubmit }) {
910
914
  return /* @__PURE__ */ jsx(
911
915
  Form.Root,
912
916
  {
917
+ "data-testid": dataTestId,
913
918
  action: flowContainer.flow.ui.action,
914
919
  method: flowContainer.flow.ui.method,
915
920
  onSubmit: (e) => void methods.handleSubmit(onSubmit)(e),
@@ -1130,7 +1135,7 @@ function OryFormSocialButtonsForm() {
1130
1135
  if (filteredNodes.length === 0) {
1131
1136
  return null;
1132
1137
  }
1133
- return /* @__PURE__ */ jsx(OryFormProvider, { children: /* @__PURE__ */ jsx(OryForm, { children: /* @__PURE__ */ jsx(OryFormOidcButtons, {}) }) });
1138
+ return /* @__PURE__ */ jsx(OryFormProvider, { children: /* @__PURE__ */ jsx(OryForm, { "data-testid": `ory/form/methods/oidc-saml`, children: /* @__PURE__ */ jsx(OryFormOidcButtons, {}) }) });
1134
1139
  }
1135
1140
  function isUINodeGroupEnum(method) {
1136
1141
  return Object.values(UiNodeGroupEnum).includes(method);
@@ -1146,7 +1151,7 @@ function OryTwoStepCard() {
1146
1151
  // We only want to render groups that have visible elements.
1147
1152
  omit: ["script", "input_hidden"]
1148
1153
  });
1149
- const options = Object.fromEntries(
1154
+ const authMethodBlocks = Object.fromEntries(
1150
1155
  Object.values(UiNodeGroupEnum).filter((group) => {
1151
1156
  var _a2;
1152
1157
  return (_a2 = groupsToShow.groups[group]) == null ? void 0 : _a2.length;
@@ -1161,7 +1166,17 @@ function OryTwoStepCard() {
1161
1166
  ].includes(group)
1162
1167
  ).map((g) => [g, {}])
1163
1168
  );
1164
- if (UiNodeGroupEnum.Code in options) {
1169
+ const authMethodAdditionalNodes = ui.nodes.filter(
1170
+ ({ group }) => [
1171
+ UiNodeGroupEnum.Oidc,
1172
+ UiNodeGroupEnum.Saml,
1173
+ UiNodeGroupEnum.Default,
1174
+ UiNodeGroupEnum.IdentifierFirst,
1175
+ UiNodeGroupEnum.Profile,
1176
+ UiNodeGroupEnum.Captcha
1177
+ ].includes(group)
1178
+ );
1179
+ if (UiNodeGroupEnum.Code in authMethodBlocks) {
1165
1180
  let identifier = (_b = (_a = findNode(ui.nodes, {
1166
1181
  group: "identifier_first",
1167
1182
  node_type: "input",
@@ -1173,7 +1188,7 @@ function OryTwoStepCard() {
1173
1188
  name: "address"
1174
1189
  })) == null ? void 0 : _c.attributes) == null ? void 0 : _d.value);
1175
1190
  if (identifier) {
1176
- options[UiNodeGroupEnum.Code] = {
1191
+ authMethodBlocks[UiNodeGroupEnum.Code] = {
1177
1192
  title: {
1178
1193
  id: "identities.messages.1010023",
1179
1194
  values: { address: identifier }
@@ -1206,39 +1221,45 @@ function OryTwoStepCard() {
1206
1221
  }
1207
1222
  return true;
1208
1223
  }).length > 0;
1209
- const captchaNodes = ui.nodes.filter(
1210
- (n) => n.group === UiNodeGroupEnum.Captcha
1211
- );
1212
1224
  return /* @__PURE__ */ jsxs(OryCard, { children: [
1213
1225
  /* @__PURE__ */ jsx(OryCardHeader, {}),
1214
1226
  /* @__PURE__ */ jsxs(OryCardContent, { children: [
1215
1227
  /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1216
1228
  showSso && /* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
1217
- /* @__PURE__ */ jsxs(OryForm, { onAfterSubmit: handleAfterFormSubmit, children: [
1218
- formState.current === "provide_identifier" && /* @__PURE__ */ jsxs(Form.Group, { children: [
1219
- showSsoDivider && /* @__PURE__ */ jsx(Card.Divider, {}),
1220
- nonSsoNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1221
- ] }),
1222
- formState.current === "select_method" && /* @__PURE__ */ jsxs(Form.Group, { children: [
1223
- Object.entries(options).length > 0 && /* @__PURE__ */ jsx(Card.Divider, {}),
1224
- Object.entries(options).length > 0 && /* @__PURE__ */ jsx(
1225
- AuthMethodList,
1226
- {
1227
- options,
1228
- setSelectedGroup: (group) => dispatchFormState({
1229
- type: "action_select_method",
1230
- method: group
1231
- })
1232
- }
1233
- ),
1234
- captchaNodes.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1235
- ] }),
1236
- formState.current === "method_active" && /* @__PURE__ */ jsxs(Form.Group, { children: [
1237
- ui.nodes.filter((n) => n.type === "script").map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
1238
- finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1239
- ] }),
1240
- /* @__PURE__ */ jsx(OryCardFooter, {})
1241
- ] })
1229
+ /* @__PURE__ */ jsxs(
1230
+ OryForm,
1231
+ {
1232
+ "data-testid": `ory/form/methods/local`,
1233
+ onAfterSubmit: handleAfterFormSubmit,
1234
+ children: [
1235
+ formState.current === "provide_identifier" && /* @__PURE__ */ jsxs(Form.Group, { children: [
1236
+ showSsoDivider && /* @__PURE__ */ jsx(Card.Divider, {}),
1237
+ nonSsoNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1238
+ ] }),
1239
+ formState.current === "select_method" && /* @__PURE__ */ jsxs(Form.Group, { children: [
1240
+ Object.entries(authMethodBlocks).length > 0 && /* @__PURE__ */ jsx(Card.Divider, {}),
1241
+ Object.entries(authMethodBlocks).length > 0 && /* @__PURE__ */ jsx(
1242
+ AuthMethodList,
1243
+ {
1244
+ options: authMethodBlocks,
1245
+ setSelectedGroup: (group) => dispatchFormState({
1246
+ type: "action_select_method",
1247
+ method: group
1248
+ })
1249
+ }
1250
+ ),
1251
+ authMethodAdditionalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1252
+ ] }),
1253
+ formState.current === "method_active" && /* @__PURE__ */ jsxs(Form.Group, { children: [
1254
+ ui.nodes.filter(
1255
+ (n) => isUiNodeScriptAttributes(n.attributes) || n.group === UiNodeGroupEnum.Captcha
1256
+ ).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
1257
+ finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1258
+ ] }),
1259
+ /* @__PURE__ */ jsx(OryCardFooter, {})
1260
+ ]
1261
+ }
1262
+ )
1242
1263
  ] })
1243
1264
  ] });
1244
1265
  }