{"version":3,"file":"InjectionZone.mjs","sources":["../../../admin/src/components/InjectionZone.tsx"],"sourcesContent":["import { useStrapiApp, InjectionZoneComponent } from '@strapi/admin/strapi-admin';\n\nimport { PLUGIN_ID } from '../constants/plugin';\n\nconst INJECTION_ZONES = {\n editView: { informations: [], 'right-links': [] },\n listView: {\n actions: [],\n deleteModalAdditionalInfos: [],\n publishModalAdditionalInfos: [],\n unpublishModalAdditionalInfos: [],\n },\n preview: {\n actions: [],\n },\n} satisfies InjectionZones;\n\ninterface InjectionZones {\n editView: {\n informations: InjectionZoneComponent[];\n 'right-links': InjectionZoneComponent[];\n };\n listView: {\n actions: InjectionZoneComponent[];\n deleteModalAdditionalInfos: InjectionZoneComponent[];\n publishModalAdditionalInfos: InjectionZoneComponent[];\n unpublishModalAdditionalInfos: InjectionZoneComponent[];\n };\n preview: {\n actions: InjectionZoneComponent[];\n };\n}\n\ntype InjectionZoneArea =\n | 'editView.informations'\n | 'editView.right-links'\n | 'listView.actions'\n | 'listView.unpublishModalAdditionalInfos'\n | 'listView.deleteModalAdditionalInfos'\n | 'listView.publishModalAdditionalInfos'\n | 'listView.deleteModalAdditionalInfos'\n | 'preview.actions';\n\ntype InjectionZoneModule = InjectionZoneArea extends `${infer Word}.${string}` ? Word : never;\ntype InjectionZoneContainer = InjectionZoneArea extends `${string}.${infer Word}.${string}`\n ? Word\n : never;\ntype InjectionZoneBlock = InjectionZoneArea extends `${string}.${string}.${infer Word}`\n ? Word\n : never;\n\n/**\n * You can't know what this component props will be because it's generic and used everywhere\n * e.g. content-manager edit view, we just send the slug but we might not in the listView,\n * therefore, people should type it themselves on the components they render.\n */\nconst InjectionZone = ({ area, ...props }: { area: InjectionZoneArea; [key: string]: unknown }) => {\n const components = useInjectionZone(area);\n\n return (\n <>\n {components.map((component) => (\n \n ))}\n \n );\n};\n\nexport const useInjectionZone = (area: InjectionZoneArea) => {\n const getPlugin = useStrapiApp('useInjectionZone', (state) => state.getPlugin);\n const contentManagerPlugin = getPlugin(PLUGIN_ID);\n const [page, position] = area.split('.') as [InjectionZoneContainer, InjectionZoneBlock];\n\n return contentManagerPlugin.getInjectedComponents(page, position);\n};\n\nexport { InjectionZone, INJECTION_ZONES };\n\nexport type {\n InjectionZoneArea,\n InjectionZoneComponent,\n InjectionZones,\n InjectionZoneModule,\n InjectionZoneContainer,\n InjectionZoneBlock,\n};\n"],"names":["INJECTION_ZONES","editView","informations","listView","actions","deleteModalAdditionalInfos","publishModalAdditionalInfos","unpublishModalAdditionalInfos","preview","InjectionZone","area","props","components","useInjectionZone","_jsx","_Fragment","map","component","Component","name","getPlugin","useStrapiApp","state","contentManagerPlugin","PLUGIN_ID","page","position","split","getInjectedComponents"],"mappings":";;;;AAIA,MAAMA,eAAkB,GAAA;IACtBC,QAAU,EAAA;AAAEC,QAAAA,YAAAA,EAAc,EAAE;AAAE,QAAA,aAAA,EAAe;AAAG,KAAA;IAChDC,QAAU,EAAA;AACRC,QAAAA,OAAAA,EAAS,EAAE;AACXC,QAAAA,0BAAAA,EAA4B,EAAE;AAC9BC,QAAAA,2BAAAA,EAA6B,EAAE;AAC/BC,QAAAA,6BAAAA,EAA+B;AACjC,KAAA;IACAC,OAAS,EAAA;AACPJ,QAAAA,OAAAA,EAAS;AACX;AACF;AAoCA;;;;AAIC,UACKK,aAAgB,GAAA,CAAC,EAAEC,IAAI,EAAE,GAAGC,KAA4D,EAAA,GAAA;AAC5F,IAAA,MAAMC,aAAaC,gBAAiBH,CAAAA,IAAAA,CAAAA;IAEpC,qBACEI,GAAA,CAAAC,QAAA,EAAA;AACGH,QAAAA,QAAAA,EAAAA,UAAAA,CAAWI,GAAG,CAAC,CAACC,SACf,iBAAAH,GAAA,CAACG,UAAUC,SAAS,EAAA;AAAuB,gBAAA,GAAGP;AAApBM,aAAAA,EAAAA,SAAAA,CAAUE,IAAI,CAAA;;AAIhD;AAEO,MAAMN,mBAAmB,CAACH,IAAAA,GAAAA;AAC/B,IAAA,MAAMU,YAAYC,YAAa,CAAA,kBAAA,EAAoB,CAACC,KAAAA,GAAUA,MAAMF,SAAS,CAAA;AAC7E,IAAA,MAAMG,uBAAuBH,SAAUI,CAAAA,SAAAA,CAAAA;AACvC,IAAA,MAAM,CAACC,IAAMC,EAAAA,QAAAA,CAAS,GAAGhB,IAAAA,CAAKiB,KAAK,CAAC,GAAA,CAAA;IAEpC,OAAOJ,oBAAAA,CAAqBK,qBAAqB,CAACH,IAAMC,EAAAA,QAAAA,CAAAA;AAC1D;;;;"}