4 lines
2.5 KiB
JavaScript
4 lines
2.5 KiB
JavaScript
;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="86a019c7-a723-a4c0-0b7b-2514e0f33792")}catch(e){}}();
|
|
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,636626,e=>{"use strict";var l=e.i(289571),a=e.i(836566),t=e.i(452797),s=e.i(600745),i=e.i(678457),o=e.i(704333),n=e.i(638857),r=e.i(55686),c=e.i(138452),u=e.i(703057),d=e.i(713465),p=e.i(907358),m={depth:0},h=e=>{let{className:h,data:{relationTo:b,value:g},nodeKey:v}=e;if("object"==typeof g)throw Error("Relationship value should be a string or number. The Lexical Relationship component should not receive the populated value object.");let _=(0,p.useRef)(null),[f]=(0,s.useLexicalComposerContext)(),x=(0,i.useLexicalEditable)(),{config:{routes:{api:R},serverURL:j},getEntityConfig:C}=(0,r.useConfig)(),[$]=(0,p.useState)(()=>C({collectionSlug:b})),{i18n:y,t:N}=(0,c.useTranslation)(),[T,w]=(0,p.useReducer)(e=>e+1,0),[{data:B},{setParams:D}]=(0,n.usePayloadAPI)((0,d.formatAdminURL)({apiRoute:R,path:`/${$.slug}/${g}`,serverURL:j}),{initialParams:m}),{closeDocumentDrawer:S,DocumentDrawer:L,DocumentDrawerToggler:P}=(0,a.a)({id:g,collectionSlug:$.slug}),A=(0,p.useCallback)(()=>{f.update(()=>{(0,u.$getNodeByKey)(v)?.remove()})},[f,v]),K=p.default.useCallback(()=>{D({...m,cacheBust:T}),S(),w()},[T,D,S]);return(0,t.jsxs)("div",{className:`${h}__contents`,contentEditable:!1,ref:_,children:[(0,t.jsxs)("div",{className:`${h}__wrap`,children:[(0,t.jsx)("p",{className:`${h}__label`,children:N("fields:labelRelationship",{label:$.labels?.singular?(0,o.getTranslation)($.labels?.singular,y):$.slug})}),(0,t.jsx)(P,{className:`${h}__doc-drawer-toggler`,children:(0,t.jsx)("p",{className:`${h}__title`,children:B?B[$?.admin?.useAsTitle||"id"]:g})})]}),x&&(0,t.jsxs)("div",{className:`${h}__actions`,children:[(0,t.jsx)(n.Button,{buttonStyle:"icon-label",className:`${h}__swapButton`,disabled:!x,el:"button",icon:"swap",onClick:()=>{v&&f.dispatchCommand(l.a,{replace:{nodeKey:v}})},round:!0,tooltip:N("fields:swapRelationship")}),(0,t.jsx)(n.Button,{buttonStyle:"icon-label",className:`${h}__removeButton`,disabled:!x,icon:"x",onClick:e=>{e.preventDefault(),A()},round:!0,tooltip:N("fields:removeRelationship")})]}),!!g&&(0,t.jsx)(L,{onSave:K})]})};e.s(["RelationshipComponent",()=>h])}]);
|
|
|
|
//# debugId=86a019c7-a723-a4c0-0b7b-2514e0f33792
|