strapi-plugin-preview-button
Version:
A plugin for Strapi CMS that adds a preview button and live view button to the content manager edit view.
48 lines (47 loc) • 2.36 kB
JavaScript
"use strict";
const jsxRuntime = require("react/jsx-runtime");
const index = require("./index-CSWOFhNV.js");
const designSystem = require("@strapi/design-system");
const iconByTypes = {
biginteger: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$j$1, {}),
boolean: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$11$1, {}),
date: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$V$1, {}),
datetime: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$V$1, {}),
decimal: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$j$1, {}),
email: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$N$1, {}),
enumeration: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$D$1, {}),
float: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$j$1, {}),
integer: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$j$1, {}),
media: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$n$1, {}),
password: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$h$1, {}),
relation: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$b$1, {}),
string: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$5$1, {}),
text: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$5$1, {}),
richtext: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$5$1, {}),
time: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$V$1, {}),
timestamp: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$V$1, {}),
json: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$r$1, {}),
uid: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$3$1, {}),
component: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$X$1, {}),
dynamiczone: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$P$1, {}),
blocks: /* @__PURE__ */ jsxRuntime.jsx(index.ForwardRef$13$1, {})
};
const FieldTypeIcon = ({ type, customFieldUid }) => {
const getCustomField = index.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;