@inspirer-dev/hero-size-checkbox
Version:
A custom field plugin for Strapi v5 that provides a checkbox selector for hero widget sizes (XL, L, M, S).
78 lines (77 loc) • 2.35 kB
JavaScript
;
const icons = require("@strapi/icons");
const react = require("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-size-checkbox";
const Initializer = ({ setPlugin }) => {
const ref = react.useRef(false);
react.useEffect(() => {
if (!ref.current) {
setPlugin("hero-size-checkbox");
ref.current = true;
}
}, [setPlugin]);
return null;
};
const index = {
register(app) {
app.customFields.register({
name: "hero-size-checkbox",
pluginId: PLUGIN_ID,
plugin: PLUGIN_ID,
type: "json",
intlLabel: {
id: `${PLUGIN_ID}.hero-size-checkbox.label`,
defaultMessage: "Hero Size Checkbox"
},
intlDescription: {
id: `${PLUGIN_ID}.hero-size-checkbox.description`,
defaultMessage: "Select multiple hero widget sizes (XL, L, M, S)"
},
icon: icons.Check,
components: {
Input: async () => Promise.resolve().then(() => require("../_chunks/index-B0WAZNDT.js"))
},
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": () => Promise.resolve().then(() => require("../_chunks/en-Bsf1asUw.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("../_chunks/ru-PxPxXIvl.js")) }), `./translations/${locale}.json`, 3);
return { data, locale };
} catch {
return { data: {}, locale };
}
})
);
}
};
module.exports = index;