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,176 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
require('react');
var designSystem = require('@strapi/design-system');
var Icons = require('@strapi/icons');
var Symbols = require('@strapi/icons/symbols');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var Icons__namespace = /*#__PURE__*/_interopNamespaceDefault(Icons);
var Symbols__namespace = /*#__PURE__*/_interopNamespaceDefault(Symbols);
const ComponentIcon = ({ showBackground = true, icon = 'dashboard', ...props })=>{
const Icon = COMPONENT_ICONS[icon] || COMPONENT_ICONS.dashboard;
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
alignItems: "center",
background: showBackground ? 'neutral200' : undefined,
justifyContent: "center",
height: 8,
width: 8,
color: "neutral600",
borderRadius: showBackground ? '50%' : 0,
...props,
children: /*#__PURE__*/ jsxRuntime.jsx(Icon, {
height: "2rem",
width: "2rem"
})
});
};
const COMPONENT_ICONS = {
alien: Icons__namespace.Alien,
apps: Icons__namespace.GridNine,
archive: Icons__namespace.Archive,
arrowDown: Icons__namespace.ArrowDown,
arrowLeft: Icons__namespace.ArrowLeft,
arrowRight: Icons__namespace.ArrowRight,
arrowUp: Icons__namespace.ArrowUp,
attachment: Icons__namespace.Paperclip,
bell: Icons__namespace.Bell,
bold: Icons__namespace.Bold,
book: Icons__namespace.Book,
briefcase: Icons__namespace.Briefcase,
brush: Icons__namespace.PaintBrush,
bulletList: Icons__namespace.BulletList,
calendar: Icons__namespace.Calendar,
car: Icons__namespace.Car,
cast: Icons__namespace.Cast,
chartBubble: Icons__namespace.ChartBubble,
chartCircle: Icons__namespace.ChartCircle,
chartPie: Icons__namespace.ChartPie,
check: Icons__namespace.Check,
clock: Icons__namespace.Clock,
cloud: Icons__namespace.Cloud,
code: Icons__namespace.Code,
cog: Icons__namespace.Cog,
collapse: Icons__namespace.Collapse,
command: Icons__namespace.Command,
connector: Icons__namespace.Faders,
crop: Icons__namespace.Crop,
crown: Icons__namespace.Crown,
cup: Icons__namespace.Coffee,
cursor: Icons__namespace.Cursor,
dashboard: Icons__namespace.SquaresFour,
database: Icons__namespace.Database,
discuss: Icons__namespace.Discuss,
doctor: Icons__namespace.Stethoscope,
earth: Icons__namespace.Earth,
emotionHappy: Icons__namespace.EmotionHappy,
emotionUnhappy: Icons__namespace.EmotionUnhappy,
envelop: Icons__namespace.Mail,
exit: Icons__namespace.SignOut,
expand: Icons__namespace.Expand,
eye: Icons__namespace.Eye,
feather: Icons__namespace.Feather,
file: Icons__namespace.File,
fileError: Icons__namespace.FileError,
filePdf: Icons__namespace.FilePdf,
filter: Icons__namespace.Filter,
folder: Icons__namespace.Folder,
gate: Icons__namespace.CastleTurret,
gift: Icons__namespace.Gift,
globe: Icons__namespace.Globe,
grid: Icons__namespace.GridFour,
handHeart: Icons__namespace.HandHeart,
hashtag: Icons__namespace.Hashtag,
headphone: Icons__namespace.Headphones,
heart: Icons__namespace.Heart,
house: Icons__namespace.House,
information: Icons__namespace.Information,
italic: Icons__namespace.Italic,
key: Icons__namespace.Key,
landscape: Icons__namespace.Images,
layer: Icons__namespace.ListPlus,
layout: Icons__namespace.Layout,
lightbulb: Icons__namespace.Lightbulb,
link: Icons__namespace.Link,
lock: Icons__namespace.Lock,
magic: Icons__namespace.Magic,
manyToMany: Icons__namespace.ManyToMany,
manyToOne: Icons__namespace.ManyToOne,
manyWays: Icons__namespace.ManyWays,
medium: Symbols__namespace.Medium,
message: Icons__namespace.Message,
microphone: Icons__namespace.Microphone,
monitor: Icons__namespace.Monitor,
moon: Icons__namespace.Moon,
music: Icons__namespace.MusicNotes,
oneToMany: Icons__namespace.OneToMany,
oneToOne: Icons__namespace.OneToOne,
oneWay: Icons__namespace.OneWay,
paint: Icons__namespace.PaintBrush,
paintBrush: Icons__namespace.PaintBrush,
paperPlane: Icons__namespace.PaperPlane,
pencil: Icons__namespace.Pencil,
phone: Icons__namespace.Phone,
picture: Icons__namespace.Image,
pin: Icons__namespace.Pin,
pinMap: Icons__namespace.PinMap,
plane: Icons__namespace.Plane,
play: Icons__namespace.Play,
plus: Icons__namespace.Plus,
priceTag: Icons__namespace.PriceTag,
puzzle: Icons__namespace.PuzzlePiece,
question: Icons__namespace.Question,
quote: Icons__namespace.Quotes,
refresh: Icons__namespace.ArrowClockwise,
restaurant: Icons__namespace.Restaurant,
rocket: Icons__namespace.Rocket,
rotate: Icons__namespace.ArrowsCounterClockwise,
scissors: Icons__namespace.Scissors,
search: Icons__namespace.Search,
seed: Icons__namespace.Plant,
server: Icons__namespace.Server,
shield: Icons__namespace.Shield,
shirt: Icons__namespace.Shirt,
shoppingCart: Icons__namespace.ShoppingCart,
slideshow: Icons__namespace.PresentationChart,
stack: Icons__namespace.Stack,
star: Icons__namespace.Star,
store: Icons__namespace.Store,
strikeThrough: Icons__namespace.StrikeThrough,
sun: Icons__namespace.Sun,
television: Icons__namespace.Television,
thumbDown: Icons__namespace.ThumbDown,
thumbUp: Icons__namespace.ThumbUp,
train: Icons__namespace.Train,
twitter: Symbols__namespace.X,
typhoon: Icons__namespace.Typhoon,
underline: Icons__namespace.Underline,
user: Icons__namespace.User,
volumeMute: Icons__namespace.VolumeMute,
volumeUp: Icons__namespace.VolumeUp,
walk: Icons__namespace.Walk,
wheelchair: Icons__namespace.Wheelchair,
write: Icons__namespace.Feather
};
exports.COMPONENT_ICONS = COMPONENT_ICONS;
exports.ComponentIcon = ComponentIcon;
//# sourceMappingURL=ComponentIcon.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,153 @@
import { jsx } from 'react/jsx-runtime';
import 'react';
import { Flex } from '@strapi/design-system';
import * as Icons from '@strapi/icons';
import * as Symbols from '@strapi/icons/symbols';
const ComponentIcon = ({ showBackground = true, icon = 'dashboard', ...props })=>{
const Icon = COMPONENT_ICONS[icon] || COMPONENT_ICONS.dashboard;
return /*#__PURE__*/ jsx(Flex, {
alignItems: "center",
background: showBackground ? 'neutral200' : undefined,
justifyContent: "center",
height: 8,
width: 8,
color: "neutral600",
borderRadius: showBackground ? '50%' : 0,
...props,
children: /*#__PURE__*/ jsx(Icon, {
height: "2rem",
width: "2rem"
})
});
};
const COMPONENT_ICONS = {
alien: Icons.Alien,
apps: Icons.GridNine,
archive: Icons.Archive,
arrowDown: Icons.ArrowDown,
arrowLeft: Icons.ArrowLeft,
arrowRight: Icons.ArrowRight,
arrowUp: Icons.ArrowUp,
attachment: Icons.Paperclip,
bell: Icons.Bell,
bold: Icons.Bold,
book: Icons.Book,
briefcase: Icons.Briefcase,
brush: Icons.PaintBrush,
bulletList: Icons.BulletList,
calendar: Icons.Calendar,
car: Icons.Car,
cast: Icons.Cast,
chartBubble: Icons.ChartBubble,
chartCircle: Icons.ChartCircle,
chartPie: Icons.ChartPie,
check: Icons.Check,
clock: Icons.Clock,
cloud: Icons.Cloud,
code: Icons.Code,
cog: Icons.Cog,
collapse: Icons.Collapse,
command: Icons.Command,
connector: Icons.Faders,
crop: Icons.Crop,
crown: Icons.Crown,
cup: Icons.Coffee,
cursor: Icons.Cursor,
dashboard: Icons.SquaresFour,
database: Icons.Database,
discuss: Icons.Discuss,
doctor: Icons.Stethoscope,
earth: Icons.Earth,
emotionHappy: Icons.EmotionHappy,
emotionUnhappy: Icons.EmotionUnhappy,
envelop: Icons.Mail,
exit: Icons.SignOut,
expand: Icons.Expand,
eye: Icons.Eye,
feather: Icons.Feather,
file: Icons.File,
fileError: Icons.FileError,
filePdf: Icons.FilePdf,
filter: Icons.Filter,
folder: Icons.Folder,
gate: Icons.CastleTurret,
gift: Icons.Gift,
globe: Icons.Globe,
grid: Icons.GridFour,
handHeart: Icons.HandHeart,
hashtag: Icons.Hashtag,
headphone: Icons.Headphones,
heart: Icons.Heart,
house: Icons.House,
information: Icons.Information,
italic: Icons.Italic,
key: Icons.Key,
landscape: Icons.Images,
layer: Icons.ListPlus,
layout: Icons.Layout,
lightbulb: Icons.Lightbulb,
link: Icons.Link,
lock: Icons.Lock,
magic: Icons.Magic,
manyToMany: Icons.ManyToMany,
manyToOne: Icons.ManyToOne,
manyWays: Icons.ManyWays,
medium: Symbols.Medium,
message: Icons.Message,
microphone: Icons.Microphone,
monitor: Icons.Monitor,
moon: Icons.Moon,
music: Icons.MusicNotes,
oneToMany: Icons.OneToMany,
oneToOne: Icons.OneToOne,
oneWay: Icons.OneWay,
paint: Icons.PaintBrush,
paintBrush: Icons.PaintBrush,
paperPlane: Icons.PaperPlane,
pencil: Icons.Pencil,
phone: Icons.Phone,
picture: Icons.Image,
pin: Icons.Pin,
pinMap: Icons.PinMap,
plane: Icons.Plane,
play: Icons.Play,
plus: Icons.Plus,
priceTag: Icons.PriceTag,
puzzle: Icons.PuzzlePiece,
question: Icons.Question,
quote: Icons.Quotes,
refresh: Icons.ArrowClockwise,
restaurant: Icons.Restaurant,
rocket: Icons.Rocket,
rotate: Icons.ArrowsCounterClockwise,
scissors: Icons.Scissors,
search: Icons.Search,
seed: Icons.Plant,
server: Icons.Server,
shield: Icons.Shield,
shirt: Icons.Shirt,
shoppingCart: Icons.ShoppingCart,
slideshow: Icons.PresentationChart,
stack: Icons.Stack,
star: Icons.Star,
store: Icons.Store,
strikeThrough: Icons.StrikeThrough,
sun: Icons.Sun,
television: Icons.Television,
thumbDown: Icons.ThumbDown,
thumbUp: Icons.ThumbUp,
train: Icons.Train,
twitter: Symbols.X,
typhoon: Icons.Typhoon,
underline: Icons.Underline,
user: Icons.User,
volumeMute: Icons.VolumeMute,
volumeUp: Icons.VolumeUp,
walk: Icons.Walk,
wheelchair: Icons.Wheelchair,
write: Icons.Feather
};
export { COMPONENT_ICONS, ComponentIcon };
//# sourceMappingURL=ComponentIcon.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,259 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var strapiAdmin = require('@strapi/admin/strapi-admin');
var designSystem = require('@strapi/design-system');
var reactIntl = require('react-intl');
var yup = require('yup');
var attributes = require('../../constants/attributes.js');
var init = require('../../services/init.js');
var strings = require('../../utils/strings.js');
var translations = require('../../utils/translations.js');
var FieldTypeIcon = require('../FieldTypeIcon.js');
var Fields = require('./Fields.js');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup);
/* -------------------------------------------------------------------------------------------------
* Constants
* -----------------------------------------------------------------------------------------------*/ const FIELD_SCHEMA = yup__namespace.object().shape({
label: yup__namespace.string().required().nullable(),
description: yup__namespace.string(),
editable: yup__namespace.boolean(),
size: yup__namespace.number().required()
});
const EditFieldForm = ({ attribute, name, onClose })=>{
const { formatMessage } = reactIntl.useIntl();
const { toggleNotification } = strapiAdmin.useNotification();
const { value, onChange } = strapiAdmin.useField(name);
const { data: mainFieldOptions } = init.useGetInitialDataQuery(undefined, {
selectFromResult: (res)=>{
if (attribute?.type !== 'relation' || !res.data) {
return {
data: []
};
}
if ('targetModel' in attribute && typeof attribute.targetModel === 'string') {
const targetSchema = res.data.contentTypes.find((schema)=>schema.uid === attribute.targetModel);
if (targetSchema) {
return {
data: Object.entries(targetSchema.attributes).reduce((acc, [key, attribute])=>{
/**
* Create the list of attributes from the schema as to which can
* be our `mainField` and dictate the display name of the schema
* we're editing.
*/ if (!attributes.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD.includes(attribute.type)) {
acc.push({
label: key,
value: key
});
}
return acc;
}, [])
};
}
}
return {
data: []
};
},
skip: attribute?.type !== 'relation'
});
if (!value || value.name === Fields.TEMP_FIELD_NAME || !attribute) {
// This is very unlikely to happen, but it ensures the form is not opened without a value.
console.error("You've opened a field to edit without it being part of the form, this is likely a bug with Strapi. Please open an issue.");
toggleNotification({
message: formatMessage({
id: 'content-manager.containers.edit-settings.modal-form.error',
defaultMessage: 'An error occurred while trying to open the form.'
}),
type: 'danger'
});
return null;
}
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Content, {
children: /*#__PURE__*/ jsxRuntime.jsxs(strapiAdmin.Form, {
method: "PUT",
initialValues: value,
validationSchema: FIELD_SCHEMA,
onSubmit: (data)=>{
onChange(name, data);
onClose();
},
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Header, {
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
gap: 3,
children: [
/*#__PURE__*/ jsxRuntime.jsx(FieldTypeIcon.FieldTypeIcon, {
type: attribute.type
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Title, {
children: formatMessage({
id: 'content-manager.containers.edit-settings.modal-form.label',
defaultMessage: 'Edit {fieldName}'
}, {
fieldName: strings.capitalise(value.name)
})
})
]
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Body, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Root, {
gap: 4,
children: [
{
name: 'label',
label: formatMessage({
id: translations.getTranslation('containers.edit-settings.modal-form.label'),
defaultMessage: 'Label'
}),
size: 6,
type: 'string'
},
{
name: 'description',
label: formatMessage({
id: translations.getTranslation('containers.edit-settings.modal-form.description'),
defaultMessage: 'Description'
}),
size: 6,
type: 'string'
},
{
name: 'placeholder',
label: formatMessage({
id: translations.getTranslation('containers.edit-settings.modal-form.placeholder'),
defaultMessage: 'Placeholder'
}),
size: 6,
type: 'string'
},
{
name: 'editable',
label: formatMessage({
id: translations.getTranslation('containers.edit-settings.modal-form.editable'),
defaultMessage: 'Editable'
}),
size: 6,
type: 'boolean'
},
{
name: 'mainField',
label: formatMessage({
id: translations.getTranslation('containers.edit-settings.modal-form.mainField'),
defaultMessage: 'Entry title'
}),
hint: formatMessage({
id: translations.getTranslation('containers.SettingPage.edit-settings.modal-form.mainField.hint'),
defaultMessage: 'Set the displayed field'
}),
size: 6,
options: mainFieldOptions,
type: 'enumeration'
},
{
name: 'size',
label: formatMessage({
id: translations.getTranslation('containers.ListSettingsView.modal-form.size'),
defaultMessage: 'Size'
}),
size: 6,
options: [
{
value: '4',
label: '33%'
},
{
value: '6',
label: '50%'
},
{
value: '8',
label: '66%'
},
{
value: '12',
label: '100%'
}
],
type: 'enumeration'
}
].filter(filterFieldsBasedOnAttributeType(attribute.type)).map(({ size, ...field })=>/*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
col: size,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.InputRenderer, {
...field
})
}, field.name))
})
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Modal.Footer, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Close, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
variant: "tertiary",
children: formatMessage({
id: 'app.components.Button.cancel',
defaultMessage: 'Cancel'
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
type: "submit",
children: formatMessage({
id: 'global.finish',
defaultMessage: 'Finish'
})
})
]
})
]
})
});
};
/**
* @internal
* @description not all edit fields have the same editable properties, it depends on the type
* e.g. a dynamic zone can only change it's label.
*/ const filterFieldsBasedOnAttributeType = (type)=>(field)=>{
switch(type){
case 'blocks':
case 'richtext':
return field.name !== 'size' && field.name !== 'mainField';
case 'boolean':
case 'media':
return field.name !== 'placeholder' && field.name !== 'mainField';
case 'component':
case 'dynamiczone':
return field.name === 'label' || field.name === 'editable';
case 'json':
return field.name !== 'placeholder' && field.name !== 'mainField' && field.name !== 'size';
case 'relation':
return true;
default:
return field.name !== 'mainField';
}
};
exports.EditFieldForm = EditFieldForm;
//# sourceMappingURL=EditFieldForm.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,238 @@
import { jsx, jsxs } from 'react/jsx-runtime';
import { useNotification, useField, Form, InputRenderer } from '@strapi/admin/strapi-admin';
import { Modal, Flex, Grid, Button } from '@strapi/design-system';
import { useIntl } from 'react-intl';
import * as yup from 'yup';
import { ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD } from '../../constants/attributes.mjs';
import { useGetInitialDataQuery } from '../../services/init.mjs';
import { capitalise } from '../../utils/strings.mjs';
import { getTranslation } from '../../utils/translations.mjs';
import { FieldTypeIcon } from '../FieldTypeIcon.mjs';
import { TEMP_FIELD_NAME } from './Fields.mjs';
/* -------------------------------------------------------------------------------------------------
* Constants
* -----------------------------------------------------------------------------------------------*/ const FIELD_SCHEMA = yup.object().shape({
label: yup.string().required().nullable(),
description: yup.string(),
editable: yup.boolean(),
size: yup.number().required()
});
const EditFieldForm = ({ attribute, name, onClose })=>{
const { formatMessage } = useIntl();
const { toggleNotification } = useNotification();
const { value, onChange } = useField(name);
const { data: mainFieldOptions } = useGetInitialDataQuery(undefined, {
selectFromResult: (res)=>{
if (attribute?.type !== 'relation' || !res.data) {
return {
data: []
};
}
if ('targetModel' in attribute && typeof attribute.targetModel === 'string') {
const targetSchema = res.data.contentTypes.find((schema)=>schema.uid === attribute.targetModel);
if (targetSchema) {
return {
data: Object.entries(targetSchema.attributes).reduce((acc, [key, attribute])=>{
/**
* Create the list of attributes from the schema as to which can
* be our `mainField` and dictate the display name of the schema
* we're editing.
*/ if (!ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD.includes(attribute.type)) {
acc.push({
label: key,
value: key
});
}
return acc;
}, [])
};
}
}
return {
data: []
};
},
skip: attribute?.type !== 'relation'
});
if (!value || value.name === TEMP_FIELD_NAME || !attribute) {
// This is very unlikely to happen, but it ensures the form is not opened without a value.
console.error("You've opened a field to edit without it being part of the form, this is likely a bug with Strapi. Please open an issue.");
toggleNotification({
message: formatMessage({
id: 'content-manager.containers.edit-settings.modal-form.error',
defaultMessage: 'An error occurred while trying to open the form.'
}),
type: 'danger'
});
return null;
}
return /*#__PURE__*/ jsx(Modal.Content, {
children: /*#__PURE__*/ jsxs(Form, {
method: "PUT",
initialValues: value,
validationSchema: FIELD_SCHEMA,
onSubmit: (data)=>{
onChange(name, data);
onClose();
},
children: [
/*#__PURE__*/ jsx(Modal.Header, {
children: /*#__PURE__*/ jsxs(Flex, {
gap: 3,
children: [
/*#__PURE__*/ jsx(FieldTypeIcon, {
type: attribute.type
}),
/*#__PURE__*/ jsx(Modal.Title, {
children: formatMessage({
id: 'content-manager.containers.edit-settings.modal-form.label',
defaultMessage: 'Edit {fieldName}'
}, {
fieldName: capitalise(value.name)
})
})
]
})
}),
/*#__PURE__*/ jsx(Modal.Body, {
children: /*#__PURE__*/ jsx(Grid.Root, {
gap: 4,
children: [
{
name: 'label',
label: formatMessage({
id: getTranslation('containers.edit-settings.modal-form.label'),
defaultMessage: 'Label'
}),
size: 6,
type: 'string'
},
{
name: 'description',
label: formatMessage({
id: getTranslation('containers.edit-settings.modal-form.description'),
defaultMessage: 'Description'
}),
size: 6,
type: 'string'
},
{
name: 'placeholder',
label: formatMessage({
id: getTranslation('containers.edit-settings.modal-form.placeholder'),
defaultMessage: 'Placeholder'
}),
size: 6,
type: 'string'
},
{
name: 'editable',
label: formatMessage({
id: getTranslation('containers.edit-settings.modal-form.editable'),
defaultMessage: 'Editable'
}),
size: 6,
type: 'boolean'
},
{
name: 'mainField',
label: formatMessage({
id: getTranslation('containers.edit-settings.modal-form.mainField'),
defaultMessage: 'Entry title'
}),
hint: formatMessage({
id: getTranslation('containers.SettingPage.edit-settings.modal-form.mainField.hint'),
defaultMessage: 'Set the displayed field'
}),
size: 6,
options: mainFieldOptions,
type: 'enumeration'
},
{
name: 'size',
label: formatMessage({
id: getTranslation('containers.ListSettingsView.modal-form.size'),
defaultMessage: 'Size'
}),
size: 6,
options: [
{
value: '4',
label: '33%'
},
{
value: '6',
label: '50%'
},
{
value: '8',
label: '66%'
},
{
value: '12',
label: '100%'
}
],
type: 'enumeration'
}
].filter(filterFieldsBasedOnAttributeType(attribute.type)).map(({ size, ...field })=>/*#__PURE__*/ jsx(Grid.Item, {
col: size,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsx(InputRenderer, {
...field
})
}, field.name))
})
}),
/*#__PURE__*/ jsxs(Modal.Footer, {
children: [
/*#__PURE__*/ jsx(Modal.Close, {
children: /*#__PURE__*/ jsx(Button, {
variant: "tertiary",
children: formatMessage({
id: 'app.components.Button.cancel',
defaultMessage: 'Cancel'
})
})
}),
/*#__PURE__*/ jsx(Button, {
type: "submit",
children: formatMessage({
id: 'global.finish',
defaultMessage: 'Finish'
})
})
]
})
]
})
});
};
/**
* @internal
* @description not all edit fields have the same editable properties, it depends on the type
* e.g. a dynamic zone can only change it's label.
*/ const filterFieldsBasedOnAttributeType = (type)=>(field)=>{
switch(type){
case 'blocks':
case 'richtext':
return field.name !== 'size' && field.name !== 'mainField';
case 'boolean':
case 'media':
return field.name !== 'placeholder' && field.name !== 'mainField';
case 'component':
case 'dynamiczone':
return field.name === 'label' || field.name === 'editable';
case 'json':
return field.name !== 'placeholder' && field.name !== 'mainField' && field.name !== 'size';
case 'relation':
return true;
default:
return field.name !== 'mainField';
}
};
export { EditFieldForm };
//# sourceMappingURL=EditFieldForm.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,534 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var strapiAdmin = require('@strapi/admin/strapi-admin');
var designSystem = require('@strapi/design-system');
var Icons = require('@strapi/icons');
var fractionalIndexing = require('fractional-indexing');
var reactDndHtml5Backend = require('react-dnd-html5-backend');
var reactIntl = require('react-intl');
var reactRouterDom = require('react-router-dom');
var styledComponents = require('styled-components');
var dragAndDrop = require('../../constants/dragAndDrop.js');
var useDragAndDrop = require('../../hooks/useDragAndDrop.js');
var translations = require('../../utils/translations.js');
var ComponentIcon = require('../ComponentIcon.js');
var EditFieldForm = require('./EditFieldForm.js');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
const Fields = ({ attributes, fieldSizes, components, metadatas = {} })=>{
const { formatMessage } = reactIntl.useIntl();
const layout = strapiAdmin.useForm('Fields', (state)=>state.values.layout ?? []);
const onChange = strapiAdmin.useForm('Fields', (state)=>state.onChange);
const addFieldRow = strapiAdmin.useForm('Fields', (state)=>state.addFieldRow);
const removeFieldRow = strapiAdmin.useForm('Fields', (state)=>state.removeFieldRow);
const existingFields = layout.map((row)=>row.children.map((field)=>field.name)).flat();
/**
* Get the fields that are not already in the layout
* But also check that they are visible before we give users
* the option to display them. e.g. `id` is not visible.
*/ const remainingFields = Object.entries(metadatas).reduce((acc, current)=>{
const [name, { visible, ...field }] = current;
if (!existingFields.includes(name) && visible === true) {
const type = attributes[name]?.type;
const size = type ? fieldSizes[type] : 12;
acc.push({
...field,
label: field.label ?? name,
name,
size
});
}
return acc;
}, []);
const handleMoveField = ([newRowIndex, newFieldIndex], [currentRowIndex, currentFieldIndex])=>{
/**
* Because this view has the constraint that the sum of field sizes cannot be greater
* than 12, we don't use the form's method to move field rows, instead, we calculate
* the new layout and set the entire form.
*/ const newLayout = structuredClone(layout);
/**
* Remove field from the current layout space using splice so we have the item
*/ const [field] = newLayout[currentRowIndex].children.splice(currentFieldIndex, 1);
if (!field || field.name === TEMP_FIELD_NAME) {
return;
}
const newRow = newLayout[newRowIndex].children;
const [newFieldKey] = generateNKeysBetween(newRow, 1, currentFieldIndex, newFieldIndex);
/**
* Next we inject the field into it's new row at it's specified index, we then remove the spaces
* if they exist and recalculate into potentially two arrays ONLY if the sizing is now over 12,
* the row and the rest of the row that couldn't fit.
*
* for example, if i have a row of `[{size: 4}, {size: 6}]` and i add `{size: 8}` a index 0,
* the new array will look like `[{size: 8}, {size: 4}, {size: 6}]` which breaks the limit of 12,
* so instead we make two arrays for the new rows `[[{size: 8}, {size: 4}], [{size: 6}]]` which we
* then inject at the original row point with spacers included.
*/ newRow.splice(newFieldIndex, 0, {
...field,
__temp_key__: newFieldKey
});
if (newLayout[newRowIndex].children.reduce((acc, curr)=>acc + curr.size, 0) > 12) {
const recalculatedRows = chunkArray(newLayout[newRowIndex].children.filter((field)=>field.name !== TEMP_FIELD_NAME));
const rowKeys = generateNKeysBetween(newLayout, recalculatedRows.length, currentRowIndex, newRowIndex);
newLayout.splice(newRowIndex, 1, ...recalculatedRows.map((row, index)=>({
__temp_key__: rowKeys[index],
children: row
})));
}
/**
* Now we remove our spacers from the rows so we can understand what dead rows exist:
* - if there's only spacers left
* - there's nothing in the row, e.g. a size 12 field left it.
* These rows are then filtered out.
* After that, we recalculate the spacers for the rows that need them.
*/ const newLayoutWithSpacers = newLayout.map((row)=>({
...row,
children: row.children.filter((field)=>field.name !== TEMP_FIELD_NAME)
})).filter((row)=>row.children.length > 0).map((row)=>{
const totalSpaceTaken = row.children.reduce((acc, curr)=>acc + curr.size, 0);
if (totalSpaceTaken < 12) {
const [spacerKey] = fractionalIndexing.generateNKeysBetween(row.children.at(-1)?.__temp_key__, undefined, 1);
return {
...row,
children: [
...row.children,
{
name: TEMP_FIELD_NAME,
size: 12 - totalSpaceTaken,
__temp_key__: spacerKey
}
]
};
}
return row;
});
onChange('layout', newLayoutWithSpacers);
};
const handleRemoveField = (rowIndex, fieldIndex)=>()=>{
if (layout[rowIndex].children.length === 1) {
removeFieldRow(`layout`, rowIndex);
} else {
onChange(`layout.${rowIndex}.children`, [
...layout[rowIndex].children.slice(0, fieldIndex),
...layout[rowIndex].children.slice(fieldIndex + 1)
]);
}
};
const handleAddField = (field)=>()=>{
addFieldRow('layout', {
children: [
field
]
});
};
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
paddingTop: 6,
direction: "column",
alignItems: "stretch",
gap: 4,
children: [
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
alignItems: "flex-start",
direction: "column",
justifyContent: "space-between",
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
fontWeight: "bold",
children: formatMessage({
id: translations.getTranslation('containers.list.displayedFields'),
defaultMessage: 'Displayed fields'
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
variant: "pi",
textColor: "neutral600",
children: formatMessage({
id: 'containers.SettingPage.editSettings.description',
defaultMessage: 'Drag & drop the fields to build the layout'
})
})
]
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
padding: 4,
hasRadius: true,
borderStyle: "dashed",
borderWidth: "1px",
borderColor: "neutral300",
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
direction: "column",
alignItems: "stretch",
gap: 2,
children: [
layout.map((row, rowIndex)=>/*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Root, {
gap: 2,
children: row.children.map(({ size, ...field }, fieldIndex)=>/*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
col: size,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxRuntime.jsx(Field, {
attribute: attributes[field.name],
components: components,
index: [
rowIndex,
fieldIndex
],
name: `layout.${rowIndex}.children.${fieldIndex}`,
onMoveField: handleMoveField,
onRemoveField: handleRemoveField(rowIndex, fieldIndex)
})
}, field.name))
}, row.__temp_key__)),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Menu.Root, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Trigger, {
startIcon: /*#__PURE__*/ jsxRuntime.jsx(Icons.Plus, {}),
endIcon: null,
disabled: remainingFields.length === 0,
fullWidth: true,
variant: "secondary",
children: formatMessage({
id: translations.getTranslation('containers.SettingPage.add.field'),
defaultMessage: 'Insert another field'
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Content, {
children: remainingFields.map((field)=>/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Item, {
onSelect: handleAddField(field),
children: field.label
}, field.name))
})
]
})
]
})
})
]
});
};
/**
* @internal
* @description Small abstraction to solve within an array of fields where you can
* add a field to the beginning or start, move back and forth what it's index range
* should be when calculating it's new temp key
*/ const generateNKeysBetween = (field, count, currInd, newInd)=>{
const startKey = currInd > newInd ? field[newInd - 1]?.__temp_key__ : field[newInd]?.__temp_key__;
const endKey = currInd > newInd ? field[newInd]?.__temp_key__ : field[newInd + 1]?.__temp_key__;
return fractionalIndexing.generateNKeysBetween(startKey, endKey, count);
};
/**
* @internal
* @description chunks a row of layouts by the max size we allow, 12. It does not add the
* spacers again, that should be added separately.
*/ const chunkArray = (array)=>{
const result = [];
let temp = [];
array.reduce((acc, field)=>{
if (acc + field.size > 12) {
result.push(temp);
temp = [
field
];
return field.size;
} else {
temp.push(field);
return acc + field.size;
}
}, 0);
if (temp.length > 0) {
result.push(temp);
}
return result;
};
const TEMP_FIELD_NAME = '_TEMP_';
/**
* Displays a field in the layout with drag options, also
* opens a modal to edit the details of said field.
*/ const Field = ({ attribute, components, name, index, onMoveField, onRemoveField })=>{
const [isModalOpen, setIsModalOpen] = React__namespace.useState(false);
const { formatMessage } = reactIntl.useIntl();
const { value } = strapiAdmin.useField(name);
const [{ isDragging }, objectRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(true, {
dropSensitivity: 'immediate',
type: dragAndDrop.ItemTypes.EDIT_FIELD,
item: {
index,
label: value?.label,
name
},
index,
onMoveItem: onMoveField
});
React__namespace.useEffect(()=>{
dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), {
captureDraggingState: false
});
}, [
dragPreviewRef
]);
const composedRefs = designSystem.useComposedRefs(dragRef, objectRef);
const handleRemoveField = (e)=>{
e.preventDefault();
e.stopPropagation();
onRemoveField(e);
};
const onEditFieldMeta = (e)=>{
e.preventDefault();
e.stopPropagation();
setIsModalOpen(true);
};
const tempRefs = designSystem.useComposedRefs(dropRef, objectRef);
if (!value) {
return null;
}
if (value.name === TEMP_FIELD_NAME) {
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
tag: "span",
height: "100%",
style: {
opacity: 0
},
ref: tempRefs
});
}
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Modal.Root, {
open: isModalOpen,
onOpenChange: setIsModalOpen,
children: [
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
borderColor: "neutral150",
background: "neutral100",
hasRadius: true,
style: {
opacity: isDragging ? 0.5 : 1
},
ref: dropRef,
gap: 3,
cursor: "pointer",
onClick: ()=>{
setIsModalOpen(true);
},
children: [
/*#__PURE__*/ jsxRuntime.jsx(DragButton, {
tag: "span",
withTooltip: false,
label: formatMessage({
id: translations.getTranslation('components.DraggableCard.move.field'),
defaultMessage: 'Move {item}'
}, {
item: value.label
}),
onClick: (e)=>e.stopPropagation(),
ref: composedRefs,
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Drag, {})
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
direction: "column",
alignItems: "flex-start",
grow: 1,
overflow: "hidden",
children: [
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
gap: 3,
justifyContent: "space-between",
width: "100%",
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
ellipsis: true,
fontWeight: "bold",
children: value.label
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
type: "button",
variant: "ghost",
background: "transparent",
onClick: onEditFieldMeta,
withTooltip: false,
label: formatMessage({
id: translations.getTranslation('components.DraggableCard.edit.field'),
defaultMessage: 'Edit {item}'
}, {
item: value.label
}),
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Pencil, {})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
type: "button",
variant: "ghost",
onClick: handleRemoveField,
background: "transparent",
withTooltip: false,
label: formatMessage({
id: translations.getTranslation('components.DraggableCard.delete.field'),
defaultMessage: 'Delete {item}'
}, {
item: value.label
}),
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Cross, {})
})
]
})
]
}),
attribute?.type === 'component' ? /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
paddingTop: 3,
paddingRight: 3,
paddingBottom: 3,
paddingLeft: 0,
alignItems: "flex-start",
direction: "column",
gap: 2,
width: "100%",
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Root, {
gap: 4,
width: "100%",
children: components[attribute.component].layout.map((row)=>row.map(({ size, ...field })=>/*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
col: size,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
alignItems: "center",
background: "neutral0",
paddingTop: 2,
paddingBottom: 2,
paddingLeft: 3,
paddingRight: 3,
hasRadius: true,
borderColor: "neutral200",
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
textColor: "neutral800",
children: field.name
})
})
}, field.name)))
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Link, {
// used to stop the edit form from appearing when we click here.
onClick: (e)=>e.stopPropagation(),
startIcon: /*#__PURE__*/ jsxRuntime.jsx(Icons.Cog, {}),
tag: reactRouterDom.NavLink,
to: `../components/${attribute.component}/configurations/edit`,
children: formatMessage({
id: translations.getTranslation('components.FieldItem.linkToComponentLayout'),
defaultMessage: "Set the component's layout"
})
})
]
}) : null,
attribute?.type === 'dynamiczone' ? /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
paddingTop: 3,
paddingRight: 3,
paddingBottom: 3,
paddingLeft: 0,
alignItems: "flex-start",
gap: 2,
width: "100%",
children: attribute?.components.map((uid)=>/*#__PURE__*/ jsxRuntime.jsxs(ComponentLink, {
// used to stop the edit form from appearing when we click here.
onClick: (e)=>e.stopPropagation(),
to: `../components/${uid}/configurations/edit`,
children: [
/*#__PURE__*/ jsxRuntime.jsx(ComponentIcon.ComponentIcon, {
icon: components[uid].settings.icon
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
fontSize: 1,
textColor: "neutral600",
fontWeight: "bold",
children: components[uid].settings.displayName
})
]
}, uid))
}) : null
]
})
]
}),
value.name !== TEMP_FIELD_NAME && /*#__PURE__*/ jsxRuntime.jsx(EditFieldForm.EditFieldForm, {
attribute: attribute,
name: name,
onClose: ()=>setIsModalOpen(false)
})
]
});
};
const DragButton = styledComponents.styled(designSystem.IconButton)`
height: unset;
align-self: stretch;
display: flex;
align-items: center;
padding: 0;
border: none;
background-color: transparent;
border-radius: 0px;
border-right: 1px solid ${({ theme })=>theme.colors.neutral150};
cursor: all-scroll;
svg {
width: 1.2rem;
height: 1.2rem;
}
`;
const ComponentLink = styledComponents.styled(reactRouterDom.NavLink)`
display: flex;
flex-direction: column;
align-items: center;
gap: ${({ theme })=>theme.spaces[1]};
padding: ${(props)=>props.theme.spaces[2]};
border: 1px solid ${({ theme })=>theme.colors.neutral200};
background: ${({ theme })=>theme.colors.neutral0};
width: 14rem;
border-radius: ${({ theme })=>theme.borderRadius};
text-decoration: none;
&:focus,
&:hover {
${({ theme })=>`
background-color: ${theme.colors.primary100};
border-color: ${theme.colors.primary200};
${designSystem.Typography} {
color: ${theme.colors.primary600};
}
`}
/* > ComponentIcon */
> div:first-child {
background: ${({ theme })=>theme.colors.primary200};
color: ${({ theme })=>theme.colors.primary600};
svg {
path {
fill: ${({ theme })=>theme.colors.primary600};
}
}
}
}
`;
exports.Fields = Fields;
exports.TEMP_FIELD_NAME = TEMP_FIELD_NAME;
//# sourceMappingURL=Fields.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,512 @@
import { jsxs, jsx } from 'react/jsx-runtime';
import * as React from 'react';
import { useForm, useField } from '@strapi/admin/strapi-admin';
import { IconButton, Typography, Flex, Box, Grid, Menu, useComposedRefs, Modal, Link } from '@strapi/design-system';
import { Plus, Drag, Pencil, Cross, Cog } from '@strapi/icons';
import { generateNKeysBetween as generateNKeysBetween$1 } from 'fractional-indexing';
import { getEmptyImage } from 'react-dnd-html5-backend';
import { useIntl } from 'react-intl';
import { NavLink } from 'react-router-dom';
import { styled } from 'styled-components';
import { ItemTypes } from '../../constants/dragAndDrop.mjs';
import { useDragAndDrop } from '../../hooks/useDragAndDrop.mjs';
import { getTranslation } from '../../utils/translations.mjs';
import { ComponentIcon } from '../ComponentIcon.mjs';
import { EditFieldForm } from './EditFieldForm.mjs';
const Fields = ({ attributes, fieldSizes, components, metadatas = {} })=>{
const { formatMessage } = useIntl();
const layout = useForm('Fields', (state)=>state.values.layout ?? []);
const onChange = useForm('Fields', (state)=>state.onChange);
const addFieldRow = useForm('Fields', (state)=>state.addFieldRow);
const removeFieldRow = useForm('Fields', (state)=>state.removeFieldRow);
const existingFields = layout.map((row)=>row.children.map((field)=>field.name)).flat();
/**
* Get the fields that are not already in the layout
* But also check that they are visible before we give users
* the option to display them. e.g. `id` is not visible.
*/ const remainingFields = Object.entries(metadatas).reduce((acc, current)=>{
const [name, { visible, ...field }] = current;
if (!existingFields.includes(name) && visible === true) {
const type = attributes[name]?.type;
const size = type ? fieldSizes[type] : 12;
acc.push({
...field,
label: field.label ?? name,
name,
size
});
}
return acc;
}, []);
const handleMoveField = ([newRowIndex, newFieldIndex], [currentRowIndex, currentFieldIndex])=>{
/**
* Because this view has the constraint that the sum of field sizes cannot be greater
* than 12, we don't use the form's method to move field rows, instead, we calculate
* the new layout and set the entire form.
*/ const newLayout = structuredClone(layout);
/**
* Remove field from the current layout space using splice so we have the item
*/ const [field] = newLayout[currentRowIndex].children.splice(currentFieldIndex, 1);
if (!field || field.name === TEMP_FIELD_NAME) {
return;
}
const newRow = newLayout[newRowIndex].children;
const [newFieldKey] = generateNKeysBetween(newRow, 1, currentFieldIndex, newFieldIndex);
/**
* Next we inject the field into it's new row at it's specified index, we then remove the spaces
* if they exist and recalculate into potentially two arrays ONLY if the sizing is now over 12,
* the row and the rest of the row that couldn't fit.
*
* for example, if i have a row of `[{size: 4}, {size: 6}]` and i add `{size: 8}` a index 0,
* the new array will look like `[{size: 8}, {size: 4}, {size: 6}]` which breaks the limit of 12,
* so instead we make two arrays for the new rows `[[{size: 8}, {size: 4}], [{size: 6}]]` which we
* then inject at the original row point with spacers included.
*/ newRow.splice(newFieldIndex, 0, {
...field,
__temp_key__: newFieldKey
});
if (newLayout[newRowIndex].children.reduce((acc, curr)=>acc + curr.size, 0) > 12) {
const recalculatedRows = chunkArray(newLayout[newRowIndex].children.filter((field)=>field.name !== TEMP_FIELD_NAME));
const rowKeys = generateNKeysBetween(newLayout, recalculatedRows.length, currentRowIndex, newRowIndex);
newLayout.splice(newRowIndex, 1, ...recalculatedRows.map((row, index)=>({
__temp_key__: rowKeys[index],
children: row
})));
}
/**
* Now we remove our spacers from the rows so we can understand what dead rows exist:
* - if there's only spacers left
* - there's nothing in the row, e.g. a size 12 field left it.
* These rows are then filtered out.
* After that, we recalculate the spacers for the rows that need them.
*/ const newLayoutWithSpacers = newLayout.map((row)=>({
...row,
children: row.children.filter((field)=>field.name !== TEMP_FIELD_NAME)
})).filter((row)=>row.children.length > 0).map((row)=>{
const totalSpaceTaken = row.children.reduce((acc, curr)=>acc + curr.size, 0);
if (totalSpaceTaken < 12) {
const [spacerKey] = generateNKeysBetween$1(row.children.at(-1)?.__temp_key__, undefined, 1);
return {
...row,
children: [
...row.children,
{
name: TEMP_FIELD_NAME,
size: 12 - totalSpaceTaken,
__temp_key__: spacerKey
}
]
};
}
return row;
});
onChange('layout', newLayoutWithSpacers);
};
const handleRemoveField = (rowIndex, fieldIndex)=>()=>{
if (layout[rowIndex].children.length === 1) {
removeFieldRow(`layout`, rowIndex);
} else {
onChange(`layout.${rowIndex}.children`, [
...layout[rowIndex].children.slice(0, fieldIndex),
...layout[rowIndex].children.slice(fieldIndex + 1)
]);
}
};
const handleAddField = (field)=>()=>{
addFieldRow('layout', {
children: [
field
]
});
};
return /*#__PURE__*/ jsxs(Flex, {
paddingTop: 6,
direction: "column",
alignItems: "stretch",
gap: 4,
children: [
/*#__PURE__*/ jsxs(Flex, {
alignItems: "flex-start",
direction: "column",
justifyContent: "space-between",
children: [
/*#__PURE__*/ jsx(Typography, {
fontWeight: "bold",
children: formatMessage({
id: getTranslation('containers.list.displayedFields'),
defaultMessage: 'Displayed fields'
})
}),
/*#__PURE__*/ jsx(Typography, {
variant: "pi",
textColor: "neutral600",
children: formatMessage({
id: 'containers.SettingPage.editSettings.description',
defaultMessage: 'Drag & drop the fields to build the layout'
})
})
]
}),
/*#__PURE__*/ jsx(Box, {
padding: 4,
hasRadius: true,
borderStyle: "dashed",
borderWidth: "1px",
borderColor: "neutral300",
children: /*#__PURE__*/ jsxs(Flex, {
direction: "column",
alignItems: "stretch",
gap: 2,
children: [
layout.map((row, rowIndex)=>/*#__PURE__*/ jsx(Grid.Root, {
gap: 2,
children: row.children.map(({ size, ...field }, fieldIndex)=>/*#__PURE__*/ jsx(Grid.Item, {
col: size,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsx(Field, {
attribute: attributes[field.name],
components: components,
index: [
rowIndex,
fieldIndex
],
name: `layout.${rowIndex}.children.${fieldIndex}`,
onMoveField: handleMoveField,
onRemoveField: handleRemoveField(rowIndex, fieldIndex)
})
}, field.name))
}, row.__temp_key__)),
/*#__PURE__*/ jsxs(Menu.Root, {
children: [
/*#__PURE__*/ jsx(Menu.Trigger, {
startIcon: /*#__PURE__*/ jsx(Plus, {}),
endIcon: null,
disabled: remainingFields.length === 0,
fullWidth: true,
variant: "secondary",
children: formatMessage({
id: getTranslation('containers.SettingPage.add.field'),
defaultMessage: 'Insert another field'
})
}),
/*#__PURE__*/ jsx(Menu.Content, {
children: remainingFields.map((field)=>/*#__PURE__*/ jsx(Menu.Item, {
onSelect: handleAddField(field),
children: field.label
}, field.name))
})
]
})
]
})
})
]
});
};
/**
* @internal
* @description Small abstraction to solve within an array of fields where you can
* add a field to the beginning or start, move back and forth what it's index range
* should be when calculating it's new temp key
*/ const generateNKeysBetween = (field, count, currInd, newInd)=>{
const startKey = currInd > newInd ? field[newInd - 1]?.__temp_key__ : field[newInd]?.__temp_key__;
const endKey = currInd > newInd ? field[newInd]?.__temp_key__ : field[newInd + 1]?.__temp_key__;
return generateNKeysBetween$1(startKey, endKey, count);
};
/**
* @internal
* @description chunks a row of layouts by the max size we allow, 12. It does not add the
* spacers again, that should be added separately.
*/ const chunkArray = (array)=>{
const result = [];
let temp = [];
array.reduce((acc, field)=>{
if (acc + field.size > 12) {
result.push(temp);
temp = [
field
];
return field.size;
} else {
temp.push(field);
return acc + field.size;
}
}, 0);
if (temp.length > 0) {
result.push(temp);
}
return result;
};
const TEMP_FIELD_NAME = '_TEMP_';
/**
* Displays a field in the layout with drag options, also
* opens a modal to edit the details of said field.
*/ const Field = ({ attribute, components, name, index, onMoveField, onRemoveField })=>{
const [isModalOpen, setIsModalOpen] = React.useState(false);
const { formatMessage } = useIntl();
const { value } = useField(name);
const [{ isDragging }, objectRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop(true, {
dropSensitivity: 'immediate',
type: ItemTypes.EDIT_FIELD,
item: {
index,
label: value?.label,
name
},
index,
onMoveItem: onMoveField
});
React.useEffect(()=>{
dragPreviewRef(getEmptyImage(), {
captureDraggingState: false
});
}, [
dragPreviewRef
]);
const composedRefs = useComposedRefs(dragRef, objectRef);
const handleRemoveField = (e)=>{
e.preventDefault();
e.stopPropagation();
onRemoveField(e);
};
const onEditFieldMeta = (e)=>{
e.preventDefault();
e.stopPropagation();
setIsModalOpen(true);
};
const tempRefs = useComposedRefs(dropRef, objectRef);
if (!value) {
return null;
}
if (value.name === TEMP_FIELD_NAME) {
return /*#__PURE__*/ jsx(Flex, {
tag: "span",
height: "100%",
style: {
opacity: 0
},
ref: tempRefs
});
}
return /*#__PURE__*/ jsxs(Modal.Root, {
open: isModalOpen,
onOpenChange: setIsModalOpen,
children: [
/*#__PURE__*/ jsxs(Flex, {
borderColor: "neutral150",
background: "neutral100",
hasRadius: true,
style: {
opacity: isDragging ? 0.5 : 1
},
ref: dropRef,
gap: 3,
cursor: "pointer",
onClick: ()=>{
setIsModalOpen(true);
},
children: [
/*#__PURE__*/ jsx(DragButton, {
tag: "span",
withTooltip: false,
label: formatMessage({
id: getTranslation('components.DraggableCard.move.field'),
defaultMessage: 'Move {item}'
}, {
item: value.label
}),
onClick: (e)=>e.stopPropagation(),
ref: composedRefs,
children: /*#__PURE__*/ jsx(Drag, {})
}),
/*#__PURE__*/ jsxs(Flex, {
direction: "column",
alignItems: "flex-start",
grow: 1,
overflow: "hidden",
children: [
/*#__PURE__*/ jsxs(Flex, {
gap: 3,
justifyContent: "space-between",
width: "100%",
children: [
/*#__PURE__*/ jsx(Typography, {
ellipsis: true,
fontWeight: "bold",
children: value.label
}),
/*#__PURE__*/ jsxs(Flex, {
children: [
/*#__PURE__*/ jsx(IconButton, {
type: "button",
variant: "ghost",
background: "transparent",
onClick: onEditFieldMeta,
withTooltip: false,
label: formatMessage({
id: getTranslation('components.DraggableCard.edit.field'),
defaultMessage: 'Edit {item}'
}, {
item: value.label
}),
children: /*#__PURE__*/ jsx(Pencil, {})
}),
/*#__PURE__*/ jsx(IconButton, {
type: "button",
variant: "ghost",
onClick: handleRemoveField,
background: "transparent",
withTooltip: false,
label: formatMessage({
id: getTranslation('components.DraggableCard.delete.field'),
defaultMessage: 'Delete {item}'
}, {
item: value.label
}),
children: /*#__PURE__*/ jsx(Cross, {})
})
]
})
]
}),
attribute?.type === 'component' ? /*#__PURE__*/ jsxs(Flex, {
paddingTop: 3,
paddingRight: 3,
paddingBottom: 3,
paddingLeft: 0,
alignItems: "flex-start",
direction: "column",
gap: 2,
width: "100%",
children: [
/*#__PURE__*/ jsx(Grid.Root, {
gap: 4,
width: "100%",
children: components[attribute.component].layout.map((row)=>row.map(({ size, ...field })=>/*#__PURE__*/ jsx(Grid.Item, {
col: size,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsx(Flex, {
alignItems: "center",
background: "neutral0",
paddingTop: 2,
paddingBottom: 2,
paddingLeft: 3,
paddingRight: 3,
hasRadius: true,
borderColor: "neutral200",
children: /*#__PURE__*/ jsx(Typography, {
textColor: "neutral800",
children: field.name
})
})
}, field.name)))
}),
/*#__PURE__*/ jsx(Link, {
// used to stop the edit form from appearing when we click here.
onClick: (e)=>e.stopPropagation(),
startIcon: /*#__PURE__*/ jsx(Cog, {}),
tag: NavLink,
to: `../components/${attribute.component}/configurations/edit`,
children: formatMessage({
id: getTranslation('components.FieldItem.linkToComponentLayout'),
defaultMessage: "Set the component's layout"
})
})
]
}) : null,
attribute?.type === 'dynamiczone' ? /*#__PURE__*/ jsx(Flex, {
paddingTop: 3,
paddingRight: 3,
paddingBottom: 3,
paddingLeft: 0,
alignItems: "flex-start",
gap: 2,
width: "100%",
children: attribute?.components.map((uid)=>/*#__PURE__*/ jsxs(ComponentLink, {
// used to stop the edit form from appearing when we click here.
onClick: (e)=>e.stopPropagation(),
to: `../components/${uid}/configurations/edit`,
children: [
/*#__PURE__*/ jsx(ComponentIcon, {
icon: components[uid].settings.icon
}),
/*#__PURE__*/ jsx(Typography, {
fontSize: 1,
textColor: "neutral600",
fontWeight: "bold",
children: components[uid].settings.displayName
})
]
}, uid))
}) : null
]
})
]
}),
value.name !== TEMP_FIELD_NAME && /*#__PURE__*/ jsx(EditFieldForm, {
attribute: attribute,
name: name,
onClose: ()=>setIsModalOpen(false)
})
]
});
};
const DragButton = styled(IconButton)`
height: unset;
align-self: stretch;
display: flex;
align-items: center;
padding: 0;
border: none;
background-color: transparent;
border-radius: 0px;
border-right: 1px solid ${({ theme })=>theme.colors.neutral150};
cursor: all-scroll;
svg {
width: 1.2rem;
height: 1.2rem;
}
`;
const ComponentLink = styled(NavLink)`
display: flex;
flex-direction: column;
align-items: center;
gap: ${({ theme })=>theme.spaces[1]};
padding: ${(props)=>props.theme.spaces[2]};
border: 1px solid ${({ theme })=>theme.colors.neutral200};
background: ${({ theme })=>theme.colors.neutral0};
width: 14rem;
border-radius: ${({ theme })=>theme.borderRadius};
text-decoration: none;
&:focus,
&:hover {
${({ theme })=>`
background-color: ${theme.colors.primary100};
border-color: ${theme.colors.primary200};
${Typography} {
color: ${theme.colors.primary600};
}
`}
/* > ComponentIcon */
> div:first-child {
background: ${({ theme })=>theme.colors.primary200};
color: ${({ theme })=>theme.colors.primary600};
svg {
path {
fill: ${({ theme })=>theme.colors.primary600};
}
}
}
}
`;
export { Fields, TEMP_FIELD_NAME };
//# sourceMappingURL=Fields.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,253 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var strapiAdmin = require('@strapi/admin/strapi-admin');
var designSystem = require('@strapi/design-system');
var fractionalIndexing = require('fractional-indexing');
var pipe = require('lodash/fp/pipe');
var reactIntl = require('react-intl');
var attributes = require('../../constants/attributes.js');
var strings = require('../../utils/strings.js');
var translations = require('../../utils/translations.js');
var Fields = require('./Fields.js');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
const ConfigurationForm = ({ attributes: attributes$1, fieldSizes, layout: editLayout, onSubmit })=>{
const { components, settings, layout, metadatas } = editLayout;
const { formatMessage } = reactIntl.useIntl();
const initialValues = React__namespace.useMemo(()=>{
const transformations = pipe(flattenPanels, replaceMainFieldWithNameOnly, extractMetadata, addTmpSpaceToLayout, addTmpKeysToLayout);
return {
layout: transformations(layout),
settings
};
}, [
layout,
settings
]);
return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Layouts.Root, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Main, {
children: /*#__PURE__*/ jsxRuntime.jsxs(strapiAdmin.Form, {
initialValues: initialValues,
onSubmit: onSubmit,
method: "PUT",
children: [
/*#__PURE__*/ jsxRuntime.jsx(Header, {
name: settings.displayName ?? ''
}),
/*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Layouts.Content, {
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
alignItems: "stretch",
background: "neutral0",
direction: "column",
gap: 6,
hasRadius: true,
shadow: "tableShadow",
paddingTop: 6,
paddingBottom: 6,
paddingLeft: 7,
paddingRight: 7,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
variant: "delta",
tag: "h2",
children: formatMessage({
id: translations.getTranslation('containers.SettingPage.settings'),
defaultMessage: 'Settings'
})
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Grid.Root, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
col: 6,
s: 12,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.InputRenderer, {
type: "enumeration",
label: formatMessage({
id: translations.getTranslation('containers.SettingPage.editSettings.entry.title'),
defaultMessage: 'Entry title'
}),
hint: formatMessage({
id: translations.getTranslation('containers.SettingPage.editSettings.entry.title.description'),
defaultMessage: 'Set the display field of your entry'
}),
name: "settings.mainField",
options: Object.entries(attributes$1).reduce((acc, [key, attribute])=>{
if (!attribute) {
return acc;
}
/**
* Create the list of attributes from the schema as to which can
* be our `mainField` and dictate the display name of the schema
* we're editing.
*/ if (!attributes.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD.includes(attribute.type)) {
acc.push({
label: key,
value: key
});
}
return acc;
}, [])
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
paddingTop: 6,
paddingBottom: 6,
col: 12,
s: 12,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Divider, {})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
col: 12,
s: 12,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
variant: "delta",
tag: "h3",
children: formatMessage({
id: translations.getTranslation('containers.SettingPage.view'),
defaultMessage: 'View'
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
col: 12,
s: 12,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxRuntime.jsx(Fields.Fields, {
attributes: attributes$1,
components: components,
fieldSizes: fieldSizes,
metadatas: metadatas
})
})
]
})
]
})
})
]
})
})
});
};
/**
* @internal
* @description Panels don't exist in the layout, so we flatten by one.
*/ const flattenPanels = (layout)=>layout.flat(1);
/**
* @internal
* @description We don't need the mainField object in the layout, we only need the name.
*/ const replaceMainFieldWithNameOnly = (layout)=>layout.map((row)=>row.map((field)=>({
...field,
mainField: field.mainField?.name
})));
/**
* @internal
* @description We extract the metadata values from the field layout, because these are editable by the user.
*/ const extractMetadata = (layout)=>{
return layout.map((row)=>row.map(({ label, disabled, hint, placeholder, size, name, mainField })=>({
label,
editable: !disabled,
description: hint,
mainField,
placeholder,
size,
name,
__temp_key__: ''
})));
};
/**
* @internal
* @description Each row of the layout has a max size of 12 (based on bootstrap grid system)
* So in order to offer a better drop zone we add the _TEMP_ div to complete the remaining substract (12 - existing)
*/ const addTmpSpaceToLayout = (layout)=>[
...layout.map((row)=>{
const totalSpaceTaken = row.reduce((acc, field)=>acc + field.size, 0);
if (totalSpaceTaken < 12) {
return [
...row,
{
name: Fields.TEMP_FIELD_NAME,
size: 12 - totalSpaceTaken,
__temp_key__: ''
}
];
}
return row;
})
];
/**
* @internal
* @description At this point of the transformations we have Field[][], but each row for the form should have a __temp_key__
* applied. This means we need to change it so `Field` is nested under the children property.
*/ const addTmpKeysToLayout = (layout)=>{
const keys = fractionalIndexing.generateNKeysBetween(undefined, undefined, layout.length);
return layout.map((row, rowIndex)=>{
const fieldKeys = fractionalIndexing.generateNKeysBetween(undefined, undefined, row.length);
return {
__temp_key__: keys[rowIndex],
children: row.map((field, fieldIndex)=>{
return {
...field,
__temp_key__: fieldKeys[fieldIndex]
};
})
};
});
};
const Header = ({ name })=>{
const { formatMessage } = reactIntl.useIntl();
const modified = strapiAdmin.useForm('Header', (state)=>state.modified);
const isSubmitting = strapiAdmin.useForm('Header', (state)=>state.isSubmitting);
return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Layouts.Header, {
title: formatMessage({
id: translations.getTranslation('components.SettingsViewWrapper.pluginHeader.title'),
defaultMessage: `Configure the view - {name}`
}, {
name: strings.capitalise(name)
}),
subtitle: formatMessage({
id: translations.getTranslation('components.SettingsViewWrapper.pluginHeader.description.edit-settings'),
defaultMessage: 'Customize how the edit view will look like.'
}),
navigationAction: /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.BackButton, {}),
primaryAction: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
disabled: !modified,
loading: isSubmitting,
type: "submit",
children: formatMessage({
id: 'global.save',
defaultMessage: 'Save'
})
})
});
};
exports.ConfigurationForm = ConfigurationForm;
//# sourceMappingURL=Form.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,232 @@
import { jsx, jsxs } from 'react/jsx-runtime';
import * as React from 'react';
import { Layouts, Form, InputRenderer, useForm, BackButton } from '@strapi/admin/strapi-admin';
import { Main, Flex, Typography, Grid, Divider, Button } from '@strapi/design-system';
import { generateNKeysBetween } from 'fractional-indexing';
import pipe from 'lodash/fp/pipe';
import { useIntl } from 'react-intl';
import { ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD } from '../../constants/attributes.mjs';
import { capitalise } from '../../utils/strings.mjs';
import { getTranslation } from '../../utils/translations.mjs';
import { Fields, TEMP_FIELD_NAME } from './Fields.mjs';
const ConfigurationForm = ({ attributes, fieldSizes, layout: editLayout, onSubmit })=>{
const { components, settings, layout, metadatas } = editLayout;
const { formatMessage } = useIntl();
const initialValues = React.useMemo(()=>{
const transformations = pipe(flattenPanels, replaceMainFieldWithNameOnly, extractMetadata, addTmpSpaceToLayout, addTmpKeysToLayout);
return {
layout: transformations(layout),
settings
};
}, [
layout,
settings
]);
return /*#__PURE__*/ jsx(Layouts.Root, {
children: /*#__PURE__*/ jsx(Main, {
children: /*#__PURE__*/ jsxs(Form, {
initialValues: initialValues,
onSubmit: onSubmit,
method: "PUT",
children: [
/*#__PURE__*/ jsx(Header, {
name: settings.displayName ?? ''
}),
/*#__PURE__*/ jsx(Layouts.Content, {
children: /*#__PURE__*/ jsxs(Flex, {
alignItems: "stretch",
background: "neutral0",
direction: "column",
gap: 6,
hasRadius: true,
shadow: "tableShadow",
paddingTop: 6,
paddingBottom: 6,
paddingLeft: 7,
paddingRight: 7,
children: [
/*#__PURE__*/ jsx(Typography, {
variant: "delta",
tag: "h2",
children: formatMessage({
id: getTranslation('containers.SettingPage.settings'),
defaultMessage: 'Settings'
})
}),
/*#__PURE__*/ jsxs(Grid.Root, {
children: [
/*#__PURE__*/ jsx(Grid.Item, {
col: 6,
s: 12,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsx(InputRenderer, {
type: "enumeration",
label: formatMessage({
id: getTranslation('containers.SettingPage.editSettings.entry.title'),
defaultMessage: 'Entry title'
}),
hint: formatMessage({
id: getTranslation('containers.SettingPage.editSettings.entry.title.description'),
defaultMessage: 'Set the display field of your entry'
}),
name: "settings.mainField",
options: Object.entries(attributes).reduce((acc, [key, attribute])=>{
if (!attribute) {
return acc;
}
/**
* Create the list of attributes from the schema as to which can
* be our `mainField` and dictate the display name of the schema
* we're editing.
*/ if (!ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD.includes(attribute.type)) {
acc.push({
label: key,
value: key
});
}
return acc;
}, [])
})
}),
/*#__PURE__*/ jsx(Grid.Item, {
paddingTop: 6,
paddingBottom: 6,
col: 12,
s: 12,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsx(Divider, {})
}),
/*#__PURE__*/ jsx(Grid.Item, {
col: 12,
s: 12,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsx(Typography, {
variant: "delta",
tag: "h3",
children: formatMessage({
id: getTranslation('containers.SettingPage.view'),
defaultMessage: 'View'
})
})
}),
/*#__PURE__*/ jsx(Grid.Item, {
col: 12,
s: 12,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsx(Fields, {
attributes: attributes,
components: components,
fieldSizes: fieldSizes,
metadatas: metadatas
})
})
]
})
]
})
})
]
})
})
});
};
/**
* @internal
* @description Panels don't exist in the layout, so we flatten by one.
*/ const flattenPanels = (layout)=>layout.flat(1);
/**
* @internal
* @description We don't need the mainField object in the layout, we only need the name.
*/ const replaceMainFieldWithNameOnly = (layout)=>layout.map((row)=>row.map((field)=>({
...field,
mainField: field.mainField?.name
})));
/**
* @internal
* @description We extract the metadata values from the field layout, because these are editable by the user.
*/ const extractMetadata = (layout)=>{
return layout.map((row)=>row.map(({ label, disabled, hint, placeholder, size, name, mainField })=>({
label,
editable: !disabled,
description: hint,
mainField,
placeholder,
size,
name,
__temp_key__: ''
})));
};
/**
* @internal
* @description Each row of the layout has a max size of 12 (based on bootstrap grid system)
* So in order to offer a better drop zone we add the _TEMP_ div to complete the remaining substract (12 - existing)
*/ const addTmpSpaceToLayout = (layout)=>[
...layout.map((row)=>{
const totalSpaceTaken = row.reduce((acc, field)=>acc + field.size, 0);
if (totalSpaceTaken < 12) {
return [
...row,
{
name: TEMP_FIELD_NAME,
size: 12 - totalSpaceTaken,
__temp_key__: ''
}
];
}
return row;
})
];
/**
* @internal
* @description At this point of the transformations we have Field[][], but each row for the form should have a __temp_key__
* applied. This means we need to change it so `Field` is nested under the children property.
*/ const addTmpKeysToLayout = (layout)=>{
const keys = generateNKeysBetween(undefined, undefined, layout.length);
return layout.map((row, rowIndex)=>{
const fieldKeys = generateNKeysBetween(undefined, undefined, row.length);
return {
__temp_key__: keys[rowIndex],
children: row.map((field, fieldIndex)=>{
return {
...field,
__temp_key__: fieldKeys[fieldIndex]
};
})
};
});
};
const Header = ({ name })=>{
const { formatMessage } = useIntl();
const modified = useForm('Header', (state)=>state.modified);
const isSubmitting = useForm('Header', (state)=>state.isSubmitting);
return /*#__PURE__*/ jsx(Layouts.Header, {
title: formatMessage({
id: getTranslation('components.SettingsViewWrapper.pluginHeader.title'),
defaultMessage: `Configure the view - {name}`
}, {
name: capitalise(name)
}),
subtitle: formatMessage({
id: getTranslation('components.SettingsViewWrapper.pluginHeader.description.edit-settings'),
defaultMessage: 'Customize how the edit view will look like.'
}),
navigationAction: /*#__PURE__*/ jsx(BackButton, {}),
primaryAction: /*#__PURE__*/ jsx(Button, {
disabled: !modified,
loading: isSubmitting,
type: "submit",
children: formatMessage({
id: 'global.save',
defaultMessage: 'Save'
})
})
});
};
export { ConfigurationForm };
//# sourceMappingURL=Form.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,50 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
require('react');
var designSystem = require('@strapi/design-system');
var reactDnd = require('react-dnd');
function getStyle(initialOffset, currentOffset, mouseOffset) {
if (!initialOffset || !currentOffset || !mouseOffset) {
return {
display: 'none'
};
}
const { x, y } = mouseOffset;
return {
transform: `translate(${x}px, ${y}px)`
};
}
const DragLayer = ({ renderItem })=>{
const { itemType, isDragging, item, initialOffset, currentOffset, mouseOffset } = reactDnd.useDragLayer((monitor)=>({
item: monitor.getItem(),
itemType: monitor.getItemType(),
initialOffset: monitor.getInitialSourceClientOffset(),
currentOffset: monitor.getSourceClientOffset(),
isDragging: monitor.isDragging(),
mouseOffset: monitor.getClientOffset()
}));
if (!isDragging) {
return null;
}
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
height: "100%",
left: 0,
position: "fixed",
pointerEvents: "none",
top: 0,
zIndex: 100,
width: "100%",
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
style: getStyle(initialOffset, currentOffset, mouseOffset),
children: renderItem({
type: itemType,
item
})
})
});
};
exports.DragLayer = DragLayer;
//# sourceMappingURL=DragLayer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DragLayer.js","sources":["../../../admin/src/components/DragLayer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box } from '@strapi/design-system';\nimport { DragLayerMonitor, XYCoord, useDragLayer } from 'react-dnd';\n\nfunction getStyle(\n initialOffset: XYCoord | null,\n currentOffset: XYCoord | null,\n mouseOffset: XYCoord | null\n) {\n if (!initialOffset || !currentOffset || !mouseOffset) {\n return { display: 'none' };\n }\n\n const { x, y } = mouseOffset;\n\n return {\n transform: `translate(${x}px, ${y}px)`,\n };\n}\n\nexport interface DragLayerProps {\n renderItem: (item: {\n /**\n * TODO: it'd be great if we could make this a union where the type infers the item.\n */\n item: any;\n type: ReturnType<DragLayerMonitor['getItemType']>;\n }) => React.ReactNode;\n}\n\nconst DragLayer = ({ renderItem }: DragLayerProps) => {\n const { itemType, isDragging, item, initialOffset, currentOffset, mouseOffset } = useDragLayer(\n (monitor) => ({\n item: monitor.getItem(),\n itemType: monitor.getItemType(),\n initialOffset: monitor.getInitialSourceClientOffset(),\n currentOffset: monitor.getSourceClientOffset(),\n isDragging: monitor.isDragging(),\n mouseOffset: monitor.getClientOffset(),\n })\n );\n\n if (!isDragging) {\n return null;\n }\n\n return (\n <Box\n height=\"100%\"\n left={0}\n position=\"fixed\"\n pointerEvents=\"none\"\n top={0}\n zIndex={100}\n width=\"100%\"\n >\n <Box style={getStyle(initialOffset, currentOffset, mouseOffset)}>\n {renderItem({ type: itemType, item })}\n </Box>\n </Box>\n );\n};\n\nexport { DragLayer };\n"],"names":["getStyle","initialOffset","currentOffset","mouseOffset","display","x","y","transform","DragLayer","renderItem","itemType","isDragging","item","useDragLayer","monitor","getItem","getItemType","getInitialSourceClientOffset","getSourceClientOffset","getClientOffset","_jsx","Box","height","left","position","pointerEvents","top","zIndex","width","style","type"],"mappings":";;;;;;;AAKA,SAASA,QACPC,CAAAA,aAA6B,EAC7BC,aAA6B,EAC7BC,WAA2B,EAAA;AAE3B,IAAA,IAAI,CAACF,aAAAA,IAAiB,CAACC,aAAAA,IAAiB,CAACC,WAAa,EAAA;QACpD,OAAO;YAAEC,OAAS,EAAA;AAAO,SAAA;AAC3B;AAEA,IAAA,MAAM,EAAEC,CAAC,EAAEC,CAAC,EAAE,GAAGH,WAAAA;IAEjB,OAAO;QACLI,SAAW,EAAA,CAAC,UAAU,EAAEF,CAAAA,CAAE,IAAI,EAAEC,CAAAA,CAAE,GAAG;AACvC,KAAA;AACF;AAYA,MAAME,SAAY,GAAA,CAAC,EAAEC,UAAU,EAAkB,GAAA;AAC/C,IAAA,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,IAAI,EAAEX,aAAa,EAAEC,aAAa,EAAEC,WAAW,EAAE,GAAGU,qBAChF,CAAA,CAACC,WAAa;AACZF,YAAAA,IAAAA,EAAME,QAAQC,OAAO,EAAA;AACrBL,YAAAA,QAAAA,EAAUI,QAAQE,WAAW,EAAA;AAC7Bf,YAAAA,aAAAA,EAAea,QAAQG,4BAA4B,EAAA;AACnDf,YAAAA,aAAAA,EAAeY,QAAQI,qBAAqB,EAAA;AAC5CP,YAAAA,UAAAA,EAAYG,QAAQH,UAAU,EAAA;AAC9BR,YAAAA,WAAAA,EAAaW,QAAQK,eAAe;SACtC,CAAA,CAAA;AAGF,IAAA,IAAI,CAACR,UAAY,EAAA;QACf,OAAO,IAAA;AACT;AAEA,IAAA,qBACES,cAACC,CAAAA,gBAAAA,EAAAA;QACCC,MAAO,EAAA,MAAA;QACPC,IAAM,EAAA,CAAA;QACNC,QAAS,EAAA,OAAA;QACTC,aAAc,EAAA,MAAA;QACdC,GAAK,EAAA,CAAA;QACLC,MAAQ,EAAA,GAAA;QACRC,KAAM,EAAA,MAAA;AAEN,QAAA,QAAA,gBAAAR,cAACC,CAAAA,gBAAAA,EAAAA;YAAIQ,KAAO7B,EAAAA,QAAAA,CAASC,eAAeC,aAAeC,EAAAA,WAAAA,CAAAA;sBAChDM,UAAW,CAAA;gBAAEqB,IAAMpB,EAAAA,QAAAA;AAAUE,gBAAAA;AAAK,aAAA;;;AAI3C;;;;"}

