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

182 lines
5.9 KiB
Plaintext

'use client';
import { c as _c } from "react/compiler-runtime";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useModal } from '@faceless-ui/modal';
import { getTranslation } from '@payloadcms/translations';
import React from 'react';
import { useConfig } from '../../../providers/Config/index.js';
import { useFolder } from '../../../providers/Folders/index.js';
import { useTranslation } from '../../../providers/Translation/index.js';
import { Button } from '../../Button/index.js';
import { DocumentDrawer, useDocumentDrawer } from '../../DocumentDrawer/index.js';
import { Popup, PopupList } from '../../Popup/index.js';
const baseClass = 'create-new-doc-in-folder';
export function ListCreateNewDocInFolderButton(t0) {
const $ = _c(24);
const {
buttonLabel,
buttonSize: t1,
buttonStyle: t2,
collectionSlugs,
folderAssignedCollections,
onCreateSuccess,
slugPrefix
} = t0;
const buttonSize = t1 === undefined ? "small" : t1;
const buttonStyle = t2 === undefined ? "pill" : t2;
const newDocInFolderDrawerSlug = `${slugPrefix}-new-doc-in-folder-drawer`;
const {
i18n
} = useTranslation();
const {
closeModal,
openModal
} = useModal();
const {
config
} = useConfig();
const {
folderCollectionConfig,
folderCollectionSlug,
folderFieldName,
folderID
} = useFolder();
let t3;
if ($[0] !== folderCollectionSlug) {
t3 = {
collectionSlug: folderCollectionSlug
};
$[0] = folderCollectionSlug;
$[1] = t3;
} else {
t3 = $[1];
}
const [FolderDocumentDrawer,, t4] = useDocumentDrawer(t3);
const {
closeDrawer: closeFolderDrawer,
openDrawer: openFolderDrawer
} = t4;
const [createCollectionSlug, setCreateCollectionSlug] = React.useState();
let t5;
if ($[2] !== collectionSlugs || $[3] !== config) {
t5 = () => collectionSlugs.reduce((acc, collectionSlug) => {
const collectionConfig = config.collections.find(t6 => {
const {
slug
} = t6;
return slug === collectionSlug;
});
if (collectionConfig) {
acc.push(collectionConfig);
}
return acc;
}, []);
$[2] = collectionSlugs;
$[3] = config;
$[4] = t5;
} else {
t5 = $[4];
}
const [enabledCollections] = React.useState(t5);
if (enabledCollections.length === 0) {
return null;
}
let t6;
if ($[5] !== FolderDocumentDrawer || $[6] !== buttonLabel || $[7] !== buttonSize || $[8] !== buttonStyle || $[9] !== closeFolderDrawer || $[10] !== closeModal || $[11] !== collectionSlugs || $[12] !== createCollectionSlug || $[13] !== enabledCollections || $[14] !== folderAssignedCollections || $[15] !== folderCollectionConfig.slug || $[16] !== folderFieldName || $[17] !== folderID || $[18] !== i18n || $[19] !== newDocInFolderDrawerSlug || $[20] !== onCreateSuccess || $[21] !== openFolderDrawer || $[22] !== openModal) {
t6 = _jsxs(React.Fragment, {
children: [enabledCollections.length === 1 ? _jsx(Button, {
buttonStyle,
className: `${baseClass}__button`,
el: "div",
onClick: () => {
if (enabledCollections[0].slug === folderCollectionConfig.slug) {
openFolderDrawer();
} else {
setCreateCollectionSlug(enabledCollections[0].slug);
openModal(newDocInFolderDrawerSlug);
}
},
size: buttonSize,
children: buttonLabel
}) : _jsx(Popup, {
button: _jsx(Button, {
buttonStyle,
className: `${baseClass}__popup-button`,
el: "div",
icon: "chevron",
size: buttonSize,
children: buttonLabel
}),
buttonType: "default",
className: `${baseClass}__action-popup`,
children: _jsx(PopupList.ButtonGroup, {
children: enabledCollections.map((collection, index) => _jsx(PopupList.Button, {
onClick: () => {
if (collection.slug === folderCollectionConfig.slug) {
openFolderDrawer();
} else {
setCreateCollectionSlug(collection.slug);
openModal(newDocInFolderDrawerSlug);
}
},
children: getTranslation(collection.labels.singular, i18n)
}, index))
})
}), createCollectionSlug && _jsx(DocumentDrawer, {
collectionSlug: createCollectionSlug,
drawerSlug: newDocInFolderDrawerSlug,
initialData: {
[folderFieldName]: folderID
},
onSave: async t7 => {
const {
doc
} = t7;
await onCreateSuccess({
collectionSlug: createCollectionSlug,
doc
});
closeModal(newDocInFolderDrawerSlug);
},
redirectAfterCreate: false
}), collectionSlugs.includes(folderCollectionConfig.slug) && _jsx(FolderDocumentDrawer, {
initialData: {
[folderFieldName]: folderID,
folderType: createCollectionSlug ? folderAssignedCollections || [createCollectionSlug] : folderAssignedCollections
},
onSave: async result => {
await onCreateSuccess({
collectionSlug: folderCollectionConfig.slug,
doc: result.doc
});
closeFolderDrawer();
},
redirectAfterCreate: false
})]
});
$[5] = FolderDocumentDrawer;
$[6] = buttonLabel;
$[7] = buttonSize;
$[8] = buttonStyle;
$[9] = closeFolderDrawer;
$[10] = closeModal;
$[11] = collectionSlugs;
$[12] = createCollectionSlug;
$[13] = enabledCollections;
$[14] = folderAssignedCollections;
$[15] = folderCollectionConfig.slug;
$[16] = folderFieldName;
$[17] = folderID;
$[18] = i18n;
$[19] = newDocInFolderDrawerSlug;
$[20] = onCreateSuccess;
$[21] = openFolderDrawer;
$[22] = openModal;
$[23] = t6;
} else {
t6 = $[23];
}
return t6;
}
//# sourceMappingURL=ListCreateNewDocInFolderButton.js.map