From 7fe5502dc173cfee7c3b3178fb233264ad7c6dc3 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 5 Feb 2026 11:53:17 +0000 Subject: Add checkbox-list custom field plugin to Strapi - Introduced a new custom field type 'checkbox-list' with associated input component. - Updated package.json to reflect the new plugin name. - Added necessary server-side files for plugin registration, including bootstrap, destroy, and service methods. - Updated package-lock.json to include new dependencies and versions. - Enhanced admin interface with custom field registration and input handling. --- admin/src/index.ts | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'admin/src/index.ts') diff --git a/admin/src/index.ts b/admin/src/index.ts index 4dff817..f3e7a28 100644 --- a/admin/src/index.ts +++ b/admin/src/index.ts @@ -1,7 +1,8 @@ -import { getTranslation } from './utils/getTranslation'; -import { PLUGIN_ID } from './pluginId'; +import { Check } from '@strapi/icons'; import { Initializer } from './components/Initializer'; import { PluginIcon } from './components/PluginIcon'; +import { PLUGIN_ID } from './pluginId'; +import { getTranslation } from './utils/getTranslation'; export default { register(app: any) { @@ -25,6 +26,53 @@ export default { 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, + }, + }, + ], + }, + ], + }, + }); }, async registerTrads({ locales }: { locales: string[] }) { -- cgit v1.2.3