View File

@@ -0,0 +1,48 @@
import { jsx } from 'react/jsx-runtime';
import 'react';
import { Box } from '@strapi/design-system';
import { useDragLayer } from 'react-dnd';
function getStyle(initialOffset, currentOffset, mouseOffset) {
if (!initialOffset || !currentOffset || !mouseOffset) {
return {
display: 'none'
};
}
const { x, y } = mouseOffset;
return {
transform: `translate(${x}px, ${y}px)`
};
}
const DragLayer = ({ renderItem })=>{
const { itemType, isDragging, item, initialOffset, currentOffset, mouseOffset } = useDragLayer((monitor)=>({
item: monitor.getItem(),
itemType: monitor.getItemType(),
initialOffset: monitor.getInitialSourceClientOffset(),
currentOffset: monitor.getSourceClientOffset(),
isDragging: monitor.isDragging(),
mouseOffset: monitor.getClientOffset()
}));
if (!isDragging) {
return null;
}
return /*#__PURE__*/ jsx(Box, {
height: "100%",
left: 0,
position: "fixed",
pointerEvents: "none",
top: 0,
zIndex: 100,
width: "100%",
children: /*#__PURE__*/ jsx(Box, {
style: getStyle(initialOffset, currentOffset, mouseOffset),
children: renderItem({
type: itemType,
item
})
})
});
};
export { DragLayer };
//# sourceMappingURL=DragLayer.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DragLayer.mjs","sources":["../../../admin/src/components/DragLayer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box } from '@strapi/design-system';\nimport { DragLayerMonitor, XYCoord, useDragLayer } from 'react-dnd';\n\nfunction getStyle(\n initialOffset: XYCoord | null,\n currentOffset: XYCoord | null,\n mouseOffset: XYCoord | null\n) {\n if (!initialOffset || !currentOffset || !mouseOffset) {\n return { display: 'none' };\n }\n\n const { x, y } = mouseOffset;\n\n return {\n transform: `translate(${x}px, ${y}px)`,\n };\n}\n\nexport interface DragLayerProps {\n renderItem: (item: {\n /**\n * TODO: it'd be great if we could make this a union where the type infers the item.\n */\n item: any;\n type: ReturnType<DragLayerMonitor['getItemType']>;\n }) => React.ReactNode;\n}\n\nconst DragLayer = ({ renderItem }: DragLayerProps) => {\n const { itemType, isDragging, item, initialOffset, currentOffset, mouseOffset } = useDragLayer(\n (monitor) => ({\n item: monitor.getItem(),\n itemType: monitor.getItemType(),\n initialOffset: monitor.getInitialSourceClientOffset(),\n currentOffset: monitor.getSourceClientOffset(),\n isDragging: monitor.isDragging(),\n mouseOffset: monitor.getClientOffset(),\n })\n );\n\n if (!isDragging) {\n return null;\n }\n\n return (\n <Box\n height=\"100%\"\n left={0}\n position=\"fixed\"\n pointerEvents=\"none\"\n top={0}\n zIndex={100}\n width=\"100%\"\n >\n <Box style={getStyle(initialOffset, currentOffset, mouseOffset)}>\n {renderItem({ type: itemType, item })}\n </Box>\n </Box>\n );\n};\n\nexport { DragLayer };\n"],"names":["getStyle","initialOffset","currentOffset","mouseOffset","display","x","y","transform","DragLayer","renderItem","itemType","isDragging","item","useDragLayer","monitor","getItem","getItemType","getInitialSourceClientOffset","getSourceClientOffset","getClientOffset","_jsx","Box","height","left","position","pointerEvents","top","zIndex","width","style","type"],"mappings":";;;;;AAKA,SAASA,QACPC,CAAAA,aAA6B,EAC7BC,aAA6B,EAC7BC,WAA2B,EAAA;AAE3B,IAAA,IAAI,CAACF,aAAAA,IAAiB,CAACC,aAAAA,IAAiB,CAACC,WAAa,EAAA;QACpD,OAAO;YAAEC,OAAS,EAAA;AAAO,SAAA;AAC3B;AAEA,IAAA,MAAM,EAAEC,CAAC,EAAEC,CAAC,EAAE,GAAGH,WAAAA;IAEjB,OAAO;QACLI,SAAW,EAAA,CAAC,UAAU,EAAEF,CAAAA,CAAE,IAAI,EAAEC,CAAAA,CAAE,GAAG;AACvC,KAAA;AACF;AAYA,MAAME,SAAY,GAAA,CAAC,EAAEC,UAAU,EAAkB,GAAA;AAC/C,IAAA,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,IAAI,EAAEX,aAAa,EAAEC,aAAa,EAAEC,WAAW,EAAE,GAAGU,YAChF,CAAA,CAACC,WAAa;AACZF,YAAAA,IAAAA,EAAME,QAAQC,OAAO,EAAA;AACrBL,YAAAA,QAAAA,EAAUI,QAAQE,WAAW,EAAA;AAC7Bf,YAAAA,aAAAA,EAAea,QAAQG,4BAA4B,EAAA;AACnDf,YAAAA,aAAAA,EAAeY,QAAQI,qBAAqB,EAAA;AAC5CP,YAAAA,UAAAA,EAAYG,QAAQH,UAAU,EAAA;AAC9BR,YAAAA,WAAAA,EAAaW,QAAQK,eAAe;SACtC,CAAA,CAAA;AAGF,IAAA,IAAI,CAACR,UAAY,EAAA;QACf,OAAO,IAAA;AACT;AAEA,IAAA,qBACES,GAACC,CAAAA,GAAAA,EAAAA;QACCC,MAAO,EAAA,MAAA;QACPC,IAAM,EAAA,CAAA;QACNC,QAAS,EAAA,OAAA;QACTC,aAAc,EAAA,MAAA;QACdC,GAAK,EAAA,CAAA;QACLC,MAAQ,EAAA,GAAA;QACRC,KAAM,EAAA,MAAA;AAEN,QAAA,QAAA,gBAAAR,GAACC,CAAAA,GAAAA,EAAAA;YAAIQ,KAAO7B,EAAAA,QAAAA,CAASC,eAAeC,aAAeC,EAAAA,WAAAA,CAAAA;sBAChDM,UAAW,CAAA;gBAAEqB,IAAMpB,EAAAA,QAAAA;AAAUE,gBAAAA;AAAK,aAAA;;;AAI3C;;;;"}

