UNPKG

@inspirer-dev/hero-widget-cta-button

Version:

A custom field plugin for Strapi v5 that provides a CTA button selector with different action types (external link, internal link, case, article, copy link, copy nickname).

76 lines (75 loc) 2.15 kB
import { Link } from "@strapi/icons"; import { useRef, useEffect } from "react"; 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 = "hero-widget-cta-button"; const Initializer = ({ setPlugin }) => { const ref = useRef(setPlugin); useEffect(() => { ref.current(PLUGIN_ID); }, []); return null; }; const index = { register(app) { app.customFields.register({ name: "cta-button", pluginId: PLUGIN_ID, plugin: PLUGIN_ID, type: "json", intlLabel: { id: `${PLUGIN_ID}.cta-button.label`, defaultMessage: "CTA Button" }, intlDescription: { id: `${PLUGIN_ID}.cta-button.description`, defaultMessage: "Configure a CTA button with different action types" }, icon: Link, components: { Input: async () => import("../_chunks/index-B2lcl2eg.mjs") }, options: { base: [], advanced: [] } }); app.registerPlugin({ id: PLUGIN_ID, initializer: Initializer, isReady: false, name: PLUGIN_ID }); }, bootstrap(app) { }, async registerTrads({ locales }) { return Promise.all( locales.map(async (locale) => { try { const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("../_chunks/en-DQponcme.mjs"), "./translations/ru.json": () => import("../_chunks/ru-yKlibDKC.mjs") }), `./translations/${locale}.json`, 3); return { data, locale }; } catch { return { data: {}, locale }; } }) ); } }; export { index as default };