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.
49 lines (48 loc) • 2.16 kB
JavaScript
import { jsx } from "react/jsx-runtime";
import { s as useStrapiApp, cA as ForwardRef$j, cB as ForwardRef$11, cC as ForwardRef$V, cD as ForwardRef$N, cE as ForwardRef$D, cF as ForwardRef$n, cG as ForwardRef$h, cH as ForwardRef$b, cI as ForwardRef$5, cJ as ForwardRef$r, cK as ForwardRef$3, cL as ForwardRef$X, cM as ForwardRef$P, cN as ForwardRef$13 } from "./index-DX9HaYlZ.mjs";
import { Box } from "@strapi/design-system";
const iconByTypes = {
biginteger: /* @__PURE__ */ jsx(ForwardRef$j, {}),
boolean: /* @__PURE__ */ jsx(ForwardRef$11, {}),
date: /* @__PURE__ */ jsx(ForwardRef$V, {}),
datetime: /* @__PURE__ */ jsx(ForwardRef$V, {}),
decimal: /* @__PURE__ */ jsx(ForwardRef$j, {}),
email: /* @__PURE__ */ jsx(ForwardRef$N, {}),
enumeration: /* @__PURE__ */ jsx(ForwardRef$D, {}),
float: /* @__PURE__ */ jsx(ForwardRef$j, {}),
integer: /* @__PURE__ */ jsx(ForwardRef$j, {}),
media: /* @__PURE__ */ jsx(ForwardRef$n, {}),
password: /* @__PURE__ */ jsx(ForwardRef$h, {}),
relation: /* @__PURE__ */ jsx(ForwardRef$b, {}),
string: /* @__PURE__ */ jsx(ForwardRef$5, {}),
text: /* @__PURE__ */ jsx(ForwardRef$5, {}),
richtext: /* @__PURE__ */ jsx(ForwardRef$5, {}),
time: /* @__PURE__ */ jsx(ForwardRef$V, {}),
timestamp: /* @__PURE__ */ jsx(ForwardRef$V, {}),
json: /* @__PURE__ */ jsx(ForwardRef$r, {}),
uid: /* @__PURE__ */ jsx(ForwardRef$3, {}),
component: /* @__PURE__ */ jsx(ForwardRef$X, {}),
dynamiczone: /* @__PURE__ */ jsx(ForwardRef$P, {}),
blocks: /* @__PURE__ */ jsx(ForwardRef$13, {})
};
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 as F
};