View File

@@ -0,0 +1,82 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var designSystem = require('@strapi/design-system');
var Icons = require('@strapi/icons');
var styledComponents = require('styled-components');
const CardDragPreview = ({ label, isSibling = false })=>{
return /*#__PURE__*/ jsxRuntime.jsxs(FieldContainer, {
background: isSibling ? 'neutral100' : 'primary100',
display: "inline-flex",
gap: 3,
hasRadius: true,
justifyContent: "space-between",
$isSibling: isSibling,
"max-height": `3.2rem`,
maxWidth: "min-content",
children: [
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
gap: 3,
children: [
/*#__PURE__*/ jsxRuntime.jsx(DragButton, {
alignItems: "center",
cursor: "all-scroll",
padding: 3,
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Drag, {})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
textColor: isSibling ? undefined : 'primary600',
fontWeight: "bold",
ellipsis: true,
maxWidth: "7.2rem",
children: label
})
]
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(ActionBox, {
alignItems: "center",
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Pencil, {})
}),
/*#__PURE__*/ jsxRuntime.jsx(ActionBox, {
alignItems: "center",
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Cross, {})
})
]
})
]
});
};
const ActionBox = styledComponents.styled(designSystem.Flex)`
height: ${({ theme })=>theme.spaces[7]};
&:last-child {
padding: 0 ${({ theme })=>theme.spaces[3]};
}
`;
const DragButton = styledComponents.styled(ActionBox)`
border-right: 1px solid ${({ theme })=>theme.colors.primary200};
svg {
width: 1.2rem;
height: 1.2rem;
}
`;
const FieldContainer = styledComponents.styled(designSystem.Flex)`
border: 1px solid
${({ theme, $isSibling })=>$isSibling ? theme.colors.neutral150 : theme.colors.primary200};
svg {
width: 1rem;
height: 1rem;
path {
fill: ${({ theme, $isSibling })=>$isSibling ? undefined : theme.colors.primary600};
}
}
`;
exports.CardDragPreview = CardDragPreview;
//# sourceMappingURL=CardDragPreview.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CardDragPreview.js","sources":["../../../../admin/src/components/DragPreviews/CardDragPreview.tsx"],"sourcesContent":["import { Flex, FlexComponent, Typography } from '@strapi/design-system';\nimport { Cross, Drag, Pencil } from '@strapi/icons';\nimport { styled } from 'styled-components';\n\ninterface CardDragPreviewProps {\n label: string;\n isSibling?: boolean;\n}\n\nconst CardDragPreview = ({ label, isSibling = false }: CardDragPreviewProps) => {\n return (\n <FieldContainer\n background={isSibling ? 'neutral100' : 'primary100'}\n display=\"inline-flex\"\n gap={3}\n hasRadius\n justifyContent=\"space-between\"\n $isSibling={isSibling}\n max-height={`3.2rem`}\n maxWidth=\"min-content\"\n >\n <Flex gap={3}>\n <DragButton alignItems=\"center\" cursor=\"all-scroll\" padding={3}>\n <Drag />\n </DragButton>\n\n <Typography\n textColor={isSibling ? undefined : 'primary600'}\n fontWeight=\"bold\"\n ellipsis\n maxWidth=\"7.2rem\"\n >\n {label}\n </Typography>\n </Flex>\n\n <Flex>\n <ActionBox alignItems=\"center\">\n <Pencil />\n </ActionBox>\n\n <ActionBox alignItems=\"center\">\n <Cross />\n </ActionBox>\n </Flex>\n </FieldContainer>\n );\n};\n\nconst ActionBox = styled<FlexComponent>(Flex)`\n height: ${({ theme }) => theme.spaces[7]};\n\n &:last-child {\n padding: 0 ${({ theme }) => theme.spaces[3]};\n }\n`;\n\nconst DragButton = styled(ActionBox)`\n border-right: 1px solid ${({ theme }) => theme.colors.primary200};\n\n svg {\n width: 1.2rem;\n height: 1.2rem;\n }\n`;\n\nconst FieldContainer = styled<FlexComponent>(Flex)<{ $isSibling: boolean }>`\n border: 1px solid\n ${({ theme, $isSibling }) => ($isSibling ? theme.colors.neutral150 : theme.colors.primary200)};\n\n svg {\n width: 1rem;\n height: 1rem;\n\n path {\n fill: ${({ theme, $isSibling }) => ($isSibling ? undefined : theme.colors.primary600)};\n }\n }\n`;\n\nexport { CardDragPreview };\nexport type { CardDragPreviewProps };\n"],"names":["CardDragPreview","label","isSibling","_jsxs","FieldContainer","background","display","gap","hasRadius","justifyContent","$isSibling","max-height","maxWidth","Flex","_jsx","DragButton","alignItems","cursor","padding","Drag","Typography","textColor","undefined","fontWeight","ellipsis","ActionBox","Pencil","Cross","styled","theme","spaces","colors","primary200","neutral150","primary600"],"mappings":";;;;;;;AASA,MAAMA,kBAAkB,CAAC,EAAEC,KAAK,EAAEC,SAAAA,GAAY,KAAK,EAAwB,GAAA;AACzE,IAAA,qBACEC,eAACC,CAAAA,cAAAA,EAAAA;AACCC,QAAAA,UAAAA,EAAYH,YAAY,YAAe,GAAA,YAAA;QACvCI,OAAQ,EAAA,aAAA;QACRC,GAAK,EAAA,CAAA;QACLC,SAAS,EAAA,IAAA;QACTC,cAAe,EAAA,eAAA;QACfC,UAAYR,EAAAA,SAAAA;QACZS,YAAY,EAAA,CAAC,MAAM,CAAC;QACpBC,QAAS,EAAA,aAAA;;0BAETT,eAACU,CAAAA,iBAAAA,EAAAA;gBAAKN,GAAK,EAAA,CAAA;;kCACTO,cAACC,CAAAA,UAAAA,EAAAA;wBAAWC,UAAW,EAAA,QAAA;wBAASC,MAAO,EAAA,YAAA;wBAAaC,OAAS,EAAA,CAAA;AAC3D,wBAAA,QAAA,gBAAAJ,cAACK,CAAAA,UAAAA,EAAAA,EAAAA;;kCAGHL,cAACM,CAAAA,uBAAAA,EAAAA;AACCC,wBAAAA,SAAAA,EAAWnB,YAAYoB,SAAY,GAAA,YAAA;wBACnCC,UAAW,EAAA,MAAA;wBACXC,QAAQ,EAAA,IAAA;wBACRZ,QAAS,EAAA,QAAA;AAERX,wBAAAA,QAAAA,EAAAA;;;;0BAILE,eAACU,CAAAA,iBAAAA,EAAAA;;kCACCC,cAACW,CAAAA,SAAAA,EAAAA;wBAAUT,UAAW,EAAA,QAAA;AACpB,wBAAA,QAAA,gBAAAF,cAACY,CAAAA,YAAAA,EAAAA,EAAAA;;kCAGHZ,cAACW,CAAAA,SAAAA,EAAAA;wBAAUT,UAAW,EAAA,QAAA;AACpB,wBAAA,QAAA,gBAAAF,cAACa,CAAAA,WAAAA,EAAAA,EAAAA;;;;;;AAKX;AAEA,MAAMF,SAAAA,GAAYG,uBAAsBf,CAAAA,iBAAAA,CAAK;UACnC,EAAE,CAAC,EAAEgB,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;;;eAG5B,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;;AAEhD,CAAC;AAED,MAAMf,UAAAA,GAAaa,uBAAOH,CAAAA,SAAAA,CAAU;0BACV,EAAE,CAAC,EAAEI,KAAK,EAAE,GAAKA,KAAME,CAAAA,MAAM,CAACC,UAAU,CAAC;;;;;;AAMnE,CAAC;AAED,MAAM5B,cAAAA,GAAiBwB,uBAAsBf,CAAAA,iBAAAA,CAA8B;;AAEvE,IAAA,EAAE,CAAC,EAAEgB,KAAK,EAAEnB,UAAU,EAAE,GAAMA,UAAAA,GAAamB,KAAME,CAAAA,MAAM,CAACE,UAAU,GAAGJ,MAAME,MAAM,CAACC,UAAU,CAAE;;;;;;;AAOtF,YAAA,EAAE,CAAC,EAAEH,KAAK,EAAEnB,UAAU,EAAE,GAAMA,UAAAA,GAAaY,SAAYO,GAAAA,KAAAA,CAAME,MAAM,CAACG,UAAU,CAAE;;;AAG5F,CAAC;;;;"}

