@ory/elements-react 1.0.0-next.15 → 1.0.0-next.16

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.
@@ -383,26 +383,32 @@ function DefaultCurrentIdentifierButton() {
383
383
  "autocomplete",
384
384
  "node_type"
385
385
  ]);
386
- return /* @__PURE__ */ jsx6("div", { children: /* @__PURE__ */ jsxs5(
386
+ return /* @__PURE__ */ jsxs5(
387
387
  "a",
388
388
  {
389
- className: "cursor-pointer py-[5px] px-3 rounded-full border border-button-identifier-border-default bg-button-identifier-bg-default hover:border-button-identifier-border-hover hover:bg-button-identifier-bg-hover transition-colors inline-flex gap-1 items-center",
389
+ className: "cursor-pointer py-[5px] px-3 rounded-full border border-button-identifier-border-default bg-button-identifier-bg-default hover:border-button-identifier-border-hover hover:bg-button-identifier-bg-hover transition-colors inline-flex gap-1 items-center self-start max-w-full",
390
390
  ...attributes,
391
391
  href: initFlowUrl,
392
392
  title: `Adjust ${nodeBackButton == null ? void 0 : nodeBackButton.attributes.value}`,
393
393
  children: [
394
- /* @__PURE__ */ jsx6(arrow_left_default, { size: 16, className: "text-button-identifier-fg-subtle" }),
394
+ /* @__PURE__ */ jsx6(
395
+ arrow_left_default,
396
+ {
397
+ size: 16,
398
+ className: "text-button-identifier-fg-subtle shrink-0"
399
+ }
400
+ ),
395
401
  /* @__PURE__ */ jsx6("span", { className: "text-sm font-medium text-button-identifier-fg-default text-ellipsis overflow-hidden text-nowrap", children: nodeBackButton == null ? void 0 : nodeBackButton.attributes.value })
396
402
  ]
397
403
  }
398
- ) });
404
+ );
399
405
  }
