Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+58
-1
@@ -1,4 +1,11 @@
|
||||
"use client";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import { SaveToast } from "~/components/notifications/SaveToast";
|
||||
import { COPY_TOAST_DURATION_MS } from "~/hooks/use-copy-toast";
|
||||
|
||||
import { CopyToClipboardButton as CopyToClipboardButtonComponent } from "./CopyToClipboardButton";
|
||||
|
||||
/**
|
||||
@@ -7,4 +14,54 @@ import { CopyToClipboardButton as CopyToClipboardButtonComponent } from "./CopyT
|
||||
* Learn more: https://docs.subframe.com/concepts/syncing-components#wrapping-components
|
||||
*/
|
||||
|
||||
export const CopyToClipboardButton = CopyToClipboardButtonComponent;
|
||||
type GeneratedProps = React.ComponentProps<typeof CopyToClipboardButtonComponent>;
|
||||
|
||||
export type CopyToClipboardButtonProps = Omit<GeneratedProps, "onCopy"> & {
|
||||
successKey?: string;
|
||||
errorKey?: string;
|
||||
onCopy?: (copied: boolean) => void;
|
||||
};
|
||||
|
||||
export const CopyToClipboardButton = React.forwardRef<HTMLDivElement, CopyToClipboardButtonProps>(function CopyToClipboardButton(
|
||||
{ successKey, errorKey, onCopy, ...props },
|
||||
ref
|
||||
) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<CopyToClipboardButtonComponent
|
||||
{...props}
|
||||
ref={ref}
|
||||
onCopy={(copied) => {
|
||||
onCopy?.(copied);
|
||||
if (copied) {
|
||||
toast.custom(
|
||||
() => (
|
||||
<SaveToast
|
||||
variant="success"
|
||||
title={t(successKey ?? "shared.copyToast.successTitle", {
|
||||
defaultValue: t("shared.copyToast.successTitle"),
|
||||
})}
|
||||
/>
|
||||
),
|
||||
{ duration: COPY_TOAST_DURATION_MS }
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
toast.custom(
|
||||
() => (
|
||||
<SaveToast
|
||||
variant="error"
|
||||
title={t("shared.copyToast.errorTitle")}
|
||||
description={t(errorKey ?? "shared.copyToast.errorDescription", {
|
||||
defaultValue: t("shared.copyToast.errorDescription"),
|
||||
})}
|
||||
/>
|
||||
),
|
||||
{ duration: COPY_TOAST_DURATION_MS }
|
||||
);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user