View File

@@ -0,0 +1,80 @@
import { jsxs, jsx } from 'react/jsx-runtime';
import { Flex, Typography } from '@strapi/design-system';
import { Drag, Pencil, Cross } from '@strapi/icons';
import { styled } from 'styled-components';
const CardDragPreview = ({ label, isSibling = false })=>{
return /*#__PURE__*/ jsxs(FieldContainer, {
background: isSibling ? 'neutral100' : 'primary100',
display: "inline-flex",
gap: 3,
hasRadius: true,
justifyContent: "space-between",
$isSibling: isSibling,
"max-height": `3.2rem`,
maxWidth: "min-content",
children: [
/*#__PURE__*/ jsxs(Flex, {
gap: 3,
children: [
/*#__PURE__*/ jsx(DragButton, {
alignItems: "center",
cursor: "all-scroll",
padding: 3,
children: /*#__PURE__*/ jsx(Drag, {})
}),
/*#__PURE__*/ jsx(Typography, {
textColor: isSibling ? undefined : 'primary600',
fontWeight: "bold",
ellipsis: true,
maxWidth: "7.2rem",
children: label
})
]
}),
/*#__PURE__*/ jsxs(Flex, {
children: [
/*#__PURE__*/ jsx(ActionBox, {
alignItems: "center",
children: /*#__PURE__*/ jsx(Pencil, {})
}),
/*#__PURE__*/ jsx(ActionBox, {
alignItems: "center",
children: /*#__PURE__*/ jsx(Cross, {})
})
]
})
]
});
};
const ActionBox = styled(Flex)`
height: ${({ theme })=>theme.spaces[7]};
&:last-child {
padding: 0 ${({ theme })=>theme.spaces[3]};
}
`;
const DragButton = styled(ActionBox)`
border-right: 1px solid ${({ theme })=>theme.colors.primary200};
svg {
width: 1.2rem;
height: 1.2rem;
}
`;
const FieldContainer = styled(Flex)`
border: 1px solid
${({ theme, $isSibling })=>$isSibling ? theme.colors.neutral150 : theme.colors.primary200};
svg {
width: 1rem;
height: 1rem;
path {
fill: ${({ theme, $isSibling })=>$isSibling ? undefined : theme.colors.primary600};
}
}
`;
export { CardDragPreview };
//# sourceMappingURL=CardDragPreview.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CardDragPreview.mjs","sources":["../../../../admin/src/components/DragPreviews/CardDragPreview.tsx"],"sourcesContent":["import { Flex, FlexComponent, Typography } from '@strapi/design-system';\nimport { Cross, Drag, Pencil } from '@strapi/icons';\nimport { styled } from 'styled-components';\n\ninterface CardDragPreviewProps {\n label: string;\n isSibling?: boolean;\n}\n\nconst CardDragPreview = ({ label, isSibling = false }: CardDragPreviewProps) => {\n return (\n <FieldContainer\n background={isSibling ? 'neutral100' : 'primary100'}\n display=\"inline-flex\"\n gap={3}\n hasRadius\n justifyContent=\"space-between\"\n $isSibling={isSibling}\n max-height={`3.2rem`}\n maxWidth=\"min-content\"\n >\n <Flex gap={3}>\n <DragButton alignItems=\"center\" cursor=\"all-scroll\" padding={3}>\n <Drag />\n </DragButton>\n\n <Typography\n textColor={isSibling ? undefined : 'primary600'}\n fontWeight=\"bold\"\n ellipsis\n maxWidth=\"7.2rem\"\n >\n {label}\n </Typography>\n </Flex>\n\n <Flex>\n <ActionBox alignItems=\"center\">\n <Pencil />\n </ActionBox>\n\n <ActionBox alignItems=\"center\">\n <Cross />\n </ActionBox>\n </Flex>\n </FieldContainer>\n );\n};\n\nconst ActionBox = styled<FlexComponent>(Flex)`\n height: ${({ theme }) => theme.spaces[7]};\n\n &:last-child {\n padding: 0 ${({ theme }) => theme.spaces[3]};\n }\n`;\n\nconst DragButton = styled(ActionBox)`\n border-right: 1px solid ${({ theme }) => theme.colors.primary200};\n\n svg {\n width: 1.2rem;\n height: 1.2rem;\n }\n`;\n\nconst FieldContainer = styled<FlexComponent>(Flex)<{ $isSibling: boolean }>`\n border: 1px solid\n ${({ theme, $isSibling }) => ($isSibling ? theme.colors.neutral150 : theme.colors.primary200)};\n\n svg {\n width: 1rem;\n height: 1rem;\n\n path {\n fill: ${({ theme, $isSibling }) => ($isSibling ? undefined : theme.colors.primary600)};\n }\n }\n`;\n\nexport { CardDragPreview };\nexport type { CardDragPreviewProps };\n"],"names":["CardDragPreview","label","isSibling","_jsxs","FieldContainer","background","display","gap","hasRadius","justifyContent","$isSibling","max-height","maxWidth","Flex","_jsx","DragButton","alignItems","cursor","padding","Drag","Typography","textColor","undefined","fontWeight","ellipsis","ActionBox","Pencil","Cross","styled","theme","spaces","colors","primary200","neutral150","primary600"],"mappings":";;;;;AASA,MAAMA,kBAAkB,CAAC,EAAEC,KAAK,EAAEC,SAAAA,GAAY,KAAK,EAAwB,GAAA;AACzE,IAAA,qBACEC,IAACC,CAAAA,cAAAA,EAAAA;AACCC,QAAAA,UAAAA,EAAYH,YAAY,YAAe,GAAA,YAAA;QACvCI,OAAQ,EAAA,aAAA;QACRC,GAAK,EAAA,CAAA;QACLC,SAAS,EAAA,IAAA;QACTC,cAAe,EAAA,eAAA;QACfC,UAAYR,EAAAA,SAAAA;QACZS,YAAY,EAAA,CAAC,MAAM,CAAC;QACpBC,QAAS,EAAA,aAAA;;0BAETT,IAACU,CAAAA,IAAAA,EAAAA;gBAAKN,GAAK,EAAA,CAAA;;kCACTO,GAACC,CAAAA,UAAAA,EAAAA;wBAAWC,UAAW,EAAA,QAAA;wBAASC,MAAO,EAAA,YAAA;wBAAaC,OAAS,EAAA,CAAA;AAC3D,wBAAA,QAAA,gBAAAJ,GAACK,CAAAA,IAAAA,EAAAA,EAAAA;;kCAGHL,GAACM,CAAAA,UAAAA,EAAAA;AACCC,wBAAAA,SAAAA,EAAWnB,YAAYoB,SAAY,GAAA,YAAA;wBACnCC,UAAW,EAAA,MAAA;wBACXC,QAAQ,EAAA,IAAA;wBACRZ,QAAS,EAAA,QAAA;AAERX,wBAAAA,QAAAA,EAAAA;;;;0BAILE,IAACU,CAAAA,IAAAA,EAAAA;;kCACCC,GAACW,CAAAA,SAAAA,EAAAA;wBAAUT,UAAW,EAAA,QAAA;AACpB,wBAAA,QAAA,gBAAAF,GAACY,CAAAA,MAAAA,EAAAA,EAAAA;;kCAGHZ,GAACW,CAAAA,SAAAA,EAAAA;wBAAUT,UAAW,EAAA,QAAA;AACpB,wBAAA,QAAA,gBAAAF,GAACa,CAAAA,KAAAA,EAAAA,EAAAA;;;;;;AAKX;AAEA,MAAMF,SAAAA,GAAYG,MAAsBf,CAAAA,IAAAA,CAAK;UACnC,EAAE,CAAC,EAAEgB,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;;;eAG5B,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;;AAEhD,CAAC;AAED,MAAMf,UAAAA,GAAaa,MAAOH,CAAAA,SAAAA,CAAU;0BACV,EAAE,CAAC,EAAEI,KAAK,EAAE,GAAKA,KAAME,CAAAA,MAAM,CAACC,UAAU,CAAC;;;;;;AAMnE,CAAC;AAED,MAAM5B,cAAAA,GAAiBwB,MAAsBf,CAAAA,IAAAA,CAA8B;;AAEvE,IAAA,EAAE,CAAC,EAAEgB,KAAK,EAAEnB,UAAU,EAAE,GAAMA,UAAAA,GAAamB,KAAME,CAAAA,MAAM,CAACE,UAAU,GAAGJ,MAAME,MAAM,CAACC,UAAU,CAAE;;;;;;;AAOtF,YAAA,EAAE,CAAC,EAAEH,KAAK,EAAEnB,UAAU,EAAE,GAAMA,UAAAA,GAAaY,SAAYO,GAAAA,KAAAA,CAAME,MAAM,CAACG,UAAU,CAAE;;;AAG5F,CAAC;;;;"}

View File

