node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,261 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
require('react');
var strapiAdmin = require('@strapi/admin/strapi-admin');
var designSystem = require('@strapi/design-system');
var Icons = require('@strapi/icons');
var qs = require('qs');
var reactIntl = require('react-intl');
var reactRouterDom = require('react-router-dom');
var styledComponents = require('styled-components');
var InjectionZone = require('../../components/InjectionZone.js');
var DocumentActions = require('../../pages/EditView/components/DocumentActions.js');
var DocumentStatus = require('../../pages/EditView/components/DocumentStatus.js');
var EditViewPage = require('../../pages/EditView/EditViewPage.js');
var Preview = require('../pages/Preview.js');
/* -------------------------------------------------------------------------------------------------
* ClosePreviewButton
* -----------------------------------------------------------------------------------------------*/ const ClosePreviewButton = ()=>{
const [{ query }] = strapiAdmin.useQueryParams();
const { formatMessage } = reactIntl.useIntl();
const canGoBack = strapiAdmin.useHistory('BackButton', (state)=>state.canGoBack);
const goBack = strapiAdmin.useHistory('BackButton', (state)=>state.goBack);
const history = strapiAdmin.useHistory('BackButton', (state)=>state.history);
const locationIndex = strapiAdmin.useHistory('BackButton', (state)=>state.currentLocationIndex);
/**
* Get the link destination from the history.
* Rely on a fallback (the parent edit view page) if there's no page to go back .
*/ const historyTo = canGoBack ? history.at(locationIndex - 2) : undefined;
const fallback = {
pathname: '..',
search: qs.stringify(query, {
encode: false
})
};
const toWithFallback = historyTo ?? fallback;
const handleClick = (e)=>{
if (canGoBack) {
// Prevent normal link behavior, go back in the history stack instead
e.preventDefault();
goBack();
return;
}
// Otherwise rely on native link behavior to go back to the edit view. We don't use navigate()
// here in order to get the relative="path" functionality from the Link component.
};
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
variant: "ghost",
tag: reactRouterDom.Link,
relative: "path",
to: toWithFallback,
onClick: handleClick,
label: formatMessage({
id: 'content-manager.preview.header.close',
defaultMessage: 'Close preview'
}),
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Cross, {})
});
};
/* -------------------------------------------------------------------------------------------------
* Status
* -----------------------------------------------------------------------------------------------*/ const Status = ()=>{
// Get status
const document = Preview.usePreviewContext('PreviewHeader', (state)=>state.document);
const schema = Preview.usePreviewContext('PreviewHeader', (state)=>state.schema);
const meta = Preview.usePreviewContext('PreviewHeader', (state)=>state.meta);
const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;
if (!hasDraftAndPublished) {
return null;
}
const status = EditViewPage.getDocumentStatus(document, meta);
return /*#__PURE__*/ jsxRuntime.jsx(DocumentStatus.DocumentStatus, {
status: status,
size: "XS"
});
};
const PreviewTabs = ()=>{
const { formatMessage } = reactIntl.useIntl();
// URL query params
const [{ query }, setQuery] = strapiAdmin.useQueryParams();
// Get status
const document = Preview.usePreviewContext('PreviewHeader', (state)=>state.document);
const schema = Preview.usePreviewContext('PreviewHeader', (state)=>state.schema);
const meta = Preview.usePreviewContext('PreviewHeader', (state)=>state.meta);
const hasDraftAndPublish = schema?.options?.draftAndPublish ?? false;
const documentStatus = EditViewPage.getDocumentStatus(document, meta);
const handleTabChange = (status)=>{
if (status === 'published' || status === 'draft') {
setQuery({
status
}, 'push', true);
}
};
if (!hasDraftAndPublish) {
return null;
}
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Tabs.Root, {
variant: "simple",
value: query.status || 'draft',
onValueChange: handleTabChange,
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Tabs.List, {
"aria-label": formatMessage({
id: 'preview.tabs.label',
defaultMessage: 'Document status'
}),
children: [
/*#__PURE__*/ jsxRuntime.jsx(StatusTab, {
value: "draft",
children: formatMessage({
id: 'content-manager.containers.List.draft',
defaultMessage: 'draft'
})
}),
/*#__PURE__*/ jsxRuntime.jsx(StatusTab, {
value: "published",
disabled: documentStatus === 'draft',
children: formatMessage({
id: 'content-manager.containers.List.published',
defaultMessage: 'published'
})
})
]
})
});
};
/* -------------------------------------------------------------------------------------------------
* PreviewHeader
* -----------------------------------------------------------------------------------------------*/ const PreviewHeader = ()=>{
const title = Preview.usePreviewContext('PreviewHeader', (state)=>state.title);
const document = Preview.usePreviewContext('PreviewHeader', (state)=>state.document);
const schema = Preview.usePreviewContext('PreviewHeader', (state)=>state.schema);
const meta = Preview.usePreviewContext('PreviewHeader', (state)=>state.meta);
Preview.usePreviewContext('PreviewHeader', (state)=>state.onPreview);
const plugins = strapiAdmin.useStrapiApp('PreviewHeader', (state)=>state.plugins);
const [{ query }] = strapiAdmin.useQueryParams();
const { formatMessage } = reactIntl.useIntl();
const { toggleNotification } = strapiAdmin.useNotification();
const { copy } = strapiAdmin.useClipboard();
const handleCopyLink = ()=>{
copy(window.location.href);
toggleNotification({
message: formatMessage({
id: 'content-manager.preview.copy.success',
defaultMessage: 'Copied preview link'
}),
type: 'success'
});
};
const hasDraftAndPublish = schema.options?.draftAndPublish ?? false;
const documentActionProps = {
activeTab: query.status ?? null,
collectionType: schema.kind === 'collectionType' ? 'collection-types' : 'single-types',
model: schema.uid,
documentId: schema.kind === 'collectionType' ? document.documentId : undefined,
document,
meta
};
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
height: "48px",
gap: 4,
background: "neutral0",
borderColor: "neutral150",
tag: "header",
children: [
/*#__PURE__*/ jsxRuntime.jsxs(TitleContainer, {
height: "100%",
paddingLeft: 2,
paddingRight: 4,
children: [
/*#__PURE__*/ jsxRuntime.jsx(ClosePreviewButton, {}),
/*#__PURE__*/ jsxRuntime.jsx(PreviewTitle, {
tag: "h1",
title: title,
maxWidth: "200px",
fontSize: 2,
paddingLeft: 2,
paddingRight: 3,
fontWeight: 600,
children: title
}),
/*#__PURE__*/ jsxRuntime.jsx(Status, {})
]
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
flex: 1,
paddingRight: 2,
gap: 2,
justifyContent: hasDraftAndPublish ? 'space-between' : 'flex-end',
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
flex: "1 1 70%",
children: /*#__PURE__*/ jsxRuntime.jsx(PreviewTabs, {})
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
gap: 2,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
type: "button",
label: formatMessage({
id: 'preview.copy.label',
defaultMessage: 'Copy preview link'
}),
onClick: handleCopyLink,
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Link, {})
}),
/*#__PURE__*/ jsxRuntime.jsx(InjectionZone.InjectionZone, {
area: "preview.actions"
}),
/*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.DescriptionComponentRenderer, {
props: documentActionProps,
descriptions: plugins['content-manager'].apis.getDocumentActions('preview'),
children: (actions)=>{
const filteredActions = actions.filter((action)=>[
action.position
].flat().includes('preview'));
const [primaryAction, secondaryAction] = filteredActions;
if (!primaryAction && !secondaryAction) return null;
// Both actions are available when draft and publish enabled
if (primaryAction && secondaryAction) {
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(DocumentActions.DocumentActionButton, {
...secondaryAction,
variant: secondaryAction.variant || 'secondary'
}),
/*#__PURE__*/ jsxRuntime.jsx(DocumentActions.DocumentActionButton, {
...primaryAction,
variant: primaryAction.variant || 'default'
})
]
});
}
// Otherwise we just have the save action
return /*#__PURE__*/ jsxRuntime.jsx(DocumentActions.DocumentActionButton, {
...primaryAction,
variant: primaryAction.variant || 'secondary'
});
}
})
]
})
]
})
]
});
};
const PreviewTitle = styledComponents.styled(designSystem.Typography)`
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`;
const StatusTab = styledComponents.styled(designSystem.Tabs.Trigger)`
text-transform: uppercase;
`;
const TitleContainer = styledComponents.styled(designSystem.Flex)`
border-right: 1px solid ${({ theme })=>theme.colors.neutral150};
`;
exports.PreviewHeader = PreviewHeader;
//# sourceMappingURL=PreviewHeader.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,259 @@
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
import 'react';
import { useStrapiApp, useQueryParams, useNotification, useClipboard, DescriptionComponentRenderer, useHistory } from '@strapi/admin/strapi-admin';
import { Typography, Tabs, Flex, IconButton } from '@strapi/design-system';
import { Link, Cross } from '@strapi/icons';
import { stringify } from 'qs';
import { useIntl } from 'react-intl';
import { Link as Link$1 } from 'react-router-dom';
import { styled } from 'styled-components';
import { InjectionZone } from '../../components/InjectionZone.mjs';
import { DocumentActionButton } from '../../pages/EditView/components/DocumentActions.mjs';
import { DocumentStatus } from '../../pages/EditView/components/DocumentStatus.mjs';
import { getDocumentStatus } from '../../pages/EditView/EditViewPage.mjs';
import { usePreviewContext } from '../pages/Preview.mjs';
/* -------------------------------------------------------------------------------------------------
* ClosePreviewButton
* -----------------------------------------------------------------------------------------------*/ const ClosePreviewButton = ()=>{
const [{ query }] = useQueryParams();
const { formatMessage } = useIntl();
const canGoBack = useHistory('BackButton', (state)=>state.canGoBack);
const goBack = useHistory('BackButton', (state)=>state.goBack);
const history = useHistory('BackButton', (state)=>state.history);
const locationIndex = useHistory('BackButton', (state)=>state.currentLocationIndex);
/**
* Get the link destination from the history.
* Rely on a fallback (the parent edit view page) if there's no page to go back .
*/ const historyTo = canGoBack ? history.at(locationIndex - 2) : undefined;
const fallback = {
pathname: '..',
search: stringify(query, {
encode: false
})
};
const toWithFallback = historyTo ?? fallback;
const handleClick = (e)=>{
if (canGoBack) {
// Prevent normal link behavior, go back in the history stack instead
e.preventDefault();
goBack();
return;
}
// Otherwise rely on native link behavior to go back to the edit view. We don't use navigate()
// here in order to get the relative="path" functionality from the Link component.
};
return /*#__PURE__*/ jsx(IconButton, {
variant: "ghost",
tag: Link$1,
relative: "path",
to: toWithFallback,
onClick: handleClick,
label: formatMessage({
id: 'content-manager.preview.header.close',
defaultMessage: 'Close preview'
}),
children: /*#__PURE__*/ jsx(Cross, {})
});
};
/* -------------------------------------------------------------------------------------------------
* Status
* -----------------------------------------------------------------------------------------------*/ const Status = ()=>{
// Get status
const document = usePreviewContext('PreviewHeader', (state)=>state.document);
const schema = usePreviewContext('PreviewHeader', (state)=>state.schema);
const meta = usePreviewContext('PreviewHeader', (state)=>state.meta);
const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;
if (!hasDraftAndPublished) {
return null;
}
const status = getDocumentStatus(document, meta);
return /*#__PURE__*/ jsx(DocumentStatus, {
status: status,
size: "XS"
});
};
const PreviewTabs = ()=>{
const { formatMessage } = useIntl();
// URL query params
const [{ query }, setQuery] = useQueryParams();
// Get status
const document = usePreviewContext('PreviewHeader', (state)=>state.document);
const schema = usePreviewContext('PreviewHeader', (state)=>state.schema);
const meta = usePreviewContext('PreviewHeader', (state)=>state.meta);
const hasDraftAndPublish = schema?.options?.draftAndPublish ?? false;
const documentStatus = getDocumentStatus(document, meta);
const handleTabChange = (status)=>{
if (status === 'published' || status === 'draft') {
setQuery({
status
}, 'push', true);
}
};
if (!hasDraftAndPublish) {
return null;
}
return /*#__PURE__*/ jsx(Tabs.Root, {
variant: "simple",
value: query.status || 'draft',
onValueChange: handleTabChange,
children: /*#__PURE__*/ jsxs(Tabs.List, {
"aria-label": formatMessage({
id: 'preview.tabs.label',
defaultMessage: 'Document status'
}),
children: [
/*#__PURE__*/ jsx(StatusTab, {
value: "draft",
children: formatMessage({
id: 'content-manager.containers.List.draft',
defaultMessage: 'draft'
})
}),
/*#__PURE__*/ jsx(StatusTab, {
value: "published",
disabled: documentStatus === 'draft',
children: formatMessage({
id: 'content-manager.containers.List.published',
defaultMessage: 'published'
})
})
]
})
});
};
/* -------------------------------------------------------------------------------------------------
* PreviewHeader
* -----------------------------------------------------------------------------------------------*/ const PreviewHeader = ()=>{
const title = usePreviewContext('PreviewHeader', (state)=>state.title);
const document = usePreviewContext('PreviewHeader', (state)=>state.document);
const schema = usePreviewContext('PreviewHeader', (state)=>state.schema);
const meta = usePreviewContext('PreviewHeader', (state)=>state.meta);
usePreviewContext('PreviewHeader', (state)=>state.onPreview);
const plugins = useStrapiApp('PreviewHeader', (state)=>state.plugins);
const [{ query }] = useQueryParams();
const { formatMessage } = useIntl();
const { toggleNotification } = useNotification();
const { copy } = useClipboard();
const handleCopyLink = ()=>{
copy(window.location.href);
toggleNotification({
message: formatMessage({
id: 'content-manager.preview.copy.success',
defaultMessage: 'Copied preview link'
}),
type: 'success'
});
};
const hasDraftAndPublish = schema.options?.draftAndPublish ?? false;
const documentActionProps = {
activeTab: query.status ?? null,
collectionType: schema.kind === 'collectionType' ? 'collection-types' : 'single-types',
model: schema.uid,
documentId: schema.kind === 'collectionType' ? document.documentId : undefined,
document,
meta
};
return /*#__PURE__*/ jsxs(Flex, {
height: "48px",
gap: 4,
background: "neutral0",
borderColor: "neutral150",
tag: "header",
children: [
/*#__PURE__*/ jsxs(TitleContainer, {
height: "100%",
paddingLeft: 2,
paddingRight: 4,
children: [
/*#__PURE__*/ jsx(ClosePreviewButton, {}),
/*#__PURE__*/ jsx(PreviewTitle, {
tag: "h1",
title: title,
maxWidth: "200px",
fontSize: 2,
paddingLeft: 2,
paddingRight: 3,
fontWeight: 600,
children: title
}),
/*#__PURE__*/ jsx(Status, {})
]
}),
/*#__PURE__*/ jsxs(Flex, {
flex: 1,
paddingRight: 2,
gap: 2,
justifyContent: hasDraftAndPublish ? 'space-between' : 'flex-end',
children: [
/*#__PURE__*/ jsx(Flex, {
flex: "1 1 70%",
children: /*#__PURE__*/ jsx(PreviewTabs, {})
}),
/*#__PURE__*/ jsxs(Flex, {
gap: 2,
children: [
/*#__PURE__*/ jsx(IconButton, {
type: "button",
label: formatMessage({
id: 'preview.copy.label',
defaultMessage: 'Copy preview link'
}),
onClick: handleCopyLink,
children: /*#__PURE__*/ jsx(Link, {})
}),
/*#__PURE__*/ jsx(InjectionZone, {
area: "preview.actions"
}),
/*#__PURE__*/ jsx(DescriptionComponentRenderer, {
props: documentActionProps,
descriptions: plugins['content-manager'].apis.getDocumentActions('preview'),
children: (actions)=>{
const filteredActions = actions.filter((action)=>[
action.position
].flat().includes('preview'));
const [primaryAction, secondaryAction] = filteredActions;
if (!primaryAction && !secondaryAction) return null;
// Both actions are available when draft and publish enabled
if (primaryAction && secondaryAction) {
return /*#__PURE__*/ jsxs(Fragment, {
children: [
/*#__PURE__*/ jsx(DocumentActionButton, {
...secondaryAction,
variant: secondaryAction.variant || 'secondary'
}),
/*#__PURE__*/ jsx(DocumentActionButton, {
...primaryAction,
variant: primaryAction.variant || 'default'
})
]
});
}
// Otherwise we just have the save action
return /*#__PURE__*/ jsx(DocumentActionButton, {
...primaryAction,
variant: primaryAction.variant || 'secondary'
});
}
})
]
})
]
})
]
});
};
const PreviewTitle = styled(Typography)`
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`;
const StatusTab = styled(Tabs.Trigger)`
text-transform: uppercase;
`;
const TitleContainer = styled(Flex)`
border-right: 1px solid ${({ theme })=>theme.colors.neutral150};
`;
export { PreviewHeader };
//# sourceMappingURL=PreviewHeader.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,91 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
require('react');
var strapiAdmin = require('@strapi/admin/strapi-admin');
var designSystem = require('@strapi/design-system');
var qs = require('qs');
var reactIntl = require('react-intl');
var reactRouterDom = require('react-router-dom');
var preview = require('../services/preview.js');
const ConditionalTooltip = ({ isShown, label, children })=>{
if (isShown) {
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Tooltip, {
label: label,
children: children
});
}
return children;
};
const PreviewSidePanel = ({ model, documentId, document })=>{
const { formatMessage } = reactIntl.useIntl();
const { trackUsage } = strapiAdmin.useTracking();
const { pathname } = reactRouterDom.useLocation();
const [{ query }] = strapiAdmin.useQueryParams();
const isModified = strapiAdmin.useForm('PreviewSidePanel', (state)=>state.modified);
/**
* The preview URL isn't used in this component, we just fetch it to know if preview is enabled
* for the content type. If it's not, the panel is not displayed. If it is, we display a link to
* /preview, and the URL will already be loaded in the RTK query cache.
*/ const { data, error } = preview.useGetPreviewUrlQuery({
params: {
contentType: model
},
query: {
documentId,
locale: document?.locale,
status: document?.status
}
});
if (!data?.data?.url || error) {
return null;
}
const trackNavigation = ()=>{
// Append /preview to the current URL
const destinationPathname = pathname.replace(/\/$/, '') + '/preview';
trackUsage('willNavigate', {
from: pathname,
to: destinationPathname
});
};
return {
title: formatMessage({
id: 'content-manager.preview.panel.title',
defaultMessage: 'Preview'
}),
content: /*#__PURE__*/ jsxRuntime.jsx(ConditionalTooltip, {
label: formatMessage({
id: 'content-manager.preview.panel.button-disabled-tooltip',
defaultMessage: 'Please save to open the preview'
}),
isShown: isModified,
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
cursor: "not-allowed",
width: "100%",
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
variant: "tertiary",
tag: reactRouterDom.Link,
to: {
pathname: 'preview',
search: qs.stringify(query, {
encode: false
})
},
onClick: trackNavigation,
width: "100%",
disabled: isModified,
pointerEvents: isModified ? 'none' : undefined,
tabIndex: isModified ? -1 : undefined,
children: formatMessage({
id: 'content-manager.preview.panel.button',
defaultMessage: 'Open preview'
})
})
})
})
};
};
exports.PreviewSidePanel = PreviewSidePanel;
//# sourceMappingURL=PreviewSidePanel.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,89 @@
import { jsx } from 'react/jsx-runtime';
import 'react';
import { useTracking, useQueryParams, useForm } from '@strapi/admin/strapi-admin';
import { Box, Button, Tooltip } from '@strapi/design-system';
import { stringify } from 'qs';
import { useIntl } from 'react-intl';
import { useLocation, Link } from 'react-router-dom';
import { useGetPreviewUrlQuery } from '../services/preview.mjs';
const ConditionalTooltip = ({ isShown, label, children })=>{
if (isShown) {
return /*#__PURE__*/ jsx(Tooltip, {
label: label,
children: children
});
}
return children;
};
const PreviewSidePanel = ({ model, documentId, document })=>{
const { formatMessage } = useIntl();
const { trackUsage } = useTracking();
const { pathname } = useLocation();
const [{ query }] = useQueryParams();
const isModified = useForm('PreviewSidePanel', (state)=>state.modified);
/**
* The preview URL isn't used in this component, we just fetch it to know if preview is enabled
* for the content type. If it's not, the panel is not displayed. If it is, we display a link to
* /preview, and the URL will already be loaded in the RTK query cache.
*/ const { data, error } = useGetPreviewUrlQuery({
params: {
contentType: model
},
query: {
documentId,
locale: document?.locale,
status: document?.status
}
});
if (!data?.data?.url || error) {
return null;
}
const trackNavigation = ()=>{
// Append /preview to the current URL
const destinationPathname = pathname.replace(/\/$/, '') + '/preview';
trackUsage('willNavigate', {
from: pathname,
to: destinationPathname
});
};
return {
title: formatMessage({
id: 'content-manager.preview.panel.title',
defaultMessage: 'Preview'
}),
content: /*#__PURE__*/ jsx(ConditionalTooltip, {
label: formatMessage({
id: 'content-manager.preview.panel.button-disabled-tooltip',
defaultMessage: 'Please save to open the preview'
}),
isShown: isModified,
children: /*#__PURE__*/ jsx(Box, {
cursor: "not-allowed",
width: "100%",
children: /*#__PURE__*/ jsx(Button, {
variant: "tertiary",
tag: Link,
to: {
pathname: 'preview',
search: stringify(query, {
encode: false
})
},
onClick: trackNavigation,
width: "100%",
disabled: isModified,
pointerEvents: isModified ? 'none' : undefined,
tabIndex: isModified ? -1 : undefined,
children: formatMessage({
id: 'content-manager.preview.panel.button',
defaultMessage: 'Open preview'
})
})
})
})
};
};
export { PreviewSidePanel };
//# sourceMappingURL=PreviewSidePanel.mjs.map

File diff suppressed because one or more lines are too long