@ory/elements-react 1.0.0-next.23 → 1.0.0-next.24

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.
@@ -722,6 +722,7 @@ var provider_logos_default = logos;
722
722
 
723
723
  // src/theme/default/components/form/social.tsx
724
724
  import { useIntl as useIntl3 } from "react-intl";
725
+ import { useEffect, useState } from "react";
725
726
  import { useFormContext as useFormContext2 } from "react-hook-form";
726
727
 
727
728
  // src/theme/default/components/form/spinner.tsx
@@ -789,6 +790,7 @@ function DefaultButtonSocial({
789
790
  const {
790
791
  flow: { ui }
791
792
  } = useOryFlow5();
793
+ const [clicked, setClicked] = useState(false);
792
794
  const intl = useIntl3();
793
795
  const {
794
796
  formState: { isSubmitting }
@@ -797,19 +799,29 @@ function DefaultButtonSocial({
797
799
  const Logo = logos2[attributes.value];
798
800
  const showLabel = _showLabel != null ? _showLabel : oidcNodeCount % 3 !== 0 && oidcNodeCount % 4 !== 0;
799
801
  const provider = (_c = extractProvider((_b = node.meta.label) == null ? void 0 : _b.context)) != null ? _c : "";
802
+ const localOnClick = () => {
803
+ setClicked(true);
804
+ onClick == null ? void 0 : onClick();
805
+ };
806
+ useEffect(() => {
807
+ if (!isSubmitting) {
808
+ setClicked(false);
809
+ }
810
+ }, [isSubmitting]);
800
811
  return /* @__PURE__ */ jsxs19(
801
812
  "button",
802
813
  {
803
- className: "gap-3 border border-button-social-border-default bg-button-social-background-default hover:bg-button-social-background-hover transition-colors rounded flex items-center justify-center px-4 py-[13px] disabled:bg-button-social-background-disabled disabled:border-button-social-border-disabled disabled:text-button-social-foreground-disabled hover:text-button-social-foreground-disabled",
814
+ className: "gap-3 border border-button-social-border-default bg-button-social-background-default hover:bg-button-social-background-hover transition-colors rounded flex items-center justify-center px-4 py-[13px] loading:bg-button-social-background-disabled loading:border-button-social-border-disabled loading:text-button-social-foreground-disabled hover:text-button-social-foreground-hover",
804
815
  value: attributes.value,
805
816
  type: "submit",
806
817
  name: "provider",
807
818
  "data-testid": `ory/form/node/input/${attributes.name}`,
808
819
  ...props,
809
- onClick,
820
+ onClick: localOnClick,
821
+ "data-loading": clicked,
810
822
  disabled: isSubmitting,
811
823
  children: [
812
- /* @__PURE__ */ jsx25("span", { className: "size-5 relative", children: !isSubmitting ? Logo ? /* @__PURE__ */ jsx25(Logo, { size: 20 }) : /* @__PURE__ */ jsx25("span", { className: "flex aspect-square items-center justify-center rounded-full border text-xs", children: provider.slice(0, 2) }) : /* @__PURE__ */ jsx25(Spinner, { className: "size-5" }) }),
824
+ /* @__PURE__ */ jsx25("span", { className: "size-5 relative", children: !clicked ? Logo ? /* @__PURE__ */ jsx25(Logo, { size: 20 }) : /* @__PURE__ */ jsx25("span", { className: "flex aspect-square items-center justify-center rounded-full border text-xs", children: provider.slice(0, 2) }) : /* @__PURE__ */ jsx25(Spinner, { className: "size-5" }) }),
813
825
  showLabel && node.meta.label ? /* @__PURE__ */ jsx25("span", { className: "grow text-left font-medium leading-none text-button-social-foreground-default", children: uiTextToFormattedMessage(node.meta.label, intl) }) : null
814
826
  ]
815
827
  }
@@ -977,6 +989,7 @@ import {
977
989
  import { cva } from "class-variance-authority";
978
990
  import { useFormContext as useFormContext3 } from "react-hook-form";
979
991
  import { useIntl as useIntl6 } from "react-intl";
992
+ import { useEffect as useEffect2, useState as useState2 } from "react";
980
993
  import { jsx as jsx32, jsxs as jsxs21 } from "react/jsx-runtime";
981
994
  var buttonStyles = cva(
982
995
  [
@@ -1027,12 +1040,18 @@ var DefaultButton = ({
1027
1040
  // End of skipped attributes
1028
1041
  ...rest
1029
1042
  } = attributes;
1043
+ const [clicked, setClicked] = useState2(false);
1030
1044
  const intl = useIntl6();
1031
1045
  const label = getNodeLabel(node);
1032
1046
  const {
1033
1047
  formState: { isSubmitting },
1034
1048
  setValue
1035
1049
  } = useFormContext3();
1050
+ useEffect2(() => {
1051
+ if (!isSubmitting) {
1052
+ setClicked(false);
1053
+ }
1054
+ }, [isSubmitting]);
1036
1055
  const isPrimary = attributes.name === "method" || attributes.name.includes("passkey") || attributes.name.includes("webauthn") || attributes.name.includes("lookup_secret");
1037
1056
  return /* @__PURE__ */ jsxs21(
1038
1057
  "button",
@@ -1043,6 +1062,7 @@ var DefaultButton = ({
1043
1062
  type: type === "button" ? "button" : "submit",
1044
1063
  onClick: (e) => {
1045
1064
  onClick == null ? void 0 : onClick(e);
1065
+ setClicked(true);
1046
1066
  if (type !== "button") {
1047
1067
  setValue(name, value);
1048
1068
  }
@@ -1050,10 +1070,10 @@ var DefaultButton = ({
1050
1070
  className: buttonStyles({
1051
1071
  intent: isPrimary ? "primary" : "secondary"
1052
1072
  }),
1053
- disabled: (_a = rest.disabled) != null ? _a : true,
1054
- "data-loading": isSubmitting,
1073
+ disabled: (_a = rest.disabled) != null ? _a : isSubmitting,
1074
+ "data-loading": clicked,
1055
1075
  children: [
1056
- isSubmitting ? /* @__PURE__ */ jsx32(Spinner, {}) : null,
1076
+ clicked ? /* @__PURE__ */ jsx32(Spinner, {}) : null,
1057
1077
  label ? /* @__PURE__ */ jsx32("span", { children: uiTextToFormattedMessage3(label, intl) }) : ""
1058
1078
  ]
1059
1079
  }
@@ -1581,7 +1601,7 @@ import { useComponents as useComponents3 } from "@ory/elements-react";
1581
1601
 
1582
1602
  // src/theme/default/components/ui/user-menu.tsx
1583
1603
  import { DropdownMenuLabel as DropdownMenuLabel2 } from "@radix-ui/react-dropdown-menu";
1584
- import { useCallback, useEffect, useState } from "react";
1604
+ import { useCallback, useEffect as useEffect3, useState as useState3 } from "react";
1585
1605
  import { useOryFlow as useOryFlow10 } from "@ory/elements-react";
1586
1606
 
1587
1607
  // src/util/client.ts
@@ -1761,12 +1781,12 @@ import { jsx as jsx50, jsxs as jsxs28 } from "react/jsx-runtime";
1761
1781
  var UserMenu = ({ session }) => {
1762
1782
  const { config } = useOryFlow10();
1763
1783
  const initials = getUserInitials(session);
1764
- const [logoutFlow, setLogoutFlow] = useState();
1784
+ const [logoutFlow, setLogoutFlow] = useState3();
1765
1785
  const fetchLogoutFlow = useCallback(async () => {
1766
1786
  const flow = await frontendClient(config.sdk.url).createBrowserLogoutFlow();
1767
1787
  setLogoutFlow(flow);
1768
1788
  }, [config.sdk.url]);
1769
- useEffect(() => {
1789
+ useEffect3(() => {
1770
1790
  void fetchLogoutFlow();
1771
1791
  }, [fetchLogoutFlow]);
1772
1792
  return /* @__PURE__ */ jsxs28(DropdownMenu, { children: [