@@ -0,0 +1,83 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var designSystem = require('@strapi/design-system');
var Icons = require('@strapi/icons');
var styledComponents = require('styled-components');
const ComponentDragPreview = ({ displayedValue })=>{
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
background: "neutral0",
borderColor: "neutral200",
justifyContent: "space-between",
gap: 3,
padding: 3,
width: "30rem",
children: [
/*#__PURE__*/ jsxRuntime.jsx(ToggleButton, {
type: "button",
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
gap: 6,
children: [
/*#__PURE__*/ jsxRuntime.jsx(DropdownIconWrapper, {
alignItems: "center",
justifyContent: "center",
background: "neutral200",
height: "3.2rem",
width: "3.2rem",
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.CaretDown, {})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
maxWidth: "15rem",
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
textColor: "neutral700",
ellipsis: true,
children: displayedValue
})
})
]
})
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
gap: 2,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
withTooltip: false,
label: "",
variant: "ghost",
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Trash, {})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
withTooltip: false,
label: "",
variant: "ghost",
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Drag, {})
})
]
})
]
});
};
const DropdownIconWrapper = styledComponents.styled(designSystem.Flex)`
border-radius: 50%;
svg {
height: 0.6rem;
width: 1.1rem;
> path {
fill: ${({ theme })=>theme.colors.neutral600};
}
}
`;
// TODO: we shouldn't have to reset a whole button
const ToggleButton = styledComponents.styled.button`
border: none;
background: transparent;
display: block;
width: 100%;
text-align: unset;
padding: 0;
`;
exports.ComponentDragPreview = ComponentDragPreview;
//# sourceMappingURL=ComponentDragPreview.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ComponentDragPreview.js","sources":["../../../../admin/src/components/DragPreviews/ComponentDragPreview.tsx"],"sourcesContent":["import { Flex, FlexComponent, IconButton, Typography } from '@strapi/design-system';\nimport { CaretDown, Drag, Trash } from '@strapi/icons';\nimport { styled } from 'styled-components';\n\ninterface ComponentDragPreviewProps {\n displayedValue: string;\n}\n\nconst ComponentDragPreview = ({ displayedValue }: ComponentDragPreviewProps) => {\n return (\n <Flex\n background=\"neutral0\"\n borderColor=\"neutral200\"\n justifyContent=\"space-between\"\n gap={3}\n padding={3}\n width=\"30rem\"\n >\n <ToggleButton type=\"button\">\n <Flex gap={6}>\n <DropdownIconWrapper\n alignItems=\"center\"\n justifyContent=\"center\"\n background=\"neutral200\"\n height=\"3.2rem\"\n width=\"3.2rem\"\n >\n <CaretDown />\n </DropdownIconWrapper>\n\n <Flex maxWidth=\"15rem\">\n <Typography textColor=\"neutral700\" ellipsis>\n {displayedValue}\n </Typography>\n </Flex>\n </Flex>\n </ToggleButton>\n\n <Flex gap={2}>\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Trash />\n </IconButton>\n\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Drag />\n </IconButton>\n </Flex>\n </Flex>\n );\n};\n\nconst DropdownIconWrapper = styled<FlexComponent>(Flex)`\n border-radius: 50%;\n\n svg {\n height: 0.6rem;\n width: 1.1rem;\n > path {\n fill: ${({ theme }) => theme.colors.neutral600};\n }\n }\n`;\n\n// TODO: we shouldn't have to reset a whole button\nconst ToggleButton = styled.button`\n border: none;\n background: transparent;\n display: block;\n width: 100%;\n text-align: unset;\n padding: 0;\n`;\n\nexport { ComponentDragPreview };\nexport type { ComponentDragPreviewProps };\n"],"names":["ComponentDragPreview","displayedValue","_jsxs","Flex","background","borderColor","justifyContent","gap","padding","width","_jsx","ToggleButton","type","DropdownIconWrapper","alignItems","height","CaretDown","maxWidth","Typography","textColor","ellipsis","IconButton","withTooltip","label","variant","Trash","Drag","styled","theme","colors","neutral600","button"],"mappings":";;;;;;;AAQA,MAAMA,oBAAuB,GAAA,CAAC,EAAEC,cAAc,EAA6B,GAAA;AACzE,IAAA,qBACEC,eAACC,CAAAA,iBAAAA,EAAAA;QACCC,UAAW,EAAA,UAAA;QACXC,WAAY,EAAA,YAAA;QACZC,cAAe,EAAA,eAAA;QACfC,GAAK,EAAA,CAAA;QACLC,OAAS,EAAA,CAAA;QACTC,KAAM,EAAA,OAAA;;0BAENC,cAACC,CAAAA,YAAAA,EAAAA;gBAAaC,IAAK,EAAA,QAAA;AACjB,gBAAA,QAAA,gBAAAV,eAACC,CAAAA,iBAAAA,EAAAA;oBAAKI,GAAK,EAAA,CAAA;;sCACTG,cAACG,CAAAA,mBAAAA,EAAAA;4BACCC,UAAW,EAAA,QAAA;4BACXR,cAAe,EAAA,QAAA;4BACfF,UAAW,EAAA,YAAA;4BACXW,MAAO,EAAA,QAAA;4BACPN,KAAM,EAAA,QAAA;AAEN,4BAAA,QAAA,gBAAAC,cAACM,CAAAA,eAAAA,EAAAA,EAAAA;;sCAGHN,cAACP,CAAAA,iBAAAA,EAAAA;4BAAKc,QAAS,EAAA,OAAA;AACb,4BAAA,QAAA,gBAAAP,cAACQ,CAAAA,uBAAAA,EAAAA;gCAAWC,SAAU,EAAA,YAAA;gCAAaC,QAAQ,EAAA,IAAA;AACxCnB,gCAAAA,QAAAA,EAAAA;;;;;;0BAMTC,eAACC,CAAAA,iBAAAA,EAAAA;gBAAKI,GAAK,EAAA,CAAA;;kCACTG,cAACW,CAAAA,uBAAAA,EAAAA;wBAAWC,WAAa,EAAA,KAAA;wBAAOC,KAAM,EAAA,EAAA;wBAAGC,OAAQ,EAAA,OAAA;AAC/C,wBAAA,QAAA,gBAAAd,cAACe,CAAAA,WAAAA,EAAAA,EAAAA;;kCAGHf,cAACW,CAAAA,uBAAAA,EAAAA;wBAAWC,WAAa,EAAA,KAAA;wBAAOC,KAAM,EAAA,EAAA;wBAAGC,OAAQ,EAAA,OAAA;AAC/C,wBAAA,QAAA,gBAAAd,cAACgB,CAAAA,UAAAA,EAAAA,EAAAA;;;;;;AAKX;AAEA,MAAMb,mBAAAA,GAAsBc,uBAAsBxB,CAAAA,iBAAAA,CAAK;;;;;;;YAO3C,EAAE,CAAC,EAAEyB,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAACC,UAAU,CAAC;;;AAGrD,CAAC;AAED;AACA,MAAMnB,YAAAA,GAAegB,uBAAOI,CAAAA,MAAM;;;;;;;AAOlC,CAAC;;;;"}

View File

@@ -0,0 +1,81 @@
import { jsxs, jsx } from 'react/jsx-runtime';
import { Flex, Typography, IconButton } from '@strapi/design-system';
import { CaretDown, Trash, Drag } from '@strapi/icons';
import { styled } from 'styled-components';
const ComponentDragPreview = ({ displayedValue })=>{
return /*#__PURE__*/ jsxs(Flex, {
background: "neutral0",
borderColor: "neutral200",
justifyContent: "space-between",
gap: 3,
padding: 3,
width: "30rem",
children: [
/*#__PURE__*/ jsx(ToggleButton, {
type: "button",
children: /*#__PURE__*/ jsxs(Flex, {
gap: 6,
children: [
/*#__PURE__*/ jsx(DropdownIconWrapper, {
alignItems: "center",
justifyContent: "center",
background: "neutral200",
height: "3.2rem",
width: "3.2rem",
children: /*#__PURE__*/ jsx(CaretDown, {})
}),
/*#__PURE__*/ jsx(Flex, {
maxWidth: "15rem",
children: /*#__PURE__*/ jsx(Typography, {
textColor: "neutral700",
ellipsis: true,
children: displayedValue
})
})
]
})
}),
/*#__PURE__*/ jsxs(Flex, {
gap: 2,
children: [
/*#__PURE__*/ jsx(IconButton, {
withTooltip: false,
label: "",
variant: "ghost",
children: /*#__PURE__*/ jsx(Trash, {})
}),
/*#__PURE__*/ jsx(IconButton, {
withTooltip: false,
label: "",
variant: "ghost",
children: /*#__PURE__*/ jsx(Drag, {})
})
]
})
]
});
};
const DropdownIconWrapper = styled(Flex)`
border-radius: 50%;
svg {
height: 0.6rem;
width: 1.1rem;
> path {
fill: ${({ theme })=>theme.colors.neutral600};
}
}
`;
// TODO: we shouldn't have to reset a whole button
const ToggleButton = styled.button`
border: none;
background: transparent;
display: block;
width: 100%;
text-align: unset;
padding: 0;
`;
export { ComponentDragPreview };
//# sourceMappingURL=ComponentDragPreview.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ComponentDragPreview.mjs","sources":["../../../../admin/src/components/DragPreviews/ComponentDragPreview.tsx"],"sourcesContent":["import { Flex, FlexComponent, IconButton, Typography } from '@strapi/design-system';\nimport { CaretDown, Drag, Trash } from '@strapi/icons';\nimport { styled } from 'styled-components';\n\ninterface ComponentDragPreviewProps {\n displayedValue: string;\n}\n\nconst ComponentDragPreview = ({ displayedValue }: ComponentDragPreviewProps) => {\n return (\n <Flex\n background=\"neutral0\"\n borderColor=\"neutral200\"\n justifyContent=\"space-between\"\n gap={3}\n padding={3}\n width=\"30rem\"\n >\n <ToggleButton type=\"button\">\n <Flex gap={6}>\n <DropdownIconWrapper\n alignItems=\"center\"\n justifyContent=\"center\"\n background=\"neutral200\"\n height=\"3.2rem\"\n width=\"3.2rem\"\n >\n <CaretDown />\n </DropdownIconWrapper>\n\n <Flex maxWidth=\"15rem\">\n <Typography textColor=\"neutral700\" ellipsis>\n {displayedValue}\n </Typography>\n </Flex>\n </Flex>\n </ToggleButton>\n\n <Flex gap={2}>\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Trash />\n </IconButton>\n\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Drag />\n </IconButton>\n </Flex>\n </Flex>\n );\n};\n\nconst DropdownIconWrapper = styled<FlexComponent>(Flex)`\n border-radius: 50%;\n\n svg {\n height: 0.6rem;\n width: 1.1rem;\n > path {\n fill: ${({ theme }) => theme.colors.neutral600};\n }\n }\n`;\n\n// TODO: we shouldn't have to reset a whole button\nconst ToggleButton = styled.button`\n border: none;\n background: transparent;\n display: block;\n width: 100%;\n text-align: unset;\n padding: 0;\n`;\n\nexport { ComponentDragPreview };\nexport type { ComponentDragPreviewProps };\n"],"names":["ComponentDragPreview","displayedValue","_jsxs","Flex","background","borderColor","justifyContent","gap","padding","width","_jsx","ToggleButton","type","DropdownIconWrapper","alignItems","height","CaretDown","maxWidth","Typography","textColor","ellipsis","IconButton","withTooltip","label","variant","Trash","Drag","styled","theme","colors","neutral600","button"],"mappings":";;;;;AAQA,MAAMA,oBAAuB,GAAA,CAAC,EAAEC,cAAc,EAA6B,GAAA;AACzE,IAAA,qBACEC,IAACC,CAAAA,IAAAA,EAAAA;QACCC,UAAW,EAAA,UAAA;QACXC,WAAY,EAAA,YAAA;QACZC,cAAe,EAAA,eAAA;QACfC,GAAK,EAAA,CAAA;QACLC,OAAS,EAAA,CAAA;QACTC,KAAM,EAAA,OAAA;;0BAENC,GAACC,CAAAA,YAAAA,EAAAA;gBAAaC,IAAK,EAAA,QAAA;AACjB,gBAAA,QAAA,gBAAAV,IAACC,CAAAA,IAAAA,EAAAA;oBAAKI,GAAK,EAAA,CAAA;;sCACTG,GAACG,CAAAA,mBAAAA,EAAAA;4BACCC,UAAW,EAAA,QAAA;4BACXR,cAAe,EAAA,QAAA;4BACfF,UAAW,EAAA,YAAA;4BACXW,MAAO,EAAA,QAAA;4BACPN,KAAM,EAAA,QAAA;AAEN,4BAAA,QAAA,gBAAAC,GAACM,CAAAA,SAAAA,EAAAA,EAAAA;;sCAGHN,GAACP,CAAAA,IAAAA,EAAAA;4BAAKc,QAAS,EAAA,OAAA;AACb,4BAAA,QAAA,gBAAAP,GAACQ,CAAAA,UAAAA,EAAAA;gCAAWC,SAAU,EAAA,YAAA;gCAAaC,QAAQ,EAAA,IAAA;AACxCnB,gCAAAA,QAAAA,EAAAA;;;;;;0BAMTC,IAACC,CAAAA,IAAAA,EAAAA;gBAAKI,GAAK,EAAA,CAAA;;kCACTG,GAACW,CAAAA,UAAAA,EAAAA;wBAAWC,WAAa,EAAA,KAAA;wBAAOC,KAAM,EAAA,EAAA;wBAAGC,OAAQ,EAAA,OAAA;AAC/C,wBAAA,QAAA,gBAAAd,GAACe,CAAAA,KAAAA,EAAAA,EAAAA;;kCAGHf,GAACW,CAAAA,UAAAA,EAAAA;wBAAWC,WAAa,EAAA,KAAA;wBAAOC,KAAM,EAAA,EAAA;wBAAGC,OAAQ,EAAA,OAAA;AAC/C,wBAAA,QAAA,gBAAAd,GAACgB,CAAAA,IAAAA,EAAAA,EAAAA;;;;;;AAKX;AAEA,MAAMb,mBAAAA,GAAsBc,MAAsBxB,CAAAA,IAAAA,CAAK;;;;;;;YAO3C,EAAE,CAAC,EAAEyB,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAACC,UAAU,CAAC;;;AAGrD,CAAC;AAED;AACA,MAAMnB,YAAAA,GAAegB,MAAOI,CAAAA,MAAM;;;;;;;AAOlC,CAAC;;;;"}

View File

@@ -0,0 +1,73 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var designSystem = require('@strapi/design-system');
var Icons = require('@strapi/icons');
var DocumentStatus = require('../../pages/EditView/components/DocumentStatus.js');
var Relations = require('../../pages/EditView/components/FormInputs/Relations/Relations.js');
const RelationDragPreview = ({ status, displayedValue, width })=>{
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
style: {
width
},
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
paddingTop: 2,
paddingBottom: 2,
paddingLeft: 2,
paddingRight: 4,
hasRadius: true,
borderWidth: 1,
background: "neutral0",
borderColor: "neutral200",
justifyContent: "space-between",
gap: 4,
children: [
/*#__PURE__*/ jsxRuntime.jsxs(Relations.FlexWrapper, {
gap: 1,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
withTooltip: false,
label: "",
variant: "ghost",
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Drag, {})
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
width: "100%",
minWidth: 0,
justifyContent: "space-between",
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
minWidth: 0,
paddingTop: 1,
paddingBottom: 1,
paddingRight: 4,
children: /*#__PURE__*/ jsxRuntime.jsx(Relations.LinkEllipsis, {
href: "",
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
textColor: "primary600",
ellipsis: true,
children: displayedValue
})
})
}),
status ? /*#__PURE__*/ jsxRuntime.jsx(DocumentStatus.DocumentStatus, {
status: status
}) : null
]
})
]
}),
/*#__PURE__*/ jsxRuntime.jsx(Relations.DisconnectButton, {
type: "button",
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Cross, {
width: "12px"
})
})
]
})
});
};
exports.RelationDragPreview = RelationDragPreview;
//# sourceMappingURL=RelationDragPreview.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"RelationDragPreview.js","sources":["../../../../admin/src/components/DragPreviews/RelationDragPreview.tsx"],"sourcesContent":["import { Box, Flex, IconButton, Typography } from '@strapi/design-system';\nimport { Cross, Drag } from '@strapi/icons';\n\nimport { DocumentStatus } from '../../pages/EditView/components/DocumentStatus';\nimport {\n DisconnectButton,\n LinkEllipsis,\n FlexWrapper,\n} from '../../pages/EditView/components/FormInputs/Relations/Relations';\n\nimport type { Data } from '@strapi/types';\n\ninterface RelationDragPreviewProps {\n status?: string;\n displayedValue: string;\n id: Data.ID;\n index: number;\n width: number;\n}\n\nconst RelationDragPreview = ({ status, displayedValue, width }: RelationDragPreviewProps) => {\n return (\n <Box style={{ width }}>\n <Flex\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={2}\n paddingRight={4}\n hasRadius\n borderWidth={1}\n background=\"neutral0\"\n borderColor=\"neutral200\"\n justifyContent=\"space-between\"\n gap={4}\n >\n <FlexWrapper gap={1}>\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Drag />\n </IconButton>\n <Flex width=\"100%\" minWidth={0} justifyContent=\"space-between\">\n <Box minWidth={0} paddingTop={1} paddingBottom={1} paddingRight={4}>\n <LinkEllipsis href=\"\">\n <Typography textColor=\"primary600\" ellipsis>\n {displayedValue}\n </Typography>\n </LinkEllipsis>\n </Box>\n {status ? <DocumentStatus status={status} /> : null}\n </Flex>\n </FlexWrapper>\n <DisconnectButton type=\"button\">\n <Cross width=\"12px\" />\n </DisconnectButton>\n </Flex>\n </Box>\n );\n};\n\nexport { RelationDragPreview };\nexport type { RelationDragPreviewProps };\n"],"names":["RelationDragPreview","status","displayedValue","width","_jsx","Box","style","_jsxs","Flex","paddingTop","paddingBottom","paddingLeft","paddingRight","hasRadius","borderWidth","background","borderColor","justifyContent","gap","FlexWrapper","IconButton","withTooltip","label","variant","Drag","minWidth","LinkEllipsis","href","Typography","textColor","ellipsis","DocumentStatus","DisconnectButton","type","Cross"],"mappings":";;;;;;;;AAoBMA,MAAAA,mBAAAA,GAAsB,CAAC,EAAEC,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAA4B,GAAA;AACtF,IAAA,qBACEC,cAACC,CAAAA,gBAAAA,EAAAA;QAAIC,KAAO,EAAA;AAAEH,YAAAA;AAAM,SAAA;AAClB,QAAA,QAAA,gBAAAI,eAACC,CAAAA,iBAAAA,EAAAA;YACCC,UAAY,EAAA,CAAA;YACZC,aAAe,EAAA,CAAA;YACfC,WAAa,EAAA,CAAA;YACbC,YAAc,EAAA,CAAA;YACdC,SAAS,EAAA,IAAA;YACTC,WAAa,EAAA,CAAA;YACbC,UAAW,EAAA,UAAA;YACXC,WAAY,EAAA,YAAA;YACZC,cAAe,EAAA,eAAA;YACfC,GAAK,EAAA,CAAA;;8BAELX,eAACY,CAAAA,qBAAAA,EAAAA;oBAAYD,GAAK,EAAA,CAAA;;sCAChBd,cAACgB,CAAAA,uBAAAA,EAAAA;4BAAWC,WAAa,EAAA,KAAA;4BAAOC,KAAM,EAAA,EAAA;4BAAGC,OAAQ,EAAA,OAAA;AAC/C,4BAAA,QAAA,gBAAAnB,cAACoB,CAAAA,UAAAA,EAAAA,EAAAA;;sCAEHjB,eAACC,CAAAA,iBAAAA,EAAAA;4BAAKL,KAAM,EAAA,MAAA;4BAAOsB,QAAU,EAAA,CAAA;4BAAGR,cAAe,EAAA,eAAA;;8CAC7Cb,cAACC,CAAAA,gBAAAA,EAAAA;oCAAIoB,QAAU,EAAA,CAAA;oCAAGhB,UAAY,EAAA,CAAA;oCAAGC,aAAe,EAAA,CAAA;oCAAGE,YAAc,EAAA,CAAA;AAC/D,oCAAA,QAAA,gBAAAR,cAACsB,CAAAA,sBAAAA,EAAAA;wCAAaC,IAAK,EAAA,EAAA;AACjB,wCAAA,QAAA,gBAAAvB,cAACwB,CAAAA,uBAAAA,EAAAA;4CAAWC,SAAU,EAAA,YAAA;4CAAaC,QAAQ,EAAA,IAAA;AACxC5B,4CAAAA,QAAAA,EAAAA;;;;AAIND,gCAAAA,MAAAA,iBAASG,cAAC2B,CAAAA,6BAAAA,EAAAA;oCAAe9B,MAAQA,EAAAA;AAAa,iCAAA,CAAA,GAAA;;;;;8BAGnDG,cAAC4B,CAAAA,0BAAAA,EAAAA;oBAAiBC,IAAK,EAAA,QAAA;AACrB,oBAAA,QAAA,gBAAA7B,cAAC8B,CAAAA,WAAAA,EAAAA;wBAAM/B,KAAM,EAAA;;;;;;AAKvB;;;;"}

View File

