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

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
@@ -190,20 +190,28 @@ function nodesToAuthMethodGroups(nodes, excludeAuthMethods = []) {
190
190
  function useNodesGroups(nodes, { omit } = {}) {
191
191
  const groupSorter = useGroupSorter();
192
192
  const groups = useMemo(() => {
193
- var _a;
193
+ var _a, _b;
194
194
  const groups2 = {};
195
+ const groupRetained = {};
195
196
  for (const node of nodes) {
197
+ const groupNodes = (_a = groups2[node.group]) != null ? _a : [];
198
+ groupNodes.push(node);
199
+ groups2[node.group] = groupNodes;
196
200
  if ((omit == null ? void 0 : omit.includes("script")) && isUiNodeScriptAttributes(node.attributes)) {
197
201
  continue;
198
202
  }
199
203
  if ((omit == null ? void 0 : omit.includes("input_hidden")) && isUiNodeInputAttributes(node.attributes) && node.attributes.type === "hidden") {
200
204
  continue;
201
205
  }
202
- const groupNodes = (_a = groups2[node.group]) != null ? _a : [];
203
- groupNodes.push(node);
204
- groups2[node.group] = groupNodes;
206
+ groupRetained[node.group] = ((_b = groupRetained[node.group]) != null ? _b : 0) + 1;
207
+ }
208
+ const finalGroups = {};
209
+ for (const [group, count] of Object.entries(groupRetained)) {
210
+ if (count > 0) {
211
+ finalGroups[group] = groups2[group];
212
+ }
205
213
  }
206
- return groups2;
214
+ return finalGroups;
207
215
  }, [nodes, omit]);
208
216
  const entries = useMemo(
209
217
  () => Object.entries(groups).sort(([a], [b]) => groupSorter(a, b)),
@@ -1213,14 +1221,14 @@ function OryTwoStepCard() {
1213
1221
  (node) => node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml
1214
1222
  );
1215
1223
  const showSso = !(formState.current === "method_active" && !(formState.method === UiNodeGroupEnum.Oidc || formState.method === UiNodeGroupEnum.Saml));
1216
- const showSsoDivider = hasSso && nonSsoNodes.filter((n) => {
1224
+ const showSsoDivider = hasSso && nonSsoNodes.some((n) => {
1217
1225
  if (isUiNodeInputAttributes(n.attributes)) {
1218
1226
  return n.attributes.type !== UiNodeInputAttributesTypeEnum.Hidden;
1219
1227
  } else if (isUiNodeScriptAttributes(n.attributes)) {
1220
1228
  return false;
1221
1229
  }
1222
1230
  return true;
1223
- }).length > 0;
1231
+ });
1224
1232
  return /* @__PURE__ */ jsxs(OryCard, { children: [
1225
1233
  /* @__PURE__ */ jsx(OryCardHeader, {}),
1226
1234
  /* @__PURE__ */ jsxs(OryCardContent, { children: [
@@ -1237,22 +1245,24 @@ function OryTwoStepCard() {
1237
1245
  nonSsoNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1238
1246
  ] }),
1239
1247
  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
- ),
1248
+ Object.entries(authMethodBlocks).length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
1249
+ /* @__PURE__ */ jsx(Card.Divider, {}),
1250
+ /* @__PURE__ */ jsx(
1251
+ AuthMethodList,
1252
+ {
1253
+ options: authMethodBlocks,
1254
+ setSelectedGroup: (group) => dispatchFormState({
1255
+ type: "action_select_method",
1256
+ method: group
1257
+ })
1258
+ }
1259
+ )
1260
+ ] }),
1251
1261
  authMethodAdditionalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1252
1262
  ] }),
1253
1263
  formState.current === "method_active" && /* @__PURE__ */ jsxs(Form.Group, { children: [
1254
1264
  ui.nodes.filter(
1255
- (n) => isUiNodeScriptAttributes(n.attributes) || n.group === UiNodeGroupEnum.Captcha
1265
+ (n) => isUiNodeScriptAttributes(n.attributes) || n.group === UiNodeGroupEnum.Captcha || n.group === UiNodeGroupEnum.Default || n.group === UiNodeGroupEnum.Profile
1256
1266
  ).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
1257
1267
  finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1258
1268
  ] }),