Files
pole-book/server/node_modules/.strapi/vite/deps/ListView-M4MMRMSH.js

1328 lines
40 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import {
AttributeIcon,
COMPONENT_ICONS,
getTrad,
useDataManager,
useFormModalNavigation
} from "./chunk-6EDW4YHC.js";
import "./chunk-SQLDXQZE.js";
import "./chunk-QF6GPHA4.js";
import "./chunk-JRLAXHTE.js";
import "./chunk-E4IFZ6ZT.js";
import "./chunk-QLEKUQKW.js";
import "./chunk-4J3VOWQV.js";
import "./chunk-PFI4R5WA.js";
import "./chunk-B3BGMYGX.js";
import "./chunk-W6ICJ5TB.js";
import "./chunk-IHYIPMY2.js";
import "./chunk-UWHSN2C7.js";
import "./chunk-ERK7O2GM.js";
import "./chunk-FCIM6RNO.js";
import "./chunk-J33IXKN4.js";
import "./chunk-NP53ZCXD.js";
import "./chunk-MBK4V2X7.js";
import "./chunk-5ESYXDTN.js";
import "./chunk-K65KIEAL.js";
import "./chunk-B7ZLODDO.js";
import "./chunk-PW7XKCYO.js";
import "./chunk-RMBEU7DO.js";
import "./chunk-RI2W2UZ6.js";
import {
BackButton
} from "./chunk-IY256CNP.js";
import "./chunk-IFOFBKTA.js";
import {
require_has,
require_upperFirst
} from "./chunk-XLSIZGJF.js";
import "./chunk-EGNP2T5O.js";
import {
useTracking
} from "./chunk-GSN7U3BK.js";
import "./chunk-T3B5F2LV.js";
import "./chunk-YXDCVYVT.js";
import "./chunk-QIJGNK42.js";
import "./chunk-7PUJSL55.js";
import "./chunk-C2ZJTFO7.js";
import "./chunk-C75BZXCZ.js";
import "./chunk-APGTER6B.js";
import "./chunk-ZM6TT53G.js";
import "./chunk-6AXVGFVQ.js";
import "./chunk-BFLP6DBI.js";
import {
useRBAC
} from "./chunk-CMLQV3Z2.js";
import "./chunk-IGCTEXRF.js";
import {
Layouts
} from "./chunk-TIVRAWTC.js";
import "./chunk-PQINNV4N.js";
import {
require_isEqual
} from "./chunk-VYSYYPOB.js";
import {
ForwardRef$J
} from "./chunk-5CAWUBTQ.js";
import "./chunk-W2TBR6J3.js";
import "./chunk-QEGMJR7H.js";
import {
require_get
} from "./chunk-LCL5TIBZ.js";
import "./chunk-WOQNBAGN.js";
import "./chunk-BHLYCXQ7.js";
import "./chunk-76QM3EFM.js";
import "./chunk-CE4VABH2.js";
import "./chunk-5VODLFKF.js";
import "./chunk-N55RVBRV.js";
import {
Box,
Button,
EmptyStateLayout,
Flex,
IconButton,
TFooter,
Table,
Tbody,
Td,
Th,
Thead,
Tr,
Typography,
useIntl
} from "./chunk-7XB6XSWQ.js";
import "./chunk-5ZC4PE57.js";
import {
useMatch,
useNavigate,
usePrompt
} from "./chunk-TUXTO2Z5.js";
import "./chunk-FOD4ENRR.js";
import {
ForwardRef$1h,
ForwardRef$1v,
ForwardRef$2h,
ForwardRef$2n,
ForwardRef$45,
ForwardRef$4F,
ForwardRef$j
} from "./chunk-WRD5KPDH.js";
import {
require_jsx_runtime
} from "./chunk-NIAJZ5MX.js";
import {
dt
} from "./chunk-ACIMPXWY.js";
import {
require_react
} from "./chunk-MADUDGYZ.js";
import {
__toESM
} from "./chunk-PLDDJCW6.js";
// node_modules/@strapi/content-type-builder/dist/admin/pages/ListView/ListView.mjs
var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
var import_get4 = __toESM(require_get(), 1);
var import_has = __toESM(require_has(), 1);
var import_isEqual = __toESM(require_isEqual(), 1);
var import_upperFirst2 = __toESM(require_upperFirst(), 1);
// node_modules/@strapi/content-type-builder/dist/admin/components/List.mjs
var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
var import_react2 = __toESM(require_react(), 1);
// node_modules/@strapi/content-type-builder/dist/admin/components/BoxWrapper.mjs
var BoxWrapper = dt(Box)`
table {
width: 100%;
white-space: nowrap;
}
thead {
border-bottom: 1px solid ${({ theme }) => theme.colors.neutral150};
tr {
border-top: 0;
}
}
tr {
border-top: 1px solid ${({ theme }) => theme.colors.neutral150};
& td,
& th {
padding: ${({ theme }) => theme.spaces[4]};
}
& td:first-of-type,
& th:first-of-type {
padding: 0 ${({ theme }) => theme.spaces[1]};
}
}
th,
td {
vertical-align: middle;
text-align: left;
color: ${({ theme }) => theme.colors.neutral600};
outline-offset: -4px;
}
`;
// node_modules/@strapi/content-type-builder/dist/admin/components/ComponentList.mjs
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
var import_get = __toESM(require_get(), 1);
// node_modules/@strapi/content-type-builder/dist/admin/components/Tr.mjs
var Tr2 = dt.tr`
&.component-row,
&.dynamiczone-row {
position: relative;
border-top: none !important;
table tr:first-child {
border-top: none;
}
> td:first-of-type {
padding: 0 0 0 2rem;
position: relative;
&::before {
content: '';
width: 0.4rem;
height: calc(100% - 40px);
position: absolute;
top: -7px;
left: 2.6rem;
border-radius: 4px;
${({ $isFromDynamicZone, $isChildOfDynamicZone, theme }) => {
if ($isChildOfDynamicZone) {
return `background-color: ${theme.colors.primary200};`;
}
if ($isFromDynamicZone) {
return `background-color: ${theme.colors.primary200};`;
}
return `background: ${theme.colors.neutral150};`;
}}
}
}
}
&.dynamiczone-row > td:first-of-type {
padding: 0;
}
`;
// node_modules/@strapi/content-type-builder/dist/admin/components/ComponentList.mjs
var ComponentList = ({ customRowComponent, component, isFromDynamicZone = false, isNestedInDZComponent = false, firstLoopComponentUid }) => {
const { modifiedData } = useDataManager();
const { schema: { attributes } } = (0, import_get.default)(modifiedData, [
"components",
component
], {
schema: {
attributes: []
}
});
return (0, import_jsx_runtime.jsx)(Tr2, {
$isChildOfDynamicZone: isFromDynamicZone,
className: "component-row",
children: (0, import_jsx_runtime.jsx)("td", {
colSpan: 12,
children: (0, import_jsx_runtime.jsx)(List, {
customRowComponent,
items: attributes,
targetUid: component,
firstLoopComponentUid: firstLoopComponentUid || component,
editTarget: "components",
isFromDynamicZone,
isNestedInDZComponent,
isSub: true,
secondLoopComponentUid: firstLoopComponentUid ? component : null
})
})
});
};
// node_modules/@strapi/content-type-builder/dist/admin/components/DynamicZoneList.mjs
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
var import_react = __toESM(require_react(), 1);
// node_modules/@strapi/content-type-builder/dist/admin/components/ComponentCard/ComponentCard.mjs
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
var import_get2 = __toESM(require_get(), 1);
// node_modules/@strapi/content-type-builder/dist/admin/components/ComponentCard/ComponentIcon/ComponentIcon.mjs
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
var ComponentIcon = ({ isActive = false, icon = "dashboard" }) => {
const Icon = COMPONENT_ICONS[icon] || COMPONENT_ICONS.dashboard;
return (0, import_jsx_runtime2.jsx)(Flex, {
alignItems: "center",
background: isActive ? "primary200" : "neutral200",
justifyContent: "center",
height: 8,
width: 8,
borderRadius: "50%",
children: (0, import_jsx_runtime2.jsx)(Icon, {
height: "2rem",
width: "2rem"
})
});
};
// node_modules/@strapi/content-type-builder/dist/admin/components/ComponentCard/ComponentCard.mjs
var CloseButton = dt(Box)`
position: absolute;
display: none;
top: 5px;
right: 0.8rem;
svg {
width: 1rem;
height: 1rem;
path {
fill: ${({ theme }) => theme.colors.primary600};
}
}
`;
var ComponentBox = dt(Flex)`
width: 14rem;
height: 8rem;
position: relative;
border: 1px solid ${({ theme }) => theme.colors.neutral200};
background: ${({ theme }) => theme.colors.neutral100};
border-radius: ${({ theme }) => theme.borderRadius};
max-width: 100%;
&.active,
&:focus,
&:hover {
border: 1px solid ${({ theme }) => theme.colors.primary200};
background: ${({ theme }) => theme.colors.primary100};
color: ${({ theme }) => theme.colors.primary600};
${CloseButton} {
display: block;
}
/* > ComponentIcon */
> div:first-child {
background: ${({ theme }) => theme.colors.primary200};
color: ${({ theme }) => theme.colors.primary600};
svg {
path {
fill: ${({ theme }) => theme.colors.primary600};
}
}
}
}
`;
var ComponentCard = ({ component, dzName, index, isActive = false, isInDevelopmentMode = false, onClick }) => {
const { modifiedData, removeComponentFromDynamicZone } = useDataManager();
const { schema: { icon, displayName } } = (0, import_get2.default)(modifiedData, [
"components",
component
], {
schema: {}
});
const onClose = (e) => {
e.stopPropagation();
removeComponentFromDynamicZone(dzName, index);
};
return (0, import_jsx_runtime3.jsxs)(ComponentBox, {
alignItems: "center",
direction: "column",
className: isActive ? "active" : "",
borderRadius: "borderRadius",
justifyContent: "center",
paddingLeft: 4,
paddingRight: 4,
shrink: 0,
onClick,
role: "tab",
tabIndex: isActive ? 0 : -1,
cursor: "pointer",
"aria-selected": isActive,
"aria-controls": `dz-${dzName}-panel-${index}`,
id: `dz-${dzName}-tab-${index}`,
children: [
(0, import_jsx_runtime3.jsx)(ComponentIcon, {
icon,
isActive
}),
(0, import_jsx_runtime3.jsx)(Box, {
marginTop: 1,
maxWidth: "100%",
children: (0, import_jsx_runtime3.jsx)(Typography, {
variant: "pi",
fontWeight: "bold",
ellipsis: true,
children: displayName
})
}),
isInDevelopmentMode && (0, import_jsx_runtime3.jsx)(CloseButton, {
tag: "button",
onClick: onClose,
children: (0, import_jsx_runtime3.jsx)(ForwardRef$45, {})
})
]
});
};
// node_modules/@strapi/content-type-builder/dist/admin/components/DynamicZoneList.mjs
var StyledAddIcon = dt(ForwardRef$1h)`
width: 3.2rem;
height: 3.2rem;
padding: 0.9rem;
border-radius: 6.4rem;
background: ${({ theme }) => theme.colors.primary100};
path {
fill: ${({ theme }) => theme.colors.primary600};
}
`;
var FixedBox = dt(Box)`
height: 9rem;
position: absolute;
width: 100%;
top: 0;
left: 0;
`;
var ScrollableStack = dt(Flex)`
width: 100%;
overflow-x: auto;
`;
var ComponentContentBox = dt(Box)`
padding-top: 9rem;
`;
var ComponentStack = dt(Flex)`
flex-shrink: 0;
width: 14rem;
height: 8rem;
justify-content: center;
align-items: center;
`;
var DynamicZoneList = ({ customRowComponent, components = [], addComponent, name, targetUid }) => {
const { isInDevelopmentMode } = useDataManager();
const [activeTab, setActiveTab] = (0, import_react.useState)(0);
const { formatMessage } = useIntl();
const toggle = (tab) => {
if (activeTab !== tab) {
setActiveTab(tab);
}
};
const handleClickAdd = () => {
addComponent(name);
};
return (0, import_jsx_runtime4.jsx)(Tr2, {
className: "dynamiczone-row",
$isFromDynamicZone: true,
children: (0, import_jsx_runtime4.jsxs)("td", {
colSpan: 12,
children: [
(0, import_jsx_runtime4.jsx)(FixedBox, {
paddingLeft: 8,
children: (0, import_jsx_runtime4.jsxs)(ScrollableStack, {
gap: 2,
children: [
isInDevelopmentMode && (0, import_jsx_runtime4.jsx)("button", {
type: "button",
onClick: handleClickAdd,
children: (0, import_jsx_runtime4.jsxs)(ComponentStack, {
direction: "column",
alignItems: "stretch",
gap: 1,
children: [
(0, import_jsx_runtime4.jsx)(StyledAddIcon, {}),
(0, import_jsx_runtime4.jsx)(Typography, {
variant: "pi",
fontWeight: "bold",
textColor: "primary600",
children: formatMessage({
id: getTrad("button.component.add"),
defaultMessage: "Add a component"
})
})
]
})
}),
(0, import_jsx_runtime4.jsx)(Flex, {
role: "tablist",
gap: 2,
children: components.map((component, index) => {
return (0, import_jsx_runtime4.jsx)(ComponentCard, {
dzName: name || "",
index,
component,
isActive: activeTab === index,
isInDevelopmentMode,
onClick: () => toggle(index)
}, component);
})
})
]
})
}),
(0, import_jsx_runtime4.jsx)(ComponentContentBox, {
children: components.map((component, index) => {
const props = {
customRowComponent,
component
};
return (0, import_jsx_runtime4.jsx)(Box, {
id: `dz-${name}-panel-${index}`,
role: "tabpanel",
"aria-labelledby": `dz-${name}-tab-${index}`,
style: {
display: activeTab === index ? "block" : "none"
},
children: (0, import_jsx_runtime4.jsx)("table", {
children: (0, import_jsx_runtime4.jsx)("tbody", {
children: (0, import_react.createElement)(ComponentList, {
...props,
isFromDynamicZone: true,
component: targetUid,
key: component
})
})
})
}, component);
})
})
]
})
});
};
// node_modules/@strapi/content-type-builder/dist/admin/components/NestedFooter.mjs
var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
var IconBox = dt(Box)`
height: 2.4rem;
width: 2.4rem;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
svg {
height: 1rem;
width: 1rem;
}
svg path {
fill: ${({ theme, color }) => theme.colors[`${color}600`]};
}
`;
var ButtonBox = dt(Box)`
border-radius: 0 0 ${({ theme }) => theme.borderRadius} ${({ theme }) => theme.borderRadius};
display: block;
width: 100%;
border: none;
position: relative;
left: -0.4rem;
`;
var NestedTFooter = ({ children, icon, color, ...props }) => {
return (0, import_jsx_runtime5.jsx)(ButtonBox, {
paddingBottom: 4,
paddingTop: 4,
tag: "button",
type: "button",
...props,
children: (0, import_jsx_runtime5.jsxs)(Flex, {
children: [
(0, import_jsx_runtime5.jsx)(IconBox, {
color,
"aria-hidden": true,
background: `${color}200`,
children: icon
}),
(0, import_jsx_runtime5.jsx)(Box, {
paddingLeft: 3,
children: (0, import_jsx_runtime5.jsx)(Typography, {
variant: "pi",
fontWeight: "bold",
textColor: `${color}600`,
children
})
})
]
})
});
};
// node_modules/@strapi/content-type-builder/dist/admin/components/List.mjs
var List = ({ addComponentToDZ, customRowComponent, editTarget, firstLoopComponentUid, isFromDynamicZone = false, isMain = false, isNestedInDZComponent = false, isSub = false, items = [], secondLoopComponentUid, targetUid }) => {
const { formatMessage } = useIntl();
const { trackUsage } = useTracking();
const { isInDevelopmentMode, modifiedData, isInContentTypeView } = useDataManager();
const { onOpenModalAddField } = useFormModalNavigation();
const onClickAddField = () => {
trackUsage("hasClickedCTBAddFieldBanner");
onOpenModalAddField({
forTarget: editTarget,
targetUid
});
};
if (!targetUid) {
return (0, import_jsx_runtime6.jsxs)(Table, {
colCount: 2,
rowCount: 2,
children: [
(0, import_jsx_runtime6.jsx)(Thead, {
children: (0, import_jsx_runtime6.jsxs)(Tr, {
children: [
(0, import_jsx_runtime6.jsx)(Th, {
children: (0, import_jsx_runtime6.jsx)(Typography, {
variant: "sigma",
textColor: "neutral600",
children: formatMessage({
id: "global.name",
defaultMessage: "Name"
})
})
}),
(0, import_jsx_runtime6.jsx)(Th, {
children: (0, import_jsx_runtime6.jsx)(Typography, {
variant: "sigma",
textColor: "neutral600",
children: formatMessage({
id: "global.type",
defaultMessage: "Type"
})
})
})
]
})
}),
(0, import_jsx_runtime6.jsx)(Tbody, {
children: (0, import_jsx_runtime6.jsx)(Tr, {
children: (0, import_jsx_runtime6.jsx)(Td, {
colSpan: 2,
children: (0, import_jsx_runtime6.jsx)(EmptyStateLayout, {
content: formatMessage({
id: getTrad("table.content.create-first-content-type"),
defaultMessage: "Create your first Collection-Type"
}),
hasRadius: true,
icon: (0, import_jsx_runtime6.jsx)(ForwardRef$J, {
width: "16rem"
})
})
})
})
})
]
});
}
if (items.length === 0 && isMain) {
return (0, import_jsx_runtime6.jsxs)(Table, {
colCount: 2,
rowCount: 2,
children: [
(0, import_jsx_runtime6.jsx)(Thead, {
children: (0, import_jsx_runtime6.jsxs)(Tr, {
children: [
(0, import_jsx_runtime6.jsx)(Th, {
children: (0, import_jsx_runtime6.jsx)(Typography, {
variant: "sigma",
textColor: "neutral600",
children: formatMessage({
id: "global.name",
defaultMessage: "Name"
})
})
}),
(0, import_jsx_runtime6.jsx)(Th, {
children: (0, import_jsx_runtime6.jsx)(Typography, {
variant: "sigma",
textColor: "neutral600",
children: formatMessage({
id: "global.type",
defaultMessage: "Type"
})
})
})
]
})
}),
(0, import_jsx_runtime6.jsx)(Tbody, {
children: (0, import_jsx_runtime6.jsx)(Tr, {
children: (0, import_jsx_runtime6.jsx)(Td, {
colSpan: 2,
children: (0, import_jsx_runtime6.jsx)(EmptyStateLayout, {
action: (0, import_jsx_runtime6.jsx)(Button, {
onClick: onClickAddField,
size: "L",
startIcon: (0, import_jsx_runtime6.jsx)(ForwardRef$1h, {}),
variant: "secondary",
children: formatMessage({
id: getTrad("table.button.no-fields"),
defaultMessage: "Add new field"
})
}),
content: formatMessage(isInContentTypeView ? {
id: getTrad("table.content.no-fields.collection-type"),
defaultMessage: "Add your first field to this Collection-Type"
} : {
id: getTrad("table.content.no-fields.component"),
defaultMessage: "Add your first field to this component"
}),
hasRadius: true,
icon: (0, import_jsx_runtime6.jsx)(ForwardRef$J, {
width: "16rem"
})
})
})
})
})
]
});
}
return (0, import_jsx_runtime6.jsxs)(BoxWrapper, {
children: [
(0, import_jsx_runtime6.jsx)(Box, {
paddingLeft: 6,
paddingRight: isMain ? 6 : 0,
...isMain && {
style: {
overflowX: "auto"
}
},
children: (0, import_jsx_runtime6.jsxs)("table", {
children: [
isMain && (0, import_jsx_runtime6.jsx)("thead", {
children: (0, import_jsx_runtime6.jsxs)("tr", {
children: [
(0, import_jsx_runtime6.jsx)("th", {
children: (0, import_jsx_runtime6.jsx)(Typography, {
variant: "sigma",
textColor: "neutral800",
children: formatMessage({
id: "global.name",
defaultMessage: "Name"
})
})
}),
(0, import_jsx_runtime6.jsx)("th", {
colSpan: 2,
children: (0, import_jsx_runtime6.jsx)(Typography, {
variant: "sigma",
textColor: "neutral800",
children: formatMessage({
id: "global.type",
defaultMessage: "Type"
})
})
})
]
})
}),
(0, import_jsx_runtime6.jsx)("tbody", {
children: items.map((item) => {
const { type } = item;
const CustomRow = customRowComponent;
return (0, import_jsx_runtime6.jsxs)(import_react2.Fragment, {
children: [
(0, import_jsx_runtime6.jsx)(CustomRow, {
...item,
isNestedInDZComponent,
targetUid,
editTarget,
firstLoopComponentUid,
isFromDynamicZone,
secondLoopComponentUid
}),
type === "component" && (0, import_jsx_runtime6.jsx)(ComponentList, {
...item,
customRowComponent,
targetUid,
isNestedInDZComponent: isFromDynamicZone,
editTarget,
firstLoopComponentUid
}),
type === "dynamiczone" && (0, import_jsx_runtime6.jsx)(DynamicZoneList, {
...item,
customRowComponent,
addComponent: addComponentToDZ,
targetUid
})
]
}, item.name);
})
})
]
})
}),
isMain && isInDevelopmentMode && (0, import_jsx_runtime6.jsx)(TFooter, {
cursor: "pointer",
icon: (0, import_jsx_runtime6.jsx)(ForwardRef$1h, {}),
onClick: onClickAddField,
children: formatMessage({
id: getTrad(`form.button.add.field.to.${modifiedData.contentType ? modifiedData.contentType.schema.kind : editTarget || "collectionType"}`),
defaultMessage: "Add another field"
})
}),
isSub && isInDevelopmentMode && !isFromDynamicZone && (0, import_jsx_runtime6.jsx)(NestedTFooter, {
icon: (0, import_jsx_runtime6.jsx)(ForwardRef$1h, {}),
onClick: onClickAddField,
color: isFromDynamicZone ? "primary" : "neutral",
children: formatMessage({
id: getTrad(`form.button.add.field.to.component`),
defaultMessage: "Add another field"
})
})
]
});
};
// node_modules/@strapi/content-type-builder/dist/admin/components/ListRow.mjs
var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
var import_react3 = __toESM(require_react(), 1);
var import_get3 = __toESM(require_get(), 1);
// node_modules/@strapi/content-type-builder/dist/admin/icons/Curve.mjs
var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
var StyledBox = dt(Box)`
position: absolute;
left: -1.8rem;
top: 0px;
&:before {
content: '';
width: 0.4rem;
height: 1.2rem;
background: ${({ theme, color }) => theme.colors[color]};
display: block;
}
`;
var Svg = dt.svg`
position: relative;
flex-shrink: 0;
transform: translate(-0.5px, -1px);
* {
fill: ${({ theme, color }) => theme.colors[color]};
}
`;
var Curve = (props) => (0, import_jsx_runtime7.jsx)(StyledBox, {
children: (0, import_jsx_runtime7.jsx)(Svg, {
width: "20",
height: "23",
viewBox: "0 0 20 23",
fill: "none",
xmlns: "http://www.w3.org/2000/svg",
...props,
children: (0, import_jsx_runtime7.jsx)("path", {
fillRule: "evenodd",
clipRule: "evenodd",
d: "M7.02477 14.7513C8.65865 17.0594 11.6046 18.6059 17.5596 18.8856C18.6836 18.9384 19.5976 19.8435 19.5976 20.9688V20.9688C19.5976 22.0941 18.6841 23.0125 17.5599 22.9643C10.9409 22.6805 6.454 20.9387 3.75496 17.1258C0.937988 13.1464 0.486328 7.39309 0.486328 0.593262H4.50974C4.50974 7.54693 5.06394 11.9813 7.02477 14.7513Z"
})
})
});
// node_modules/@strapi/content-type-builder/dist/admin/components/DisplayedType.mjs
var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
var DisplayedType = ({ type, customField = null, repeatable = false }) => {
const { formatMessage } = useIntl();
let readableType = type;
if ([
"integer",
"biginteger",
"float",
"decimal"
].includes(type)) {
readableType = "number";
} else if ([
"string"
].includes(type)) {
readableType = "text";
}
if (customField) {
return (0, import_jsx_runtime8.jsx)(Typography, {
children: formatMessage({
id: getTrad("attribute.customField"),
defaultMessage: "Custom field"
})
});
}
return (0, import_jsx_runtime8.jsxs)(Typography, {
textColor: "neutral800",
children: [
formatMessage({
id: getTrad(`attribute.${readableType}`),
defaultMessage: type
}),
" ",
repeatable && formatMessage({
id: getTrad("component.repeatable"),
defaultMessage: "(repeatable)"
})
]
});
};
// node_modules/@strapi/content-type-builder/dist/admin/components/UpperFirst.mjs
var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
var import_upperFirst = __toESM(require_upperFirst(), 1);
var UpperFirst = ({ content }) => (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, {
children: (0, import_upperFirst.default)(content)
});
// node_modules/@strapi/content-type-builder/dist/admin/components/ListRow.mjs
var BoxWrapper2 = dt(Box)`
position: relative;
`;
var ListRow = (0, import_react3.memo)(({ configurable = true, customField = null, editTarget, firstLoopComponentUid = null, isFromDynamicZone = false, name, onClick, relation = "", repeatable = false, secondLoopComponentUid = null, target = null, targetUid = null, type }) => {
const { contentTypes, isInDevelopmentMode, removeAttribute } = useDataManager();
const { formatMessage } = useIntl();
const isMorph = type === "relation" && relation.includes("morph");
const ico = [
"integer",
"biginteger",
"float",
"decimal"
].includes(type) ? "number" : type;
const contentType = (0, import_get3.default)(contentTypes, [
target
], {});
const contentTypeFriendlyName = (0, import_get3.default)(contentType, [
"schema",
"displayName"
], "");
const isPluginContentType = (0, import_get3.default)(contentType, "plugin");
const src = target ? "relation" : ico;
const handleClick = () => {
if (isMorph) {
return;
}
if (configurable !== false) {
const attrType = type;
onClick(
// Tells where the attribute is located in the main modifiedData object : contentType, component or components
editTarget,
// main data type uid
secondLoopComponentUid || firstLoopComponentUid || targetUid,
// Name of the attribute
name,
// Type of the attribute
attrType,
customField
);
}
};
let loopNumber;
if (secondLoopComponentUid && firstLoopComponentUid) {
loopNumber = 2;
} else if (firstLoopComponentUid) {
loopNumber = 1;
} else {
loopNumber = 0;
}
return (0, import_jsx_runtime10.jsxs)(BoxWrapper2, {
tag: "tr",
onClick: isInDevelopmentMode && configurable && !isMorph ? handleClick : void 0,
children: [
(0, import_jsx_runtime10.jsxs)("td", {
style: {
position: "relative"
},
children: [
loopNumber !== 0 && (0, import_jsx_runtime10.jsx)(Curve, {
color: isFromDynamicZone ? "primary200" : "neutral150"
}),
(0, import_jsx_runtime10.jsxs)(Flex, {
paddingLeft: 2,
gap: 4,
children: [
(0, import_jsx_runtime10.jsx)(AttributeIcon, {
type: src,
customField
}),
(0, import_jsx_runtime10.jsx)(Typography, {
textColor: "neutral800",
fontWeight: "bold",
children: name
})
]
})
]
}),
(0, import_jsx_runtime10.jsx)("td", {
children: target ? (0, import_jsx_runtime10.jsxs)(Typography, {
textColor: "neutral800",
children: [
formatMessage({
id: getTrad(`modelPage.attribute.${isMorph ? "relation-polymorphic" : "relationWith"}`),
defaultMessage: "Relation with"
}),
" ",
(0, import_jsx_runtime10.jsxs)("span", {
style: {
fontStyle: "italic"
},
children: [
(0, import_jsx_runtime10.jsx)(UpperFirst, {
content: contentTypeFriendlyName
}),
" ",
isPluginContentType && `(${formatMessage({
id: getTrad(`from`),
defaultMessage: "from"
})}: ${isPluginContentType})`
]
})
]
}) : (0, import_jsx_runtime10.jsx)(DisplayedType, {
type,
customField,
repeatable
})
}),
(0, import_jsx_runtime10.jsx)("td", {
children: isInDevelopmentMode ? (0, import_jsx_runtime10.jsx)(Flex, {
justifyContent: "flex-end",
onClick: (e) => e.stopPropagation(),
children: configurable ? (0, import_jsx_runtime10.jsxs)(Flex, {
gap: 1,
children: [
!isMorph && (0, import_jsx_runtime10.jsx)(IconButton, {
onClick: handleClick,
label: `${formatMessage({
id: "app.utils.edit",
defaultMessage: "Edit"
})} ${name}`,
variant: "ghost",
children: (0, import_jsx_runtime10.jsx)(ForwardRef$1v, {})
}),
(0, import_jsx_runtime10.jsx)(IconButton, {
onClick: (e) => {
e.stopPropagation();
removeAttribute(editTarget, name, secondLoopComponentUid || firstLoopComponentUid || "");
},
label: `${formatMessage({
id: "global.delete",
defaultMessage: "Delete"
})} ${name}`,
variant: "ghost",
children: (0, import_jsx_runtime10.jsx)(ForwardRef$j, {})
})
]
}) : (0, import_jsx_runtime10.jsx)(ForwardRef$2h, {})
}) : (
/*
In production mode the edit icons aren't visible, therefore
we need to reserve the same space, otherwise the height of the
row might collapse, leading to bad positioned curve icons
*/
(0, import_jsx_runtime10.jsx)(Box, {
height: "3.2rem"
})
)
})
]
});
});
// node_modules/@strapi/content-type-builder/dist/admin/utils/getAttributeDisplayedType.mjs
var getAttributeDisplayedType = (type) => {
let displayedType;
switch (type) {
case "date":
case "datetime":
case "time":
case "timestamp":
displayedType = "date";
break;
case "integer":
case "biginteger":
case "decimal":
case "float":
displayedType = "number";
break;
case "string":
case "text":
displayedType = "text";
break;
case "":
displayedType = "relation";
break;
default:
displayedType = type;
}
return displayedType;
};
// node_modules/@strapi/content-type-builder/dist/admin/pages/ListView/LinkToCMSettingsView.mjs
var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
var import_react4 = __toESM(require_react(), 1);
var cmPermissions = {
collectionTypesConfigurations: [
{
action: "plugin::content-manager.collection-types.configure-view",
subject: null
}
],
componentsConfigurations: [
{
action: "plugin::content-manager.components.configure-layout",
subject: null
}
],
singleTypesConfigurations: [
{
action: "plugin::content-manager.single-types.configure-view",
subject: null
}
]
};
var getPermission = ({ isInContentTypeView, contentTypeKind }) => {
if (isInContentTypeView) {
if (contentTypeKind === "singleType") {
return cmPermissions.singleTypesConfigurations;
}
return cmPermissions.collectionTypesConfigurations;
}
return cmPermissions.componentsConfigurations;
};
var LinkToCMSettingsView = (0, import_react4.memo)(({ disabled, isInContentTypeView = true, contentTypeKind = "collectionType", targetUid = "" }) => {
const { formatMessage } = useIntl();
const navigate = useNavigate();
const permissionsToApply = getPermission({
isInContentTypeView,
contentTypeKind
});
const label = formatMessage({
id: "content-type-builder.form.button.configure-view",
defaultMessage: "Configure the view"
});
const handleClick = () => {
if (disabled) {
return false;
}
if (isInContentTypeView) {
navigate(`/content-manager/collection-types/${targetUid}/configurations/edit`);
} else {
navigate(`/content-manager/components/${targetUid}/configurations/edit`);
}
return false;
};
const { isLoading, allowedActions } = useRBAC({
viewConfig: permissionsToApply
});
if (isLoading) {
return null;
}
if (!allowedActions.canConfigureView && !allowedActions.canConfigureLayout) {
return null;
}
return (0, import_jsx_runtime11.jsx)(Button, {
startIcon: (0, import_jsx_runtime11.jsx)(ForwardRef$2n, {}),
variant: "tertiary",
onClick: handleClick,
disabled,
children: label
});
});
// node_modules/@strapi/content-type-builder/dist/admin/pages/ListView/ListView.mjs
var LayoutsHeaderCustom = dt(Layouts.Header)`
overflow-wrap: anywhere;
`;
var ListView = () => {
const { initialData, modifiedData, isInDevelopmentMode, isInContentTypeView, submitData } = useDataManager();
const { formatMessage } = useIntl();
const { trackUsage } = useTracking();
const match = useMatch("/plugins/content-type-builder/:kind/:currentUID");
const { onOpenModalAddComponentsToDZ, onOpenModalAddField, onOpenModalEditField, onOpenModalEditSchema, onOpenModalEditCustomField } = useFormModalNavigation();
const firstMainDataPath = isInContentTypeView ? "contentType" : "component";
const mainDataTypeAttributesPath = [
firstMainDataPath,
"schema",
"attributes"
];
const targetUid = (0, import_get4.default)(modifiedData, [
firstMainDataPath,
"uid"
]);
const isTemporary = (0, import_get4.default)(modifiedData, [
firstMainDataPath,
"isTemporary"
], false);
const contentTypeKind = (0, import_get4.default)(modifiedData, [
firstMainDataPath,
"schema",
"kind"
], null);
const attributes = (0, import_get4.default)(modifiedData, mainDataTypeAttributesPath, []);
const isFromPlugin = (0, import_has.default)(initialData, [
firstMainDataPath,
"plugin"
]);
const hasModelBeenModified = !(0, import_isEqual.default)(modifiedData, initialData);
const forTarget = isInContentTypeView ? "contentType" : "component";
const handleClickAddComponentToDZ = (dynamicZoneTarget) => {
onOpenModalAddComponentsToDZ({
dynamicZoneTarget,
targetUid
});
};
const handleClickEditField = async (forTarget2, targetUid2, attributeName, type, customField) => {
const attributeType = getAttributeDisplayedType(type);
const step = type === "component" ? "2" : null;
if (customField) {
onOpenModalEditCustomField({
forTarget: forTarget2,
targetUid: targetUid2,
attributeName,
attributeType,
customFieldUid: customField
});
} else {
onOpenModalEditField({
forTarget: forTarget2,
targetUid: targetUid2,
attributeName,
attributeType,
step
});
}
};
let label = (0, import_get4.default)(modifiedData, [
firstMainDataPath,
"schema",
"displayName"
], "");
const kind = (0, import_get4.default)(modifiedData, [
firstMainDataPath,
"schema",
"kind"
], "");
const isCreatingFirstContentType = (match == null ? void 0 : match.params.currentUID) === "create-content-type";
if (!label && isCreatingFirstContentType) {
label = formatMessage({
id: getTrad("button.model.create"),
defaultMessage: "Create new collection type"
});
}
const onEdit = () => {
const contentType = kind || firstMainDataPath;
if (contentType === "collectionType") {
trackUsage("willEditNameOfContentType");
}
if (contentType === "singleType") {
trackUsage("willEditNameOfSingleType");
}
onOpenModalEditSchema({
modalType: firstMainDataPath,
forTarget: firstMainDataPath,
targetUid,
kind: contentType
});
};
usePrompt({
when: hasModelBeenModified,
message: formatMessage({
id: getTrad("prompt.unsaved"),
defaultMessage: "Are you sure?"
})
});
const primaryAction = isInDevelopmentMode && (0, import_jsx_runtime12.jsxs)(Flex, {
gap: 2,
marginLeft: 2,
children: [
!isCreatingFirstContentType && (0, import_jsx_runtime12.jsx)(Button, {
startIcon: (0, import_jsx_runtime12.jsx)(ForwardRef$1h, {}),
variant: "secondary",
minWidth: "max-content",
onClick: () => {
onOpenModalAddField({
forTarget,
targetUid
});
},
children: formatMessage({
id: getTrad("button.attributes.add.another"),
defaultMessage: "Add another field"
})
}),
(0, import_jsx_runtime12.jsx)(Button, {
startIcon: (0, import_jsx_runtime12.jsx)(ForwardRef$4F, {}),
onClick: async () => await submitData(),
type: "submit",
disabled: (0, import_isEqual.default)(modifiedData, initialData),
children: formatMessage({
id: "global.save",
defaultMessage: "Save"
})
})
]
});
const secondaryAction = isInDevelopmentMode && !isFromPlugin && !isCreatingFirstContentType && (0, import_jsx_runtime12.jsx)(Button, {
startIcon: (0, import_jsx_runtime12.jsx)(ForwardRef$1v, {}),
variant: "tertiary",
onClick: onEdit,
children: formatMessage({
id: "app.utils.edit",
defaultMessage: "Edit"
})
});
return (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, {
children: [
(0, import_jsx_runtime12.jsx)(LayoutsHeaderCustom, {
id: "title",
primaryAction,
secondaryAction,
title: (0, import_upperFirst2.default)(label),
subtitle: formatMessage({
id: getTrad("listView.headerLayout.description"),
defaultMessage: "Build the data architecture of your content"
}),
navigationAction: (0, import_jsx_runtime12.jsx)(BackButton, {})
}),
(0, import_jsx_runtime12.jsx)(Layouts.Content, {
children: (0, import_jsx_runtime12.jsxs)(Flex, {
direction: "column",
alignItems: "stretch",
gap: 4,
children: [
(0, import_jsx_runtime12.jsx)(Flex, {
justifyContent: "flex-end",
children: (0, import_jsx_runtime12.jsx)(Flex, {
gap: 2,
children: (0, import_jsx_runtime12.jsx)(LinkToCMSettingsView, {
targetUid,
isInContentTypeView,
contentTypeKind,
disabled: isCreatingFirstContentType || isTemporary
}, "link-to-cm-settings-view")
})
}),
(0, import_jsx_runtime12.jsx)(Box, {
background: "neutral0",
shadow: "filterShadow",
hasRadius: true,
children: (0, import_jsx_runtime12.jsx)(List, {
items: attributes,
customRowComponent: (props) => (0, import_jsx_runtime12.jsx)(ListRow, {
...props,
onClick: handleClickEditField
}),
addComponentToDZ: handleClickAddComponentToDZ,
targetUid,
editTarget: forTarget,
isMain: true
})
})
]
})
})
]
});
};
export {
ListView as default
};
//# sourceMappingURL=ListView-M4MMRMSH.js.map