@@ -0,0 +1,71 @@
import { jsx, jsxs } from 'react/jsx-runtime';
import { Box, Flex, IconButton, Typography } from '@strapi/design-system';
import { Drag, Cross } from '@strapi/icons';
import { DocumentStatus } from '../../pages/EditView/components/DocumentStatus.mjs';
import { FlexWrapper, LinkEllipsis, DisconnectButton } from '../../pages/EditView/components/FormInputs/Relations/Relations.mjs';
const RelationDragPreview = ({ status, displayedValue, width })=>{
return /*#__PURE__*/ jsx(Box, {
style: {
width
},
children: /*#__PURE__*/ jsxs(Flex, {
paddingTop: 2,
paddingBottom: 2,
paddingLeft: 2,
paddingRight: 4,
hasRadius: true,
borderWidth: 1,
background: "neutral0",
borderColor: "neutral200",
justifyContent: "space-between",
gap: 4,
children: [
/*#__PURE__*/ jsxs(FlexWrapper, {
gap: 1,
children: [
/*#__PURE__*/ jsx(IconButton, {
withTooltip: false,
label: "",
variant: "ghost",
children: /*#__PURE__*/ jsx(Drag, {})
}),
/*#__PURE__*/ jsxs(Flex, {
width: "100%",
minWidth: 0,
justifyContent: "space-between",
children: [
/*#__PURE__*/ jsx(Box, {
minWidth: 0,
paddingTop: 1,
paddingBottom: 1,
paddingRight: 4,
children: /*#__PURE__*/ jsx(LinkEllipsis, {
href: "",
children: /*#__PURE__*/ jsx(Typography, {
textColor: "primary600",
ellipsis: true,
children: displayedValue
})
})
}),
status ? /*#__PURE__*/ jsx(DocumentStatus, {
status: status
}) : null
]
})
]
}),
/*#__PURE__*/ jsx(DisconnectButton, {
type: "button",
children: /*#__PURE__*/ jsx(Cross, {
width: "12px"
})
})
]
})
});
};
export { RelationDragPreview };
//# sourceMappingURL=RelationDragPreview.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"RelationDragPreview.mjs","sources":["../../../../admin/src/components/DragPreviews/RelationDragPreview.tsx"],"sourcesContent":["import { Box, Flex, IconButton, Typography } from '@strapi/design-system';\nimport { Cross, Drag } from '@strapi/icons';\n\nimport { DocumentStatus } from '../../pages/EditView/components/DocumentStatus';\nimport {\n DisconnectButton,\n LinkEllipsis,\n FlexWrapper,\n} from '../../pages/EditView/components/FormInputs/Relations/Relations';\n\nimport type { Data } from '@strapi/types';\n\ninterface RelationDragPreviewProps {\n status?: string;\n displayedValue: string;\n id: Data.ID;\n index: number;\n width: number;\n}\n\nconst RelationDragPreview = ({ status, displayedValue, width }: RelationDragPreviewProps) => {\n return (\n <Box style={{ width }}>\n <Flex\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={2}\n paddingRight={4}\n hasRadius\n borderWidth={1}\n background=\"neutral0\"\n borderColor=\"neutral200\"\n justifyContent=\"space-between\"\n gap={4}\n >\n <FlexWrapper gap={1}>\n <IconButton withTooltip={false} label=\"\" variant=\"ghost\">\n <Drag />\n </IconButton>\n <Flex width=\"100%\" minWidth={0} justifyContent=\"space-between\">\n <Box minWidth={0} paddingTop={1} paddingBottom={1} paddingRight={4}>\n <LinkEllipsis href=\"\">\n <Typography textColor=\"primary600\" ellipsis>\n {displayedValue}\n </Typography>\n </LinkEllipsis>\n </Box>\n {status ? <DocumentStatus status={status} /> : null}\n </Flex>\n </FlexWrapper>\n <DisconnectButton type=\"button\">\n <Cross width=\"12px\" />\n </DisconnectButton>\n </Flex>\n </Box>\n );\n};\n\nexport { RelationDragPreview };\nexport type { RelationDragPreviewProps };\n"],"names":["RelationDragPreview","status","displayedValue","width","_jsx","Box","style","_jsxs","Flex","paddingTop","paddingBottom","paddingLeft","paddingRight","hasRadius","borderWidth","background","borderColor","justifyContent","gap","FlexWrapper","IconButton","withTooltip","label","variant","Drag","minWidth","LinkEllipsis","href","Typography","textColor","ellipsis","DocumentStatus","DisconnectButton","type","Cross"],"mappings":";;;;;;AAoBMA,MAAAA,mBAAAA,GAAsB,CAAC,EAAEC,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAA4B,GAAA;AACtF,IAAA,qBACEC,GAACC,CAAAA,GAAAA,EAAAA;QAAIC,KAAO,EAAA;AAAEH,YAAAA;AAAM,SAAA;AAClB,QAAA,QAAA,gBAAAI,IAACC,CAAAA,IAAAA,EAAAA;YACCC,UAAY,EAAA,CAAA;YACZC,aAAe,EAAA,CAAA;YACfC,WAAa,EAAA,CAAA;YACbC,YAAc,EAAA,CAAA;YACdC,SAAS,EAAA,IAAA;YACTC,WAAa,EAAA,CAAA;YACbC,UAAW,EAAA,UAAA;YACXC,WAAY,EAAA,YAAA;YACZC,cAAe,EAAA,eAAA;YACfC,GAAK,EAAA,CAAA;;8BAELX,IAACY,CAAAA,WAAAA,EAAAA;oBAAYD,GAAK,EAAA,CAAA;;sCAChBd,GAACgB,CAAAA,UAAAA,EAAAA;4BAAWC,WAAa,EAAA,KAAA;4BAAOC,KAAM,EAAA,EAAA;4BAAGC,OAAQ,EAAA,OAAA;AAC/C,4BAAA,QAAA,gBAAAnB,GAACoB,CAAAA,IAAAA,EAAAA,EAAAA;;sCAEHjB,IAACC,CAAAA,IAAAA,EAAAA;4BAAKL,KAAM,EAAA,MAAA;4BAAOsB,QAAU,EAAA,CAAA;4BAAGR,cAAe,EAAA,eAAA;;8CAC7Cb,GAACC,CAAAA,GAAAA,EAAAA;oCAAIoB,QAAU,EAAA,CAAA;oCAAGhB,UAAY,EAAA,CAAA;oCAAGC,aAAe,EAAA,CAAA;oCAAGE,YAAc,EAAA,CAAA;AAC/D,oCAAA,QAAA,gBAAAR,GAACsB,CAAAA,YAAAA,EAAAA;wCAAaC,IAAK,EAAA,EAAA;AACjB,wCAAA,QAAA,gBAAAvB,GAACwB,CAAAA,UAAAA,EAAAA;4CAAWC,SAAU,EAAA,YAAA;4CAAaC,QAAQ,EAAA,IAAA;AACxC5B,4CAAAA,QAAAA,EAAAA;;;;AAIND,gCAAAA,MAAAA,iBAASG,GAAC2B,CAAAA,cAAAA,EAAAA;oCAAe9B,MAAQA,EAAAA;AAAa,iCAAA,CAAA,GAAA;;;;;8BAGnDG,GAAC4B,CAAAA,gBAAAA,EAAAA;oBAAiBC,IAAK,EAAA,QAAA;AACrB,oBAAA,QAAA,gBAAA7B,GAAC8B,CAAAA,KAAAA,EAAAA;wBAAM/B,KAAM,EAAA;;;;;;AAKvB;;;;"}

View File

@@ -0,0 +1,58 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
require('react');
var strapiAdmin = require('@strapi/admin/strapi-admin');
var designSystem = require('@strapi/design-system');
var Symbols = require('@strapi/icons/symbols');
const iconByTypes = {
biginteger: /*#__PURE__*/ jsxRuntime.jsx(Symbols.NumberField, {}),
boolean: /*#__PURE__*/ jsxRuntime.jsx(Symbols.BooleanField, {}),
date: /*#__PURE__*/ jsxRuntime.jsx(Symbols.DateField, {}),
datetime: /*#__PURE__*/ jsxRuntime.jsx(Symbols.DateField, {}),
decimal: /*#__PURE__*/ jsxRuntime.jsx(Symbols.NumberField, {}),
email: /*#__PURE__*/ jsxRuntime.jsx(Symbols.EmailField, {}),
enumeration: /*#__PURE__*/ jsxRuntime.jsx(Symbols.EnumerationField, {}),
float: /*#__PURE__*/ jsxRuntime.jsx(Symbols.NumberField, {}),
integer: /*#__PURE__*/ jsxRuntime.jsx(Symbols.NumberField, {}),
media: /*#__PURE__*/ jsxRuntime.jsx(Symbols.MediaField, {}),
password: /*#__PURE__*/ jsxRuntime.jsx(Symbols.PasswordField, {}),
relation: /*#__PURE__*/ jsxRuntime.jsx(Symbols.RelationField, {}),
string: /*#__PURE__*/ jsxRuntime.jsx(Symbols.TextField, {}),
text: /*#__PURE__*/ jsxRuntime.jsx(Symbols.TextField, {}),
richtext: /*#__PURE__*/ jsxRuntime.jsx(Symbols.TextField, {}),
time: /*#__PURE__*/ jsxRuntime.jsx(Symbols.DateField, {}),
timestamp: /*#__PURE__*/ jsxRuntime.jsx(Symbols.DateField, {}),
json: /*#__PURE__*/ jsxRuntime.jsx(Symbols.JsonField, {}),
uid: /*#__PURE__*/ jsxRuntime.jsx(Symbols.UidField, {}),
component: /*#__PURE__*/ jsxRuntime.jsx(Symbols.ComponentField, {}),
dynamiczone: /*#__PURE__*/ jsxRuntime.jsx(Symbols.DynamicZoneField, {}),
blocks: /*#__PURE__*/ jsxRuntime.jsx(Symbols.BlocksField, {})
};
const FieldTypeIcon = ({ type, customFieldUid })=>{
const getCustomField = strapiAdmin.useStrapiApp('FieldTypeIcon', (state)=>state.customFields.get);
if (!type) {
return null;
}
let Compo = iconByTypes[type];
if (customFieldUid) {
const customField = getCustomField(customFieldUid);
const CustomFieldIcon = customField?.icon;
if (CustomFieldIcon) {
Compo = /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
marginRight: 3,
width: 7,
height: 6,
children: /*#__PURE__*/ jsxRuntime.jsx(CustomFieldIcon, {})
});
}
}
if (!iconByTypes[type]) {
return null;
}
return Compo;
};
exports.FieldTypeIcon = FieldTypeIcon;
//# sourceMappingURL=FieldTypeIcon.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FieldTypeIcon.js","sources":["../../../admin/src/components/FieldTypeIcon.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useStrapiApp } from '@strapi/admin/strapi-admin';\nimport { Box } from '@strapi/design-system';\nimport {\n BlocksField,\n BooleanField,\n ComponentField,\n DateField,\n DynamicZoneField,\n EmailField,\n EnumerationField,\n JsonField,\n MediaField,\n NumberField,\n PasswordField,\n RelationField,\n TextField,\n UidField,\n} from '@strapi/icons/symbols';\n\nimport type { Schema } from '@strapi/types';\n\nconst iconByTypes: Record<Schema.Attribute.Kind, React.ReactElement> = {\n biginteger: <NumberField />,\n boolean: <BooleanField />,\n date: <DateField />,\n datetime: <DateField />,\n decimal: <NumberField />,\n email: <EmailField />,\n enumeration: <EnumerationField />,\n float: <NumberField />,\n integer: <NumberField />,\n media: <MediaField />,\n password: <PasswordField />,\n relation: <RelationField />,\n string: <TextField />,\n text: <TextField />,\n richtext: <TextField />,\n time: <DateField />,\n timestamp: <DateField />,\n json: <JsonField />,\n uid: <UidField />,\n component: <ComponentField />,\n dynamiczone: <DynamicZoneField />,\n blocks: <BlocksField />,\n};\n\ninterface FieldTypeIconProps {\n type?: keyof typeof iconByTypes;\n customFieldUid?: string;\n}\n\nconst FieldTypeIcon = ({ type, customFieldUid }: FieldTypeIconProps) => {\n const getCustomField = useStrapiApp('FieldTypeIcon', (state) => state.customFields.get);\n\n if (!type) {\n return null;\n }\n\n let Compo = iconByTypes[type];\n\n if (customFieldUid) {\n const customField = getCustomField(customFieldUid);\n const CustomFieldIcon = customField?.icon;\n\n if (CustomFieldIcon) {\n Compo = (\n <Box marginRight={3} width={7} height={6}>\n <CustomFieldIcon />\n </Box>\n );\n }\n }\n\n if (!iconByTypes[type]) {\n return null;\n }\n\n return Compo;\n};\n\nexport { FieldTypeIcon };\n"],"names":["iconByTypes","biginteger","_jsx","NumberField","boolean","BooleanField","date","DateField","datetime","decimal","email","EmailField","enumeration","EnumerationField","float","integer","media","MediaField","password","PasswordField","relation","RelationField","string","TextField","text","richtext","time","timestamp","json","JsonField","uid","UidField","component","ComponentField","dynamiczone","DynamicZoneField","blocks","BlocksField","FieldTypeIcon","type","customFieldUid","getCustomField","useStrapiApp","state","customFields","get","Compo","customField","CustomFieldIcon","icon","Box","marginRight","width","height"],"mappings":";;;;;;;;AAuBA,MAAMA,WAAiE,GAAA;AACrEC,IAAAA,UAAAA,gBAAYC,cAACC,CAAAA,mBAAAA,EAAAA,EAAAA,CAAAA;AACbC,IAAAA,OAAAA,gBAASF,cAACG,CAAAA,oBAAAA,EAAAA,EAAAA,CAAAA;AACVC,IAAAA,IAAAA,gBAAMJ,cAACK,CAAAA,iBAAAA,EAAAA,EAAAA,CAAAA;AACPC,IAAAA,QAAAA,gBAAUN,cAACK,CAAAA,iBAAAA,EAAAA,EAAAA,CAAAA;AACXE,IAAAA,OAAAA,gBAASP,cAACC,CAAAA,mBAAAA,EAAAA,EAAAA,CAAAA;AACVO,IAAAA,KAAAA,gBAAOR,cAACS,CAAAA,kBAAAA,EAAAA,EAAAA,CAAAA;AACRC,IAAAA,WAAAA,gBAAaV,cAACW,CAAAA,wBAAAA,EAAAA,EAAAA,CAAAA;AACdC,IAAAA,KAAAA,gBAAOZ,cAACC,CAAAA,mBAAAA,EAAAA,EAAAA,CAAAA;AACRY,IAAAA,OAAAA,gBAASb,cAACC,CAAAA,mBAAAA,EAAAA,EAAAA,CAAAA;AACVa,IAAAA,KAAAA,gBAAOd,cAACe,CAAAA,kBAAAA,EAAAA,EAAAA,CAAAA;AACRC,IAAAA,QAAAA,gBAAUhB,cAACiB,CAAAA,qBAAAA,EAAAA,EAAAA,CAAAA;AACXC,IAAAA,QAAAA,gBAAUlB,cAACmB,CAAAA,qBAAAA,EAAAA,EAAAA,CAAAA;AACXC,IAAAA,MAAAA,gBAAQpB,cAACqB,CAAAA,iBAAAA,EAAAA,EAAAA,CAAAA;AACTC,IAAAA,IAAAA,gBAAMtB,cAACqB,CAAAA,iBAAAA,EAAAA,EAAAA,CAAAA;AACPE,IAAAA,QAAAA,gBAAUvB,cAACqB,CAAAA,iBAAAA,EAAAA,EAAAA,CAAAA;AACXG,IAAAA,IAAAA,gBAAMxB,cAACK,CAAAA,iBAAAA,EAAAA,EAAAA,CAAAA;AACPoB,IAAAA,SAAAA,gBAAWzB,cAACK,CAAAA,iBAAAA,EAAAA,EAAAA,CAAAA;AACZqB,IAAAA,IAAAA,gBAAM1B,cAAC2B,CAAAA,iBAAAA,EAAAA,EAAAA,CAAAA;AACPC,IAAAA,GAAAA,gBAAK5B,cAAC6B,CAAAA,gBAAAA,EAAAA,EAAAA,CAAAA;AACNC,IAAAA,SAAAA,gBAAW9B,cAAC+B,CAAAA,sBAAAA,EAAAA,EAAAA,CAAAA;AACZC,IAAAA,WAAAA,gBAAahC,cAACiC,CAAAA,wBAAAA,EAAAA,EAAAA,CAAAA;AACdC,IAAAA,MAAAA,gBAAQlC,cAACmC,CAAAA,mBAAAA,EAAAA,EAAAA;AACX,CAAA;AAOA,MAAMC,gBAAgB,CAAC,EAAEC,IAAI,EAAEC,cAAc,EAAsB,GAAA;IACjE,MAAMC,cAAAA,GAAiBC,yBAAa,eAAiB,EAAA,CAACC,QAAUA,KAAMC,CAAAA,YAAY,CAACC,GAAG,CAAA;AAEtF,IAAA,IAAI,CAACN,IAAM,EAAA;QACT,OAAO,IAAA;AACT;IAEA,IAAIO,KAAAA,GAAQ9C,WAAW,CAACuC,IAAK,CAAA;AAE7B,IAAA,IAAIC,cAAgB,EAAA;AAClB,QAAA,MAAMO,cAAcN,cAAeD,CAAAA,cAAAA,CAAAA;AACnC,QAAA,MAAMQ,kBAAkBD,WAAaE,EAAAA,IAAAA;AAErC,QAAA,IAAID,eAAiB,EAAA;AACnBF,YAAAA,KAAAA,iBACE5C,cAACgD,CAAAA,gBAAAA,EAAAA;gBAAIC,WAAa,EAAA,CAAA;gBAAGC,KAAO,EAAA,CAAA;gBAAGC,MAAQ,EAAA,CAAA;AACrC,gBAAA,QAAA,gBAAAnD,cAAC8C,CAAAA,eAAAA,EAAAA,EAAAA;;AAGP;AACF;AAEA,IAAA,IAAI,CAAChD,WAAW,CAACuC,IAAAA,CAAK,EAAE;QACtB,OAAO,IAAA;AACT;IAEA,OAAOO,KAAAA;AACT;;;;"}

View File

@@ -0,0 +1,56 @@
import { jsx } from 'react/jsx-runtime';
import 'react';
import { useStrapiApp } from '@strapi/admin/strapi-admin';
import { Box } from '@strapi/design-system';
import { NumberField, BooleanField, DateField, EmailField, EnumerationField, MediaField, PasswordField, RelationField, TextField, JsonField, UidField, ComponentField, DynamicZoneField, BlocksField } from '@strapi/icons/symbols';
const iconByTypes = {
biginteger: /*#__PURE__*/ jsx(NumberField, {}),
boolean: /*#__PURE__*/ jsx(BooleanField, {}),
date: /*#__PURE__*/ jsx(DateField, {}),
datetime: /*#__PURE__*/ jsx(DateField, {}),
decimal: /*#__PURE__*/ jsx(NumberField, {}),
email: /*#__PURE__*/ jsx(EmailField, {}),
enumeration: /*#__PURE__*/ jsx(EnumerationField, {}),
float: /*#__PURE__*/ jsx(NumberField, {}),
integer: /*#__PURE__*/ jsx(NumberField, {}),
media: /*#__PURE__*/ jsx(MediaField, {}),
password: /*#__PURE__*/ jsx(PasswordField, {}),
relation: /*#__PURE__*/ jsx(RelationField, {}),
string: /*#__PURE__*/ jsx(TextField, {}),
text: /*#__PURE__*/ jsx(TextField, {}),
richtext: /*#__PURE__*/ jsx(TextField, {}),
time: /*#__PURE__*/ jsx(DateField, {}),
timestamp: /*#__PURE__*/ jsx(DateField, {}),
json: /*#__PURE__*/ jsx(JsonField, {}),
uid: /*#__PURE__*/ jsx(UidField, {}),
component: /*#__PURE__*/ jsx(ComponentField, {}),
dynamiczone: /*#__PURE__*/ jsx(DynamicZoneField, {}),
blocks: /*#__PURE__*/ jsx(BlocksField, {})
};
const FieldTypeIcon = ({ type, customFieldUid })=>{
const getCustomField = useStrapiApp('FieldTypeIcon', (state)=>state.customFields.get);
if (!type) {
return null;
}
let Compo = iconByTypes[type];
if (customFieldUid) {
const customField = getCustomField(customFieldUid);
const CustomFieldIcon = customField?.icon;
if (CustomFieldIcon) {
Compo = /*#__PURE__*/ jsx(Box, {
marginRight: 3,
width: 7,
height: 6,
children: /*#__PURE__*/ jsx(CustomFieldIcon, {})
});
}
}
if (!iconByTypes[type]) {
return null;
}
return Compo;
};
export { FieldTypeIcon };
//# sourceMappingURL=FieldTypeIcon.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FieldTypeIcon.mjs","sources":["../../../admin/src/components/FieldTypeIcon.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useStrapiApp } from '@strapi/admin/strapi-admin';\nimport { Box } from '@strapi/design-system';\nimport {\n BlocksField,\n BooleanField,\n ComponentField,\n DateField,\n DynamicZoneField,\n EmailField,\n EnumerationField,\n JsonField,\n MediaField,\n NumberField,\n PasswordField,\n RelationField,\n TextField,\n UidField,\n} from '@strapi/icons/symbols';\n\nimport type { Schema } from '@strapi/types';\n\nconst iconByTypes: Record<Schema.Attribute.Kind, React.ReactElement> = {\n biginteger: <NumberField />,\n boolean: <BooleanField />,\n date: <DateField />,\n datetime: <DateField />,\n decimal: <NumberField />,\n email: <EmailField />,\n enumeration: <EnumerationField />,\n float: <NumberField />,\n integer: <NumberField />,\n media: <MediaField />,\n password: <PasswordField />,\n relation: <RelationField />,\n string: <TextField />,\n text: <TextField />,\n richtext: <TextField />,\n time: <DateField />,\n timestamp: <DateField />,\n json: <JsonField />,\n uid: <UidField />,\n component: <ComponentField />,\n dynamiczone: <DynamicZoneField />,\n blocks: <BlocksField />,\n};\n\ninterface FieldTypeIconProps {\n type?: keyof typeof iconByTypes;\n customFieldUid?: string;\n}\n\nconst FieldTypeIcon = ({ type, customFieldUid }: FieldTypeIconProps) => {\n const getCustomField = useStrapiApp('FieldTypeIcon', (state) => state.customFields.get);\n\n if (!type) {\n return null;\n }\n\n let Compo = iconByTypes[type];\n\n if (customFieldUid) {\n const customField = getCustomField(customFieldUid);\n const CustomFieldIcon = customField?.icon;\n\n if (CustomFieldIcon) {\n Compo = (\n <Box marginRight={3} width={7} height={6}>\n <CustomFieldIcon />\n </Box>\n );\n }\n }\n\n if (!iconByTypes[type]) {\n return null;\n }\n\n return Compo;\n};\n\nexport { FieldTypeIcon };\n"],"names":["iconByTypes","biginteger","_jsx","NumberField","boolean","BooleanField","date","DateField","datetime","decimal","email","EmailField","enumeration","EnumerationField","float","integer","media","MediaField","password","PasswordField","relation","RelationField","string","TextField","text","richtext","time","timestamp","json","JsonField","uid","UidField","component","ComponentField","dynamiczone","DynamicZoneField","blocks","BlocksField","FieldTypeIcon","type","customFieldUid","getCustomField","useStrapiApp","state","customFields","get","Compo","customField","CustomFieldIcon","icon","Box","marginRight","width","height"],"mappings":";;;;;;AAuBA,MAAMA,WAAiE,GAAA;AACrEC,IAAAA,UAAAA,gBAAYC,GAACC,CAAAA,WAAAA,EAAAA,EAAAA,CAAAA;AACbC,IAAAA,OAAAA,gBAASF,GAACG,CAAAA,YAAAA,EAAAA,EAAAA,CAAAA;AACVC,IAAAA,IAAAA,gBAAMJ,GAACK,CAAAA,SAAAA,EAAAA,EAAAA,CAAAA;AACPC,IAAAA,QAAAA,gBAAUN,GAACK,CAAAA,SAAAA,EAAAA,EAAAA,CAAAA;AACXE,IAAAA,OAAAA,gBAASP,GAACC,CAAAA,WAAAA,EAAAA,EAAAA,CAAAA;AACVO,IAAAA,KAAAA,gBAAOR,GAACS,CAAAA,UAAAA,EAAAA,EAAAA,CAAAA;AACRC,IAAAA,WAAAA,gBAAaV,GAACW,CAAAA,gBAAAA,EAAAA,EAAAA,CAAAA;AACdC,IAAAA,KAAAA,gBAAOZ,GAACC,CAAAA,WAAAA,EAAAA,EAAAA,CAAAA;AACRY,IAAAA,OAAAA,gBAASb,GAACC,CAAAA,WAAAA,EAAAA,EAAAA,CAAAA;AACVa,IAAAA,KAAAA,gBAAOd,GAACe,CAAAA,UAAAA,EAAAA,EAAAA,CAAAA;AACRC,IAAAA,QAAAA,gBAAUhB,GAACiB,CAAAA,aAAAA,EAAAA,EAAAA,CAAAA;AACXC,IAAAA,QAAAA,gBAAUlB,GAACmB,CAAAA,aAAAA,EAAAA,EAAAA,CAAAA;AACXC,IAAAA,MAAAA,gBAAQpB,GAACqB,CAAAA,SAAAA,EAAAA,EAAAA,CAAAA;AACTC,IAAAA,IAAAA,gBAAMtB,GAACqB,CAAAA,SAAAA,EAAAA,EAAAA,CAAAA;AACPE,IAAAA,QAAAA,gBAAUvB,GAACqB,CAAAA,SAAAA,EAAAA,EAAAA,CAAAA;AACXG,IAAAA,IAAAA,gBAAMxB,GAACK,CAAAA,SAAAA,EAAAA,EAAAA,CAAAA;AACPoB,IAAAA,SAAAA,gBAAWzB,GAACK,CAAAA,SAAAA,EAAAA,EAAAA,CAAAA;AACZqB,IAAAA,IAAAA,gBAAM1B,GAAC2B,CAAAA,SAAAA,EAAAA,EAAAA,CAAAA;AACPC,IAAAA,GAAAA,gBAAK5B,GAAC6B,CAAAA,QAAAA,EAAAA,EAAAA,CAAAA;AACNC,IAAAA,SAAAA,gBAAW9B,GAAC+B,CAAAA,cAAAA,EAAAA,EAAAA,CAAAA;AACZC,IAAAA,WAAAA,gBAAahC,GAACiC,CAAAA,gBAAAA,EAAAA,EAAAA,CAAAA;AACdC,IAAAA,MAAAA,gBAAQlC,GAACmC,CAAAA,WAAAA,EAAAA,EAAAA;AACX,CAAA;AAOA,MAAMC,gBAAgB,CAAC,EAAEC,IAAI,EAAEC,cAAc,EAAsB,GAAA;IACjE,MAAMC,cAAAA,GAAiBC,aAAa,eAAiB,EAAA,CAACC,QAAUA,KAAMC,CAAAA,YAAY,CAACC,GAAG,CAAA;AAEtF,IAAA,IAAI,CAACN,IAAM,EAAA;QACT,OAAO,IAAA;AACT;IAEA,IAAIO,KAAAA,GAAQ9C,WAAW,CAACuC,IAAK,CAAA;AAE7B,IAAA,IAAIC,cAAgB,EAAA;AAClB,QAAA,MAAMO,cAAcN,cAAeD,CAAAA,cAAAA,CAAAA;AACnC,QAAA,MAAMQ,kBAAkBD,WAAaE,EAAAA,IAAAA;AAErC,QAAA,IAAID,eAAiB,EAAA;AACnBF,YAAAA,KAAAA,iBACE5C,GAACgD,CAAAA,GAAAA,EAAAA;gBAAIC,WAAa,EAAA,CAAA;gBAAGC,KAAO,EAAA,CAAA;gBAAGC,MAAQ,EAAA,CAAA;AACrC,gBAAA,QAAA,gBAAAnD,GAAC8C,CAAAA,eAAAA,EAAAA,EAAAA;;AAGP;AACF;AAEA,IAAA,IAAI,CAAChD,WAAW,CAACuC,IAAAA,CAAK,EAAE;QACtB,OAAO,IAAA;AACT;IAEA,OAAOO,KAAAA;AACT;;;;"}

