@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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 1.0.0-next.45 (2025-04-15)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - add missing test id to scope checkbox label ([#437](https://github.com/ory/elements/pull/437))
6
+ - add missing captcha group to all methods ([#432](https://github.com/ory/elements/pull/432))
7
+
8
+ ### ❤️ Thank You
9
+
10
+ - hackerman @aeneasr
11
+ - Jonas Hungershausen
12
+
1
13
  ## 1.0.0-next.44 (2025-04-10)
2
14
 
3
15
  ### 🩹 Fixes
package/dist/index.d.mts CHANGED
@@ -53,6 +53,7 @@ type OryNodeImageProps = {
53
53
  type FormValues = Record<string, string | boolean | number | undefined>;
54
54
  type OryFormRootProps = ComponentPropsWithoutRef<"form"> & {
55
55
  onSubmit: FormEventHandler<HTMLFormElement>;
56
+ "data-testid"?: string;
56
57
  };
57
58
  type OryNodeInputProps = {
58
59
  attributes: UiNodeInputAttributes;
@@ -374,8 +375,9 @@ type DeepPartialTwoLevels<T> = {
374
375
  type OryFlowComponentOverrides = DeepPartialTwoLevels<OryFlowComponents>;
375
376
  type OryFormProps = PropsWithChildren<{
376
377
  onAfterSubmit?: (method: string | number | boolean | undefined) => void;
378
+ "data-testid"?: string;
377
379
  }>;
378
- declare function OryForm({ children, onAfterSubmit }: OryFormProps): react_jsx_runtime.JSX.Element;
380
+ declare function OryForm({ children, onAfterSubmit, "data-testid": dataTestId, }: OryFormProps): react_jsx_runtime.JSX.Element;
379
381
 
380
382
  declare function useComponents(): OryFlowComponents;
381
383
  declare function useNodeSorter(): (a: UiNode, b: UiNode, ctx: {
package/dist/index.d.ts CHANGED
@@ -53,6 +53,7 @@ type OryNodeImageProps = {
53
53
  type FormValues = Record<string, string | boolean | number | undefined>;
54
54
  type OryFormRootProps = ComponentPropsWithoutRef<"form"> & {
55
55
  onSubmit: FormEventHandler<HTMLFormElement>;
56
+ "data-testid"?: string;
56
57
  };
57
58
  type OryNodeInputProps = {
58
59
  attributes: UiNodeInputAttributes;
@@ -374,8 +375,9 @@ type DeepPartialTwoLevels<T> = {
374
375
  type OryFlowComponentOverrides = DeepPartialTwoLevels<OryFlowComponents>;
375
376
  type OryFormProps = PropsWithChildren<{
376
377
  onAfterSubmit?: (method: string | number | boolean | undefined) => void;
378
+ "data-testid"?: string;
377
379
  }>;
378
- declare function OryForm({ children, onAfterSubmit }: OryFormProps): react_jsx_runtime.JSX.Element;
380
+ declare function OryForm({ children, onAfterSubmit, "data-testid": dataTestId, }: OryFormProps): react_jsx_runtime.JSX.Element;
379
381
 
380
382
  declare function useComponents(): OryFlowComponents;
381
383
  declare function useNodeSorter(): (a: UiNode, b: UiNode, ctx: {
package/dist/index.js CHANGED
@@ -206,7 +206,7 @@ function useNodesGroups(nodes, { omit } = {}) {
206
206
  groups2[node.group] = groupNodes;
207
207
  }
208
208
  return groups2;
209
- }, [nodes]);
209
+ }, [nodes, omit]);
210
210
  const entries = react.useMemo(
211
211
  () => Object.entries(groups).sort(([a], [b]) => groupSorter(a, b)),
212
212
  [groups, groupSorter]
@@ -873,7 +873,11 @@ function useOryFormSubmit(onAfterSubmit) {
873
873
  };
874
874
  return onSubmit;
875
875
  }
876
- function OryForm({ children, onAfterSubmit }) {
876
+ function OryForm({
877
+ children,
878
+ onAfterSubmit,
879
+ "data-testid": dataTestId
880
+ }) {
877
881
  const { Form } = useComponents();
878
882
  const flowContainer = useOryFlow();
879
883
  const methods = reactHookForm.useFormContext();
@@ -901,7 +905,7 @@ function OryForm({ children, onAfterSubmit }) {
901
905
  }),
902
906
  type: "error"
903
907
  };
904
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
908
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-8", "data-testid": dataTestId, children: [
905
909
  /* @__PURE__ */ jsxRuntime.jsx(Message.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(Message.Content, { message: m }, m.id) }),
906
910
  /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
907
911
  ] });
@@ -912,6 +916,7 @@ function OryForm({ children, onAfterSubmit }) {
912
916
  return /* @__PURE__ */ jsxRuntime.jsx(
913
917
  Form.Root,
914
918
  {
919
+ "data-testid": dataTestId,
915
920
  action: flowContainer.flow.ui.action,
916
921
  method: flowContainer.flow.ui.method,
917
922
  onSubmit: (e) => void methods.handleSubmit(onSubmit)(e),
@@ -1132,7 +1137,7 @@ function OryFormSocialButtonsForm() {
1132
1137
  if (filteredNodes.length === 0) {
1133
1138
  return null;
1134
1139
  }
1135
- return /* @__PURE__ */ jsxRuntime.jsx(OryFormProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(OryForm, { children: /* @__PURE__ */ jsxRuntime.jsx(OryFormOidcButtons, {}) }) });
1140
+ return /* @__PURE__ */ jsxRuntime.jsx(OryFormProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(OryForm, { "data-testid": `ory/form/methods/oidc-saml`, children: /* @__PURE__ */ jsxRuntime.jsx(OryFormOidcButtons, {}) }) });
1136
1141
  }
1137
1142
  function isUINodeGroupEnum(method) {
1138
1143
  return Object.values(clientFetch.UiNodeGroupEnum).includes(method);
@@ -1148,7 +1153,7 @@ function OryTwoStepCard() {
1148
1153
  // We only want to render groups that have visible elements.
1149
1154
  omit: ["script", "input_hidden"]
1150
1155
  });
1151
- const options = Object.fromEntries(
1156
+ const authMethodBlocks = Object.fromEntries(
1152
1157
  Object.values(clientFetch.UiNodeGroupEnum).filter((group) => {
1153
1158
  var _a2;
1154
1159
  return (_a2 = groupsToShow.groups[group]) == null ? void 0 : _a2.length;
@@ -1163,7 +1168,17 @@ function OryTwoStepCard() {
1163
1168
  ].includes(group)
1164
1169
  ).map((g) => [g, {}])
1165
1170
  );
1166
- if (clientFetch.UiNodeGroupEnum.Code in options) {
1171
+ const authMethodAdditionalNodes = ui.nodes.filter(
1172
+ ({ group }) => [
1173
+ clientFetch.UiNodeGroupEnum.Oidc,
1174
+ clientFetch.UiNodeGroupEnum.Saml,
1175
+ clientFetch.UiNodeGroupEnum.Default,
1176
+ clientFetch.UiNodeGroupEnum.IdentifierFirst,
1177
+ clientFetch.UiNodeGroupEnum.Profile,
1178
+ clientFetch.UiNodeGroupEnum.Captcha
1179
+ ].includes(group)
1180
+ );
1181
+ if (clientFetch.UiNodeGroupEnum.Code in authMethodBlocks) {
1167
1182
  let identifier = (_b = (_a = findNode(ui.nodes, {
1168
1183
  group: "identifier_first",
1169
1184
  node_type: "input",
@@ -1175,7 +1190,7 @@ function OryTwoStepCard() {
1175
1190
  name: "address"
1176
1191
  })) == null ? void 0 : _c.attributes) == null ? void 0 : _d.value);
1177
1192
  if (identifier) {
1178
- options[clientFetch.UiNodeGroupEnum.Code] = {
1193
+ authMethodBlocks[clientFetch.UiNodeGroupEnum.Code] = {
1179
1194
  title: {
1180
1195
  id: "identities.messages.1010023",
1181
1196
  values: { address: identifier }
@@ -1208,39 +1223,45 @@ function OryTwoStepCard() {
1208
1223
  }
1209
1224
  return true;
1210
1225
  }).length > 0;
1211
- const captchaNodes = ui.nodes.filter(
1212
- (n) => n.group === clientFetch.UiNodeGroupEnum.Captcha
1213
- );
1214
1226
  return /* @__PURE__ */ jsxRuntime.jsxs(OryCard, { children: [
1215
1227
  /* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
1216
1228
  /* @__PURE__ */ jsxRuntime.jsxs(OryCardContent, { children: [
1217
1229
  /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
1218
1230
  showSso && /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
1219
- /* @__PURE__ */ jsxRuntime.jsxs(OryForm, { onAfterSubmit: handleAfterFormSubmit, children: [
1220
- formState.current === "provide_identifier" && /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1221
- showSsoDivider && /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1222
- nonSsoNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1223
- ] }),
1224
- formState.current === "select_method" && /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1225
- Object.entries(options).length > 0 && /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1226
- Object.entries(options).length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1227
- AuthMethodList,
1228
- {
1229
- options,
1230
- setSelectedGroup: (group) => dispatchFormState({
1231
- type: "action_select_method",
1232
- method: group
1233
- })
1234
- }
1235
- ),
1236
- captchaNodes.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1237
- ] }),
1238
- formState.current === "method_active" && /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1239
- ui.nodes.filter((n) => n.type === "script").map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)),
1240
- finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1241
- ] }),
1242
- /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1243
- ] })
1231
+ /* @__PURE__ */ jsxRuntime.jsxs(
1232
+ OryForm,
1233
+ {
1234
+ "data-testid": `ory/form/methods/local`,
1235
+ onAfterSubmit: handleAfterFormSubmit,
1236
+ children: [
1237
+ formState.current === "provide_identifier" && /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1238
+ showSsoDivider && /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1239
+ nonSsoNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1240
+ ] }),
1241
+ formState.current === "select_method" && /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1242
+ Object.entries(authMethodBlocks).length > 0 && /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1243
+ Object.entries(authMethodBlocks).length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1244
+ AuthMethodList,
1245
+ {
1246
+ options: authMethodBlocks,
1247
+ setSelectedGroup: (group) => dispatchFormState({
1248
+ type: "action_select_method",
1249
+ method: group
1250
+ })
1251
+ }
1252
+ ),
1253
+ authMethodAdditionalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1254
+ ] }),
1255
+ formState.current === "method_active" && /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1256
+ ui.nodes.filter(
1257
+ (n) => clientFetch.isUiNodeScriptAttributes(n.attributes) || n.group === clientFetch.UiNodeGroupEnum.Captcha
1258
+ ).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)),
1259
+ finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1260
+ ] }),
1261
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1262
+ ]
1263
+ }
1264
+ )
1244
1265
  ] })
1245
1266
  ] });
1246
1267
  }