Files
strapi-plugin-checkbox-list/admin/src/index.ts

92 lines
2.3 KiB
TypeScript
Raw Normal View History

import { Check } from '@strapi/icons';
2026-02-05 10:19:56 +00:00
import { Initializer } from './components/Initializer';
import { PluginIcon } from './components/PluginIcon';
import { PLUGIN_ID } from './pluginId';
import { getTranslation } from './utils/getTranslation';
2026-02-05 10:19:56 +00:00
export default {
register(app: any) {
app.addMenuLink({
to: `plugins/${PLUGIN_ID}`,
icon: PluginIcon,
intlLabel: {
id: `${PLUGIN_ID}.plugin.name`,
defaultMessage: PLUGIN_ID,
},
Component: async () => {
const { App } = await import('./pages/App');
return App;
},
});
app.registerPlugin({
id: PLUGIN_ID,
initializer: Initializer,
isReady: false,
name: PLUGIN_ID,
});
app.customFields.register({
name: 'checkbox-list',
pluginId: PLUGIN_ID,
type: 'json',
icon: Check,
intlLabel: {
id: `${PLUGIN_ID}.customField.label`,
defaultMessage: 'Checkbox list',
},
intlDescription: {
id: `${PLUGIN_ID}.customField.description`,
defaultMessage: 'Select multiple values from a list',
},
components: {
Input: async () => {
const { default: Component } = await import('./components/CheckboxListInput');
return { default: Component };
},
},
options: {
base: [
{
sectionTitle: null,
items: [
{
name: 'enum',
type: 'textarea-enum',
size: 6,
intlLabel: {
id: 'form.attribute.item.enumeration.rules',
defaultMessage: 'Values (one line per value)',
},
placeholder: {
id: 'form.attribute.item.enumeration.placeholder',
defaultMessage: 'Ex:\nmorning\nnoon\nevening',
},
validations: {
required: true,
},
},
],
},
],
},
});
2026-02-05 10:19:56 +00:00
},
async registerTrads({ locales }: { locales: string[] }) {
return Promise.all(
locales.map(async (locale) => {
try {
const { default: data } = await import(`./translations/${locale}.json`);
return { data, locale };
} catch {
return { data: {}, locale };
}
})
);
},
};