View File

@@ -0,0 +1,44 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var strapiAdmin = require('@strapi/admin/strapi-admin');
var plugin = require('../constants/plugin.js');
const INJECTION_ZONES = {
editView: {
informations: [],
'right-links': []
},
listView: {
actions: [],
deleteModalAdditionalInfos: [],
publishModalAdditionalInfos: [],
unpublishModalAdditionalInfos: []
},
preview: {
actions: []
}
};
/**
* You can't know what this component props will be because it's generic and used everywhere
* e.g. content-manager edit view, we just send the slug but we might not in the listView,
* therefore, people should type it themselves on the components they render.
*/ const InjectionZone = ({ area, ...props })=>{
const components = useInjectionZone(area);
return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
children: components.map((component)=>/*#__PURE__*/ jsxRuntime.jsx(component.Component, {
...props
}, component.name))
});
};
const useInjectionZone = (area)=>{
const getPlugin = strapiAdmin.useStrapiApp('useInjectionZone', (state)=>state.getPlugin);
const contentManagerPlugin = getPlugin(plugin.PLUGIN_ID);
const [page, position] = area.split('.');
return contentManagerPlugin.getInjectedComponents(page, position);
};
exports.INJECTION_ZONES = INJECTION_ZONES;
exports.InjectionZone = InjectionZone;
exports.useInjectionZone = useInjectionZone;
//# sourceMappingURL=InjectionZone.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"InjectionZone.js","sources":["../../../admin/src/components/InjectionZone.tsx"],"sourcesContent":["import { useStrapiApp, InjectionZoneComponent } from '@strapi/admin/strapi-admin';\n\nimport { PLUGIN_ID } from '../constants/plugin';\n\nconst INJECTION_ZONES = {\n editView: { informations: [], 'right-links': [] },\n listView: {\n actions: [],\n deleteModalAdditionalInfos: [],\n publishModalAdditionalInfos: [],\n unpublishModalAdditionalInfos: [],\n },\n preview: {\n actions: [],\n },\n} satisfies InjectionZones;\n\ninterface InjectionZones {\n editView: {\n informations: InjectionZoneComponent[];\n 'right-links': InjectionZoneComponent[];\n };\n listView: {\n actions: InjectionZoneComponent[];\n deleteModalAdditionalInfos: InjectionZoneComponent[];\n publishModalAdditionalInfos: InjectionZoneComponent[];\n unpublishModalAdditionalInfos: InjectionZoneComponent[];\n };\n preview: {\n actions: InjectionZoneComponent[];\n };\n}\n\ntype InjectionZoneArea =\n | 'editView.informations'\n | 'editView.right-links'\n | 'listView.actions'\n | 'listView.unpublishModalAdditionalInfos'\n | 'listView.deleteModalAdditionalInfos'\n | 'listView.publishModalAdditionalInfos'\n | 'listView.deleteModalAdditionalInfos'\n | 'preview.actions';\n\ntype InjectionZoneModule = InjectionZoneArea extends `${infer Word}.${string}` ? Word : never;\ntype InjectionZoneContainer = InjectionZoneArea extends `${string}.${infer Word}.${string}`\n ? Word\n : never;\ntype InjectionZoneBlock = InjectionZoneArea extends `${string}.${string}.${infer Word}`\n ? Word\n : never;\n\n/**\n * You can't know what this component props will be because it's generic and used everywhere\n * e.g. content-manager edit view, we just send the slug but we might not in the listView,\n * therefore, people should type it themselves on the components they render.\n */\nconst InjectionZone = ({ area, ...props }: { area: InjectionZoneArea; [key: string]: unknown }) => {\n const components = useInjectionZone(area);\n\n return (\n <>\n {components.map((component) => (\n <component.Component key={component.name} {...props} />\n ))}\n </>\n );\n};\n\nexport const useInjectionZone = (area: InjectionZoneArea) => {\n const getPlugin = useStrapiApp('useInjectionZone', (state) => state.getPlugin);\n const contentManagerPlugin = getPlugin(PLUGIN_ID);\n const [page, position] = area.split('.') as [InjectionZoneContainer, InjectionZoneBlock];\n\n return contentManagerPlugin.getInjectedComponents(page, position);\n};\n\nexport { InjectionZone, INJECTION_ZONES };\n\nexport type {\n InjectionZoneArea,\n InjectionZoneComponent,\n InjectionZones,\n InjectionZoneModule,\n InjectionZoneContainer,\n InjectionZoneBlock,\n};\n"],"names":["INJECTION_ZONES","editView","informations","listView","actions","deleteModalAdditionalInfos","publishModalAdditionalInfos","unpublishModalAdditionalInfos","preview","InjectionZone","area","props","components","useInjectionZone","_jsx","_Fragment","map","component","Component","name","getPlugin","useStrapiApp","state","contentManagerPlugin","PLUGIN_ID","page","position","split","getInjectedComponents"],"mappings":";;;;;;AAIA,MAAMA,eAAkB,GAAA;IACtBC,QAAU,EAAA;AAAEC,QAAAA,YAAAA,EAAc,EAAE;AAAE,QAAA,aAAA,EAAe;AAAG,KAAA;IAChDC,QAAU,EAAA;AACRC,QAAAA,OAAAA,EAAS,EAAE;AACXC,QAAAA,0BAAAA,EAA4B,EAAE;AAC9BC,QAAAA,2BAAAA,EAA6B,EAAE;AAC/BC,QAAAA,6BAAAA,EAA+B;AACjC,KAAA;IACAC,OAAS,EAAA;AACPJ,QAAAA,OAAAA,EAAS;AACX;AACF;AAoCA;;;;AAIC,UACKK,aAAgB,GAAA,CAAC,EAAEC,IAAI,EAAE,GAAGC,KAA4D,EAAA,GAAA;AAC5F,IAAA,MAAMC,aAAaC,gBAAiBH,CAAAA,IAAAA,CAAAA;IAEpC,qBACEI,cAAA,CAAAC,mBAAA,EAAA;AACGH,QAAAA,QAAAA,EAAAA,UAAAA,CAAWI,GAAG,CAAC,CAACC,SACf,iBAAAH,cAAA,CAACG,UAAUC,SAAS,EAAA;AAAuB,gBAAA,GAAGP;AAApBM,aAAAA,EAAAA,SAAAA,CAAUE,IAAI,CAAA;;AAIhD;AAEO,MAAMN,mBAAmB,CAACH,IAAAA,GAAAA;AAC/B,IAAA,MAAMU,YAAYC,wBAAa,CAAA,kBAAA,EAAoB,CAACC,KAAAA,GAAUA,MAAMF,SAAS,CAAA;AAC7E,IAAA,MAAMG,uBAAuBH,SAAUI,CAAAA,gBAAAA,CAAAA;AACvC,IAAA,MAAM,CAACC,IAAMC,EAAAA,QAAAA,CAAS,GAAGhB,IAAAA,CAAKiB,KAAK,CAAC,GAAA,CAAA;IAEpC,OAAOJ,oBAAAA,CAAqBK,qBAAqB,CAACH,IAAMC,EAAAA,QAAAA,CAAAA;AAC1D;;;;;;"}

View File

@@ -0,0 +1,40 @@
import { jsx, Fragment } from 'react/jsx-runtime';
import { useStrapiApp } from '@strapi/admin/strapi-admin';
import { PLUGIN_ID } from '../constants/plugin.mjs';
const INJECTION_ZONES = {
editView: {
informations: [],
'right-links': []
},
listView: {
actions: [],
deleteModalAdditionalInfos: [],
publishModalAdditionalInfos: [],
unpublishModalAdditionalInfos: []
},
preview: {
actions: []
}
};
/**
* You can't know what this component props will be because it's generic and used everywhere
* e.g. content-manager edit view, we just send the slug but we might not in the listView,
* therefore, people should type it themselves on the components they render.
*/ const InjectionZone = ({ area, ...props })=>{
const components = useInjectionZone(area);
return /*#__PURE__*/ jsx(Fragment, {
children: components.map((component)=>/*#__PURE__*/ jsx(component.Component, {
...props
}, component.name))
});
};
const useInjectionZone = (area)=>{
const getPlugin = useStrapiApp('useInjectionZone', (state)=>state.getPlugin);
const contentManagerPlugin = getPlugin(PLUGIN_ID);
const [page, position] = area.split('.');
return contentManagerPlugin.getInjectedComponents(page, position);
};
export { INJECTION_ZONES, InjectionZone, useInjectionZone };
//# sourceMappingURL=InjectionZone.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"InjectionZone.mjs","sources":["../../../admin/src/components/InjectionZone.tsx"],"sourcesContent":["import { useStrapiApp, InjectionZoneComponent } from '@strapi/admin/strapi-admin';\n\nimport { PLUGIN_ID } from '../constants/plugin';\n\nconst INJECTION_ZONES = {\n editView: { informations: [], 'right-links': [] },\n listView: {\n actions: [],\n deleteModalAdditionalInfos: [],\n publishModalAdditionalInfos: [],\n unpublishModalAdditionalInfos: [],\n },\n preview: {\n actions: [],\n },\n} satisfies InjectionZones;\n\ninterface InjectionZones {\n editView: {\n informations: InjectionZoneComponent[];\n 'right-links': InjectionZoneComponent[];\n };\n listView: {\n actions: InjectionZoneComponent[];\n deleteModalAdditionalInfos: InjectionZoneComponent[];\n publishModalAdditionalInfos: InjectionZoneComponent[];\n unpublishModalAdditionalInfos: InjectionZoneComponent[];\n };\n preview: {\n actions: InjectionZoneComponent[];\n };\n}\n\ntype InjectionZoneArea =\n | 'editView.informations'\n | 'editView.right-links'\n | 'listView.actions'\n | 'listView.unpublishModalAdditionalInfos'\n | 'listView.deleteModalAdditionalInfos'\n | 'listView.publishModalAdditionalInfos'\n | 'listView.deleteModalAdditionalInfos'\n | 'preview.actions';\n\ntype InjectionZoneModule = InjectionZoneArea extends `${infer Word}.${string}` ? Word : never;\ntype InjectionZoneContainer = InjectionZoneArea extends `${string}.${infer Word}.${string}`\n ? Word\n : never;\ntype InjectionZoneBlock = InjectionZoneArea extends `${string}.${string}.${infer Word}`\n ? Word\n : never;\n\n/**\n * You can't know what this component props will be because it's generic and used everywhere\n * e.g. content-manager edit view, we just send the slug but we might not in the listView,\n * therefore, people should type it themselves on the components they render.\n */\nconst InjectionZone = ({ area, ...props }: { area: InjectionZoneArea; [key: string]: unknown }) => {\n const components = useInjectionZone(area);\n\n return (\n <>\n {components.map((component) => (\n <component.Component key={component.name} {...props} />\n ))}\n </>\n );\n};\n\nexport const useInjectionZone = (area: InjectionZoneArea) => {\n const getPlugin = useStrapiApp('useInjectionZone', (state) => state.getPlugin);\n const contentManagerPlugin = getPlugin(PLUGIN_ID);\n const [page, position] = area.split('.') as [InjectionZoneContainer, InjectionZoneBlock];\n\n return contentManagerPlugin.getInjectedComponents(page, position);\n};\n\nexport { InjectionZone, INJECTION_ZONES };\n\nexport type {\n InjectionZoneArea,\n InjectionZoneComponent,\n InjectionZones,\n InjectionZoneModule,\n InjectionZoneContainer,\n InjectionZoneBlock,\n};\n"],"names":["INJECTION_ZONES","editView","informations","listView","actions","deleteModalAdditionalInfos","publishModalAdditionalInfos","unpublishModalAdditionalInfos","preview","InjectionZone","area","props","components","useInjectionZone","_jsx","_Fragment","map","component","Component","name","getPlugin","useStrapiApp","state","contentManagerPlugin","PLUGIN_ID","page","position","split","getInjectedComponents"],"mappings":";;;;AAIA,MAAMA,eAAkB,GAAA;IACtBC,QAAU,EAAA;AAAEC,QAAAA,YAAAA,EAAc,EAAE;AAAE,QAAA,aAAA,EAAe;AAAG,KAAA;IAChDC,QAAU,EAAA;AACRC,QAAAA,OAAAA,EAAS,EAAE;AACXC,QAAAA,0BAAAA,EAA4B,EAAE;AAC9BC,QAAAA,2BAAAA,EAA6B,EAAE;AAC/BC,QAAAA,6BAAAA,EAA+B;AACjC,KAAA;IACAC,OAAS,EAAA;AACPJ,QAAAA,OAAAA,EAAS;AACX;AACF;AAoCA;;;;AAIC,UACKK,aAAgB,GAAA,CAAC,EAAEC,IAAI,EAAE,GAAGC,KAA4D,EAAA,GAAA;AAC5F,IAAA,MAAMC,aAAaC,gBAAiBH,CAAAA,IAAAA,CAAAA;IAEpC,qBACEI,GAAA,CAAAC,QAAA,EAAA;AACGH,QAAAA,QAAAA,EAAAA,UAAAA,CAAWI,GAAG,CAAC,CAACC,SACf,iBAAAH,GAAA,CAACG,UAAUC,SAAS,EAAA;AAAuB,gBAAA,GAAGP;AAApBM,aAAAA,EAAAA,SAAAA,CAAUE,IAAI,CAAA;;AAIhD;AAEO,MAAMN,mBAAmB,CAACH,IAAAA,GAAAA;AAC/B,IAAA,MAAMU,YAAYC,YAAa,CAAA,kBAAA,EAAoB,CAACC,KAAAA,GAAUA,MAAMF,SAAS,CAAA;AAC7E,IAAA,MAAMG,uBAAuBH,SAAUI,CAAAA,SAAAA,CAAAA;AACvC,IAAA,MAAM,CAACC,IAAMC,EAAAA,QAAAA,CAAS,GAAGhB,IAAAA,CAAKiB,KAAK,CAAC,GAAA,CAAA;IAEpC,OAAOJ,oBAAAA,CAAqBK,qBAAqB,CAACH,IAAMC,EAAAA,QAAAA,CAAAA;AAC1D;;;;"}

View File

@@ -0,0 +1,172 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var React = 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 styledComponents = require('styled-components');
var useContentTypeSchema = require('../hooks/useContentTypeSchema.js');
var hooks = require('../modules/hooks.js');
var translations = require('../utils/translations.js');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
const SubNavLinkCustom = styledComponents.styled(designSystem.SubNavLink)`
div {
width: inherit;
span:nth-child(2) {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: inherit;
}
}
`;
const LeftMenu = ()=>{
const [search, setSearch] = React__namespace.useState('');
const [{ query }] = strapiAdmin.useQueryParams();
const { formatMessage, locale } = reactIntl.useIntl();
const collectionTypeLinks = hooks.useTypedSelector((state)=>state['content-manager'].app.collectionTypeLinks);
const singleTypeLinks = hooks.useTypedSelector((state)=>state['content-manager'].app.singleTypeLinks);
const { schemas } = useContentTypeSchema.useContentTypeSchema();
const { startsWith } = designSystem.useFilter(locale, {
sensitivity: 'base'
});
const formatter = designSystem.useCollator(locale, {
sensitivity: 'base'
});
const menu = React__namespace.useMemo(()=>[
{
id: 'collectionTypes',
title: formatMessage({
id: translations.getTranslation('components.LeftMenu.collection-types'),
defaultMessage: 'Collection Types'
}),
searchable: true,
links: collectionTypeLinks
},
{
id: 'singleTypes',
title: formatMessage({
id: translations.getTranslation('components.LeftMenu.single-types'),
defaultMessage: 'Single Types'
}),
searchable: true,
links: singleTypeLinks
}
].map((section)=>({
...section,
links: section.links/**
* Filter by the search value
*/ .filter((link)=>startsWith(link.title, search))/**
* Sort correctly using the language
*/ .sort((a, b)=>formatter.compare(a.title, b.title))/**
* Apply the formated strings to the links from react-intl
*/ .map((link)=>{
return {
...link,
title: formatMessage({
id: link.title,
defaultMessage: link.title
})
};
})
})), [
collectionTypeLinks,
search,
singleTypeLinks,
startsWith,
formatMessage,
formatter
]);
const handleClear = ()=>{
setSearch('');
};
const handleChangeSearch = ({ target: { value } })=>{
setSearch(value);
};
const label = formatMessage({
id: translations.getTranslation('header.name'),
defaultMessage: 'Content Manager'
});
const getPluginsParamsForLink = (link)=>{
const schema = schemas.find((schema)=>schema.uid === link.uid);
const isI18nEnabled = Boolean(schema?.pluginOptions?.i18n?.localized);
// The search params have the i18n plugin
if (query.plugins && 'i18n' in query.plugins) {
// Prepare removal of i18n from the plugins search params
const { i18n, ...restPlugins } = query.plugins;
// i18n is not enabled, remove it from the plugins search params
if (!isI18nEnabled) {
return restPlugins;
}
// i18n is enabled, put the plugins search params back together
return {
i18n,
...restPlugins
};
}
return query.plugins;
};
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.SubNav, {
"aria-label": label,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SubNavHeader, {
label: label,
searchable: true,
value: search,
onChange: handleChangeSearch,
onClear: handleClear,
searchLabel: formatMessage({
id: 'content-manager.components.LeftMenu.Search.label',
defaultMessage: 'Search for a content type'
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SubNavSections, {
children: menu.map((section)=>{
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.SubNavSection, {
label: section.title,
badgeLabel: section.links.length.toString(),
children: section.links.map((link)=>{
return /*#__PURE__*/ jsxRuntime.jsx(SubNavLinkCustom, {
tag: reactRouterDom.NavLink,
to: {
pathname: link.to,
search: qs.stringify({
...qs.parse(link.search ?? ''),
plugins: getPluginsParamsForLink(link)
})
},
width: "100%",
children: link.title
}, link.uid);
})
}, section.id);
})
})
]
});
};
exports.LeftMenu = LeftMenu;
//# sourceMappingURL=LeftMenu.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,151 @@
import { jsxs, jsx } from 'react/jsx-runtime';
import * as React from 'react';
import { useQueryParams } from '@strapi/admin/strapi-admin';
import { SubNavLink, useFilter, useCollator, SubNav, SubNavHeader, SubNavSections, SubNavSection } from '@strapi/design-system';
import { stringify, parse } from 'qs';
import { useIntl } from 'react-intl';
import { NavLink } from 'react-router-dom';
import { styled } from 'styled-components';
import { useContentTypeSchema } from '../hooks/useContentTypeSchema.mjs';
import { useTypedSelector } from '../modules/hooks.mjs';
import { getTranslation } from '../utils/translations.mjs';
const SubNavLinkCustom = styled(SubNavLink)`
div {
width: inherit;
span:nth-child(2) {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: inherit;
}
}
`;
const LeftMenu = ()=>{
const [search, setSearch] = React.useState('');
const [{ query }] = useQueryParams();
const { formatMessage, locale } = useIntl();
const collectionTypeLinks = useTypedSelector((state)=>state['content-manager'].app.collectionTypeLinks);
const singleTypeLinks = useTypedSelector((state)=>state['content-manager'].app.singleTypeLinks);
const { schemas } = useContentTypeSchema();
const { startsWith } = useFilter(locale, {
sensitivity: 'base'
});
const formatter = useCollator(locale, {
sensitivity: 'base'
});
const menu = React.useMemo(()=>[
{
id: 'collectionTypes',
title: formatMessage({
id: getTranslation('components.LeftMenu.collection-types'),
defaultMessage: 'Collection Types'
}),
searchable: true,
links: collectionTypeLinks
},
{
id: 'singleTypes',
title: formatMessage({
id: getTranslation('components.LeftMenu.single-types'),
defaultMessage: 'Single Types'
}),
searchable: true,
links: singleTypeLinks
}
].map((section)=>({
...section,
links: section.links/**
* Filter by the search value
*/ .filter((link)=>startsWith(link.title, search))/**
* Sort correctly using the language
*/ .sort((a, b)=>formatter.compare(a.title, b.title))/**
* Apply the formated strings to the links from react-intl
*/ .map((link)=>{
return {
...link,
title: formatMessage({
id: link.title,
defaultMessage: link.title
})
};
})
})), [
collectionTypeLinks,
search,
singleTypeLinks,
startsWith,
formatMessage,
formatter
]);
const handleClear = ()=>{
setSearch('');
};
const handleChangeSearch = ({ target: { value } })=>{
setSearch(value);
};
const label = formatMessage({
id: getTranslation('header.name'),
defaultMessage: 'Content Manager'
});
const getPluginsParamsForLink = (link)=>{
const schema = schemas.find((schema)=>schema.uid === link.uid);
const isI18nEnabled = Boolean(schema?.pluginOptions?.i18n?.localized);
// The search params have the i18n plugin
if (query.plugins && 'i18n' in query.plugins) {
// Prepare removal of i18n from the plugins search params
const { i18n, ...restPlugins } = query.plugins;
// i18n is not enabled, remove it from the plugins search params
if (!isI18nEnabled) {
return restPlugins;
}
// i18n is enabled, put the plugins search params back together
return {
i18n,
...restPlugins
};
}
return query.plugins;
};
return /*#__PURE__*/ jsxs(SubNav, {
"aria-label": label,
children: [
/*#__PURE__*/ jsx(SubNavHeader, {
label: label,
searchable: true,
value: search,
onChange: handleChangeSearch,
onClear: handleClear,
searchLabel: formatMessage({
id: 'content-manager.components.LeftMenu.Search.label',
defaultMessage: 'Search for a content type'
})
}),
/*#__PURE__*/ jsx(SubNavSections, {
children: menu.map((section)=>{
return /*#__PURE__*/ jsx(SubNavSection, {
label: section.title,
badgeLabel: section.links.length.toString(),
children: section.links.map((link)=>{
return /*#__PURE__*/ jsx(SubNavLinkCustom, {
tag: NavLink,
to: {
pathname: link.to,
search: stringify({
...parse(link.search ?? ''),
plugins: getPluginsParamsForLink(link)
})
},
width: "100%",
children: link.title
}, link.uid);
})
}, section.id);
})
})
]
});
};
export { LeftMenu };
//# sourceMappingURL=LeftMenu.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,76 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var dateFns = require('date-fns');
var reactIntl = require('react-intl');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
const intervals = [
'years',
'months',
'days',
'hours',
'minutes',
'seconds'
];
/**
* Displays the relative time between a given timestamp and the current time.
* You can display a custom message for given time intervals by passing an array of custom intervals.
*
* @example
* ```jsx
* <caption>Display "last hour" if the timestamp is less than an hour ago</caption>
* <RelativeTime
* timestamp={new Date('2021-01-01')}
* customIntervals={[
* { unit: 'hours', threshold: 1, text: 'last hour' },
* ]}
* ```
*/ const RelativeTime = /*#__PURE__*/ React__namespace.forwardRef(({ timestamp, customIntervals = [], ...restProps }, forwardedRef)=>{
const { formatRelativeTime, formatDate, formatTime } = reactIntl.useIntl();
/**
* TODO: make this auto-update, like a clock.
*/ const interval = dateFns.intervalToDuration({
start: timestamp,
end: Date.now()
});
const unit = intervals.find((intervalUnit)=>{
return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
}) ?? 'seconds';
const relativeTime = dateFns.isPast(timestamp) ? -interval[unit] : interval[unit];
// Display custom text if interval is less than the threshold
const customInterval = customIntervals.find((custom)=>interval[custom.unit] < custom.threshold);
const displayText = customInterval ? customInterval.text : formatRelativeTime(relativeTime, unit, {
numeric: 'auto'
});
return /*#__PURE__*/ jsxRuntime.jsx("time", {
ref: forwardedRef,
dateTime: timestamp.toISOString(),
role: "time",
title: `${formatDate(timestamp)} ${formatTime(timestamp)}`,
...restProps,
children: displayText
});
});
exports.RelativeTime = RelativeTime;
//# sourceMappingURL=RelativeTime.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"RelativeTime.js","sources":["../../../admin/src/components/RelativeTime.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Duration, intervalToDuration, isPast } from 'date-fns';\nimport { useIntl } from 'react-intl';\n\nconst intervals: Array<keyof Duration> = ['years', 'months', 'days', 'hours', 'minutes', 'seconds'];\n\ninterface CustomInterval {\n unit: keyof Duration;\n text: string;\n threshold: number;\n}\n\ninterface RelativeTimeProps extends React.ComponentPropsWithoutRef<'time'> {\n timestamp: Date;\n customIntervals?: CustomInterval[];\n}\n\n/**\n * Displays the relative time between a given timestamp and the current time.\n * You can display a custom message for given time intervals by passing an array of custom intervals.\n *\n * @example\n * ```jsx\n * <caption>Display \"last hour\" if the timestamp is less than an hour ago</caption>\n * <RelativeTime\n * timestamp={new Date('2021-01-01')}\n * customIntervals={[\n * { unit: 'hours', threshold: 1, text: 'last hour' },\n * ]}\n * ```\n */\nconst RelativeTime = React.forwardRef<HTMLTimeElement, RelativeTimeProps>(\n ({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {\n const { formatRelativeTime, formatDate, formatTime } = useIntl();\n\n /**\n * TODO: make this auto-update, like a clock.\n */\n const interval = intervalToDuration({\n start: timestamp,\n end: Date.now(),\n // see https://github.com/date-fns/date-fns/issues/2891 No idea why it's all partial it returns it every time.\n }) as Required<Duration>;\n\n const unit =\n intervals.find((intervalUnit) => {\n return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);\n }) ?? 'seconds';\n\n const relativeTime = isPast(timestamp) ? -interval[unit] : interval[unit];\n\n // Display custom text if interval is less than the threshold\n const customInterval = customIntervals.find(\n (custom) => interval[custom.unit] < custom.threshold\n );\n\n const displayText = customInterval\n ? customInterval.text\n : formatRelativeTime(relativeTime, unit, { numeric: 'auto' });\n\n return (\n <time\n ref={forwardedRef}\n dateTime={timestamp.toISOString()}\n role=\"time\"\n title={`${formatDate(timestamp)} ${formatTime(timestamp)}`}\n {...restProps}\n >\n {displayText}\n </time>\n );\n }\n);\n\nexport { RelativeTime };\nexport type { CustomInterval, RelativeTimeProps };\n"],"names":["intervals","RelativeTime","React","forwardRef","timestamp","customIntervals","restProps","forwardedRef","formatRelativeTime","formatDate","formatTime","useIntl","interval","intervalToDuration","start","end","Date","now","unit","find","intervalUnit","Object","keys","includes","relativeTime","isPast","customInterval","custom","threshold","displayText","text","numeric","_jsx","time","ref","dateTime","toISOString","role","title"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAMA,SAAmC,GAAA;AAAC,IAAA,OAAA;AAAS,IAAA,QAAA;AAAU,IAAA,MAAA;AAAQ,IAAA,OAAA;AAAS,IAAA,SAAA;AAAW,IAAA;AAAU,CAAA;AAanG;;;;;;;;;;;;;AAaC,IACKC,MAAAA,YAAAA,iBAAeC,gBAAMC,CAAAA,UAAU,CACnC,CAAC,EAAEC,SAAS,EAAEC,eAAkB,GAAA,EAAE,EAAE,GAAGC,WAAW,EAAEC,YAAAA,GAAAA;AAClD,IAAA,MAAM,EAAEC,kBAAkB,EAAEC,UAAU,EAAEC,UAAU,EAAE,GAAGC,iBAAAA,EAAAA;AAEvD;;QAGA,MAAMC,WAAWC,0BAAmB,CAAA;QAClCC,KAAOV,EAAAA,SAAAA;AACPW,QAAAA,GAAAA,EAAKC,KAAKC,GAAG;AAEf,KAAA,CAAA;AAEA,IAAA,MAAMC,IACJlB,GAAAA,SAAAA,CAAUmB,IAAI,CAAC,CAACC,YAAAA,GAAAA;QACd,OAAOR,QAAQ,CAACQ,YAAAA,CAAa,GAAG,CAAA,IAAKC,OAAOC,IAAI,CAACV,QAAUW,CAAAA,CAAAA,QAAQ,CAACH,YAAAA,CAAAA;KAChE,CAAA,IAAA,SAAA;IAER,MAAMI,YAAAA,GAAeC,cAAOrB,CAAAA,SAAAA,CAAAA,GAAa,CAACQ,QAAQ,CAACM,IAAK,CAAA,GAAGN,QAAQ,CAACM,IAAK,CAAA;;AAGzE,IAAA,MAAMQ,cAAiBrB,GAAAA,eAAAA,CAAgBc,IAAI,CACzC,CAACQ,MAAAA,GAAWf,QAAQ,CAACe,MAAOT,CAAAA,IAAI,CAAC,GAAGS,OAAOC,SAAS,CAAA;AAGtD,IAAA,MAAMC,cAAcH,cAChBA,GAAAA,cAAAA,CAAeI,IAAI,GACnBtB,kBAAAA,CAAmBgB,cAAcN,IAAM,EAAA;QAAEa,OAAS,EAAA;AAAO,KAAA,CAAA;AAE7D,IAAA,qBACEC,cAACC,CAAAA,MAAAA,EAAAA;QACCC,GAAK3B,EAAAA,YAAAA;AACL4B,QAAAA,QAAAA,EAAU/B,UAAUgC,WAAW,EAAA;QAC/BC,IAAK,EAAA,MAAA;QACLC,KAAO,EAAA,CAAC,EAAE7B,UAAWL,CAAAA,SAAAA,CAAAA,CAAW,CAAC,EAAEM,UAAAA,CAAWN,WAAW,CAAC;AACzD,QAAA,GAAGE,SAAS;AAEZuB,QAAAA,QAAAA,EAAAA;;AAGP,CAAA;;;;"}

