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

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
@@ -187,13 +187,16 @@ function nodesToAuthMethodGroups(nodes, excludeAuthMethods = []) {
187
187
  ].includes(group)
188
188
  );
189
189
  }
190
- function useNodesGroups(nodes) {
190
+ function useNodesGroups(nodes, { omit } = {}) {
191
191
  const groupSorter = useGroupSorter();
192
192
  const groups = useMemo(() => {
193
193
  var _a;
194
194
  const groups2 = {};
195
195
  for (const node of nodes) {
196
- if (node.type === "script") {
196
+ if ((omit == null ? void 0 : omit.includes("script")) && isUiNodeScriptAttributes(node.attributes)) {
197
+ continue;
198
+ }
199
+ if ((omit == null ? void 0 : omit.includes("input_hidden")) && isUiNodeInputAttributes(node.attributes) && node.attributes.type === "hidden") {
197
200
  continue;
198
201
  }
199
202
  const groupNodes = (_a = groups2[node.group]) != null ? _a : [];
@@ -1139,11 +1142,14 @@ function OryTwoStepCard() {
1139
1142
  const { ui } = flow;
1140
1143
  const nodeSorter = useNodeSorter();
1141
1144
  const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
1142
- const uniqueGroups = useNodesGroups(ui.nodes);
1145
+ const groupsToShow = useNodesGroups(ui.nodes, {
1146
+ // We only want to render groups that have visible elements.
1147
+ omit: ["script", "input_hidden"]
1148
+ });
1143
1149
  const options = Object.fromEntries(
1144
1150
  Object.values(UiNodeGroupEnum).filter((group) => {
1145
1151
  var _a2;
1146
- return (_a2 = uniqueGroups.groups[group]) == null ? void 0 : _a2.length;
1152
+ return (_a2 = groupsToShow.groups[group]) == null ? void 0 : _a2.length;
1147
1153
  }).filter(
1148
1154
  (group) => ![
1149
1155
  UiNodeGroupEnum.Oidc,
@@ -1176,7 +1182,7 @@ function OryTwoStepCard() {
1176
1182
  }
1177
1183
  }
1178
1184
  const nonSsoNodes = removeSsoNodes(ui.nodes);
1179
- const finalNodes = formState.current === "method_active" ? getFinalNodes(uniqueGroups.groups, formState.method) : [];
1185
+ const finalNodes = formState.current === "method_active" ? getFinalNodes(groupsToShow.groups, formState.method) : [];
1180
1186
  const handleAfterFormSubmit = (method) => {
1181
1187
  if (typeof method !== "string" || !isUINodeGroupEnum(method)) {
1182
1188
  return;
@@ -1200,35 +1206,36 @@ function OryTwoStepCard() {
1200
1206
  }
1201
1207
  return true;
1202
1208
  }).length > 0;
1209
+ const captchaNodes = ui.nodes.filter(
1210
+ (n) => n.group === UiNodeGroupEnum.Captcha
1211
+ );
1203
1212
  return /* @__PURE__ */ jsxs(OryCard, { children: [
1204
1213
  /* @__PURE__ */ jsx(OryCardHeader, {}),
1205
1214
  /* @__PURE__ */ jsxs(OryCardContent, { children: [
1206
1215
  /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1207
1216
  showSso && /* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
1208
1217
  /* @__PURE__ */ jsxs(OryForm, { onAfterSubmit: handleAfterFormSubmit, children: [
1209
- /* @__PURE__ */ jsxs(Form.Group, { children: [
1210
- formState.current === "provide_identifier" && /* @__PURE__ */ jsxs(Fragment, { children: [
1211
- showSsoDivider && /* @__PURE__ */ jsx(Card.Divider, {}),
1212
- nonSsoNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1213
- ] }),
1214
- formState.current === "select_method" && /* @__PURE__ */ jsxs(Fragment, { children: [
1215
- /* @__PURE__ */ jsx(Card.Divider, {}),
1216
- /* @__PURE__ */ jsx(
1217
- AuthMethodList,
1218
- {
1219
- options,
1220
- setSelectedGroup: (group) => dispatchFormState({
1221
- type: "action_select_method",
1222
- method: group
1223
- })
1224
- }
1225
- ),
1226
- ui.nodes.filter((n) => n.group === UiNodeGroupEnum.Captcha).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1227
- ] }),
1228
- formState.current === "method_active" && /* @__PURE__ */ jsxs(Fragment, { children: [
1229
- ui.nodes.filter((n) => n.type === "script").map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
1230
- finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1231
- ] })
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))
1232
1239
  ] }),
1233
1240
  /* @__PURE__ */ jsx(OryCardFooter, {})
1234
1241
  ] })
@@ -1238,6 +1245,9 @@ function OryTwoStepCard() {
1238
1245
  function AuthMethodList({ options, setSelectedGroup }) {
1239
1246
  const { Card } = useComponents();
1240
1247
  const { setValue, getValues } = useFormContext();
1248
+ if (Object.entries(options).length === 0) {
1249
+ return null;
1250
+ }
1241
1251
  const handleClick = (group, options2) => {
1242
1252
  var _a, _b, _c, _d;
1243
1253
  if (isGroupImmediateSubmit(group)) {
@@ -1663,16 +1673,19 @@ function SettingsSectionContent({ group, nodes }) {
1663
1673
  const { Card } = useComponents();
1664
1674
  const intl = useIntl();
1665
1675
  const { flow } = useOryFlow();
1666
- const uniqueGroups = useNodesGroups(flow.ui.nodes);
1676
+ const groupedNodes = useNodesGroups(flow.ui.nodes, {
1677
+ // Script nodes are already handled by the parent component.
1678
+ omit: ["script"]
1679
+ });
1667
1680
  if (group === UiNodeGroupEnum.Totp) {
1668
1681
  return /* @__PURE__ */ jsxs(
1669
1682
  OryFormSection,
1670
1683
  {
1671
- nodes: uniqueGroups.groups.totp,
1684
+ nodes: groupedNodes.groups.totp,
1672
1685
  "data-testid": "ory/screen/settings/group/totp",
1673
1686
  children: [
1674
- /* @__PURE__ */ jsx(OrySettingsTotp, { nodes: (_a = uniqueGroups.groups.totp) != null ? _a : [] }),
1675
- (_b = uniqueGroups.groups.default) == null ? void 0 : _b.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1687
+ /* @__PURE__ */ jsx(OrySettingsTotp, { nodes: (_a = groupedNodes.groups.totp) != null ? _a : [] }),
1688
+ (_b = groupedNodes.groups.default) == null ? void 0 : _b.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1676
1689
  ]
1677
1690
  }
1678
1691
  );
@@ -1681,16 +1694,16 @@ function SettingsSectionContent({ group, nodes }) {
1681
1694
  return /* @__PURE__ */ jsxs(
1682
1695
  OryFormSection,
1683
1696
  {
1684
- nodes: uniqueGroups.groups.lookup_secret,
1697
+ nodes: groupedNodes.groups.lookup_secret,
1685
1698
  "data-testid": "ory/screen/settings/group/lookup_secret",
1686
1699
  children: [
1687
1700
  /* @__PURE__ */ jsx(
1688
1701
  OrySettingsRecoveryCodes,
1689
1702
  {
1690
- nodes: (_c = uniqueGroups.groups.lookup_secret) != null ? _c : []
1703
+ nodes: (_c = groupedNodes.groups.lookup_secret) != null ? _c : []
1691
1704
  }
1692
1705
  ),
1693
- (_d = uniqueGroups.groups.default) == null ? void 0 : _d.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1706
+ (_d = groupedNodes.groups.default) == null ? void 0 : _d.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1694
1707
  ]
1695
1708
  }
1696
1709
  );
@@ -1699,11 +1712,11 @@ function SettingsSectionContent({ group, nodes }) {
1699
1712
  return /* @__PURE__ */ jsxs(
1700
1713
  OryFormSection,
1701
1714
  {
1702
- nodes: uniqueGroups.groups.oidc,
1715
+ nodes: groupedNodes.groups.oidc,
1703
1716
  "data-testid": "ory/screen/settings/group/oidc",
1704
1717
  children: [
1705
- /* @__PURE__ */ jsx(OrySettingsOidc, { nodes: (_e = uniqueGroups.groups.oidc) != null ? _e : [] }),
1706
- (_f = uniqueGroups.groups.default) == null ? void 0 : _f.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1718
+ /* @__PURE__ */ jsx(OrySettingsOidc, { nodes: (_e = groupedNodes.groups.oidc) != null ? _e : [] }),
1719
+ (_f = groupedNodes.groups.default) == null ? void 0 : _f.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1707
1720
  ]
1708
1721
  }
1709
1722
  );
@@ -1712,11 +1725,11 @@ function SettingsSectionContent({ group, nodes }) {
1712
1725
  return /* @__PURE__ */ jsxs(
1713
1726
  OryFormSection,
1714
1727
  {
1715
- nodes: uniqueGroups.groups.webauthn,
1728
+ nodes: groupedNodes.groups.webauthn,
1716
1729
  "data-testid": "ory/screen/settings/group/webauthn",
1717
1730
  children: [
1718
- /* @__PURE__ */ jsx(OrySettingsWebauthn, { nodes: (_g = uniqueGroups.groups.webauthn) != null ? _g : [] }),
1719
- (_h = uniqueGroups.groups.default) == null ? void 0 : _h.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1731
+ /* @__PURE__ */ jsx(OrySettingsWebauthn, { nodes: (_g = groupedNodes.groups.webauthn) != null ? _g : [] }),
1732
+ (_h = groupedNodes.groups.default) == null ? void 0 : _h.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1720
1733
  ]
1721
1734
  }
1722
1735
  );
@@ -1725,11 +1738,11 @@ function SettingsSectionContent({ group, nodes }) {
1725
1738
  return /* @__PURE__ */ jsxs(
1726
1739
  OryFormSection,
1727
1740
  {
1728
- nodes: uniqueGroups.groups.passkey,
1741
+ nodes: groupedNodes.groups.passkey,
1729
1742
  "data-testid": "ory/screen/settings/group/passkey",
1730
1743
  children: [
1731
- /* @__PURE__ */ jsx(OrySettingsPasskey, { nodes: (_i = uniqueGroups.groups.passkey) != null ? _i : [] }),
1732
- (_j = uniqueGroups.groups.default) == null ? void 0 : _j.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1744
+ /* @__PURE__ */ jsx(OrySettingsPasskey, { nodes: (_i = groupedNodes.groups.passkey) != null ? _i : [] }),
1745
+ (_j = groupedNodes.groups.default) == null ? void 0 : _j.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1733
1746
  ]
1734
1747
  }
1735
1748
  );
@@ -1750,7 +1763,7 @@ function SettingsSectionContent({ group, nodes }) {
1750
1763
  id: `settings.${group}.description`
1751
1764
  }),
1752
1765
  children: [
1753
- (_k = uniqueGroups.groups.default) == null ? void 0 : _k.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
1766
+ (_k = groupedNodes.groups.default) == null ? void 0 : _k.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
1754
1767
  nodes.filter(
1755
1768
  (node) => "type" in node.attributes && node.attributes.type !== "submit"
1756
1769
  ).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
@@ -1764,16 +1777,16 @@ function SettingsSectionContent({ group, nodes }) {
1764
1777
  }
1765
1778
  );
1766
1779
  }
1767
- var getScriptNode = (nodes) => nodes.find(
1768
- (node) => "id" in node.attributes && node.attributes.id === "webauthn_script"
1780
+ var onlyScriptNodes = (nodes) => nodes.filter(
1781
+ (node) => isUiNodeScriptAttributes(node.attributes) && node.attributes.id === "webauthn_script"
1769
1782
  );
1770
1783
  function OrySettingsCard() {
1771
1784
  const { flow } = useOryFlow();
1772
- const uniqueGroups = useNodesGroups(flow.ui.nodes);
1773
- const scriptNode = getScriptNode(flow.ui.nodes);
1785
+ const uniqueGroups = useNodesGroups(flow.ui.nodes, { omit: ["script"] });
1786
+ const scriptNodes = onlyScriptNodes(flow.ui.nodes);
1774
1787
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1775
1788
  /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1776
- scriptNode && /* @__PURE__ */ jsx(Node, { node: scriptNode }),
1789
+ scriptNodes.map((n) => /* @__PURE__ */ jsx(Node, { node: n })),
1777
1790
  uniqueGroups.entries.map(([group, nodes]) => {
1778
1791
  if (group === UiNodeGroupEnum.Default) {
1779
1792
  return null;
@@ -2299,7 +2312,7 @@ var de_default = {
2299
2312
  "two-step.code.description": "Ein Best\xE4tigungscode wird an Ihre E-Mail gesendet.",
2300
2313
  "two-step.code.title": "E-Mail-Code",
2301
2314
  "two-step.passkey.description": "Verwenden Sie die Fingerabdruck- oder Gesichtserkennung Ihres Ger\xE4ts",
2302
- "two-step.passkey.title": "Passwort (empfohlen)",
2315
+ "two-step.passkey.title": "Passkey (empfohlen)",
2303
2316
  "two-step.password.description": "Geben Sie Ihr Passwort ein, das mit Ihrem Konto verkn\xFCpft ist",
2304
2317
  "two-step.password.title": "Passwort",
2305
2318
  "two-step.webauthn.title": "Sicherheitsschl\xFCssel",