Files
klz-cables.com/.pnpm-store/v10/files/be/ba49f506dba8d102080e955ad5ac3f10cdc8d03cedc8e6347996a457d4c2cb0ffaacaea92eb381548dc8bec5d870e2a80c8b9c8cb8f73d33bf3c64627902e4
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

60 lines
1.6 KiB
Plaintext

'use client';
import { jsx as _jsx } from "react/jsx-runtime";
import React, { useRef } from 'react';
import { useForm, useFormModified } from '../../forms/Form/context.js';
import { FormSubmit } from '../../forms/Submit/index.js';
import { useHotkey } from '../../hooks/useHotkey.js';
import { useDocumentInfo } from '../../providers/DocumentInfo/index.js';
import { useEditDepth } from '../../providers/EditDepth/index.js';
import { useOperation } from '../../providers/Operation/index.js';
import { useTranslation } from '../../providers/Translation/index.js';
export function SaveButton({
label: labelProp
}) {
const {
uploadStatus
} = useDocumentInfo();
const {
t
} = useTranslation();
const {
submit
} = useForm();
const modified = useFormModified();
const label = labelProp || t('general:save');
const ref = useRef(null);
const editDepth = useEditDepth();
const operation = useOperation();
const disabled = operation === 'update' && !modified || uploadStatus === 'uploading';
useHotkey({
cmdCtrlKey: true,
editDepth,
keyCodes: ['s']
}, e => {
if (disabled) {
// absorb the event
}
e.preventDefault();
e.stopPropagation();
if (ref?.current) {
ref.current.click();
}
});
const handleSubmit = () => {
if (uploadStatus === 'uploading') {
return;
}
return void submit();
};
return /*#__PURE__*/_jsx(FormSubmit, {
buttonId: "action-save",
disabled: disabled,
onClick: handleSubmit,
ref: ref,
size: "medium",
type: "button",
children: label
});
}
//# sourceMappingURL=index.js.map