Files
klz-cables.com/.pnpm-store/v10/files/07/542a428b5bb01555f9be820de985e11162a0f366ee4223e8102219343023a477610d2068fd6586a9327d40b5fff83d365e50148a1472a028b284a6bf5ed02d
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

98 lines
2.6 KiB
Plaintext

'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useCallback } from 'react';
import { toast } from 'sonner';
import { MoreIcon } from '../../icons/More/index.js';
import { useTranslation } from '../../providers/Translation/index.js';
import { Popup, PopupList } from '../Popup/index.js';
import { ClipboardActionLabel } from './ClipboardActionLabel.js';
import { clipboardCopy, clipboardPaste } from './clipboardUtilities.js';
const baseClass = 'clipboard-action';
/**
* Menu actions for copying and pasting fields. Currently, this is only used in Arrays and Blocks.
* @note This component doesn't use the Clipboard API, but localStorage. See rationale in #11513
*/
export const ClipboardAction = ({
allowCopy,
allowPaste,
className,
copyClassName,
disabled,
isRow,
onPaste,
pasteClassName,
path,
...rest
}) => {
const {
t
} = useTranslation();
const classes = [`${baseClass}__popup`, className].filter(Boolean).join(' ');
const handleCopy = useCallback(() => {
const clipboardResult = clipboardCopy({
path,
t,
...rest
});
if (typeof clipboardResult === 'string') {
toast.error(clipboardResult);
} else {
toast.success(t('general:copied'));
}
}, [t, rest, path]);
const handlePaste = useCallback(() => {
const clipboardResult_0 = clipboardPaste(rest.type === 'array' ? {
onPaste,
path,
schemaFields: rest.fields,
t
} : {
onPaste,
path,
schemaBlocks: rest.blocks,
t
});
if (typeof clipboardResult_0 === 'string') {
toast.error(clipboardResult_0);
}
}, [onPaste, rest, path, t]);
if (!allowPaste && !allowCopy) {
return null;
}
return /*#__PURE__*/_jsx(Popup, {
button: /*#__PURE__*/_jsx(MoreIcon, {}),
className: classes,
disabled: disabled,
horizontalAlign: "center",
render: ({
close
}) => /*#__PURE__*/_jsxs(PopupList.ButtonGroup, {
children: [/*#__PURE__*/_jsx(PopupList.Button, {
className: copyClassName,
disabled: !allowCopy,
onClick: () => {
void handleCopy();
close();
},
children: /*#__PURE__*/_jsx(ClipboardActionLabel, {
isRow: isRow
})
}), /*#__PURE__*/_jsx(PopupList.Button, {
className: pasteClassName,
disabled: !allowPaste,
onClick: () => {
void handlePaste();
close();
},
children: /*#__PURE__*/_jsx(ClipboardActionLabel, {
isPaste: true,
isRow: isRow
})
})]
}),
size: "large",
verticalAlign: "bottom"
});
};
//# sourceMappingURL=index.js.map