@ory/elements-react 1.0.0-rc.0 → 1.0.0-rc.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## 1.0.0-rc.1 (2025-04-21)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - re-add missing error message when no methods provided ([#460](https://github.com/ory/elements/pull/460))
6
+ - resend not working for registration ([#468](https://github.com/ory/elements/pull/468))
7
+ - add missing color class to registration footer ([#473](https://github.com/ory/elements/pull/473))
8
+ - resend not working for registration ([#467](https://github.com/ory/elements/pull/467))
9
+
10
+ ### ❤️ Thank You
11
+
12
+ - hackerman @aeneasr
13
+ - Jonas Hungershausen
14
+
1
15
  ## 1.0.0-rc.0 (2025-04-17)
2
16
 
3
17
  ### 🚀 Features
package/dist/index.d.mts CHANGED
@@ -565,14 +565,17 @@ declare function messageTestId(message: UiText): {
565
565
  "data-testid": string;
566
566
  };
567
567
 
568
- type FormState = {
569
- current: "provide_identifier";
570
- } | {
568
+ type FormStateSelectMethod = {
571
569
  current: "select_method";
572
- } | {
570
+ };
571
+ type FormStateProvideIdentifier = {
572
+ current: "provide_identifier";
573
+ };
574
+ type FormStateMethodActive = {
573
575
  current: "method_active";
574
576
  method: UiNodeGroupEnum;
575
- } | {
577
+ };
578
+ type FormState = FormStateSelectMethod | FormStateProvideIdentifier | FormStateMethodActive | {
576
579
  current: "success_screen";
577
580
  } | {
578
581
  current: "settings";
@@ -619,4 +622,4 @@ type OryProviderProps = {
619
622
  } & OryFlowContainer & PropsWithChildren;
620
623
  declare function OryProvider({ children, components: Components, ...oryFlowProps }: OryProviderProps): react_jsx_runtime.JSX.Element;
621
624
 
622
- export { type ConsentFlow, type ConsentFlowContainer, type ErrorFlowContainer, type FlowContainerSetter, type FlowContextValue, type FormState, type FormStateAction, type FormValues, HeadlessPageHeader, type IntlConfig, type LoginFlowContainer, type OnSubmitHandlerProps, OryCard, type OryCardAuthMethodListItemProps, OryCardContent, type OryCardContentProps, type OryCardDividerProps, OryCardFooter, type OryCardFooterProps, OryCardHeader, type OryCardHeaderProps, type OryCardLogoProps, type OryCardRootProps as OryCardProps, type OryCardSettingsSectionProps, OryCardValidationMessages, type OryClientConfiguration, OryConsentCard, type OryFlowComponentOverrides, type OryFlowComponents, type OryFlowContainer, OryForm, OryFormGroupDivider, type OryFormGroupProps, OryFormGroups, type OryFormGroupsProps, OryFormOidcButtons, type OryFormOidcRootProps, type OryFormProps, type OryFormRootProps, OryFormSection, type OryFormSectionContentProps, type OryFormSectionFooterProps, type OryFormSectionProps, OryFormSocialButtonsForm, OryLocales, type OryMessageContentProps, type OryMessageRootProps, type OryNodeAnchorProps, type OryNodeButtonProps, type OryNodeCaptchaProps, type OryNodeConsentScopeCheckboxProps, type OryNodeImageProps, type OryNodeInputProps, type OryNodeLabelProps, type OryNodeOidcButtonProps, type OryNodeTextProps, type OryPageHeaderProps, OryProvider, type OryProviderProps, OrySettingsCard, type OrySettingsOidcProps, type OrySettingsPasskeyProps, type OrySettingsRecoveryCodesProps, type OrySettingsTotpProps, type OrySettingsWebauthnProps, OryTwoStepCard, type RecoveryFlowContainer, type RegistrationFlowContainer, type SettingsFlowContainer, type VerificationFlowContainer, messageTestId, uiTextToFormattedMessage, useComponents, useNodeSorter, useOryFlow };
625
+ export { type ConsentFlow, type ConsentFlowContainer, type ErrorFlowContainer, type FlowContainerSetter, type FlowContextValue, type FormState, type FormStateAction, type FormStateMethodActive, type FormStateProvideIdentifier, type FormStateSelectMethod, type FormValues, HeadlessPageHeader, type IntlConfig, type LoginFlowContainer, type OnSubmitHandlerProps, OryCard, type OryCardAuthMethodListItemProps, OryCardContent, type OryCardContentProps, type OryCardDividerProps, OryCardFooter, type OryCardFooterProps, OryCardHeader, type OryCardHeaderProps, type OryCardLogoProps, type OryCardRootProps as OryCardProps, type OryCardSettingsSectionProps, OryCardValidationMessages, type OryClientConfiguration, OryConsentCard, type OryFlowComponentOverrides, type OryFlowComponents, type OryFlowContainer, OryForm, OryFormGroupDivider, type OryFormGroupProps, OryFormGroups, type OryFormGroupsProps, OryFormOidcButtons, type OryFormOidcRootProps, type OryFormProps, type OryFormRootProps, OryFormSection, type OryFormSectionContentProps, type OryFormSectionFooterProps, type OryFormSectionProps, OryFormSocialButtonsForm, OryLocales, type OryMessageContentProps, type OryMessageRootProps, type OryNodeAnchorProps, type OryNodeButtonProps, type OryNodeCaptchaProps, type OryNodeConsentScopeCheckboxProps, type OryNodeImageProps, type OryNodeInputProps, type OryNodeLabelProps, type OryNodeOidcButtonProps, type OryNodeTextProps, type OryPageHeaderProps, OryProvider, type OryProviderProps, OrySettingsCard, type OrySettingsOidcProps, type OrySettingsPasskeyProps, type OrySettingsRecoveryCodesProps, type OrySettingsTotpProps, type OrySettingsWebauthnProps, OryTwoStepCard, type RecoveryFlowContainer, type RegistrationFlowContainer, type SettingsFlowContainer, type VerificationFlowContainer, messageTestId, uiTextToFormattedMessage, useComponents, useNodeSorter, useOryFlow };
package/dist/index.d.ts CHANGED
@@ -565,14 +565,17 @@ declare function messageTestId(message: UiText): {
565
565
  "data-testid": string;
566
566
  };
567
567
 
568
- type FormState = {
569
- current: "provide_identifier";
570
- } | {
568
+ type FormStateSelectMethod = {
571
569
  current: "select_method";
572
- } | {
570
+ };
571
+ type FormStateProvideIdentifier = {
572
+ current: "provide_identifier";
573
+ };
574
+ type FormStateMethodActive = {
573
575
  current: "method_active";
574
576
  method: UiNodeGroupEnum;
575
- } | {
577
+ };
578
+ type FormState = FormStateSelectMethod | FormStateProvideIdentifier | FormStateMethodActive | {
576
579
  current: "success_screen";
577
580
  } | {
578
581
  current: "settings";
@@ -619,4 +622,4 @@ type OryProviderProps = {
619
622
  } & OryFlowContainer & PropsWithChildren;
620
623
  declare function OryProvider({ children, components: Components, ...oryFlowProps }: OryProviderProps): react_jsx_runtime.JSX.Element;
621
624
 
622
- export { type ConsentFlow, type ConsentFlowContainer, type ErrorFlowContainer, type FlowContainerSetter, type FlowContextValue, type FormState, type FormStateAction, type FormValues, HeadlessPageHeader, type IntlConfig, type LoginFlowContainer, type OnSubmitHandlerProps, OryCard, type OryCardAuthMethodListItemProps, OryCardContent, type OryCardContentProps, type OryCardDividerProps, OryCardFooter, type OryCardFooterProps, OryCardHeader, type OryCardHeaderProps, type OryCardLogoProps, type OryCardRootProps as OryCardProps, type OryCardSettingsSectionProps, OryCardValidationMessages, type OryClientConfiguration, OryConsentCard, type OryFlowComponentOverrides, type OryFlowComponents, type OryFlowContainer, OryForm, OryFormGroupDivider, type OryFormGroupProps, OryFormGroups, type OryFormGroupsProps, OryFormOidcButtons, type OryFormOidcRootProps, type OryFormProps, type OryFormRootProps, OryFormSection, type OryFormSectionContentProps, type OryFormSectionFooterProps, type OryFormSectionProps, OryFormSocialButtonsForm, OryLocales, type OryMessageContentProps, type OryMessageRootProps, type OryNodeAnchorProps, type OryNodeButtonProps, type OryNodeCaptchaProps, type OryNodeConsentScopeCheckboxProps, type OryNodeImageProps, type OryNodeInputProps, type OryNodeLabelProps, type OryNodeOidcButtonProps, type OryNodeTextProps, type OryPageHeaderProps, OryProvider, type OryProviderProps, OrySettingsCard, type OrySettingsOidcProps, type OrySettingsPasskeyProps, type OrySettingsRecoveryCodesProps, type OrySettingsTotpProps, type OrySettingsWebauthnProps, OryTwoStepCard, type RecoveryFlowContainer, type RegistrationFlowContainer, type SettingsFlowContainer, type VerificationFlowContainer, messageTestId, uiTextToFormattedMessage, useComponents, useNodeSorter, useOryFlow };
625
+ export { type ConsentFlow, type ConsentFlowContainer, type ErrorFlowContainer, type FlowContainerSetter, type FlowContextValue, type FormState, type FormStateAction, type FormStateMethodActive, type FormStateProvideIdentifier, type FormStateSelectMethod, type FormValues, HeadlessPageHeader, type IntlConfig, type LoginFlowContainer, type OnSubmitHandlerProps, OryCard, type OryCardAuthMethodListItemProps, OryCardContent, type OryCardContentProps, type OryCardDividerProps, OryCardFooter, type OryCardFooterProps, OryCardHeader, type OryCardHeaderProps, type OryCardLogoProps, type OryCardRootProps as OryCardProps, type OryCardSettingsSectionProps, OryCardValidationMessages, type OryClientConfiguration, OryConsentCard, type OryFlowComponentOverrides, type OryFlowComponents, type OryFlowContainer, OryForm, OryFormGroupDivider, type OryFormGroupProps, OryFormGroups, type OryFormGroupsProps, OryFormOidcButtons, type OryFormOidcRootProps, type OryFormProps, type OryFormRootProps, OryFormSection, type OryFormSectionContentProps, type OryFormSectionFooterProps, type OryFormSectionProps, OryFormSocialButtonsForm, OryLocales, type OryMessageContentProps, type OryMessageRootProps, type OryNodeAnchorProps, type OryNodeButtonProps, type OryNodeCaptchaProps, type OryNodeConsentScopeCheckboxProps, type OryNodeImageProps, type OryNodeInputProps, type OryNodeLabelProps, type OryNodeOidcButtonProps, type OryNodeTextProps, type OryPageHeaderProps, OryProvider, type OryProviderProps, OrySettingsCard, type OrySettingsOidcProps, type OrySettingsPasskeyProps, type OrySettingsRecoveryCodesProps, type OrySettingsTotpProps, type OrySettingsWebauthnProps, OryTwoStepCard, type RecoveryFlowContainer, type RegistrationFlowContainer, type SettingsFlowContainer, type VerificationFlowContainer, messageTestId, uiTextToFormattedMessage, useComponents, useNodeSorter, useOryFlow };
package/dist/index.js CHANGED
@@ -94,28 +94,10 @@ function OryComponentProvider({
94
94
  }
95
95
  );
96
96
  }
97
- function isChoosingMethod(flow) {
98
- return flow.flow.ui.nodes.some(
99
- (node) => "name" in node.attributes && node.attributes.name === "screen" && "value" in node.attributes && node.attributes.value === "previous"
100
- ) || flow.flow.ui.nodes.some(
101
- (node) => node.group === clientFetch.UiNodeGroupEnum.IdentifierFirst && "name" in node.attributes && node.attributes.name === "identifier" && node.attributes.type === "hidden"
102
- ) || flow.flowType === clientFetch.FlowType.Login && flow.flow.requested_aal === "aal2";
103
- }
104
- function removeSsoNodes(nodes) {
105
- return nodes.filter(
106
- (node) => !(node.group === clientFetch.UiNodeGroupEnum.Oidc || node.group === clientFetch.UiNodeGroupEnum.Saml)
107
- );
108
- }
109
- function getFinalNodes(uniqueGroups, selectedGroup) {
110
- var _a, _b, _c, _d;
111
- const selectedNodes = selectedGroup ? (_a = uniqueGroups[selectedGroup]) != null ? _a : [] : [];
112
- return [
113
- ...(_b = uniqueGroups == null ? void 0 : uniqueGroups.identifier_first) != null ? _b : [],
114
- ...(_c = uniqueGroups == null ? void 0 : uniqueGroups.default) != null ? _c : [],
115
- ...(_d = uniqueGroups == null ? void 0 : uniqueGroups.captcha) != null ? _d : []
116
- ].flat().filter(
117
- (node) => "type" in node.attributes && node.attributes.type === "hidden"
118
- ).concat(selectedNodes);
97
+
98
+ // src/theme/default/utils/form.ts
99
+ function isGroupImmediateSubmit(group) {
100
+ return group === "code";
119
101
  }
120
102
  function triggerToWindowCall(trigger) {
121
103
  if (!trigger) {
@@ -227,6 +209,93 @@ function useNodesGroups(nodes, { omit } = {}) {
227
209
  var findNode = (nodes, opt) => nodes.find((n) => {
228
210
  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);
229
211
  });
212
+ function useFunctionalNodes(nodes) {
213
+ return nodes.filter(
214
+ ({ group }) => [
215
+ clientFetch.UiNodeGroupEnum.Default,
216
+ clientFetch.UiNodeGroupEnum.IdentifierFirst,
217
+ clientFetch.UiNodeGroupEnum.Profile,
218
+ clientFetch.UiNodeGroupEnum.Captcha
219
+ ].includes(group)
220
+ );
221
+ }
222
+ function isUiNodeGroupEnum(method) {
223
+ return Object.values(clientFetch.UiNodeGroupEnum).includes(method);
224
+ }
225
+ function isSingleSignOnNode(node) {
226
+ return node.group === clientFetch.UiNodeGroupEnum.Oidc || node.group === clientFetch.UiNodeGroupEnum.Saml;
227
+ }
228
+ function hasSingleSignOnNodes(nodes) {
229
+ return nodes.some(isSingleSignOnNode);
230
+ }
231
+ function withoutSingleSignOnNodes(nodes) {
232
+ return nodes.filter((node) => !isSingleSignOnNode(node));
233
+ }
234
+ function isNodeVisible(node) {
235
+ if (clientFetch.isUiNodeScriptAttributes(node.attributes)) {
236
+ return false;
237
+ } else if (clientFetch.isUiNodeInputAttributes(node.attributes)) {
238
+ if (node.attributes.type === "hidden") {
239
+ return false;
240
+ }
241
+ }
242
+ return true;
243
+ }
244
+ function useNodeGroupsWithVisibleNodes(nodes) {
245
+ return react.useMemo(() => {
246
+ var _a, _b;
247
+ const groups = {};
248
+ const groupRetained = {};
249
+ for (const node of nodes) {
250
+ const groupNodes = (_a = groups[node.group]) != null ? _a : [];
251
+ const groupCount = (_b = groupRetained[node.group]) != null ? _b : 0;
252
+ groupNodes.push(node);
253
+ groups[node.group] = groupNodes;
254
+ if (!isNodeVisible(node)) {
255
+ continue;
256
+ }
257
+ groupRetained[node.group] = groupCount + 1;
258
+ }
259
+ const finalGroups = {};
260
+ for (const [group, count] of Object.entries(groupRetained)) {
261
+ if (count > 0) {
262
+ finalGroups[group] = groups[group];
263
+ }
264
+ }
265
+ return finalGroups;
266
+ }, [nodes]);
267
+ }
268
+
269
+ // src/components/card/two-step/utils.ts
270
+ function isChoosingMethod(flow) {
271
+ return flow.flow.ui.nodes.some(
272
+ (node) => "name" in node.attributes && node.attributes.name === "screen" && "value" in node.attributes && node.attributes.value === "previous"
273
+ ) || flow.flow.ui.nodes.some(
274
+ (node) => node.group === clientFetch.UiNodeGroupEnum.IdentifierFirst && "name" in node.attributes && node.attributes.name === "identifier" && node.attributes.type === "hidden"
275
+ ) || flow.flowType === clientFetch.FlowType.Login && flow.flow.requested_aal === "aal2";
276
+ }
277
+ function getFinalNodes(uniqueGroups, selectedGroup) {
278
+ var _a, _b, _c, _d;
279
+ const selectedNodes = selectedGroup ? (_a = uniqueGroups[selectedGroup]) != null ? _a : [] : [];
280
+ return [
281
+ ...(_b = uniqueGroups == null ? void 0 : uniqueGroups.identifier_first) != null ? _b : [],
282
+ ...(_c = uniqueGroups == null ? void 0 : uniqueGroups.default) != null ? _c : [],
283
+ ...(_d = uniqueGroups == null ? void 0 : uniqueGroups.captcha) != null ? _d : []
284
+ ].flat().filter(
285
+ (node) => "type" in node.attributes && node.attributes.type === "hidden"
286
+ ).concat(selectedNodes);
287
+ }
288
+ var handleAfterFormSubmit = (dispatchFormState) => (method) => {
289
+ if (typeof method !== "string" || !isUiNodeGroupEnum(method)) {
290
+ return;
291
+ }
292
+ if (isGroupImmediateSubmit(method)) {
293
+ dispatchFormState({
294
+ type: "action_select_method",
295
+ method
296
+ });
297
+ }
298
+ };
230
299
 
231
300
  // src/context/form-state.ts
232
301
  function findMethodWithMessage(nodes) {
@@ -492,11 +561,6 @@ function OryCardContent({ children }) {
492
561
  const { Card } = useComponents();
493
562
  return /* @__PURE__ */ jsxRuntime.jsx(Card.Content, { children });
494
563
  }
495
-
496
- // src/theme/default/utils/form.ts
497
- function isGroupImmediateSubmit(group) {
498
- return group === "code";
499
- }
500
564
  function frontendClient(sdkUrl, opts = {}) {
501
565
  const config = new clientFetch.Configuration({
502
566
  ...opts,
@@ -894,6 +958,9 @@ function OryForm({
894
958
  const onSubmit = useOryFormSubmit(onAfterSubmit);
895
959
  const hasMethods = flowContainer.flow.ui.nodes.some((node) => {
896
960
  if (clientFetch.isUiNodeInputAttributes(node.attributes)) {
961
+ if (node.attributes.type === "hidden") {
962
+ return false;
963
+ }
897
964
  return node.attributes.name !== "csrf_token";
898
965
  } else if (clientFetch.isUiNodeAnchorAttributes(node.attributes)) {
899
966
  return true;
@@ -915,7 +982,7 @@ function OryForm({
915
982
  };
916
983
  return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": dataTestId, children: /* @__PURE__ */ jsxRuntime.jsx(Message.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(Message.Content, { message: m }, m.id) }) });
917
984
  }
918
- if (flowContainer.flowType === clientFetch.FlowType.Login && flowContainer.formState.current === "method_active" && flowContainer.formState.method === "code") {
985
+ if ((flowContainer.flowType === clientFetch.FlowType.Login || flowContainer.flowType === clientFetch.FlowType.Registration) && flowContainer.formState.current === "method_active" && flowContainer.formState.method === "code") {
919
986
  methods.setValue("method", "code");
920
987
  }
921
988
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -1141,24 +1208,104 @@ function OryFormSocialButtonsForm() {
1141
1208
  }
1142
1209
  return /* @__PURE__ */ jsxRuntime.jsx(OryFormProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(OryForm, { "data-testid": `ory/form/methods/oidc-saml`, children: /* @__PURE__ */ jsxRuntime.jsx(OryFormOidcButtons, {}) }) });
1143
1210
  }
1144
- function isUINodeGroupEnum(method) {
1145
- return Object.values(clientFetch.UiNodeGroupEnum).includes(method);
1211
+ function OryTwoStepCardStateMethodActive({
1212
+ formState
1213
+ }) {
1214
+ const { Form } = useComponents();
1215
+ const { flow, flowType, dispatchFormState } = useOryFlow();
1216
+ const { ui } = flow;
1217
+ const nodeSorter = useNodeSorter();
1218
+ const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
1219
+ const groupsToShow = useNodeGroupsWithVisibleNodes(ui.nodes);
1220
+ const finalNodes = getFinalNodes(groupsToShow, formState.method);
1221
+ const selectedMethodIsSocial = formState.method === clientFetch.UiNodeGroupEnum.Oidc || formState.method === clientFetch.UiNodeGroupEnum.Saml;
1222
+ return /* @__PURE__ */ jsxRuntime.jsxs(OryCard, { children: [
1223
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
1224
+ /* @__PURE__ */ jsxRuntime.jsxs(OryCardContent, { children: [
1225
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
1226
+ selectedMethodIsSocial && /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
1227
+ /* @__PURE__ */ jsxRuntime.jsx(
1228
+ OryForm,
1229
+ {
1230
+ "data-testid": `ory/form/methods/local`,
1231
+ onAfterSubmit: handleAfterFormSubmit(dispatchFormState),
1232
+ children: /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1233
+ ui.nodes.filter(
1234
+ (n) => clientFetch.isUiNodeScriptAttributes(n.attributes) || n.group === clientFetch.UiNodeGroupEnum.Captcha || n.group === clientFetch.UiNodeGroupEnum.Default || n.group === clientFetch.UiNodeGroupEnum.Profile
1235
+ ).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)),
1236
+ finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1237
+ ] })
1238
+ }
1239
+ )
1240
+ ] }),
1241
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1242
+ ] });
1146
1243
  }
1147
- function OryTwoStepCard() {
1148
- var _a, _b, _c, _d;
1244
+ function OryTwoStepCardStateProvideIdentifier() {
1149
1245
  const { Form, Card } = useComponents();
1150
- const { flow, flowType, formState, dispatchFormState } = useOryFlow();
1151
- const { ui } = flow;
1246
+ const { flowType, flow, dispatchFormState } = useOryFlow();
1152
1247
  const nodeSorter = useNodeSorter();
1153
1248
  const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
1154
- const groupsToShow = useNodesGroups(ui.nodes, {
1155
- // We only want to render groups that have visible elements.
1156
- omit: ["script", "input_hidden"]
1157
- });
1158
- const authMethodBlocks = Object.fromEntries(
1249
+ const nonSsoNodes = withoutSingleSignOnNodes(flow.ui.nodes).sort(sortNodes);
1250
+ const hasSso = flow.ui.nodes.filter(isNodeVisible).some(
1251
+ (node) => node.group === clientFetch.UiNodeGroupEnum.Oidc || node.group === clientFetch.UiNodeGroupEnum.Saml
1252
+ );
1253
+ const showSsoDivider = hasSso && nonSsoNodes.some(isNodeVisible);
1254
+ return /* @__PURE__ */ jsxRuntime.jsxs(OryCard, { children: [
1255
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
1256
+ /* @__PURE__ */ jsxRuntime.jsxs(OryCardContent, { children: [
1257
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
1258
+ /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
1259
+ /* @__PURE__ */ jsxRuntime.jsx(
1260
+ OryForm,
1261
+ {
1262
+ "data-testid": `ory/form/methods/local`,
1263
+ onAfterSubmit: handleAfterFormSubmit(dispatchFormState),
1264
+ children: /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1265
+ showSsoDivider && /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1266
+ nonSsoNodes.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1267
+ ] })
1268
+ }
1269
+ )
1270
+ ] }),
1271
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1272
+ ] });
1273
+ }
1274
+ function AuthMethodList({
1275
+ options,
1276
+ setSelectedGroup
1277
+ }) {
1278
+ const { Card } = useComponents();
1279
+ const { setValue, getValues } = reactHookForm.useFormContext();
1280
+ if (Object.entries(options).length === 0) {
1281
+ return null;
1282
+ }
1283
+ const handleClick = (group, options2) => {
1284
+ var _a, _b, _c, _d;
1285
+ if (isGroupImmediateSubmit(group)) {
1286
+ if (group === "code" && !getValues("identifier") && ((_b = (_a = options2 == null ? void 0 : options2.title) == null ? void 0 : _a.values) == null ? void 0 : _b.address)) {
1287
+ setValue("identifier", (_d = (_c = options2 == null ? void 0 : options2.title) == null ? void 0 : _c.values) == null ? void 0 : _d.address);
1288
+ }
1289
+ setValue("method", group);
1290
+ } else {
1291
+ setSelectedGroup(group);
1292
+ }
1293
+ };
1294
+ return /* @__PURE__ */ jsxRuntime.jsx(Card.AuthMethodListContainer, { children: Object.entries(options).map(([group, options2]) => /* @__PURE__ */ jsxRuntime.jsx(
1295
+ Card.AuthMethodListItem,
1296
+ {
1297
+ group,
1298
+ title: options2.title,
1299
+ onClick: () => handleClick(group, options2)
1300
+ },
1301
+ group
1302
+ )) });
1303
+ }
1304
+ function toAuthMethodPickerOptions(visibleGroups) {
1305
+ return Object.fromEntries(
1159
1306
  Object.values(clientFetch.UiNodeGroupEnum).filter((group) => {
1160
- var _a2;
1161
- return (_a2 = groupsToShow.groups[group]) == null ? void 0 : _a2.length;
1307
+ var _a;
1308
+ return (_a = visibleGroups[group]) == null ? void 0 : _a.length;
1162
1309
  }).filter(
1163
1310
  (group) => ![
1164
1311
  clientFetch.UiNodeGroupEnum.Oidc,
@@ -1170,16 +1317,18 @@ function OryTwoStepCard() {
1170
1317
  ].includes(group)
1171
1318
  ).map((g) => [g, {}])
1172
1319
  );
1173
- const authMethodAdditionalNodes = ui.nodes.filter(
1174
- ({ group }) => [
1175
- clientFetch.UiNodeGroupEnum.Oidc,
1176
- clientFetch.UiNodeGroupEnum.Saml,
1177
- clientFetch.UiNodeGroupEnum.Default,
1178
- clientFetch.UiNodeGroupEnum.IdentifierFirst,
1179
- clientFetch.UiNodeGroupEnum.Profile,
1180
- clientFetch.UiNodeGroupEnum.Captcha
1181
- ].includes(group)
1182
- );
1320
+ }
1321
+ function OryTwoStepCardStateSelectMethod() {
1322
+ var _a, _b, _c, _d;
1323
+ const { Form, Card, Message } = useComponents();
1324
+ const { flow, flowType, dispatchFormState } = useOryFlow();
1325
+ const { ui } = flow;
1326
+ const intl = reactIntl.useIntl();
1327
+ const nodeSorter = useNodeSorter();
1328
+ const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
1329
+ const visibleGroups = useNodeGroupsWithVisibleNodes(ui.nodes);
1330
+ const authMethodBlocks = toAuthMethodPickerOptions(visibleGroups);
1331
+ const authMethodAdditionalNodes = useFunctionalNodes(ui.nodes);
1183
1332
  if (clientFetch.UiNodeGroupEnum.Code in authMethodBlocks) {
1184
1333
  let identifier = (_b = (_a = findNode(ui.nodes, {
1185
1334
  group: "identifier_first",
@@ -1200,137 +1349,59 @@ function OryTwoStepCard() {
1200
1349
  };
1201
1350
  }
1202
1351
  }
1203
- const nonSsoNodes = removeSsoNodes(ui.nodes);
1204
- const finalNodes = formState.current === "method_active" ? getFinalNodes(groupsToShow.groups, formState.method) : [];
1205
- const handleAfterFormSubmit = (method) => {
1206
- if (typeof method !== "string" || !isUINodeGroupEnum(method)) {
1207
- return;
1208
- }
1209
- if (isGroupImmediateSubmit(method)) {
1210
- dispatchFormState({
1211
- type: "action_select_method",
1212
- method
1213
- });
1214
- }
1352
+ const noMethods = {
1353
+ id: 5000002,
1354
+ text: intl.formatMessage({
1355
+ id: `identities.messages.5000002`,
1356
+ defaultMessage: "No authentication methods are available for this request. Please contact the site or app owner."
1357
+ }),
1358
+ type: "error"
1215
1359
  };
1216
- const hasSso = ui.nodes.some(
1217
- (node) => node.group === clientFetch.UiNodeGroupEnum.Oidc || node.group === clientFetch.UiNodeGroupEnum.Saml
1218
- );
1219
- const showSso = !(formState.current === "method_active" && !(formState.method === clientFetch.UiNodeGroupEnum.Oidc || formState.method === clientFetch.UiNodeGroupEnum.Saml));
1220
- const showSsoDivider = hasSso && nonSsoNodes.some((n) => {
1221
- if (clientFetch.isUiNodeInputAttributes(n.attributes)) {
1222
- return n.attributes.type !== clientFetch.UiNodeInputAttributesTypeEnum.Hidden;
1223
- } else if (clientFetch.isUiNodeScriptAttributes(n.attributes)) {
1224
- return false;
1225
- }
1226
- return true;
1227
- });
1360
+ return /* @__PURE__ */ jsxRuntime.jsxs(OryCard, { children: [
1361
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
1362
+ /* @__PURE__ */ jsxRuntime.jsxs(OryCardContent, { children: [
1363
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
1364
+ /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
1365
+ Object.entries(authMethodBlocks).length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
1366
+ OryForm,
1367
+ {
1368
+ "data-testid": `ory/form/methods/local`,
1369
+ onAfterSubmit: handleAfterFormSubmit(dispatchFormState),
1370
+ children: /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1371
+ /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1372
+ /* @__PURE__ */ jsxRuntime.jsx(
1373
+ AuthMethodList,
1374
+ {
1375
+ options: authMethodBlocks,
1376
+ setSelectedGroup: (group) => dispatchFormState({
1377
+ type: "action_select_method",
1378
+ method: group
1379
+ })
1380
+ }
1381
+ ),
1382
+ authMethodAdditionalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1383
+ ] })
1384
+ }
1385
+ ) : !hasSingleSignOnNodes(ui.nodes) && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": `ory/form/methods/local`, children: /* @__PURE__ */ jsxRuntime.jsx(Message.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(Message.Content, { message: noMethods }, noMethods.id) }) })
1386
+ ] }),
1387
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1388
+ ] });
1389
+ }
1390
+ function OryTwoStepCard() {
1391
+ const { formState } = useOryFlow();
1228
1392
  switch (formState.current) {
1229
1393
  case "provide_identifier":
1230
- return /* @__PURE__ */ jsxRuntime.jsxs(OryCard, { children: [
1231
- /* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
1232
- /* @__PURE__ */ jsxRuntime.jsxs(OryCardContent, { children: [
1233
- /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
1234
- showSso && /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
1235
- /* @__PURE__ */ jsxRuntime.jsx(
1236
- OryForm,
1237
- {
1238
- "data-testid": `ory/form/methods/local`,
1239
- onAfterSubmit: handleAfterFormSubmit,
1240
- children: /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1241
- showSsoDivider && /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1242
- nonSsoNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1243
- ] })
1244
- }
1245
- )
1246
- ] }),
1247
- /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1248
- ] });
1394
+ return /* @__PURE__ */ jsxRuntime.jsx(OryTwoStepCardStateProvideIdentifier, {});
1249
1395
  case "select_method":
1250
- return /* @__PURE__ */ jsxRuntime.jsxs(OryCard, { children: [
1251
- /* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
1252
- /* @__PURE__ */ jsxRuntime.jsxs(OryCardContent, { children: [
1253
- /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
1254
- showSso && /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
1255
- Object.entries(authMethodBlocks).length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1256
- OryForm,
1257
- {
1258
- "data-testid": `ory/form/methods/local`,
1259
- onAfterSubmit: handleAfterFormSubmit,
1260
- children: /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1261
- /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1262
- /* @__PURE__ */ jsxRuntime.jsx(
1263
- AuthMethodList,
1264
- {
1265
- options: authMethodBlocks,
1266
- setSelectedGroup: (group) => dispatchFormState({
1267
- type: "action_select_method",
1268
- method: group
1269
- })
1270
- }
1271
- ),
1272
- authMethodAdditionalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1273
- ] })
1274
- }
1275
- )
1276
- ] }),
1277
- /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1278
- ] });
1396
+ return /* @__PURE__ */ jsxRuntime.jsx(OryTwoStepCardStateSelectMethod, {});
1279
1397
  case "method_active":
1280
- return /* @__PURE__ */ jsxRuntime.jsxs(OryCard, { children: [
1281
- /* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
1282
- /* @__PURE__ */ jsxRuntime.jsxs(OryCardContent, { children: [
1283
- /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
1284
- showSso && /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
1285
- /* @__PURE__ */ jsxRuntime.jsx(
1286
- OryForm,
1287
- {
1288
- "data-testid": `ory/form/methods/local`,
1289
- onAfterSubmit: handleAfterFormSubmit,
1290
- children: /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1291
- ui.nodes.filter(
1292
- (n) => clientFetch.isUiNodeScriptAttributes(n.attributes) || n.group === clientFetch.UiNodeGroupEnum.Captcha || n.group === clientFetch.UiNodeGroupEnum.Default || n.group === clientFetch.UiNodeGroupEnum.Profile
1293
- ).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)),
1294
- finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1295
- ] })
1296
- }
1297
- )
1298
- ] }),
1299
- /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1300
- ] });
1398
+ return /* @__PURE__ */ jsxRuntime.jsx(OryTwoStepCardStateMethodActive, { formState });
1301
1399
  }
1302
1400
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1303
1401
  "unknown form state: ",
1304
1402
  formState.current
1305
1403
  ] });
1306
1404
  }
1307
- function AuthMethodList({ options, setSelectedGroup }) {
1308
- const { Card } = useComponents();
1309
- const { setValue, getValues } = reactHookForm.useFormContext();
1310
- if (Object.entries(options).length === 0) {
1311
- return null;
1312
- }
1313
- const handleClick = (group, options2) => {
1314
- var _a, _b, _c, _d;
1315
- if (isGroupImmediateSubmit(group)) {
1316
- if (group === "code" && !getValues("identifier") && ((_b = (_a = options2 == null ? void 0 : options2.title) == null ? void 0 : _a.values) == null ? void 0 : _b.address)) {
1317
- setValue("identifier", (_d = (_c = options2 == null ? void 0 : options2.title) == null ? void 0 : _c.values) == null ? void 0 : _d.address);
1318
- }
1319
- setValue("method", group);
1320
- } else {
1321
- setSelectedGroup(group);
1322
- }
1323
- };
1324
- return /* @__PURE__ */ jsxRuntime.jsx(Card.AuthMethodListContainer, { children: Object.entries(options).map(([group, options2]) => /* @__PURE__ */ jsxRuntime.jsx(
1325
- Card.AuthMethodListItem,
1326
- {
1327
- group,
1328
- title: options2.title,
1329
- onClick: () => handleClick(group, options2)
1330
- },
1331
- group
1332
- )) });
1333
- }
1334
1405
  function OryFormGroups({ groups }) {
1335
1406
  const {
1336
1407
  flow: { ui }