UNPKG

strapi-plugin-email-designer-v5

Version:
84 lines (83 loc) 2.59 kB
import { useRef, useEffect } from "react"; import { jsx } from "react/jsx-runtime"; import { BsEnvelopeHeartFill } from "react-icons/bs"; const __variableDynamicImportRuntimeHelper = (glob, path, segs) => { const v = glob[path]; if (v) { return typeof v === "function" ? v() : Promise.resolve(v); } return new Promise((_, reject) => { (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)( reject.bind( null, new Error( "Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "") ) ) ); }); }; const PLUGIN_ID = "email-designer-v5"; const pluginName = "email-designer-v5"; const Initializer = ({ setPlugin }) => { const ref = useRef(setPlugin); useEffect(() => { ref.current(PLUGIN_ID); }, []); return null; }; const PluginIcon = () => /* @__PURE__ */ jsx(BsEnvelopeHeartFill, { size: 18 }); const APP_PERMISSIONS = { "menu-link": [{ action: `plugin::${pluginName}.menu-link`, subject: null }] }; const prefixPluginTranslations = (trad, pluginId) => { return Object.keys(trad).reduce((acc, current) => { acc[`${pluginId}.${current}`] = trad[current]; return acc; }, {}); }; const index = { register(app) { app.addMenuLink({ to: `plugins/${PLUGIN_ID}`, icon: PluginIcon, intlLabel: { id: `${PLUGIN_ID}.plugin.name`, defaultMessage: PLUGIN_ID }, Component: () => import("./App-CLh0Fy7E.mjs").then((mod) => ({ default: mod.App })), permissions: APP_PERMISSIONS["menu-link"] }); app.registerPlugin({ id: PLUGIN_ID, initializer: Initializer, isReady: false, name: PLUGIN_ID }); }, async registerTrads({ locales }) { const importedTrads = await Promise.all( locales.map((locale) => { return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("./en-Bb-oHGst.mjs"), "./translations/es.json": () => import("./es-DJSfNmGR.mjs"), "./translations/fr.json": () => import("./fr-BTtZ_ujZ.mjs") }), `./translations/${locale}.json`, 3).then(({ default: data }) => { return { data: prefixPluginTranslations(data, PLUGIN_ID), locale }; }).catch(() => { return { data: {}, locale }; }); }) ); return Promise.resolve(importedTrads); } }; export { PLUGIN_ID as P, index as i, pluginName as p };