@ory/elements-react 1.0.0-next.30 → 1.0.0-next.31

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
@@ -38,6 +38,9 @@ var defaultNodeOrder = [
38
38
  "default",
39
39
  "profile",
40
40
  "password",
41
+ // CAPTCHA is below password because otherwise the password input field
42
+ // would be above the captcha. Somehow, we sort the password sign up button somewhere else to be always at the bottom.
43
+ "captcha",
41
44
  "passkey",
42
45
  "code",
43
46
  "webauthn"
@@ -46,6 +49,11 @@ function defaultNodeSorter(a, b) {
46
49
  var _a, _b;
47
50
  const aGroupWeight = (_a = defaultNodeOrder.indexOf(a.group)) != null ? _a : 999;
48
51
  const bGroupWeight = (_b = defaultNodeOrder.indexOf(b.group)) != null ? _b : 999;
52
+ if (b.group === "captcha" && isUiNodeInputAttributes(a.attributes) && a.attributes.type === "submit") {
53
+ return aGroupWeight - (bGroupWeight - 2);
54
+ } else if (a.group === "captcha" && isUiNodeInputAttributes(b.attributes) && b.attributes.type === "submit") {
55
+ return aGroupWeight - 2 - bGroupWeight;
56
+ }
49
57
  return aGroupWeight - bGroupWeight;
50
58
  }
51
59
  var defaultGroupOrder = [
@@ -94,11 +102,12 @@ function filterOidcOut(nodes) {
94
102
  return nodes.filter((node) => node.group !== UiNodeGroupEnum.Oidc);
95
103
  }
96
104
  function getFinalNodes(uniqueGroups, selectedGroup) {
97
- var _a, _b, _c;
105
+ var _a, _b, _c, _d;
98
106
  const selectedNodes = selectedGroup ? (_a = uniqueGroups[selectedGroup]) != null ? _a : [] : [];
99
107
  return [
100
108
  ...(_b = uniqueGroups == null ? void 0 : uniqueGroups.identifier_first) != null ? _b : [],
101
- ...(_c = uniqueGroups == null ? void 0 : uniqueGroups.default) != null ? _c : []
109
+ ...(_c = uniqueGroups == null ? void 0 : uniqueGroups.default) != null ? _c : [],
110
+ ...(_d = uniqueGroups == null ? void 0 : uniqueGroups.captcha) != null ? _d : []
102
111
  ].flat().filter(
103
112
  (node) => "type" in node.attributes && node.attributes.type === "hidden"
104
113
  ).concat(selectedNodes);
@@ -170,6 +179,7 @@ function nodesToAuthMethodGroups(nodes, excludeAuthMethods = []) {
170
179
  UiNodeGroupEnum.Default,
171
180
  UiNodeGroupEnum.IdentifierFirst,
172
181
  UiNodeGroupEnum.Profile,
182
+ UiNodeGroupEnum.Captcha,
173
183
  ...excludeAuthMethods
174
184
  ].includes(group)
175
185
  );
@@ -950,6 +960,9 @@ var NodeInput = ({
950
960
  };
951
961
  var Node = ({ node, onClick }) => {
952
962
  const { Node: Node2 } = useComponents();
963
+ if (node.group === UiNodeGroupEnum.Captcha) {
964
+ return /* @__PURE__ */ jsx(Node2.Captcha, { node });
965
+ }
953
966
  if (isUiNodeImageAttributes(node.attributes)) {
954
967
  return /* @__PURE__ */ jsx(Node2.Image, { node, attributes: node.attributes });
955
968
  } else if (isUiNodeTextAttributes(node.attributes)) {
@@ -1035,7 +1048,8 @@ function OryTwoStepCard() {
1035
1048
  UiNodeGroupEnum.Oidc,
1036
1049
  UiNodeGroupEnum.Default,
1037
1050
  UiNodeGroupEnum.IdentifierFirst,
1038
- UiNodeGroupEnum.Profile
1051
+ UiNodeGroupEnum.Profile,
1052
+ UiNodeGroupEnum.Captcha
1039
1053
  ].includes(group)
1040
1054
  );
1041
1055
  const nonOidcNodes = filterOidcOut(ui.nodes);
@@ -1075,7 +1089,8 @@ function OryTwoStepCard() {
1075
1089
  method: group
1076
1090
  })
1077
1091
  }
1078
- )
1092
+ ),
1093
+ ui.nodes.filter((n) => n.group === UiNodeGroupEnum.Captcha).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1079
1094
  ] }),
1080
1095
  formState.current === "method_active" && /* @__PURE__ */ jsxs(Fragment, { children: [
1081
1096
  ui.nodes.filter((n) => n.type === "script").map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),