View File

@@ -0,0 +1,55 @@
import { jsx } from 'react/jsx-runtime';
import * as React from 'react';
import { intervalToDuration, isPast } from 'date-fns';
import { useIntl } from 'react-intl';
const intervals = [
'years',
'months',
'days',
'hours',
'minutes',
'seconds'
];
/**
* Displays the relative time between a given timestamp and the current time.
* You can display a custom message for given time intervals by passing an array of custom intervals.
*
* @example
* ```jsx
* <caption>Display "last hour" if the timestamp is less than an hour ago</caption>
* <RelativeTime
* timestamp={new Date('2021-01-01')}
* customIntervals={[
* { unit: 'hours', threshold: 1, text: 'last hour' },
* ]}
* ```
*/ const RelativeTime = /*#__PURE__*/ React.forwardRef(({ timestamp, customIntervals = [], ...restProps }, forwardedRef)=>{
const { formatRelativeTime, formatDate, formatTime } = useIntl();
/**
* TODO: make this auto-update, like a clock.
*/ const interval = intervalToDuration({
start: timestamp,
end: Date.now()
});
const unit = intervals.find((intervalUnit)=>{
return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
}) ?? 'seconds';
const relativeTime = isPast(timestamp) ? -interval[unit] : interval[unit];
// Display custom text if interval is less than the threshold
const customInterval = customIntervals.find((custom)=>interval[custom.unit] < custom.threshold);
const displayText = customInterval ? customInterval.text : formatRelativeTime(relativeTime, unit, {
numeric: 'auto'
});
return /*#__PURE__*/ jsx("time", {
ref: forwardedRef,
dateTime: timestamp.toISOString(),
role: "time",
title: `${formatDate(timestamp)} ${formatTime(timestamp)}`,
...restProps,
children: displayText
});
});
export { RelativeTime };
//# sourceMappingURL=RelativeTime.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"RelativeTime.mjs","sources":["../../../admin/src/components/RelativeTime.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Duration, intervalToDuration, isPast } from 'date-fns';\nimport { useIntl } from 'react-intl';\n\nconst intervals: Array<keyof Duration> = ['years', 'months', 'days', 'hours', 'minutes', 'seconds'];\n\ninterface CustomInterval {\n unit: keyof Duration;\n text: string;\n threshold: number;\n}\n\ninterface RelativeTimeProps extends React.ComponentPropsWithoutRef<'time'> {\n timestamp: Date;\n customIntervals?: CustomInterval[];\n}\n\n/**\n * Displays the relative time between a given timestamp and the current time.\n * You can display a custom message for given time intervals by passing an array of custom intervals.\n *\n * @example\n * ```jsx\n * <caption>Display \"last hour\" if the timestamp is less than an hour ago</caption>\n * <RelativeTime\n * timestamp={new Date('2021-01-01')}\n * customIntervals={[\n * { unit: 'hours', threshold: 1, text: 'last hour' },\n * ]}\n * ```\n */\nconst RelativeTime = React.forwardRef<HTMLTimeElement, RelativeTimeProps>(\n ({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {\n const { formatRelativeTime, formatDate, formatTime } = useIntl();\n\n /**\n * TODO: make this auto-update, like a clock.\n */\n const interval = intervalToDuration({\n start: timestamp,\n end: Date.now(),\n // see https://github.com/date-fns/date-fns/issues/2891 No idea why it's all partial it returns it every time.\n }) as Required<Duration>;\n\n const unit =\n intervals.find((intervalUnit) => {\n return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);\n }) ?? 'seconds';\n\n const relativeTime = isPast(timestamp) ? -interval[unit] : interval[unit];\n\n // Display custom text if interval is less than the threshold\n const customInterval = customIntervals.find(\n (custom) => interval[custom.unit] < custom.threshold\n );\n\n const displayText = customInterval\n ? customInterval.text\n : formatRelativeTime(relativeTime, unit, { numeric: 'auto' });\n\n return (\n <time\n ref={forwardedRef}\n dateTime={timestamp.toISOString()}\n role=\"time\"\n title={`${formatDate(timestamp)} ${formatTime(timestamp)}`}\n {...restProps}\n >\n {displayText}\n </time>\n );\n }\n);\n\nexport { RelativeTime };\nexport type { CustomInterval, RelativeTimeProps };\n"],"names":["intervals","RelativeTime","React","forwardRef","timestamp","customIntervals","restProps","forwardedRef","formatRelativeTime","formatDate","formatTime","useIntl","interval","intervalToDuration","start","end","Date","now","unit","find","intervalUnit","Object","keys","includes","relativeTime","isPast","customInterval","custom","threshold","displayText","text","numeric","_jsx","time","ref","dateTime","toISOString","role","title"],"mappings":";;;;;AAKA,MAAMA,SAAmC,GAAA;AAAC,IAAA,OAAA;AAAS,IAAA,QAAA;AAAU,IAAA,MAAA;AAAQ,IAAA,OAAA;AAAS,IAAA,SAAA;AAAW,IAAA;AAAU,CAAA;AAanG;;;;;;;;;;;;;AAaC,IACKC,MAAAA,YAAAA,iBAAeC,KAAMC,CAAAA,UAAU,CACnC,CAAC,EAAEC,SAAS,EAAEC,eAAkB,GAAA,EAAE,EAAE,GAAGC,WAAW,EAAEC,YAAAA,GAAAA;AAClD,IAAA,MAAM,EAAEC,kBAAkB,EAAEC,UAAU,EAAEC,UAAU,EAAE,GAAGC,OAAAA,EAAAA;AAEvD;;QAGA,MAAMC,WAAWC,kBAAmB,CAAA;QAClCC,KAAOV,EAAAA,SAAAA;AACPW,QAAAA,GAAAA,EAAKC,KAAKC,GAAG;AAEf,KAAA,CAAA;AAEA,IAAA,MAAMC,IACJlB,GAAAA,SAAAA,CAAUmB,IAAI,CAAC,CAACC,YAAAA,GAAAA;QACd,OAAOR,QAAQ,CAACQ,YAAAA,CAAa,GAAG,CAAA,IAAKC,OAAOC,IAAI,CAACV,QAAUW,CAAAA,CAAAA,QAAQ,CAACH,YAAAA,CAAAA;KAChE,CAAA,IAAA,SAAA;IAER,MAAMI,YAAAA,GAAeC,MAAOrB,CAAAA,SAAAA,CAAAA,GAAa,CAACQ,QAAQ,CAACM,IAAK,CAAA,GAAGN,QAAQ,CAACM,IAAK,CAAA;;AAGzE,IAAA,MAAMQ,cAAiBrB,GAAAA,eAAAA,CAAgBc,IAAI,CACzC,CAACQ,MAAAA,GAAWf,QAAQ,CAACe,MAAOT,CAAAA,IAAI,CAAC,GAAGS,OAAOC,SAAS,CAAA;AAGtD,IAAA,MAAMC,cAAcH,cAChBA,GAAAA,cAAAA,CAAeI,IAAI,GACnBtB,kBAAAA,CAAmBgB,cAAcN,IAAM,EAAA;QAAEa,OAAS,EAAA;AAAO,KAAA,CAAA;AAE7D,IAAA,qBACEC,GAACC,CAAAA,MAAAA,EAAAA;QACCC,GAAK3B,EAAAA,YAAAA;AACL4B,QAAAA,QAAAA,EAAU/B,UAAUgC,WAAW,EAAA;QAC/BC,IAAK,EAAA,MAAA;QACLC,KAAO,EAAA,CAAC,EAAE7B,UAAWL,CAAAA,SAAAA,CAAAA,CAAW,CAAC,EAAEM,UAAAA,CAAWN,WAAW,CAAC;AACzD,QAAA,GAAGE,SAAS;AAEZuB,QAAAA,QAAAA,EAAAA;;AAGP,CAAA;;;;"}

View File

@@ -0,0 +1,161 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var strapiAdmin = require('@strapi/admin/strapi-admin');
var designSystem = require('@strapi/design-system');
var Icons = require('@strapi/icons');
var reactIntl = require('react-intl');
var reactRouterDom = require('react-router-dom');
var styledComponents = require('styled-components');
var DocumentStatus = require('../pages/EditView/components/DocumentStatus.js');
var homepage = require('../services/homepage.js');
var RelativeTime = require('./RelativeTime.js');
const CellTypography = styledComponents.styled(designSystem.Typography).attrs({
maxWidth: '14.4rem',
display: 'block'
})`
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`;
const RecentDocumentsTable = ({ documents })=>{
const { formatMessage } = reactIntl.useIntl();
const { trackUsage } = strapiAdmin.useTracking();
const navigate = reactRouterDom.useNavigate();
const getEditViewLink = (document)=>{
const isSingleType = document.kind === 'singleType';
const kindPath = isSingleType ? 'single-types' : 'collection-types';
const queryParams = document.locale ? `?plugins[i18n][locale]=${document.locale}` : '';
return `/content-manager/${kindPath}/${document.contentTypeUid}${isSingleType ? '' : '/' + document.documentId}${queryParams}`;
};
const handleRowClick = (document)=>()=>{
trackUsage('willEditEntryFromHome');
const link = getEditViewLink(document);
navigate(link);
};
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Table, {
colCount: 5,
rowCount: documents?.length ?? 0,
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Tbody, {
children: documents?.map((document)=>/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Tr, {
onClick: handleRowClick(document),
cursor: "pointer",
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Td, {
children: /*#__PURE__*/ jsxRuntime.jsx(CellTypography, {
title: document.title,
variant: "omega",
textColor: "neutral800",
children: document.title
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Td, {
children: /*#__PURE__*/ jsxRuntime.jsx(CellTypography, {
variant: "omega",
textColor: "neutral600",
children: document.kind === 'singleType' ? formatMessage({
id: 'content-manager.widget.last-edited.single-type',
defaultMessage: 'Single-Type'
}) : formatMessage({
id: document.contentTypeDisplayName,
defaultMessage: document.contentTypeDisplayName
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Td, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
display: "inline-block",
children: document.status ? /*#__PURE__*/ jsxRuntime.jsx(DocumentStatus.DocumentStatus, {
status: document.status
}) : /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
textColor: "neutral600",
"aria-hidden": true,
children: "-"
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Td, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
textColor: "neutral600",
children: /*#__PURE__*/ jsxRuntime.jsx(RelativeTime.RelativeTime, {
timestamp: new Date(document.updatedAt)
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Td, {
onClick: (e)=>e.stopPropagation(),
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
display: "inline-block",
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
tag: reactRouterDom.Link,
to: getEditViewLink(document),
onClick: ()=>trackUsage('willEditEntryFromHome'),
label: formatMessage({
id: 'content-manager.actions.edit.label',
defaultMessage: 'Edit'
}),
variant: "ghost",
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Pencil, {})
})
})
})
]
}, document.documentId))
})
});
};
/* -------------------------------------------------------------------------------------------------
* LastEditedWidget
* -----------------------------------------------------------------------------------------------*/ const LastEditedWidget = ()=>{
const { formatMessage } = reactIntl.useIntl();
const { data, isLoading, error } = homepage.useGetRecentDocumentsQuery({
action: 'update'
});
if (isLoading) {
return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Widget.Loading, {});
}
if (error || !data) {
return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Widget.Error, {});
}
if (data.length === 0) {
return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Widget.NoData, {
children: formatMessage({
id: 'content-manager.widget.last-edited.no-data',
defaultMessage: 'No edited entries'
})
});
}
return /*#__PURE__*/ jsxRuntime.jsx(RecentDocumentsTable, {
documents: data
});
};
/* -------------------------------------------------------------------------------------------------
* LastPublishedWidget
* -----------------------------------------------------------------------------------------------*/ const LastPublishedWidget = ()=>{
const { formatMessage } = reactIntl.useIntl();
const { data, isLoading, error } = homepage.useGetRecentDocumentsQuery({
action: 'publish'
});
if (isLoading) {
return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Widget.Loading, {});
}
if (error || !data) {
return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Widget.Error, {});
}
if (data.length === 0) {
return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Widget.NoData, {
children: formatMessage({
id: 'content-manager.widget.last-published.no-data',
defaultMessage: 'No published entries'
})
});
}
return /*#__PURE__*/ jsxRuntime.jsx(RecentDocumentsTable, {
documents: data
});
};
exports.LastEditedWidget = LastEditedWidget;
exports.LastPublishedWidget = LastPublishedWidget;
//# sourceMappingURL=Widgets.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,158 @@
import { jsx, jsxs } from 'react/jsx-runtime';
import { Widget, useTracking } from '@strapi/admin/strapi-admin';
import { Typography, Table, Tbody, Tr, Td, Box, IconButton } from '@strapi/design-system';
import { Pencil } from '@strapi/icons';
import { useIntl } from 'react-intl';
import { useNavigate, Link } from 'react-router-dom';
import { styled } from 'styled-components';
import { DocumentStatus } from '../pages/EditView/components/DocumentStatus.mjs';
import { useGetRecentDocumentsQuery } from '../services/homepage.mjs';
import { RelativeTime } from './RelativeTime.mjs';
const CellTypography = styled(Typography).attrs({
maxWidth: '14.4rem',
display: 'block'
})`
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`;
const RecentDocumentsTable = ({ documents })=>{
const { formatMessage } = useIntl();
const { trackUsage } = useTracking();
const navigate = useNavigate();
const getEditViewLink = (document)=>{
const isSingleType = document.kind === 'singleType';
const kindPath = isSingleType ? 'single-types' : 'collection-types';
const queryParams = document.locale ? `?plugins[i18n][locale]=${document.locale}` : '';
return `/content-manager/${kindPath}/${document.contentTypeUid}${isSingleType ? '' : '/' + document.documentId}${queryParams}`;
};
const handleRowClick = (document)=>()=>{
trackUsage('willEditEntryFromHome');
const link = getEditViewLink(document);
navigate(link);
};
return /*#__PURE__*/ jsx(Table, {
colCount: 5,
rowCount: documents?.length ?? 0,
children: /*#__PURE__*/ jsx(Tbody, {
children: documents?.map((document)=>/*#__PURE__*/ jsxs(Tr, {
onClick: handleRowClick(document),
cursor: "pointer",
children: [
/*#__PURE__*/ jsx(Td, {
children: /*#__PURE__*/ jsx(CellTypography, {
title: document.title,
variant: "omega",
textColor: "neutral800",
children: document.title
})
}),
/*#__PURE__*/ jsx(Td, {
children: /*#__PURE__*/ jsx(CellTypography, {
variant: "omega",
textColor: "neutral600",
children: document.kind === 'singleType' ? formatMessage({
id: 'content-manager.widget.last-edited.single-type',
defaultMessage: 'Single-Type'
}) : formatMessage({
id: document.contentTypeDisplayName,
defaultMessage: document.contentTypeDisplayName
})
})
}),
/*#__PURE__*/ jsx(Td, {
children: /*#__PURE__*/ jsx(Box, {
display: "inline-block",
children: document.status ? /*#__PURE__*/ jsx(DocumentStatus, {
status: document.status
}) : /*#__PURE__*/ jsx(Typography, {
textColor: "neutral600",
"aria-hidden": true,
children: "-"
})
})
}),
/*#__PURE__*/ jsx(Td, {
children: /*#__PURE__*/ jsx(Typography, {
textColor: "neutral600",
children: /*#__PURE__*/ jsx(RelativeTime, {
timestamp: new Date(document.updatedAt)
})
})
}),
/*#__PURE__*/ jsx(Td, {
onClick: (e)=>e.stopPropagation(),
children: /*#__PURE__*/ jsx(Box, {
display: "inline-block",
children: /*#__PURE__*/ jsx(IconButton, {
tag: Link,
to: getEditViewLink(document),
onClick: ()=>trackUsage('willEditEntryFromHome'),
label: formatMessage({
id: 'content-manager.actions.edit.label',
defaultMessage: 'Edit'
}),
variant: "ghost",
children: /*#__PURE__*/ jsx(Pencil, {})
})
})
})
]
}, document.documentId))
})
});
};
/* -------------------------------------------------------------------------------------------------
* LastEditedWidget
* -----------------------------------------------------------------------------------------------*/ const LastEditedWidget = ()=>{
const { formatMessage } = useIntl();
const { data, isLoading, error } = useGetRecentDocumentsQuery({
action: 'update'
});
if (isLoading) {
return /*#__PURE__*/ jsx(Widget.Loading, {});
}
if (error || !data) {
return /*#__PURE__*/ jsx(Widget.Error, {});
}
if (data.length === 0) {
return /*#__PURE__*/ jsx(Widget.NoData, {
children: formatMessage({
id: 'content-manager.widget.last-edited.no-data',
defaultMessage: 'No edited entries'
})
});
}
return /*#__PURE__*/ jsx(RecentDocumentsTable, {
documents: data
});
};
/* -------------------------------------------------------------------------------------------------
* LastPublishedWidget
* -----------------------------------------------------------------------------------------------*/ const LastPublishedWidget = ()=>{
const { formatMessage } = useIntl();
const { data, isLoading, error } = useGetRecentDocumentsQuery({
action: 'publish'
});
if (isLoading) {
return /*#__PURE__*/ jsx(Widget.Loading, {});
}
if (error || !data) {
return /*#__PURE__*/ jsx(Widget.Error, {});
}
if (data.length === 0) {
return /*#__PURE__*/ jsx(Widget.NoData, {
children: formatMessage({
id: 'content-manager.widget.last-published.no-data',
defaultMessage: 'No published entries'
})
});
}
return /*#__PURE__*/ jsx(RecentDocumentsTable, {
documents: data
});
};
export { LastEditedWidget, LastPublishedWidget };
//# sourceMappingURL=Widgets.mjs.map

File diff suppressed because one or more lines are too long