400
406
  function getBackButtonNode(flowType, nodes) {
401
407
  let nodeBackButton;
402
408
  switch (flowType) {
403
409
  case FlowType3.Login:
404
410
  nodeBackButton = nodes.find(
405
- (node) => "name" in node.attributes && node.attributes.name === "identifier" && node.group === "identifier_first"
411
+ (node) => "name" in node.attributes && node.attributes.name === "identifier" && ["default", "identifier_first"].includes(node.group)
406
412
  );
407
413
  break;
408
414
  case FlowType3.Registration:
@@ -480,6 +486,7 @@ function cn(...inputs) {
480
486
  // src/theme/default/components/form/index.tsx
481
487
  import { useIntl as useIntl3 } from "react-intl";
482
488
  import {
489
+ messageTestId,
483
490
  uiTextToFormattedMessage,
484
491
  useOryFlow as useOryFlow5
485
492
  } from "@ory/elements-react";
@@ -523,11 +530,12 @@ function DefaultMessage({ message }) {
523
530
  return /* @__PURE__ */ jsx10(
524
531
  "span",
525
532
  {
526
- className: cn("text-sm mt-1 leading-normal", {
533
+ className: cn("text-sm leading-normal", {
527
534
  "text-forms-fg-error": message.type === "error",
528
535
  "text-forms-fg-default": message.type === "info",
529
536
  "text-forms-fg-success": message.type === "success"
530
537
  }),
538
+ ...messageTestId(message),
531
539
  children: uiTextToFormattedMessage(message, intl)
532
540
  }
533
541
  );
@@ -597,6 +605,9 @@ function DefaultAuthMethodListItem({
597
605
  className: "flex text-left py-2 gap-3 cursor-pointer",
598
606
  onClick,
599
607
  type: isGroupImmediateSubmit(group) ? "submit" : "button",
608
+ id: `auth-method-list-item-${group}`,
609
+ "data-testid": "auth-method-list-item",
610
+ "aria-label": `Authenticate with ${group}`,
600
611
  children: [
601
612
  /* @__PURE__ */ jsx15("div", { className: "flex-none w-4 h-4 mt-[2px]", children: Icon && /* @__PURE__ */ jsx15(Icon, { size: 20, className: "text-forms-fg-default" }) }),
602
613
  /* @__PURE__ */ jsxs8("div", { className: "flex-1 text-sm leading-normal", children: [
@@ -754,7 +765,7 @@ DefaultButton.displayName = "DefaultButton";
754
765
  // src/theme/default/components/form/checkbox.tsx
755
766
  import { getNodeLabel as getNodeLabel2 } from "@ory/client-fetch";
756
767
  import {
757
- messageTestId,
768
+ messageTestId as messageTestId2,
758
769
  uiTextToFormattedMessage as uiTextToFormattedMessage4
759
770
  } from "@ory/elements-react";
760
771
  import { useState } from "react";
@@ -940,7 +951,7 @@ var DefaultCheckbox = ({
940
951
  "span",
941
952
  {
942
953
  className: "text-sm text-red-900 mt-1",
943
- ...messageTestId(message),
954
+ ...messageTestId2(message),
944
955
  children: uiTextToFormattedMessage4(message, intl)
945
956
  },
946
957
  message.id
@@ -1026,12 +1037,19 @@ var DefaultInput = ({
1026
1037
  // src/theme/default/components/form/label.tsx
1027
1038
  import { FlowType as FlowType7, getNodeLabel as getNodeLabel4 } from "@ory/client-fetch";
1028
1039
  import {
1029
- messageTestId as messageTestId2,
1040
+ messageTestId as messageTestId3,
1030
1041
  uiTextToFormattedMessage as uiTextToFormattedMessage6,
1042
+ useComponents as useComponents2,
1031
1043
  useOryFlow as useOryFlow8
1032
1044
  } from "@ory/elements-react";
1045
+ import { useFormContext as useFormContext4 } from "react-hook-form";
1033
1046
  import { useIntl as useIntl9 } from "react-intl";
1034
1047
  import { jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
1048
+ function findResendNode(nodes) {
1049
+ return nodes.find(
1050
+ (n) => "name" in n.attributes && (n.attributes.name === "email" && n.attributes.type === "submit" || n.attributes.name === "resend")
1051
+ );
1052
+ }
1035
1053
  function DefaultLabel({
1036
1054
  node,
1037
1055
  children,
@@ -1040,17 +1058,22 @@ function DefaultLabel({
1040
1058
  }) {
1041
1059
  const intl = useIntl9();
1042
1060
  const label = getNodeLabel4(node);
1061
+ const { Message } = useComponents2();
1043
1062
  const { config, flowType, flow } = useOryFlow8();
1063
+ const { setValue } = useFormContext4();
1044
1064
  const isPassword = attributes.type === "password";
1045
- const hasResendNode = flow.ui.nodes.some(
1046
- (n) => "name" in n.attributes && n.attributes.name === "email" && n.attributes.type === "submit"
1047
- );
1065
+ const resendNode = findResendNode(flow.ui.nodes);
1066
+ const handleResend = () => {
1067
+ if ((resendNode == null ? void 0 : resendNode.attributes) && "name" in resendNode.attributes) {
1068
+ setValue(resendNode.attributes.name, resendNode.attributes.value);
1069
+ }
1070
+ };
1048
1071
  return /* @__PURE__ */ jsxs12("div", { className: "flex flex-col antialiased gap-1", children: [
1049
1072
  label && /* @__PURE__ */ jsxs12("span", { className: "inline-flex justify-between", children: [
1050
1073
  /* @__PURE__ */ jsx24(
1051
1074
  "label",
1052
1075
  {
1053
- ...messageTestId2(label),
1076
+ ...messageTestId3(label),
1054
1077
  className: "text-sm font-medium leading-normal",
1055
1078
  htmlFor: attributes.name,
1056
1079
  ...rest,
@@ -1069,31 +1092,20 @@ function DefaultLabel({
1069
1092
  })
1070
1093
  }
1071
1094
  ),
1072
- hasResendNode && /* @__PURE__ */ jsx24(
1095
+ (resendNode == null ? void 0 : resendNode.attributes.node_type) === "input" && /* @__PURE__ */ jsx24(
1073
1096
  "button",
1074
1097
  {
1075
1098
  type: "submit",
1076
- name: "method",
1077
- value: "code",
1099
+ name: resendNode.attributes.name,
1100
+ value: resendNode.attributes.value,
1101
+ onClick: handleResend,
1078
1102
  className: "text-links-link-default hover:underline hover:text-link-hover transition-colors text-sm font-medium cursor-pointer",
1079
1103
  children: intl.formatMessage({ id: "identities.messages.1070008" })
1080
1104
  }
1081
1105
  )
1082
1106
  ] }),
1083
1107
  children,
1084
- node.messages.map((message) => /* @__PURE__ */ jsx24(
1085
- "span",
1086
- {
1087
- className: cn("text-sm leading-normal", {
1088
- "text-forms-fg-error": message.type === "error",
1089
- "text-forms-fg-default": message.type === "info",
1090
- "text-forms-fg-success": message.type === "success"
1091
- }),
1092
- ...messageTestId2(message),
1093
- children: uiTextToFormattedMessage6(message, intl)
1094
- },
1095
- message.id
1096
- ))
1108
+ node.messages.map((message) => /* @__PURE__ */ jsx24(Message.Content, { message }, message.id))
1097
1109
  ] });
1098
1110
  }
1099
1111
 
@@ -1124,7 +1136,7 @@ var DefaultLinkButton = forwardRef(({ attributes, node }, ref) => {
1124
1136
  DefaultLinkButton.displayName = "DefaultLinkButton";
1125
1137
 
1126
1138
  // src/theme/default/components/form/pin-code-input.tsx
1127
- import { useFormContext as useFormContext4 } from "react-hook-form";
1139
+ import { useFormContext as useFormContext5 } from "react-hook-form";
1128
1140
 
1129
1141
  // src/theme/default/components/form/shadcn/otp-input.tsx
1130
1142
  import { OTPInput, OTPInputContext } from "input-otp";
@@ -1170,7 +1182,7 @@ InputOTPSlot.displayName = "InputOTPSlot";
1170
1182
  // src/theme/default/components/form/pin-code-input.tsx
1171
1183
  import { jsx as jsx27 } from "react/jsx-runtime";
1172
1184
  var DefaultPinCodeInput = ({ attributes }) => {
1173
- const { setValue, watch } = useFormContext4();
1185
+ const { setValue, watch } = useFormContext5();
1174
1186
  const { maxlength, name } = attributes;
1175
1187
  const elements = maxlength != null ? maxlength : 6;
1176
1188
  const handleInputChange = (v) => {
@@ -1491,7 +1503,7 @@ function DefaultText({ node, attributes }) {
1491
1503
  }
1492
1504
 
1493
1505
  // src/theme/default/components/generic/page-header.tsx
1494
- import { useComponents as useComponents2 } from "@ory/elements-react";
1506
+ import { useComponents as useComponents3 } from "@ory/elements-react";
1495
1507
 
1496
1508
  // src/theme/default/components/ui/user-menu.tsx
1497
1509
  import { DropdownMenuLabel as DropdownMenuLabel2 } from "@radix-ui/react-dropdown-menu";
@@ -1700,7 +1712,7 @@ var UserMenu = ({ session }) => {
1700
1712
  import { useSession } from "@ory/elements-react/client";
1701
1713
  import { jsx as jsx50, jsxs as jsxs30 } from "react/jsx-runtime";
1702
1714
  var DefaultPageHeader = (_props) => {
1703
- const { Card } = useComponents2();
1715
+ const { Card } = useComponents3();
1704
1716
  const { session } = useSession();
1705
1717
  return /* @__PURE__ */ jsx50("div", { className: "flex max-w-[896px] flex-col w-full gap-3 mt-16", children: /* @__PURE__ */ jsx50("div", { className: "flex flex-col gap-12", children: /* @__PURE__ */ jsxs30("div", { className: "flex gap-2 max-h-10 justify-between flex-1", children: [
1706
1718
  /* @__PURE__ */ jsx50("div", { className: "h-10 flex-1 relative", children: /* @__PURE__ */ jsx50(Card.Logo, {}) }),
@@ -1718,7 +1730,7 @@ var SvgTrash = (props) => {
1718
1730
  var trash_default = SvgTrash;
1719
1731
 
1720
1732
  // src/theme/default/components/settings/settings-oidc.tsx
1721
- import { useFormContext as useFormContext5 } from "react-hook-form";
1733
+ import { useFormContext as useFormContext6 } from "react-hook-form";
1722
1734
  import { jsx as jsx52, jsxs as jsxs31 } from "react/jsx-runtime";
1723
1735
  function DefaultSettingsOidc({
1724
1736
  linkButtons,
@@ -1726,7 +1738,7 @@ function DefaultSettingsOidc({
1726
1738
  }) {
1727
1739
  const hasLinkButtons = linkButtons.length > 0;
1728
1740
  const hasUnlinkButtons = unlinkButtons.length > 0;
1729
- const { setValue } = useFormContext5();
1741
+ const { setValue } = useFormContext6();
1730
1742
  return /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-8", children: [
1731
1743
  hasLinkButtons && /* @__PURE__ */ jsx52("div", { className: "flex gap-3 items-start [&>button]:w-[79px]", children: linkButtons.map((button) => {
1732
1744
  const attrs = button.attributes;