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

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.
@@ -1834,6 +1834,7 @@ var trash_default = SvgTrash;
1834
1834
 
1835
1835
  // src/theme/default/components/settings/settings-oidc.tsx
1836
1836
  import { useFormContext as useFormContext7 } from "react-hook-form";
1837
+ import { useEffect as useEffect4, useState as useState4 } from "react";
1837
1838
  import { jsx as jsx53, jsxs as jsxs30 } from "react/jsx-runtime";
1838
1839
  function DefaultSettingsOidc({
1839
1840
  linkButtons,
@@ -1841,9 +1842,6 @@ function DefaultSettingsOidc({
1841
1842
  }) {
1842
1843
  const hasLinkButtons = linkButtons.length > 0;
1843
1844
  const hasUnlinkButtons = unlinkButtons.length > 0;
1844
- const {
1845
- formState: { isSubmitting }
1846
- } = useFormContext7();
1847
1845
  return /* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-8", children: [
1848
1846
  hasLinkButtons && /* @__PURE__ */ jsx53("div", { className: "grid items-start gap-3 grid-cols-1 sm:grid-cols-2 md:grid-cols-3", children: linkButtons.map((button) => {
1849
1847
  const attrs = button.attributes;
@@ -1860,36 +1858,55 @@ function DefaultSettingsOidc({
1860
1858
  }) }),
1861
1859
  hasUnlinkButtons && hasLinkButtons ? /* @__PURE__ */ jsx53(DefaultHorizontalDivider, {}) : null,
1862
1860
  unlinkButtons.map((button) => {
1863
- var _a, _b;
1864
- const attrs = button.attributes;
1865
- const provider = (_b = extractProvider((_a = button.meta.label) == null ? void 0 : _a.context)) != null ? _b : "";
1866
- const Logo = attrs.value in provider_logos_default ? provider_logos_default[attrs.value] : provider_logos_default.generic;
1867
- return /* @__PURE__ */ jsxs30("div", { className: "flex justify-between", children: [
1868
- /* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-6", children: [
1869
- /* @__PURE__ */ jsx53(Logo, { size: 32 }),
1870
- /* @__PURE__ */ jsx53("p", { className: "text-sm font-medium text-interface-foreground-default-secondary", children: provider })
1871
- ] }),
1872
- /* @__PURE__ */ jsx53(
1873
- "button",
1861
+ if (button.attributes.node_type !== "input") {
1862
+ return null;
1863
+ }
1864
+ return /* @__PURE__ */ jsx53(UnlinkRow, { button }, button.attributes.value);
1865
+ })
1866
+ ] });
1867
+ }
1868
+ function UnlinkRow({ button }) {
1869
+ var _a, _b;
1870
+ const [clicked, setClicked] = useState4(false);
1871
+ const {
1872
+ formState: { isSubmitting }
1873
+ } = useFormContext7();
1874
+ const attrs = button.attributes;
1875
+ const provider = (_b = extractProvider((_a = button.meta.label) == null ? void 0 : _a.context)) != null ? _b : "";
1876
+ const Logo = attrs.value in provider_logos_default ? provider_logos_default[attrs.value] : provider_logos_default.generic;
1877
+ const localOnClick = () => {
1878
+ setClicked(true);
1879
+ button.onClick();
1880
+ };
1881
+ useEffect4(() => {
1882
+ if (!isSubmitting) {
1883
+ setClicked(false);
1884
+ }
1885
+ }, [isSubmitting]);
1886
+ return /* @__PURE__ */ jsxs30("div", { className: "flex justify-between", children: [
1887
+ /* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-6", children: [
1888
+ /* @__PURE__ */ jsx53(Logo, { size: 32 }),
1889
+ /* @__PURE__ */ jsx53("p", { className: "text-sm font-medium text-interface-foreground-default-secondary", children: provider })
1890
+ ] }),
1891
+ /* @__PURE__ */ jsx53(
1892
+ "button",
1893
+ {
1894
+ ...attrs,
1895
+ type: "submit",
1896
+ onClick: localOnClick,
1897
+ disabled: isSubmitting,
1898
+ className: "relative",
1899
+ title: `Unlink ${provider}`,
1900
+ children: clicked ? /* @__PURE__ */ jsx53(Spinner, { className: "relative" }) : /* @__PURE__ */ jsx53(
1901
+ trash_default,
1874
1902
  {
1875
- ...attrs,
1876
- type: "submit",
1877
- onClick: button.onClick,
1878
- disabled: isSubmitting,
1879
- className: "relative",
1880
- title: `Unlink ${provider}`,
1881
- children: isSubmitting ? /* @__PURE__ */ jsx53(Spinner, { className: "relative" }) : /* @__PURE__ */ jsx53(
1882
- trash_default,
1883
- {
1884
- className: "text-button-link-default-secondary hover:text-button-link-default-secondary-hover",
1885
- size: 24
1886
- }
1887
- )
1903
+ className: "text-button-link-default-secondary hover:text-button-link-default-secondary-hover",
1904
+ size: 24
1888
1905
  }
1889
1906
  )
1890
- ] }, attrs.value);
1891
- })
1892
- ] });
1907
+ }
1908
+ )
1909
+ ] }, attrs.value);
1893
1910
  }
1894
1911
 
1895
1912
  // src/theme/default/components/settings/settings-passkey.tsx