@strapi/admin 4.12.0-beta.3 → 4.12.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/src/content-manager/components/CollectionTypeFormWrapper/index.js +13 -35
- package/admin/src/content-manager/pages/ListView/components/TableRows/index.js +304 -0
- package/admin/src/pages/AuthPage/components/Register/index.js +4 -0
- package/build/2379.0ca87a89.chunk.js +1 -0
- package/build/2395.df7a044a.chunk.js +26 -0
- package/build/2801.b1140c9b.chunk.js +1 -0
- package/build/{3100.21c343fa.chunk.js → 3100.2ba4df95.chunk.js} +1 -1
- package/build/{3483.ddd2d6df.chunk.js → 3483.e2ee2547.chunk.js} +1 -1
- package/build/3984.dda474f7.chunk.js +1 -0
- package/build/502.8ae8ef60.chunk.js +1 -0
- package/build/5483.6dd2e776.chunk.js +6 -0
- package/build/7065.ec811562.chunk.js +114 -0
- package/build/7464.8a6c1e6c.chunk.js +1 -0
- package/build/8276.6c7b8e6e.chunk.js +26 -0
- package/build/{9806.91360bb6.chunk.js → 9806.aa25371d.chunk.js} +10 -10
- package/build/{Admin-authenticatedApp.36b3826c.chunk.js → Admin-authenticatedApp.6b8dfa45.chunk.js} +1 -1
- package/build/{admin-app.1c3f7fd6.chunk.js → admin-app.c2e4e128.chunk.js} +8 -8
- package/build/content-manager.8772445b.chunk.js +1103 -0
- package/build/index.html +1 -1
- package/build/{main.a12c4c0f.js → main.af84ad9c.js} +281 -281
- package/build/review-workflows-settings-create-view.05758184.chunk.js +1 -0
- package/build/review-workflows-settings-edit-view.c33f7c58.chunk.js +1 -0
- package/build/review-workflows-settings-list-view.3ee9190d.chunk.js +56 -0
- package/build/{runtime~main.d197f488.js → runtime~main.a65ca6fb.js} +2 -2
- package/build/sso-settings-page.7c9b2fd9.chunk.js +1 -0
- package/ee/admin/constants.js +3 -0
- package/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js +12 -4
- package/ee/admin/hooks/index.js +1 -1
- package/ee/admin/hooks/useLicenseLimitNotification/index.js +1 -1
- package/ee/admin/hooks/useLicenseLimits/__mocks__/index.js +8 -0
- package/ee/admin/hooks/useLicenseLimits/index.js +1 -3
- package/ee/admin/hooks/useLicenseLimits/useLicenseLimits.js +3 -13
- package/ee/admin/pages/SettingsPage/pages/ApplicationInfosPage/components/AdminSeatInfo/index.js +19 -4
- package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/Stages/Stage/Stage.js +7 -0
- package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/Stages/Stages.js +20 -16
- package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/WorkflowAttributes/WorkflowAttributes.js +120 -29
- package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/constants.js +3 -0
- package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/CreateView/CreateView.js +108 -31
- package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/CreateView/index.js +8 -3
- package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/EditView/EditView.js +138 -61
- package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/EditView/index.js +8 -3
- package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/ListView/ListView.js +72 -55
- package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/pages/ListView/index.js +8 -3
- package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/reducer/index.js +2 -8
- package/ee/admin/pages/SettingsPage/pages/SingleSignOn/index.js +2 -8
- package/ee/admin/pages/SettingsPage/pages/SingleSignOn/utils/schema.js +8 -5
- package/ee/server/services/review-workflows/review-workflows.js +1 -1
- package/ee/server/services/review-workflows/validation.js +6 -4
- package/ee/server/services/review-workflows/workflows/content-types.js +28 -19
- package/ee/server/services/review-workflows/workflows/index.js +14 -2
- package/ee/server/validation/authentication.js +20 -9
- package/package.json +9 -9
- package/build/2379.d33a2e16.chunk.js +0 -1
- package/build/2395.b0419a54.chunk.js +0 -26
- package/build/2801.18f38baf.chunk.js +0 -1
- package/build/3984.ea7b8036.chunk.js +0 -1
- package/build/502.ccb38223.chunk.js +0 -1
- package/build/5483.ed2c7efa.chunk.js +0 -6
- package/build/7464.c6d0565c.chunk.js +0 -1
- package/build/8276.23e0763b.chunk.js +0 -26
- package/build/8298.fd253c9f.chunk.js +0 -117
- package/build/content-manager.b8d593d4.chunk.js +0 -1103
- package/build/review-workflows-settings-create-view.dfd87e1f.chunk.js +0 -1
- package/build/review-workflows-settings-edit-view.53c00afe.chunk.js +0 -1
- package/build/review-workflows-settings-list-view.a34be805.chunk.js +0 -56
- package/build/sso-settings-page.ed6f3f15.chunk.js +0 -1
- package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/ProtectedPage/ProtectedPage.js +0 -21
- package/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/components/ProtectedPage/index.js +0 -1
|
@@ -0,0 +1,1103 @@
|
|
|
1
|
+
(self.webpackChunk_strapi_admin=self.webpackChunk_strapi_admin||[]).push([[994],{11170:function(Yo,ct,l){"use strict";l.r(ct),l.d(ct,{App:function(){return rs},default:function(){return Xp}});var e=l(32735),Te=l(27649),De=l(82055),tt=l(96709),y=l(19565),Mt=l(98978),dt=l.n(Mt),Ge=l(74758),K=l(67879),ae=l(15062),re=l(53038),Tt=l(17379),We=l(30305),Ot=(0,e.createContext)(),Se=l(7921),ut=l(24381),xe=l(60216),n=l.n(xe),nt=l(47533),It=(0,e.createContext)(),Jo=l(75430),oe=l(69242),f=l(97724),le=l(41415),Qe=l(17e3),H=l(72850),P=l(87933),W=l(49372),Oe=l(15335),be=l(5803),Ae=l(68465),Ce=l(84967),jt=l(9026),ot=l(29439),we=l(66456),an=l(99381),$e=l.n(an),_o=l(3704),Wt=l.n(_o),sn=l(33795),Z=l.n(sn),as=l(89793),ke=l.n(as),ss=l(88423),ln=l.n(ss),is=l(3040),te=l.n(is),ls=l(23940),Pt=l.n(ls),Be=l(20108),mt=l(20716),pe=l(14708),pt=l(19406),Ke=l(68625);const er=e.createContext();function cn({attributes:t,buttonData:o,children:r,goTo:a,layout:s,metadatas:c,moveItem:i,moveRow:d,onAddData:m,relationsLayout:u,removeField:p,selectedItemName:E,setEditFieldToSelect:h,...g}){return e.createElement(er.Provider,{value:{attributes:t,buttonData:o,goTo:a,layout:s,metadatas:c,moveItem:i,moveRow:d,onAddData:m,relationsLayout:u,removeField:p,selectedItemName:E,setEditFieldToSelect:h,...g}},r)}cn.defaultProps={attributes:{},buttonData:[],goTo(){},layout:[],metadatas:{},moveItem(){},moveRow(){},onAddData(){},relationsLayout:[],removeField(){},selectedItemName:null,setEditFieldToSelect(){}},cn.propTypes={attributes:n().object,buttonData:n().array,children:n().node.isRequired,goTo:n().func,layout:n().array,metadatas:n().object,moveItem:n().func,moveRow:n().func,onAddData:n().func,relationsLayout:n().array,removeField:n().func,selectedItemName:n().string,setEditFieldToSelect:n().func};function rt(){return e.useContext(er)}const cs=[{action:"plugin::content-type-builder.read",subject:null}];var ds=()=>{const{trackUsage:t}=(0,y.rS)(),{formatMessage:o}=(0,K.Z)(),{slug:r,modifiedData:a,isContentTypeView:s}=rt(),c=s?"content-types":"components",i=`/plugins/content-type-builder/${c==="content-types"?c:"component-categories"}`,d=Z()(a,"category",""),m=c==="content-types"?r:`${d}/${r}`,u=()=>{t("willEditEditLayout")};return r==="strapi::administrator"?null:e.createElement(y.jW,{permissions:cs},e.createElement(y.Qj,{to:`${i}/${m}`,onClick:u,size:"S",startIcon:e.createElement(Ke.Z,null),variant:"secondary"},o({id:(0,Se.Z)(`edit-settings-view.link-to-ctb.${c}`),defaultMessage:"Edit the content type"})))},Ye=l(47081),zt=l(74506),xt=l(51968),q=l(8471),Re=l(50563),Ve=l(4038),dn=l(45112);const tr=({componentUid:t})=>{const{componentLayouts:o}=rt(),{formatMessage:r}=(0,K.Z)(),a=Z()(o,[t],{}),s=Z()(a,["layouts","edit"],[]);return e.createElement(H.x,{padding:3},s.map((c,i)=>e.createElement(Oe.r,{gap:4,key:i},c.map(d=>e.createElement(be.P,{key:d.name,col:d.size},e.createElement(H.x,{paddingTop:2},e.createElement(P.k,{alignItems:"center",background:"neutral0",paddingLeft:3,paddingRight:3,height:`${32/16}rem`,hasRadius:!0,borderColor:"neutral200"},e.createElement(W.Z,{textColor:"neutral800"},d.name))))))),e.createElement(H.x,{paddingTop:2},e.createElement(y.rU,{startIcon:e.createElement(dn.Z,null),to:`/content-manager/components/${t}/configurations/edit`},r({id:(0,Se.Z)("components.FieldItem.linkToComponentLayout"),defaultMessage:"Set the component's layout"}))))};tr.propTypes={componentUid:n().string.isRequired};var us=tr,gt=l(14911),ft=l(99140),ms=l(55805),ps=l(31206),gs=l(97075),fs=l(14949),hs=l(8482),ys=l(65261),Es=l(55877),bs=l(84298),un=l(73906),vs=l(37272),Cs=l(67121),Rs=l(39869),nr=l(35635),Ms=l(26366),Ts=l(98464),Ds=l(2362),Os=l(89992),Is=l(10473),Ps=l(95971),xs=l(72536),Zs=l(68312),or=l(80601),rr=l(74464),Ls=l(70809),Ss=l(98148),ks=l(81424),Fs=l(69317),As=l(25789),ws=l(77359),$s=l(50416),Bs=l(20015),Ns=l(20276),js=l(82068),Ws=l(41645),zs=l(61294),Us=l(65943),Vs=l(8606),qs=l(7961),Hs=l(92967),ar=l(18070),Gs=l(54894),Qs=l(30285),Ks=l(96011),Ys=l(47041),Xs=l(60625),sr=l(5644),Js=l(78150),_s=l(63717),ei=l(24609),ti=l(86543),ni=l(62864),oi=l(92989),ri=l(49886),ai=l(47052),si=l(50694),ii=l(81875),li=l(92323),mn=l(49844),ci=l(11631),di=l(9254),ir=l(2669),ui=l(18709),mi=l(20258),lr=l(43231),pi=l(45147),gi=l(23154),fi=l(26253),hi=l(79634),yi=l(32548),Ei=l(99482),bi=l(45323),vi=l(76994),Ci=l(88777),Ri=l(95703),Mi=l(8981),Ti=l(7733),Di=l(10168),Oi=l(25449),Ii=l(83900),Pi=l(32645),xi=l(78429),Zi=l(9882),cr=l(11417),Li=l(39698),Si=l(92168),ki=l(69621),Fi=l(2438),Ai=l(92254),wi=l(2287),$i=l(29685),dr=l(65663),pn=l(44647),Bi=l(5502),Ni=l(31047),ji=l(93307),Wi=l(78055),zi=l(51239),Ui=l(6792),Vi=l(75156),qi=l(80683),Hi=l(2689),Gi=l(40202),Qi=l(36919),Ki=l(75444),Yi=l(92003),Xi=l(4511),Ji=l(2847),ur=l(83139),_i=l(53779),el=l(72890),tl=l(84411),nl=l(37193),ol=l(74831),rl=l(99221),al=l(34119),gn=l(99283),sl=l(21371),il=l(70727),ll=l(42213),cl=l(8611),dl=l(20448),ul=l(73165);const mr={alien:ms.Z,apps:ps.Z,archive:gs.Z,arrowDown:fs.Z,arrowLeft:ot.Z,arrowRight:hs.Z,arrowUp:ys.Z,attachment:Es.Z,bell:bs.Z,bold:un.Z,book:vs.Z,briefcase:Cs.Z,brush:Rs.Z,bulletList:nr.Z,calendar:Ms.Z,car:Ts.Z,cast:Ds.Z,chartBubble:Os.Z,chartCircle:Is.Z,chartPie:Ps.Z,check:we.Z,clock:xs.Z,cloud:Zs.Z,code:or.Z,cog:dn.Z,collapse:rr.Z,command:Ls.Z,connector:Ss.Z,crop:ks.Z,crown:Fs.Z,cube:As.Z,cup:ws.Z,cursor:$s.Z,dashboard:Bs.Z,database:Ns.Z,discuss:js.Z,doctor:Ws.Z,earth:zs.Z,emotionHappy:Us.Z,emotionUnhappy:Vs.Z,envelop:qs.Z,exit:Hs.Z,expand:ar.Z,eye:Gs.Z,feather:Qs.Z,file:Ks.Z,fileError:Ys.Z,filePdf:Xs.Z,filter:sr.Z,folder:Js.Z,gate:_s.Z,gift:ei.Z,globe:ti.Z,grid:ni.Z,handHeart:oi.Z,hashtag:ri.Z,headphone:ai.Z,heart:si.Z,house:ii.Z,information:li.Z,italic:mn.Z,key:ci.Z,landscape:di.Z,layer:ir.Z,layout:ui.Z,lightbulb:mi.Z,link:lr.Z,lock:pi.Z,magic:gi.Z,manyToMany:fi.Z,manyToOne:hi.Z,manyWays:yi.Z,medium:Ei.Z,message:bi.Z,microphone:vi.Z,monitor:Ci.Z,moon:Ri.Z,music:Mi.Z,oneToMany:Ti.Z,oneToOne:Di.Z,oneWay:Oi.Z,paint:Ii.Z,paintBrush:Pi.Z,paperPlane:xi.Z,pencil:Ke.Z,phone:Zi.Z,picture:cr.Z,pin:Li.Z,pinMap:Si.Z,plane:ki.Z,play:Fi.Z,plus:pt.Z,priceTag:Ai.Z,puzzle:wi.Z,question:$i.Z,quote:dr.Z,refresh:pn.Z,repeat:Bi.Z,restaurant:Ni.Z,rocket:ji.Z,rotate:Wi.Z,scissors:zi.Z,search:Ui.Z,seed:Vi.Z,server:qi.Z,shield:Hi.Z,shirt:Gi.Z,shoppingCart:Qi.Z,slideshow:Ki.Z,stack:Yi.Z,star:Xi.Z,store:Ji.Z,strikeThrough:ur.Z,sun:_i.Z,television:el.Z,thumbDown:tl.Z,thumbUp:nl.Z,train:ol.Z,twitter:rl.Z,typhoon:al.Z,underline:gn.Z,user:sl.Z,volumeMute:il.Z,volumeUp:ll.Z,walk:cl.Z,wheelchair:dl.Z,write:ul.Z};function Zt({showBackground:t=!0,size:o="M",icon:r}){return e.createElement(P.k,{alignItems:"center",background:t?"neutral200":null,justifyContent:"center",size:o,showBackground:t,height:o==="S"?5:8,width:o==="S"?5:8,color:"neutral600",borderRadius:t?"50%":0},e.createElement(ft.J,{as:mr[r]||mr.cube,height:o==="S"?3:5,width:o==="S"?3:5}))}Zt.defaultProps={showBackground:!0,size:"M",icon:"Cube"},Zt.propTypes={showBackground:n().bool,size:n().string,icon:n().string};const ml=(0,q.ZP)(P.k)`
|
|
2
|
+
text-decoration: none;
|
|
3
|
+
|
|
4
|
+
&:focus,
|
|
5
|
+
&:hover {
|
|
6
|
+
${({theme:t})=>`
|
|
7
|
+
background-color: ${t.colors.primary100};
|
|
8
|
+
border-color: ${t.colors.primary200};
|
|
9
|
+
|
|
10
|
+
${W.Z} {
|
|
11
|
+
color: ${t.colors.primary600};
|
|
12
|
+
}
|
|
13
|
+
`}
|
|
14
|
+
|
|
15
|
+
/* > ComponentIcon */
|
|
16
|
+
> div:first-child {
|
|
17
|
+
background: ${({theme:t})=>t.colors.primary200};
|
|
18
|
+
color: ${({theme:t})=>t.colors.primary600};
|
|
19
|
+
|
|
20
|
+
svg {
|
|
21
|
+
path {
|
|
22
|
+
fill: ${({theme:t})=>t.colors.primary600};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`,pr=({components:t})=>{const{componentLayouts:o}=rt();return e.createElement(P.k,{gap:2,overflow:"scroll hidden",padding:3},t.map(r=>e.createElement(ml,{hasRadius:!0,background:"neutral0",justifyContent:"center",alignItems:"center",height:`${84/16}rem`,minWidth:`${140/16}rem`,key:r,padding:2,direction:"column",borderColor:"neutral200",as:gt.rU,to:`/content-manager/components/${r}/configurations/edit`},e.createElement(Zt,{icon:o?.[r]?.info?.icon}),e.createElement(H.x,{paddingTop:1},e.createElement(W.Z,{fontSize:1,textColor:"neutral600",fontWeight:"bold"},o?.[r]?.info?.displayName??"")))))};pr.propTypes={components:n().arrayOf(n().string).isRequired};var pl=pr;const gr=(0,q.ZP)(Re.h)`
|
|
28
|
+
background-color: transparent;
|
|
29
|
+
path {
|
|
30
|
+
fill: ${({theme:t})=>t.colors.neutral600};
|
|
31
|
+
}
|
|
32
|
+
`,fn=({attribute:t,onEditField:o,onDeleteField:r,children:a})=>{const{formatMessage:s}=(0,K.Z)();return e.createElement(H.x,{overflow:"hidden",width:"100%"},e.createElement(P.k,{paddingLeft:3,alignItems:"center",justifyContent:"space-between"},e.createElement(W.Z,{fontWeight:"semiBold",textColor:"neutral800",ellipsis:!0},a),e.createElement(P.k,null,e.createElement(gr,{label:s({id:(0,f.OB)("containers.ListSettingsView.modal-form.edit-label"),defaultMessage:"Edit {fieldName}"},{fieldName:a}),onClick:o,icon:e.createElement(Ke.Z,null),noBorder:!0}),e.createElement(gr,{label:s({id:"global.delete-target",defaultMessage:"Delete {target}"},{target:a}),"data-testid":"delete-field",onClick:r,icon:e.createElement(Ve.Z,null),noBorder:!0}))),t?.type==="component"&&e.createElement(us,{componentUid:t.component}),t?.type==="dynamiczone"&&e.createElement(pl,{components:t.components}))};fn.defaultProps={attribute:void 0},fn.propTypes={attribute:n().shape({components:n().array,component:n().string,type:n().string}),onEditField:n().func.isRequired,onDeleteField:n().func.isRequired,children:n().string.isRequired};var gl=fn;const fl=(0,q.ZP)(P.k)`
|
|
33
|
+
position: relative;
|
|
34
|
+
${({isFirst:t,isLast:o,hasHorizontalPadding:r})=>t?`
|
|
35
|
+
padding-right: 4px;
|
|
36
|
+
`:o?`
|
|
37
|
+
padding-left: 4px;
|
|
38
|
+
`:r?`
|
|
39
|
+
padding: 0 4px;
|
|
40
|
+
`:""}
|
|
41
|
+
${({showRightCarret:t,showLeftCarret:o,theme:r})=>t?`
|
|
42
|
+
&:after {
|
|
43
|
+
content: '';
|
|
44
|
+
position: absolute;
|
|
45
|
+
right: -1px;
|
|
46
|
+
background-color: ${r.colors.primary600};
|
|
47
|
+
width: 2px;
|
|
48
|
+
height: 100%;
|
|
49
|
+
align-self: stretch;
|
|
50
|
+
z-index: 1;
|
|
51
|
+
}
|
|
52
|
+
`:o?`
|
|
53
|
+
&:before {
|
|
54
|
+
content: '';
|
|
55
|
+
position: absolute;
|
|
56
|
+
left: -1px;
|
|
57
|
+
background-color: ${r.colors.primary600};
|
|
58
|
+
width: 2px;
|
|
59
|
+
height: 100%;
|
|
60
|
+
align-self: stretch;
|
|
61
|
+
z-index: 1;
|
|
62
|
+
}
|
|
63
|
+
`:""};
|
|
64
|
+
`,hl=(0,q.ZP)(Ye.Z)`
|
|
65
|
+
height: ${12/16}rem;
|
|
66
|
+
width: ${12/16}rem;
|
|
67
|
+
path {
|
|
68
|
+
fill: ${({theme:t})=>t.colors.neutral600};
|
|
69
|
+
}
|
|
70
|
+
`,yl=(0,q.ZP)(P.k)`
|
|
71
|
+
display: ${({dragStart:t})=>t?"none":"flex"};
|
|
72
|
+
opacity: ${({isDragging:t,isFullSize:o,isHidden:r})=>t&&!o?.2:t&&o||r?0:1};
|
|
73
|
+
`,El=(0,q.ZP)(P.k)`
|
|
74
|
+
cursor: all-scroll;
|
|
75
|
+
border-right: 1px solid ${({theme:t})=>t.colors.neutral200};
|
|
76
|
+
`,hn=({attribute:t,children:o,index:r,lastIndex:a,moveItem:s,moveRow:c,name:i,onDeleteField:d,onEditField:m,rowIndex:u,size:p})=>{const[E,h]=(0,e.useState)(!1),g=i==="_TEMP_",{setIsDraggingSibling:b}=rt(),C=p===12,I=(0,e.useRef)(null),v=(0,e.useRef)(null),[{clientOffset:M,isOver:x},j]=(0,zt.useDrop)({accept:f._Q.EDIT_FIELD,hover(A,k){if(!v.current||A.size!==12)return;const R=k.getItem().index,F=r,U=k.getItem().rowIndex,Y=u;if(R===F&&U===Y)return;const L=v.current.getBoundingClientRect(),B=(L.bottom-L.top)/2,ce=k.getClientOffset().y-L.top;U<Y&&ce<B||U>Y&&ce>B||(c(U,Y),A.rowIndex=Y,A.itemIndex=F)},drop(A,k){if(!v.current)return;const R=k.getItem().index,F=r,U=k.getItem().rowIndex,Y=u;if(A.size===12||R===F&&U===Y)return;const L=v.current.getBoundingClientRect();if(Math.abs(k.getClientOffset().x-L.left)>L.width/1.8){s(R,F+1,U,Y),A.itemIndex=F+1,A.rowIndex=Y;return}s(R,F,U,Y),A.itemIndex=F,A.rowIndex=Y},collect:A=>({canDrop:A.canDrop(),clientOffset:A.getClientOffset(),isOver:A.isOver(),isOverCurrent:A.isOver({shallow:!0}),itemType:A.getItemType()})}),[{isDragging:D,getItem:O},N,w]=(0,zt.useDrag)({type:f._Q.EDIT_FIELD,item(){return b(!0),{index:r,labelField:o,rowIndex:u,name:i,size:p}},canDrag(){return i!=="_TEMP_"},collect:A=>({isDragging:A.isDragging(),getItem:A.getItem()}),end(){b(!1)}});(0,e.useEffect)(()=>{w((0,xt.rX)(),{captureDraggingState:!0})},[w]);const T={dragRef:N(I),dropRef:j(v)};let S=!1,G=!1;if(v.current&&M){const A=v.current.getBoundingClientRect();S=x&&O.size!==12&&Math.abs(M.x-A.left)<A.width/2,G=x&&O.size!==12&&Math.abs(M.x-A.left)>A.width/2,i==="_TEMP_"&&(S=x&&O.size!==12,G=!1)}const $=()=>t&&C?`${74/16}rem`:`${32/16}rem`,X=r===0&&!C,Q=r===a&&!C,J=r!==0&&!C;return e.createElement(be.P,{col:p},e.createElement(fl,{ref:T.dropRef,showLeftCarret:S,showRightCarret:G,isFirst:X,isLast:Q,hasHorizontalPadding:J,onDrag:()=>{C&&!E&&h(!0)},onDragEnd:()=>{C&&h(!1)}},E&&C&&e.createElement(H.x,{width:"100%",height:"2px",background:"primary600"}),e.createElement(yl,{width:C&&E?0:"100%",borderColor:"neutral150",hasRadius:!0,background:"neutral100",minHeight:$(),alignItems:"stretch",isDragging:D,dragStart:E,isFullSize:C,isHidden:g},e.createElement(El,{as:"span",type:"button",ref:T.dragRef,onClick:A=>A.stopPropagation(),alignItems:"center",paddingLeft:3,paddingRight:3,tabIndex:-1},e.createElement(hl,null)),!g&&e.createElement(gl,{attribute:t,onEditField:m,onDeleteField:d},o))))};hn.defaultProps={attribute:void 0},hn.propTypes={attribute:n().shape({components:n().array,component:n().string,type:n().string}),children:n().string.isRequired,index:n().number.isRequired,moveItem:n().func.isRequired,moveRow:n().func.isRequired,name:n().string.isRequired,onDeleteField:n().func.isRequired,onEditField:n().func.isRequired,rowIndex:n().number.isRequired,lastIndex:n().number.isRequired,size:n().number.isRequired};var bl=hn;const fr=({rowItem:t,onRemoveField:o,rowId:r,rowIndex:a,index:s,lastIndex:c})=>{const{setEditFieldToSelect:i,attributes:d,modifiedData:m,moveRow:u,moveItem:p}=rt(),E=Z()(d,[t.name],{}),h=Z()(m,["metadatas",t.name,"edit","label"],"");return e.createElement(bl,{onEditField:()=>i(t.name),onDeleteField:()=>o(r,s),attribute:E,index:s,lastIndex:c,rowIndex:a,name:t.name,size:t.size,moveRow:u,moveItem:p},h||t.name)};fr.propTypes={index:n().number.isRequired,lastIndex:n().number.isRequired,onRemoveField:n().func.isRequired,rowId:n().number.isRequired,rowIndex:n().number.isRequired,rowItem:n().object.isRequired};var vl=fr;const hr=({row:t,onRemoveField:o,rowIndex:r})=>e.createElement(Oe.r,null,t.rowContent.map((a,s)=>e.createElement(vl,{key:a.name,rowItem:a,index:s,rowId:t.rowId,onRemoveField:o,rowIndex:r,lastIndex:t.rowContent.length-1})));hr.propTypes={onRemoveField:n().func.isRequired,row:n().object.isRequired,rowIndex:n().number.isRequired};var Cl=hr;const yr=({editLayout:t,fields:o,onRemoveField:r,onAddField:a})=>{const{formatMessage:s}=(0,K.Z)();return e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:4},e.createElement(P.k,{justifyContent:"space-between"},e.createElement("div",null,e.createElement(H.x,null,e.createElement(W.Z,{fontWeight:"bold"},s({id:(0,f.OB)("containers.ListPage.displayedFields"),defaultMessage:"Displayed fields"}))),e.createElement(H.x,null,e.createElement(W.Z,{variant:"pi",textColor:"neutral600"},s({id:"containers.SettingPage.editSettings.description",defaultMessage:"Drag & drop the fields to build the layout"})))),e.createElement(ds,null)),e.createElement(H.x,{padding:4,hasRadius:!0,borderStyle:"dashed",borderWidth:"1px",borderColor:"neutral300"},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:2},t.map((c,i)=>e.createElement(Cl,{key:c.rowId,row:c,rowIndex:i,onRemoveField:r})),e.createElement(pe.fC,null,e.createElement(pe.xz,{startIcon:e.createElement(pt.Z,null),endIcon:null,disabled:o.length===0,fullWidth:!0,variant:"secondary"},s({id:(0,f.OB)("containers.SettingPage.add.field"),defaultMessage:"Insert another field"})),e.createElement(pe.VY,null,o.map(c=>e.createElement(pe.ck,{key:c,onSelect:()=>a(c)},c)))))))};yr.propTypes={editLayout:n().array.isRequired,fields:n().array.isRequired,onAddField:n().func.isRequired,onRemoveField:n().func.isRequired};var Rl=yr,yn=l(85025),En=l(55225),bn=l(31600),vn=l(11406),Lt=l(32031),Ml=l(73779),Ut=l(88675),Tl=l(22348),Er=l(7184),Cn=l(43475),Dl=l(82512),Rn=l(83218),Ol=l(872),Il=l(17757),Pl=l(1176),xl=l(15431);const br={biginteger:e.createElement(Lt.Z,null),boolean:e.createElement(Ml.Z,null),date:e.createElement(Ut.Z,null),datetime:e.createElement(Ut.Z,null),decimal:e.createElement(Lt.Z,null),email:e.createElement(Tl.Z,null),enum:e.createElement(Er.Z,null),enumeration:e.createElement(Er.Z,null),file:e.createElement(Cn.Z,null),files:e.createElement(Cn.Z,null),float:e.createElement(Lt.Z,null),integer:e.createElement(Lt.Z,null),media:e.createElement(Cn.Z,null),number:e.createElement(Lt.Z,null),relation:e.createElement(Dl.Z,null),string:e.createElement(Rn.Z,null),text:e.createElement(Rn.Z,null),richtext:e.createElement(Rn.Z,null),time:e.createElement(Ut.Z,null),timestamp:e.createElement(Ut.Z,null),json:e.createElement(Ol.Z,null),uid:e.createElement(Il.Z,null),component:e.createElement(Pl.Z,null),dynamiczone:e.createElement(xl.Z,null)},Mn=({type:t,customFieldUid:o})=>{const r=(0,y.mZ)();let a=br[t];if(o){const c=r.get(o).icon;c&&(a=e.createElement(H.x,{marginRight:3,width:7,height:6},e.createElement(c,null)))}return br[t]?a:null};Mn.defaultProps={customFieldUid:null},Mn.propTypes={type:n().string.isRequired,customFieldUid:n().string};var vr=Mn,Zl=t=>t.reduce((o,r)=>{const a=r?.attributes??{},s=Object.keys(a).filter(c=>!["boolean","component","dynamiczone","json","media","password","relation","text","richtext"].includes(a?.[c]?.type??""));return o[r.uid]=s,o},{}),Cr=t=>{let o;switch(t){case"description":case"label":case"placeholder":o="text";break;case"mainField":o="select";break;case"editable":o="bool";break;default:o=""}const r=t==="mainField"?(0,f.OB)("containers.SettingPage.editSettings.entry.title"):(0,f.OB)(`form.Input.${t}`);return{type:o,label:{id:r}}},Tn=l(10369),St=l(71842);const Dn=({type:t,options:o,onChange:r,value:a,name:s,...c})=>{const{formatMessage:i}=(0,K.Z)();switch(t){case"text":return e.createElement(Tn.o,{onChange:r,value:a,name:s,...c});case"bool":return e.createElement(St.s,{onChange:d=>{r({target:{name:s,value:d.target.checked}})},checked:a,name:s,onLabel:i({id:"app.components.ToggleCheckbox.on-label",defaultMessage:"On"}),offLabel:i({id:"app.components.ToggleCheckbox.off-label",defaultMessage:"Off"}),...c});case"select":return e.createElement(Ae.P,{value:a,name:s,onChange:d=>r({target:{name:s,value:d}}),...c},o.map(d=>e.createElement(Ce.W,{key:d,value:d},d)));default:return null}};Dn.defaultProps={options:void 0},Dn.propTypes={type:n().string.isRequired,options:n().arrayOf(n().string),onChange:n().func.isRequired,value:n().oneOfType([n().string,n().bool]).isRequired,name:n().string.isRequired};var Ll=Dn;const Sl=[[4,"33%"],[6,"50%"],[8,"66%"],[12,"100%"]],Rr=({onMetaChange:t,onSizeChange:o})=>{const{formatMessage:r}=(0,K.Z)(),{modifiedData:a,selectedField:s,attributes:c,fieldForm:i}=rt(),d=(0,e.useMemo)(mt.Vo,[]),{schemas:m}=(0,ae.v9)(v=>d(v),ae.wU),u=(0,ae.v9)(mt.Jg),p=(0,e.useMemo)(()=>{if(!s)return[];const v=Z()(a,["metadatas",s,"edit"],{});return Object.keys(v).filter(M=>M!=="visible")},[s,a]),E=(0,e.useMemo)(()=>Zl(m),[m]),h=(0,e.useCallback)(v=>{if(v!=="relation"&&v!=="component")return[];const M=v==="component"?"component":"targetModel",x=Z()(a,["attributes",s,M],"");return Z()(E,[x],[])},[s,E,a]),g=p.map(v=>{const M=Z()(c,[s,"type"]);return["component","dynamiczone"].includes(M)&&!["label","description"].includes(v)||M==="component"&&v!=="label"||["media","json","boolean"].includes(M)&&v==="placeholder"||v==="step"?null:e.createElement(be.P,{col:6,key:v},e.createElement(Ll,{type:Cr(v).type,hint:v==="mainField"?r({id:(0,Se.Z)("containers.SettingPage.editSettings.relation-field.description")}):"",label:r({id:Z()(Cr(v),"label.id","app.utils.defaultMessage")}),name:v,onChange:t,value:Z()(i,["metadata",v],""),options:h(M)}))}),{type:b,customField:C}=c[s],{isResizable:I}=u[C]??u[b];return e.createElement(e.Fragment,null,g,I&&e.createElement(be.P,{col:6,key:"size"},e.createElement(Ae.P,{value:i?.size,name:"size",onChange:v=>{o({name:s,value:v})},label:r({id:(0,Se.Z)("containers.SettingPage.editSettings.size.label"),defaultMessage:"Size"})},Sl.map(([v,M])=>e.createElement(Ce.W,{key:v,value:v},M)))))};Rr.propTypes={onMetaChange:n().func.isRequired,onSizeChange:n().func.isRequired};var kl=Rr;const Fl=(0,q.ZP)(P.k)`
|
|
77
|
+
svg {
|
|
78
|
+
width: ${32/16}rem;
|
|
79
|
+
height: ${24/16}rem;
|
|
80
|
+
margin-right: ${({theme:t})=>t.spaces[3]};
|
|
81
|
+
}
|
|
82
|
+
`,On=({onToggle:t,onMetaChange:o,onSizeChange:r,onSubmit:a,type:s,customFieldUid:c})=>{const{selectedField:i}=rt(),{formatMessage:d}=(0,K.Z)(),m=()=>s==="timestamp"?"date":["decimal","float","integer","biginter"].includes(s)?"number":s;return e.createElement(yn.P,{onClose:t,labelledBy:"title"},e.createElement("form",{onSubmit:a},e.createElement(En.x,null,e.createElement(Fl,null,e.createElement(vr,{type:m(),customFieldUid:c}),e.createElement(W.Z,{fontWeight:"bold",textColor:"neutral800",as:"h2",id:"title"},d({id:(0,f.OB)("containers.ListSettingsView.modal-form.edit-label"),defaultMessage:"Edit {fieldName}"},{fieldName:Pt()(i)})))),e.createElement(bn.f,null,e.createElement(Oe.r,{gap:4},e.createElement(kl,{onMetaChange:o,onSizeChange:r}))),e.createElement(vn.m,{startActions:e.createElement(le.z,{onClick:t,variant:"tertiary"},d({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endActions:e.createElement(le.z,{type:"submit"},d({id:"global.finish",defaultMessage:"Finish"}))})))};On.defaultProps={customFieldUid:null},On.propTypes={customFieldUid:n().string,onSubmit:n().func.isRequired,onToggle:n().func.isRequired,onMetaChange:n().func.isRequired,onSizeChange:n().func.isRequired,type:n().string.isRequired};var Al=On;const In=t=>t.reduce((o,r)=>o+r.size,0),wl=t=>t.reduce((o,r,a)=>{const s={rowId:a,rowContent:r};return o.concat(s)},[]),ht=t=>t.reduce((o,r)=>{let a=[];const s=r.rowContent.reduce((d,m)=>{const u=In(d);return m.name==="_TEMP_"||(u+m.size<=12?d.push(m):a.push(m)),d},[]),c=o.length===0?0:Math.max.apply(Math,o.map(d=>d.rowId))+1,i=In(s);if(i<12&&s.push({name:"_TEMP_",size:12-i}),o.push({rowId:c,rowContent:s}),a.length>0){const d=In(a);d<12&&a.push({name:"_TEMP_",size:12-d}),o.push({rowId:c+1,rowContent:a}),a=[]}return o},[]).filter(o=>o.rowContent.length>0).filter(o=>o.rowContent.length===1?o.rowContent[0].name!=="_TEMP_":!0),$l=t=>t.reduce((o,r)=>{const a=r.rowContent.filter(s=>s.name!=="_TEMP_");return o.concat([a])},[]),Bl=(t,o=[])=>o.reduce((r,{rowContent:a})=>{const s=a.find(c=>c.name===t)?.size??null;return s&&(r=s),r},null),Nl=(t,o,r=[])=>r.map(a=>(a.rowContent=a.rowContent.map(s=>s.name===t?{...s,size:o}:s),a));var jl=(t,o,r)=>{let a=$e()(o);return te()(a,["layouts","edit"],ht(wl(o.layouts.edit))),{...t,initialData:a,modifiedData:a,componentLayouts:r}},Pn=l(97889);const Mr=6,xn={fieldForm:{},componentLayouts:{},metaToEdit:"",initialData:{},metaForm:{},modifiedData:{}};var Wl=(t=xn,o)=>(0,Pn.ZP)(t,r=>{const a=["modifiedData","layouts","edit"];switch(o.type){case"MOVE_ROW":{const s=Z()(t,a,[]),{fromIndex:c,toIndex:i}=o;te()(r,a,(0,f.W3)(s,c,i));break}case"ON_ADD_FIELD":{const s=$e()(t),c=Z()(s,["modifiedData","attributes",o.name],{}),i=o.fieldSizes[c?.customField]?.default??o.fieldSizes[c?.type]?.default??Mr,d=Z()(s,a,[]).length,m=[...a,d-1,"rowContent"],u=Z()(s,m,[]);let p=Z()(s,a,[]);Array.isArray(u)?te()(p,[d>0?d-1:0,"rowContent"],[...u,{name:o.name,size:i}]):te()(p,[d>0?d-1:0,"rowContent"],[{name:o.name,size:i}]);const E=ht(p);te()(r,a,E);break}case"ON_CHANGE":{te()(r,["modifiedData",...o.keys],o.value);break}case"ON_CHANGE_META":{te()(r,["metaForm","metadata",...o.keys],o.value);break}case"ON_CHANGE_SIZE":{te()(r,["metaForm","size"],o.value);break}case"ON_RESET":{r.modifiedData=t.initialData;break}case"REMOVE_FIELD":{const s=Z()(t,[...a,o.rowIndex,"rowContent"],[]);let c=$e()(t);if(s.length===1||s.length===2&&Z()(s,[1,"name"],"")==="_TEMP_"){const d=Z()(t,a,[]);te()(c,a,d.filter((m,u)=>o.rowIndex!==u))}else te()(c,[...a,o.rowIndex,"rowContent"],s.filter((d,m)=>m!==o.fieldIndex));const i=ht(Z()(c,a,[]));te()(r,a,i);break}case"REORDER_DIFF_ROW":{const s=Z()(t,[...a,o.dragRowIndex,"rowContent"],[]),c=Z()(t,[...a,o.hoverRowIndex,"rowContent"],[]),i=Z()(t,[...a,o.dragRowIndex,"rowContent",o.dragIndex],{}),d=[...c,i];let m=$e()(t);te()(m,[...a,o.dragRowIndex,"rowContent"],s.filter((p,E)=>o.dragIndex!==E)),te()(m,[...a,o.hoverRowIndex,"rowContent"],(0,f.W3)(d,d.length-1,o.hoverIndex));const u=ht(Z()(m,a,[]));te()(r,a,u);break}case"REORDER_ROW":{const s=$e()(t),c=Z()(s,[...a,o.dragRowIndex,"rowContent"],[]);te()(s,[...a,o.dragRowIndex,"rowContent"],(0,f.W3)(c,o.dragIndex,o.hoverIndex));const i=ht(Z()(s,a,[]));te()(r,a,i);break}case"SET_FIELD_TO_EDIT":{r.metaToEdit=o.name,r.metaForm={metadata:Z()(t,["modifiedData","metadatas",o.name,"edit"],{}),size:Bl(o.name,t.modifiedData?.layouts?.edit)??Mr};break}case"SUBMIT_META_FORM":{te()(r,["modifiedData","metadatas",t.metaToEdit,"edit"],t.metaForm.metadata);const s=$e()(Z()(t,a,[])),c=Nl(t.metaToEdit,t.metaForm.size,s);c.length>0&&te()(r,a,ht(c));break}case"SUBMIT_SUCCEEDED":{r.initialData=t.modifiedData;break}case"UNSET_FIELD_TO_EDIT":{r.metaToEdit="",r.metaForm={};break}default:return r}}),zl=(t,o,r)=>{const{put:a}=(0,y.tg)();return a((0,f.IF)(r?`content-types/${o}/configuration`:`components/${o}/configuration`),t)};const Zn=({mainLayout:t,components:o,isContentTypeView:r,slug:a,updateLayout:s})=>{const[c,i]=(0,e.useReducer)(Wl,xn,()=>jl(xn,t,o)),[d,m]=(0,e.useState)(!1),{trackUsage:u}=(0,y.rS)(),p=(0,y.lm)(),{goBack:E}=(0,re.k6)(),[h,g]=(0,e.useState)(!1),[b,C]=(0,e.useState)(!1),{componentLayouts:I,initialData:v,modifiedData:M,metaToEdit:x,metaForm:j}=c,{formatMessage:D}=(0,K.Z)(),O=Z()(t,["info","displayName"],""),N=Z()(M,["attributes"],{}),w=(0,ae.v9)(mt.Jg),T=Object.keys(N).filter(V=>{const z=Z()(N,[V,"type"],"");return!["dynamiczone","json","text","relation","component","boolean","media","password","richtext","timestamp"].includes(z)&&!!z}),S=Z()(M,["layouts","edit"],[]),G=Wt()(S,"rowContent"),$=Object.keys(M.attributes).filter(V=>Z()(M,["metadatas",V,"edit","visible"],!1)===!0).filter(V=>G.findIndex(z=>z.name===V)===-1).sort(),X=({target:{name:V,value:z}})=>{i({type:"ON_CHANGE",keys:V.split("."),value:z})},Q=()=>{g(V=>!V)},J=()=>{C(V=>!V)},A=({target:{name:V,value:z}})=>{i({type:"ON_CHANGE_META",keys:V.split("."),value:z})},k=({name:V,value:z})=>{i({type:"ON_CHANGE_SIZE",name:V,value:z})},R=V=>{V.preventDefault(),i({type:"SUBMIT_META_FORM"}),Q()},F=V=>{V.preventDefault(),J()},U=(0,Be.useMutation)(V=>zl(V,a,r),{onSuccess({data:V}){s&&s(V.data),i({type:"SUBMIT_SUCCEEDED"}),J(),u("didEditEditSettings")},onError(){p({type:"warning",message:{id:"notification.error"}})}}),{isLoading:Y}=U,L=()=>{const V=ln()($e()(M),["layouts","metadatas","settings"]);te()(V,"layouts.edit",$l(V.layouts.edit)),U.mutate(V)},B=(V,z)=>{i({type:"MOVE_RELATION",fromIndex:V,toIndex:z})},ne=(V,z)=>{i({type:"MOVE_FIELD",fromIndex:V,toIndex:z})},ce=(V,z,ye,he)=>{i(ye===he?{type:"REORDER_ROW",dragRowIndex:ye,dragIndex:V,hoverIndex:z}:{type:"REORDER_DIFF_ROW",dragIndex:V,hoverIndex:z,dragRowIndex:ye,hoverRowIndex:he})},ge=(V,z)=>{i({type:"MOVE_ROW",fromIndex:V,toIndex:z})};return e.createElement(cn,{isContentTypeView:r,attributes:N,modifiedData:M,slug:a,componentLayouts:I,selectedField:x,fieldForm:j,onMoveRelation:B,onMoveField:ne,moveRow:ge,moveItem:ce,setEditFieldToSelect:V=>{i({type:"SET_FIELD_TO_EDIT",name:V}),Q()},isDraggingSibling:d,setIsDraggingSibling:m},e.createElement(Te.o,null,e.createElement("form",{onSubmit:F},e.createElement(De.T,{title:D({id:(0,f.OB)("components.SettingsViewWrapper.pluginHeader.title"),defaultMessage:`Configure the view - ${Pt()(O)}`},{name:Pt()(O)}),subtitle:D({id:(0,f.OB)("components.SettingsViewWrapper.pluginHeader.description.edit-settings"),defaultMessage:"Customize how the edit view will look like."}),navigationAction:e.createElement(y.rU,{startIcon:e.createElement(ot.Z,null),onClick:V=>{V.preventDefault(),E()},to:"/"},D({id:"global.back",defaultMessage:"Back"})),primaryAction:e.createElement(le.z,{disabled:ke()(v,M),startIcon:e.createElement(we.Z,null),type:"submit"},D({id:"global.save",defaultMessage:"Save"}))}),e.createElement(Qe.D,null,e.createElement(H.x,{background:"neutral0",hasRadius:!0,shadow:"filterShadow",paddingTop:6,paddingBottom:6,paddingLeft:7,paddingRight:7},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:4},e.createElement(W.Z,{variant:"delta",as:"h2"},D({id:(0,f.OB)("containers.SettingPage.settings"),defaultMessage:"Settings"})),e.createElement(Oe.r,null,e.createElement(be.P,{col:6,s:12},e.createElement(Ae.P,{label:D({id:(0,f.OB)("containers.SettingPage.editSettings.entry.title"),defaultMessage:"Entry title"}),hint:D({id:(0,f.OB)("containers.SettingPage.editSettings.entry.title.description"),defaultMessage:"Set the display field of your entry"}),onChange:V=>{X({target:{name:"settings.mainField",value:V===""?null:V}})},value:M.settings.mainField},T.map(V=>e.createElement(Ce.W,{key:V,value:V},V))))),e.createElement(H.x,{paddingTop:2,paddingBottom:2},e.createElement(jt.i,null)),e.createElement(W.Z,{variant:"delta",as:"h3"},D({id:(0,f.OB)("containers.SettingPage.view"),defaultMessage:"View"})),e.createElement(Rl,{attributes:N,editLayout:S,fields:$,onAddField:V=>{i({type:"ON_ADD_FIELD",name:V,fieldSizes:w})},onRemoveField:(V,z)=>{i({type:"REMOVE_FIELD",rowIndex:V,fieldIndex:z})}})))),e.createElement(y.QH,{bodyText:{id:(0,f.OB)("popUpWarning.warning.updateAllSettings"),defaultMessage:"This will modify all your settings"},iconRightButton:e.createElement(we.Z,null),isConfirmButtonLoading:Y,isOpen:b,onToggleDialog:J,onConfirm:L,variantRightButton:"success-light"})),h&&e.createElement(Al,{onSubmit:R,onToggle:Q,onMetaChange:A,onSizeChange:k,type:Z()(N,[x,"type"],""),customFieldUid:Z()(N,[x,"customField"],"")})))};Zn.defaultProps={isContentTypeView:!1,updateLayout:null},Zn.propTypes={components:n().object.isRequired,isContentTypeView:n().bool,mainLayout:n().shape({attributes:n().object.isRequired,info:n().object.isRequired,layouts:n().shape({list:n().array.isRequired,edit:n().array.isRequired}).isRequired,metadatas:n().object.isRequired,options:n().object.isRequired}).isRequired,slug:n().string.isRequired,updateLayout:n().func};var Ln=Zn,Vt=l(66941),Tr=l(40582);const Ul=()=>({type:Tr.c}),Vl=(t,o)=>({type:Tr.O,layout:t,query:o});var Sn=l(9592),ql=l(76402),Hl=()=>(0,e.useContext)(ql.ux),Dr=t=>{const{getAdminInjectedComponents:o}=Hl(),[r,a,s]=t.split(".");return o(r,a,s)};const Or=({area:t,...o})=>Dr(t).map(a=>e.createElement(a.Component,{key:a.name,...o}));Or.propTypes={area:n().string.isRequired};var qt=Or,ze=l(84306),Xe=l(46491);const Ht=()=>({type:Xe.ZA}),kn=t=>({type:Xe.Id,data:t}),Fn=(t,o=!1)=>({type:Xe.TP,rawQuery:t,isSingleType:o}),Ir=()=>({type:Xe.c2}),Pr=(t,o)=>({type:Xe.w7,componentsDataStructure:t,contentTypeDataStructure:o}),me=t=>({type:Xe.d0,status:t}),Je=t=>({type:Xe.t9,data:t}),Gl=()=>({type:Xe.tE});var An=t=>t["content-manager_editViewCrudReducer"];const wn=({allLayoutData:t,children:o,slug:r,id:a,origin:s})=>{const c=(0,Be.useQueryClient)(),i=(0,y.lm)(),{setCurrentStep:d}=(0,y.c1)(),{trackUsage:m}=(0,y.rS)(),{push:u,replace:p}=(0,re.k6)(),[{query:E,rawQuery:h}]=(0,y.Kx)(),g=(0,ae.I0)(),{componentsDataStructure:b,contentTypeDataStructure:C,data:I,isLoading:v,status:M}=(0,ae.v9)(An),x=(0,oe.Ky)(r),{formatAPIError:j}=(0,y.So)(f.OB),D=(0,e.useRef)(!0),O=(0,e.useRef)(m),N=(0,e.useRef)(t),w=(0,y.kY)(),{put:T,post:S,del:G}=w,$=a===null,X=$&&!s?null:(0,f.IF)(`collection-types/${r}/${s||a}`),Q=(0,e.useCallback)(L=>{const B=(0,f.kc)(L,N.current.contentType,N.current.components);return(0,y.dU)(B,N.current.contentType,N.current.components)},[]);(0,e.useEffect)(()=>{const L=Object.keys(t.components).reduce((ce,ge)=>{const V=(0,f.Di)(Z()(t,["components",ge,"attributes"],{}),t.components);return ce[ge]=(0,y.dU)(V,t.components[ge],t.components),ce},{}),B=(0,f.Di)(t.contentType.attributes,t.components),ne=(0,y.dU)(B,t.contentType,t.components);g(Pr(L,ne))},[t,g]),(0,e.useEffect)(()=>()=>{g(Ir())},[g]),(0,e.useEffect)(()=>{const B=ze.default.CancelToken.source(),ne=async ge=>{g(Ht());try{const{data:V}=await w.get(X,{cancelToken:ge.token});g(kn(Q(V)))}catch(V){if(ze.default.isCancel(V))return;const z=Z()(V,"response.status",null);if(z===404){u(x);return}z===403&&(i({type:"info",message:{id:(0,f.OB)("permissions.not-allowed.update")}}),u(x))}},ce=async()=>{g(Ht()),g(Fn(h))};return D.current?(X?ne(B):ce(),()=>{B.cancel("Operation canceled by the user.")}):()=>{}},[w,Q,u,X,g,h,x,i]);const J=(0,e.useCallback)(L=>{i({type:"warning",message:j(L)})},[i,j]),A=(0,e.useCallback)(async L=>{try{O.current("willDeleteEntry",L);const{data:B}=await G((0,f.IF)(`collection-types/${r}/${a}`));return i({type:"success",message:{id:(0,f.OB)("success.record.delete")}}),O.current("didDeleteEntry",L),p(x),Promise.resolve(B)}catch(B){return O.current("didNotDeleteEntry",{error:B,...L}),Promise.reject(B)}},[a,r,i,G,x,p]),k=(0,e.useCallback)(async(L,B)=>{const ne=typeof s=="string",ce=ne?(0,f.IF)(`collection-types/${r}/clone/${s}`):(0,f.IF)(`collection-types/${r}`);try{g(me("submit-pending"));const{id:ge,...V}=L,{data:z}=await S(ce,ne?V:L,{params:E});return O.current("didCreateEntry",B),i({type:"success",message:{id:(0,f.OB)("success.record.save")}}),d("contentManager.success"),c.invalidateQueries(["relation"]),g(Je(Q(z))),g(me("resolved")),p(`/content-manager/collectionType/${r}/${z.id}${h}`),Promise.resolve(z)}catch(ge){return J(ge),O.current("didNotCreateEntry",{error:ge,trackerProperty:B}),g(me("resolved")),Promise.reject(ge)}},[s,Q,J,p,r,g,E,i,d,c,S,h]),R=(0,e.useCallback)(async()=>{try{O.current("willCheckDraftRelations");const L=(0,f.IF)(`collection-types/${r}/${a}/actions/countDraftRelations`);g(me("draft-relation-check-pending"));const B=await w.get(L);return O.current("didCheckDraftRelations"),g(me("resolved")),B.data.data}catch(L){return J(L),g(me("resolved")),Promise.reject(L)}},[J,a,r,g,w]),F=(0,e.useCallback)(async()=>{try{O.current("willPublishEntry");const L=(0,f.IF)(`collection-types/${r}/${a}/actions/publish`);g(me("publish-pending"));const{data:B}=await S(L);return O.current("didPublishEntry"),g(Je(Q(B))),g(me("resolved")),i({type:"success",message:{id:(0,f.OB)("success.record.publish")}}),Promise.resolve(B)}catch(L){return J(L),g(me("resolved")),Promise.reject(L)}},[Q,J,a,r,g,i,S]),U=(0,e.useCallback)(async(L,B)=>{const ne=(0,f.IF)(`collection-types/${r}/${a}`);try{O.current("willEditEntry",B),g(me("submit-pending"));const{data:ce}=await T(ne,L);return O.current("didEditEntry",{trackerProperty:B}),i({type:"success",message:{id:(0,f.OB)("success.record.save")}}),c.invalidateQueries(["relation"]),g(Je(Q(ce))),g(me("resolved")),Promise.resolve(ce)}catch(ce){return O.current("didNotEditEntry",{error:ce,trackerProperty:B}),J(ce),g(me("resolved")),Promise.reject(ce)}},[Q,J,r,a,g,i,c,T]),Y=(0,e.useCallback)(async()=>{const L=(0,f.IF)(`collection-types/${r}/${a}/actions/unpublish`);g(me("unpublish-pending"));try{O.current("willUnpublishEntry");const{data:B}=await S(L);return O.current("didUnpublishEntry"),i({type:"success",message:{id:(0,f.OB)("success.record.unpublish")}}),g(Je(Q(B))),g(me("resolved")),Promise.resolve(B)}catch(B){return g(me("resolved")),J(B),Promise.reject(B)}},[Q,J,a,r,g,i,S]);return o({componentsDataStructure:b,contentTypeDataStructure:C,data:I,isCreatingEntry:$,isLoadingForData:v,onDelete:A,onPost:k,onPublish:F,onDraftRelationCheck:R,onPut:U,onUnpublish:Y,status:M,redirectionLink:x})};wn.defaultProps={id:null,origin:null},wn.propTypes={allLayoutData:n().exact({components:n().object.isRequired,contentType:n().shape({apiID:n().string.isRequired,attributes:n().object.isRequired,info:n().object.isRequired,isDisplayed:n().bool.isRequired,kind:n().string.isRequired,layouts:n().object.isRequired,metadatas:n().object.isRequired,options:n().object.isRequired,pluginOptions:n().object,settings:n().object.isRequired,uid:n().string.isRequired}).isRequired}).isRequired,children:n().func.isRequired,id:n().string,origin:n().string,slug:n().string.isRequired};var Ql=(0,e.memo)(wn,ke()),_e=l(3685),$n=l(69783),xr=l(86308);const Bn=({hasError:t,isDisabled:o,isOpen:r,children:a,onClick:s})=>e.createElement(Kl,{type:"button",onClick:s,disabled:o,hasError:t,background:"neutral0",paddingTop:3,paddingBottom:3,paddingLeft:4,paddingRight:4,style:{cursor:o?"not-allowed":"pointer"}},e.createElement(P.k,{as:"span",gap:2},e.createElement(Nn,{"aria-hidden":!0,$isOpen:r,$hasError:t&&!r}),e.createElement(W.Z,{variant:"pi",fontWeight:"bold",textColor:t&&!r?"danger600":"neutral500"},a))),Nn=(0,q.ZP)(xr.Z)`
|
|
83
|
+
height: ${({theme:t})=>t.spaces[6]};
|
|
84
|
+
width: ${({theme:t})=>t.spaces[6]};
|
|
85
|
+
transform: ${({$isOpen:t})=>t?"rotate(45deg)":"rotate(0deg)"};
|
|
86
|
+
> circle {
|
|
87
|
+
fill: ${({theme:t,$hasError:o})=>o?t.colors.danger200:t.colors.neutral150};
|
|
88
|
+
}
|
|
89
|
+
> path {
|
|
90
|
+
fill: ${({theme:t,$hasError:o})=>o?t.colors.danger600:t.colors.neutral600};
|
|
91
|
+
}
|
|
92
|
+
`,Kl=(0,q.ZP)($n.Y)`
|
|
93
|
+
border-radius: 26px;
|
|
94
|
+
border-color: ${({theme:t})=>t.colors.neutral150};
|
|
95
|
+
box-shadow: ${({theme:t})=>t.shadows.filterShadow};
|
|
96
|
+
|
|
97
|
+
&:hover {
|
|
98
|
+
${W.Z} {
|
|
99
|
+
color: ${({theme:t})=>t.colors.primary600};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
${Nn} {
|
|
103
|
+
> circle {
|
|
104
|
+
fill: ${({theme:t})=>t.colors.primary600};
|
|
105
|
+
}
|
|
106
|
+
> path {
|
|
107
|
+
fill: ${({theme:t})=>t.colors.neutral100};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
&:active {
|
|
112
|
+
${W.Z} {
|
|
113
|
+
color: ${({theme:t})=>t.colors.primary600};
|
|
114
|
+
}
|
|
115
|
+
${Nn} {
|
|
116
|
+
> circle {
|
|
117
|
+
fill: ${({theme:t})=>t.colors.primary600};
|
|
118
|
+
}
|
|
119
|
+
> path {
|
|
120
|
+
fill: ${({theme:t})=>t.colors.neutral100};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
`;Bn.defaultProps={hasError:!1,isDisabled:!1,isOpen:!1},Bn.propTypes={children:n().node.isRequired,hasError:n().bool,isDisabled:n().bool,isOpen:n().bool,onClick:n().func.isRequired};var Zr=l(861),jn=l(83828),Wn=l(61762),zn=l(89966);const Un=({category:t,components:o,variant:r,isOpen:a,onAddComponent:s,onToggle:c})=>{const{formatMessage:i}=(0,K.Z)(),d=()=>{c(t)};return e.createElement(jn.U,{expanded:a,onToggle:d,size:"S"},e.createElement(Wn.B,{variant:r,title:i({id:t,defaultMessage:t}),togglePosition:"left"}),e.createElement(zn.v,null,e.createElement(H.x,{paddingTop:4,paddingBottom:4,paddingLeft:3,paddingRight:3},e.createElement(Yl,null,o.map(({componentUid:m,info:{displayName:u,icon:p}})=>e.createElement(Xl,{key:m,as:"button",type:"button",background:"neutral100",justifyContent:"center",onClick:s(m),hasRadius:!0,height:(0,y.Q1)(84),shrink:0,borderColor:"neutral200"},e.createElement(P.k,{direction:"column",gap:1,alignItems:"center",justifyContent:"center"},e.createElement(Zt,{icon:p}),e.createElement(W.Z,{variant:"pi",fontWeight:"bold",textColor:"neutral600"},i({id:u,defaultMessage:u})))))))))},Yl=q.ZP.div`
|
|
125
|
+
display: grid;
|
|
126
|
+
grid-template-columns: repeat(auto-fit, ${140/16}rem);
|
|
127
|
+
grid-gap: ${({theme:t})=>t.spaces[1]};
|
|
128
|
+
`,Xl=(0,q.ZP)(P.k)`
|
|
129
|
+
&:focus,
|
|
130
|
+
&:hover {
|
|
131
|
+
border: 1px solid ${({theme:t})=>t.colors.primary200};
|
|
132
|
+
background: ${({theme:t})=>t.colors.primary100};
|
|
133
|
+
|
|
134
|
+
${W.Z} {
|
|
135
|
+
color: ${({theme:t})=>t.colors.primary600};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/* > Flex > ComponentIcon */
|
|
139
|
+
> div > div:first-child {
|
|
140
|
+
background: ${({theme:t})=>t.colors.primary200};
|
|
141
|
+
color: ${({theme:t})=>t.colors.primary600};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
`;Un.defaultProps={components:[],isOpen:!1,variant:"primary"},Un.propTypes={category:n().string.isRequired,components:n().array,isOpen:n().bool,onAddComponent:n().func.isRequired,onToggle:n().func.isRequired,variant:n().oneOf(["primary","secondary"])};const Vn=({dynamicComponentsByCategory:t,isOpen:o,onClickAddComponent:r})=>{const{formatMessage:a}=(0,K.Z)(),[s,c]=(0,e.useState)("");(0,e.useEffect)(()=>{const m=Object.keys(t);o&&m.length>0&&c(m[0])},[o,t]);const i=m=>()=>{r(m),c("")},d=m=>{c(u=>u===m?"":m)};return o?e.createElement(H.x,{paddingTop:6,paddingBottom:6,paddingLeft:5,paddingRight:5,background:"neutral0",shadow:"tableShadow",borderColor:"neutral150",hasRadius:!0},e.createElement(P.k,{justifyContent:"center"},e.createElement(W.Z,{fontWeight:"bold",textColor:"neutral600"},a({id:(0,f.OB)("components.DynamicZone.ComponentPicker-label"),defaultMessage:"Pick one component"}))),e.createElement(H.x,{paddingTop:2},e.createElement(Zr.k,{attributeName:"data-strapi-accordion-toggle"},Object.entries(t).map(([m,u],p)=>e.createElement(Un,{key:m,category:m,components:u,onAddComponent:i,isOpen:m===s,onToggle:d,variant:p%2===1?"primary":"secondary"}))))):null};Vn.defaultProps={dynamicComponentsByCategory:{},isOpen:!1},Vn.propTypes={dynamicComponentsByCategory:n().shape({components:n().arrayOf(n().shape({componentUid:n().string.isRequired,info:n().object}))}),isOpen:n().bool,onClickAddComponent:n().func.isRequired};var Lr=l(91647),qn=l(49825),Jl=l(61868),_l=l.n(Jl);const ec=q.ZP.span`
|
|
145
|
+
> svg {
|
|
146
|
+
width: ${(0,y.Q1)(24)};
|
|
147
|
+
height: ${(0,y.Q1)(24)};
|
|
148
|
+
> circle {
|
|
149
|
+
fill: ${({theme:t})=>t.colors.primary200};
|
|
150
|
+
}
|
|
151
|
+
> path {
|
|
152
|
+
fill: ${({theme:t})=>t.colors.primary600};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
`,Hn=({error:t,isReadOnly:o,onClick:r})=>{const{formatMessage:a}=(0,K.Z)();return e.createElement(e.Fragment,null,e.createElement(H.x,{as:"button",background:"neutral100",borderColor:t?"danger600":"neutral200",disabled:o,hasRadius:!0,onClick:r,paddingTop:9,paddingBottom:9,type:"button"},e.createElement(P.k,{direction:"column",gap:2},e.createElement(P.k,{justifyContent:"center",style:{cursor:o?"not-allowed":"inherit"}},e.createElement(ec,null,e.createElement(xr.Z,null))),e.createElement(P.k,{justifyContent:"center"},e.createElement(W.Z,{textColor:"primary600",variant:"pi",fontWeight:"bold"},a({id:(0,f.OB)("components.empty-repeatable"),defaultMessage:"No entry yet. Click on the button below to add one."}))))),t?.id&&e.createElement(W.Z,{textColor:"danger600",variant:"pi"},a(t,{...t.values})))};Hn.defaultProps={error:void 0,isReadOnly:!1},Hn.propTypes={error:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}),isReadOnly:n().bool,onClick:n().func.isRequired};var Sr=Hn;const kt=new Map;var Gn=(t=[])=>{const[o,r]=(0,e.useState)(Object.fromEntries(kt)),a=t.filter(m=>!kt.get(m)),[s,c]=(0,e.useState)(()=>!!a.length),i=(0,y.mZ)();(0,e.useEffect)(()=>{const m=p=>{r(p),c(!1)},u=async(p,E)=>{const h=await Promise.all(E);p.forEach((g,b)=>{kt.set(g,h[b].default)}),m(Object.fromEntries(kt))};if(a.length>0){c(!0);const p=a.reduce((E,h)=>{const g=i.get(h);return g&&E.push(g.components.Input()),E},[]);p.length>0&&u(a,p)}},[a,i]);const d=(0,e.useCallback)(()=>{kt.clear(),r({})},[]);return{isLazyLoading:s,lazyComponentStore:o,cleanup:d}},tc=l(9086),nc=l.n(tc),oc=l(88708),Ft=l.n(oc),Qn=l(38705),At=l(69932),rc=l(27169),kr=l(99097),ac=l(63642);const sc=(0,q.ZP)(ac.E)`
|
|
156
|
+
svg {
|
|
157
|
+
height: 1rem;
|
|
158
|
+
width: 1rem;
|
|
159
|
+
path {
|
|
160
|
+
fill: ${({theme:t})=>t.colors.neutral400};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
svg:hover {
|
|
165
|
+
path {
|
|
166
|
+
fill: ${({theme:t})=>t.colors.primary600};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
`,Fr=(0,q.ZP)(P.k)`
|
|
170
|
+
svg {
|
|
171
|
+
height: ${12/16}rem;
|
|
172
|
+
width: ${12/16}rem;
|
|
173
|
+
|
|
174
|
+
path {
|
|
175
|
+
fill: ${({theme:t,available:o})=>o?t.colors.success600:t.colors.danger600};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
`,ic=(0,q.F4)`
|
|
179
|
+
from {
|
|
180
|
+
transform: rotate(0deg);
|
|
181
|
+
}
|
|
182
|
+
to {
|
|
183
|
+
transform: rotate(359deg);
|
|
184
|
+
}
|
|
185
|
+
`,lc=(0,q.ZP)(P.k)`
|
|
186
|
+
animation: ${ic} 2s infinite linear;
|
|
187
|
+
`;var cc=/^[A-Za-z0-9-_.~]*$/;const Kn=({attribute:t,contentTypeUID:o,hint:r,disabled:a,error:s,intlLabel:c,labelAction:i,name:d,onChange:m,value:u,placeholder:p,required:E})=>{const{modifiedData:h,initialData:g,layout:b}=(0,y.Wq)(),[C,I]=(0,e.useState)(!1),[v,M]=(0,e.useState)(null),x=(0,kr.Z)(u,300),j=(0,e.useRef)(),D=(0,y.lm)(),{formatAPIError:O}=(0,y.So)(),N=g[d],{formatMessage:w}=(0,K.Z)(),T=b?.options?.timestamps??0,S=!g[T],G=(0,kr.Z)(h[t.targetField],300),[$,X]=(0,e.useState)(!1),[Q,J]=(0,e.useState)(null),{post:A}=(0,y.kY)(),k=c.id?w({id:c.id,defaultMessage:c.defaultMessage},{...c.values}):d,R=p?w({id:p.id,defaultMessage:p.defaultMessage},{...p.values}):"";j.current=async(B=!1)=>{I(!0);try{const{data:{data:ne}}=await A((0,f.IF)("uid/generate"),{contentTypeUID:o,field:d,data:h});m({target:{name:d,value:ne,type:"text"}},B),I(!1)}catch(ne){I(!1),D({type:"warning",message:O(ne)})}};const F=async()=>{if(u){I(!0);try{const{data:B}=await A((0,f.IF)("uid/check-availability"),{contentTypeUID:o,field:d,value:u?u.trim():""});I(!1),M(B)}catch(B){I(!1),D({type:"warning",message:O(B)})}}};(0,e.useEffect)(()=>{!u&&t.required&&j.current(!0)},[t.required,j,u]),(0,e.useEffect)(()=>{x?.trim().match(cc)&&x!==N&&F(),x||M(null)},[N,x]),(0,e.useEffect)(()=>{let B;return v?.isAvailable&&(B=setTimeout(()=>{M(null)},4e3)),()=>{B&&clearTimeout(B)}},[v]),(0,e.useEffect)(()=>{!$&&S&&G&&h[t.targetField]&&!u&&j.current(!0)},[G,$,S]);const U=()=>{J(w({id:"content-manager.components.uid.regenerate",defaultMessage:"Regenerate"}))},Y=()=>{J(null)},L=B=>{B.target.value&&S&&X(!0),m(B)};return e.createElement(Tn.o,{disabled:a,error:s,endAction:e.createElement(P.k,{position:"relative",gap:1},v&&!Q&&e.createElement(Fr,{alignItems:"center",gap:1,justifyContent:"flex-end",available:!!v?.isAvailable,"data-not-here-outer":!0,position:"absolute",pointerEvents:"none",right:6,width:"100px"},v?.isAvailable?e.createElement(Qn.Z,null):e.createElement(At.Z,null),e.createElement(W.Z,{textColor:v.isAvailable?"success600":"danger600",variant:"pi"},w(v.isAvailable?{id:"content-manager.components.uid.available",defaultMessage:"Available"}:{id:"content-manager.components.uid.unavailable",defaultMessage:"Unavailable"}))),!a&&e.createElement(e.Fragment,null,Q&&e.createElement(Fr,{alignItems:"center",justifyContent:"flex-end",gap:1},e.createElement(W.Z,{textColor:"primary600",variant:"pi"},Q)),e.createElement(sc,{onClick:()=>j.current(),label:w({id:"content-manager.components.uid.regenerate",defaultMessage:"Regenerate"}),onMouseEnter:U,onMouseLeave:Y},C?e.createElement(lc,{"data-testid":"loading-wrapper"},e.createElement(rc.Z,null)):e.createElement(pn.Z,null)))),hint:r,label:k,labelAction:i,name:d,onChange:L,placeholder:R,value:u||"",required:E})};Kn.propTypes={attribute:n().shape({targetField:n().string,required:n().bool}).isRequired,contentTypeUID:n().string.isRequired,disabled:n().bool,error:n().string,intlLabel:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}).isRequired,labelAction:n().element,name:n().string.isRequired,onChange:n().func.isRequired,value:n().string,placeholder:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}),required:n().bool,hint:n().oneOfType([n().string,n().array])},Kn.defaultProps={disabled:!1,error:void 0,labelAction:void 0,placeholder:void 0,value:"",required:!1,hint:""};var dc=Kn;function uc(t,o){return r=>{const a=o(r);return e.createElement(t,{...r,...a})}}var mc=uc;const pc=(t=[],o=[])=>{const r=t.reduce((s,c)=>o.find(i=>i.id===c.id)?s:[...s,c.id],[]),a=o.reduce((s,c)=>t.find(i=>i.id===c.id)?s:[...s,c.id],[]);return[r,a]},at={DRAFT:"draft",PUBLISHED:"published"},Yn=5,gc=10;function fc(t,o){return`${(0,f.IF)(`collectionType/${t}/${o??""}`)}`}const Xn=(t,{shouldAddLink:o,mainFieldName:r,targetModel:a})=>{const s={...t};return o&&(s.href=fc(a,s.id)),s.publicationState=!1,s?.publishedAt!==void 0&&(s.publicationState=s.publishedAt?at.PUBLISHED:at.DRAFT),s.mainField=s[r],s},hc=(t,{shouldAddLink:o=!1,mainFieldName:r,targetModel:a}={})=>[...t].map(s=>Xn(s,{shouldAddLink:o,mainFieldName:r,targetModel:a})),yc=(t,{mainFieldName:o})=>{const{data:r}=t,{pages:a=[]}=r??{};return{...t,data:a.map(s=>s?.results.map(c=>Xn(c,{mainFieldName:o}))).filter(Boolean).flat()}};function Ec({componentUid:t,isUserAllowedToEditField:o,isUserAllowedToReadField:r,name:a,queryInfos:s}){const{isCreatingEntry:c,createActionAllowedFields:i,readActionAllowedFields:d,updateActionAllowedFields:m,slug:u,modifiedData:p}=(0,y.Wq)(),{params:E}=(0,re.$B)("/content-manager/collectionType/:collectionType/create/clone/:origin")??{},{origin:h}=E??{},g=(0,e.useMemo)(()=>o===!0?!0:(c?i:m).includes(a),[c,i,a,o,m]),b=(0,e.useMemo)(()=>r?!0:(c?[]:d).includes(a),[c,r,a,d]),C=a.split(".");let I;t&&(I=Z()(p,C.slice(0,-1))?.id);const v=h||p.id,M=(0,e.useMemo)(()=>c&&!h?null:t?I?(0,f.IF)(`relations/${t}/${I}/${C.at(-1)}`):null:(0,f.IF)(`relations/${u}/${v}/${a.split(".").at(-1)}`),[c,h,t,u,v,a,I,C]),x=(0,e.useMemo)(()=>t?(0,f.IF)(`relations/${t}/${a.split(".").at(-1)}`):(0,f.IF)(`relations/${u}/${a.split(".").at(-1)}`),[t,u,a]);return{entityId:v,componentId:I,isComponentRelation:Boolean(t),queryInfos:{...s,endpoints:{search:x,relation:M}},isCloningEntry:Boolean(h),isCreatingEntry:c,isFieldAllowed:g,isFieldReadable:b}}var bc=Ec;const vc=(t,{relation:o,search:r})=>{const[a,s]=(0,e.useState)({}),[c,i]=(0,e.useState)(0),{get:d}=(0,y.kY)(),m=async({pageParam:D=1})=>{try{const{data:O}=await d(o?.endpoint,{params:{...o.pageParams??{},page:D}});return i(D),O}catch{return null}},u=async({pageParam:D=1})=>{try{const{data:O}=await d(r.endpoint,{params:{...r.pageParams??{},...a,page:D}});return O}catch{return null}},{onLoad:p,normalizeArguments:E={}}=o,h=(0,Be.useInfiniteQuery)(["relation",...t],m,{cacheTime:0,enabled:o.enabled,getNextPageParam(D){const O=!D?.pagination;if(!(!D||O||D?.pagination.page>=D?.pagination.pageCount))return D.pagination.page+1},select:D=>({...D,pages:D.pages.map(O=>{if(!O)return O;const{data:N,results:w,pagination:T}=O,S=!!N;let G=[];return S?G=[N]:w&&(G=[...w].reverse()),{pagination:T,results:G}})})}),{pageGoal:g}=o,{status:b,data:C,fetchNextPage:I,hasNextPage:v}=h;(0,e.useEffect)(()=>{g>c&&v&&b==="success"&&I({pageParam:c+1})},[g,c,I,v,b]);const M=(0,y.W6)(p);(0,e.useEffect)(()=>{if(b==="success"&&C&&C.pages?.at(-1)?.results&&M){const D=hc(C.pages.at(-1).results,E);M(D)}},[b,M,C]);const x=(0,Be.useInfiniteQuery)(["relation",...t,"search",JSON.stringify(a)],u,{enabled:Object.keys(a).length>0,getNextPageParam(D){if(!(!D?.pagination||D.pagination.page>=D.pagination.pageCount))return D.pagination.page+1}});return{relations:h,search:x,searchFor:(D,O={})=>{s({...O,_q:D})}}},Ar=(t,o)=>r=>{const a=r.split(".");return a.reduce((s,c,i)=>{const d=Z()(t,s),m=Z()(o,[...a.slice(0,i),c,"__temp_key__"]);if(Array.isArray(d)&&typeof m=="number"){const u=d.findIndex(p=>p.__temp_key__===m);return s.push(u.toString()),s}return s.push(c),s},[])};var Cc=l(50428),Rc=l(21428),wr=l(7563),wt=l(63919),Jn=l(41234),Gt=l(35331),Mc=l(41044),$r=l(90333);const Tc=q.ZP.div`
|
|
188
|
+
flex-shrink: 0;
|
|
189
|
+
width: ${(0,y.Q1)(6)};
|
|
190
|
+
height: ${(0,y.Q1)(6)};
|
|
191
|
+
margin-right: ${({theme:t})=>t.spaces[2]};
|
|
192
|
+
background-color: ${({theme:t,isDraft:o})=>t.colors[o?"secondary600":"success600"]};
|
|
193
|
+
border-radius: 50%;
|
|
194
|
+
`,_n=({publicationState:t,mainField:o,id:r})=>{const{formatMessage:a}=(0,K.Z)(),s=(o??r).toString();if(t){const c=t==="draft",i={id:(0,f.OB)("components.Select.draft-info-title"),defaultMessage:"State: Draft"},d={id:(0,f.OB)("components.Select.publish-info-title"),defaultMessage:"State: Published"},m=a(c?i:d);return e.createElement($r.O,{value:r,textValue:s},e.createElement(P.k,null,e.createElement(Tc,{title:m,isDraft:c}),e.createElement(W.Z,{ellipsis:!0},s)))}return e.createElement($r.O,{value:r,textValue:s},s)};_n.defaultProps={mainField:void 0,publicationState:void 0},_n.propTypes={id:n().number.isRequired,mainField:n().oneOfType([n().string,n().number]),publicationState:n().oneOfType([n().string,n().bool])};var Br=l(77622);const Qt=50,yt=4,Nr=(0,q.ZP)(P.k)`
|
|
195
|
+
width: 100%;
|
|
196
|
+
/* Used to prevent endAction to be pushed out of container */
|
|
197
|
+
min-width: 0;
|
|
198
|
+
|
|
199
|
+
& > div[role='button'] {
|
|
200
|
+
cursor: all-scroll;
|
|
201
|
+
}
|
|
202
|
+
`,jr=(0,q.ZP)(P.k)`
|
|
203
|
+
width: 100%;
|
|
204
|
+
/* Used to prevent endAction to be pushed out of container */
|
|
205
|
+
min-width: 0;
|
|
206
|
+
`,eo=({ariaDescribedBy:t,children:o,displayValue:r,canDrag:a,disabled:s,endAction:c,iconButtonAriaLabel:i,style:d,id:m,index:u,name:p,onCancel:E,onDropItem:h,onGrabItem:g,status:b,updatePositionOfRelation:C,...I})=>{const[{handlerId:v,isDragging:M,handleKeyDown:x},j,D,O,N]=(0,Br.Y)(a&&!s,{type:`${f._Q.RELATION}_${p}`,index:u,item:{displayedValue:r,status:b,id:m},onGrabItem:g,onDropItem:h,onCancel:E,onMoveItem:C,dropSensitivity:"immediate"}),w=(0,f.FE)(j,O);return(0,e.useEffect)(()=>{N((0,xt.rX)())},[N]),e.createElement(H.x,{style:d,as:"li",ref:D,"aria-describedby":t,cursor:a?"all-scroll":"default"},M?e.createElement(Dc,null):e.createElement(P.k,{paddingTop:2,paddingBottom:2,paddingLeft:a?2:4,paddingRight:4,hasRadius:!0,borderSize:1,borderColor:"neutral200",background:s?"neutral150":"neutral0",justifyContent:"space-between",ref:a?w:void 0,"data-handler-id":v,...I},e.createElement(Nr,{gap:1},a?e.createElement(Re.h,{forwardedAs:"div",role:"button",tabIndex:0,"aria-label":i,noBorder:!0,onKeyDown:x,disabled:s},e.createElement(Ye.Z,null)):null,e.createElement(jr,{justifyContent:"space-between"},o)),c&&e.createElement(H.x,{paddingLeft:4},c)))},Dc=()=>e.createElement(H.x,{paddingTop:2,paddingBottom:2,paddingLeft:4,paddingRight:4,hasRadius:!0,borderStyle:"dashed",borderColor:"primary600",borderWidth:"1px",background:"primary100",height:`calc(100% - ${yt}px)`});eo.defaultProps={ariaDescribedBy:"",canDrag:!1,displayValue:"",disabled:!1,endAction:void 0,onCancel:void 0,onDropItem:void 0,onGrabItem:void 0,style:void 0,status:void 0,updatePositionOfRelation:void 0},eo.propTypes={ariaDescribedBy:n().string,canDrag:n().bool,children:n().node.isRequired,displayValue:n().string,disabled:n().bool,endAction:n().node,iconButtonAriaLabel:n().string.isRequired,id:n().number.isRequired,index:n().number.isRequired,name:n().string.isRequired,onCancel:n().func,onDropItem:n().func,onGrabItem:n().func,status:n().string,style:n().shape({height:n().number,left:n().number,position:n().string,right:n().number,width:n().string}),updatePositionOfRelation:n().func};const Oc=(0,q.ZP)(H.x)`
|
|
207
|
+
position: relative;
|
|
208
|
+
overflow: hidden;
|
|
209
|
+
flex: 1;
|
|
210
|
+
|
|
211
|
+
&:before,
|
|
212
|
+
&:after {
|
|
213
|
+
position: absolute;
|
|
214
|
+
width: 100%;
|
|
215
|
+
height: 4px;
|
|
216
|
+
z-index: 1;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
&:before {
|
|
220
|
+
/* TODO: as for DS Table component we would need this to be handled by the DS theme */
|
|
221
|
+
content: '';
|
|
222
|
+
background: linear-gradient(rgba(3, 3, 5, 0.2) 0%, rgba(0, 0, 0, 0) 100%);
|
|
223
|
+
top: 0;
|
|
224
|
+
opacity: ${({overflowDirection:t})=>t==="top-bottom"||t==="top"?1:0};
|
|
225
|
+
transition: opacity 0.2s ease-in-out;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
&:after {
|
|
229
|
+
/* TODO: as for DS Table component we would need this to be handled by the DS theme */
|
|
230
|
+
content: '';
|
|
231
|
+
background: linear-gradient(0deg, rgba(3, 3, 5, 0.2) 0%, rgba(0, 0, 0, 0) 100%);
|
|
232
|
+
bottom: 0;
|
|
233
|
+
opacity: ${({overflowDirection:t})=>t==="top-bottom"||t==="bottom"?1:0};
|
|
234
|
+
transition: opacity 0.2s ease-in-out;
|
|
235
|
+
}
|
|
236
|
+
`,to=({children:t,overflow:o,...r})=>e.createElement(Oc,{overflowDirection:o,...r},t);to.defaultProps={overflow:""},to.propTypes={children:n().node.isRequired,overflow:n().oneOf(["top-bottom","bottom","top",""])};const Wr=(0,q.ZP)(Cc.r)`
|
|
237
|
+
display: block;
|
|
238
|
+
|
|
239
|
+
> span {
|
|
240
|
+
white-space: nowrap;
|
|
241
|
+
overflow: hidden;
|
|
242
|
+
text-overflow: ellipsis;
|
|
243
|
+
display: block;
|
|
244
|
+
}
|
|
245
|
+
`,zr=q.ZP.button`
|
|
246
|
+
svg path {
|
|
247
|
+
fill: ${({theme:t,disabled:o})=>o?t.colors.neutral600:t.colors.neutral500};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
&:hover svg path,
|
|
251
|
+
&:focus svg path {
|
|
252
|
+
fill: ${({theme:t,disabled:o})=>!o&&t.colors.neutral600};
|
|
253
|
+
}
|
|
254
|
+
`,no=({canReorder:t,description:o,disabled:r,error:a,iconButtonAriaLabel:s,id:c,name:i,numberOfRelationsToDisplay:d,label:m,labelAction:u,labelLoadMore:p,labelDisconnectRelation:E,listAriaDescription:h,liveText:g,loadingMessage:b,onCancel:C,onDropItem:I,onGrabItem:v,noRelationsMessage:M,onRelationConnect:x,onRelationLoadMore:j,onRelationDisconnect:D,onRelationReorder:O,onSearchNextPage:N,onSearch:w,placeholder:T,publicationStateTranslations:S,required:G,relations:$,searchResults:X,size:Q})=>{const[J,A]=(0,e.useState)(""),[k,R]=(0,e.useState)(""),F=(0,e.useRef)(),U=(0,e.useRef)(),{data:Y}=X,L=$.data,B=L.length??0,ne=(0,e.useMemo)(()=>B>d?Math.min(B,d)*(Qt+yt)+Qt/2:Math.min(B,d)*(Qt+yt),[B,d]),ce=!!p&&$.hasNextPage,ge=(0,e.useMemo)(()=>Y.flat().filter(Boolean).map(de=>({...de,value:de.id,label:de.mainField})),[Y]);(0,e.useEffect)(()=>{if(B<=d)return R("");const de=je=>{const Pe=je.target.parentNode.scrollHeight,He=je.target.scrollHeight-je.target.scrollTop;return je.target.scrollTop===0?R("bottom"):R(He===Pe?"top":"top-bottom")},Ie=U?.current;return!$.isLoading&&L.length>0&&Ie&&U.current.addEventListener("scroll",de),()=>{Ie&&Ie.removeEventListener("scroll",de)}},[$,L,d,B]);const V=de=>{de&&w()},z=(de,Ie)=>{O&&de>=0&&de<L.length&&O(Ie,de)},ye=(0,oe.zH)(L.length),he=(0,e.useRef)(),Ne=()=>{he.current="loadMore",j()};(0,e.useEffect)(()=>{he.current==="onChange"&&A(""),he.current==="onChange"&&L.length!==ye?(F.current.scrollToItem(L.length,"end"),he.current=void 0):he.current==="loadMore"&&L.length!==ye&&(F.current.scrollToItem(0,"start"),he.current=void 0)},[ye,L]);const Ue=`${i}-item-instructions`;return e.createElement(P.k,{gap:3,justifyContent:"space-between",alignItems:"end",wrap:"wrap"},e.createElement(P.k,{direction:"column",alignItems:"stretch",basis:Q<=6?"100%":"70%",gap:2},e.createElement(Rc.hQ,{autocomplete:"list",error:a,name:i,hint:o,id:c,required:G,label:m,labelAction:u,disabled:r,placeholder:T,hasMoreItems:X.hasNextPage,loading:X.isLoading,onOpenChange:V,noOptionsMessage:()=>M,loadingMessage:b,onLoadMore:()=>{N()},textValue:J,onChange:de=>{de&&(x(ge.find(Ie=>Ie.id===de)),he.current="onChange")},onTextValueChange:de=>{A(de)},onInputChange:de=>{w(de.currentTarget.value)}},ge.map(de=>e.createElement(_n,{key:de.id,...de}))),ce&&e.createElement(wr.A,{disabled:$.isLoading||$.isFetchingNextPage,onClick:Ne,loading:$.isLoading||$.isFetchingNextPage,startIcon:e.createElement(pn.Z,null)},p)),L.length>0&&e.createElement(to,{overflow:k},e.createElement(_e.T,{id:Ue},h),e.createElement(_e.T,{"aria-live":"assertive"},g),e.createElement(Mc.t7,{height:ne,ref:F,outerRef:U,itemCount:B,itemSize:Qt+yt,itemData:{name:i,ariaDescribedBy:Ue,canDrag:t,disabled:r,handleCancel:C,handleDropItem:I,handleGrabItem:v,iconButtonAriaLabel:s,labelDisconnectRelation:E,onRelationDisconnect:D,publicationStateTranslations:S,relations:L,updatePositionOfRelation:z},itemKey:de=>`${L[de].mainField}_${L[de].id}`,innerElementType:"ol"},oo)))},Ic=n().shape({data:n().arrayOf(n().shape({href:n().string,id:n().number.isRequired,publicationState:n().oneOfType([n().string,n().bool]),mainField:n().oneOfType([n().string,n().number])})),hasNextPage:n().bool,isFetchingNextPage:n().bool.isRequired,isLoading:n().bool.isRequired,isSuccess:n().bool.isRequired}),Pc=n().shape({data:n().arrayOf(n().shape({id:n().number.isRequired,href:n().string,mainField:n().oneOfType([n().string,n().number]),publicationState:n().oneOfType([n().string,n().bool])})),hasNextPage:n().bool,isLoading:n().bool.isRequired,isSuccess:n().bool.isRequired});no.defaultProps={canReorder:!1,description:void 0,disabled:!1,error:void 0,labelAction:null,labelLoadMore:null,liveText:void 0,onCancel:void 0,onDropItem:void 0,onGrabItem:void 0,required:!1,relations:{data:[]},searchResults:{data:[]}},no.propTypes={error:n().string,canReorder:n().bool,description:n().string,disabled:n().bool,iconButtonAriaLabel:n().string.isRequired,id:n().string.isRequired,label:n().string.isRequired,labelAction:n().element,labelLoadMore:n().string,labelDisconnectRelation:n().string.isRequired,listAriaDescription:n().string.isRequired,liveText:n().string,loadingMessage:n().string.isRequired,name:n().string.isRequired,noRelationsMessage:n().string.isRequired,numberOfRelationsToDisplay:n().number.isRequired,onCancel:n().func,onDropItem:n().func,onGrabItem:n().func,onRelationConnect:n().func.isRequired,onRelationDisconnect:n().func.isRequired,onRelationLoadMore:n().func.isRequired,onRelationReorder:n().func.isRequired,onSearch:n().func.isRequired,onSearchNextPage:n().func.isRequired,placeholder:n().string.isRequired,publicationStateTranslations:n().shape({draft:n().string.isRequired,published:n().string.isRequired}).isRequired,required:n().bool,searchResults:Pc,size:n().number.isRequired,relations:Ic};const oo=({data:t,index:o,style:r})=>{const{ariaDescribedBy:a,canDrag:s,disabled:c,handleCancel:i,handleDropItem:d,handleGrabItem:m,iconButtonAriaLabel:u,name:p,labelDisconnectRelation:E,onRelationDisconnect:h,publicationStateTranslations:g,relations:b,updatePositionOfRelation:C}=t,{publicationState:I,href:v,mainField:M,id:x}=b[o],j=I==="draft"?"secondary":"success";return e.createElement(eo,{ariaDescribedBy:a,canDrag:s,disabled:c,displayValue:String(M??x),iconButtonAriaLabel:u,id:x,index:o,name:p,endAction:e.createElement(zr,{"data-testid":`remove-relation-${x}`,disabled:c,type:"button",onClick:()=>h(b[o]),"aria-label":E},e.createElement(ft.J,{width:"12px",as:Gt.Z})),onCancel:i,onDropItem:d,onGrabItem:m,status:I||void 0,style:{...r,bottom:r.bottom??0+yt,height:r.height??0-yt},updatePositionOfRelation:C},e.createElement(H.x,{minWidth:0,paddingTop:1,paddingBottom:1,paddingRight:4},e.createElement(wt.u,{description:M??`${x}`},v?e.createElement(Wr,{to:v},M??x):e.createElement(W.Z,{textColor:c?"neutral600":"primary600",ellipsis:!0},M??x))),I&&e.createElement(Jn.q,{variant:j,showBullet:!1,size:"S"},e.createElement(W.Z,{fontWeight:"bold",textColor:`${j}700`},g[I])))};oo.defaultProps={data:{}},oo.propTypes={data:n().shape({ariaDescribedBy:n().string.isRequired,canDrag:n().bool.isRequired,disabled:n().bool.isRequired,handleCancel:n().func,handleDropItem:n().func,handleGrabItem:n().func,iconButtonAriaLabel:n().string.isRequired,labelDisconnectRelation:n().string.isRequired,name:n().string.isRequired,onRelationDisconnect:n().func.isRequired,publicationStateTranslations:n().shape({draft:n().string.isRequired,published:n().string.isRequired}).isRequired,relations:n().arrayOf(n().shape({href:n().string,id:n().number.isRequired,publicationState:n().oneOfType([n().string,n().bool]),mainField:n().oneOfType([n().string,n().number])})),updatePositionOfRelation:n().func.isRequired}),index:n().number.isRequired,style:n().object.isRequired};var xc=no;const ro=({error:t,entityId:o,componentId:r,isComponentRelation:a,editable:s,description:c,intlLabel:i,isCreatingEntry:d,isCloningEntry:m,isFieldAllowed:u,isFieldReadable:p,labelAction:E,mainField:h,name:g,queryInfos:{endpoints:b,defaultParams:C,shouldDisplayRelationLink:I},placeholder:v,required:M,relationType:x,size:j,targetModel:D})=>{const[O,N]=(0,e.useState)(""),{formatMessage:w}=(0,K.Z)(),{slug:T,initialData:S,modifiedData:G,relationConnect:$,relationDisconnect:X,relationLoad:Q,relationReorder:J}=(0,y.Wq)(),A=g.split("."),k=Ar(S,G)(g),R=Z()(G,g,[]),F=Math.ceil(Z()(S,g,[]).length/Yn),{relations:U,search:Y,searchFor:L}=vc([T,k.join("."),G.id,C],{relation:{enabled:!!b.relation,endpoint:b.relation,pageGoal:F,pageParams:{...C,pageSize:Yn},onLoad(fe){Q({target:{initialDataPath:["initialData",...k],modifiedDataPath:["modifiedData",...A],value:fe}})},normalizeArguments:{mainFieldName:h.name,shouldAddLink:I,targetModel:D}},search:{endpoint:b.search,pageParams:{...C,entityId:d||m?void 0:a?r:o,pageSize:gc}}}),B=(0,e.useMemo)(()=>x.toLowerCase().includes("morph"),[x]),ne=["oneWay","oneToOne","manyToOne","oneToManyMorph","oneToOneMorph"].includes(x),ce=(0,e.useMemo)(()=>B?!0:d?!s:!u&&p||!s,[B,d,s,u,p]),ge=fe=>{const Me=Xn(fe,{mainFieldName:h.name,shouldAddLink:I,targetModel:D});$({name:g,value:Me,toOneRelation:ne})},V=fe=>{X({name:g,id:fe.id})},z=()=>{U.fetchNextPage()},ye=(fe="")=>{const[Me,et]=pc(R,Z()(S,g));L(fe,{idsToInclude:et,idsToOmit:Me})},he=()=>{Y.fetchNextPage()},Ne=fe=>`${fe+1} of ${R.length}`,Ue=(fe,Me)=>{const et=R[fe];N(w({id:(0,f.OB)("dnd.reorder"),defaultMessage:"{item}, moved. New position in list: {position}."},{item:et.mainField??et.id,position:Ne(Me)})),J({name:g,newIndex:Me,oldIndex:fe})},de=fe=>{const Me=R[fe];N(w({id:(0,f.OB)("dnd.grab-item"),defaultMessage:"{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel."},{item:Me.mainField??Me.id,position:Ne(fe)}))},Ie=fe=>{const Me=R[fe];N(w({id:(0,f.OB)("dnd.drop-item"),defaultMessage:"{item}, dropped. Final position in list: {position}."},{item:Me.mainField??Me.id,position:Ne(fe)}))},je=fe=>{const Me=R[fe];N(w({id:(0,f.OB)("dnd.cancel-item"),defaultMessage:"{item}, dropped. Re-order cancelled."},{item:Me.mainField??Me.id}))};if(!u&&d||!d&&!u&&!p)return e.createElement(y.X0,{name:g,intlLabel:i,labelAction:E});const Pe=R.length,He=(Z()(S,k)??[]).length,Rt=U.data?.pages[0]?.pagination?.total??0,it=!U.data&&Pe===He?Pe:Pe-He+Rt;return e.createElement(xc,{error:t,canReorder:!ne,description:c,disabled:ce,iconButtonAriaLabel:w({id:(0,f.OB)("components.RelationInput.icon-button-aria-label"),defaultMessage:"Drag"}),id:g,label:`${w({id:i.id,defaultMessage:i.defaultMessage})} ${it>0?`(${it})`:""}`,labelAction:E,labelLoadMore:!d||m?w({id:(0,f.OB)("relation.loadMore"),defaultMessage:"Load More"}):null,labelDisconnectRelation:w({id:(0,f.OB)("relation.disconnect"),defaultMessage:"Remove"}),listAriaDescription:w({id:(0,f.OB)("dnd.instructions"),defaultMessage:"Press spacebar to grab and re-order"}),listHeight:320,liveText:O,loadingMessage:w({id:(0,f.OB)("relation.isLoading"),defaultMessage:"Relations are loading"}),name:g,noRelationsMessage:w({id:(0,f.OB)("relation.notAvailable"),defaultMessage:"No relations available"}),numberOfRelationsToDisplay:Yn,onDropItem:Ie,onGrabItem:de,onCancel:je,onRelationConnect:ge,onRelationDisconnect:V,onRelationLoadMore:z,onRelationReorder:Ue,onSearch:fe=>ye(fe),onSearchNextPage:()=>he(),placeholder:w(v||{id:(0,f.OB)("relation.add"),defaultMessage:"Add relation"}),publicationStateTranslations:{[at.DRAFT]:w({id:(0,f.OB)("relation.publicationState.draft"),defaultMessage:"Draft"}),[at.PUBLISHED]:w({id:(0,f.OB)("relation.publicationState.published"),defaultMessage:"Published"})},relations:ln()({...U,data:R},"data","hasNextPage","isFetchingNextPage","isLoading","isSuccess"),required:M,searchResults:yc(Y,{mainFieldName:h.name}),size:j})};ro.defaultProps={componentId:void 0,entityId:void 0,editable:!0,error:void 0,description:"",labelAction:null,isComponentRelation:!1,isFieldAllowed:!0,placeholder:null,required:!1},ro.propTypes={componentId:n().number,entityId:n().number,editable:n().bool,error:n().string,description:n().string,intlLabel:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}).isRequired,labelAction:n().element,isCloningEntry:n().bool.isRequired,isCreatingEntry:n().bool.isRequired,isComponentRelation:n().bool,isFieldAllowed:n().bool,isFieldReadable:n().bool.isRequired,mainField:n().shape({name:n().string.isRequired,schema:n().shape({type:n().string.isRequired}).isRequired}).isRequired,name:n().string.isRequired,placeholder:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}),required:n().bool,relationType:n().string.isRequired,size:n().number.isRequired,targetModel:n().string.isRequired,queryInfos:n().shape({defaultParams:n().shape({locale:n().string}),endpoints:n().shape({relation:n().string,search:n().string.isRequired}).isRequired,shouldDisplayRelationLink:n().bool.isRequired}).isRequired};const Zc=(0,e.memo)(ro);var Lc=mc(Zc,bc);const ao=({id:t,error:o,name:r,hint:a})=>a.length===0||o?null:e.createElement(W.Z,{as:"p",variant:"pi",id:`${t||r}-hint`,textColor:"neutral600"},a);ao.defaultProps={id:void 0,error:void 0,hint:""},ao.propTypes={hint:n().oneOfType([n().string,n().array]),error:n().string,id:n().string,name:n().string.isRequired};var Sc=ao,kc=l(87702),so=l.n(kc),io=l(59845),Fc=l(88591),Ac=l.n(Fc),wc=l(20871),$c=l.n(wc),Bc=l(48375),Ur=l.n(Bc),Nc=l(31089),jc=l.n(Nc),Wc=l(16043),zc=l.n(Wc),Uc=l(5109),Vc=l.n(Uc),qc=l(47955),Hc=l.n(qc),Gc=l(95706),Qc=l.n(Gc),Kc=l(6658),Yc=l.n(Kc),Xc=l(36407),Jc=l.n(Xc);(async()=>{await l.e(7347).then(l.bind(l,74194))})();const Et=new(Ac())({html:!0,xhtmlOut:!1,breaks:!0,langPrefix:"language-",linkify:!0,typographer:!0,highlight(t,o){if(o&&o!=="auto"&&(0,io.getLanguage)(o))return'<pre class="hljs language-'+Et.utils.escapeHtml(o.toLowerCase())+'"><code>'+(0,io.highlight)(o,t,!0).value+"</code></pre>";if(o==="auto"){const r=(0,io.highlightAuto)(t);return'<pre class="hljs language-'+Et.utils.escapeHtml(r.language)+'"><code>'+r.value+"</code></pre>"}return'<pre class="hljs"><code>'+Et.utils.escapeHtml(t)+"</code></pre>"}}).use($c()).use(Ur(),"warning").use(Ur(),"tip").use(jc()).use(zc()).use(Vc()).use(Hc()).use(Qc()).use(Yc()).use(Jc());Et.renderer.rules.footnote_ref=(t,o,r,a,s)=>'<sup class="footnote-ref"><span>'+s.rules.footnote_caption(t,o,r,a,s)+"</span></sup>",Et.renderer.rules.footnote_anchor=()=>' <span class="footnote-backref">\u21A9\uFE0E</span>';var _c=Et,ed=l(13993),Vr=l.n(ed);const td={...Vr().defaults,allowedTags:!1,allowedAttributes:{"*":["href","align","alt","center","width","height","type","controls","target"],img:["src","alt"],source:["src","type"]}};var nd=t=>Vr()(t,td),od=q.ZP.div`
|
|
255
|
+
position: absolute;
|
|
256
|
+
top: 0;
|
|
257
|
+
width: 100%;
|
|
258
|
+
height: 100%;
|
|
259
|
+
overflow: auto;
|
|
260
|
+
padding: ${({theme:t})=>`${t.spaces[3]} ${t.spaces[4]}`};
|
|
261
|
+
font-size: ${14/16}rem;
|
|
262
|
+
background-color: ${({theme:t})=>t.colors.neutral0};
|
|
263
|
+
color: ${({theme:t})=>t.colors.neutral800};
|
|
264
|
+
line-height: ${({theme:t})=>t.lineHeights[6]};
|
|
265
|
+
|
|
266
|
+
h1,
|
|
267
|
+
h2,
|
|
268
|
+
h3,
|
|
269
|
+
h4,
|
|
270
|
+
h5,
|
|
271
|
+
h6 {
|
|
272
|
+
margin-block-start: ${({theme:t})=>t.spaces[2]};
|
|
273
|
+
margin-block-end: ${({theme:t})=>t.spaces[2]};
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
p {
|
|
277
|
+
margin-bottom: ${({theme:t})=>t.spaces[2]};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
h1 {
|
|
281
|
+
font-size: ${36/16}rem;
|
|
282
|
+
font-weight: 600;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
h2 {
|
|
286
|
+
font-size: ${30/16}rem;
|
|
287
|
+
font-weight: 500;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
h3 {
|
|
291
|
+
font-size: ${24/16}rem;
|
|
292
|
+
font-weight: 500;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
h4 {
|
|
296
|
+
font-size: ${20/16}rem;
|
|
297
|
+
font-weight: 500;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
strong {
|
|
301
|
+
font-weight: 800;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
em {
|
|
305
|
+
font-style: italic;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
blockquote {
|
|
309
|
+
margin-top: ${({theme:t})=>t.spaces[8]};
|
|
310
|
+
margin-bottom: ${({theme:t})=>t.spaces[7]};
|
|
311
|
+
font-size: ${14/16}rem;
|
|
312
|
+
font-weight: 400;
|
|
313
|
+
border-left: 4px solid ${({theme:t})=>t.colors.neutral150};
|
|
314
|
+
font-style: italic;
|
|
315
|
+
padding: ${({theme:t})=>t.spaces[2]} ${({theme:t})=>t.spaces[5]};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
img {
|
|
319
|
+
max-width: 100%;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
table {
|
|
323
|
+
thead {
|
|
324
|
+
background: ${({theme:t})=>t.colors.neutral150};
|
|
325
|
+
|
|
326
|
+
th {
|
|
327
|
+
padding: ${({theme:t})=>t.spaces[4]};
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
tr {
|
|
331
|
+
border: 1px solid ${({theme:t})=>t.colors.neutral200};
|
|
332
|
+
}
|
|
333
|
+
th,
|
|
334
|
+
td {
|
|
335
|
+
padding: ${({theme:t})=>t.spaces[4]};
|
|
336
|
+
border: 1px solid ${({theme:t})=>t.colors.neutral200};
|
|
337
|
+
border-bottom: 0;
|
|
338
|
+
border-top: 0;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
pre,
|
|
343
|
+
code {
|
|
344
|
+
font-size: ${14/16}rem;
|
|
345
|
+
border-radius: 4px;
|
|
346
|
+
/*
|
|
347
|
+
Hard coded since the color is the same between themes,
|
|
348
|
+
theme.colors.neutral800 changes between themes.
|
|
349
|
+
|
|
350
|
+
Matches the color of the JSON Input component.
|
|
351
|
+
*/
|
|
352
|
+
background-color: #32324d;
|
|
353
|
+
max-width: 100%;
|
|
354
|
+
overflow: auto;
|
|
355
|
+
padding: ${({theme:t})=>t.spaces[2]};
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/* Inline code */
|
|
359
|
+
p,
|
|
360
|
+
pre,
|
|
361
|
+
td {
|
|
362
|
+
> code {
|
|
363
|
+
color: #839496;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
ol {
|
|
368
|
+
list-style-type: decimal;
|
|
369
|
+
margin-block-start: ${({theme:t})=>t.spaces[4]};
|
|
370
|
+
margin-block-end: ${({theme:t})=>t.spaces[4]};
|
|
371
|
+
margin-inline-start: 0px;
|
|
372
|
+
margin-inline-end: 0px;
|
|
373
|
+
padding-inline-start: ${({theme:t})=>t.spaces[4]};
|
|
374
|
+
|
|
375
|
+
ol,
|
|
376
|
+
ul {
|
|
377
|
+
margin-block-start: 0px;
|
|
378
|
+
margin-block-end: 0px;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
ul {
|
|
383
|
+
list-style-type: disc;
|
|
384
|
+
margin-block-start: ${({theme:t})=>t.spaces[4]};
|
|
385
|
+
margin-block-end: ${({theme:t})=>t.spaces[4]};
|
|
386
|
+
margin-inline-start: 0px;
|
|
387
|
+
margin-inline-end: 0px;
|
|
388
|
+
padding-inline-start: ${({theme:t})=>t.spaces[4]};
|
|
389
|
+
|
|
390
|
+
ul,
|
|
391
|
+
ol {
|
|
392
|
+
margin-block-start: 0px;
|
|
393
|
+
margin-block-end: 0px;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
`;const lo=({data:t})=>{const o=(0,e.useMemo)(()=>nd(_c.render(t.replaceAll("\\n",`
|
|
397
|
+
`)||"")),[t]);return e.createElement(od,null,e.createElement("div",{dangerouslySetInnerHTML:{__html:o}}))};lo.defaultProps={data:""},lo.propTypes={data:n().string};var qr=(0,e.memo)(lo);const rd=q.ZP.div`
|
|
398
|
+
cursor: ${({disabled:t})=>t?"not-allowed !important":"auto"};
|
|
399
|
+
height: 100%;
|
|
400
|
+
/* BASICS */
|
|
401
|
+
.CodeMirror-placeholder {
|
|
402
|
+
color: ${({theme:t})=>t.colors.neutral600} !important;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
.CodeMirror {
|
|
406
|
+
/* Set height, width, borders, and global font properties here */
|
|
407
|
+
font-size: ${14/16}rem;
|
|
408
|
+
height: ${({isExpandMode:t})=>t?"100%":"290px"};
|
|
409
|
+
color: ${({theme:t})=>t.colors.neutral800};
|
|
410
|
+
direction: ltr;
|
|
411
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
|
|
412
|
+
'Open Sans', 'Helvetica Neue', sans-serif;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/* PADDING */
|
|
416
|
+
|
|
417
|
+
.CodeMirror-lines {
|
|
418
|
+
padding: ${({theme:t})=>`${t.spaces[3]} ${t.spaces[4]}`};
|
|
419
|
+
/* Vertical padding around content */
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
.CodeMirror-scrollbar-filler,
|
|
423
|
+
.CodeMirror-gutter-filler {
|
|
424
|
+
/* The little square between H and V scrollbars */
|
|
425
|
+
background-color: ${({theme:t})=>`${t.colors.neutral0}`};
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/* GUTTER */
|
|
429
|
+
|
|
430
|
+
.CodeMirror-gutters {
|
|
431
|
+
border-right: 1px solid #ddd;
|
|
432
|
+
background-color: #f7f7f7;
|
|
433
|
+
white-space: nowrap;
|
|
434
|
+
}
|
|
435
|
+
.CodeMirror-linenumbers {
|
|
436
|
+
}
|
|
437
|
+
.CodeMirror-linenumber {
|
|
438
|
+
padding: 0 3px 0 5px;
|
|
439
|
+
min-width: 20px;
|
|
440
|
+
text-align: right;
|
|
441
|
+
color: #999;
|
|
442
|
+
white-space: nowrap;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
.CodeMirror-guttermarker {
|
|
446
|
+
color: black;
|
|
447
|
+
}
|
|
448
|
+
.CodeMirror-guttermarker-subtle {
|
|
449
|
+
color: #999;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/* CURSOR */
|
|
453
|
+
|
|
454
|
+
.CodeMirror-cursor {
|
|
455
|
+
border-left: 1px solid black;
|
|
456
|
+
border-right: none;
|
|
457
|
+
width: 0;
|
|
458
|
+
}
|
|
459
|
+
/* Shown when moving in bi-directional text */
|
|
460
|
+
.CodeMirror div.CodeMirror-secondarycursor {
|
|
461
|
+
border-left: 1px solid silver;
|
|
462
|
+
}
|
|
463
|
+
.cm-fat-cursor .CodeMirror-cursor {
|
|
464
|
+
width: auto;
|
|
465
|
+
border: 0 !important;
|
|
466
|
+
background: #7e7;
|
|
467
|
+
}
|
|
468
|
+
.cm-fat-cursor div.CodeMirror-cursors {
|
|
469
|
+
/* z-index: 1; */
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.cm-fat-cursor-mark {
|
|
473
|
+
background-color: rgba(20, 255, 20, 0.5);
|
|
474
|
+
-webkit-animation: blink 1.06s steps(1) infinite;
|
|
475
|
+
-moz-animation: blink 1.06s steps(1) infinite;
|
|
476
|
+
animation: blink 1.06s steps(1) infinite;
|
|
477
|
+
}
|
|
478
|
+
.cm-animate-fat-cursor {
|
|
479
|
+
width: auto;
|
|
480
|
+
border: 0;
|
|
481
|
+
-webkit-animation: blink 1.06s steps(1) infinite;
|
|
482
|
+
-moz-animation: blink 1.06s steps(1) infinite;
|
|
483
|
+
animation: blink 1.06s steps(1) infinite;
|
|
484
|
+
background-color: #7e7;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/* Can style cursor different in overwrite (non-insert) mode */
|
|
488
|
+
.CodeMirror-overwrite .CodeMirror-cursor {
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
.cm-tab {
|
|
492
|
+
display: inline-block;
|
|
493
|
+
text-decoration: inherit;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
.CodeMirror-rulers {
|
|
497
|
+
position: absolute;
|
|
498
|
+
left: 0;
|
|
499
|
+
right: 0;
|
|
500
|
+
top: -50px;
|
|
501
|
+
bottom: 0;
|
|
502
|
+
overflow: hidden;
|
|
503
|
+
}
|
|
504
|
+
.CodeMirror-ruler {
|
|
505
|
+
border-left: 1px solid #ccc;
|
|
506
|
+
top: 0;
|
|
507
|
+
bottom: 0;
|
|
508
|
+
position: absolute;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/* DEFAULT THEME */
|
|
512
|
+
|
|
513
|
+
.cm-header,
|
|
514
|
+
.cm-strong {
|
|
515
|
+
font-weight: bold;
|
|
516
|
+
}
|
|
517
|
+
.cm-em {
|
|
518
|
+
font-style: italic;
|
|
519
|
+
}
|
|
520
|
+
.cm-link {
|
|
521
|
+
text-decoration: underline;
|
|
522
|
+
}
|
|
523
|
+
.cm-strikethrough {
|
|
524
|
+
text-decoration: line-through;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
.CodeMirror-composing {
|
|
528
|
+
border-bottom: 2px solid;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/* Default styles for common addons */
|
|
532
|
+
|
|
533
|
+
div.CodeMirror span.CodeMirror-matchingbracket {
|
|
534
|
+
color: #0b0;
|
|
535
|
+
}
|
|
536
|
+
div.CodeMirror span.CodeMirror-nonmatchingbracket {
|
|
537
|
+
color: #a22;
|
|
538
|
+
}
|
|
539
|
+
.CodeMirror-matchingtag {
|
|
540
|
+
background: rgba(255, 150, 0, 0.3);
|
|
541
|
+
}
|
|
542
|
+
.CodeMirror-activeline-background {
|
|
543
|
+
background: #e8f2ff;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/* STOP */
|
|
547
|
+
|
|
548
|
+
/* The rest of this file contains styles related to the mechanics of
|
|
549
|
+
the editor. You probably shouldn't touch them. */
|
|
550
|
+
|
|
551
|
+
.CodeMirror {
|
|
552
|
+
position: relative;
|
|
553
|
+
overflow: hidden;
|
|
554
|
+
background: ${({theme:t})=>`${t.colors.neutral0}`};
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.CodeMirror-scroll {
|
|
558
|
+
overflow: scroll !important; /* Things will break if this is overridden */
|
|
559
|
+
/* 50px is the magic margin used to hide the element's real scrollbars */
|
|
560
|
+
/* See overflow: hidden in .CodeMirror */
|
|
561
|
+
margin-bottom: -50px;
|
|
562
|
+
margin-right: -50px;
|
|
563
|
+
padding-bottom: 50px;
|
|
564
|
+
height: 100%;
|
|
565
|
+
outline: none; /* Prevent dragging from highlighting the element */
|
|
566
|
+
position: relative;
|
|
567
|
+
}
|
|
568
|
+
.CodeMirror-sizer {
|
|
569
|
+
position: relative;
|
|
570
|
+
border-right: 50px solid transparent;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
|
574
|
+
before actual scrolling happens, thus preventing shaking and
|
|
575
|
+
flickering artifacts. */
|
|
576
|
+
.CodeMirror-vscrollbar,
|
|
577
|
+
.CodeMirror-hscrollbar,
|
|
578
|
+
.CodeMirror-scrollbar-filler,
|
|
579
|
+
.CodeMirror-gutter-filler {
|
|
580
|
+
position: absolute;
|
|
581
|
+
z-index: 1;
|
|
582
|
+
display: none;
|
|
583
|
+
outline: none;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
.CodeMirror-vscrollbar {
|
|
587
|
+
right: 0;
|
|
588
|
+
top: 0;
|
|
589
|
+
overflow-x: hidden;
|
|
590
|
+
overflow-y: scroll;
|
|
591
|
+
}
|
|
592
|
+
.CodeMirror-hscrollbar {
|
|
593
|
+
bottom: 0;
|
|
594
|
+
left: 0;
|
|
595
|
+
overflow-y: hidden;
|
|
596
|
+
overflow-x: scroll;
|
|
597
|
+
}
|
|
598
|
+
.CodeMirror-scrollbar-filler {
|
|
599
|
+
right: 0;
|
|
600
|
+
bottom: 0;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
.CodeMirror-lines {
|
|
604
|
+
cursor: text;
|
|
605
|
+
min-height: 1px; /* prevents collapsing before first draw */
|
|
606
|
+
}
|
|
607
|
+
/* Reset some styles that the rest of the page might have set */
|
|
608
|
+
.CodeMirror pre.CodeMirror-line,
|
|
609
|
+
.CodeMirror pre.CodeMirror-line-like {
|
|
610
|
+
-moz-border-radius: 0;
|
|
611
|
+
-webkit-border-radius: 0;
|
|
612
|
+
border-radius: 0;
|
|
613
|
+
border-width: 0;
|
|
614
|
+
background: transparent;
|
|
615
|
+
font-family: inherit;
|
|
616
|
+
font-size: inherit;
|
|
617
|
+
margin: 0;
|
|
618
|
+
white-space: pre;
|
|
619
|
+
word-wrap: normal;
|
|
620
|
+
line-height: 1.5;
|
|
621
|
+
color: inherit;
|
|
622
|
+
/* z-index: 2; */
|
|
623
|
+
position: relative;
|
|
624
|
+
overflow: visible;
|
|
625
|
+
-webkit-tap-highlight-color: transparent;
|
|
626
|
+
-webkit-font-variant-ligatures: contextual;
|
|
627
|
+
font-variant-ligatures: contextual;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
.CodeMirror pre.CodeMirror-line-like {
|
|
631
|
+
z-index: 2;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
.CodeMirror-wrap pre.CodeMirror-line,
|
|
635
|
+
.CodeMirror-wrap pre.CodeMirror-line-like {
|
|
636
|
+
word-wrap: break-word;
|
|
637
|
+
white-space: pre-wrap;
|
|
638
|
+
word-break: normal;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
.CodeMirror-linebackground {
|
|
642
|
+
position: absolute;
|
|
643
|
+
left: 0;
|
|
644
|
+
right: 0;
|
|
645
|
+
top: 0;
|
|
646
|
+
bottom: 0;
|
|
647
|
+
z-index: 0;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
.CodeMirror-linewidget {
|
|
651
|
+
position: relative;
|
|
652
|
+
/* z-index: 2; */
|
|
653
|
+
padding: 0.1px; /* Force widget margins to stay inside of the container */
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
.CodeMirror-widget {
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
.CodeMirror-rtl pre {
|
|
660
|
+
direction: rtl;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
.CodeMirror-code {
|
|
664
|
+
outline: none;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/* Force content-box sizing for the elements where we expect it */
|
|
668
|
+
.CodeMirror-scroll,
|
|
669
|
+
.CodeMirror-sizer,
|
|
670
|
+
.CodeMirror-gutter,
|
|
671
|
+
.CodeMirror-gutters,
|
|
672
|
+
.CodeMirror-linenumber {
|
|
673
|
+
-moz-box-sizing: content-box;
|
|
674
|
+
box-sizing: content-box;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
.CodeMirror-measure {
|
|
678
|
+
position: absolute;
|
|
679
|
+
width: 100%;
|
|
680
|
+
height: 0;
|
|
681
|
+
overflow: hidden;
|
|
682
|
+
visibility: hidden;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
.CodeMirror-cursor {
|
|
686
|
+
position: absolute;
|
|
687
|
+
pointer-events: none;
|
|
688
|
+
border-color: ${({theme:t})=>`${t.colors.neutral800}`};
|
|
689
|
+
}
|
|
690
|
+
.CodeMirror-measure pre {
|
|
691
|
+
position: static;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
div.CodeMirror-cursors {
|
|
695
|
+
visibility: hidden;
|
|
696
|
+
position: relative;
|
|
697
|
+
+ div {
|
|
698
|
+
z-index: 0 !important;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
div.CodeMirror-dragcursors {
|
|
703
|
+
visibility: visible;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
.CodeMirror-focused div.CodeMirror-cursors {
|
|
707
|
+
visibility: visible;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
.CodeMirror-selected {
|
|
711
|
+
background: ${({theme:t})=>t.colors.neutral200};
|
|
712
|
+
/* z-index: -10; */
|
|
713
|
+
}
|
|
714
|
+
.CodeMirror-crosshair {
|
|
715
|
+
cursor: crosshair;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/* Used to force a border model for a node */
|
|
719
|
+
.cm-force-border {
|
|
720
|
+
padding-right: 0.1px;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/* See issue #2901 */
|
|
724
|
+
.cm-tab-wrap-hack:after {
|
|
725
|
+
content: '';
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/* Help users use markselection to safely style text background */
|
|
729
|
+
span.CodeMirror-selectedtext {
|
|
730
|
+
background: none;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
span {
|
|
734
|
+
color: ${({theme:t})=>t.colors.neutral800} !important;
|
|
735
|
+
}
|
|
736
|
+
`;var Kt=/^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/,ad=/^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/,sd=/[*+-]\s/;function id(t){if(t.getOption("disableInput"))return so().Pass;for(var o=t.listSelections(),r=[],a=0;a<o.length;a++){var s=o[a].head,c=t.getStateAfter(s.line),i=c.list!==!1,d=c.quote!==0,m=t.getLine(s.line),u=Kt.exec(m),p=/^\s*$/.test(m.slice(0,s.ch));if(!o[a].empty()||!i&&!d||!u||p){t.execCommand("newlineAndIndent");return}if(ad.test(m)){var E=d&&/>\s*$/.test(m),h=!/>\s*$/.test(m);(E||h)&&t.replaceRange("",{line:s.line,ch:0},{line:s.line,ch:s.ch+1}),r[a]=`
|
|
737
|
+
`}else{var g=u[1],b=u[5],C=!(sd.test(u[2])||u[2].indexOf(">")>=0),I=C?parseInt(u[3],10)+1+u[4]:u[2].replace("x"," ");r[a]=`
|
|
738
|
+
`+g+I+b,C&&ld(t,s)}}t.replaceSelections(r)}function ld(t,o){var r=o.line,a=0,s=0,c=Kt.exec(t.getLine(r)),i=c[1];do{a+=1;var d=r+a,m=t.getLine(d),u=Kt.exec(m);if(u){var p=u[1],E=parseInt(c[3],10)+a-s,h=parseInt(u[3],10),g=h;if(i===p&&!isNaN(h))E===h&&(g=h+1),E>h&&(g=E+1),t.replaceRange(m.replace(Kt,p+g+u[4]+u[5]),{line:d,ch:0},{line:d,ch:m.length});else{if(i.length>p.length||i.length<p.length&&a===1)return;s+=1}}}while(u)}var cd=id;const Ze=(0,q.ZP)(Re.h)`
|
|
739
|
+
padding: ${({theme:t})=>t.spaces[2]};
|
|
740
|
+
/* Trick to prevent the outline from overflowing because of the general outline-offset */
|
|
741
|
+
outline-offset: -2px !important;
|
|
742
|
+
|
|
743
|
+
svg {
|
|
744
|
+
width: ${18/16}rem;
|
|
745
|
+
height: ${18/16}rem;
|
|
746
|
+
}
|
|
747
|
+
`,dd=(0,q.ZP)(Ze)`
|
|
748
|
+
svg {
|
|
749
|
+
width: ${8/16}rem;
|
|
750
|
+
height: ${8/16}rem;
|
|
751
|
+
}
|
|
752
|
+
`,Hr=(0,q.ZP)(Re.o)`
|
|
753
|
+
margin-left: ${({theme:t})=>t.spaces[4]};
|
|
754
|
+
`,Gr=(0,q.ZP)(Re.h)`
|
|
755
|
+
margin: ${({theme:t})=>`0 ${t.spaces[2]}`};
|
|
756
|
+
padding: ${({theme:t})=>t.spaces[2]};
|
|
757
|
+
|
|
758
|
+
svg {
|
|
759
|
+
width: ${18/16}rem;
|
|
760
|
+
height: ${18/16}rem;
|
|
761
|
+
}
|
|
762
|
+
`,ud=(0,q.ZP)(Re.o)`
|
|
763
|
+
margin-right: ${({theme:t})=>`${t.spaces[2]}`};
|
|
764
|
+
`,md=q.ZP.div`
|
|
765
|
+
position: relative;
|
|
766
|
+
height: calc(100% - 48px);
|
|
767
|
+
`,pd=(0,q.ZP)($n.Y)`
|
|
768
|
+
background-color: transparent;
|
|
769
|
+
border: none;
|
|
770
|
+
align-items: center;
|
|
771
|
+
|
|
772
|
+
svg {
|
|
773
|
+
margin-left: ${({theme:t})=>`${t.spaces[2]}`};
|
|
774
|
+
path {
|
|
775
|
+
fill: ${({theme:t})=>t.colors.neutral700};
|
|
776
|
+
width: ${12/16}rem;
|
|
777
|
+
height: ${12/16}rem;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
`;var Eg=l(27217);const co=({disabled:t,editorRef:o,error:r,isPreviewMode:a,isExpandMode:s,name:c,onChange:i,placeholder:d,textareaRef:m,value:u})=>{const p=(0,e.useRef)(i);return(0,e.useEffect)(()=>{o.current=so().fromTextArea(m.current,{lineWrapping:!0,extraKeys:{Enter:"newlineAndIndentContinueMarkdownList",Tab:!1,"Shift-Tab":!1},readOnly:!1,smartIndent:!1,placeholder:d,spellcheck:!0,inputStyle:"contenteditable"}),so().commands.newlineAndIndentContinueMarkdownList=cd,o.current.on("change",E=>{p.current({target:{name:c,value:E.getValue(),type:"wysiwyg"}})})},[o,m,c,d]),(0,e.useEffect)(()=>{u&&!o.current.hasFocus()&&o.current.setValue(u)},[o,u]),(0,e.useEffect)(()=>{a||t?o.current.setOption("readOnly","nocursor"):o.current.setOption("readOnly",!1)},[t,a,o]),(0,e.useEffect)(()=>{r?o.current.setOption("screenReaderLabel",r):o.current.setOption("screenReaderLabel","Editor")},[o,r]),e.createElement(md,null,e.createElement(rd,{isExpandMode:s,disabled:t||a},e.createElement("textarea",{ref:m})),a&&e.createElement(qr,{data:u}))};co.defaultProps={disabled:!1,error:void 0,isPreviewMode:!1,isExpandMode:!1,placeholder:"",value:""},co.propTypes={disabled:n().bool,editorRef:n().shape({current:n().any}).isRequired,error:n().string,isPreviewMode:n().bool,isExpandMode:n().bool,name:n().string.isRequired,onChange:n().func.isRequired,placeholder:n().string,textareaRef:n().shape({current:n().any}).isRequired,value:n().string};var gd=co,fd=l(71933),hd=l(67563);const yd=(t,o)=>`${t}${Math.floor(o*255).toString(16).padStart(2,0)}`,Ed=(0,q.ZP)(P.k)`
|
|
781
|
+
background: ${({theme:t})=>yd(t.colors.neutral800,.2)};
|
|
782
|
+
`,bd=(0,q.ZP)(H.x)`
|
|
783
|
+
border-right: 1px solid ${({theme:t})=>t.colors.neutral200};
|
|
784
|
+
`,vd=(0,q.ZP)($n.Y)`
|
|
785
|
+
background-color: transparent;
|
|
786
|
+
border: none;
|
|
787
|
+
align-items: center;
|
|
788
|
+
|
|
789
|
+
svg {
|
|
790
|
+
margin-left: ${({theme:t})=>`${t.spaces[2]}`};
|
|
791
|
+
|
|
792
|
+
path {
|
|
793
|
+
fill: ${({theme:t})=>t.colors.neutral700};
|
|
794
|
+
width: ${12/16}rem;
|
|
795
|
+
height: ${12/16}rem;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
`,uo=({children:t,isExpandMode:o,error:r,previewContent:a,onCollapse:s})=>{const{formatMessage:c}=(0,K.Z)();return(0,y.F5)(o),o?e.createElement(fd.h,{role:"dialog","aria-modal":!1},e.createElement(hd.i,{onEscape:s},e.createElement(Ed,{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:4,justifyContent:"center",onClick:s},e.createElement(H.x,{background:"neutral0",hasRadius:!0,shadow:"popupShadow",overflow:"hidden",width:"70%",height:"70%",onClick:i=>i.stopPropagation()},e.createElement(P.k,{height:"100%",alignItems:"flex-start"},e.createElement(bd,{flex:"1",height:"100%"},t),e.createElement(P.k,{alignItems:"start",direction:"column",flex:1,height:"100%",width:"100%"},e.createElement(P.k,{height:(0,y.Q1)(48),background:"neutral100",justifyContent:"flex-end",shrink:0,width:"100%"},e.createElement(vd,{onClick:s},e.createElement(W.Z,null,c({id:"components.Wysiwyg.collapse",defaultMessage:"Collapse"})),e.createElement(rr.Z,null))),e.createElement(H.x,{position:"relative",height:"100%",width:"100%"},e.createElement(qr,{data:a})))))))):e.createElement(H.x,{borderColor:r?"danger600":"neutral200",borderStyle:"solid",borderWidth:"1px",hasRadius:!0},t)};uo.defaultProps={error:void 0,previewContent:""},uo.propTypes={children:n().node.isRequired,error:n().string,isExpandMode:n().bool.isRequired,previewContent:n().string,onCollapse:n().func.isRequired};const Qr=(t,o)=>{let r;switch(t){case"Strikethrough":r=`~~${o}~~`;break;case"Bold":r=`**${o}**`;break;case"Italic":r=`_${o}_`;break;case"Underline":r=`<u>${o}</u>`;break;case"Code":r=`\`\`\`
|
|
799
|
+
${o}
|
|
800
|
+
\`\`\``;break;case"Link":r=`[${o}](link)`;break;case"Quote":r=`>${o}`;break;default:r=o}return r},Kr=t=>{let o,r={start:t.length,end:0};switch(t){case"Strikethrough":o=`~~${t}~~`,r.end=2;break;case"Bold":o=`**${t}**`,r.end=2;break;case"Italic":o=`_${t}_`,r.end=1;break;case"alt":o=`[${t}]()`,r.end=3;break;case"Underline":o=`<u>${t}</u>`,r.end=4;break;case"Code":o=`\`\`\`
|
|
801
|
+
${t}
|
|
802
|
+
\`\`\``,r.end=3;break;case"Link":o=`[${t}](link)`,r.end=7;break;case"Quote":o=`>${t}`,r.end=0;break;default:o=""}return{editedText:o,selection:r}},Yr=t=>{let o;switch(t){case"BulletList":o="- ";break;case"NumberList":o="1. ";break;case"h1":o="# ";break;case"h2":o="## ";break;case"h3":o="### ";break;case"h4":o="#### ";break;case"h5":o="##### ";break;case"h6":o="###### ";break;default:return""}return o},Xr=(t,o)=>{const r=t.current.getSelection();let a;if(r){const s=Qr(o,r);t.current.replaceSelection(s),t.current.focus()}else{a=Kr(o),t.current.replaceSelection(a.editedText),t.current.focus();const{line:s,ch:c}=t.current.getCursor(),i=c-a.selection.end,d=c-a.selection.end-a.selection.start;t.current.setSelection({line:s,ch:d},{line:s,ch:i})}},Cd=(t,o)=>{const r=t.current.getDoc(),a=o==="BulletList"?"- ":"1. ";if(r.somethingSelected()){const s=r.listSelections();let c=null;t.current.operation(function(){s.forEach(function(i){const d=[i.head.line,i.anchor.line].sort();c==null&&(c=r.getLine(d[0]).startsWith(a));for(let m=d[0];m<=d[1];m++)if(c)r.getLine(m).startsWith(a)&&r.replaceRange("",{line:m,ch:0},{line:m,ch:a.length});else{const u=o==="BulletList"?"- ":`${m+1}. `;r.replaceRange(u,{line:m,ch:0})}})})}else{let{line:s}=r.getCursor();const c=Yr(o),i=t.current.getLine(s),d=c+i;t.current.setSelection({line:s,ch:0},{line:s,ch:i.length}),t.current.replaceSelection(d)}t.current.focus()},Rd=(t,o)=>{let{line:r}=t.current.getCursor();const a=Yr(o),s=t.current.getLine(r),c=s.replace(/#{1,6}\s/g,"").trim(),i=a+c;t.current.setSelection({line:r,ch:0},{line:r,ch:s.length}),t.current.replaceSelection(i),setTimeout(()=>{const d=t.current.getLine(r).length;t.current.focus(),t.current.setCursor({line:r,ch:d})},0)},Md=(t,o)=>{let{line:r,ch:a}=t.current.getCursor();o.forEach((s,c)=>{let i=t.current.getLine(r).length;t.current.setCursor({line:r,ch:i}),(c>0||c===0&&a!==0)&&(i=t.current.getLine(r).length,t.current.setCursor({line:r,ch:i}),r++,t.current.replaceSelection(`
|
|
803
|
+
`)),s.mime.includes("image")?t.current.replaceSelection(``):t.current.replaceSelection(`[${s.alt}](${s.url})`)}),setTimeout(()=>t.current.focus(),0)},Td=(t,o,r,a,s)=>{const c=Qr(o,s),i=t.current.getRange({line:r+1,ch:0},{line:1/0,ch:1/0});if(t.current.replaceRange("",{line:r+1,ch:0},{line:1/0,ch:1/0}),t.current.replaceSelection(""),t.current.setCursor({line:r,ch:a}),t.current.replaceSelection(`
|
|
804
|
+
`),t.current.replaceSelection(c),o==="Code"){let{line:d}=t.current.getCursor();t.current.setCursor({line:d-1,ch:s.length})}t.current.replaceRange(i,{line:r+4,ch:0},{line:1/0,ch:1/0}),t.current.focus()},Dd=(t,o,r,a)=>{const s=Kr(o),c=t.current.getRange({line:r+1,ch:0},{line:1/0,ch:1/0});if(t.current.replaceRange("",{line:r+1,ch:0},{line:1/0,ch:1/0}),t.current.setCursor({line:r,ch:a}),t.current.replaceSelection(`
|
|
805
|
+
`),t.current.replaceSelection(s.editedText),o==="Code")r+=2,t.current.setSelection({line:r,ch:0},{line:r,ch:4});else{r+=1;let{ch:i}=t.current.getCursor(),d=i-s.selection.end,m=i-s.selection.end-s.selection.start;t.current.setSelection({line:r,ch:m},{line:r,ch:d})}t.current.replaceRange(c,{line:r+2,ch:0},{line:1/0,ch:1/0}),t.current.focus()},Od=(t,o)=>{const r=t.current.getSelection();let{line:a}=t.current.getCursor(),s=t.current.getLine(a).length;r?Td(t,o,a,s,r):Dd(t,o,a,s)},mo=({onToggleExpand:t})=>{const{formatMessage:o}=(0,K.Z)();return e.createElement(H.x,{padding:2,background:"neutral100",hasRadius:!0},e.createElement(P.k,{justifyContent:"flex-end",alignItems:"flex-end"},e.createElement(pd,{id:"expand",onClick:t},e.createElement(W.Z,null,o({id:"components.WysiwygBottomControls.fullscreen",defaultMessage:"Expand"})),e.createElement(ar.Z,null))))};mo.defaultProps={onToggleExpand(){}},mo.propTypes={onToggleExpand:n().func};var Id=mo,Pd=l(5383),xd=l(20063);const po=({disabled:t,editorRef:o,isExpandMode:r,isPreviewMode:a,onActionClick:s,onToggleMediaLib:c,onTogglePreviewMode:i})=>{const[d,m]=(0,e.useState)(!1),{formatMessage:u}=(0,K.Z)(),p=u({id:"components.Wysiwyg.selectOptions.title",defaultMessage:"Add a title"}),E=(0,e.useRef)(),h=()=>{m(g=>!g)};return t||a?e.createElement(P.k,{padding:2,background:"neutral100",justifyContent:"space-between"},e.createElement(Jr,null,e.createElement(Ae.P,{disabled:!0,placeholder:p,size:"S",label:p},e.createElement(Ce.W,{value:"h1"},"h1"),e.createElement(Ce.W,{value:"h2"},"h2"),e.createElement(Ce.W,{value:"h3"},"h3"),e.createElement(Ce.W,{value:"h4"},"h4"),e.createElement(Ce.W,{value:"h5"},"h5"),e.createElement(Ce.W,{value:"h6"},"h6")),e.createElement(Hr,null,e.createElement(Ze,{disabled:!0,id:"Bold",label:"Bold",name:"Bold",icon:e.createElement(un.Z,null)}),e.createElement(Ze,{disabled:!0,id:"Italic",label:"Italic",name:"Italic",icon:e.createElement(mn.Z,null)}),e.createElement(Ze,{disabled:!0,id:"Underline",label:"Underline",name:"Underline",icon:e.createElement(gn.Z,null)})),e.createElement(Gr,{disabled:!0,id:"more",label:"More",icon:e.createElement(qn.Z,null)})),!r&&e.createElement(le.z,{onClick:i,variant:"tertiary",id:"preview"},u({id:"components.Wysiwyg.ToggleMode.markdown-mode",defaultMessage:"Markdown mode"}))):e.createElement(P.k,{padding:2,background:"neutral100",justifyContent:"space-between"},e.createElement(Jr,null,e.createElement(Ae.P,{placeholder:p,label:p,size:"S",onChange:g=>s(g,o)},e.createElement(Ce.W,{value:"h1"},"h1"),e.createElement(Ce.W,{value:"h2"},"h2"),e.createElement(Ce.W,{value:"h3"},"h3"),e.createElement(Ce.W,{value:"h4"},"h4"),e.createElement(Ce.W,{value:"h5"},"h5"),e.createElement(Ce.W,{value:"h6"},"h6")),e.createElement(Hr,null,e.createElement(Ze,{onClick:()=>s("Bold",o),id:"Bold",label:"Bold",name:"Bold",icon:e.createElement(un.Z,null)}),e.createElement(Ze,{onClick:()=>s("Italic",o),id:"Italic",label:"Italic",name:"Italic",icon:e.createElement(mn.Z,null)}),e.createElement(Ze,{onClick:()=>s("Underline",o),id:"Underline",label:"Underline",name:"Underline",icon:e.createElement(gn.Z,null)})),e.createElement(Gr,{ref:E,onClick:h,id:"more",label:"More",icon:e.createElement(qn.Z,null)}),d&&e.createElement(Pd.J2,{onDismiss:h,centered:!0,source:E,spacing:4,id:"popover"},e.createElement(P.k,null,e.createElement(ud,null,e.createElement(Ze,{onClick:()=>s("Strikethrough",o,h),id:"Strikethrough",label:"Strikethrough",name:"Strikethrough",icon:e.createElement(ur.Z,null)}),e.createElement(Ze,{onClick:()=>s("BulletList",o,h),id:"BulletList",label:"BulletList",name:"BulletList",icon:e.createElement(nr.Z,null)}),e.createElement(Ze,{onClick:()=>s("NumberList",o,h),id:"NumberList",label:"NumberList",name:"NumberList",icon:e.createElement(xd.Z,null)})),e.createElement(Re.o,null,e.createElement(Ze,{onClick:()=>s("Code",o,h),id:"Code",label:"Code",name:"Code",icon:e.createElement(or.Z,null)}),e.createElement(Ze,{onClick:()=>{h(),c()},id:"Image",label:"Image",name:"Image",icon:e.createElement(cr.Z,null)}),e.createElement(dd,{onClick:()=>s("Link",o,h),id:"Link",label:"Link",name:"Link",icon:e.createElement(lr.Z,null)}),e.createElement(Ze,{onClick:()=>s("Quote",o,h),id:"Quote",label:"Quote",name:"Quote",icon:e.createElement(dr.Z,null)}))))),i&&e.createElement(le.z,{onClick:i,variant:"tertiary",id:"preview"},u({id:"components.Wysiwyg.ToggleMode.preview-mode",defaultMessage:"Preview mode"})))};po.defaultProps={isPreviewMode:!1,onActionClick(){},onToggleMediaLib(){},onTogglePreviewMode:void 0},po.propTypes={disabled:n().bool.isRequired,editorRef:n().shape({current:n().any}).isRequired,isExpandMode:n().bool.isRequired,isPreviewMode:n().bool,onActionClick:n().func,onToggleMediaLib:n().func,onTogglePreviewMode:n().func};var Zd=po;const Jr=(0,q.ZP)(P.k)`
|
|
806
|
+
/* Hide the label, every input needs a label. */
|
|
807
|
+
label {
|
|
808
|
+
border: 0;
|
|
809
|
+
clip: rect(0 0 0 0);
|
|
810
|
+
height: 1px;
|
|
811
|
+
margin: -1px;
|
|
812
|
+
overflow: hidden;
|
|
813
|
+
padding: 0;
|
|
814
|
+
position: absolute;
|
|
815
|
+
width: 1px;
|
|
816
|
+
}
|
|
817
|
+
`,Ld=(0,q.ZP)(H.x)`
|
|
818
|
+
svg path {
|
|
819
|
+
fill: ${({theme:t})=>t.colors.neutral500};
|
|
820
|
+
}
|
|
821
|
+
`,Sd=(0,q.ZP)(W.Z)`
|
|
822
|
+
line-height: 0;
|
|
823
|
+
`,go=({hint:t,disabled:o,error:r,intlLabel:a,labelAction:s,name:c,onChange:i,placeholder:d,value:m,required:u})=>{const{formatMessage:p}=(0,K.Z)(),E=(0,e.useRef)(null),h=(0,e.useRef)(null),[g,b]=(0,e.useState)(!1),[C,I]=(0,e.useState)(!1),[v,M]=(0,e.useState)(!1),{components:x}=(0,y.yX)(),j=x["media-library"],D=()=>I($=>!$),O=()=>b($=>!$),N=()=>{b(!1),M($=>!$)},w=($,X,Q)=>{switch($){case"Link":case"Strikethrough":{Xr(X,$),Q();break}case"Code":case"Quote":{Od(X,$),Q();break}case"Bold":case"Italic":case"Underline":{Xr(X,$);break}case"BulletList":case"NumberList":{Cd(X,$),Q();break}case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{Rd(X,$);break}default:}},T=$=>{const X=$.map(Q=>({alt:Q.alternativeText||Q.name,url:(0,y.CR)(Q.url),mime:Q.mime}));Md(h,X),I(!1)},S=d?p({id:d.id,defaultMessage:d.defaultMessage},{...d.values}):"",G=a.id?p({id:a.id,defaultMessage:a.defaultMessage},{...a.values}):c;return e.createElement(e.Fragment,null,e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:1},e.createElement(P.k,{gap:1},e.createElement(W.Z,{variant:"pi",fontWeight:"bold",textColor:"neutral800"},G,u&&e.createElement(Sd,{textColor:"danger600"},"*")),s&&e.createElement(Ld,{paddingLeft:1},s)),e.createElement(uo,{isExpandMode:v,error:r,previewContent:m,onCollapse:N},e.createElement(Zd,{isExpandMode:v,editorRef:h,isPreviewMode:g,onActionClick:w,onToggleMediaLib:D,onTogglePreviewMode:v?void 0:O,disabled:o}),e.createElement(gd,{disabled:o,isExpandMode:v,editorRef:h,error:r,isPreviewMode:g,name:c,onChange:i,placeholder:S,textareaRef:E,value:m}),!v&&e.createElement(Id,{onToggleExpand:N})),e.createElement(Sc,{hint:t,name:c,error:r})),r&&e.createElement(H.x,{paddingTop:1},e.createElement(W.Z,{variant:"pi",textColor:"danger600","data-strapi-field-error":!0},r)),C&&e.createElement(j,{onClose:D,onSelectAssets:T}))};go.defaultProps={disabled:!1,error:"",labelAction:void 0,placeholder:null,required:!1,value:"",hint:""},go.propTypes={hint:n().oneOfType([n().string,n().array]),disabled:n().bool,error:n().string,intlLabel:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}).isRequired,labelAction:n().element,name:n().string.isRequired,onChange:n().func.isRequired,placeholder:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}),required:n().bool,value:n().string};var kd=go;function Fd(t,o){return r=>{const a=o(r.keys);return e.createElement(t,{...r,...a})}}var Ad=Fd,wd=(t,o=!1)=>[{metadatas:{intlLabel:{id:"components.InputSelect.option.placeholder",defaultMessage:"Choose here"},disabled:o,hidden:o},key:"__enum_option_null",value:""},...t.map(r=>({metadatas:{intlLabel:{id:r,defaultMessage:r},hidden:!1,disabled:!1},key:r,value:r}))],$d=l(59578),Bd=l.n($d),Nd=(t="")=>{switch(Bd()(t)){case"boolean":return"bool";case"biginteger":return"text";case"decimal":case"float":case"integer":return"number";case"date":case"datetime":case"time":return t;case"email":return"email";case"enumeration":return"select";case"password":return"password";case"string":return"text";case"text":return"textarea";case"media":case"file":case"files":return"media";case"json":return"json";case"wysiwyg":case"WYSIWYG":case"richtext":return"wysiwyg";case"uid":return"uid";default:return t||"text"}};function jd(t){const{createActionAllowedFields:o,formErrors:r,isCreatingEntry:a,modifiedData:s,onChange:c,readActionAllowedFields:i,shouldNotRunValidations:d,updateActionAllowedFields:m}=(0,y.Wq)(),u=(0,e.useMemo)(()=>a?o:m,[a,o,m]),p=(0,e.useMemo)(()=>a?[]:i,[a,i]),E=Z()(s,t,null);return{allowedFields:u,formErrors:r,isCreatingEntry:a,onChange:c,readableFields:p,shouldNotRunValidations:d,value:E}}var Wd=jd,_r=["type","model","via","collection","default","plugin","enum","regex","pluginOptions"];function fo({allowedFields:t,componentUid:o,fieldSchema:r,formErrors:a,isCreatingEntry:s,keys:c,labelAction:i,metadatas:d,onChange:m,readableFields:u,shouldNotRunValidations:p,queryInfos:E,value:h,size:g,customFieldInputs:b}){const{fields:C}=(0,y.yX)(),{formatMessage:I}=(0,K.Z)(),{contentType:v}=(0,oe.PL)(),M=(0,e.useMemo)(()=>!Z()(d,"editable",!0),[d]),{type:x,customField:j}=r,D=Z()(a,[c],null),O=(0,e.useMemo)(()=>(0,f.Ts)(c),[c]),N=(0,e.useMemo)(()=>{const L=nc()(r,p?[..._r,"required","minLength"]:_r),B=r.regex||null;if(B){const ne=new RegExp(B);ne&&(L.regex=ne)}return L},[r,p]),w=(0,e.useMemo)(()=>Z()(N,["required"],!1),[N]),T=(0,e.useMemo)(()=>{const L=Z()(v,["attributes"],{});return Z()(L,[O[0],"type"],null)==="dynamiczone"},[v,O]),S=Nd(x),G=x==="media"&&!h?[]:h,$=(0,e.useMemo)(()=>{const L=O.join(".");if(t.includes(L))return!0;if(T)return t.includes(O[0]);if(O.length>1){const ne=Ft()(O,O.length-1).join(".");return t.includes(ne)}return!1},[t,O,T]),X=(0,e.useMemo)(()=>{const L=O.join(".");if(u.includes(L))return!0;if(T)return u.includes(O[0]);if(O.length>1){const ne=Ft()(O,O.length-1).join(".");return u.includes(ne)}return!1},[u,O,T]),Q=(0,e.useMemo)(()=>X||$,[$,X]),J=(0,e.useMemo)(()=>s?M:X&&!$?!0:M,[M,s,$,X]),A=(0,e.useMemo)(()=>wd(r.enum||[],w),[r,w]),{label:k,description:R,placeholder:F,visible:U}=d;if(U===!1)return null;if(!Q)return e.createElement(y.X0,{description:R?{id:R,defaultMessage:R}:null,intlLabel:{id:k,defaultMessage:k},labelAction:i,error:D&&I(D),name:c,required:w});if(x==="relation")return e.createElement(Lc,{...d,...r,componentUid:o,description:d.description?I({id:d.description,defaultMessage:d.description}):void 0,intlLabel:{id:d.label,defaultMessage:d.label},labelAction:i,isUserAllowedToEditField:$,isUserAllowedToReadField:X,name:c,placeholder:d.placeholder?{id:d.placeholder,defaultMessage:d.placeholder}:null,queryInfos:E,size:g,value:h,error:D&&I(D)});const Y={uid:dc,media:C.media,wysiwyg:kd,...C,...b};return e.createElement(y.jm,{attribute:r,autoComplete:"new-password",intlLabel:{id:k,defaultMessage:k},isNullable:S==="bool"&&[null,void 0].includes(r.default),description:R?{id:R,defaultMessage:R}:null,disabled:J,error:D,labelAction:i,contentTypeUID:v.uid,customInputs:Y,multiple:r.multiple||!1,name:c,onChange:m,options:A,placeholder:F?{id:F,defaultMessage:F}:null,required:r.required||!1,step:zd(x),type:j||S,value:G,withDefaultValue:!1})}fo.defaultProps={componentUid:void 0,formErrors:{},labelAction:void 0,size:void 0,value:null,queryInfos:{},customFieldInputs:{}},fo.propTypes={allowedFields:n().array.isRequired,componentUid:n().string,fieldSchema:n().object.isRequired,formErrors:n().object,keys:n().string.isRequired,isCreatingEntry:n().bool.isRequired,labelAction:n().element,metadatas:n().object.isRequired,onChange:n().func.isRequired,readableFields:n().array.isRequired,size:n().number,shouldNotRunValidations:n().bool.isRequired,value:n().any,queryInfos:n().shape({containsKey:n().string,defaultParams:n().object,endPoint:n().string}),customFieldInputs:n().object};const zd=t=>{switch(t){case"float":case"decimal":return .01;default:return 1}},Ud=(0,e.memo)(fo,ke());var ho=Ad(Ud,Wd);const yo=({componentUid:t,isFromDynamicZone:o,isNested:r,name:a})=>{const{getComponentLayout:s}=(0,oe.PL)(),i=(0,e.useMemo)(()=>s(t),[t,s]).layouts.edit,{lazyComponentStore:d}=Gn();return e.createElement(H.x,{background:o?"":"neutral100",paddingLeft:6,paddingRight:6,paddingTop:6,paddingBottom:6,hasRadius:r,borderColor:r?"neutral200":""},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:6},i.map((m,u)=>e.createElement(Oe.r,{gap:4,key:u},m.map(({name:p,size:E,metadatas:h,fieldSchema:g,queryInfos:b})=>{const C=g.type==="component",I=`${a}.${p}`;if(C){const v=g.component;return e.createElement(be.P,{col:E,s:12,xs:12,key:p},e.createElement(Yt,{componentUid:v,intlLabel:{id:h.label,defaultMessage:h.label},isNested:!0,isRepeatable:g.repeatable,max:g.max,min:g.min,name:I,required:g.required||!1}))}return e.createElement(be.P,{col:E,key:p,s:12,xs:12},e.createElement(ho,{componentUid:t,keys:I,fieldSchema:g,metadatas:h,queryInfos:b,size:E,customFieldInputs:d}))})))))};yo.defaultProps={isFromDynamicZone:!1,isNested:!1},yo.propTypes={componentUid:n().string.isRequired,isFromDynamicZone:n().bool,isNested:n().bool,name:n().string.isRequired};var Vd=yo;const qd=(0,q.ZP)(H.x)`
|
|
824
|
+
overflow: hidden;
|
|
825
|
+
border-bottom: 1px solid ${({theme:t})=>t.colors.neutral200};
|
|
826
|
+
border-right: 1px solid ${({theme:t})=>t.colors.neutral200};
|
|
827
|
+
border-left: 1px solid ${({theme:t})=>t.colors.neutral200};
|
|
828
|
+
border-radius: 0 0 ${({theme:t})=>t.borderRadius} ${({theme:t})=>t.borderRadius};
|
|
829
|
+
`,Hd=(0,q.ZP)(H.x)`
|
|
830
|
+
border-bottom: none;
|
|
831
|
+
|
|
832
|
+
/* add the borders and make sure the top is transparent to avoid jumping with the hover effect */
|
|
833
|
+
& > div > div {
|
|
834
|
+
border: 1px solid ${({theme:t})=>t.colors.neutral200};
|
|
835
|
+
border-top-color: transparent;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
/* the top accordion _does_ need a border though */
|
|
839
|
+
& > div:first-child > div {
|
|
840
|
+
border-top: 1px solid ${({theme:t})=>t.colors.neutral200};
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/* Reset all the border-radius' */
|
|
844
|
+
& > div > div,
|
|
845
|
+
& > div > div > div {
|
|
846
|
+
border-radius: unset;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/* Give the border radius back to the first accordion */
|
|
850
|
+
& > div:first-child > div,
|
|
851
|
+
& > div:first-child > div > div {
|
|
852
|
+
border-radius: ${({theme:t})=>t.borderRadius} ${({theme:t})=>t.borderRadius} 0 0;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
& > div > div[data-strapi-expanded='true'] {
|
|
856
|
+
border: 1px solid ${({theme:t})=>t.colors.primary600};
|
|
857
|
+
}
|
|
858
|
+
`,Eo=({children:t,error:o})=>{const{formatMessage:r}=(0,K.Z)();return e.createElement(Zr.k,{attributeName:"data-strapi-accordion-toggle"},t,o&&e.createElement(H.x,{paddingTop:1},e.createElement(W.Z,{variant:"pi",textColor:"danger600"},r({id:o.id,defaultMessage:o.defaultMessage},{...o.values}))))};Eo.defaultProps={error:void 0},Eo.propTypes={children:n().node.isRequired,error:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object})};var Gd=l(41119),ea=l.n(Gd);const Qd=q.ZP.span`
|
|
859
|
+
display: block;
|
|
860
|
+
background-color: ${({theme:t})=>t.colors.primary100};
|
|
861
|
+
outline: 1px dashed ${({theme:t})=>t.colors.primary500};
|
|
862
|
+
outline-offset: -1px;
|
|
863
|
+
padding: ${({theme:t})=>t.spaces[6]};
|
|
864
|
+
`;var Kd=()=>e.createElement(Qd,{padding:6,background:"primary100"});const Yd=(0,q.ZP)(Re.h)`
|
|
865
|
+
background-color: transparent;
|
|
866
|
+
|
|
867
|
+
svg {
|
|
868
|
+
path {
|
|
869
|
+
fill: ${({theme:t,expanded:o})=>o?t.colors.primary600:t.colors.neutral600};
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
&:hover {
|
|
874
|
+
svg {
|
|
875
|
+
path {
|
|
876
|
+
fill: ${({theme:t})=>t.colors.primary600};
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
`,Xd=(0,q.ZP)(P.k)`
|
|
881
|
+
& .drag-handle {
|
|
882
|
+
background: unset;
|
|
883
|
+
|
|
884
|
+
svg {
|
|
885
|
+
path {
|
|
886
|
+
fill: ${({theme:t,expanded:o})=>o?t.colors.primary600:void 0};
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
&:hover {
|
|
891
|
+
svg {
|
|
892
|
+
path {
|
|
893
|
+
/* keeps the hover style of the accordion */
|
|
894
|
+
fill: ${({theme:t})=>t.colors.primary600};
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
`,bo=({componentFieldName:t,componentUid:o,fields:r,index:a,isOpen:s,isReadOnly:c,mainField:i,moveComponentField:d,onClickToggle:m,toggleCollapses:u,onGrabItem:p,onDropItem:E,onCancel:h})=>{const{modifiedData:g,removeRepeatableField:b,triggerFormValidation:C}=(0,y.Wq)(),I=ea()(Z()(g,[...t.split("."),i],"")),v=(0,e.useRef)(null),{formatMessage:M}=(0,K.Z)(),x=t.split(".").slice(0,-1).join("."),[{handlerId:j,isDragging:D,handleKeyDown:O},N,w,T,S]=(0,Br.Y)(!c,{type:`${f._Q.COMPONENT}_${x}`,index:a,item:{displayedValue:I},onMoveItem:d,onStart(){u()},onEnd(){C()},onGrabItem:p,onDropItem:E,onCancel:h});(0,e.useEffect)(()=>{S((0,xt.rX)(),{captureDraggingState:!1})},[S,a]);const G=(0,f.FE)(v,T),$=(0,f.FE)(N,w),{lazyComponentStore:X}=Gn();return e.createElement(H.x,{ref:$},D?e.createElement(Kd,null):e.createElement(jn.U,{expanded:s,onToggle:m,id:t,size:"S"},e.createElement(Wn.B,{action:c?null:e.createElement(Xd,{gap:0,expanded:s},e.createElement(Yd,{expanded:s,noBorder:!0,onClick:()=>{b(t),u()},label:M({id:(0,f.OB)("containers.Edit.delete"),defaultMessage:"Delete"}),icon:e.createElement(Ve.Z,null)}),e.createElement(Re.h,{className:"drag-handle",ref:G,forwardedAs:"div",role:"button",noBorder:!0,tabIndex:0,onClick:Q=>Q.stopPropagation(),"data-handler-id":j,label:M({id:(0,f.OB)("components.DragHandle-label"),defaultMessage:"Drag"}),onKeyDown:O},e.createElement(Ye.Z,null))),title:I,togglePosition:"left"}),e.createElement(zn.v,null,e.createElement(P.k,{direction:"column",alignItems:"stretch",background:"neutral100",padding:6,gap:6},r.map((Q,J)=>e.createElement(Oe.r,{gap:4,key:J},Q.map(({name:A,fieldSchema:k,metadatas:R,queryInfos:F,size:U})=>{const Y=k.type==="component",L=`${t}.${A}`;if(Y){const B=k.component;return e.createElement(be.P,{col:U,s:12,xs:12,key:A},e.createElement(Yt,{componentUid:B,intlLabel:{id:R.label,defaultMessage:R.label},isRepeatable:k.repeatable,isNested:!0,name:L,max:k.max,min:k.min,required:k.required}))}return e.createElement(be.P,{key:L,col:U,s:12,xs:12},e.createElement(ho,{componentUid:o,fieldSchema:k,keys:L,metadatas:R,queryInfos:F,size:U,customFieldInputs:X}))})))))))};bo.defaultProps={componentUid:void 0,fields:[],isReadOnly:!1,isOpen:!1,onGrabItem:void 0,onDropItem:void 0,onCancel:void 0,toggleCollapses(){}},bo.propTypes={componentFieldName:n().string.isRequired,componentUid:n().string,fields:n().array,index:n().number.isRequired,isOpen:n().bool,isReadOnly:n().bool,mainField:n().string.isRequired,moveComponentField:n().func.isRequired,onGrabItem:n().func,onDropItem:n().func,onCancel:n().func,onClickToggle:n().func.isRequired,toggleCollapses:n().func};var Jd=(0,e.memo)(bo);function _d(t,o={}){return Object.keys(o).filter(r=>r.startsWith(t)).map(r=>r.split(".").slice(0,t.split(".").length+1).join("."))}const eu=(0,q.ZP)(wr.A)`
|
|
900
|
+
height: 100%;
|
|
901
|
+
width: 100%;
|
|
902
|
+
border-radius: 0 0 4px 4px;
|
|
903
|
+
display: flex;
|
|
904
|
+
justify-content: center;
|
|
905
|
+
span {
|
|
906
|
+
font-weight: 600;
|
|
907
|
+
font-size: 14px;
|
|
908
|
+
}
|
|
909
|
+
`,vo=({componentUid:t,componentValue:o,componentValueLength:r,isReadOnly:a,max:s,min:c,name:i})=>{const{addRepeatableComponentToField:d,formErrors:m,moveComponentField:u}=(0,y.Wq)(),p=(0,y.lm)(),{formatMessage:E}=(0,K.Z)(),[h,g]=(0,e.useState)(""),[b,C]=(0,e.useState)(""),{getComponentLayout:I,components:v}=(0,oe.PL)(),M=(0,e.useMemo)(()=>I(t),[t,I]),x=(0,e.useMemo)(()=>(0,f.Uo)(o||[])+1,[o]),j=_d(i,m),D=c-r,O=Z()(m,i,{id:""}).id.includes("min"),N=()=>{g("")},w=()=>{a||(r<s?(d(i,M,v,O),g(x)):r>=s&&p({type:"info",message:{id:(0,f.OB)("components.notification.info.maximum-requirement")}}))},T=(R,F)=>{C(E({id:(0,f.OB)("dnd.reorder"),defaultMessage:"{item}, moved. New position in list: {position}."},{item:`${i}.${F}`,position:$(R)})),u({name:i,newIndex:R,currentIndex:F})},S=Z()(M,["settings","mainField"],"id"),G=R=>()=>{g(h===R?"":R)},$=R=>`${R+1} of ${r}`,X=R=>{C(E({id:(0,f.OB)("dnd.cancel-item"),defaultMessage:"{item}, dropped. Re-order cancelled."},{item:`${i}.${R}`}))},Q=R=>{C(E({id:(0,f.OB)("dnd.grab-item"),defaultMessage:"{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel."},{item:`${i}.${R}`,position:$(R)}))},J=R=>{C(E({id:(0,f.OB)("dnd.drop-item"),defaultMessage:"{item}, dropped. Final position in list: {position}."},{item:`${i}.${R}`,position:$(R)}))};let A=m[i];if(O?A={id:(0,f.OB)("components.DynamicZone.missing-components"),defaultMessage:"There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}",values:{number:D}}:j.some(R=>R.split(".").length>1)&&!O&&(A={id:(0,f.OB)("components.RepeatableComponent.error-message"),defaultMessage:"The component(s) contain error(s)"}),r===0)return e.createElement(Sr,{error:A,isReadOnly:a,onClick:w});const k=`${i}-item-instructions`;return e.createElement(H.x,{hasRadius:!0},e.createElement(_e.T,{id:k},E({id:(0,f.OB)("dnd.instructions"),defaultMessage:"Press spacebar to grab and re-order"})),e.createElement(_e.T,{"aria-live":"assertive"},b),e.createElement(Eo,{error:A,ariaDescribedBy:k},e.createElement(Hd,{"aria-describedby":k},o.map(({__temp_key__:R},F)=>e.createElement(Jd,{componentFieldName:`${i}.${F}`,componentUid:t,fields:M.layouts.edit,key:R,index:F,isOpen:h===R,isReadOnly:a,mainField:S,moveComponentField:T,onClickToggle:G(R),toggleCollapses:N,onCancel:X,onDropItem:J,onGrabItem:Q}))),e.createElement(qd,null,e.createElement(P.k,{justifyContent:"center",height:"48px",background:"neutral0"},e.createElement(eu,{disabled:a,onClick:w,startIcon:e.createElement(pt.Z,null)},E({id:(0,f.OB)("containers.EditView.add.new-entry"),defaultMessage:"Add an entry"}))))))};vo.defaultProps={componentValue:null,componentValueLength:0,isReadOnly:!1,max:1/0,min:0},vo.propTypes={componentUid:n().string.isRequired,componentValue:n().oneOfType([n().array,n().object]),componentValueLength:n().number,isReadOnly:n().bool,max:n().number,min:n().number,name:n().string.isRequired};var tu=(0,e.memo)(vo);const nu=(0,q.ZP)(H.x)`
|
|
910
|
+
svg path {
|
|
911
|
+
fill: ${({theme:t})=>t.colors.neutral500};
|
|
912
|
+
}
|
|
913
|
+
`,Co=({intlLabel:t,id:o,labelAction:r,name:a,numberOfEntries:s,showNumberOfEntries:c,required:i})=>{const{formatMessage:d}=(0,K.Z)(),m=t?.id?d(t):a;return e.createElement(H.x,{paddingBottom:1},e.createElement(P.k,null,e.createElement(W.Z,{textColor:"neutral800",htmlFor:o||a,variant:"pi",fontWeight:"bold",as:"label"},m,c&&e.createElement(e.Fragment,null,"\xA0(",s,")"),i&&e.createElement(W.Z,{textColor:"danger600"},"*")),r&&e.createElement(nu,{paddingLeft:1},r)))};Co.defaultProps={id:void 0,labelAction:void 0,numberOfEntries:0,required:!1,showNumberOfEntries:!1},Co.propTypes={id:n().string,intlLabel:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}).isRequired,labelAction:n().element,name:n().string.isRequired,numberOfEntries:n().number,required:n().bool,showNumberOfEntries:n().bool};var ou=Co;function ru(t,o){return r=>{const a=o(r);return e.createElement(t,{...r,...a})}}var au=ru;function su({isFromDynamicZone:t,name:o}){const{addNonRepeatableComponentToField:r,createActionAllowedFields:a,isCreatingEntry:s,modifiedData:c,removeComponentFromField:i,readActionAllowedFields:d,updateActionAllowedFields:m,formErrors:u}=(0,y.Wq)(),{contentType:p}=(0,oe.PL)(),E=(0,e.useMemo)(()=>{const M=Z()(p,["attributes"],{});return Object.keys(M).filter(j=>Z()(M,[j,"type"],"")==="dynamiczone")},[p]),h=(0,e.useMemo)(()=>s?a:m,[s,a,m]),g=Z()(c,o,null),b=(0,e.useMemo)(()=>(0,f.Ts)(o),[o]),C=(0,e.useMemo)(()=>t&&s||h.filter(j=>j===b[0]).length>0?!0:h.map(j=>j.split(".")).filter(j=>j.length<b.length?!1:Ft()(j,b.length).join(".")===b.join(".")).length>0,[t,s,h,b]),I=(0,e.useMemo)(()=>t||E.includes(b[0])?!0:(s?[]:d).map(j=>j.split(".")).filter(j=>j.length<b.length?!1:Ft()(j,b.length).join(".")===b.join(".")).length>0,[t,E,b,s,d]),v=(0,e.useMemo)(()=>s||C?!1:I,[C,I,s]);return{addNonRepeatableComponentToField:r,formErrors:u,hasChildrenAllowedFields:C,hasChildrenReadableFields:I,isCreatingEntry:s,isReadOnly:v,removeComponentFromField:i,componentValue:g}}var iu=su;const Ro=({addNonRepeatableComponentToField:t,componentUid:o,intlLabel:r,isCreatingEntry:a,isFromDynamicZone:s,isRepeatable:c,isNested:i,labelAction:d,max:m,min:u,name:p,hasChildrenAllowedFields:E,hasChildrenReadableFields:h,isReadOnly:g,componentValue:b,removeComponentFromField:C,required:I})=>{const{formatMessage:v}=(0,K.Z)(),M=_l()(b),x=b!==null||s,j=!c&&x&&!s&&E,{getComponentLayout:D,components:O}=(0,oe.PL)(),N=(0,e.useMemo)(()=>D(o),[o,D]);if(!E&&a)return e.createElement(y.X0,{labelAction:d,intlLabel:r,name:p});if(!E&&!a&&!h)return e.createElement(y.X0,{labelAction:d,intlLabel:r,name:p});const w=()=>{t(p,N,O)};return e.createElement(H.x,null,e.createElement(P.k,{justifyContent:"space-between"},r&&e.createElement(ou,{intlLabel:r,labelAction:d,name:p,numberOfEntries:M,showNumberOfEntries:c,required:I}),j&&e.createElement(Re.h,{label:v({id:(0,f.OB)("components.reset-entry"),defaultMessage:"Reset Entry"}),icon:e.createElement(Ve.Z,null),noBorder:!0,onClick:()=>{C(p,o)}})),e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:1},!c&&!x&&e.createElement(Sr,{isReadOnly:g,onClick:w}),!c&&x&&e.createElement(Vd,{componentUid:o,isFromDynamicZone:s,isNested:i,name:p}),c&&e.createElement(tu,{componentValue:b,componentValueLength:M,componentUid:o,isReadOnly:g,max:m,min:u,name:p})))};Ro.defaultProps={componentValue:null,hasChildrenAllowedFields:!1,hasChildrenReadableFields:!1,intlLabel:void 0,isFromDynamicZone:!1,isReadOnly:!1,isRepeatable:!1,isNested:!1,labelAction:void 0,max:1/0,min:-1/0,required:!1},Ro.propTypes={addNonRepeatableComponentToField:n().func.isRequired,componentUid:n().string.isRequired,componentValue:n().oneOfType([n().object,n().array]),hasChildrenAllowedFields:n().bool,hasChildrenReadableFields:n().bool,isCreatingEntry:n().bool.isRequired,isFromDynamicZone:n().bool,isReadOnly:n().bool,isRepeatable:n().bool,isNested:n().bool,intlLabel:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}),labelAction:n().element,max:n().number,min:n().number,name:n().string.isRequired,removeComponentFromField:n().func.isRequired,required:n().bool};const lu=(0,e.memo)(Ro,ke());var Yt=au(lu,iu);const Mo=({componentUid:t,formErrors:o,index:r,isFieldAllowed:a,name:s,onRemoveComponentClick:c,onMoveComponent:i,onGrabItem:d,onDropItem:m,onCancel:u,dynamicComponentsByCategory:p,onAddComponent:E})=>{const[h,g]=(0,e.useState)(!0),{formatMessage:b}=(0,K.Z)(),{getComponentLayout:C}=(0,oe.PL)(),{modifiedData:I}=(0,y.Wq)(),{icon:v,friendlyName:M,mainValue:x}=(0,e.useMemo)(()=>{const A=C(t),{info:{icon:k,displayName:R}}=A,F=Z()(A,["settings","mainField"],"id"),U=Z()(I,[s,r,F])??"",Y=F==="id"?"":String(U).trim(),L=Y.length>0?` - ${Y}`:Y;return{friendlyName:R,icon:k,mainValue:L}},[t,C,I,s,r]),j=Object.keys(o).filter(A=>{const k=A.split(".");return`${k[0]}.${k[1]}`==`${s}.${r}`});let D;j.length>0&&(D=b({id:(0,f.OB)("components.DynamicZone.error-message"),defaultMessage:"The component contains error(s)"}));const O=()=>{g(A=>!A)},[{handlerId:N,isDragging:w,handleKeyDown:T},S,G,$,X]=(0,oe.Y9)(a,{type:`${f._Q.DYNAMIC_ZONE}_${s}`,index:r,item:{displayedValue:`${M}${x}`,icon:v},onMoveItem:i,onGrabItem:d,onDropItem:m,onCancel:u});(0,e.useEffect)(()=>{X((0,xt.rX)(),{captureDraggingState:!1})},[X,r]);const Q=(0,f.FE)(S,G),J=a?e.createElement(cu,{gap:0,expanded:h},e.createElement(du,{noBorder:!0,label:b({id:(0,f.OB)("components.DynamicZone.delete-label"),defaultMessage:"Delete {name}"},{name:M}),onClick:c},e.createElement(Ve.Z,null)),e.createElement(Re.h,{forwardedAs:"div",role:"button",noBorder:!0,tabIndex:0,onClick:A=>A.stopPropagation(),"data-handler-id":N,ref:$,label:b({id:(0,f.OB)("components.DragHandle-label"),defaultMessage:"Drag"}),onKeyDown:T},e.createElement(Ye.Z,null)),e.createElement(pe.fC,null,e.createElement(pe.xz,{size:"S",endIcon:void 0,paddingLeft:2,paddingRight:2},e.createElement(qn.Z,{"aria-hidden":!0,focusable:!1}),e.createElement(_e.T,{as:"span"},b({id:(0,f.OB)("components.DynamicZone.more-actions"),defaultMessage:"More actions"}))),e.createElement(pe.VY,null,e.createElement(pe.rl,null,e.createElement(pe.fF,null,b({id:(0,f.OB)("components.DynamicZone.add-item-above"),defaultMessage:"Add component above"})),e.createElement(pe.tu,null,Object.entries(p).map(([A,k])=>e.createElement(e.Fragment,{key:A},e.createElement(pe.__,null,A),k.map(({componentUid:R,info:{displayName:F}})=>e.createElement(Lr.sN,{key:R,onSelect:()=>E(R,r)},F)))))),e.createElement(pe.rl,null,e.createElement(pe.fF,null,b({id:(0,f.OB)("components.DynamicZone.add-item-below"),defaultMessage:"Add component below"})),e.createElement(pe.tu,null,Object.entries(p).map(([A,k])=>e.createElement(e.Fragment,{key:A},e.createElement(pe.__,null,A),k.map(({componentUid:R,info:{displayName:F}})=>e.createElement(Lr.sN,{key:R,onSelect:()=>E(R,r+1)},F))))))))):null;return e.createElement(fu,{as:"li",width:"100%"},e.createElement(P.k,{justifyContent:"center"},e.createElement(pu,{background:"neutral200"})),e.createElement(uu,{ref:Q,hasRadius:!0},w?e.createElement(gu,{padding:6,background:"primary100"}):e.createElement(jn.U,{expanded:h,onToggle:O,size:"S",error:D},e.createElement(Wn.B,{startIcon:e.createElement(Zt,{icon:v,showBackground:!1,size:"S"}),action:J,title:`${M}${x}`,togglePosition:"left"}),e.createElement(zn.v,null,e.createElement(mu,{background:"neutral0"},e.createElement(Yt,{componentUid:t,icon:v,name:`${s}.${r}`,isFromDynamicZone:!0}))))))},cu=(0,q.ZP)(P.k)`
|
|
914
|
+
/*
|
|
915
|
+
we need to remove the background from the button but we can't
|
|
916
|
+
wrap the element in styled because it breaks the forwardedAs which
|
|
917
|
+
we need for drag handler to work on firefox
|
|
918
|
+
*/
|
|
919
|
+
div[role='button'] {
|
|
920
|
+
background: transparent;
|
|
921
|
+
}
|
|
922
|
+
`,du=(0,q.ZP)(Re.h)`
|
|
923
|
+
background-color: transparent;
|
|
924
|
+
|
|
925
|
+
svg path {
|
|
926
|
+
fill: ${({theme:t,expanded:o})=>o?t.colors.primary600:t.colors.neutral600};
|
|
927
|
+
}
|
|
928
|
+
`,uu=(0,q.ZP)(H.x)`
|
|
929
|
+
> div:first-child {
|
|
930
|
+
box-shadow: ${({theme:t})=>t.shadows.tableShadow};
|
|
931
|
+
}
|
|
932
|
+
`,mu=(0,q.ZP)(H.x)`
|
|
933
|
+
border-radius: 0 0 ${({theme:t})=>t.spaces[1]} ${({theme:t})=>t.spaces[1]};
|
|
934
|
+
`,pu=(0,q.ZP)(H.x)`
|
|
935
|
+
width: ${({theme:t})=>t.spaces[2]};
|
|
936
|
+
height: ${({theme:t})=>t.spaces[4]};
|
|
937
|
+
`,gu=q.ZP.span`
|
|
938
|
+
display: block;
|
|
939
|
+
background-color: ${({theme:t})=>t.colors.primary100};
|
|
940
|
+
outline: 1px dashed ${({theme:t})=>t.colors.primary500};
|
|
941
|
+
outline-offset: -1px;
|
|
942
|
+
padding: ${({theme:t})=>t.spaces[6]};
|
|
943
|
+
`,fu=(0,q.ZP)(H.x)`
|
|
944
|
+
list-style: none;
|
|
945
|
+
padding: 0;
|
|
946
|
+
margin: 0;
|
|
947
|
+
`;Mo.defaultProps={dynamicComponentsByCategory:{},formErrors:{},index:0,isFieldAllowed:!0,onAddComponent:void 0,onGrabItem:void 0,onDropItem:void 0,onCancel:void 0},Mo.propTypes={componentUid:n().string.isRequired,dynamicComponentsByCategory:n().shape({components:n().arrayOf(n().shape({componentUid:n().string.isRequired,info:n().object}))}),formErrors:n().object,index:n().number,isFieldAllowed:n().bool,name:n().string.isRequired,onAddComponent:n().func,onGrabItem:n().func,onDropItem:n().func,onCancel:n().func,onMoveComponent:n().func.isRequired,onRemoveComponentClick:n().func.isRequired};const To=({label:t,labelAction:o,name:r,numberOfComponents:a,required:s,intlDescription:c})=>{const{formatMessage:i}=(0,K.Z)(),d=i({id:t||r,defaultMessage:t||r});return e.createElement(P.k,{justifyContent:"center"},e.createElement(H.x,{paddingTop:3,paddingBottom:3,paddingRight:4,paddingLeft:4,borderRadius:26,background:"neutral0",shadow:"filterShadow",color:"neutral500"},e.createElement(P.k,{direction:"column",justifyContent:"center"},e.createElement(P.k,{maxWidth:(0,y.Q1)(356)},e.createElement(W.Z,{variant:"pi",textColor:"neutral600",fontWeight:"bold",ellipsis:!0},d,"\xA0"),e.createElement(W.Z,{variant:"pi",textColor:"neutral600",fontWeight:"bold"},"(",a,")"),s&&e.createElement(W.Z,{textColor:"danger600"},"*"),o&&e.createElement(H.x,{paddingLeft:1},o)),c&&e.createElement(H.x,{paddingTop:1,maxWidth:(0,y.Q1)(356)},e.createElement(W.Z,{variant:"pi",textColor:"neutral600",ellipsis:!0},i(c))))))};To.defaultProps={intlDescription:void 0,label:"",labelAction:void 0,numberOfComponents:0,required:!1},To.propTypes={intlDescription:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired}),label:n().string,labelAction:n().element,name:n().string.isRequired,numberOfComponents:n().number,required:n().bool};const Do=({name:t,labelAction:o,fieldSchema:r,metadatas:a})=>{const{max:s=1/0,min:c=-1/0,components:i=[],required:d=!1}=r,[m,u]=(0,e.useState)(!1),[p,E]=(0,e.useState)(""),{addComponentToDynamicZone:h,createActionAllowedFields:g,isCreatingEntry:b,formErrors:C,modifiedData:I,moveComponentField:v,removeComponentFromDynamicZone:M,readActionAllowedFields:x,updateActionAllowedFields:j}=(0,y.Wq)(),D=(0,e.useMemo)(()=>(I?.[t]??[]).map(z=>({componentUid:z.__component,id:z.id??z.__temp_key__})),[I,t]),{getComponentLayout:O,components:N}=(0,oe.PL)(),w=(0,e.useMemo)(()=>i.reduce((z,ye)=>{const{category:he,info:Ne,attributes:Ue}=O(ye),de={componentUid:ye,info:Ne,attributes:Ue};return z[he]||(z[he]=[]),z[he]=[...z[he],de],z},{}),[i,O]),{formatMessage:T}=(0,K.Z)(),S=(0,y.lm)(),G=(0,e.useMemo)(()=>(b?g:j).includes(t),[t,b,g,j]),$=(0,e.useMemo)(()=>(b?[]:x).includes(t),[t,b,x]),X=D.length,Q=a.description?{id:a.description,defaultMessage:a.description}:null,J=C[t],A=c-X,k=!!J,R=(z,ye)=>{u(!1);const he=O(z);h(t,he,N,k,ye)},F=()=>{X<s?u(z=>!z):S({type:"info",message:{id:(0,f.OB)("components.notification.info.maximum-requirement")}})},U=(z,ye)=>{E(T({id:(0,f.OB)("dnd.reorder"),defaultMessage:"{item}, moved. New position in list: {position}."},{item:`${t}.${ye}`,position:Y(z)})),v({name:t,newIndex:z,currentIndex:ye})},Y=z=>`${z+1} of ${D.length}`,L=z=>{E(T({id:(0,f.OB)("dnd.cancel-item"),defaultMessage:"{item}, dropped. Re-order cancelled."},{item:`${t}.${z}`}))},B=z=>{E(T({id:(0,f.OB)("dnd.grab-item"),defaultMessage:"{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel."},{item:`${t}.${z}`,position:Y(z)}))},ne=z=>{E(T({id:(0,f.OB)("dnd.drop-item"),defaultMessage:"{item}, dropped. Final position in list: {position}."},{item:`${t}.${z}`,position:Y(z)}))},ce=(z,ye)=>()=>{M(z,ye)},ge=()=>m?T({id:"app.utils.close-label",defaultMessage:"Close"}):k&&J.id.includes("max")?T({id:"components.Input.error.validation.max",defaultMessage:"The value is too high."}):k&&J.id.includes("min")?T({id:(0,f.OB)("components.DynamicZone.missing-components"),defaultMessage:"There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"},{number:A}):T({id:(0,f.OB)("components.DynamicZone.add-component"),defaultMessage:"Add a component to {componentName}"},{componentName:a.label||t});if(!G&&(b||!$&&!b))return e.createElement(y.X0,{description:Q,intlLabel:{id:a.label,defaultMessage:a.label},labelAction:o,name:t});const V=`${t}-item-instructions`;return e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:6},X>0&&e.createElement(H.x,null,e.createElement(To,{intlDescription:Q,label:a.label,labelAction:o,name:t,numberOfComponents:X,required:d}),e.createElement(_e.T,{id:V},T({id:(0,f.OB)("dnd.instructions"),defaultMessage:"Press spacebar to grab and re-order"})),e.createElement(_e.T,{"aria-live":"assertive"},p),e.createElement("ol",{"aria-describedby":V},D.map(({componentUid:z,id:ye},he)=>e.createElement(Mo,{componentUid:z,formErrors:C,key:`${z}-${ye}`,index:he,isFieldAllowed:G,name:t,onMoveComponent:U,onRemoveComponentClick:ce(t,he),onCancel:L,onDropItem:ne,onGrabItem:B,onAddComponent:R,dynamicComponentsByCategory:w})))),e.createElement(P.k,{justifyContent:"center"},e.createElement(Bn,{hasError:k,isDisabled:!G,isOpen:m,onClick:F},ge())),e.createElement(Vn,{dynamicComponentsByCategory:w,isOpen:m,onClickAddComponent:R}))};Do.defaultProps={fieldSchema:{},labelAction:null},Do.propTypes={fieldSchema:n().shape({components:n().array,max:n().number,min:n().number,required:n().bool}),labelAction:n().element,metadatas:n().shape({description:n().string,label:n().string}).isRequired,name:n().string.isRequired};var hu=l(86834),Fe=l.n(hu),ta=l(12788),Oo=l(99526),yu=l(10268),na=l.n(yu),Eu=l(56236),bu=l.n(Eu),vu=l(77236),Cu=l.n(vu),Ru=l(85973),Mu=l.n(Ru);const Tu=({browserState:t,serverState:o},r,a)=>{const s=o,c=t,i=(u,p)=>Z()(u,["attributes",p,"type"],""),d=(u,p)=>Z()(u,["attributes",...p],""),m=(u,p,E,h)=>Object.keys(u).reduce((g,b)=>{const C=h?`${h}.${b}`:b,I=i(E,b),v=Z()(u,b),M=Z()(p,b),x=d(E,[b,"component"]),j=d(E,[b,"repeatable"]);let D;switch(I){case"json":D=JSON.parse(v);break;case"time":{D=v,v&&v.split(":").length<3&&(D=`${v}:00`);break}case"media":d(E,[b,"multiple"])===!0?D=v?v.filter(O=>!(O instanceof File)):null:D=Z()(v,0)instanceof File?null:Z()(v,"id",null);break;case"component":j?D=v&&v.map((O,N)=>m(O,(M??[])[N],a[x],`${C}.${N}`)):D=v&&m(v,M,a[x],C);break;case"relation":{const O=Ar(s,c)(C).join(".");let N=Z()(s,O,[]);const w=v.reduce((S,G,$,X)=>{const Q=N.find(A=>A.id===G.id),J=X[$+1];if(!Q||Q.__temp_key__!==G.__temp_key__){const A=J?{before:J.id}:{end:!0};return[...S,{id:G.id,position:A}]}return S},[]);D={disconnect:N.reduce((S,G)=>v.find($=>$.id===G.id)?S:[...S,{id:G.id}],[]),connect:w.reverse()};break}case"dynamiczone":D=v.map((O,N)=>m(O,(M??[])[N],a[O.__component],`${C}.${N}`));break;default:D=Du(v,"id")}return g[b]=D,g},{});return m(t,o,r,"")},Du=(t,o)=>Cu()(t)?t.map(r=>r[o]?r[o]:r):Mu()(t)?t[o]:t;var Ou=Tu;const Xt=(t,o=()=>!1,r=void 0)=>{const a=(s,c,{ignoreFalseyValues:i=!1,path:d=[],parent:m=c}={})=>Object.entries(c).reduce((u,[p,E])=>{if(i&&(u==null||u[p]===void 0||u[p]===null))return u;if(o(E,{path:[...d,p],parent:m})&&(u[p]=typeof r=="function"?r(u[p],{path:[...d,p],parent:u}):r),E.type==="component"){const h=t[E.component].attributes;!E.repeatable&&u[p]&&typeof u[p]=="object"?u[p]=a(u[p],h,{ignoreFalseyValues:i,path:[...d,p],parent:c[p]}):E.repeatable&&Array.isArray(u[p])&&(u[p]=u[p].map((g,b)=>a(g,h,{ignoreFalseyValues:i,path:[...d,p,b],parent:c[p]})))}else E.type==="dynamiczone"&&Array.isArray(u[p])&&(u[p]=u[p].map((h,g)=>{const b=t[h.__component].attributes;return a(h,b,{ignoreFalseyValues:i,path:[...d,p,g],parent:c[p]})}));return u},{...s});return a};var oa=(t,o,r,a)=>{const s=t.slice();return s.splice(o,1),s.splice(r,0,a),s};const Iu={componentsDataStructure:{},contentTypeDataStructure:{},formErrors:{},initialData:{},modifiedData:null,shouldCheckErrors:!1,modifiedDZName:null,publishConfirmation:{show:!1,draftCount:0}};var Pu=(t,o)=>(0,Pn.ZP)(t,r=>{switch(o.type){case"ADD_NON_REPEATABLE_COMPONENT_TO_FIELD":{const{componentLayoutData:a,allComponents:s}=o,c={...t.componentsDataStructure[a.uid]},d=Xt(s,m=>m.type==="relation",[])(c,a.attributes);te()(r,["modifiedData",...o.keys],d);break}case"ADD_COMPONENT_TO_DYNAMIC_ZONE":case"ADD_REPEATABLE_COMPONENT_TO_FIELD":{const{keys:a,allComponents:s,componentLayoutData:c,shouldCheckErrors:i,position:d=void 0}=o;i&&(r.shouldCheckErrors=!t.shouldCheckErrors),o.type==="ADD_COMPONENT_TO_DYNAMIC_ZONE"&&(r.modifiedDZName=a[0]);const m=[...Z()(t,["modifiedData",...a],[])];let u=d;u===void 0?u=m.length:u<0&&(u=0);const p=o.type==="ADD_COMPONENT_TO_DYNAMIC_ZONE"?{...t.componentsDataStructure[c.uid],__component:c.uid,__temp_key__:(0,f.Uo)(m)+1}:{...t.componentsDataStructure[c.uid],__temp_key__:(0,f.Uo)(m)+1},h=Xt(s,g=>g.type==="relation",[])(p,c.attributes);m.splice(u,0,h),te()(r,["modifiedData",...a],m);break}case"LOAD_RELATION":{const{initialDataPath:a,modifiedDataPath:s,value:c}=o,i=Z()(t,a),d=Z()(t,s),m=i?c.filter(E=>!i.some(h=>h.id===E.id)):c,u=(0,Oo.zJ)(null,d[0]?.__temp_key__,m.length),p=m.map((E,h)=>({...E,__temp_key__:u[h]}));te()(r,a,na()([...p,...i],"id")),te()(r,s,na()([...p,...d],"id"));break}case"CONNECT_RELATION":{const a=["modifiedData",...o.keys],{value:s,toOneRelation:c}=o;if(c)te()(r,a,[s]);else{const i=Z()(t,a),[d]=(0,Oo.zJ)(i.at(-1)?.__temp_key__,null,1),m=[...i,{...s,__temp_key__:d}];te()(r,a,m)}break}case"DISCONNECT_RELATION":{const a=["modifiedData",...o.keys],{id:s}=o,i=Z()(t,[...a]).filter(d=>d.id!==s);te()(r,a,i);break}case"MOVE_COMPONENT_FIELD":case"REORDER_RELATION":{const{oldIndex:a,newIndex:s,keys:c}=o,i=["modifiedData",...c],d=Z()(t,[...i]),m=d[a],u=[...d];if(o.type==="REORDER_RELATION"){const p=a>s?d[s-1]?.__temp_key__:d[s]?.__temp_key__,E=a>s?d[s]?.__temp_key__:d[s+1]?.__temp_key__,[h]=(0,Oo.zJ)(p,E,1);u.splice(a,1),u.splice(s,0,{...m,__temp_key__:h})}else u.splice(a,1),u.splice(s,0,m);te()(r,i,u);break}case"INIT_FORM":{const{initialValues:a,components:s={},attributes:c={},setModifiedDataOnly:i}=o,d=$e()(a),u=Xt(s,h=>h.type==="relation",(h,{path:g})=>t.modifiedData?.id===d.id&&Z()(t.modifiedData,g)?Z()(t.modifiedData,g):[])(d,c),E=Xt(s,h=>h.type==="dynamiczone"||h.type==="component"&&!h.repeatable,h=>Array.isArray(h)?h.map((g,b)=>({...g,__temp_key__:b})):{...h,__temp_key__:0})(u,c,{ignoreFalseyValues:!0});i||(r.initialData=E),r.modifiedData=E,r.formErrors={},r.modifiedDZName=null,r.shouldCheckErrors=!1;break}case"MOVE_COMPONENT_UP":case"MOVE_COMPONENT_DOWN":{const{currentIndex:a,dynamicZoneName:s,shouldCheckErrors:c}=o;c&&(r.shouldCheckErrors=!t.shouldCheckErrors);const i=t.modifiedData[s],d=o.type==="MOVE_COMPONENT_UP"?a-1:a+1,m=t.modifiedData[s][a],u=oa(i,a,d,m);te()(r,["modifiedData",o.dynamicZoneName],u);break}case"MOVE_FIELD":{const a=Z()(t,["modifiedData",...o.keys],[]).slice(),s=Z()(t,["modifiedData",...o.keys,o.dragIndex]),c=oa(a,o.dragIndex,o.overIndex,s);te()(r,["modifiedData",...o.keys],c);break}case"ON_CHANGE":{const[a]=o.keys;if(o.shouldSetInitialValue&&te()(r,["initialData",...o.keys],o.value),o.keys.length===2&&Z()(t,["modifiedData",a])===null){te()(r,["modifiedData",a],{[o.keys[1]]:o.value});break}te()(r,["modifiedData",...o.keys],o.value);break}case"REMOVE_COMPONENT_FROM_DYNAMIC_ZONE":{o.shouldCheckErrors&&(r.shouldCheckErrors=!t.shouldCheckErrors),r.modifiedData[o.dynamicZoneName].splice(o.index,1);break}case"REMOVE_COMPONENT_FROM_FIELD":{const a=["modifiedData",...o.keys];te()(r,a,null);break}case"REMOVE_PASSWORD_FIELD":{bu()(r,["modifiedData",...o.keys]);break}case"REMOVE_REPEATABLE_FIELD":{const a=o.keys.length-1,s=["modifiedData",...Ft()(o.keys,a)];Object.keys(t.formErrors).length>0&&(r.shouldCheckErrors=!t.shouldCheckErrors);const i=Z()(t,s).slice();i.splice(parseInt(o.keys[a],10),1),te()(r,s,i);break}case"SET_DEFAULT_DATA_STRUCTURES":{r.componentsDataStructure=o.componentsDataStructure,r.contentTypeDataStructure=o.contentTypeDataStructure;break}case"SET_FORM_ERRORS":{r.modifiedDZName=null,r.formErrors=o.errors;break}case"TRIGGER_FORM_VALIDATION":{Object.keys(t.formErrors).length>0&&(r.shouldCheckErrors=!t.shouldCheckErrors);break}case"SET_PUBLISH_CONFIRMATION":{r.publishConfirmation={...o.publishConfirmation};break}case"RESET_PUBLISH_CONFIRMATION":{r.publishConfirmation={...t.publishConfirmation,show:!1};break}default:return r}});const Io=({allLayoutData:t,allowedActions:{canRead:o,canUpdate:r},children:a,componentsDataStructure:s,contentTypeDataStructure:c,createActionAllowedFields:i,from:d,initialValues:m,isCreatingEntry:u,isLoadingForData:p,isSingleType:E,onPost:h,onPublish:g,onDraftRelationCheck:b,onPut:C,onUnpublish:I,readActionAllowedFields:v,redirectToPreviousPage:M,slug:x,status:j,updateActionAllowedFields:D})=>{const[O,N]=e.useState(!1),[w,T]=(0,e.useReducer)(Pu,Iu),{formErrors:S,initialData:G,modifiedData:$,modifiedDZName:X,shouldCheckErrors:Q,publishConfirmation:J}=w,{setModifiedDataOnly:A}=(0,ae.v9)(An),k=(0,ae.I0)(),R=(0,y.lm)(),{lockApp:F,unlockApp:U}=(0,y.o1)(),Y=Z()(t,["contentType"],{}),L=(0,e.useMemo)(()=>Z()(Y,["options","draftAndPublish"],!1),[Y]),B=(0,e.useMemo)(()=>L&&!G.publishedAt,[L,G.publishedAt]),{trackUsage:ne}=(0,y.rS)(),{formatMessage:ce}=(0,K.Z)(),ge=(0,e.useRef)(ne),V=(0,e.useMemo)(()=>p||u?!1:o===!1&&r===!1,[p,u,o,r]);(0,e.useEffect)(()=>{j==="resolved"?U():F()},[F,U,j]),(0,e.useEffect)(()=>{p||He()},[Q]),(0,e.useEffect)(()=>{const ee=Object.keys(S);if(ee.length>0){const _=ee[0],ie=document.getElementById(_);ie&&ie.focus()}},[S]),(0,e.useEffect)(()=>{V&&R({type:"info",message:{id:(0,f.OB)("permissions.not-allowed.update")}})},[V,R]),(0,e.useEffect)(()=>{T({type:"SET_DEFAULT_DATA_STRUCTURES",componentsDataStructure:s,contentTypeDataStructure:c})},[s,c]);const{components:z}=t,ye=(0,oe.zH)(m);(0,e.useEffect)(()=>{m&&Y?.attributes&&!ke()(ye,m)&&(T({type:"INIT_FORM",initialValues:m,components:z,attributes:Y.attributes,setModifiedDataOnly:A}),A&&k(Gl()))},[m,Y,z,A,k,ye]);const he=(0,e.useCallback)(ee=>(_,ie,Le,lt=!1,Nt=void 0)=>{ge.current("didAddComponentToDynamicZone"),T({type:ee,keys:_.split("."),position:Nt,componentLayoutData:ie,allComponents:Le,shouldCheckErrors:lt})},[]),Ne=he("ADD_COMPONENT_TO_DYNAMIC_ZONE"),Ue=(0,e.useCallback)((ee,_,ie)=>{T({type:"ADD_NON_REPEATABLE_COMPONENT_TO_FIELD",keys:ee.split("."),componentLayoutData:_,allComponents:ie})},[]),de=(0,e.useCallback)(({name:ee,value:_,toOneRelation:ie})=>{T({type:"CONNECT_RELATION",keys:ee.split("."),value:_,toOneRelation:ie})},[]),Ie=(0,e.useCallback)(({target:{initialDataPath:ee,modifiedDataPath:_,value:ie,modifiedDataOnly:Le}})=>{T({type:"LOAD_RELATION",modifiedDataPath:_,initialDataPath:ee,value:ie,modifiedDataOnly:Le})},[]),je=he("ADD_REPEATABLE_COMPONENT_TO_FIELD"),Pe=(0,e.useMemo)(()=>{const ee={isCreatingEntry:u,isDraft:B,isFromComponent:!1};return(0,f.Ex)(Y,{components:t.components||{}},ee)},[t.components,Y,u,B]),He=(0,e.useCallback)(async(ee={})=>{let _={};const ie=$e()($);Fe()(ie)||te()(ie,ee.path,ee.value);try{await Pe.validate(ie,{abortEarly:!1})}catch(Le){_=(0,y.CJ)(Le),X&&(_=Object.keys(_).reduce((lt,Nt)=>(Nt.split(".")[0]!==X&&(lt[Nt]=_[Nt]),lt),{}))}T({type:"SET_FORM_ERRORS",errors:_})},[X,$,Pe]),Rt=(0,e.useCallback)(({target:{name:ee,value:_,type:ie}},Le=!1)=>{let lt=_;if(["text","textarea","string","email","uid","select","select-one","number"].includes(ie)&&!_&&_!==0&&(lt=null),ie==="password"&&!_){T({type:"REMOVE_PASSWORD_FIELD",keys:ee.split(".")});return}T({type:"ON_CHANGE",keys:ee.split("."),value:lt,shouldSetInitialValue:Le})},[]),it=(0,e.useCallback)((ee,_)=>Ou({browserState:ee,serverState:_},Y,t.components),[t.components,Y]),fe=(0,e.useMemo)(()=>L?B?{status:"draft"}:{}:{},[L,B]),Me=(0,e.useCallback)(async ee=>(ee.preventDefault(),T({type:"RESET_PUBLISH_CONFIRMATION"})),[]),et=(0,e.useCallback)(async ee=>{ee.preventDefault();let _={};try{await Pe.validate($,{abortEarly:!1})}catch(ie){_=(0,y.CJ)(ie)}try{if(Fe()(_)){const ie=it($,G);(0,ta.flushSync)(()=>{N(!0)}),u?await h(ie,fe):await C(ie,fe),N(!1)}}catch(ie){N(!1),_={..._,...(0,y.nn)(ie,{getTrad:f.OB})}}T({type:"SET_FORM_ERRORS",errors:_})},[it,u,$,G,h,C,fe,Pe]),se=(0,e.useCallback)(async()=>{const ee=(0,f.Ex)(Y,{components:Z()(t,"components",{})},{isCreatingEntry:u,isDraft:!1,isFromComponent:!1}),_=await b();if(!J.show&&_>0){T({type:"SET_PUBLISH_CONFIRMATION",publishConfirmation:{show:!0,draftCount:_}});return}T({type:"RESET_PUBLISH_CONFIRMATION"});let ie={};try{await ee.validate($,{abortEarly:!1})}catch(Le){ie=(0,y.CJ)(Le)}try{Fe()(ie)&&((0,ta.flushSync)(()=>{N(!0)}),await g(),N(!1))}catch(Le){N(!1),ie={...ie,...(0,y.nn)(Le,{getTrad:f.OB})}}T({type:"SET_FORM_ERRORS",errors:ie})},[t,Y,u,$,J.show,g,b]),ue=(0,e.useCallback)(ee=>{const _=Object.keys(S).some(Le=>Le.split(".")[0]===ee);return!Fe()(S)&&_},[S]),Ee=(0,e.useCallback)((ee,_)=>{ge.current("changeComponentsOrder"),T({type:"MOVE_COMPONENT_DOWN",dynamicZoneName:ee,currentIndex:_,shouldCheckErrors:ue(ee)})},[ue]),ve=(0,e.useCallback)((ee,_)=>{ge.current("changeComponentsOrder"),T({type:"MOVE_COMPONENT_UP",dynamicZoneName:ee,currentIndex:_,shouldCheckErrors:ue(ee)})},[ue]),Bt=(0,e.useCallback)(({name:ee,newIndex:_,currentIndex:ie})=>{T({type:"MOVE_COMPONENT_FIELD",keys:ee.split("."),newIndex:_,oldIndex:ie})},[]),Jp=(0,e.useCallback)(({name:ee,id:_})=>{T({type:"DISCONNECT_RELATION",keys:ee.split("."),id:_})},[]),_p=(0,e.useCallback)(({name:ee,oldIndex:_,newIndex:ie})=>{T({type:"REORDER_RELATION",keys:ee.split("."),oldIndex:_,newIndex:ie})},[]),eg=(0,e.useCallback)((ee,_)=>{ge.current("removeComponentFromDynamicZone"),T({type:"REMOVE_COMPONENT_FROM_DYNAMIC_ZONE",dynamicZoneName:ee,index:_,shouldCheckErrors:ue(ee)})},[ue]),tg=(0,e.useCallback)((ee,_)=>{T({type:"REMOVE_COMPONENT_FROM_FIELD",keys:ee.split("."),componentUid:_})},[]),ng=(0,e.useCallback)((ee,_)=>{T({type:"REMOVE_REPEATABLE_FIELD",keys:ee.split("."),componentUid:_})},[]),og=(0,e.useCallback)(()=>{T({type:"TRIGGER_FORM_VALIDATION"})},[]);return V?e.createElement(re.l_,{to:d}):$?e.createElement(y.W1.Provider,{value:{addComponentToDynamicZone:Ne,addNonRepeatableComponentToField:Ue,addRepeatableComponentToField:je,allLayoutData:t,checkFormErrors:He,createActionAllowedFields:i,formErrors:S,hasDraftAndPublish:L,initialData:G,isCreatingEntry:u,isSingleType:E,shouldNotRunValidations:B,status:j,layout:Y,modifiedData:$,moveComponentField:Bt,moveComponentDown:Ee,moveComponentUp:ve,onChange:Rt,onPublish:se,onUnpublish:I,readActionAllowedFields:v,redirectToPreviousPage:M,removeComponentFromDynamicZone:eg,removeComponentFromField:tg,removeRepeatableField:ng,relationConnect:de,relationDisconnect:Jp,relationLoad:Ie,relationReorder:_p,slug:x,triggerFormValidation:og,updateActionAllowedFields:D,onPublishPromptDismissal:Me,publishConfirmation:J}},p||!u&&!G.id?e.createElement(Te.o,{"aria-busy":"true"},e.createElement(y.dO,null)):e.createElement(e.Fragment,null,O?null:e.createElement(re.NL,{when:!ke()($,G),message:ce({id:"global.prompt.unsaved"})}),e.createElement("form",{noValidate:!0,onSubmit:et},a))):null};Io.defaultProps={from:"/",initialValues:null,redirectToPreviousPage(){}},Io.propTypes={allLayoutData:n().object.isRequired,allowedActions:n().object.isRequired,children:n().node.isRequired,componentsDataStructure:n().object.isRequired,contentTypeDataStructure:n().object.isRequired,createActionAllowedFields:n().array.isRequired,from:n().string,initialValues:n().object,isCreatingEntry:n().bool.isRequired,isLoadingForData:n().bool.isRequired,isSingleType:n().bool.isRequired,onPost:n().func.isRequired,onPublish:n().func.isRequired,onDraftRelationCheck:n().func.isRequired,onPut:n().func.isRequired,onUnpublish:n().func.isRequired,readActionAllowedFields:n().array.isRequired,redirectToPreviousPage:n().func,slug:n().string.isRequired,status:n().string.isRequired,updateActionAllowedFields:n().array.isRequired};var xu=Io;const Zu=(t={})=>Object.values(t).reduce((o,r)=>Object.assign(o,r),{});var ra=(t={})=>{const{plugins:o,_q:r,...a}={...t,...Zu(t.plugins)};return r&&(a._q=encodeURIComponent(r)),a},st=t=>(0,f.IF)(`single-types/${t}`);const aa=({allLayoutData:t,children:o,slug:r})=>{const a=(0,Be.useQueryClient)(),{trackUsage:s}=(0,y.rS)(),{push:c}=(0,re.k6)(),{setCurrentStep:i}=(0,y.c1)(),d=(0,e.useRef)(s),[m,u]=(0,e.useState)(!0),[{query:p,rawQuery:E}]=(0,y.Kx)(),h=(0,e.useMemo)(()=>ra(p),[p]),g=(0,y.lm)(),b=(0,ae.I0)(),{formatAPIError:C}=(0,y.So)(f.OB),I=(0,y.kY)(),{post:v,put:M,del:x}=I,{componentsDataStructure:j,contentTypeDataStructure:D,data:O,isLoading:N,status:w}=(0,ae.v9)(An),T=(0,e.useCallback)(k=>{const R=(0,f.kc)(k,t.contentType,t.components);return(0,y.dU)(R,t.contentType,t.components)},[t]);(0,e.useEffect)(()=>()=>{b(Ir())},[b]),(0,e.useEffect)(()=>{const k=Object.keys(t.components).reduce((U,Y)=>{const L=(0,f.Di)(Z()(t,["components",Y,"attributes"],{}),t.components);return U[Y]=(0,y.dU)(L,t.components[Y],t.components),U},{}),R=(0,f.Di)(t.contentType.attributes,t.components),F=(0,y.dU)(R,t.contentType,t.components);b(Pr(k,F))},[t,b]),(0,e.useEffect)(()=>{const R=ze.default.CancelToken.source();return(async U=>{b(Ht()),u(!0);try{const{data:Y}=await I.get(st(r),{cancelToken:U.token,params:h});b(kn(T(Y))),u(!1)}catch(Y){if(ze.default.isCancel(Y))return;const L=Z()(Y,"response.status",null);L===404&&b(Fn(E,!0)),L===403&&(g({type:"info",message:{id:(0,f.OB)("permissions.not-allowed.update")}}),c("/"))}})(R),()=>R.cancel("Operation canceled by the user.")},[I,T,c,r,b,h,E,g]);const S=(0,e.useCallback)(k=>{g({type:"warning",message:C(k)})},[g,C]),G=(0,e.useCallback)(async k=>{try{d.current("willDeleteEntry",k);const{data:R}=await x(st(r),{params:h});return g({type:"success",message:{id:(0,f.OB)("success.record.delete")}}),d.current("didDeleteEntry",k),u(!0),b(Fn(E,!0)),Promise.resolve(R)}catch(R){return d.current("didNotDeleteEntry",{error:R,...k}),S(R),Promise.reject(R)}},[x,r,h,g,b,E,S]),$=(0,e.useCallback)(async(k,R)=>{const F=st(r);try{b(me("submit-pending"));const{data:U}=await M(F,k,{params:p});return d.current("didCreateEntry",R),g({type:"success",message:{id:(0,f.OB)("success.record.save")}}),i("contentManager.success"),a.invalidateQueries(["relation"]),b(Je(T(U))),u(!1),b(me("resolved")),Promise.resolve(U)}catch(U){return d.current("didNotCreateEntry",{error:U,trackerProperty:R}),S(U),b(me("resolved")),Promise.reject(U)}},[M,T,S,r,b,p,g,i,a]),X=(0,e.useCallback)(async()=>{try{d.current("willCheckDraftRelations");const k=st(`${r}/actions/countDraftRelations`);b(me("draft-relation-check-pending"));const R=await I.get(k);return d.current("didCheckDraftRelations"),b(me("resolved")),R.data.data}catch(k){return S(k),b(me("resolved")),Promise.reject(k)}},[I,S,r,b]),Q=(0,e.useCallback)(async()=>{try{d.current("willPublishEntry");const k=st(`${r}/actions/publish`);b(me("publish-pending"));const{data:R}=await v(k,{},{params:h});return d.current("didPublishEntry"),g({type:"success",message:{id:(0,f.OB)("success.record.publish")}}),b(Je(T(R))),b(me("resolved")),Promise.resolve(R)}catch(k){return S(k),b(me("resolved")),Promise.reject(k)}},[r,b,v,h,g,T,S]),J=(0,e.useCallback)(async(k,R)=>{const F=st(r);try{d.current("willEditEntry",R),b(me("submit-pending"));const{data:U}=await M(F,k,{params:p});return g({type:"success",message:{id:(0,f.OB)("success.record.save")}}),d.current("didEditEntry",{trackerProperty:R}),a.invalidateQueries(["relation"]),b(Je(T(U))),b(me("resolved")),Promise.resolve(U)}catch(U){return S(U),d.current("didNotEditEntry",{error:U,trackerProperty:R}),b(me("resolved")),Promise.reject(U)}},[M,T,S,r,b,p,g,a]),A=(0,e.useCallback)(async()=>{const k=st(`${r}/actions/unpublish`);b(me("unpublish-pending"));try{d.current("willUnpublishEntry");const{data:R}=await v(k,{},{params:h});d.current("didUnpublishEntry"),g({type:"success",message:{id:(0,f.OB)("success.record.unpublish")}}),b(Je(T(R))),b(me("resolved"))}catch(R){b(me("resolved")),S(R)}},[r,b,v,h,g,T,S]);return o({componentsDataStructure:j,contentTypeDataStructure:D,data:O,isCreatingEntry:m,isLoadingForData:N,onDelete:G,onPost:$,onDraftRelationCheck:X,onPublish:Q,onPut:J,onUnpublish:A,redirectionLink:"/",status:w})};aa.propTypes={allLayoutData:n().shape({components:n().object.isRequired,contentType:n().object.isRequired}).isRequired,children:n().func.isRequired,slug:n().string.isRequired};var Lu=(0,e.memo)(aa);function Su(t,o){return r=>{const a=o();return e.createElement(t,{...r,...a})}}var ku=Su;function Fu(){const{hasDraftAndPublish:t,modifiedData:o}=(0,y.Wq)();let r={};return t&&(r=Fe()(o.publishedAt)?{status:"draft"}:{status:"published"}),{hasDraftAndPublish:t,trackerProperty:r}}var Au=Fu;const sa=({onDelete:t,trackerProperty:o})=>{const[r,a]=(0,e.useState)(!1),[s,c]=(0,e.useState)(!1),{formatMessage:i}=(0,K.Z)(),{formatAPIError:d}=(0,y.So)(f.OB),m=(0,y.lm)(),u=()=>a(E=>!E),p=async()=>{try{c(!0),await t(o),c(!1),u()}catch(E){c(!1),u(),m({type:"warning",message:d(E)})}};return e.createElement(e.Fragment,null,e.createElement(le.z,{onClick:u,size:"S",startIcon:e.createElement(Ve.Z,null),variant:"danger-light"},i({id:(0,f.OB)("containers.Edit.delete-entry"),defaultMessage:"Delete this entry"})),e.createElement(y.QH,{isConfirmButtonLoading:s,isOpen:r,onConfirm:p,onToggleDialog:u}))};sa.propTypes={onDelete:n().func.isRequired,trackerProperty:n().object.isRequired};const wu=(0,e.memo)(sa,ke());var $u=ku(wu,Au),Bu=l(56243);function Nu(t,o){return r=>{const a=o();return e.createElement(t,{...r,...a})}}var ju=Nu;function Wu(){const{initialData:t,hasDraftAndPublish:o}=(0,y.Wq)(),r=t.publishedAt!==void 0&&t.publishedAt!==null;return{hasDraftAndPublish:o,isPublished:r}}var zu=Wu;const Uu=(0,q.ZP)(Bu.Z)`
|
|
948
|
+
width: ${(0,y.Q1)(6)};
|
|
949
|
+
height: ${(0,y.Q1)(6)};
|
|
950
|
+
* {
|
|
951
|
+
fill: ${({theme:t,$bulletColor:o})=>t.colors[o]};
|
|
952
|
+
}
|
|
953
|
+
`,ia=({hasDraftAndPublish:t,isPublished:o})=>{const{formatMessage:r}=(0,K.Z)();if(!t)return null;const a={draft:{textColor:"secondary700",bulletColor:"secondary600",box:{background:"secondary100",borderColor:"secondary200"}},published:{textColor:"success700",bulletColor:"success600",box:{background:"success100",borderColor:"success200"}}},s=o?a.published:a.draft;return e.createElement(H.x,{hasRadius:!0,as:"aside",paddingTop:4,paddingBottom:4,paddingLeft:5,paddingRight:5,...s.box},e.createElement(H.x,{as:P.k},e.createElement(Uu,{$bulletColor:s.bulletColor}),e.createElement(H.x,{paddingLeft:3},e.createElement(W.Z,{textColor:s.textColor},r({id:(0,f.OB)("containers.Edit.information.editing"),defaultMessage:"Editing"}),"\xA0"),e.createElement(W.Z,{fontWeight:"bold",textColor:s.textColor},o&&r({id:(0,f.OB)("containers.Edit.information.publishedVersion"),defaultMessage:"published version"}),!o&&r({id:(0,f.OB)("containers.Edit.information.draftVersion"),defaultMessage:"draft version"})))))};ia.propTypes={hasDraftAndPublish:n().bool.isRequired,isPublished:n().bool.isRequired};var Vu=ju(ia,zu);const Po=({columns:t,customFieldInputs:o})=>e.createElement(Oe.r,{gap:4},t.map(({fieldSchema:r,labelAction:a,metadatas:s,name:c,size:i,queryInfos:d})=>{if(r.type==="component"){const{component:u,max:p,min:E,repeatable:h=!1,required:g=!1}=r;return e.createElement(be.P,{col:i,s:12,xs:12,key:u},e.createElement(Yt,{componentUid:u,labelAction:a,isRepeatable:h,intlLabel:{id:s.label,defaultMessage:s.label},max:p,min:E,name:c,required:g}))}return e.createElement(be.P,{col:i,key:c,s:12,xs:12},e.createElement(ho,{size:i,fieldSchema:r,keys:c,labelAction:a,metadatas:s,queryInfos:d,customFieldInputs:o}))}));Po.defaultProps={customFieldInputs:{}},Po.propTypes={columns:n().array.isRequired,customFieldInputs:n().object};var qu=Po,Jt=l(22342),_t=l(96166),en=l(88693);function Hu(t,o){return r=>{const a=o();return e.createElement(t,{...r,...a})}}var Gu=Hu;function Qu(){const{initialData:t,isCreatingEntry:o,isSingleType:r,status:a,layout:s,hasDraftAndPublish:c,modifiedData:i,onPublish:d,onUnpublish:m,publishConfirmation:u,onPublishPromptDismissal:p}=(0,y.Wq)();return{initialData:t,isCreatingEntry:o,isSingleType:r,status:a,layout:s,hasDraftAndPublish:c,modifiedData:i,onPublish:d,onUnpublish:m,publishConfirmation:u,onPublishPromptDismissal:p}}var Ku=Qu;const la=(0,q.ZP)(P.k)`
|
|
954
|
+
text-align: center;
|
|
955
|
+
`,ca=({allowedActions:{canUpdate:t,canCreate:o,canPublish:r},initialData:a,isCreatingEntry:s,isSingleType:c,hasDraftAndPublish:i,layout:d,modifiedData:m,onPublish:u,onUnpublish:p,status:E,publishConfirmation:{show:h,draftCount:g},onPublishPromptDismissal:b})=>{const{goBack:C}=(0,re.k6)(),[I,v]=(0,e.useState)(!1),{formatMessage:M}=(0,K.Z)(),x=Z()(d,["settings","mainField"],"id"),j=Z()(d,["info","displayName"],"NOT FOUND"),D=!ke()(a,m)||s&&!Fe()(m);let N=M({id:(0,f.OB)("containers.Edit.pluginHeader.title.new"),defaultMessage:"Create an entry"});!s&&!c&&(N=a[x]||j),c&&(N=j);let w=null;if(s&&o&&(w=e.createElement(P.k,{gap:2},i&&e.createElement(le.z,{disabled:!0,startIcon:e.createElement(we.Z,null),variant:"secondary"},M({id:"app.utils.publish",defaultMessage:"Publish"})),e.createElement(le.z,{disabled:!D,loading:E==="submit-pending",type:"submit"},M({id:(0,f.OB)("containers.Edit.submit"),defaultMessage:"Save"})))),!s&&t){const $=i&&r,X=!Fe()(a.publishedAt),Q=X?E==="unpublish-pending":E==="publish-pending",J=X?{id:"app.utils.unpublish",defaultMessage:"Unpublish"}:{id:"app.utils.publish",defaultMessage:"Publish"},A=X?()=>v(!0):()=>u();w=e.createElement(P.k,null,$&&e.createElement(le.z,{disabled:D,loading:Q,onClick:A,startIcon:e.createElement(we.Z,null),variant:"secondary"},M(J)),e.createElement(H.x,{paddingLeft:$?2:0},e.createElement(le.z,{disabled:!D,loading:E==="submit-pending",type:"submit"},M({id:(0,f.OB)("containers.Edit.submit"),defaultMessage:"Save"}))))}const T=()=>v($=>!$),S=()=>{T(),p()},G=`${M({id:(0,f.OB)("api.id"),defaultMessage:"API ID "})} : ${d.apiID}`;return e.createElement(e.Fragment,null,e.createElement(De.T,{title:N.toString(),primaryAction:w,subtitle:G,navigationAction:e.createElement(y.rU,{startIcon:e.createElement(ot.Z,null),onClick:$=>{$.preventDefault(),C()},to:"/"},M({id:"global.back",defaultMessage:"Back"}))}),e.createElement(Jt.V,{onClose:T,title:"Confirmation",labelledBy:"confirmation",describedBy:"confirm-description",isOpen:I},e.createElement(_t.a,{icon:e.createElement(At.Z,null)},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(P.k,{justifyContent:"center",style:{textAlign:"center"}},e.createElement(W.Z,{id:"confirm-description"},M({id:(0,f.OB)("popUpWarning.warning.unpublish"),defaultMessage:"Unpublish this content will automatically change it to a draft."},{br:()=>e.createElement("br",null)}))),e.createElement(P.k,{justifyContent:"center",style:{textAlign:"center"}},e.createElement(W.Z,{id:"confirm-description"},M({id:(0,f.OB)("popUpWarning.warning.unpublish-question"),defaultMessage:"Are you sure you want to unpublish it?"}))))),e.createElement(en.c,{startAction:e.createElement(le.z,{onClick:T,variant:"tertiary"},M({id:"components.popUpWarning.button.cancel",defaultMessage:"Cancel"})),endAction:e.createElement(le.z,{variant:"danger-light",onClick:S},M({id:"components.popUpWarning.button.confirm",defaultMessage:"Confirm"}))})),e.createElement(Jt.V,{onClose:b,title:M({id:(0,f.OB)("popUpWarning.warning.has-draft-relations.title"),defaultMessage:"Confirmation"}),labelledBy:"confirmation",describedBy:"confirm-description",isOpen:h},e.createElement(_t.a,{icon:e.createElement(At.Z,null)},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(la,{justifyContent:"center"},e.createElement(W.Z,{id:"confirm-description"},g,M({id:(0,f.OB)("popUpwarning.warning.has-draft-relations.message"),defaultMessage:"<b>{count, plural, one { relation is} other { relations are}}</b> not published yet and might lead to unexpected behavior."},{b:$=>e.createElement(W.Z,{fontWeight:"bold"},$),count:g}))),e.createElement(la,{justifyContent:"center"},e.createElement(W.Z,{id:"confirm-description"},M({id:(0,f.OB)("popUpWarning.warning.publish-question"),defaultMessage:"Do you still want to publish?"}))))),e.createElement(en.c,{startAction:e.createElement(le.z,{onClick:b,variant:"tertiary"},M({id:"components.popUpWarning.button.cancel",defaultMessage:"Cancel"})),endAction:e.createElement(le.z,{variant:"success",onClick:u},M({id:(0,f.OB)("popUpwarning.warning.has-draft-relations.button-confirm"),defaultMessage:"Publish"}))})))};ca.propTypes={allowedActions:n().shape({canUpdate:n().bool.isRequired,canCreate:n().bool.isRequired,canPublish:n().bool.isRequired}).isRequired,initialData:n().object.isRequired,isCreatingEntry:n().bool.isRequired,isSingleType:n().bool.isRequired,status:n().string.isRequired,layout:n().object.isRequired,hasDraftAndPublish:n().bool.isRequired,modifiedData:n().object.isRequired,onPublish:n().func.isRequired,onUnpublish:n().func.isRequired,publishConfirmation:n().shape({show:n().bool.isRequired,draftCount:n().number.isRequired}).isRequired,onPublishPromptDismissal:n().func.isRequired};const Yu=(0,e.memo)(ca,ke());var Xu=Gu(Yu,Ku);const Ju=t=>(0,e.useEffect)(t,_u),_u=[];var xo=l(98865);function em(){return e.createElement(xo.d.Root,null,e.createElement(xo.d.Title,null),e.createElement(xo.d.Body,null))}var Zo=l(98178),tm=t=>{if(!t.layouts)return[];const o=t.layouts.edit,r=t.attributes,a=i=>Z()(r,[i,"type"],"");let s=0;const c=[];return o.forEach(i=>{const d=i.some(({name:m})=>a(m)==="dynamiczone");c[s]||(c[s]=[]),d?(s=s===0&&Fe()(c[0])?0:s+1,c[s]||(c[s]=[]),c[s].push(i),s+=1):c[s].push(i)}),c.filter(i=>i.length>0)},nm=t=>{if(!t)return[];const r=[...t.contentType.layouts.edit,...Object.values(t.components).flatMap(s=>s.layouts.edit)].flat().filter(s=>s.fieldSchema.customField).map(s=>s.fieldSchema.customField);return[...new Set(r)]},om=l(91815),rm=l.n(om),am=(t,o)=>{const r=a=>{const s=(0,y.ZT)(t,[{action:`plugin::content-manager.explorer.${a}`,subject:o}]);return rm()(Wt()(s,"properties.fields"))};return{createActionAllowedFields:r("create"),readActionAllowedFields:r("read"),updateActionAllowedFields:r("update")}};const Lo=t=>t["content-manager_editViewLayoutManager"].currentLayout,sm=(0,Zo.P1)(Lo,t=>tm(t?.contentType??{})),im=(0,Zo.P1)(Lo,t=>nm(t)),lm=[{action:"plugin::content-type-builder.read",subject:null}],So=({allowedActions:t,isSingleType:o,goBack:r,slug:a,id:s,origin:c,userPermissions:i})=>{const{trackUsage:d}=(0,y.rS)(),{formatMessage:m}=(0,K.Z)(),u=(0,ae.v9)(We._),p=(0,re.TH)(),E=(0,y.lm)(),h=(0,Sn.c)(em,async()=>(await l.e(5483).then(l.bind(l,90978))).InformationBoxEE);Ju(()=>{p?.state&&"error"in p.state&&E({type:"warning",message:p.state.error,timeout:5e3})});const{layout:g,formattedContentTypeLayout:b,customFieldUids:C}=(0,ae.v9)(T=>({layout:Lo(T),formattedContentTypeLayout:sm(T),customFieldUids:im(T)})),{isLazyLoading:I,lazyComponentStore:v}=Gn(C),{createActionAllowedFields:M,readActionAllowedFields:x,updateActionAllowedFields:j}=am(i,a),D=o?u.contentManager.singleTypesConfigurations:u.contentManager.collectionTypesConfigurations,O=`/content-manager/${o?"singleType":"collectionType"}/${a}/configurations/edit`,N=o?Lu:Ql,w=T=>T.every(S=>S.every(G=>G.fieldSchema.type==="dynamiczone"));return I?e.createElement(y.dO,null):h?e.createElement(N,{allLayoutData:g,slug:a,id:s,origin:c},({componentsDataStructure:T,contentTypeDataStructure:S,data:G,isCreatingEntry:$,isLoadingForData:X,onDelete:Q,onPost:J,onPublish:A,onDraftRelationCheck:k,onPut:R,onUnpublish:F,redirectionLink:U,status:Y})=>e.createElement(xu,{allowedActions:t,allLayoutData:g,createActionAllowedFields:M,componentsDataStructure:T,contentTypeDataStructure:S,from:U,initialValues:G,isCreatingEntry:$,isLoadingForData:X,isSingleType:o,onPost:J,onPublish:A,onDraftRelationCheck:k,onPut:R,onUnpublish:F,readActionAllowedFields:x,redirectToPreviousPage:r,slug:a,status:Y,updateActionAllowedFields:j},e.createElement(Te.o,{"aria-busy":Y!=="resolved"},e.createElement(Xu,{allowedActions:t}),e.createElement(Qe.D,null,e.createElement(Oe.r,{gap:4},e.createElement(be.P,{col:9,s:12},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:6},b.map((L,B)=>{if(w(L)){const{0:{0:{name:ne,fieldSchema:ce,metadatas:ge,labelAction:V}}}=L;return e.createElement(H.x,{key:B},e.createElement(Oe.r,{gap:4},e.createElement(be.P,{col:12,s:12,xs:12},e.createElement(Do,{name:ne,fieldSchema:ce,labelAction:V,metadatas:ge}))))}return e.createElement(H.x,{key:B,hasRadius:!0,background:"neutral0",shadow:"tableShadow",paddingLeft:6,paddingRight:6,paddingTop:6,paddingBottom:6,borderColor:"neutral150"},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:6},L.map((ne,ce)=>e.createElement(qu,{columns:ne,customFieldInputs:v,key:ce}))))}))),e.createElement(be.P,{col:3,s:12},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(Vu,null),e.createElement(H.x,{as:"aside","aria-labelledby":"additional-information",background:"neutral0",borderColor:"neutral150",hasRadius:!0,paddingBottom:4,paddingLeft:4,paddingRight:4,paddingTop:6,shadow:"tableShadow"},e.createElement(h,null),e.createElement(qt,{area:"contentManager.editView.informations"})),e.createElement(H.x,{as:"aside","aria-labelledby":"links"},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(qt,{area:"contentManager.editView.right-links",slug:a}),a!=="strapi::administrator"&&e.createElement(y.jW,{permissions:lm},e.createElement(y.Qj,{onClick:()=>{d("willEditEditLayout")},size:"S",startIcon:e.createElement(Ke.Z,null),style:{width:"100%"},to:`/plugins/content-type-builder/content-types/${a}`,variant:"secondary"},m({id:(0,f.OB)("link-to-ctb"),defaultMessage:"Edit the model"}))),e.createElement(y.jW,{permissions:D},e.createElement(y.Qj,{size:"S",startIcon:e.createElement(ir.Z,null),style:{width:"100%"},to:O,variant:"secondary"},m({id:"app.links.configure-view",defaultMessage:"Configure the view"}))),t.canDelete&&!$&&e.createElement($u,{onDelete:Q})))))))))):null};So.defaultProps={id:null,isSingleType:!1,origin:null,userPermissions:[]},So.propTypes={allowedActions:n().shape({canRead:n().bool.isRequired,canUpdate:n().bool.isRequired,canCreate:n().bool.isRequired,canDelete:n().bool.isRequired}).isRequired,id:n().string,isSingleType:n().bool,goBack:n().func.isRequired,origin:n().string,slug:n().string.isRequired,userPermissions:n().array};var cm=So;const ko=t=>{const o=(0,e.useMemo)(()=>(0,f.TA)(t.slug),[t.slug]),{isLoading:r,allowedActions:a}=(0,y.ss)(o,t.userPermissions);return r?e.createElement(y.dO,null):e.createElement(cm,{...t,allowedActions:a})};ko.defaultProps={permissions:[]},ko.propTypes={permissions:n().array,slug:n().string.isRequired,userPermissions:n().array.isRequired};var dm=(0,e.memo)(ko,ke()),um=l(53634);const da=({layout:t,...o})=>{const r=(0,ae.v9)(um.Z),a=(0,ae.I0)(),[{query:s}]=(0,y.Kx)(),{runHookWaterfall:c}=(0,y.j1)(),i=(0,oe.r5)(s,o.slug,"editView");return(0,e.useEffect)(()=>{const d=c(Vt.Eo,{layout:t,query:s});return a(Vl(d.layout,s)),()=>{a(Ul())}},[t,a,s,c]),!r||!i?e.createElement(y.dO,null):e.createElement(dm,{...o,userPermissions:i})};da.propTypes={layout:n().shape({components:n().object.isRequired,contentType:n().shape({uid:n().string.isRequired,settings:n().object.isRequired,metadatas:n().object.isRequired,options:n().object.isRequired,attributes:n().object.isRequired}).isRequired}).isRequired};var tn=da,Fo=l(33348);const mm=(0,q.ZP)(P.k)`
|
|
956
|
+
svg {
|
|
957
|
+
width: ${32/16}rem;
|
|
958
|
+
height: ${24/16}rem;
|
|
959
|
+
margin-right: ${({theme:t})=>t.spaces[3]};
|
|
960
|
+
}
|
|
961
|
+
`,ua=({attributes:t,fieldForm:o,fieldToEdit:r,onCloseModal:a,onChangeEditLabel:s,onSubmit:c,type:i})=>{const{formatMessage:d}=(0,K.Z)(),m=t[r].relationType;let u=!["media","relation"].includes(i);return["oneWay","oneToOne","manyToOne"].includes(m)&&(u=!0),e.createElement(yn.P,{onClose:a,labelledBy:"title"},e.createElement("form",{onSubmit:c},e.createElement(En.x,null,e.createElement(mm,null,e.createElement(vr,{type:i}),e.createElement(W.Z,{fontWeight:"bold",textColor:"neutral800",as:"h2",id:"title"},d({id:(0,f.OB)("containers.ListSettingsView.modal-form.edit-label"),defaultMessage:"Edit {fieldName}"},{fieldName:Pt()(r)})))),e.createElement(bn.f,null,e.createElement(Oe.r,{gap:4},e.createElement(be.P,{s:12,col:6},e.createElement(Tn.o,{id:"label-input",label:d({id:(0,f.OB)("form.Input.label"),defaultMessage:"Label"}),name:"label",onChange:p=>s(p),value:o.label,hint:d({id:(0,f.OB)("form.Input.label.inputDescription"),defaultMessage:"This value overrides the label displayed in the table's head"})})),u&&e.createElement(be.P,{s:12,col:6},e.createElement(St.s,{"data-testid":"Enable sort on this field",checked:o.sortable,label:d({id:(0,f.OB)("form.Input.sort.field"),defaultMessage:"Enable sort on this field"}),name:"sortable",onChange:p=>s({target:{name:"sortable",value:p.target.checked}}),onLabel:d({id:"app.components.ToggleCheckbox.on-label",defaultMessage:"on"}),offLabel:d({id:"app.components.ToggleCheckbox.off-label",defaultMessage:"off"})})))),e.createElement(vn.m,{startActions:e.createElement(le.z,{onClick:a,variant:"tertiary"},d({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endActions:e.createElement(le.z,{type:"submit"},d({id:"global.finish",defaultMessage:"Finish"}))})))};ua.propTypes={attributes:n().objectOf(n().shape({relationType:n().string})).isRequired,fieldForm:n().shape({label:n().string,sortable:n().bool}).isRequired,fieldToEdit:n().string.isRequired,onChangeEditLabel:n().func.isRequired,onCloseModal:n().func.isRequired,onSubmit:n().func.isRequired,type:n().string.isRequired};var pm=ua;const Ao=({modifiedData:t,onChange:o,sortOptions:r})=>{const{formatMessage:a}=(0,K.Z)(),{settings:s,metadatas:c}=t;return e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:4},e.createElement(W.Z,{variant:"delta",as:"h2"},a({id:(0,f.OB)("containers.SettingPage.settings"),defaultMessage:"Settings"})),e.createElement(P.k,{justifyContent:"space-between",gap:4},e.createElement(H.x,{width:"100%"},e.createElement(St.s,{label:a({id:(0,f.OB)("form.Input.search"),defaultMessage:"Enable search"}),onChange:i=>{o({target:{name:"settings.searchable",value:i.target.checked}})},onLabel:a({id:"app.components.ToggleCheckbox.on-label",defaultMessage:"on"}),offLabel:a({id:"app.components.ToggleCheckbox.off-label",defaultMessage:"off"}),name:"settings.searchable",checked:s.searchable})),e.createElement(H.x,{width:"100%"},e.createElement(St.s,{label:a({id:(0,f.OB)("form.Input.filters"),defaultMessage:"Enable filters"}),onChange:i=>{o({target:{name:"settings.filterable",value:i.target.checked}})},onLabel:a({id:"app.components.ToggleCheckbox.on-label",defaultMessage:"on"}),offLabel:a({id:"app.components.ToggleCheckbox.off-label",defaultMessage:"off"}),name:"settings.filterable",checked:s.filterable})),e.createElement(H.x,{width:"100%"},e.createElement(St.s,{label:a({id:(0,f.OB)("form.Input.bulkActions"),defaultMessage:"Enable bulk actions"}),onChange:i=>{o({target:{name:"settings.bulkable",value:i.target.checked}})},onLabel:a({id:"app.components.ToggleCheckbox.on-label",defaultMessage:"on"}),offLabel:a({id:"app.components.ToggleCheckbox.off-label",defaultMessage:"off"}),name:"settings.bulkable",checked:s.bulkable}))),e.createElement(Oe.r,{gap:4},e.createElement(be.P,{s:12,col:6},e.createElement(Ae.P,{label:a({id:(0,f.OB)("form.Input.pageEntries"),defaultMessage:"Entries per page"}),hint:a({id:(0,f.OB)("form.Input.pageEntries.inputDescription"),defaultMessage:"Note: You can override this value in the Collection Type settings page."}),onChange:i=>o({target:{name:"settings.pageSize",value:i}}),name:"settings.pageSize",value:t.settings.pageSize||""},[10,20,50,100].map(i=>e.createElement(Ce.W,{key:i,value:i},i)))),e.createElement(be.P,{s:12,col:3},e.createElement(Ae.P,{label:a({id:(0,f.OB)("form.Input.defaultSort"),defaultMessage:"Default sort attribute"}),onChange:i=>o({target:{name:"settings.defaultSortBy",value:i}}),name:"settings.defaultSortBy",value:t.settings.defaultSortBy||""},r.map(i=>e.createElement(Ce.W,{key:i,value:i},c[i].list.label||i)))),e.createElement(be.P,{s:12,col:3},e.createElement(Ae.P,{label:a({id:(0,f.OB)("form.Input.sort.order"),defaultMessage:"Default sort order"}),onChange:i=>o({target:{name:"settings.defaultSortOrder",value:i}}),name:"settings.defaultSortOrder",value:t.settings.defaultSortOrder||""},["ASC","DESC"].map(i=>e.createElement(Ce.W,{key:i,value:i},i))))))};Ao.defaultProps={modifiedData:{},sortOptions:[]},Ao.propTypes={modifiedData:n().object,onChange:n().func.isRequired,sortOptions:n().array};var gm=Ao;const wo=(0,q.ZP)(P.k)`
|
|
962
|
+
height: ${({theme:t})=>t.spaces[7]};
|
|
963
|
+
|
|
964
|
+
&:last-child {
|
|
965
|
+
padding: 0 ${({theme:t})=>t.spaces[3]};
|
|
966
|
+
}
|
|
967
|
+
`,fm=(0,q.ZP)(wo)`
|
|
968
|
+
border-right: 1px solid
|
|
969
|
+
${({theme:t,isSibling:o})=>o?t.colors.neutral150:t.colors.primary200};
|
|
970
|
+
|
|
971
|
+
svg {
|
|
972
|
+
width: ${12/16}rem;
|
|
973
|
+
height: ${12/16}rem;
|
|
974
|
+
}
|
|
975
|
+
`,hm=(0,q.ZP)(P.k)`
|
|
976
|
+
border: 1px solid
|
|
977
|
+
${({theme:t,isSibling:o})=>o?t.colors.neutral150:t.colors.primary200};
|
|
978
|
+
|
|
979
|
+
svg {
|
|
980
|
+
width: ${10/16}rem;
|
|
981
|
+
height: ${10/16}rem;
|
|
982
|
+
|
|
983
|
+
path {
|
|
984
|
+
fill: ${({theme:t,isSibling:o})=>o?void 0:t.colors.primary600};
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
`,ym=(0,q.ZP)(W.Z)`
|
|
988
|
+
max-width: ${72/16}rem;
|
|
989
|
+
`;function $t({labelField:t,transparent:o,isSibling:r}){return e.createElement(hm,{background:r?"neutral100":"primary100",display:"inline-flex",gap:3,hasRadius:!0,justifyContent:"space-between",transparent:o,isSibling:r,"max-height":(0,y.Q1)(32),maxWidth:"min-content",opacity:o?0:1},e.createElement(P.k,{gap:3},e.createElement(fm,{alignItems:"center",cursor:"all-scroll",padding:3},e.createElement(Ye.Z,null)),e.createElement(ym,{textColor:r?void 0:"primary600",fontWeight:"bold",ellipsis:!0},t)),e.createElement(P.k,null,e.createElement(wo,{alignItems:"center"},e.createElement(Ke.Z,null)),e.createElement(wo,{alignItems:"center"},e.createElement(Gt.Z,null))))}$t.defaultProps={isSibling:!1,transparent:!1},$t.propTypes={isSibling:n().bool,labelField:n().string.isRequired,transparent:n().bool};const $o=q.ZP.button`
|
|
990
|
+
display: flex;
|
|
991
|
+
align-items: center;
|
|
992
|
+
height: ${({theme:t})=>t.spaces[7]};
|
|
993
|
+
|
|
994
|
+
&:last-child {
|
|
995
|
+
padding: 0 ${({theme:t})=>t.spaces[3]};
|
|
996
|
+
}
|
|
997
|
+
`,ma=(0,q.ZP)($o)`
|
|
998
|
+
padding: 0 ${({theme:t})=>t.spaces[3]};
|
|
999
|
+
border-right: 1px solid ${({theme:t})=>t.colors.neutral150};
|
|
1000
|
+
cursor: all-scroll;
|
|
1001
|
+
|
|
1002
|
+
svg {
|
|
1003
|
+
width: ${12/16}rem;
|
|
1004
|
+
height: ${12/16}rem;
|
|
1005
|
+
}
|
|
1006
|
+
`,Em=(0,q.ZP)(P.k)`
|
|
1007
|
+
max-height: ${32/16}rem;
|
|
1008
|
+
cursor: pointer;
|
|
1009
|
+
|
|
1010
|
+
svg {
|
|
1011
|
+
width: ${10/16}rem;
|
|
1012
|
+
height: ${10/16}rem;
|
|
1013
|
+
|
|
1014
|
+
path {
|
|
1015
|
+
fill: ${({theme:t})=>t.colors.neutral600};
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
&:hover {
|
|
1020
|
+
background-color: ${({theme:t})=>t.colors.primary100};
|
|
1021
|
+
border-color: ${({theme:t})=>t.colors.primary200};
|
|
1022
|
+
|
|
1023
|
+
svg {
|
|
1024
|
+
path {
|
|
1025
|
+
fill: ${({theme:t})=>t.colors.primary600};
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
${W.Z} {
|
|
1030
|
+
color: ${({theme:t})=>t.colors.primary600};
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
${ma} {
|
|
1034
|
+
border-right: 1px solid ${({theme:t})=>t.colors.primary200};
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
`,bm=(0,q.ZP)(H.x)`
|
|
1038
|
+
&:last-child {
|
|
1039
|
+
padding-right: ${({theme:t})=>t.spaces[3]};
|
|
1040
|
+
}
|
|
1041
|
+
`,pa=({index:t,isDraggingSibling:o,labelField:r,onClickEditField:a,onMoveField:s,onRemoveField:c,name:i,setIsDraggingSibling:d})=>{const{formatMessage:m}=(0,K.Z)(),u=(0,e.useRef)(null),p=(0,e.useRef)(null),[,E]=(0,e.useState)(!1),h=(0,e.useRef)(),g=()=>{h.current&&h.current.click()},[,b]=(0,zt.useDrop)({accept:f._Q.FIELD,hover(x,j){if(!p.current)return;const D=x.index,O=t;if(D===O)return;const N=p.current.getBoundingClientRect(),w=(N.right-N.left)/2,S=j.getClientOffset().x-N.left;D>O&&S>w||D<O&&S<w||(s(D,O),x.index=O)}}),[{isDragging:C},I,v]=(0,zt.useDrag)({type:f._Q.FIELD,item(){return{index:t,labelField:r,name:i}},collect:x=>({isDragging:x.isDragging()}),end(){d(!1)}});(0,e.useEffect)(()=>{v((0,xt.rX)(),{captureDraggingState:!1})},[v]),(0,e.useEffect)(()=>{C&&d(!0)},[C,d]),(0,e.useEffect)(()=>{o||E(x=>!x)},[o]);const M={dragRef:I(u),dropRef:b(p)};return e.createElement(bm,{ref:M?M.dropRef:null},C&&e.createElement($t,{transparent:!0,labelField:r}),!C&&o&&e.createElement($t,{isSibling:!0,labelField:r}),!C&&!o&&e.createElement(Em,{borderColor:"neutral150",background:"neutral100",hasRadius:!0,justifyContent:"space-between",onClick:g,isDragging:C},e.createElement(P.k,{gap:3},e.createElement(ma,{as:"span","aria-label":m({id:(0,f.OB)("components.DraggableCard.move.field"),defaultMessage:"Move {item}"},{item:r}),onClick:x=>x.stopPropagation(),ref:M.dragRef,type:"button"},e.createElement(Ye.Z,null)),e.createElement(W.Z,{fontWeight:"bold"},r)),e.createElement(P.k,{paddingLeft:3},e.createElement($o,{ref:h,onClick:x=>{x.stopPropagation(),a(i)},"aria-label":m({id:(0,f.OB)("components.DraggableCard.edit.field"),defaultMessage:"Edit {item}"},{item:r}),type:"button"},e.createElement(Ke.Z,null)),e.createElement($o,{onClick:c,"data-testid":`delete-${i}`,"aria-label":m({id:(0,f.OB)("components.DraggableCard.delete.field"),defaultMessage:"Delete {item}"},{item:r}),type:"button"},e.createElement(Gt.Z,null)))))};pa.propTypes={index:n().number.isRequired,isDraggingSibling:n().bool.isRequired,labelField:n().string.isRequired,name:n().string.isRequired,onClickEditField:n().func.isRequired,onMoveField:n().func.isRequired,onRemoveField:n().func.isRequired,setIsDraggingSibling:n().func.isRequired};var vm=pa;const Cm=(0,q.ZP)(H.x)`
|
|
1042
|
+
flex: ${({size:t})=>t};
|
|
1043
|
+
overflow-x: scroll;
|
|
1044
|
+
overflow-y: hidden;
|
|
1045
|
+
`,ga=({displayedFields:t,listRemainingFields:o,metadatas:r,onAddField:a,onClickEditField:s,onMoveField:c,onRemoveField:i})=>{const{formatMessage:d}=(0,K.Z)(),[m,u]=(0,e.useState)(!1),[p,E]=(0,e.useState)(null),h=(0,e.useRef)();function g(...C){E("add"),a(...C)}function b(...C){E("remove"),i(...C)}return(0,e.useEffect)(()=>{p==="add"&&h?.current&&(h.current.scrollLeft=h.current.scrollWidth)},[t,p]),e.createElement(e.Fragment,null,e.createElement(H.x,{paddingBottom:4},e.createElement(W.Z,{variant:"delta",as:"h2"},d({id:(0,f.OB)("containers.SettingPage.view"),defaultMessage:"View"}))),e.createElement(P.k,{paddingTop:4,paddingLeft:4,paddingRight:4,borderColor:"neutral300",borderStyle:"dashed",borderWidth:"1px",hasRadius:!0},e.createElement(Cm,{size:"1",paddingBottom:4,ref:h},e.createElement(P.k,{gap:3},t.map((C,I)=>e.createElement(vm,{key:C,index:I,isDraggingSibling:m,onMoveField:c,onClickEditField:s,onRemoveField:v=>b(v,I),name:C,labelField:r[C].list.label||C,setIsDraggingSibling:u})))),e.createElement(pe.fC,null,e.createElement(pe.xz,{paddingLeft:2,paddingRight:2,justifyContent:"center",endIcon:null,disabled:o.length<=0,marginBottom:4,variant:"tertiary"},e.createElement(_e.T,{as:"span"},d({id:(0,f.OB)("components.FieldSelect.label"),defaultMessage:"Add a field"})),e.createElement(pt.Z,{"aria-hidden":!0,focusable:!1,style:{position:"relative",top:2}})),e.createElement(pe.VY,null,o.map(C=>e.createElement(pe.ck,{key:C,onSelect:()=>g(C)},r[C].list.label||C))))))};ga.propTypes={displayedFields:xe.PropTypes.array.isRequired,listRemainingFields:xe.PropTypes.array.isRequired,metadatas:xe.PropTypes.objectOf(xe.PropTypes.shape({list:xe.PropTypes.shape({label:xe.PropTypes.string})})).isRequired,onAddField:xe.PropTypes.func.isRequired,onClickEditField:xe.PropTypes.func.isRequired,onMoveField:xe.PropTypes.func.isRequired,onRemoveField:xe.PropTypes.func.isRequired};var Rm=ga;const Mm=["media","richtext","dynamiczone","relation","component","json"];var Tm=(t,o)=>({...t,initialData:o,modifiedData:o});const Bo={fieldForm:{},fieldToEdit:"",initialData:{},modifiedData:{}};var Dm=(t=Bo,o)=>(0,Pn.ZP)(t,r=>{const a=["modifiedData","layouts","list"];switch(o.type){case"ADD_FIELD":{const s=Z()(t,a,[]);te()(r,a,[...s,o.item]);break}case"MOVE_FIELD":{const s=Z()(t,a,[]),{originalIndex:c,atIndex:i}=o;te()(r,a,(0,f.W3)(s,c,i));break}case"ON_CHANGE":{te()(r,["modifiedData",...o.keys.split(".")],o.value);break}case"ON_CHANGE_FIELD_METAS":{te()(r,["fieldForm",o.name],o.value);break}case"REMOVE_FIELD":{const s=Z()(t,a,[]);te()(r,a,s.filter((c,i)=>o.index!==i));break}case"SET_FIELD_TO_EDIT":{const{fieldToEdit:s}=o;r.fieldToEdit=s,r.fieldForm.label=Z()(r,["modifiedData","metadatas",s,"list","label"],""),r.fieldForm.sortable=Z()(r,["modifiedData","metadatas",s,"list","sortable"],"");break}case"UNSET_FIELD_TO_EDIT":{r.fieldForm={},r.fieldToEdit="";break}case"SUBMIT_FIELD_FORM":{const s=["modifiedData","metadatas",t.fieldToEdit,"list"];te()(r,[...s,"label"],t.fieldForm.label),te()(r,[...s,"sortable"],t.fieldForm.sortable);break}default:return r}});const fa=({layout:t,slug:o})=>{const{put:r}=(0,y.kY)(),{formatMessage:a}=(0,K.Z)(),{trackUsage:s}=(0,y.rS)(),c=(0,oe.fi)(),i=(0,y.lm)(),{refetchData:d}=(0,e.useContext)(Ot),[m,u]=(0,e.useState)(!1),p=()=>u(F=>!F),[E,h]=(0,e.useReducer)(Dm,Bo,()=>Tm(Bo,t)),{fieldToEdit:g,fieldForm:b,initialData:C,modifiedData:I}=E,v=!Fe()(b),{attributes:M}=t,x=I.layouts.list,j=()=>{const{settings:{pageSize:F,defaultSortBy:U,defaultSortOrder:Y},kind:L,uid:B}=C,ne=`${U}:${Y}`,ce=`${(0,Fo.stringify)({page:1,pageSize:F,sort:ne},{encode:!1})}${c?`&${c}`:""}`;return`/content-manager/${L}/${B}?${ce}`},D=({target:{name:F,value:U}})=>{h({type:"ON_CHANGE",keys:F,value:F==="settings.pageSize"?parseInt(U,10):U})},O=async()=>{const F=ln()(I,["layouts","settings","metadatas"]);X.mutate(F)},N=F=>{h({type:"ADD_FIELD",item:F})},w=(F,U)=>{F.stopPropagation(),x.length===1?i({type:"info",message:{id:(0,f.OB)("notification.info.minimumFields")}}):h({type:"REMOVE_FIELD",index:U})},T=F=>{F.preventDefault(),p(),s("willSaveContentTypeLayout")},S=F=>{h({type:"SET_FIELD_TO_EDIT",fieldToEdit:F})},G=()=>{h({type:"UNSET_FIELD_TO_EDIT"})},$=F=>{F.preventDefault(),h({type:"SUBMIT_FIELD_FORM"}),G()},X=(0,Be.useMutation)(F=>r(`/content-manager/content-types/${o}/configuration`,F),{onSuccess(){s("didEditListSettings"),d()},onError(){i({type:"warning",message:{id:"notification.error"}})}}),{isLoading:Q}=X,J=({target:{name:F,value:U}})=>{h({type:"ON_CHANGE_FIELD_METAS",name:F,value:U})},A=Object.entries(M).filter(([F,U])=>(0,f.ko)(U)&&!x.includes(F)).map(([F])=>F).sort(),k=Object.entries(M).filter(([,F])=>!Mm.includes(F.type)).map(([F])=>F),R=(F,U)=>{h({type:"MOVE_FIELD",originalIndex:F,atIndex:U})};return e.createElement(tt.A,null,e.createElement(Te.o,{"aria-busy":Q},e.createElement("form",{onSubmit:T},e.createElement(De.T,{navigationAction:e.createElement(y.rU,{startIcon:e.createElement(ot.Z,null),to:j,id:"go-back"},a({id:"global.back",defaultMessage:"Back"})),primaryAction:e.createElement(le.z,{size:"S",startIcon:e.createElement(we.Z,null),disabled:ke()(I,C),type:"submit"},a({id:"global.save",defaultMessage:"Save"})),subtitle:a({id:(0,f.OB)("components.SettingsViewWrapper.pluginHeader.description.list-settings"),defaultMessage:"Define the settings of the list view."}),title:a({id:(0,f.OB)("components.SettingsViewWrapper.pluginHeader.title"),defaultMessage:"Configure the view - {name}"},{name:Pt()(I.info.displayName)})}),e.createElement(Qe.D,null,e.createElement(H.x,{background:"neutral0",hasRadius:!0,shadow:"tableShadow",paddingTop:6,paddingBottom:6,paddingLeft:7,paddingRight:7},e.createElement(gm,{modifiedData:I,onChange:D,sortOptions:k}),e.createElement(H.x,{paddingTop:6,paddingBottom:6},e.createElement(jt.i,null)),e.createElement(Rm,{listRemainingFields:A,displayedFields:x,onAddField:N,onClickEditField:S,onMoveField:R,onRemoveField:w,metadatas:I.metadatas}))),e.createElement(y.QH,{bodyText:{id:(0,f.OB)("popUpWarning.warning.updateAllSettings"),defaultMessage:"This will modify all your settings"},iconRightButton:e.createElement(we.Z,null),isConfirmButtonLoading:Q,isOpen:m,onToggleDialog:p,onConfirm:O,variantRightButton:"success-light"})),v&&e.createElement(pm,{attributes:M,fieldForm:b,fieldToEdit:g,onChangeEditLabel:J,onCloseModal:G,onSubmit:$,type:Z()(M,[g,"type"],"text")})))};fa.propTypes={layout:n().shape({uid:n().string.isRequired,settings:n().shape({bulkable:n().bool,defaultSortBy:n().string,defaultSortOrder:n().string,filterable:n().bool,pageSize:n().number,searchable:n().bool}).isRequired,metadatas:n().object.isRequired,options:n().object.isRequired,attributes:n().objectOf(n().shape({type:n().string})).isRequired}).isRequired,slug:n().string.isRequired};var Om=(0,e.memo)(fa),bt=l(93088);const Im=()=>({type:bt.ZA}),Pm=(t,o)=>({type:bt.Id,pagination:t,data:o}),xm=()=>({type:bt.MP});function Zm(){return{type:bt.c2}}const Lm=({components:t,contentType:o})=>{const{layouts:r}=o;return{contentType:o,components:t,displayedHeaders:r.list,type:bt.Zz}},No=t=>({type:bt.Rp,target:t});var jo=l(94638),ha=l(99223),ya=l(94547),qe=l(19786),Sm=l(12301),km=l(59177),Ea=l(6680);const ba=({displayedFilters:t})=>{const[o,r]=(0,e.useState)(!1),{formatMessage:a}=(0,K.Z)(),s=(0,e.useRef)(),{trackUsage:c}=(0,y.rS)(),i=()=>{o||c("willFilterEntries"),r(d=>!d)};return e.createElement(e.Fragment,null,e.createElement(H.x,{paddingTop:1,paddingBottom:1},e.createElement(le.z,{variant:"tertiary",ref:s,startIcon:e.createElement(sr.Z,null),onClick:i,size:"S"},a({id:"app.utils.filters",defaultMessage:"Filters"})),o&&e.createElement(y.J5,{displayedFilters:t,isVisible:o,onToggle:i,source:s})),e.createElement(y.W$,{filtersSchema:t}))};ba.propTypes={displayedFilters:n().arrayOf(n().shape({name:n().string.isRequired,metadatas:n().shape({label:n().string}),fieldSchema:n().shape({type:n().string})})).isRequired};var Fm=ba;const Am=["json","component","media","richtext","dynamiczone","password"],wm=["createdAt","updatedAt"];var $m=(t,o)=>{const{allPermissions:r}=(0,y.vn)(),a=(0,y.ZT)(r,[{action:"plugin::content-manager.explorer.read",subject:o}]),s=Z()(a,["0","properties","fields"],[]);return Object.keys(Z()(t,["attributes"]),{}).filter(d=>{const m=Z()(t,["attributes",d],{});return!(!m.type||Am.includes(m.type)||!s.includes(d)&&d!=="id"&&!wm.includes(d))}).sort()};const va=({contentType:t,slug:o,metadatas:r})=>{const{formatMessage:a}=(0,K.Z)(),c=$m(t,o).map(i=>{const d=t.attributes[i],{type:m,enum:u}=d,p={name:"didFilterEntries",properties:{useRelation:m==="relation"}},{mainField:E,label:h}=r[i].list;return{name:i,metadatas:{label:a({id:h,defaultMessage:h})},fieldSchema:{type:m,options:u,mainField:E},trackedEvent:p}});return e.createElement(Fm,{displayedFilters:c})};va.propTypes={contentType:n().object.isRequired,metadatas:n().object.isRequired,slug:n().string.isRequired};var Bm=va,Nm=l(82884),jm=l(47765);const Ca=({area:t,...o})=>{const r=Dr(t);return r?e.createElement("ul",null,r.map(a=>a.Component(o)?e.createElement(H.x,{key:a.name,padding:3,style:{textAlign:"center"}},e.createElement(a.Component,{...o})):null)):null};Ca.propTypes={area:n().string.isRequired};var nn=Ca;const Ra=({isConfirmButtonLoading:t,isOpen:o,onToggleDialog:r,onConfirm:a})=>{const{formatMessage:s}=(0,K.Z)();return e.createElement(Jt.V,{onClose:r,title:s({id:"app.components.ConfirmDialog.title",defaultMessage:"Confirmation"}),labelledBy:"confirmation",describedBy:"confirm-description",isOpen:o},e.createElement(_t.a,{icon:e.createElement(At.Z,null)},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(P.k,{justifyContent:"center"},e.createElement(W.Z,{id:"confirm-description"},s({id:"components.popUpWarning.message",defaultMessage:"Are you sure you want to delete this?"}))),e.createElement(P.k,null,e.createElement(nn,{area:"contentManager.listView.deleteModalAdditionalInfos"})))),e.createElement(en.c,{startAction:e.createElement(le.z,{onClick:r,variant:"tertiary"},s({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endAction:e.createElement(le.z,{onClick:a,variant:"danger-light",startIcon:e.createElement(Ve.Z,null),id:"confirm-delete",loading:t},s({id:"app.components.Button.confirm",defaultMessage:"Confirm"}))}))};Ra.propTypes={isConfirmButtonLoading:n().bool.isRequired,isOpen:n().bool.isRequired,onConfirm:n().func.isRequired,onToggleDialog:n().func.isRequired};const Ma=t=>t.stopPropagation(),Ta=({rowId:t,index:o})=>{const{selectedEntries:r,onSelectRow:a}=(0,y.Sh)(),{formatMessage:s}=(0,K.Z)(),c=r.findIndex(d=>d===t)!==-1,i=s({id:"app.component.table.select.one-entry",defaultMessage:"Select {target}"},{target:o+1});return e.createElement(qe.Td,{onClick:Ma},e.createElement(Nm.C,{"aria-label":i,checked:c,onChange:()=>{a({name:t,value:!c})}}))};Ta.propTypes={rowId:n().number.isRequired,index:n().number.isRequired};const Wo=({rowId:t,index:o,canCreate:r,canDelete:a,setIsConfirmDeleteRowOpen:s,handleCloneClick:c})=>{const{formatMessage:i}=(0,K.Z)(),{trackUsage:d}=(0,y.rS)(),{setSelectedEntries:m}=(0,y.Sh)(),u=(0,oe.fi)(),{location:{pathname:p}}=(0,re.k6)(),E=i({id:"content-manager.components.ListViewTable.row-line",defaultMessage:"item line {number}"},{number:o+1});return e.createElement(qe.Td,null,e.createElement(P.k,{gap:1,justifyContent:"end",onClick:Ma},e.createElement(Re.h,{forwardedAs:gt.rU,onClick:()=>{d("willEditEntryFromButton")},to:{pathname:`${p}/${t}`,state:{from:p},search:u},label:i({id:"app.component.table.edit",defaultMessage:"Edit {target}"},{target:E}),noBorder:!0},e.createElement(Ke.Z,null)),r&&e.createElement(Re.h,{onClick:c(t),label:i({id:"app.component.table.duplicate",defaultMessage:"Duplicate {target}"},{target:E}),noBorder:!0},e.createElement(jm.Z,null)),a&&e.createElement(Re.h,{onClick:()=>{d("willDeleteEntryFromList"),m([t]),s(!0)},label:i({id:"global.delete-target",defaultMessage:"Delete {target}"},{target:E}),noBorder:!0},e.createElement(Ve.Z,null))))};Wo.defaultProps={canCreate:!1,canDelete:!1},Wo.propTypes={rowId:n().number.isRequired,index:n().number.isRequired,setIsConfirmDeleteRowOpen:n().func.isRequired,handleCloneClick:n().func.isRequired,canCreate:n().bool,canDelete:n().bool};const Da=({children:t,onConfirmDelete:o,isConfirmDeleteRowOpen:r,setIsConfirmDeleteRowOpen:a})=>{const[s,c]=e.useState(!1),{selectedEntries:i,setSelectedEntries:d}=(0,y.Sh)(),m=async()=>{try{c(!0),await o(i[0]),a(!1),c(!1),d([])}catch{c(!1),a(!1)}};return e.createElement(y.iA.Body,null,t,e.createElement(Ra,{isConfirmButtonLoading:s,onConfirm:m,onToggleDialog:()=>a(!r),isOpen:r}))};Da.propTypes={children:n().node.isRequired,onConfirmDelete:n().func.isRequired,isConfirmDeleteRowOpen:n().bool.isRequired,setIsConfirmDeleteRowOpen:n().func.isRequired};const on={CheckboxDataCell:Ta,EntityActionsDataCell:Wo,Root:Da};var Wm=l(14090);const vt=()=>t=>t["content-manager_listView"]||Wm.E,zm=()=>(0,Zo.P1)(vt(),t=>t),Oa=t=>{const{displayedHeaders:o}=t["content-manager_listView"];return o};var Um=zm;const rn=({onToggleDialog:t,isOpen:o,dialogBody:r,endAction:a})=>{const{formatMessage:s}=(0,K.Z)();return e.createElement(Jt.V,{onClose:t,title:s({id:"app.components.ConfirmDialog.title",defaultMessage:"Confirmation"}),isOpen:o},e.createElement(_t.a,{icon:e.createElement(At.Z,null)},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:2},r)),e.createElement(en.c,{startAction:e.createElement(le.z,{onClick:t,variant:"tertiary"},s({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endAction:a}))};rn.propTypes={isOpen:n().bool.isRequired,onToggleDialog:n().func.isRequired,dialogBody:n().node.isRequired,endAction:n().node.isRequired};const zo={isConfirmButtonLoading:n().bool.isRequired,isOpen:n().bool.isRequired,onConfirm:n().func.isRequired,onToggleDialog:n().func.isRequired},Vm=t=>e.createElement(W.Z,{fontWeight:"bold"},t),Ia=({isOpen:t,onToggleDialog:o,isConfirmButtonLoading:r,onConfirm:a})=>{const{formatMessage:s}=(0,K.Z)(),{get:c}=(0,y.kY)(),{selectedEntries:i}=(0,y.Sh)(),d=(0,y.lm)(),{formatAPIError:m}=(0,y.So)(f.OB),{contentType:{uid:u}}=(0,ae.v9)(vt()),{data:p,isLoading:E,isError:h}=(0,Be.useQuery)(["content-manager","draft-relations",u,i],async()=>{const{data:{data:g}}=await c(`/content-manager/collection-types/${u}/actions/countManyEntriesDraftRelations`,{params:{ids:i}});return g},{onError(g){d({type:"warning",message:m(g)})}});return h?null:e.createElement(rn,{isOpen:t&&!E,onToggleDialog:o,dialogBody:e.createElement(e.Fragment,null,e.createElement(W.Z,{id:"confirm-description",textAlign:"center"},p>0&&s({id:(0,f.OB)("popUpwarning.warning.bulk-has-draft-relations.message"),defaultMessage:"<b>{count} {count, plural, one { relation } other { relations } } out of {entities} { entities, plural, one { entry } other { entries } } {count, plural, one { is } other { are } }</b> not published yet and might lead to unexpected behavior. "},{b:Vm,count:p,entities:i.length}),s({id:(0,f.OB)("popUpWarning.bodyMessage.contentType.publish.all"),defaultMessage:"Are you sure you want to publish these entries?"})),e.createElement(nn,{area:"contentManager.listView.publishModalAdditionalInfos"})),endAction:e.createElement(le.z,{onClick:a,variant:"secondary",startIcon:e.createElement(we.Z,null),loading:r},s({id:"app.utils.publish",defaultMessage:"Publish"}))})};Ia.propTypes=zo;var Pa=l(23866),qm=l(88890),Hm=l(5074);const Gm=(0,q.ZP)(W.Z)`
|
|
1046
|
+
max-width: 300px;
|
|
1047
|
+
`,Uo=({errors:t,isPublished:o})=>{const{formatMessage:r}=(0,K.Z)();if(t){const a=Object.entries(t).map(([s,c])=>r({id:`${c.id}.withField`,defaultMessage:c.defaultMessage},{field:s})).join(" ");return e.createElement(P.k,{gap:2},e.createElement(ft.J,{color:"danger600",as:qm.Z}),e.createElement(wt.u,{description:a},e.createElement(Gm,{textColor:"danger600",variant:"omega",fontWeight:"semiBold",ellipsis:!0},a)))}return o?e.createElement(P.k,{gap:2},e.createElement(ft.J,{color:"success600",as:Qn.Z}),e.createElement(W.Z,{textColor:"success600",fontWeight:"bold"},r({id:"app.utils.published",defaultMessage:"Published"}))):e.createElement(P.k,{gap:2},e.createElement(ft.J,{color:"success600",as:Qn.Z}),e.createElement(W.Z,null,r({id:"app.utils.ready-to-publish",defaultMessage:"Ready to publish"})))};Uo.defaultProps={errors:null,isPublished:!1},Uo.propTypes={errors:n().shape({[n().string]:n().shape({id:n().string,defaultMessage:n().string})}),isPublished:n().bool};const Vo=({isPublishing:t,rowsToDisplay:o,entriesToPublish:r})=>{const{location:{pathname:a}}=(0,re.k6)(),{formatMessage:s}=(0,K.Z)(),c=(0,ae.v9)(vt()),{mainField:i}=c.contentType.settings,d=i!=null&&i!=="id",m=u=>s({id:"content-manager.components.ListViewTable.row-line",defaultMessage:"item line {number}"},{number:u+1});return e.createElement(y.iA.Content,null,e.createElement(y.iA.Head,null,e.createElement(y.iA.HeaderCheckboxCell,null),e.createElement(y.iA.HeaderCell,{fieldSchemaType:"number",label:"id",name:"id"}),d&&e.createElement(y.iA.HeaderCell,{fieldSchemaType:"string",label:"name",name:"name"}),e.createElement(y.iA.HeaderCell,{fieldSchemaType:"string",label:"status",name:"status"})),e.createElement(y.iA.LoadingBody,null),e.createElement(y.iA.Body,null,o.map(({entity:u,errors:p},E)=>e.createElement(ya.Tr,{key:u.id},e.createElement(on.CheckboxDataCell,{rowId:u.id,index:E}),e.createElement(qe.Td,null,e.createElement(W.Z,null,u.id)),d&&e.createElement(qe.Td,null,e.createElement(W.Z,null,u[i])),e.createElement(qe.Td,null,t&&r.includes(u.id)?e.createElement(P.k,{gap:2},e.createElement(W.Z,null,s({id:"content-manager.success.record.publishing",defaultMessage:"Publishing..."})),e.createElement(Pa.a,{small:!0})):e.createElement(Uo,{errors:p,isPublished:u.publishedAt!==null})),e.createElement(qe.Td,null,e.createElement(Re.h,{forwardedAs:gt.rU,to:{pathname:`${a}/${u.id}`,state:{from:a}},label:s({id:"app.component.table.edit",defaultMessage:"Edit {target}"},{target:m(E)}),noBorder:!0,target:"_blank"},e.createElement(Ke.Z,null)))))))};Vo.defaultProps={isPublishing:!1,rowsToDisplay:[],entriesToPublish:[]},Vo.propTypes={isPublishing:n().bool,rowsToDisplay:n().arrayOf(n().object),entriesToPublish:n().arrayOf(n().number)};const xa=t=>e.createElement(W.Z,{fontWeight:"bold"},t),Za=({toggleModal:t,refetchModalData:o,setEntriesToFetch:r})=>{const{formatMessage:a}=(0,K.Z)(),{selectedEntries:s,rows:c,onSelectRow:i,isLoading:d,isFetching:m}=(0,y.Sh)(),[u,p]=e.useState(!1),[E,h]=e.useState([]),[g,b]=e.useState(0),C=c.filter(({entity:T,errors:S})=>s.includes(T.id)&&!S).map(({entity:T})=>T.id),{post:I}=(0,y.kY)(),v=(0,y.lm)(),{contentType:M}=(0,ae.v9)(vt()),x=E.filter(({entity:T,errors:S})=>s.includes(T.id)&&S).length,j=s.length-x,D=(0,Be.useMutation)(T=>I(`/content-manager/collection-types/${M.uid}/actions/bulkPublish`,T),{onSuccess(){const T=E.filter(S=>(C.includes(S.entity.id)&&i({name:S.entity.id,value:!1}),!C.includes(S.entity.id)));h(T),r(T.map(({entity:S})=>S.id)),T.length===0&&t(),v({type:"success",message:{id:"content-manager.success.record.publish",defaultMessage:"Published"}})},onError(T){v({type:"warning",message:(0,Hm.Z)(T)})}}),O=()=>p(T=>!T),N=async()=>{O();const{data:T}=await D.mutateAsync({ids:C});b(T.count)},w=()=>g?a({id:(0,f.OB)("containers.ListPage.selectedEntriesModal.publishedCount"),defaultMessage:"<b>{publishedCount}</b> {publishedCount, plural, =0 {entries} one {entry} other {entries}} published. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action."},{publishedCount:g,withErrorsCount:x,b:xa}):a({id:(0,f.OB)("containers.ListPage.selectedEntriesModal.selectedCount"),defaultMessage:"<b>{readyToPublishCount}</b> {readyToPublishCount, plural, =0 {entries} one {entry} other {entries}} ready to publish. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action."},{readyToPublishCount:j,withErrorsCount:x,b:xa});return e.useEffect(()=>{c.length>0&&h(c)},[c]),e.createElement(yn.P,{onClose:t,labelledBy:"title"},e.createElement(En.x,null,e.createElement(W.Z,{fontWeight:"bold",textColor:"neutral800",as:"h2",id:"title"},a({id:(0,f.OB)("containers.ListPage.selectedEntriesModal.title"),defaultMessage:"Publish entries"}))),e.createElement(bn.f,null,e.createElement(W.Z,null,w()),e.createElement(H.x,{marginTop:5},e.createElement(Vo,{isPublishing:D.isLoading,rowsToDisplay:E,entriesToPublish:C}))),e.createElement(vn.m,{startActions:e.createElement(le.z,{onClick:t,variant:"tertiary"},a({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endActions:e.createElement(P.k,{gap:2},e.createElement(le.z,{onClick:o,variant:"tertiary",loading:m},a({id:"app.utils.refresh",defaultMessage:"Refresh"})),e.createElement(le.z,{onClick:O,disabled:s.length===0||s.length===x||d,loading:D.isLoading},a({id:"app.utils.publish",defaultMessage:"Publish"})))}),e.createElement(Ia,{isOpen:u,onToggleDialog:O,isConfirmButtonLoading:D.isLoading,onConfirm:N}))};Za.propTypes={toggleModal:n().func.isRequired,refetchModalData:n().func.isRequired,setEntriesToFetch:n().func.isRequired};const La=({onToggle:t})=>{const{selectedEntries:o}=(0,y.Sh)(),{contentType:r,components:a}=(0,ae.v9)(vt()),[s,c]=e.useState(o),[{query:{sort:i}}]=(0,y.Kx)(),d={sort:i,filters:{id:{$in:s}}},{get:m}=(0,y.kY)(),{data:u,isLoading:p,isFetching:E,refetch:h}=(0,Be.useQuery)(["entries",r.uid,d],async()=>{const{data:g}=await m(`content-manager/collection-types/${r.uid}`,{params:d});if(g.results){const b=(0,f.Ex)(r,{components:a},{isDraft:!1});return g.results.map(I=>{try{return b.validateSync(I,{abortEarly:!1}),{entity:I}}catch(v){return{entity:I,errors:(0,y.CJ)(v)}}})}return[]});return e.createElement(y.iA.Root,{rows:u,defaultSelectedEntries:o,colCount:4,isLoading:p,isFetching:E},e.createElement(Za,{setEntriesToFetch:c,toggleModal:t,refetchModalData:h}))};La.propTypes={onToggle:n().func.isRequired};var Qm=La;const Sa=({isOpen:t,onToggleDialog:o,isConfirmButtonLoading:r,onConfirm:a})=>{const{formatMessage:s}=(0,K.Z)();return e.createElement(rn,{isOpen:t,onToggleDialog:o,dialogBody:e.createElement(e.Fragment,null,e.createElement(W.Z,{id:"confirm-description",textAlign:"center"},s({id:(0,f.OB)("popUpWarning.bodyMessage.contentType.unpublish.all"),defaultMessage:"Are you sure you want to unpublish these entries?"})),e.createElement(nn,{area:"contentManager.listView.unpublishModalAdditionalInfos"})),endAction:e.createElement(le.z,{onClick:a,variant:"secondary",startIcon:e.createElement(we.Z,null),loading:r},s({id:"app.utils.unpublish",defaultMessage:"Unpublish"}))})};Sa.propTypes=zo;const ka=({isOpen:t,onToggleDialog:o,isConfirmButtonLoading:r,onConfirm:a})=>{const{formatMessage:s}=(0,K.Z)();return e.createElement(rn,{isOpen:t,onToggleDialog:o,dialogBody:e.createElement(e.Fragment,null,e.createElement(W.Z,{id:"confirm-description",textAlign:"center"},s({id:(0,f.OB)("popUpWarning.bodyMessage.contentType.delete.all"),defaultMessage:"Are you sure you want to delete these entries?"})),e.createElement(nn,{area:"contentManager.listView.deleteModalAdditionalInfos"})),endAction:e.createElement(le.z,{onClick:a,variant:"danger-light",startIcon:e.createElement(Ve.Z,null),id:"confirm-delete",loading:r},s({id:"app.components.Button.confirm",defaultMessage:"Confirm"}))})};ka.propTypes=zo;const qo=({showPublish:t,showDelete:o,onConfirmDeleteAll:r,onConfirmUnpublishAll:a,refetchData:s})=>{const{formatMessage:c}=(0,K.Z)(),{trackUsage:i}=(0,y.rS)(),{data:d}=(0,ae.v9)(vt()),{selectedEntries:m,setSelectedEntries:u}=(0,y.Sh)(),[p,E]=e.useState(!1),[h,g]=e.useState(!1),[b,C]=e.useState(null),I=d.filter(T=>m.includes(T.id)),v=t&&I.some(T=>!T.publishedAt),M=t&&I.some(T=>T.publishedAt),x=()=>{b==="delete"?C(null):(C("delete"),i("willBulkDeleteEntries"))},j=()=>{b==="unpublish"?C(null):(C("unpublish"),i("willBulkUnpublishEntries"))},D=async(T,S)=>{try{E(!0),await T(m),E(!1),S(),u([])}catch{E(!1),S()}},O=()=>D(r,x),N=()=>D(a,j),w=()=>{g(T=>(T&&s(),!T))};return e.createElement(e.Fragment,null,v&&e.createElement(e.Fragment,null,e.createElement(le.z,{variant:"tertiary",onClick:w},c({id:"app.utils.publish",defaultMessage:"Publish"})),h&&e.createElement(Qm,{onToggle:w})),M&&e.createElement(e.Fragment,null,e.createElement(le.z,{variant:"tertiary",onClick:j},c({id:"app.utils.unpublish",defaultMessage:"Unpublish"})),e.createElement(Sa,{isOpen:b==="unpublish",onToggleDialog:j,isConfirmButtonLoading:p,onConfirm:N})),o&&e.createElement(e.Fragment,null,e.createElement(le.z,{variant:"danger-light",onClick:x},c({id:"global.delete",defaultMessage:"Delete"})),e.createElement(ka,{isOpen:b==="delete",onToggleDialog:x,isConfirmButtonLoading:p,onConfirm:O})))};qo.defaultProps={showPublish:!1,showDelete:!1,onConfirmDeleteAll(){},onConfirmUnpublishAll(){},refetchData(){}},qo.propTypes={showPublish:n().bool,showDelete:n().bool,onConfirmDeleteAll:n().func,onConfirmUnpublishAll:n().func,refetchData:n().func};var Km=qo,Ym=l(96315);const Fa=({type:t,value:o})=>{const{formatDate:r,formatTime:a,formatNumber:s}=(0,K.Z)();let c=o;if(t==="date"&&(c=r((0,Ym.Z)(o),{dateStyle:"full"})),t==="datetime"&&(c=r(o,{dateStyle:"full",timeStyle:"short"})),t==="time"){const[i,d,m]=o.split(":"),u=new Date;u.setHours(i),u.setMinutes(d),u.setSeconds(m),c=a(u,{numeric:"auto",style:"short"})}return["float","decimal"].includes(t)&&(c=s(o,{maximumFractionDigits:20})),["integer","biginteger"].includes(t)&&(c=s(o,{maximumFractionDigits:0})),ea()(c)};Fa.propTypes={type:n().string.isRequired,value:n().any.isRequired};var Ct=Fa,Xm=l(69033);const Jm=(0,q.ZP)(P.k)`
|
|
1048
|
+
position: relative;
|
|
1049
|
+
border-radius: 50%;
|
|
1050
|
+
width: 26px;
|
|
1051
|
+
height: 26px;
|
|
1052
|
+
border: 1px solid ${({theme:t})=>t.colors.neutral200};
|
|
1053
|
+
background: ${({theme:t})=>t.colors.neutral150};
|
|
1054
|
+
padding-left: 1px;
|
|
1055
|
+
|
|
1056
|
+
span {
|
|
1057
|
+
line-height: 0.6rem;
|
|
1058
|
+
font-size: 0.6rem;
|
|
1059
|
+
}
|
|
1060
|
+
`,Aa=({children:t,...o})=>e.createElement(Jm,{justifyContent:"center",alignItems:"center",as:"span",...o},e.createElement(W.Z,{variant:"sigma",textColor:"neutral600"},t));Aa.propTypes={children:n().string.isRequired};var wa=Aa;const Ho=({url:t,mime:o,alternativeText:r,name:a,ext:s,formats:c})=>{const i=(0,y.CR)(t);if(o.includes("image")){const u=c?.thumbnail?.url||null,p=(0,y.CR)(u)||i;return e.createElement(Xm.q,{src:p,alt:r||a,preview:!0})}const d=(0,y.mD)(s),m=a.length>100?`${a.substring(0,100)}...`:a;return e.createElement(wt.u,{description:m},e.createElement(wa,null,d))};Ho.defaultProps={alternativeText:null,formats:null},Ho.propTypes={alternativeText:n().string,ext:n().string.isRequired,formats:n().object,mime:n().string.isRequired,name:n().string.isRequired,url:n().string.isRequired};var $a=Ho,_m=l(25898);const Ba=({value:t})=>e.createElement(_m.H,null,t.map((o,r)=>{const a=`${o.id}${r}`;if(r===3){const s=`+${t.length-3}`;return e.createElement(wa,{key:a,preview:!1},s)}return r>3?null:e.createElement($a,{key:a,...o})}));Ba.propTypes={value:n().arrayOf(n().shape({alternativeText:n().string,ext:n().string.isRequired,formats:n().object,mime:n().string.isRequired,name:n().string.isRequired,url:n().string.isRequired})).isRequired};var ep=Ba,Na=l(6518);const ja=({fieldSchema:t,metadatas:o,name:r,entityId:a,value:s,contentType:c})=>{const{formatMessage:i}=(0,K.Z)(),{notifyStatus:d}=(0,jo.G)(),[m,u]=(0,e.useState)(!1),{get:p}=(0,y.kY)(),{data:E,status:h}=(0,Be.useQuery)([t.targetModel,a],async()=>{const{data:{results:g,pagination:b}}=await p((0,f.IF)(`relations/${c.uid}/${a}/${r.split(".")[0]}`));return{results:g,pagination:b}},{enabled:m,staleTime:0,select:g=>({...g,results:[...g.results].reverse()})});return(0,e.useEffect)(()=>{E&&d(i({id:(0,f.OB)("DynamicTable.relation-loaded"),defaultMessage:"Relations have been loaded"}))},[E,i,d]),e.createElement(pe.fC,{onOpenChange:g=>u(g)},e.createElement(np,{onClick:g=>g.stopPropagation()},e.createElement(P.k,{gap:1,wrap:"nowrap"},e.createElement(Na.C,null,s.count),i({id:"content-manager.containers.ListPage.items",defaultMessage:"{number, plural, =0 {items} one {item} other {items}}"},{number:s.count}))),e.createElement(pe.VY,null,h!=="success"&&e.createElement(pe.ck,{disabled:!0},e.createElement(Pa.a,{small:!0},i({id:(0,f.OB)("ListViewTable.relation-loading"),defaultMessage:"Relations are loading"}))),h==="success"&&e.createElement(e.Fragment,null,E?.results.map(g=>e.createElement(pe.ck,{key:g.id,disabled:!0},e.createElement(tp,{ellipsis:!0},e.createElement(Ct,{type:o.mainField.schema.type,value:g[o.mainField.name]||g.id})))),E?.pagination.total>10&&e.createElement(pe.ck,{"aria-disabled":!0,"aria-label":i({id:(0,f.OB)("ListViewTable.relation-more"),defaultMessage:"This relation contains more entities than displayed"})},e.createElement(W.Z,null,"\u2026")))))};ja.propTypes={contentType:n().shape({uid:n().string.isRequired}).isRequired,fieldSchema:n().shape({relation:n().string,targetModel:n().string,type:n().string.isRequired}).isRequired,metadatas:n().shape({mainField:n().shape({name:n().string.isRequired,schema:n().shape({type:n().string.isRequired}).isRequired})}).isRequired,name:n().string.isRequired,entityId:n().oneOfType([n().string,n().number]).isRequired,value:n().object.isRequired};const tp=(0,q.ZP)(W.Z)`
|
|
1061
|
+
max-width: 500px;
|
|
1062
|
+
`,np=(0,q.ZP)(pe.xz)`
|
|
1063
|
+
svg {
|
|
1064
|
+
width: ${6/16}rem;
|
|
1065
|
+
height: ${4/16}rem;
|
|
1066
|
+
}
|
|
1067
|
+
`;var op=ja;const rp=(0,q.ZP)(W.Z)`
|
|
1068
|
+
max-width: 500px;
|
|
1069
|
+
`,Wa=({metadatas:t,value:o})=>e.createElement(rp,{textColor:"neutral800",ellipsis:!0},e.createElement(Ct,{type:t.mainField.schema.type,value:o[t.mainField.name]??o.id}));Wa.propTypes={metadatas:n().shape({mainField:n().shape({name:n().string.isRequired,schema:n().shape({type:n().string.isRequired}).isRequired})}).isRequired,value:n().object.isRequired};var ap=Wa;const sp=(0,q.ZP)(W.Z)`
|
|
1070
|
+
max-width: 500px;
|
|
1071
|
+
`,za=({value:t,metadatas:o})=>{const{formatMessage:r}=(0,K.Z)(),{mainField:{type:a,name:s}}=o;return e.createElement(pe.fC,null,e.createElement(ip,{onClick:c=>c.stopPropagation()},e.createElement(Na.C,null,t.length)," ",r({id:"content-manager.containers.ListPage.items",defaultMessage:"{number, plural, =0 {items} one {item} other {items}}"},{number:t.length})),e.createElement(pe.VY,null,t.map(c=>e.createElement(pe.ck,{key:c.id,disabled:!0},e.createElement(sp,{ellipsis:!0},e.createElement(Ct,{type:a,value:c[s]||c.id}))))))};za.propTypes={metadatas:n().shape({mainField:n().shape({name:n().string,type:n().string,value:n().string})}).isRequired,value:n().array.isRequired};const ip=(0,q.ZP)(pe.xz)`
|
|
1072
|
+
svg {
|
|
1073
|
+
width: ${6/16}rem;
|
|
1074
|
+
height: ${4/16}rem;
|
|
1075
|
+
}
|
|
1076
|
+
`;var lp=za;const cp=(0,q.ZP)(W.Z)`
|
|
1077
|
+
max-width: 250px;
|
|
1078
|
+
`,Ua=({value:t,metadatas:o})=>{const{mainField:r}=o,a=t[r.name];return e.createElement(wt.u,{label:a},e.createElement(cp,{textColor:"neutral800",ellipsis:!0},e.createElement(Ct,{type:r.type,value:a})))};Ua.propTypes={metadatas:n().shape({mainField:n().shape({name:n().string,type:n().string,value:n().string})}).isRequired,value:n().object.isRequired};var dp=Ua,up=l(80022),Va=l.n(up),qa=l(73347);function Ha(t){return["oneToOne","manyToOne","oneToOneMorph"].includes(t)}function mp(t,o,r,a){if(t==="component"){const{mainField:{name:s,type:c}}=r;if(a?.repeatable)return o.length>0;const i=o?.[s];return s==="id"&&![void 0,null].includes(i)?!0:(0,qa.Z)(c)&&c!=="biginteger"&&s!=="id"?Va()(i):!Fe()(i)}return t==="relation"?Ha(a.relation)?!Fe()(o):o?.count>0:(0,qa.Z)(t)&&t!=="biginteger"?Va()(o):t==="boolean"?o!==null:!Fe()(o)}const Ga=(0,q.ZP)(W.Z)`
|
|
1079
|
+
max-width: 300px;
|
|
1080
|
+
`,Go=({content:t,fieldSchema:o,metadatas:r,name:a,rowId:s,contentType:c})=>{const{type:i}=o;if(!mp(i,t,r,o))return e.createElement(W.Z,{textColor:"neutral800"},"-");switch(i){case"media":return o.multiple?e.createElement(ep,{value:t}):e.createElement($a,{...t});case"relation":return Ha(o.relation)?e.createElement(ap,{metadatas:r,value:t}):e.createElement(op,{fieldSchema:o,metadatas:r,value:t,name:a,entityId:s,contentType:c});case"component":return o.repeatable===!0?e.createElement(lp,{value:t,metadatas:r}):e.createElement(dp,{value:t,metadatas:r});case"string":return e.createElement(wt.u,{description:t},e.createElement(Ga,{ellipsis:!0,textColor:"neutral800"},e.createElement(Ct,{type:i,value:t})));default:return e.createElement(Ga,{ellipsis:!0,textColor:"neutral800"},e.createElement(Ct,{type:i,value:t}))}};Go.defaultProps={content:void 0},Go.propTypes={content:n().any,contentType:n().shape({uid:n().string.isRequired}).isRequired,fieldSchema:n().shape({component:n().string,multiple:n().bool,type:n().string.isRequired,repeatable:n().bool,relation:n().string}).isRequired,metadatas:n().object.isRequired,name:n().string.isRequired,rowId:n().oneOfType([n().string,n().number]).isRequired};var pp=Go;const Qa=({layout:t})=>{const o=(0,ae.I0)(),r=(0,ae.v9)(Oa),{trackUsage:a}=(0,y.rS)(),{formatMessage:s}=(0,K.Z)(),c=gp(t.contentType.attributes).map(m=>{const u=t.contentType.metadatas[m].list;return{name:m,intlLabel:{id:u.label,defaultMessage:u.label}}}),i=r.map(({name:m})=>m),d=m=>{if(a("didChangeDisplayedFields"),m.length<i.length){const u=i.filter(p=>m.indexOf(p)===-1);o(No({name:u[0],value:!0}))}else{const u=m.filter(p=>i.indexOf(p)===-1);o(No({name:u[0],value:!1}))}};return e.createElement(H.x,{paddingTop:1,paddingBottom:1},e.createElement(Ae.P,{"aria-label":"change displayed fields",value:i,onChange:d,customizeContent:m=>s({id:(0,f.OB)("select.currently.selected"),defaultMessage:"{count} currently selected"},{count:m.length}),multi:!0,size:"S"},c.map(m=>e.createElement(Ce.W,{key:m.name,value:m.name},s({id:m.intlLabel.id||m.name,defaultMessage:m.intlLabel.defaultMessage||m.name})))))};Qa.propTypes={layout:n().shape({contentType:n().shape({attributes:n().object.isRequired,metadatas:n().object.isRequired,layouts:n().shape({list:n().array.isRequired}).isRequired,options:n().object.isRequired,settings:n().object.isRequired}).isRequired}).isRequired};const gp=t=>Object.keys(t).reduce((r,a)=>{const s=t[a];return(0,f.ko)(s)&&r.push(a),r},[]).sort(),fp=(0,q.ZP)(H.x)`
|
|
1081
|
+
svg {
|
|
1082
|
+
path {
|
|
1083
|
+
fill: ${({theme:t})=>t.colors.neutral900};
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
`,hp=null,yp=()=>null;function Ka({canCreate:t,canDelete:o,canRead:r,canPublish:a,data:s,getData:c,getDataSucceeded:i,isLoading:d,layout:m,pagination:u,slug:p}){const{total:E}=u,{contentType:h}=m,{info:g,options:b,metadatas:C,settings:{bulkable:I,filterable:v,searchable:M}}=h,[x,j]=e.useState(!1),D=(0,y.lm)(),{trackUsage:O}=(0,y.rS)(),{refetchPermissions:N}=(0,y.vn)(),w=e.useRef(O),T=e.useRef(N),{notifyStatus:S}=(0,jo.G)(),{formatAPIError:G}=(0,y.So)(f.OB),$=(0,ae.v9)(We._);(0,y.go)();const[{query:X}]=(0,y.Kx)(),Q=e.useMemo(()=>ra(X),[X]),J=(0,Fo.stringify)({plugins:X.plugins},{encode:!1}),{pathname:A}=(0,re.TH)(),{push:k}=(0,re.k6)(),{formatMessage:R}=(0,K.Z)(),F=(0,y.kY)(),U=b?.draftAndPublish??!1,Y=b?.reviewWorkflows??!1,L=(0,Sn.c)(hp,async()=>(await l.e(6158).then(l.bind(l,76158))).REVIEW_WORKFLOW_COLUMNS_EE,{enabled:!!b?.reviewWorkflows}),B=(0,Sn.c)(yp,async()=>(await l.e(3984).then(l.bind(l,33984))).ReviewWorkflowsStageEE,{enabled:Y}),{post:ne,del:ce}=F,ge=(0,Be.useMutation)(se=>ne(`/content-manager/collection-types/${h.uid}/actions/bulkUnpublish`,se),{onSuccess(){D({type:"success",message:{id:"content-manager.success.record.unpublish",defaultMessage:"Unpublished"}}),z(`/content-manager/collection-types/${p}`,{params:Q})},onError(se){D({type:"warning",message:G(se)})}}),V=e.useRef(""),z=e.useCallback(async(se,ue)=>{c();try{const{data:{results:Ee,pagination:ve}}=await F.get(se,ue);S(R({id:(0,f.OB)("utils.data-loaded"),defaultMessage:"{number, plural, =1 {# entry has} other {# entries have}} successfully been loaded"},{number:ve.count})),i(ve,Ee)}catch(Ee){if(ze.default.isCancel(Ee))return;if((Ee?.response?.status??null)===403){await T.current(),D({type:"info",message:{id:(0,f.OB)("permissions.not-allowed.update")}}),k("/");return}D({type:"warning",message:{id:(0,f.OB)("error.model.fetch")}})}},[R,c,i,S,k,D,F]),ye=e.useCallback(async se=>{try{await ne(`/content-manager/collection-types/${p}/actions/bulkDelete`,{ids:se}),z(`/content-manager/collection-types/${p}`,{params:Q}),w.current("didBulkDeleteEntries")}catch(ue){D({type:"warning",message:G(ue)})}},[p,D,G,ne,z,Q]),he=e.useCallback(async se=>{try{await ce(`/content-manager/collection-types/${p}/${se}`);const ue=(0,f.IF)(`collection-types/${p}`);z(ue,{params:Q}),D({type:"success",message:{id:(0,f.OB)("success.record.delete")}})}catch(ue){D({type:"warning",message:G(ue)})}},[p,D,G,ce,z,Q]),Ne=se=>ge.mutateAsync({ids:se});e.useEffect(()=>{const ue=ze.default.CancelToken.source(),Ee=r,ve=(0,f.IF)(`collection-types/${p}`);return Ee&&ve.includes(V.current)&&z(ve,{cancelToken:ue.token,params:Q}),()=>{V.current=p,ue.cancel("Operation canceled by the user.")}},[r,c,p,Q,i,z]);const Ue=R({id:(0,f.OB)("header.name"),defaultMessage:"Content"}),de=R({id:g.displayName,defaultMessage:g.displayName||Ue}),{runHookWaterfall:Ie}=(0,y.j1)(),je=(0,ae.v9)(Oa),Pe=e.useMemo(()=>{const ue=Ie(Vt.No,{displayedHeaders:je,layout:m}).displayedHeaders.map(Ee=>{const{metadatas:ve}=Ee;if(Ee.fieldSchema.type==="relation"){const Bt=`${Ee.name}.${Ee.metadatas.mainField.name}`;return{...Ee,metadatas:{...ve,label:R({id:(0,f.OB)(`containers.ListPage.table-headers.${Ee.name}`),defaultMessage:ve.label})},name:Bt}}return{...Ee,metadatas:{...ve,label:R({id:(0,f.OB)(`containers.ListPage.table-headers.${Ee.name}`),defaultMessage:ve.label})}}});return U&&ue.push({key:"__published_at_temp_key__",name:"publishedAt",fieldSchema:{type:"custom"},metadatas:{label:R({id:(0,f.OB)("containers.ListPage.table-headers.publishedAt"),defaultMessage:"publishedAt"}),searchable:!1,sortable:!0}}),L&&(typeof L.metadatas.label!="string"&&(L.metadatas.label=R(L.metadatas.label)),ue.push(L)),ue},[Ie,je,m,L,U,R]),He=r?R({id:(0,f.OB)("pages.ListView.header-subtitle"),defaultMessage:"{number, plural, =0 {# entries} one {# entry} other {# entries}} found"},{number:E}):null,Rt=se=>t?e.createElement(le.z,{...se,forwardedAs:gt.rU,onClick:()=>{const ue=U?{status:"draft"}:{};w.current("willCreateEntry",ue)},to:{pathname:`${A}/create`,search:X.plugins?J:""},startIcon:e.createElement(pt.Z,null),style:{textDecoration:"none"}},R({id:(0,f.OB)("HeaderLayout.button.label-add-entry"),defaultMessage:"Create new entry"})):null,it=se=>()=>{O("willEditEntryFromList"),k({pathname:`${A}/${se}`,state:{from:A},search:J})},fe=se=>async()=>{try{const{data:ue}=await ne(`/content-manager/collection-types/${h.uid}/auto-clone/${se}?${J}`);"id"in ue&&k({pathname:`${A}/${ue.id}`,state:{from:A},search:J})}catch(ue){ue instanceof km.d7&&k({pathname:`${A}/create/clone/${se}`,state:{from:A,error:G(ue)},search:J})}},Me=Pe.length+2,et=()=>{z(`/content-manager/collection-types/${p}`,{params:Q})};return B?e.createElement(Te.o,{"aria-busy":d},e.createElement(De.T,{primaryAction:Rt(),subtitle:He,title:de,navigationAction:e.createElement(y.rU,{startIcon:e.createElement(ot.Z,null),to:"/content-manager/"},R({id:"global.back",defaultMessage:"Back"}))}),!r&&e.createElement(ha.Z,{endActions:e.createElement(qt,{area:"contentManager.listView.actions"})}),r&&e.createElement(ha.Z,{endActions:e.createElement(e.Fragment,null,e.createElement(qt,{area:"contentManager.listView.actions"}),e.createElement(Qa,{layout:m}),e.createElement(y.jW,{permissions:$.contentManager.collectionTypesConfigurations},e.createElement(fp,{paddingTop:1,paddingBottom:1},e.createElement(Re.h,{onClick:()=>{O("willEditListLayout")},forwardedAs:gt.rU,to:{pathname:`${p}/configurations/list`,search:J},icon:e.createElement(dn.Z,null),label:R({id:"app.links.configure-view",defaultMessage:"Configure the view"})})))),startActions:e.createElement(e.Fragment,null,M&&e.createElement(y.m,{label:R({id:"app.component.search.label",defaultMessage:"Search for {target}"},{target:de}),placeholder:R({id:"global.search",defaultMessage:"Search"}),trackedEvent:"didSearch"}),v&&e.createElement(Bm,{contentType:h,slug:p,metadatas:C}))}),e.createElement(Qe.D,null,r?e.createElement(P.k,{gap:4,direction:"column",alignItems:"stretch"},e.createElement(y.iA.Root,{rows:s,isLoading:d,colCount:Me},e.createElement(y.iA.ActionBar,null,e.createElement(Km,{showPublish:a&&U,showDelete:o,onConfirmDeleteAll:ye,onConfirmUnpublishAll:Ne,refetchData:et})),e.createElement(y.iA.Content,null,e.createElement(y.iA.Head,null,e.createElement(y.iA.HeaderCheckboxCell,null),Pe.map(({fieldSchema:se,key:ue,name:Ee,metadatas:ve})=>e.createElement(y.iA.HeaderCell,{key:ue,name:Ee,fieldSchemaType:se.type,relationFieldName:ve.mainField?.name,isSortable:ve.sortable,label:ve.label})),e.createElement(y.iA.HeaderHiddenActionsCell,null)),e.createElement(y.iA.LoadingBody,null),e.createElement(y.iA.EmptyBody,{contentType:de,aciton:Rt({variant:"secondary"})}),e.createElement(on.Root,{onConfirmDelete:he,isConfirmDeleteRowOpen:x,setIsConfirmDeleteRowOpen:j},s.map((se,ue)=>e.createElement(ya.Tr,{cursor:"pointer",key:s.id,onClick:it(se.id)},e.createElement(on.CheckboxDataCell,{rowId:se.id,index:ue}),Pe.map(({key:Ee,name:ve,...Bt})=>U&&ve==="publishedAt"?e.createElement(qe.Td,{key:Ee},e.createElement(Jn.q,{width:"min-content",showBullet:!1,variant:se.publishedAt?"success":"secondary",size:"S"},e.createElement(W.Z,{fontWeight:"bold",textColor:`${se.publishedAt?"success":"secondary"}700`},R({id:(0,f.OB)(`containers.List.${se.publishedAt?"published":"draft"}`),defaultMessage:se.publishedAt?"Published":"Draft"})))):Y&&ve==="strapi_stage"?e.createElement(qe.Td,{key:Ee},se.strapi_stage?e.createElement(B,{color:se.strapi_stage.color??Sm.W.colors.primary600,name:se.strapi_stage.name}):e.createElement(W.Z,{textColor:"neutral800"},"-")):e.createElement(qe.Td,{key:Ee},e.createElement(pp,{content:se[ve.split(".")[0]],name:ve,contentType:m.contentType,...Bt,rowId:se.id}))),(o||a)&&I&&e.createElement(on.EntityActionsDataCell,{rowId:se.id,index:ue,setIsConfirmDeleteRowOpen:j,canCreate:t,canDelete:o,handleCloneClick:fe})))))),e.createElement(P.k,{alignItems:"flex-end",justifyContent:"space-between"},e.createElement(y.v4,{trackedEvent:"willChangeNumberOfEntriesPerPage"}),e.createElement(y.tU,{pagination:{pageCount:u?.pageCount||1}}))):e.createElement(y.ZF,null))):null}Ka.propTypes={canCreate:n().bool.isRequired,canDelete:n().bool.isRequired,canRead:n().bool.isRequired,canPublish:n().bool.isRequired,data:n().array.isRequired,layout:n().exact({components:n().object.isRequired,contentType:n().shape({uid:n().string.isRequired,attributes:n().object.isRequired,metadatas:n().object.isRequired,info:n().shape({displayName:n().string.isRequired}).isRequired,layouts:n().shape({list:n().array.isRequired}).isRequired,options:n().object.isRequired,settings:n().object.isRequired}).isRequired}).isRequired,isLoading:n().bool.isRequired,getData:n().func.isRequired,getDataSucceeded:n().func.isRequired,pagination:n().shape({total:n().number.isRequired,pageCount:n().number}).isRequired,slug:n().string.isRequired};const Ep=Um();function bp(t){return(0,Ea.bindActionCreators)({getData:Im,getDataSucceeded:Pm,onChangeListHeaders:No,onResetListHeaders:xm},t)}const vp=(0,ae.$j)(Ep,bp);var Cp=(0,Ea.compose)(vp)(e.memo(Ka,ke()));const Qo=t=>{const o=(0,e.useMemo)(()=>(0,f.TA)(t.slug),[t.slug]),{isLoading:r,allowedActions:a}=(0,y.ss)(o,t.permissions);return r?e.createElement(y.dO,null):e.createElement(Cp,{...t,...a})};Qo.defaultProps={permissions:[]},Qo.propTypes={permissions:n().array,slug:n().string.isRequired};var Rp=(0,e.memo)(Qo,(t,o)=>{const r=(0,y.e5)(t,o);return Object.keys(r).filter(s=>s!=="state").length>0});const Ya=({layout:t,...o})=>{const r=(0,ae.I0)(),{replace:a}=(0,re.k6)(),[{query:s,rawQuery:c}]=(0,y.Kx)(),i=(0,oe.r5)(s,o.slug,"listView"),d=(0,oe.Ky)(o.slug);return(0,e.useEffect)(()=>{c||a(d)},[c,a,d]),(0,e.useEffect)(()=>{r(Lm(t))},[r,t]),(0,e.useEffect)(()=>()=>{r(Zm())},[r]),i?e.createElement(Rp,{...o,layout:t,permissions:i}):null};Ya.propTypes={layout:n().exact({components:n().object.isRequired,contentType:n().shape({attributes:n().object.isRequired,metadatas:n().object.isRequired,layouts:n().shape({list:n().array.isRequired}).isRequired,options:n().object.isRequired,settings:n().object.isRequired,pluginOptions:n().object}).isRequired}).isRequired,slug:n().string.isRequired};var Mp=Ya,Tp=()=>e.createElement(H.x,{padding:8},e.createElement(y.Hn,null));const Xa=({match:{params:{slug:t},url:o}})=>{const r=(0,ae.v9)(We._),{isLoading:a,layout:s,updateLayout:c}=(0,oe.zE)(t),{rawContentTypeLayout:i,rawComponentsLayouts:d}=(0,e.useMemo)(()=>{let E={},h={};return s.contentType&&(E=(0,f.du)(s.contentType)),s.components&&(h=Object.keys(s.components).reduce((g,b)=>(g[b]=(0,f.du)(s.components[b]),g),{})),{rawContentTypeLayout:E,rawComponentsLayouts:h}},[s]);if((s?.contentType?.uid??null)!==t||a)return e.createElement(y.dO,null);const u=({location:{state:E},history:{goBack:h},match:{params:{id:g,origin:b}}},C)=>e.createElement(C,{slug:t,layout:s,state:E,goBack:h,id:g,origin:b}),p=[{path:"create/clone/:origin",comp:tn},{path:"create",comp:tn},{path:":id",comp:tn},{path:"",comp:Mp}].map(({path:E,comp:h})=>e.createElement(re.AW,{key:E,path:`${o}/${E}`,render:g=>u(g,h)}));return e.createElement(nt.ErrorBoundary,{FallbackComponent:Tp},e.createElement(It.Provider,{value:s},e.createElement(re.rs,null,e.createElement(re.AW,{path:`${o}/configurations/list`},e.createElement(y.O4,{permissions:r.contentManager.collectionTypesConfigurations},e.createElement(Om,{layout:i,slug:t,updateLayout:c}))),e.createElement(re.AW,{path:`${o}/configurations/edit`},e.createElement(y.O4,{permissions:r.contentManager.collectionTypesConfigurations},e.createElement(Ln,{components:d,isContentTypeView:!0,mainLayout:i,slug:t,updateLayout:c}))),p)))};Xa.propTypes={match:n().shape({url:n().string.isRequired,params:n().shape({slug:n().string.isRequired}).isRequired}).isRequired};var Dp=(0,e.memo)(Xa),Ja=l(4214);const Op=()=>{const[{isLoading:t,data:o},r]=(0,e.useReducer)(Ja.Z,Ja.q),a=(0,e.useMemo)(mt.Vo,[]),{schemas:s}=(0,ae.v9)(m=>a(m),ae.wU),c=(0,ae.v9)(We._),{uid:i}=(0,re.UO)(),{get:d}=(0,y.kY)();return(0,e.useEffect)(()=>{const u=ze.default.CancelToken.source();return(async E=>{try{r(Ht());const{data:{data:h}}=await d(`/content-manager/components/${i}/configuration`,{cancelToken:E.token});r(kn((0,f.w8)(h,s,"component")))}catch(h){if(ze.default.isCancel(h))return;console.error(h)}})(u),()=>{u.cancel("Operation canceled by the user.")}},[i,s,d]),t?e.createElement(y.dO,null):e.createElement(y.O4,{permissions:c.contentManager.componentsConfigurations},e.createElement(Ln,{components:o.components,mainLayout:o.component,slug:i}))};var Ip=(0,e.memo)(Op),Pp=l(9695),xp=l(54725),Zp=()=>{const{formatMessage:t}=(0,K.Z)();return(0,y.go)(),e.createElement(Te.o,null,e.createElement(De.T,{title:t({id:(0,f.OB)("header.name"),defaultMessage:"Content"})}),e.createElement(Qe.D,null,e.createElement(Pp.x,{action:e.createElement(y.Qj,{variant:"secondary",startIcon:e.createElement(pt.Z,null),to:"/plugins/content-type-builder/content-types/create-content-type"},t({id:"app.components.HomePage.create",defaultMessage:"Create your first Content-type"})),content:t({id:"content-manager.pages.NoContentType.text",defaultMessage:"You don't have any content yet, we recommend you to create your first Content-Type."}),hasRadius:!0,icon:e.createElement(xp.Z,{width:"10rem"}),shadow:"tableShadow"})))},Lp=()=>{const{formatMessage:t}=(0,K.Z)();return(0,y.go)(),e.createElement(Te.o,null,e.createElement(De.T,{title:t({id:(0,f.OB)("header.name"),defaultMessage:"Content"})}),e.createElement(Qe.D,null,e.createElement(y.ZF,null)))};const _a=({match:{params:{slug:t},url:o}})=>{const r=(0,ae.v9)(We._),{isLoading:a,layout:s,updateLayout:c}=(0,oe.zE)(t),{rawContentTypeLayout:i,rawComponentsLayouts:d}=(0,e.useMemo)(()=>{let m={},u={};return s.contentType&&(u=(0,f.du)(s.contentType)),s.components&&(m=Object.keys(s.components).reduce((p,E)=>(p[E]=(0,f.du)(s.components[E]),p),{})),{rawContentTypeLayout:u,rawComponentsLayouts:m}},[s]);return a?e.createElement(y.dO,null):e.createElement(It.Provider,{value:s},e.createElement(re.rs,null,e.createElement(re.AW,{path:`${o}/configurations/edit`},e.createElement(y.O4,{permissions:r.contentManager.singleTypesConfigurations},e.createElement(Ln,{components:d,isContentTypeView:!0,mainLayout:i,slug:t,updateLayout:c}))),e.createElement(re.AW,{path:o,render:({location:{state:m},history:{goBack:u}})=>e.createElement(tn,{layout:s,slug:t,isSingleType:!0,state:m,goBack:u})})))};_a.propTypes={match:n().shape({url:n().string.isRequired,params:n().shape({slug:n().string.isRequired}).isRequired}).isRequired};var Sp=(0,e.memo)(_a),kp=l(16899);const Fp=(0,q.ZP)(P.k)`
|
|
1087
|
+
border-radius: 50%;
|
|
1088
|
+
|
|
1089
|
+
svg {
|
|
1090
|
+
height: ${6/16}rem;
|
|
1091
|
+
width: ${11/16}rem;
|
|
1092
|
+
> path {
|
|
1093
|
+
fill: ${({theme:t})=>t.colors.neutral600};
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
`,Ap=q.ZP.button`
|
|
1097
|
+
border: none;
|
|
1098
|
+
background: transparent;
|
|
1099
|
+
display: block;
|
|
1100
|
+
width: 100%;
|
|
1101
|
+
text-align: unset;
|
|
1102
|
+
padding: 0;
|
|
1103
|
+
`;function es({displayedValue:t}){return e.createElement(P.k,{background:"neutral0",borderColor:"neutral200",justifyContent:"space-between",gap:3,padding:3,width:(0,y.Q1)(300)},e.createElement(Ap,{type:"button"},e.createElement(P.k,{gap:6},e.createElement(Fp,{alignItems:"center",justifyContent:"center",background:"neutral200",height:(0,y.Q1)(32),width:(0,y.Q1)(32)},e.createElement(kp.Z,null)),e.createElement(P.k,{maxWidth:(0,y.Q1)(150)},e.createElement(W.Z,{textColor:"neutral700",ellipsis:!0},t)))),e.createElement(P.k,{gap:2},e.createElement(Re.h,{noBorder:!0},e.createElement(Ve.Z,null)),e.createElement(Re.h,{noBorder:!0},e.createElement(Ye.Z,null))))}es.propTypes={displayedValue:n().string.isRequired};const ts=({status:t,displayedValue:o,width:r})=>{const{formatMessage:a}=(0,K.Z)(),s={[at.DRAFT]:a({id:(0,f.OB)("relation.publicationState.draft"),defaultMessage:"Draft"}),[at.PUBLISHED]:a({id:(0,f.OB)("relation.publicationState.published"),defaultMessage:"Published"})},c=t===at.DRAFT?"secondary":"success";return e.createElement(H.x,{style:{width:r}},e.createElement(P.k,{paddingTop:2,paddingBottom:2,paddingLeft:2,paddingRight:4,hasRadius:!0,borderSize:1,background:"neutral0",borderColor:"neutral200",justifyContent:"space-between"},e.createElement(Nr,{gap:1},e.createElement(Re.h,{noBorder:!0},e.createElement(Ye.Z,null)),e.createElement(jr,{maxWidth:"100%",justifyContent:"space-between"},e.createElement(H.x,{minWidth:0,paddingTop:1,paddingBottom:1,paddingRight:4},e.createElement(Wr,null,e.createElement(W.Z,{textColor:"primary600",ellipsis:!0},o))),t&&e.createElement(Jn.q,{variant:c,showBullet:!1,size:"S"},e.createElement(W.Z,{fontWeight:"bold",textColor:`${c}700`},s[t])))),e.createElement(H.x,{paddingLeft:4},e.createElement(zr,{type:"button"},e.createElement(ft.J,{width:"12px",as:Gt.Z})))))};ts.propTypes={status:n().string.isRequired,displayedValue:n().string.isRequired,width:n().number.isRequired};var wp=l(90700),$p=l(78090),Bp=l(77013),Np=l(79318),jp=l(66618),Wp=()=>{const[t,o]=(0,e.useState)(""),{formatMessage:r,locale:a}=(0,K.Z)(),s=(0,e.useMemo)(mt.KQ,[]),{collectionTypeLinks:c,singleTypeLinks:i}=(0,ae.v9)(s,ae.wU),{startsWith:d}=(0,y.L0)(a,{sensitivity:"base"}),m=(0,y.Xe)(a,{sensitivity:"base"}),u=(0,e.useMemo)(()=>[{id:"collectionTypes",title:{id:(0,Se.Z)("components.LeftMenu.collection-types"),defaultMessage:"Collection Types"},searchable:!0,links:c},{id:"singleTypes",title:{id:(0,Se.Z)("components.LeftMenu.single-types"),defaultMessage:"Single Types"},searchable:!0,links:i}].map(g=>({...g,links:g.links.filter(b=>d(b.title,t)).sort((b,C)=>m.compare(b.title,C.title)).map(b=>({...b,title:r({id:b.title,defaultMessage:b.title})}))})),[c,t,i,d,r,m]),p=()=>{o("")},E=({target:{value:g}})=>{o(g)},h=r({id:(0,Se.Z)("header.name"),defaultMessage:"Content"});return e.createElement(wp.m,{ariaLabel:h},e.createElement($p.p,{label:h,searchable:!0,value:t,onChange:E,onClear:p,searchLabel:r({id:"content-manager.components.LeftMenu.Search.label",defaultMessage:"Search for a content type"})}),e.createElement(Bp.Z,null,u.map(g=>{const b=r({id:g.title.id,defaultMessage:g.title.defaultMessage},g.title.values);return e.createElement(Np.D,{key:g.id,label:b,badgeLabel:g.links.length.toString()},g.links.map(C=>{const I=C.search?`?${C.search}`:"";return e.createElement(jp.E,{as:gt.OL,key:C.uid,to:`${C.to}${I}`},C.title)}))})))},Ko=l(70475);const zp=()=>({type:Ko.fn}),Up=()=>({type:Ko.sZ}),Vp=({authorizedCollectionTypeLinks:t,authorizedSingleTypeLinks:o,contentTypeSchemas:r,components:a,fieldSizes:s})=>({type:Ko.IX,data:{authorizedCollectionTypeLinks:t,authorizedSingleTypeLinks:o,components:a,contentTypeSchemas:r,fieldSizes:s}});var ns=(t,o)=>o.map(({permissions:r})=>(0,y.qX)(t,r)),qp=l(81346),Hp=l.n(qp);const os=(t,o,r=[])=>t.filter(a=>a.isDisplayed).map(a=>{const s=[{action:"plugin::content-manager.explorer.create",subject:a.uid},{action:"plugin::content-manager.explorer.read",subject:a.uid}],c=[{action:"plugin::content-manager.explorer.read",subject:a.uid}],i=o==="collectionTypes"?s:c,d=r.find(({uid:u})=>u===a.uid);let m=null;if(d){const u={page:1,pageSize:d.settings.pageSize,sort:`${d.settings.defaultSortBy}:${d.settings.defaultSortOrder}`};m=(0,Fo.stringify)(u,{encode:!1})}return{permissions:i,search:m,kind:a.kind,title:a.info.displayName,to:`/content-manager/${a.kind}/${a.uid}`,uid:a.uid,name:a.uid,isDisplayed:a.isDisplayed}});var Gp=(t,o)=>{const r=Object.entries(Hp()(t,"kind")).map(([c,i])=>({name:c,links:i})),[a,s]=dt()(r,"name");return{collectionTypeSectionLinks:os(a?.links||[],"collectionTypes",o),singleTypeSectionLinks:os(s?.links??[],"singleTypes")}},Qp=async({models:t,userPermissions:o,toggleNotification:r})=>{const{get:a}=(0,y.tg)();try{const{data:{data:s}}=await a((0,f.IF)("content-types-settings")),{collectionTypeSectionLinks:c,singleTypeSectionLinks:i}=Gp(t,s),d=await Promise.all(ns(o,c)),m=c.filter((E,h)=>d[h]),u=await Promise.all(ns(o,i)),p=i.filter((E,h)=>u[h]);return{authorizedCollectionTypeLinks:m,authorizedSingleTypeLinks:p}}catch(s){return console.error(s),r({type:"warning",message:{id:"notification.error"}}),{authorizedCollectionTypeLinks:[],authorizedSingleTypeLinks:[]}}},Kp=()=>{const t=(0,ae.I0)(),o=(0,y.lm)(),r=(0,ae.v9)((0,mt.Yg)()),a=(0,e.useRef)(),{allPermissions:s}=(0,y.vn)(),{runHookWaterfall:c}=(0,y.j1)(),d=ze.default.CancelToken.source(),{notifyStatus:m}=(0,jo.G)(),{formatMessage:u}=(0,K.Z)(),{get:p}=(0,y.kY)(),E=async()=>{t(zp());try{const{data:{data:{components:h,contentTypes:g,fieldSizes:b}}}=await p("/content-manager/init",{cancelToken:d.token});m(u({id:(0,f.OB)("App.schemas.data-loaded"),defaultMessage:"The schemas have been successfully loaded."}));const C=await Qp({models:g,userPermissions:s,toggleNotification:o}),{ctLinks:I}=c(Vt.LK,{ctLinks:C.authorizedCollectionTypeLinks,models:g}),{stLinks:v}=c(Vt.dV,{stLinks:C.authorizedSingleTypeLinks,models:g}),M=Vp({authorizedCollectionTypeLinks:I,authorizedSingleTypeLinks:v,contentTypeSchemas:g,components:h,fieldSizes:b});t(M)}catch(h){if(ze.default.isCancel(h))return;console.error(h),o({type:"warning",message:{id:"notification.error"}})}};return a.current=E,(0,e.useEffect)(()=>(a.current(),()=>{d.cancel("Operation canceled by the user."),t(Up())}),[t,o]),{...r,refetchData:a.current}};function Yp({type:t,item:o}){if([ut.Z.EDIT_FIELD,ut.Z.FIELD].includes(t))return e.createElement($t,{labelField:o.labelField});const[r]=t.split("_");switch(r){case ut.Z.COMPONENT:case ut.Z.DYNAMIC_ZONE:return e.createElement(es,{displayedValue:o.displayedValue});case ut.Z.RELATION:return e.createElement(ts,{displayedValue:o.displayedValue,status:o.status,width:o.width});default:return null}}const rs=()=>{const t=(0,re.$B)("/content-manager/:kind/:uid"),{status:o,collectionTypeLinks:r,singleTypeLinks:a,models:s,refetchData:c}=Kp(),i=dt()([...r,...a],g=>g.title.toLowerCase()),{pathname:d}=(0,re.TH)(),{formatMessage:m}=(0,K.Z)(),{startSection:u}=(0,y.c1)(),p=(0,e.useRef)(u),E=(0,ae.v9)(We._);if((0,e.useEffect)(()=>{p.current&&p.current("contentManager")},[]),o==="loading")return e.createElement(Te.o,{"aria-busy":"true"},e.createElement(De.T,{title:m({id:(0,Se.Z)("header.name"),defaultMessage:"Content"})}),e.createElement(y.dO,null));const h=s.filter(({isDisplayed:g})=>g);return i.length===0&&h.length>0&&d!=="/content-manager/403"?e.createElement(re.l_,{to:"/content-manager/403"}):h.length===0&&d!=="/content-manager/no-content-types"?e.createElement(re.l_,{to:"/content-manager/no-content-types"}):!t&&i.length>0?e.createElement(re.l_,{to:`${i[0].to}${i[0].search?`?${i[0].search}`:""}`}):e.createElement(tt.A,{sideNav:e.createElement(Wp,null)},e.createElement(Tt.r,{renderItem:Yp}),e.createElement(Ot.Provider,{value:{refetchData:c}},e.createElement(re.rs,null,e.createElement(re.AW,{path:"/content-manager/components/:uid/configurations/edit"},e.createElement(y.O4,{permissions:E.contentManager.componentsConfigurations},e.createElement(Ip,null))),e.createElement(re.AW,{path:"/content-manager/collectionType/:slug",component:Dp}),e.createElement(re.AW,{path:"/content-manager/singleType/:slug",component:Sp}),e.createElement(re.AW,{path:"/content-manager/403"},e.createElement(Lp,null)),e.createElement(re.AW,{path:"/content-manager/no-content-types"},e.createElement(Zp,null)),e.createElement(re.AW,{path:"",component:y.Hn}))))};function Xp(){const{formatMessage:t}=(0,K.Z)();return e.createElement(e.Fragment,null,e.createElement(Ge.q,{title:t({id:(0,Se.Z)("plugin.name"),defaultMessage:"Content Manager"})}),e.createElement(rs,null))}},98865:function(Yo,ct,l){"use strict";l.d(ct,{d:function(){return Jo}});var e=l(32735),Te=l(87933),De=l(49372),tt=l(72850),y=l(9026),Mt=l(19565),dt=l(60216),Ge=l.n(dt),K=l(67879),ae=l(86209),re=l(97724);const Tt=60*1e3,We=Tt*60,Dt=We*24,Ot=Dt*30,Se=Dt*365;var xe=oe=>oe<Tt?{unit:"second",value:-Math.round(oe/1e3)}:oe<We?{unit:"minute",value:-Math.round(oe/Tt)}:oe<Dt?{unit:"hour",value:-Math.round(oe/We)}:oe<Ot?{unit:"day",value:-Math.round(oe/Dt)}:oe<Se?{unit:"month",value:-Math.round(oe/Ot)}:{unit:"year",value:-Math.round(oe/Se)};const n=()=>{const{formatMessage:oe}=(0,K.Z)();return e.createElement(Te.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(De.Z,{variant:"sigma",textColor:"neutral600",id:"additional-information"},oe({id:(0,re.OB)("containers.Edit.information"),defaultMessage:"Information"})),e.createElement(tt.x,null,e.createElement(y.i,null)))},nt=({label:oe,value:f})=>e.createElement(Te.k,{justifyContent:"space-between"},e.createElement(De.Z,{as:"dt",fontWeight:"bold",textColor:"neutral800",variant:"pi"},oe),e.createElement(De.Z,{as:"dd",variant:"pi",textColor:"neutral600"},f));nt.propTypes={label:Ge().string.isRequired,value:Ge().string.isRequired};const Xo=()=>{const{formatMessage:oe,formatRelativeTime:f}=(0,K.Z)(),{initialData:le,isCreatingEntry:Qe}=(0,Mt.Wq)(),H=(0,e.useRef)(Date.now()),P=(be,Ae)=>{const{firstname:Ce,lastname:jt,username:ot}=le[Ae]??{},we=Ce??"",an=jt??"",$e=ot??(0,ae.Pp)(we,an),Wt=(le[be]?new Date(le[be]).getTime():Date.now())-H.current,{unit:sn,value:Z}=xe(-Wt);return{at:f(Z,sn,{numeric:"auto"}),by:Qe?"-":$e}},W=P("updatedAt","updatedBy"),Oe=P("createdAt","createdBy");return e.createElement(Te.k,{direction:"column",alignItems:"stretch",gap:4},e.createElement(Te.k,{direction:"column",alignItems:"stretch",gap:2,as:"dl"},e.createElement(nt,{label:oe({id:(0,re.OB)("containers.Edit.information.created"),defaultMessage:"Created"}),value:Oe.at}),e.createElement(nt,{label:oe({id:(0,re.OB)("containers.Edit.information.by"),defaultMessage:"By"}),value:Oe.by})),e.createElement(Te.k,{direction:"column",alignItems:"stretch",gap:2,as:"dl"},e.createElement(nt,{label:oe({id:(0,re.OB)("containers.Edit.information.lastUpdate"),defaultMessage:"Last update"}),value:W.at}),e.createElement(nt,{label:oe({id:(0,re.OB)("containers.Edit.information.by"),defaultMessage:"By"}),value:W.by})))},It=({children:oe})=>e.createElement(Te.k,{direction:"column",alignItems:"stretch",gap:4},oe);It.propTypes={children:Ge().oneOfType([Ge().arrayOf(Ge().node),Ge().node]).isRequired};const Jo={Root:It,Title:n,Body:Xo}},99097:function(Yo,ct,l){"use strict";var e=l(32735);const Te=(De,tt)=>{const[y,Mt]=(0,e.useState)(De);return(0,e.useEffect)(()=>{const dt=setTimeout(()=>{Mt(De)},tt);return()=>{clearTimeout(dt)}},[De,tt]),y};ct.Z=Te},62433:function(){},15498:function(){},73353:function(){},12998:function(){},74492:function(){}}]);
|