@strapi/admin 4.12.2 → 4.13.0-beta.0
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/DynamicTable/CellContent/ReviewWorkflowsStage/getTableColumns.js +2 -0
- package/admin/src/content-manager/components/EditViewDataManagerProvider/reducer.js +8 -1
- package/admin/src/content-manager/components/Filter/CustomInputs/AdminUsersFilter.js +42 -0
- package/admin/src/content-manager/components/{AttributeFilter/Filters.js → Filter/Filter.js} +5 -7
- package/admin/src/content-manager/components/Filter/index.js +1 -0
- package/admin/src/content-manager/hooks/useAllowedAttributes.js +47 -0
- package/admin/src/content-manager/hooks/useSyncRbac/index.js +10 -2
- package/admin/src/content-manager/pages/EditView/Information/index.js +9 -8
- package/admin/src/content-manager/pages/EditViewLayoutManager/index.js +2 -2
- package/admin/src/content-manager/pages/ListSettingsView/components/Settings.js +40 -7
- package/admin/src/content-manager/pages/ListSettingsView/index.js +6 -2
- package/admin/src/content-manager/pages/ListView/components/FieldPicker/index.js +67 -69
- package/admin/src/content-manager/pages/ListView/components/ViewSettingsMenu/index.js +74 -0
- package/admin/src/content-manager/pages/ListView/index.js +254 -68
- package/admin/src/content-manager/pages/ListViewLayoutManager/index.js +2 -2
- package/admin/src/content-manager/utils/getDisplayName.js +33 -0
- package/admin/src/content-manager/utils/index.js +1 -0
- package/admin/src/translations/en.json +3 -1
- package/admin/src/translations/zh-Hans.json +918 -902
- package/build/1227.32fe57ce.chunk.js +1 -0
- package/build/4174.fa8f9954.chunk.js +1 -0
- package/build/4546.ff09eeda.chunk.js +1 -0
- package/build/4724.baf7c5b1.chunk.js +6 -0
- package/build/6158.c3c13c20.chunk.js +1 -0
- package/build/78.dcc6df5c.chunk.js +1 -0
- package/build/{9806.3392505e.chunk.js → 9806.5d5a0e8d.chunk.js} +16 -16
- package/build/{Admin-authenticatedApp.3c585a0d.chunk.js → Admin-authenticatedApp.53a24d28.chunk.js} +2 -2
- package/build/audit-logs-settings-page.0f73ccf8.chunk.js +1 -0
- package/build/content-manager.7f96a2f1.chunk.js +1097 -0
- package/build/{content-type-builder.40534de5.chunk.js → content-type-builder.cd999f6e.chunk.js} +2 -2
- package/build/{en-json.08c05fcf.chunk.js → en-json.4f06fe03.chunk.js} +1 -1
- package/build/i18n-translation-ru-json.a3dbc125.chunk.js +1 -0
- package/build/index.html +1 -1
- package/build/main.40b94779.js +2859 -0
- package/build/{runtime~main.2902859a.js → runtime~main.b16af570.js} +2 -2
- package/build/users-permissions-translation-zh-Hans-json.8d82c809.chunk.js +1 -0
- package/build/{users-roles-settings-page.3f9f063e.chunk.js → users-roles-settings-page.9d9a1eff.chunk.js} +1 -1
- package/build/zh-Hans-json.97efd015.chunk.js +1 -0
- package/ee/admin/content-manager/components/Filter/CustomInputs/ReviewWorkflows/AssigneeFilter.js +42 -0
- package/ee/admin/content-manager/components/Filter/CustomInputs/ReviewWorkflows/StageFilter.js +70 -0
- package/ee/admin/content-manager/components/Filter/CustomInputs/ReviewWorkflows/constants.js +71 -0
- package/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js +9 -217
- package/ee/admin/content-manager/pages/EditView/InformationBox/components/AssigneeSelect/AssigneeSelect.js +149 -0
- package/ee/admin/content-manager/pages/EditView/InformationBox/components/AssigneeSelect/index.js +1 -0
- package/ee/admin/content-manager/pages/EditView/InformationBox/components/StageSelect/StageSelect.js +241 -0
- package/ee/admin/content-manager/pages/EditView/InformationBox/components/StageSelect/index.js +1 -0
- package/ee/admin/content-manager/pages/EditView/InformationBox/constants.js +2 -0
- package/ee/admin/content-manager/pages/ListSettingsView/constants.js +7 -0
- package/ee/admin/content-manager/pages/ListView/ReviewWorkflowsColumn/ReviewWorkflowsAssigneeEE.js +51 -0
- package/ee/admin/content-manager/pages/ListView/ReviewWorkflowsColumn/constants.js +44 -17
- package/ee/admin/content-manager/pages/ListView/ReviewWorkflowsColumn/index.js +1 -0
- package/ee/server/constants/workflows.js +1 -0
- package/ee/server/controllers/index.js +1 -0
- package/ee/server/controllers/workflows/assignees/index.js +44 -0
- package/ee/server/routes/review-workflows.js +17 -0
- package/ee/server/services/index.js +1 -0
- package/ee/server/services/review-workflows/assignees.js +54 -0
- package/ee/server/services/review-workflows/metrics/index.js +5 -0
- package/ee/server/services/review-workflows/review-workflows.js +20 -11
- package/ee/server/validation/review-workflows.js +8 -0
- package/package.json +10 -10
- package/server/services/permission/permissions-manager/sanitize.js +12 -0
- package/admin/src/content-manager/components/AttributeFilter/hooks/useAllowedAttributes.js +0 -42
- package/admin/src/content-manager/components/AttributeFilter/index.js +0 -40
- package/build/3984.dda474f7.chunk.js +0 -1
- package/build/4546.cfafae68.chunk.js +0 -1
- package/build/5483.6dd2e776.chunk.js +0 -6
- package/build/6158.c974fd83.chunk.js +0 -1
- package/build/audit-logs-settings-page.4b422831.chunk.js +0 -1
- package/build/content-manager.2af15f57.chunk.js +0 -1099
- package/build/i18n-translation-ru-json.401bc498.chunk.js +0 -1
- package/build/main.f13fc96c.js +0 -2856
- package/build/users-permissions-translation-zh-Hans-json.6ab714ee.chunk.js +0 -1
- package/build/zh-Hans-json.937b395b.chunk.js +0 -1
|
@@ -0,0 +1,1097 @@
|
|
|
1
|
+
(self.webpackChunk_strapi_admin=self.webpackChunk_strapi_admin||[]).push([[994],{75850:function(an,et,i){"use strict";i.r(et),i.d(et,{App:function(){return us},default:function(){return Jp}});var e=i(32735),Te=i(27649),Oe=i(82055),Ge=i(96709),f=i(19565),Qe=i(98978),Ke=i.n(Qe),ze=i(74758),H=i(67879),re=i(15062),le=i(53038),lt=i(17379),Pe=i(30305),Tt=(0,e.createContext)(),Ve=i(7921),ct=i(24381),xe=i(60216),n=i.n(xe),sn=i(47533),wt=(0,e.createContext)(),ye=i(75430),be=i(69242),y=i(69997),ue=i(41415),tt=i(17e3),Q=i(72850),D=i(87933),W=i(49372),Se=i(15335),ve=i(5803),Ue=i(68465),Re=i(84967),cn=i(9026),dt=i(29439),we=i(66456),dn=i(99381),Ye=i.n(dn),ms=i(89793),Fe=i.n(ms),ps=i(23940),Dt=i.n(ps),Ne=i(20108),gt=i(20716),ge=i(1594),ft=i(19406),nt=i(68625),gs=i(33795),w=i.n(gs);const ar=e.createContext();function un({attributes:t,buttonData:o,children:r,goTo:a,layout:s,metadatas:l,moveItem:c,moveRow:d,onAddData:p,relationsLayout:m,removeField:u,selectedItemName:h,setEditFieldToSelect:E,...g}){return e.createElement(ar.Provider,{value:{attributes:t,buttonData:o,goTo:a,layout:s,metadatas:l,moveItem:c,moveRow:d,onAddData:p,relationsLayout:m,removeField:u,selectedItemName:h,setEditFieldToSelect:E,...g}},r)}un.defaultProps={attributes:{},buttonData:[],goTo(){},layout:[],metadatas:{},moveItem(){},moveRow(){},onAddData(){},relationsLayout:[],removeField(){},selectedItemName:null,setEditFieldToSelect(){}},un.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 ut(){return e.useContext(ar)}const fs=[{action:"plugin::content-type-builder.read",subject:null}];var hs=()=>{const{trackUsage:t}=(0,f.rS)(),{formatMessage:o}=(0,H.Z)(),{slug:r,modifiedData:a,isContentTypeView:s}=ut(),l=s?"content-types":"components",c=`/plugins/content-type-builder/${l==="content-types"?l:"component-categories"}`,d=w()(a,"category",""),p=l==="content-types"?r:`${d}/${r}`,m=()=>{t("willEditEditLayout")};return r==="strapi::administrator"?null:e.createElement(f.jW,{permissions:fs},e.createElement(f.Qj,{to:`${c}/${p}`,onClick:m,size:"S",startIcon:e.createElement(nt.Z,null),variant:"secondary"},o({id:(0,Ve.Z)(`edit-settings-view.link-to-ctb.${l}`),defaultMessage:"Edit the content type"})))},ot=i(47081),Nt=i(74506),Ot=i(51968),U=i(8471),Me=i(50563),Xe=i(4038),mn=i(45112);const sr=({componentUid:t})=>{const{componentLayouts:o}=ut(),{formatMessage:r}=(0,H.Z)(),a=w()(o,[t],{}),s=w()(a,["layouts","edit"],[]);return e.createElement(Q.x,{padding:3},s.map((l,c)=>e.createElement(Se.r,{gap:4,key:c},l.map(d=>e.createElement(ve.P,{key:d.name,col:d.size},e.createElement(Q.x,{paddingTop:2},e.createElement(D.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(Q.x,{paddingTop:2},e.createElement(f.rU,{startIcon:e.createElement(mn.Z,null),to:`/content-manager/components/${t}/configurations/edit`},r({id:(0,Ve.Z)("components.FieldItem.linkToComponentLayout"),defaultMessage:"Set the component's layout"}))))};sr.propTypes={componentUid:n().string.isRequired};var Es=sr,It=i(14911),ht=i(99140),ys=i(55805),bs=i(31206),vs=i(97075),Cs=i(14949),Rs=i(8482),Ms=i(65261),Ts=i(55877),Ds=i(84298),pn=i(73906),Os=i(37272),Is=i(67121),Ps=i(39869),ir=i(35635),Ss=i(26366),Zs=i(98464),xs=i(2362),Ls=i(89992),ks=i(10473),As=i(95971),Fs=i(72536),$s=i(68312),lr=i(80601),cr=i(74464),Bs=i(70809),ws=i(98148),Ns=i(81424),Ws=i(69317),js=i(25789),zs=i(77359),Vs=i(50416),Us=i(20015),qs=i(20276),Hs=i(82068),Gs=i(41645),Qs=i(61294),Ks=i(65943),Ys=i(8606),Xs=i(7961),Js=i(92967),dr=i(18070),_s=i(54894),ei=i(30285),ti=i(96011),ni=i(47041),oi=i(60625),ur=i(5644),ri=i(78150),ai=i(63717),si=i(24609),ii=i(86543),li=i(62864),ci=i(92989),di=i(49886),ui=i(47052),mi=i(50694),pi=i(81875),gi=i(92323),gn=i(49844),fi=i(11631),hi=i(9254),fn=i(2669),Ei=i(18709),yi=i(20258),mr=i(43231),bi=i(45147),vi=i(23154),Ci=i(26253),Ri=i(79634),Mi=i(32548),Ti=i(99482),Di=i(45323),Oi=i(76994),Ii=i(88777),Pi=i(95703),Si=i(8981),Zi=i(7733),xi=i(10168),Li=i(25449),ki=i(83900),Ai=i(32645),Fi=i(78429),$i=i(9882),pr=i(11417),Bi=i(39698),wi=i(92168),Ni=i(69621),Wi=i(2438),ji=i(92254),zi=i(2287),Vi=i(29685),gr=i(65663),hn=i(44647),Ui=i(5502),qi=i(31047),Hi=i(93307),Gi=i(78055),Qi=i(51239),Ki=i(6792),Yi=i(75156),Xi=i(80683),Ji=i(2689),_i=i(40202),el=i(36919),tl=i(75444),nl=i(92003),ol=i(4511),rl=i(2847),fr=i(83139),al=i(53779),sl=i(72890),il=i(84411),ll=i(37193),cl=i(74831),dl=i(99221),ul=i(34119),En=i(99283),ml=i(21371),pl=i(70727),gl=i(42213),fl=i(8611),hl=i(20448),El=i(73165);const hr={alien:ys.Z,apps:bs.Z,archive:vs.Z,arrowDown:Cs.Z,arrowLeft:dt.Z,arrowRight:Rs.Z,arrowUp:Ms.Z,attachment:Ts.Z,bell:Ds.Z,bold:pn.Z,book:Os.Z,briefcase:Is.Z,brush:Ps.Z,bulletList:ir.Z,calendar:Ss.Z,car:Zs.Z,cast:xs.Z,chartBubble:Ls.Z,chartCircle:ks.Z,chartPie:As.Z,check:we.Z,clock:Fs.Z,cloud:$s.Z,code:lr.Z,cog:mn.Z,collapse:cr.Z,command:Bs.Z,connector:ws.Z,crop:Ns.Z,crown:Ws.Z,cube:js.Z,cup:zs.Z,cursor:Vs.Z,dashboard:Us.Z,database:qs.Z,discuss:Hs.Z,doctor:Gs.Z,earth:Qs.Z,emotionHappy:Ks.Z,emotionUnhappy:Ys.Z,envelop:Xs.Z,exit:Js.Z,expand:dr.Z,eye:_s.Z,feather:ei.Z,file:ti.Z,fileError:ni.Z,filePdf:oi.Z,filter:ur.Z,folder:ri.Z,gate:ai.Z,gift:si.Z,globe:ii.Z,grid:li.Z,handHeart:ci.Z,hashtag:di.Z,headphone:ui.Z,heart:mi.Z,house:pi.Z,information:gi.Z,italic:gn.Z,key:fi.Z,landscape:hi.Z,layer:fn.Z,layout:Ei.Z,lightbulb:yi.Z,link:mr.Z,lock:bi.Z,magic:vi.Z,manyToMany:Ci.Z,manyToOne:Ri.Z,manyWays:Mi.Z,medium:Ti.Z,message:Di.Z,microphone:Oi.Z,monitor:Ii.Z,moon:Pi.Z,music:Si.Z,oneToMany:Zi.Z,oneToOne:xi.Z,oneWay:Li.Z,paint:ki.Z,paintBrush:Ai.Z,paperPlane:Fi.Z,pencil:nt.Z,phone:$i.Z,picture:pr.Z,pin:Bi.Z,pinMap:wi.Z,plane:Ni.Z,play:Wi.Z,plus:ft.Z,priceTag:ji.Z,puzzle:zi.Z,question:Vi.Z,quote:gr.Z,refresh:hn.Z,repeat:Ui.Z,restaurant:qi.Z,rocket:Hi.Z,rotate:Gi.Z,scissors:Qi.Z,search:Ki.Z,seed:Yi.Z,server:Xi.Z,shield:Ji.Z,shirt:_i.Z,shoppingCart:el.Z,slideshow:tl.Z,stack:nl.Z,star:ol.Z,store:rl.Z,strikeThrough:fr.Z,sun:al.Z,television:sl.Z,thumbDown:il.Z,thumbUp:ll.Z,train:cl.Z,twitter:dl.Z,typhoon:ul.Z,underline:En.Z,user:ml.Z,volumeMute:pl.Z,volumeUp:gl.Z,walk:fl.Z,wheelchair:hl.Z,write:El.Z};function Pt({showBackground:t=!0,size:o="M",icon:r}){return e.createElement(D.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(ht.J,{as:hr[r]||hr.cube,height:o==="S"?3:5,width:o==="S"?3:5}))}Pt.defaultProps={showBackground:!0,size:"M",icon:"Cube"},Pt.propTypes={showBackground:n().bool,size:n().string,icon:n().string};const yl=(0,U.ZP)(D.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
|
+
`,Er=({components:t})=>{const{componentLayouts:o}=ut();return e.createElement(D.k,{gap:2,overflow:"scroll hidden",padding:3},t.map(r=>e.createElement(yl,{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:It.rU,to:`/content-manager/components/${r}/configurations/edit`},e.createElement(Pt,{icon:o?.[r]?.info?.icon}),e.createElement(Q.x,{paddingTop:1},e.createElement(W.Z,{fontSize:1,textColor:"neutral600",fontWeight:"bold"},o?.[r]?.info?.displayName??"")))))};Er.propTypes={components:n().arrayOf(n().string).isRequired};var bl=Er;const yr=(0,U.ZP)(Me.h)`
|
|
28
|
+
background-color: transparent;
|
|
29
|
+
path {
|
|
30
|
+
fill: ${({theme:t})=>t.colors.neutral600};
|
|
31
|
+
}
|
|
32
|
+
`,yn=({attribute:t,onEditField:o,onDeleteField:r,children:a})=>{const{formatMessage:s}=(0,H.Z)();return e.createElement(Q.x,{overflow:"hidden",width:"100%"},e.createElement(D.k,{paddingLeft:3,alignItems:"center",justifyContent:"space-between"},e.createElement(W.Z,{fontWeight:"semiBold",textColor:"neutral800",ellipsis:!0},a),e.createElement(D.k,null,e.createElement(yr,{label:s({id:(0,y.OB)("containers.ListSettingsView.modal-form.edit-label"),defaultMessage:"Edit {fieldName}"},{fieldName:a}),onClick:o,icon:e.createElement(nt.Z,null),noBorder:!0}),e.createElement(yr,{label:s({id:"global.delete-target",defaultMessage:"Delete {target}"},{target:a}),"data-testid":"delete-field",onClick:r,icon:e.createElement(Xe.Z,null),noBorder:!0}))),t?.type==="component"&&e.createElement(Es,{componentUid:t.component}),t?.type==="dynamiczone"&&e.createElement(bl,{components:t.components}))};yn.defaultProps={attribute:void 0},yn.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 vl=yn;const Cl=(0,U.ZP)(D.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
|
+
`,Rl=(0,U.ZP)(ot.Z)`
|
|
65
|
+
height: ${12/16}rem;
|
|
66
|
+
width: ${12/16}rem;
|
|
67
|
+
path {
|
|
68
|
+
fill: ${({theme:t})=>t.colors.neutral600};
|
|
69
|
+
}
|
|
70
|
+
`,Ml=(0,U.ZP)(D.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
|
+
`,Tl=(0,U.ZP)(D.k)`
|
|
74
|
+
cursor: all-scroll;
|
|
75
|
+
border-right: 1px solid ${({theme:t})=>t.colors.neutral200};
|
|
76
|
+
`,bn=({attribute:t,children:o,index:r,lastIndex:a,moveItem:s,moveRow:l,name:c,onDeleteField:d,onEditField:p,rowIndex:m,size:u})=>{const[h,E]=(0,e.useState)(!1),g=c==="_TEMP_",{setIsDraggingSibling:b}=ut(),C=u===12,L=(0,e.useRef)(null),v=(0,e.useRef)(null),[{clientOffset:R,isOver:x},V]=(0,Nt.useDrop)({accept:y._Q.EDIT_FIELD,hover(F,S){if(!v.current||F.size!==12)return;const I=S.getItem().index,A=r,q=S.getItem().rowIndex,K=m;if(I===A&&q===K)return;const k=v.current.getBoundingClientRect(),z=(k.bottom-k.top)/2,ce=S.getClientOffset().y-k.top;q<K&&ce<z||q>K&&ce>z||(l(q,K),F.rowIndex=K,F.itemIndex=A)},drop(F,S){if(!v.current)return;const I=S.getItem().index,A=r,q=S.getItem().rowIndex,K=m;if(F.size===12||I===A&&q===K)return;const k=v.current.getBoundingClientRect();if(Math.abs(S.getClientOffset().x-k.left)>k.width/1.8){s(I,A+1,q,K),F.itemIndex=A+1,F.rowIndex=K;return}s(I,A,q,K),F.itemIndex=A,F.rowIndex=K},collect:F=>({canDrop:F.canDrop(),clientOffset:F.getClientOffset(),isOver:F.isOver(),isOverCurrent:F.isOver({shallow:!0}),itemType:F.getItemType()})}),[{isDragging:M,getItem:O},j,$]=(0,Nt.useDrag)({type:y._Q.EDIT_FIELD,item(){return b(!0),{index:r,labelField:o,rowIndex:m,name:c,size:u}},canDrag(){return c!=="_TEMP_"},collect:F=>({isDragging:F.isDragging(),getItem:F.getItem()}),end(){b(!1)}});(0,e.useEffect)(()=>{$((0,Ot.rX)(),{captureDraggingState:!0})},[$]);const P={dragRef:j(L),dropRef:V(v)};let N=!1,Y=!1;if(v.current&&R){const F=v.current.getBoundingClientRect();N=x&&O.size!==12&&Math.abs(R.x-F.left)<F.width/2,Y=x&&O.size!==12&&Math.abs(R.x-F.left)>F.width/2,c==="_TEMP_"&&(N=x&&O.size!==12,Y=!1)}const T=()=>t&&C?`${74/16}rem`:`${32/16}rem`,X=r===0&&!C,G=r===a&&!C,J=r!==0&&!C;return e.createElement(ve.P,{col:u},e.createElement(Cl,{ref:P.dropRef,showLeftCarret:N,showRightCarret:Y,isFirst:X,isLast:G,hasHorizontalPadding:J,onDrag:()=>{C&&!h&&E(!0)},onDragEnd:()=>{C&&E(!1)}},h&&C&&e.createElement(Q.x,{width:"100%",height:"2px",background:"primary600"}),e.createElement(Ml,{width:C&&h?0:"100%",borderColor:"neutral150",hasRadius:!0,background:"neutral100",minHeight:T(),alignItems:"stretch",isDragging:M,dragStart:h,isFullSize:C,isHidden:g},e.createElement(Tl,{as:"span",type:"button",ref:P.dragRef,onClick:F=>F.stopPropagation(),alignItems:"center",paddingLeft:3,paddingRight:3,tabIndex:-1},e.createElement(Rl,null)),!g&&e.createElement(vl,{attribute:t,onEditField:p,onDeleteField:d},o))))};bn.defaultProps={attribute:void 0},bn.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 Dl=bn;const br=({rowItem:t,onRemoveField:o,rowId:r,rowIndex:a,index:s,lastIndex:l})=>{const{setEditFieldToSelect:c,attributes:d,modifiedData:p,moveRow:m,moveItem:u}=ut(),h=w()(d,[t.name],{}),E=w()(p,["metadatas",t.name,"edit","label"],"");return e.createElement(Dl,{onEditField:()=>c(t.name),onDeleteField:()=>o(r,s),attribute:h,index:s,lastIndex:l,rowIndex:a,name:t.name,size:t.size,moveRow:m,moveItem:u},E||t.name)};br.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 Ol=br;const vr=({row:t,onRemoveField:o,rowIndex:r})=>e.createElement(Se.r,null,t.rowContent.map((a,s)=>e.createElement(Ol,{key:a.name,rowItem:a,index:s,rowId:t.rowId,onRemoveField:o,rowIndex:r,lastIndex:t.rowContent.length-1})));vr.propTypes={onRemoveField:n().func.isRequired,row:n().object.isRequired,rowIndex:n().number.isRequired};var Il=vr;const Cr=({editLayout:t,fields:o,onRemoveField:r,onAddField:a})=>{const{formatMessage:s}=(0,H.Z)();return e.createElement(D.k,{direction:"column",alignItems:"stretch",gap:4},e.createElement(D.k,{justifyContent:"space-between"},e.createElement("div",null,e.createElement(Q.x,null,e.createElement(W.Z,{fontWeight:"bold"},s({id:(0,y.OB)("containers.ListPage.displayedFields"),defaultMessage:"Displayed fields"}))),e.createElement(Q.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(hs,null)),e.createElement(Q.x,{padding:4,hasRadius:!0,borderStyle:"dashed",borderWidth:"1px",borderColor:"neutral300"},e.createElement(D.k,{direction:"column",alignItems:"stretch",gap:2},t.map((l,c)=>e.createElement(Il,{key:l.rowId,row:l,rowIndex:c,onRemoveField:r})),e.createElement(ge.fC,null,e.createElement(ge.xz,{startIcon:e.createElement(ft.Z,null),endIcon:null,disabled:o.length===0,fullWidth:!0,variant:"secondary"},s({id:(0,y.OB)("containers.SettingPage.add.field"),defaultMessage:"Insert another field"})),e.createElement(ge.VY,null,o.map(l=>e.createElement(ge.ck,{key:l,onSelect:()=>a(l)},l)))))))};Cr.propTypes={editLayout:n().array.isRequired,fields:n().array.isRequired,onAddField:n().func.isRequired,onRemoveField:n().func.isRequired};var Pl=Cr,vn=i(85025),Cn=i(55225),Rn=i(31600),Mn=i(11406),St=i(32031),Sl=i(73779),Wt=i(88675),Zl=i(22348),Rr=i(7184),Tn=i(43475),xl=i(82512),Dn=i(83218),Ll=i(872),kl=i(17757),Al=i(1176),Fl=i(15431);const Mr={biginteger:e.createElement(St.Z,null),boolean:e.createElement(Sl.Z,null),date:e.createElement(Wt.Z,null),datetime:e.createElement(Wt.Z,null),decimal:e.createElement(St.Z,null),email:e.createElement(Zl.Z,null),enum:e.createElement(Rr.Z,null),enumeration:e.createElement(Rr.Z,null),file:e.createElement(Tn.Z,null),files:e.createElement(Tn.Z,null),float:e.createElement(St.Z,null),integer:e.createElement(St.Z,null),media:e.createElement(Tn.Z,null),number:e.createElement(St.Z,null),relation:e.createElement(xl.Z,null),string:e.createElement(Dn.Z,null),text:e.createElement(Dn.Z,null),richtext:e.createElement(Dn.Z,null),time:e.createElement(Wt.Z,null),timestamp:e.createElement(Wt.Z,null),json:e.createElement(Ll.Z,null),uid:e.createElement(kl.Z,null),component:e.createElement(Al.Z,null),dynamiczone:e.createElement(Fl.Z,null)},On=({type:t,customFieldUid:o})=>{const r=(0,f.mZ)();let a=Mr[t];if(o){const l=r.get(o).icon;l&&(a=e.createElement(Q.x,{marginRight:3,width:7,height:6},e.createElement(l,null)))}return Mr[t]?a:null};On.defaultProps={customFieldUid:null},On.propTypes={type:n().string.isRequired,customFieldUid:n().string};var Tr=On,$l=t=>t.reduce((o,r)=>{const a=r?.attributes??{},s=Object.keys(a).filter(l=>!["boolean","component","dynamiczone","json","media","password","relation","text","richtext"].includes(a?.[l]?.type??""));return o[r.uid]=s,o},{}),Dr=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,y.OB)("containers.SettingPage.editSettings.entry.title"):(0,y.OB)(`form.Input.${t}`);return{type:o,label:{id:r}}},In=i(10369),Zt=i(71842);const Pn=({type:t,options:o,onChange:r,value:a,name:s,...l})=>{const{formatMessage:c}=(0,H.Z)();switch(t){case"text":return e.createElement(In.o,{onChange:r,value:a,name:s,...l});case"bool":return e.createElement(Zt.s,{onChange:d=>{r({target:{name:s,value:d.target.checked}})},checked:a,name:s,onLabel:c({id:"app.components.ToggleCheckbox.on-label",defaultMessage:"On"}),offLabel:c({id:"app.components.ToggleCheckbox.off-label",defaultMessage:"Off"}),...l});case"select":return e.createElement(Ue.P,{value:a,name:s,onChange:d=>r({target:{name:s,value:d}}),...l},o.map(d=>e.createElement(Re.W,{key:d,value:d},d)));default:return null}};Pn.defaultProps={options:void 0},Pn.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 Bl=Pn;const wl=[[4,"33%"],[6,"50%"],[8,"66%"],[12,"100%"]],Or=({onMetaChange:t,onSizeChange:o})=>{const{formatMessage:r}=(0,H.Z)(),{modifiedData:a,selectedField:s,attributes:l,fieldForm:c}=ut(),d=(0,e.useMemo)(gt.Vo,[]),{schemas:p}=(0,re.v9)(v=>d(v),re.wU),m=(0,re.v9)(gt.Jg),u=(0,e.useMemo)(()=>{if(!s)return[];const v=w()(a,["metadatas",s,"edit"],{});return Object.keys(v).filter(R=>R!=="visible")},[s,a]),h=(0,e.useMemo)(()=>$l(p),[p]),E=(0,e.useCallback)(v=>{if(v!=="relation"&&v!=="component")return[];const R=v==="component"?"component":"targetModel",x=w()(a,["attributes",s,R],"");return w()(h,[x],[])},[s,h,a]),g=u.map(v=>{const R=w()(l,[s,"type"]);return["component","dynamiczone"].includes(R)&&!["label","description"].includes(v)||R==="component"&&v!=="label"||["media","json","boolean"].includes(R)&&v==="placeholder"||v==="step"?null:e.createElement(ve.P,{col:6,key:v},e.createElement(Bl,{type:Dr(v).type,hint:v==="mainField"?r({id:(0,Ve.Z)("containers.SettingPage.editSettings.relation-field.description")}):"",label:r({id:w()(Dr(v),"label.id","app.utils.defaultMessage")}),name:v,onChange:t,value:w()(c,["metadata",v],""),options:E(R)}))}),{type:b,customField:C}=l[s],{isResizable:L}=m[C]??m[b];return e.createElement(e.Fragment,null,g,L&&e.createElement(ve.P,{col:6,key:"size"},e.createElement(Ue.P,{value:c?.size,name:"size",onChange:v=>{o({name:s,value:v})},label:r({id:(0,Ve.Z)("containers.SettingPage.editSettings.size.label"),defaultMessage:"Size"})},wl.map(([v,R])=>e.createElement(Re.W,{key:v,value:v},R)))))};Or.propTypes={onMetaChange:n().func.isRequired,onSizeChange:n().func.isRequired};var Nl=Or;const Wl=(0,U.ZP)(D.k)`
|
|
77
|
+
svg {
|
|
78
|
+
width: ${32/16}rem;
|
|
79
|
+
height: ${24/16}rem;
|
|
80
|
+
margin-right: ${({theme:t})=>t.spaces[3]};
|
|
81
|
+
}
|
|
82
|
+
`,Sn=({onToggle:t,onMetaChange:o,onSizeChange:r,onSubmit:a,type:s,customFieldUid:l})=>{const{selectedField:c}=ut(),{formatMessage:d}=(0,H.Z)(),p=()=>s==="timestamp"?"date":["decimal","float","integer","biginter"].includes(s)?"number":s;return e.createElement(vn.P,{onClose:t,labelledBy:"title"},e.createElement("form",{onSubmit:a},e.createElement(Cn.x,null,e.createElement(Wl,null,e.createElement(Tr,{type:p(),customFieldUid:l}),e.createElement(W.Z,{fontWeight:"bold",textColor:"neutral800",as:"h2",id:"title"},d({id:(0,y.OB)("containers.ListSettingsView.modal-form.edit-label"),defaultMessage:"Edit {fieldName}"},{fieldName:Dt()(c)})))),e.createElement(Rn.f,null,e.createElement(Se.r,{gap:4},e.createElement(Nl,{onMetaChange:o,onSizeChange:r}))),e.createElement(Mn.m,{startActions:e.createElement(ue.z,{onClick:t,variant:"tertiary"},d({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endActions:e.createElement(ue.z,{type:"submit"},d({id:"global.finish",defaultMessage:"Finish"}))})))};Sn.defaultProps={customFieldUid:null},Sn.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 jl=Sn,zl=i(3040),ae=i.n(zl);const Zn=t=>t.reduce((o,r)=>o+r.size,0),Vl=t=>t.reduce((o,r,a)=>{const s={rowId:a,rowContent:r};return o.concat(s)},[]),Et=t=>t.reduce((o,r)=>{let a=[];const s=r.rowContent.reduce((d,p)=>{const m=Zn(d);return p.name==="_TEMP_"||(m+p.size<=12?d.push(p):a.push(p)),d},[]),l=o.length===0?0:Math.max.apply(Math,o.map(d=>d.rowId))+1,c=Zn(s);if(c<12&&s.push({name:"_TEMP_",size:12-c}),o.push({rowId:l,rowContent:s}),a.length>0){const d=Zn(a);d<12&&a.push({name:"_TEMP_",size:12-d}),o.push({rowId:l+1,rowContent:a}),a=[]}return o},[]).filter(o=>o.rowContent.length>0).filter(o=>o.rowContent.length===1?o.rowContent[0].name!=="_TEMP_":!0),Ul=t=>t.reduce((o,r)=>{const a=r.rowContent.filter(s=>s.name!=="_TEMP_");return o.concat([a])},[]),ql=(t,o=[])=>o.reduce((r,{rowContent:a})=>{const s=a.find(l=>l.name===t)?.size??null;return s&&(r=s),r},null),Hl=(t,o,r=[])=>r.map(a=>(a.rowContent=a.rowContent.map(s=>s.name===t?{...s,size:o}:s),a));var Gl=(t,o,r)=>{let a=Ye()(o);return ae()(a,["layouts","edit"],Et(Vl(o.layouts.edit))),{...t,initialData:a,modifiedData:a,componentLayouts:r}},xn=i(97889);const Ir=6,Ln={fieldForm:{},componentLayouts:{},metaToEdit:"",initialData:{},metaForm:{},modifiedData:{}};var Ql=(t=Ln,o)=>(0,xn.ZP)(t,r=>{const a=["modifiedData","layouts","edit"];switch(o.type){case"MOVE_ROW":{const s=w()(t,a,[]),{fromIndex:l,toIndex:c}=o;ae()(r,a,(0,y.W3)(s,l,c));break}case"ON_ADD_FIELD":{const s=Ye()(t),l=w()(s,["modifiedData","attributes",o.name],{}),c=o.fieldSizes[l?.customField]?.default??o.fieldSizes[l?.type]?.default??Ir,d=w()(s,a,[]).length,p=[...a,d-1,"rowContent"],m=w()(s,p,[]);let u=w()(s,a,[]);Array.isArray(m)?ae()(u,[d>0?d-1:0,"rowContent"],[...m,{name:o.name,size:c}]):ae()(u,[d>0?d-1:0,"rowContent"],[{name:o.name,size:c}]);const h=Et(u);ae()(r,a,h);break}case"ON_CHANGE":{ae()(r,["modifiedData",...o.keys],o.value);break}case"ON_CHANGE_META":{ae()(r,["metaForm","metadata",...o.keys],o.value);break}case"ON_CHANGE_SIZE":{ae()(r,["metaForm","size"],o.value);break}case"ON_RESET":{r.modifiedData=t.initialData;break}case"REMOVE_FIELD":{const s=w()(t,[...a,o.rowIndex,"rowContent"],[]);let l=Ye()(t);if(s.length===1||s.length===2&&w()(s,[1,"name"],"")==="_TEMP_"){const d=w()(t,a,[]);ae()(l,a,d.filter((p,m)=>o.rowIndex!==m))}else ae()(l,[...a,o.rowIndex,"rowContent"],s.filter((d,p)=>p!==o.fieldIndex));const c=Et(w()(l,a,[]));ae()(r,a,c);break}case"REORDER_DIFF_ROW":{const s=w()(t,[...a,o.dragRowIndex,"rowContent"],[]),l=w()(t,[...a,o.hoverRowIndex,"rowContent"],[]),c=w()(t,[...a,o.dragRowIndex,"rowContent",o.dragIndex],{}),d=[...l,c];let p=Ye()(t);ae()(p,[...a,o.dragRowIndex,"rowContent"],s.filter((u,h)=>o.dragIndex!==h)),ae()(p,[...a,o.hoverRowIndex,"rowContent"],(0,y.W3)(d,d.length-1,o.hoverIndex));const m=Et(w()(p,a,[]));ae()(r,a,m);break}case"REORDER_ROW":{const s=Ye()(t),l=w()(s,[...a,o.dragRowIndex,"rowContent"],[]);ae()(s,[...a,o.dragRowIndex,"rowContent"],(0,y.W3)(l,o.dragIndex,o.hoverIndex));const c=Et(w()(s,a,[]));ae()(r,a,c);break}case"SET_FIELD_TO_EDIT":{r.metaToEdit=o.name,r.metaForm={metadata:w()(t,["modifiedData","metadatas",o.name,"edit"],{}),size:ql(o.name,t.modifiedData?.layouts?.edit)??Ir};break}case"SUBMIT_META_FORM":{ae()(r,["modifiedData","metadatas",t.metaToEdit,"edit"],t.metaForm.metadata);const s=Ye()(w()(t,a,[])),l=Hl(t.metaToEdit,t.metaForm.size,s);l.length>0&&ae()(r,a,Et(l));break}case"SUBMIT_SUCCEEDED":{r.initialData=t.modifiedData;break}case"UNSET_FIELD_TO_EDIT":{r.metaToEdit="",r.metaForm={};break}default:return r}});const kn=({mainLayout:t,components:o,isContentTypeView:r,slug:a,updateLayout:s})=>{const[l,c]=(0,e.useReducer)(Ql,Ln,()=>Gl(Ln,t,o)),[d,p]=(0,e.useState)(!1),{trackUsage:m}=(0,f.rS)(),u=(0,f.lm)(),{goBack:h}=(0,le.k6)(),[E,g]=(0,e.useState)(!1),[b,C]=(0,e.useState)(!1),{componentLayouts:L,initialData:v,modifiedData:R,metaToEdit:x,metaForm:V}=l,{formatMessage:M}=(0,H.Z)(),O=t.info.displayName,j=R?.attributes??{},$=(0,re.v9)(gt.Jg),{put:P}=(0,f.kY)(),N=Object.keys(j).filter(Z=>{const te=j?.[Z]?.type??"";return!["dynamiczone","json","text","relation","component","boolean","media","password","richtext","timestamp"].includes(te)&&!!te}),Y=R.layouts.edit,T=Y.flatMap(Z=>Z.rowContent),X=Object.keys(R.attributes).filter(Z=>(R?.metadatas?.[Z]?.edit?.visible??!1)===!0).filter(Z=>T.findIndex(te=>te.name===Z)===-1).sort(),G=({target:{name:Z,value:te}})=>{c({type:"ON_CHANGE",keys:Z.split("."),value:te})},J=()=>{g(Z=>!Z)},F=()=>{C(Z=>!Z)},S=({target:{name:Z,value:te}})=>{c({type:"ON_CHANGE_META",keys:Z.split("."),value:te})},I=({name:Z,value:te})=>{c({type:"ON_CHANGE_SIZE",name:Z,value:te})},A=Z=>{Z.preventDefault(),c({type:"SUBMIT_META_FORM"}),J()},q=Z=>{Z.preventDefault(),F()},K=(0,Ne.useMutation)(Z=>P(r?`/content-manager/content-types/${a}/configuration`:`/content-manager/components/${a}/configuration`,Z),{onSuccess({data:Z}){s&&s(Z.data),c({type:"SUBMIT_SUCCEEDED"}),F(),m("didEditEditSettings")},onError(){u({type:"warning",message:{id:"notification.error"}})}}),{isLoading:k}=K,z=()=>{const{layouts:Z,metadatas:te,settings:me}=Ye()(R);K.mutate({layouts:{...Z,edit:Ul(Z.edit)},metadatas:te,settings:me})},ne=(Z,te)=>{c({type:"MOVE_RELATION",fromIndex:Z,toIndex:te})},ce=(Z,te)=>{c({type:"MOVE_FIELD",fromIndex:Z,toIndex:te})},he=(Z,te,me,Ze)=>{c(me===Ze?{type:"REORDER_ROW",dragRowIndex:me,dragIndex:Z,hoverIndex:te}:{type:"REORDER_DIFF_ROW",dragIndex:Z,hoverIndex:te,dragRowIndex:me,hoverRowIndex:Ze})},fe=(Z,te)=>{c({type:"MOVE_ROW",fromIndex:Z,toIndex:te})};return e.createElement(un,{isContentTypeView:r,attributes:j,modifiedData:R,slug:a,componentLayouts:L,selectedField:x,fieldForm:V,onMoveRelation:ne,onMoveField:ce,moveRow:fe,moveItem:he,setEditFieldToSelect:Z=>{c({type:"SET_FIELD_TO_EDIT",name:Z}),J()},isDraggingSibling:d,setIsDraggingSibling:p},e.createElement(Te.o,null,e.createElement("form",{onSubmit:q},e.createElement(Oe.T,{title:M({id:(0,y.OB)("components.SettingsViewWrapper.pluginHeader.title"),defaultMessage:`Configure the view - ${Dt()(O)}`},{name:Dt()(O)}),subtitle:M({id:(0,y.OB)("components.SettingsViewWrapper.pluginHeader.description.edit-settings"),defaultMessage:"Customize how the edit view will look like."}),navigationAction:e.createElement(f.rU,{startIcon:e.createElement(dt.Z,null),onClick:Z=>{Z.preventDefault(),h()},to:"/"},M({id:"global.back",defaultMessage:"Back"})),primaryAction:e.createElement(ue.z,{disabled:Fe()(v,R),startIcon:e.createElement(we.Z,null),type:"submit"},M({id:"global.save",defaultMessage:"Save"}))}),e.createElement(tt.D,null,e.createElement(Q.x,{background:"neutral0",hasRadius:!0,shadow:"filterShadow",paddingTop:6,paddingBottom:6,paddingLeft:7,paddingRight:7},e.createElement(D.k,{direction:"column",alignItems:"stretch",gap:4},e.createElement(W.Z,{variant:"delta",as:"h2"},M({id:(0,y.OB)("containers.SettingPage.settings"),defaultMessage:"Settings"})),e.createElement(Se.r,null,e.createElement(ve.P,{col:6,s:12},e.createElement(Ue.P,{label:M({id:(0,y.OB)("containers.SettingPage.editSettings.entry.title"),defaultMessage:"Entry title"}),hint:M({id:(0,y.OB)("containers.SettingPage.editSettings.entry.title.description"),defaultMessage:"Set the display field of your entry"}),onChange:Z=>{G({target:{name:"settings.mainField",value:Z===""?null:Z}})},value:R.settings.mainField},N.map(Z=>e.createElement(Re.W,{key:Z,value:Z},Z))))),e.createElement(Q.x,{paddingTop:2,paddingBottom:2},e.createElement(cn.i,null)),e.createElement(W.Z,{variant:"delta",as:"h3"},M({id:(0,y.OB)("containers.SettingPage.view"),defaultMessage:"View"})),e.createElement(Pl,{attributes:j,editLayout:Y,fields:X,onAddField:Z=>{c({type:"ON_ADD_FIELD",name:Z,fieldSizes:$})},onRemoveField:(Z,te)=>{c({type:"REMOVE_FIELD",rowIndex:Z,fieldIndex:te})}})))),e.createElement(f.QH,{bodyText:{id:(0,y.OB)("popUpWarning.warning.updateAllSettings"),defaultMessage:"This will modify all your settings"},iconRightButton:e.createElement(we.Z,null),isConfirmButtonLoading:k,isOpen:b,onToggleDialog:F,onConfirm:z,variantRightButton:"success-light"})),E&&e.createElement(jl,{onSubmit:A,onToggle:J,onMetaChange:S,onSizeChange:I,type:j?.[x]?.type??"",customFieldUid:j?.[x]?.customField??""})))};kn.defaultProps={isContentTypeView:!1,updateLayout:null},kn.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 An=kn,jt=i(66941),Pr=i(40582);const Kl=()=>({type:Pr.c}),Yl=(t,o)=>({type:Pr.O,layout:t,query:o});var xt=i(9592),Xl=i(76402),Jl=()=>(0,e.useContext)(Xl.ux),Sr=t=>{const{getAdminInjectedComponents:o}=Jl(),[r,a,s]=t.split(".");return o(r,a,s)};const Zr=({area:t,...o})=>Sr(t).map(a=>e.createElement(a.Component,{key:a.name,...o}));Zr.propTypes={area:n().string.isRequired};var zt=Zr,qe=i(84306),rt=i(46491);const Vt=()=>({type:rt.ZA}),Fn=t=>({type:rt.Id,data:t}),$n=(t,o=!1)=>({type:rt.TP,rawQuery:t,isSingleType:o}),xr=()=>({type:rt.c2}),Lr=(t,o)=>({type:rt.w7,componentsDataStructure:t,contentTypeDataStructure:o}),pe=t=>({type:rt.d0,status:t}),at=t=>({type:rt.t9,data:t}),_l=()=>({type:rt.tE});var Bn=t=>t["content-manager_editViewCrudReducer"];const wn=({allLayoutData:t,children:o,slug:r,id:a,origin:s})=>{const l=(0,Ne.useQueryClient)(),c=(0,f.lm)(),{setCurrentStep:d}=(0,f.c1)(),{trackUsage:p}=(0,f.rS)(),{push:m,replace:u}=(0,le.k6)(),[{query:h,rawQuery:E}]=(0,f.Kx)(),g=(0,re.I0)(),{componentsDataStructure:b,contentTypeDataStructure:C,data:L,isLoading:v,status:R}=(0,re.v9)(Bn),x=(0,be.Ky)(r),{formatAPIError:V}=(0,f.So)(y.OB),M=(0,e.useRef)(!0),O=(0,e.useRef)(p),j=(0,e.useRef)(t),$=(0,f.kY)(),{put:P,post:N,del:Y}=$,T=a===null,X=T&&!s?null:`/content-manager/collection-types/${r}/${s||a}`,G=(0,e.useCallback)(k=>{const z=(0,y.kc)(k,j.current.contentType,j.current.components);return(0,f.dU)(z,j.current.contentType,j.current.components)},[]);(0,e.useEffect)(()=>{const k=Object.keys(t.components).reduce((ce,he)=>{const fe=(0,y.Di)(w()(t,["components",he,"attributes"],{}),t.components);return ce[he]=(0,f.dU)(fe,t.components[he],t.components),ce},{}),z=(0,y.Di)(t.contentType.attributes,t.components),ne=(0,f.dU)(z,t.contentType,t.components);g(Lr(k,ne))},[t,g]),(0,e.useEffect)(()=>()=>{g(xr())},[g]),(0,e.useEffect)(()=>{const z=qe.default.CancelToken.source(),ne=async he=>{g(Vt());try{const{data:fe}=await $.get(X,{cancelToken:he.token});g(Fn(G(fe)))}catch(fe){if(qe.default.isCancel(fe))return;const Z=w()(fe,"response.status",null);if(Z===404){m(x);return}Z===403&&(c({type:"info",message:{id:(0,y.OB)("permissions.not-allowed.update")}}),m(x))}},ce=async()=>{g(Vt()),g($n(E))};return M.current?(X?ne(z):ce(),()=>{z.cancel("Operation canceled by the user.")}):()=>{}},[$,G,m,X,g,E,x,c]);const J=(0,e.useCallback)(k=>{c({type:"warning",message:V(k)})},[c,V]),F=(0,e.useCallback)(async k=>{try{O.current("willDeleteEntry",k);const{data:z}=await Y(`/content-manager/collection-types/${r}/${a}`);return c({type:"success",message:{id:(0,y.OB)("success.record.delete")}}),O.current("didDeleteEntry",k),u(x),Promise.resolve(z)}catch(z){return O.current("didNotDeleteEntry",{error:z,...k}),Promise.reject(z)}},[a,r,c,Y,x,u]),S=(0,e.useCallback)(async(k,z)=>{const ne=typeof s=="string",ce=ne?`/content-manager/collection-types/${r}/clone/${s}`:`/content-manager/collection-types/${r}`;try{g(pe("submit-pending"));const{id:he,...fe}=k,{data:Z}=await N(ce,ne?fe:k,{params:h});return O.current("didCreateEntry",z),c({type:"success",message:{id:(0,y.OB)("success.record.save")}}),d("contentManager.success"),l.invalidateQueries(["relation"]),g(at(G(Z))),g(pe("resolved")),u(`/content-manager/collectionType/${r}/${Z.id}${E}`),Promise.resolve(Z)}catch(he){return J(he),O.current("didNotCreateEntry",{error:he,trackerProperty:z}),g(pe("resolved")),Promise.reject(he)}},[s,G,J,u,r,g,h,c,d,l,N,E]),I=(0,e.useCallback)(async()=>{try{O.current("willCheckDraftRelations");const k=`/content-manager/collection-types/${r}/${a}/actions/countDraftRelations`;g(pe("draft-relation-check-pending"));const z=await $.get(k);return O.current("didCheckDraftRelations"),g(pe("resolved")),z.data.data}catch(k){return J(k),g(pe("resolved")),Promise.reject(k)}},[J,a,r,g,$]),A=(0,e.useCallback)(async()=>{try{O.current("willPublishEntry");const k=`/content-manager/collection-types/${r}/${a}/actions/publish`;g(pe("publish-pending"));const{data:z}=await N(k);return O.current("didPublishEntry"),g(at(G(z))),g(pe("resolved")),c({type:"success",message:{id:(0,y.OB)("success.record.publish")}}),Promise.resolve(z)}catch(k){return J(k),g(pe("resolved")),Promise.reject(k)}},[G,J,a,r,g,c,N]),q=(0,e.useCallback)(async(k,z)=>{const ne=`/content-manager/collection-types/${r}/${a}`;try{O.current("willEditEntry",z),g(pe("submit-pending"));const{data:ce}=await P(ne,k);return O.current("didEditEntry",{trackerProperty:z}),c({type:"success",message:{id:(0,y.OB)("success.record.save")}}),l.invalidateQueries(["relation"]),g(at(G(ce))),g(pe("resolved")),Promise.resolve(ce)}catch(ce){return O.current("didNotEditEntry",{error:ce,trackerProperty:z}),J(ce),g(pe("resolved")),Promise.reject(ce)}},[G,J,r,a,g,c,l,P]),K=(0,e.useCallback)(async()=>{const k=`/content-manager/collection-types/${r}/${a}/actions/unpublish`;g(pe("unpublish-pending"));try{O.current("willUnpublishEntry");const{data:z}=await N(k);return O.current("didUnpublishEntry"),c({type:"success",message:{id:(0,y.OB)("success.record.unpublish")}}),g(at(G(z))),g(pe("resolved")),Promise.resolve(z)}catch(z){return g(pe("resolved")),J(z),Promise.reject(z)}},[G,J,a,r,g,c,N]);return o({componentsDataStructure:b,contentTypeDataStructure:C,data:L,isCreatingEntry:T,isLoadingForData:v,onDelete:F,onPost:S,onPublish:A,onDraftRelationCheck:I,onPut:q,onUnpublish:K,status:R,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 ec=(0,e.memo)(wn,Fe()),st=i(3685),Nn=i(69783),kr=i(86308);const Wn=({hasError:t,isDisabled:o,isOpen:r,children:a,onClick:s})=>e.createElement(tc,{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(D.k,{as:"span",gap:2},e.createElement(jn,{"aria-hidden":!0,$isOpen:r,$hasError:t&&!r}),e.createElement(W.Z,{variant:"pi",fontWeight:"bold",textColor:t&&!r?"danger600":"neutral500"},a))),jn=(0,U.ZP)(kr.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
|
+
`,tc=(0,U.ZP)(Nn.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
|
+
${jn} {
|
|
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
|
+
${jn} {
|
|
116
|
+
> circle {
|
|
117
|
+
fill: ${({theme:t})=>t.colors.primary600};
|
|
118
|
+
}
|
|
119
|
+
> path {
|
|
120
|
+
fill: ${({theme:t})=>t.colors.neutral100};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
`;Wn.defaultProps={hasError:!1,isDisabled:!1,isOpen:!1},Wn.propTypes={children:n().node.isRequired,hasError:n().bool,isDisabled:n().bool,isOpen:n().bool,onClick:n().func.isRequired};var Ar=i(861),zn=i(83828),Vn=i(61762),Un=i(89966);const qn=({category:t,components:o,variant:r,isOpen:a,onAddComponent:s,onToggle:l})=>{const{formatMessage:c}=(0,H.Z)(),d=()=>{l(t)};return e.createElement(zn.U,{expanded:a,onToggle:d,size:"S"},e.createElement(Vn.B,{variant:r,title:c({id:t,defaultMessage:t}),togglePosition:"left"}),e.createElement(Un.v,null,e.createElement(Q.x,{paddingTop:4,paddingBottom:4,paddingLeft:3,paddingRight:3},e.createElement(nc,null,o.map(({componentUid:p,info:{displayName:m,icon:u}})=>e.createElement(oc,{key:p,as:"button",type:"button",background:"neutral100",justifyContent:"center",onClick:s(p),hasRadius:!0,height:(0,f.Q1)(84),shrink:0,borderColor:"neutral200"},e.createElement(D.k,{direction:"column",gap:1,alignItems:"center",justifyContent:"center"},e.createElement(Pt,{icon:u}),e.createElement(W.Z,{variant:"pi",fontWeight:"bold",textColor:"neutral600"},c({id:m,defaultMessage:m})))))))))},nc=U.ZP.div`
|
|
125
|
+
display: grid;
|
|
126
|
+
grid-template-columns: repeat(auto-fit, ${140/16}rem);
|
|
127
|
+
grid-gap: ${({theme:t})=>t.spaces[1]};
|
|
128
|
+
`,oc=(0,U.ZP)(D.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
|
+
`;qn.defaultProps={components:[],isOpen:!1,variant:"primary"},qn.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 Hn=({dynamicComponentsByCategory:t,isOpen:o,onClickAddComponent:r})=>{const{formatMessage:a}=(0,H.Z)(),[s,l]=(0,e.useState)("");(0,e.useEffect)(()=>{const p=Object.keys(t);o&&p.length>0&&l(p[0])},[o,t]);const c=p=>()=>{r(p),l("")},d=p=>{l(m=>m===p?"":p)};return o?e.createElement(Q.x,{paddingTop:6,paddingBottom:6,paddingLeft:5,paddingRight:5,background:"neutral0",shadow:"tableShadow",borderColor:"neutral150",hasRadius:!0},e.createElement(D.k,{justifyContent:"center"},e.createElement(W.Z,{fontWeight:"bold",textColor:"neutral600"},a({id:(0,y.OB)("components.DynamicZone.ComponentPicker-label"),defaultMessage:"Pick one component"}))),e.createElement(Q.x,{paddingTop:2},e.createElement(Ar.k,{attributeName:"data-strapi-accordion-toggle"},Object.entries(t).map(([p,m],u)=>e.createElement(qn,{key:p,category:p,components:m,onAddComponent:c,isOpen:p===s,onToggle:d,variant:u%2===1?"primary":"secondary"}))))):null};Hn.defaultProps={dynamicComponentsByCategory:{},isOpen:!1},Hn.propTypes={dynamicComponentsByCategory:n().shape({components:n().arrayOf(n().shape({componentUid:n().string.isRequired,info:n().object}))}),isOpen:n().bool,onClickAddComponent:n().func.isRequired};var Fr=i(91647),Gn=i(49825),rc=i(61868),ac=i.n(rc);const sc=U.ZP.span`
|
|
145
|
+
> svg {
|
|
146
|
+
width: ${(0,f.Q1)(24)};
|
|
147
|
+
height: ${(0,f.Q1)(24)};
|
|
148
|
+
> circle {
|
|
149
|
+
fill: ${({theme:t})=>t.colors.primary200};
|
|
150
|
+
}
|
|
151
|
+
> path {
|
|
152
|
+
fill: ${({theme:t})=>t.colors.primary600};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
`,Qn=({error:t,isReadOnly:o,onClick:r})=>{const{formatMessage:a}=(0,H.Z)();return e.createElement(e.Fragment,null,e.createElement(Q.x,{as:"button",background:"neutral100",borderColor:t?"danger600":"neutral200",disabled:o,hasRadius:!0,onClick:r,paddingTop:9,paddingBottom:9,type:"button"},e.createElement(D.k,{direction:"column",gap:2},e.createElement(D.k,{justifyContent:"center",style:{cursor:o?"not-allowed":"inherit"}},e.createElement(sc,null,e.createElement(kr.Z,null))),e.createElement(D.k,{justifyContent:"center"},e.createElement(W.Z,{textColor:"primary600",variant:"pi",fontWeight:"bold"},a({id:(0,y.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})))};Qn.defaultProps={error:void 0,isReadOnly:!1},Qn.propTypes={error:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}),isReadOnly:n().bool,onClick:n().func.isRequired};var $r=Qn;const Lt=new Map;var Kn=(t=[])=>{const[o,r]=(0,e.useState)(Object.fromEntries(Lt)),a=t.filter(p=>!Lt.get(p)),[s,l]=(0,e.useState)(()=>!!a.length),c=(0,f.mZ)();(0,e.useEffect)(()=>{const p=u=>{r(u),l(!1)},m=async(u,h)=>{const E=await Promise.all(h);u.forEach((g,b)=>{Lt.set(g,E[b].default)}),p(Object.fromEntries(Lt))};if(a.length>0){l(!0);const u=a.reduce((h,E)=>{const g=c.get(E);return g&&h.push(g.components.Input()),h},[]);u.length>0&&m(a,u)}},[a,c]);const d=(0,e.useCallback)(()=>{Lt.clear(),r({})},[]);return{isLazyLoading:s,lazyComponentStore:o,cleanup:d}},ic=i(9086),lc=i.n(ic),cc=i(88708),kt=i.n(cc),Yn=i(38705),At=i(69932),dc=i(27169),Br=i(99097),uc=i(63642);const mc=(0,U.ZP)(uc.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
|
+
`,wr=(0,U.ZP)(D.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
|
+
`,pc=(0,U.F4)`
|
|
179
|
+
from {
|
|
180
|
+
transform: rotate(0deg);
|
|
181
|
+
}
|
|
182
|
+
to {
|
|
183
|
+
transform: rotate(359deg);
|
|
184
|
+
}
|
|
185
|
+
`,gc=(0,U.ZP)(D.k)`
|
|
186
|
+
animation: ${pc} 2s infinite linear;
|
|
187
|
+
`;var fc=/^[A-Za-z0-9-_.~]*$/;const Xn=({attribute:t,contentTypeUID:o,hint:r,disabled:a,error:s,intlLabel:l,labelAction:c,name:d,onChange:p,value:m,placeholder:u,required:h})=>{const{modifiedData:E,initialData:g,layout:b}=(0,f.Wq)(),[C,L]=(0,e.useState)(!1),[v,R]=(0,e.useState)(null),x=(0,Br.Z)(m,300),V=(0,e.useRef)(),M=(0,f.lm)(),{formatAPIError:O}=(0,f.So)(),j=g[d],{formatMessage:$}=(0,H.Z)(),P=b?.options?.timestamps??0,N=!g[P],Y=(0,Br.Z)(E[t.targetField],300),[T,X]=(0,e.useState)(!1),[G,J]=(0,e.useState)(null),{post:F}=(0,f.kY)(),S=l.id?$({id:l.id,defaultMessage:l.defaultMessage},{...l.values}):d,I=u?$({id:u.id,defaultMessage:u.defaultMessage},{...u.values}):"";V.current=async(z=!1)=>{L(!0);try{const{data:{data:ne}}=await F("/content-manager/uid/generate",{contentTypeUID:o,field:d,data:E});p({target:{name:d,value:ne,type:"text"}},z),L(!1)}catch(ne){L(!1),M({type:"warning",message:O(ne)})}};const A=async()=>{if(m){L(!0);try{const{data:z}=await F("/content-manager/uid/check-availability",{contentTypeUID:o,field:d,value:m?m.trim():""});L(!1),R(z)}catch(z){L(!1),M({type:"warning",message:O(z)})}}};(0,e.useEffect)(()=>{!m&&t.required&&V.current(!0)},[t.required,V,m]),(0,e.useEffect)(()=>{x?.trim().match(fc)&&x!==j&&A(),x||R(null)},[j,x]),(0,e.useEffect)(()=>{let z;return v?.isAvailable&&(z=setTimeout(()=>{R(null)},4e3)),()=>{z&&clearTimeout(z)}},[v]),(0,e.useEffect)(()=>{!T&&N&&Y&&E[t.targetField]&&!m&&V.current(!0)},[Y,T,N]);const q=()=>{J($({id:"content-manager.components.uid.regenerate",defaultMessage:"Regenerate"}))},K=()=>{J(null)},k=z=>{z.target.value&&N&&X(!0),p(z)};return e.createElement(In.o,{disabled:a,error:s,endAction:e.createElement(D.k,{position:"relative",gap:1},v&&!G&&e.createElement(wr,{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(Yn.Z,null):e.createElement(At.Z,null),e.createElement(W.Z,{textColor:v.isAvailable?"success600":"danger600",variant:"pi"},$(v.isAvailable?{id:"content-manager.components.uid.available",defaultMessage:"Available"}:{id:"content-manager.components.uid.unavailable",defaultMessage:"Unavailable"}))),!a&&e.createElement(e.Fragment,null,G&&e.createElement(wr,{alignItems:"center",justifyContent:"flex-end",gap:1},e.createElement(W.Z,{textColor:"primary600",variant:"pi"},G)),e.createElement(mc,{onClick:()=>V.current(),label:$({id:"content-manager.components.uid.regenerate",defaultMessage:"Regenerate"}),onMouseEnter:q,onMouseLeave:K},C?e.createElement(gc,{"data-testid":"loading-wrapper"},e.createElement(dc.Z,null)):e.createElement(hn.Z,null)))),hint:r,label:S,labelAction:c,name:d,onChange:k,placeholder:I,value:m||"",required:h})};Xn.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])},Xn.defaultProps={disabled:!1,error:void 0,labelAction:void 0,placeholder:void 0,value:"",required:!1,hint:""};var hc=Xn,Ec=i(88423),yc=i.n(Ec);function bc(t,o){return r=>{const a=o(r);return e.createElement(t,{...r,...a})}}var vc=bc;const Cc=(t=[],o=[])=>{const r=t.reduce((s,l)=>o.find(c=>c.id===l.id)?s:[...s,l.id],[]),a=o.reduce((s,l)=>t.find(c=>c.id===l.id)?s:[...s,l.id],[]);return[r,a]},mt={DRAFT:"draft",PUBLISHED:"published"},Jn=5,Rc=10;function Mc(t,o){return`/content-manager/collectionType/${t}/${o??""}`}const _n=(t,{shouldAddLink:o,mainFieldName:r,targetModel:a})=>{const s={...t};return o&&(s.href=Mc(a,s.id)),s.publicationState=!1,s?.publishedAt!==void 0&&(s.publicationState=s.publishedAt?mt.PUBLISHED:mt.DRAFT),s.mainField=s[r],s},Tc=(t,{shouldAddLink:o=!1,mainFieldName:r,targetModel:a}={})=>[...t].map(s=>_n(s,{shouldAddLink:o,mainFieldName:r,targetModel:a})),Dc=(t,{mainFieldName:o})=>{const{data:r}=t,{pages:a=[]}=r??{};return{...t,data:a.map(s=>s?.results.map(l=>_n(l,{mainFieldName:o}))).filter(Boolean).flat()}};function Oc({componentUid:t,isUserAllowedToEditField:o,isUserAllowedToReadField:r,name:a,queryInfos:s}){const{isCreatingEntry:l,createActionAllowedFields:c,readActionAllowedFields:d,updateActionAllowedFields:p,slug:m,modifiedData:u}=(0,f.Wq)(),{params:h}=(0,le.$B)("/content-manager/collectionType/:collectionType/create/clone/:origin")??{},{origin:E}=h??{},g=(0,e.useMemo)(()=>o===!0?!0:(l?c:p).includes(a),[l,c,a,o,p]),b=(0,e.useMemo)(()=>r?!0:(l?[]:d).includes(a),[l,r,a,d]),C=a.split(".");let L;t&&(L=w()(u,C.slice(0,-1))?.id);const v=E||u.id,R=(0,e.useMemo)(()=>l&&!E?null:t?L?`/content-manager/relations/${t}/${L}/${C.at(-1)}`:null:`/content-manager/relations/${m}/${v}/${a.split(".").at(-1)}`,[l,E,t,m,v,a,L,C]),x=(0,e.useMemo)(()=>t?`/content-manager/relations/${t}/${a.split(".").at(-1)}`:`/content-manager/relations/${m}/${a.split(".").at(-1)}`,[t,m,a]);return{entityId:v,componentId:L,isComponentRelation:Boolean(t),queryInfos:{...s,endpoints:{search:x,relation:R}},isCloningEntry:Boolean(E),isCreatingEntry:l,isFieldAllowed:g,isFieldReadable:b}}var Ic=Oc;const Pc=(t,{relation:o,search:r})=>{const[a,s]=(0,e.useState)({}),[l,c]=(0,e.useState)(0),{get:d}=(0,f.kY)(),p=async({pageParam:M=1})=>{try{const{data:O}=await d(o?.endpoint,{params:{...o.pageParams??{},page:M}});return c(M),O}catch{return null}},m=async({pageParam:M=1})=>{try{const{data:O}=await d(r.endpoint,{params:{...r.pageParams??{},...a,page:M}});return O}catch{return null}},{onLoad:u,normalizeArguments:h={}}=o,E=(0,Ne.useInfiniteQuery)(["relation",...t],p,{cacheTime:0,enabled:o.enabled,getNextPageParam(M){const O=!M?.pagination;if(!(!M||O||M?.pagination.page>=M?.pagination.pageCount))return M.pagination.page+1},select:M=>({...M,pages:M.pages.map(O=>{if(!O)return O;const{data:j,results:$,pagination:P}=O,N=!!j;let Y=[];return N?Y=[j]:$&&(Y=[...$].reverse()),{pagination:P,results:Y}})})}),{pageGoal:g}=o,{status:b,data:C,fetchNextPage:L,hasNextPage:v}=E;(0,e.useEffect)(()=>{g>l&&v&&b==="success"&&L({pageParam:l+1})},[g,l,L,v,b]);const R=(0,f.W6)(u);(0,e.useEffect)(()=>{if(b==="success"&&C&&C.pages?.at(-1)?.results&&R){const M=Tc(C.pages.at(-1).results,h);R(M)}},[b,R,C]);const x=(0,Ne.useInfiniteQuery)(["relation",...t,"search",JSON.stringify(a)],m,{enabled:Object.keys(a).length>0,getNextPageParam(M){if(!(!M?.pagination||M.pagination.page>=M.pagination.pageCount))return M.pagination.page+1}});return{relations:E,search:x,searchFor:(M,O={})=>{s({...O,_q:M})}}},Nr=(t,o)=>r=>{const a=r.split(".");return a.reduce((s,l,c)=>{const d=w()(t,s),p=w()(o,[...a.slice(0,c),l,"__temp_key__"]);if(Array.isArray(d)&&typeof p=="number"){const m=d.findIndex(u=>u.__temp_key__===p);return s.push(m.toString()),s}return s.push(l),s},[])};var Sc=i(50428),Wr=i(21428),eo=i(7563),Ft=i(63919),to=i(41234),Ut=i(35331),Zc=i(41044),no=i(90333);const xc=U.ZP.div`
|
|
188
|
+
flex-shrink: 0;
|
|
189
|
+
width: ${(0,f.Q1)(6)};
|
|
190
|
+
height: ${(0,f.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
|
+
`,oo=({publicationState:t,mainField:o,id:r})=>{const{formatMessage:a}=(0,H.Z)(),s=(o??r).toString();if(t){const l=t==="draft",c={id:(0,y.OB)("components.Select.draft-info-title"),defaultMessage:"State: Draft"},d={id:(0,y.OB)("components.Select.publish-info-title"),defaultMessage:"State: Published"},p=a(l?c:d);return e.createElement(no.O,{value:r,textValue:s},e.createElement(D.k,null,e.createElement(xc,{title:p,isDraft:l}),e.createElement(W.Z,{ellipsis:!0},s)))}return e.createElement(no.O,{value:r,textValue:s},s)};oo.defaultProps={mainField:void 0,publicationState:void 0},oo.propTypes={id:n().number.isRequired,mainField:n().oneOfType([n().string,n().number]),publicationState:n().oneOfType([n().string,n().bool])};var jr=i(77622);const qt=50,yt=4,zr=(0,U.ZP)(D.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
|
+
`,Vr=(0,U.ZP)(D.k)`
|
|
203
|
+
width: 100%;
|
|
204
|
+
/* Used to prevent endAction to be pushed out of container */
|
|
205
|
+
min-width: 0;
|
|
206
|
+
`,ro=({ariaDescribedBy:t,children:o,displayValue:r,canDrag:a,disabled:s,endAction:l,iconButtonAriaLabel:c,style:d,id:p,index:m,name:u,onCancel:h,onDropItem:E,onGrabItem:g,status:b,updatePositionOfRelation:C,...L})=>{const[{handlerId:v,isDragging:R,handleKeyDown:x},V,M,O,j]=(0,jr.Y)(a&&!s,{type:`${y._Q.RELATION}_${u}`,index:m,item:{displayedValue:r,status:b,id:p},onGrabItem:g,onDropItem:E,onCancel:h,onMoveItem:C,dropSensitivity:"immediate"}),$=(0,y.FE)(V,O);return(0,e.useEffect)(()=>{j((0,Ot.rX)())},[j]),e.createElement(Q.x,{style:d,as:"li",ref:M,"aria-describedby":t,cursor:a?"all-scroll":"default"},R?e.createElement(Lc,null):e.createElement(D.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?$:void 0,"data-handler-id":v,...L},e.createElement(zr,{gap:1},a?e.createElement(Me.h,{forwardedAs:"div",role:"button",tabIndex:0,"aria-label":c,noBorder:!0,onKeyDown:x,disabled:s},e.createElement(ot.Z,null)):null,e.createElement(Vr,{justifyContent:"space-between"},o)),l&&e.createElement(Q.x,{paddingLeft:4},l)))},Lc=()=>e.createElement(Q.x,{paddingTop:2,paddingBottom:2,paddingLeft:4,paddingRight:4,hasRadius:!0,borderStyle:"dashed",borderColor:"primary600",borderWidth:"1px",background:"primary100",height:`calc(100% - ${yt}px)`});ro.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},ro.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 kc=(0,U.ZP)(Q.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
|
+
`,ao=({children:t,overflow:o,...r})=>e.createElement(kc,{overflowDirection:o,...r},t);ao.defaultProps={overflow:""},ao.propTypes={children:n().node.isRequired,overflow:n().oneOf(["top-bottom","bottom","top",""])};const Ur=(0,U.ZP)(Sc.r)`
|
|
237
|
+
display: block;
|
|
238
|
+
|
|
239
|
+
> span {
|
|
240
|
+
white-space: nowrap;
|
|
241
|
+
overflow: hidden;
|
|
242
|
+
text-overflow: ellipsis;
|
|
243
|
+
display: block;
|
|
244
|
+
}
|
|
245
|
+
`,qr=U.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
|
+
`,so=({canReorder:t,description:o,disabled:r,error:a,iconButtonAriaLabel:s,id:l,name:c,numberOfRelationsToDisplay:d,label:p,labelAction:m,labelLoadMore:u,labelDisconnectRelation:h,listAriaDescription:E,liveText:g,loadingMessage:b,onCancel:C,onDropItem:L,onGrabItem:v,noRelationsMessage:R,onRelationConnect:x,onRelationLoadMore:V,onRelationDisconnect:M,onRelationReorder:O,onSearchNextPage:j,onSearch:$,placeholder:P,publicationStateTranslations:N,required:Y,relations:T,searchResults:X,size:G})=>{const[J,F]=(0,e.useState)(""),[S,I]=(0,e.useState)(""),A=(0,e.useRef)(),q=(0,e.useRef)(),{data:K}=X,k=T.data,z=k.length??0,ne=(0,e.useMemo)(()=>z>d?Math.min(z,d)*(qt+yt)+qt/2:Math.min(z,d)*(qt+yt),[z,d]),ce=!!u&&T.hasNextPage,he=(0,e.useMemo)(()=>K.flat().filter(Boolean).map(de=>({...de,value:de.id,label:de.mainField})),[K]);(0,e.useEffect)(()=>{if(z<=d)return I("");const de=je=>{const De=je.target.parentNode.scrollHeight,Je=je.target.scrollHeight-je.target.scrollTop;return je.target.scrollTop===0?I("bottom"):I(Je===De?"top":"top-bottom")},Ae=q?.current;return!T.isLoading&&k.length>0&&Ae&&q.current.addEventListener("scroll",de),()=>{Ae&&Ae.removeEventListener("scroll",de)}},[T,k,d,z]);const fe=de=>{de&&$()},Z=(de,Ae)=>{O&&de>=0&&de<k.length&&O(Ae,de)},te=(0,be.zH)(k.length),me=(0,e.useRef)(),Ze=()=>{me.current="loadMore",V()};(0,e.useEffect)(()=>{me.current==="onChange"&&F(""),me.current==="onChange"&&k.length!==te?(A.current.scrollToItem(k.length,"end"),me.current=void 0):me.current==="loadMore"&&k.length!==te&&(A.current.scrollToItem(0,"start"),me.current=void 0)},[te,k]);const ke=`${c}-item-instructions`;return e.createElement(D.k,{gap:3,justifyContent:"space-between",alignItems:"end",wrap:"wrap"},e.createElement(D.k,{direction:"column",alignItems:"stretch",basis:G<=6?"100%":"70%",gap:2},e.createElement(Wr.hQ,{autocomplete:"list",error:a,name:c,hint:o,id:l,required:Y,label:p,labelAction:m,disabled:r,placeholder:P,hasMoreItems:X.hasNextPage,loading:X.isLoading,onOpenChange:fe,noOptionsMessage:()=>R,loadingMessage:b,onLoadMore:()=>{j()},textValue:J,onChange:de=>{de&&(x(he.find(Ae=>Ae.id===de)),me.current="onChange")},onTextValueChange:de=>{F(de)},onInputChange:de=>{$(de.currentTarget.value)}},he.map(de=>e.createElement(oo,{key:de.id,...de}))),ce&&e.createElement(eo.A,{disabled:T.isLoading||T.isFetchingNextPage,onClick:Ze,loading:T.isLoading||T.isFetchingNextPage,startIcon:e.createElement(hn.Z,null)},u)),k.length>0&&e.createElement(ao,{overflow:S},e.createElement(st.T,{id:ke},E),e.createElement(st.T,{"aria-live":"assertive"},g),e.createElement(Zc.t7,{height:ne,ref:A,outerRef:q,itemCount:z,itemSize:qt+yt,itemData:{name:c,ariaDescribedBy:ke,canDrag:t,disabled:r,handleCancel:C,handleDropItem:L,handleGrabItem:v,iconButtonAriaLabel:s,labelDisconnectRelation:h,onRelationDisconnect:M,publicationStateTranslations:N,relations:k,updatePositionOfRelation:Z},itemKey:de=>`${k[de].mainField}_${k[de].id}`,innerElementType:"ol"},io)))},Ac=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}),Fc=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});so.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:[]}},so.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:Fc,size:n().number.isRequired,relations:Ac};const io=({data:t,index:o,style:r})=>{const{ariaDescribedBy:a,canDrag:s,disabled:l,handleCancel:c,handleDropItem:d,handleGrabItem:p,iconButtonAriaLabel:m,name:u,labelDisconnectRelation:h,onRelationDisconnect:E,publicationStateTranslations:g,relations:b,updatePositionOfRelation:C}=t,{publicationState:L,href:v,mainField:R,id:x}=b[o],V=L==="draft"?"secondary":"success";return e.createElement(ro,{ariaDescribedBy:a,canDrag:s,disabled:l,displayValue:String(R??x),iconButtonAriaLabel:m,id:x,index:o,name:u,endAction:e.createElement(qr,{"data-testid":`remove-relation-${x}`,disabled:l,type:"button",onClick:()=>E(b[o]),"aria-label":h},e.createElement(ht.J,{width:"12px",as:Ut.Z})),onCancel:c,onDropItem:d,onGrabItem:p,status:L||void 0,style:{...r,bottom:r.bottom??0+yt,height:r.height??0-yt},updatePositionOfRelation:C},e.createElement(Q.x,{minWidth:0,paddingTop:1,paddingBottom:1,paddingRight:4},e.createElement(Ft.u,{description:R??`${x}`},v?e.createElement(Ur,{to:v},R??x):e.createElement(W.Z,{textColor:l?"neutral600":"primary600",ellipsis:!0},R??x))),L&&e.createElement(to.q,{variant:V,showBullet:!1,size:"S"},e.createElement(W.Z,{fontWeight:"bold",textColor:`${V}700`},g[L])))};io.defaultProps={data:{}},io.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 $c=so;const lo=({error:t,entityId:o,componentId:r,isComponentRelation:a,editable:s,description:l,intlLabel:c,isCreatingEntry:d,isCloningEntry:p,isFieldAllowed:m,isFieldReadable:u,labelAction:h,mainField:E,name:g,queryInfos:{endpoints:b,defaultParams:C,shouldDisplayRelationLink:L},placeholder:v,required:R,relationType:x,size:V,targetModel:M})=>{const[O,j]=(0,e.useState)(""),{formatMessage:$}=(0,H.Z)(),{slug:P,initialData:N,modifiedData:Y,relationConnect:T,relationDisconnect:X,relationLoad:G,relationReorder:J}=(0,f.Wq)(),F=g.split("."),S=Nr(N,Y)(g),I=w()(Y,g,[]),A=Math.ceil(w()(N,g,[]).length/Jn),{relations:q,search:K,searchFor:k}=Pc([P,S.join("."),Y.id,C],{relation:{enabled:!!b.relation,endpoint:b.relation,pageGoal:A,pageParams:{...C,pageSize:Jn},onLoad(Ee){G({target:{initialDataPath:["initialData",...S],modifiedDataPath:["modifiedData",...F],value:Ee}})},normalizeArguments:{mainFieldName:E.name,shouldAddLink:L,targetModel:M}},search:{endpoint:b.search,pageParams:{...C,entityId:d||p?void 0:a?r:o,pageSize:Rc}}}),z=(0,e.useMemo)(()=>x.toLowerCase().includes("morph"),[x]),ne=["oneWay","oneToOne","manyToOne","oneToManyMorph","oneToOneMorph"].includes(x),ce=(0,e.useMemo)(()=>z?!0:d?!s:!m&&u||!s,[z,d,s,m,u]),he=Ee=>{const Ce=_n(Ee,{mainFieldName:E.name,shouldAddLink:L,targetModel:M});T({name:g,value:Ce,toOneRelation:ne})},fe=Ee=>{X({name:g,id:Ee.id})},Z=()=>{q.fetchNextPage()},te=(Ee="")=>{const[Ce,_e]=Cc(I,w()(N,g));k(Ee,{idsToInclude:_e,idsToOmit:Ce})},me=()=>{K.fetchNextPage()},Ze=Ee=>`${Ee+1} of ${I.length}`,ke=(Ee,Ce)=>{const _e=I[Ee];j($({id:(0,y.OB)("dnd.reorder"),defaultMessage:"{item}, moved. New position in list: {position}."},{item:_e.mainField??_e.id,position:Ze(Ce)})),J({name:g,newIndex:Ce,oldIndex:Ee})},de=Ee=>{const Ce=I[Ee];j($({id:(0,y.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:Ce.mainField??Ce.id,position:Ze(Ee)}))},Ae=Ee=>{const Ce=I[Ee];j($({id:(0,y.OB)("dnd.drop-item"),defaultMessage:"{item}, dropped. Final position in list: {position}."},{item:Ce.mainField??Ce.id,position:Ze(Ee)}))},je=Ee=>{const Ce=I[Ee];j($({id:(0,y.OB)("dnd.cancel-item"),defaultMessage:"{item}, dropped. Re-order cancelled."},{item:Ce.mainField??Ce.id}))};if(!m&&d||!d&&!m&&!u)return e.createElement(f.X0,{name:g,intlLabel:c,labelAction:h});const De=I.length,Je=(w()(N,S)??[]).length,Bt=q.data?.pages[0]?.pagination?.total??0,pt=!q.data&&De===Je?De:De-Je+Bt;return e.createElement($c,{error:t,canReorder:!ne,description:l,disabled:ce,iconButtonAriaLabel:$({id:(0,y.OB)("components.RelationInput.icon-button-aria-label"),defaultMessage:"Drag"}),id:g,label:`${$({id:c.id,defaultMessage:c.defaultMessage})} ${pt>0?`(${pt})`:""}`,labelAction:h,labelLoadMore:!d||p?$({id:(0,y.OB)("relation.loadMore"),defaultMessage:"Load More"}):null,labelDisconnectRelation:$({id:(0,y.OB)("relation.disconnect"),defaultMessage:"Remove"}),listAriaDescription:$({id:(0,y.OB)("dnd.instructions"),defaultMessage:"Press spacebar to grab and re-order"}),listHeight:320,liveText:O,loadingMessage:$({id:(0,y.OB)("relation.isLoading"),defaultMessage:"Relations are loading"}),name:g,noRelationsMessage:$({id:(0,y.OB)("relation.notAvailable"),defaultMessage:"No relations available"}),numberOfRelationsToDisplay:Jn,onDropItem:Ae,onGrabItem:de,onCancel:je,onRelationConnect:he,onRelationDisconnect:fe,onRelationLoadMore:Z,onRelationReorder:ke,onSearch:Ee=>te(Ee),onSearchNextPage:()=>me(),placeholder:$(v||{id:(0,y.OB)("relation.add"),defaultMessage:"Add relation"}),publicationStateTranslations:{[mt.DRAFT]:$({id:(0,y.OB)("relation.publicationState.draft"),defaultMessage:"Draft"}),[mt.PUBLISHED]:$({id:(0,y.OB)("relation.publicationState.published"),defaultMessage:"Published"})},relations:yc()({...q,data:I},"data","hasNextPage","isFetchingNextPage","isLoading","isSuccess"),required:R,searchResults:Dc(K,{mainFieldName:E.name}),size:V})};lo.defaultProps={componentId:void 0,entityId:void 0,editable:!0,error:void 0,description:"",labelAction:null,isComponentRelation:!1,isFieldAllowed:!0,placeholder:null,required:!1},lo.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 Bc=(0,e.memo)(lo);var wc=vc(Bc,Ic);const co=({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);co.defaultProps={id:void 0,error:void 0,hint:""},co.propTypes={hint:n().oneOfType([n().string,n().array]),error:n().string,id:n().string,name:n().string.isRequired};var Nc=co,Wc=i(87702),uo=i.n(Wc),mo=i(59845),jc=i(88591),zc=i.n(jc),Vc=i(20871),Uc=i.n(Vc),qc=i(48375),Hr=i.n(qc),Hc=i(31089),Gc=i.n(Hc),Qc=i(16043),Kc=i.n(Qc),Yc=i(5109),Xc=i.n(Yc),Jc=i(47955),_c=i.n(Jc),ed=i(95706),td=i.n(ed),nd=i(6658),od=i.n(nd),rd=i(36407),ad=i.n(rd);(async()=>{await i.e(7347).then(i.bind(i,74194))})();const bt=new(zc())({html:!0,xhtmlOut:!1,breaks:!0,langPrefix:"language-",linkify:!0,typographer:!0,highlight(t,o){if(o&&o!=="auto"&&(0,mo.getLanguage)(o))return'<pre class="hljs language-'+bt.utils.escapeHtml(o.toLowerCase())+'"><code>'+(0,mo.highlight)(o,t,!0).value+"</code></pre>";if(o==="auto"){const r=(0,mo.highlightAuto)(t);return'<pre class="hljs language-'+bt.utils.escapeHtml(r.language)+'"><code>'+r.value+"</code></pre>"}return'<pre class="hljs"><code>'+bt.utils.escapeHtml(t)+"</code></pre>"}}).use(Uc()).use(Hr(),"warning").use(Hr(),"tip").use(Gc()).use(Kc()).use(Xc()).use(_c()).use(td()).use(od()).use(ad());bt.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>",bt.renderer.rules.footnote_anchor=()=>' <span class="footnote-backref">\u21A9\uFE0E</span>';var sd=bt,id=i(13993),Gr=i.n(id);const ld={...Gr().defaults,allowedTags:!1,allowedAttributes:{"*":["href","align","alt","center","width","height","type","controls","target"],img:["src","alt"],source:["src","type"]}};var cd=t=>Gr()(t,ld),dd=U.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 po=({data:t})=>{const o=(0,e.useMemo)(()=>cd(sd.render(t.replaceAll("\\n",`
|
|
397
|
+
`)||"")),[t]);return e.createElement(dd,null,e.createElement("div",{dangerouslySetInnerHTML:{__html:o}}))};po.defaultProps={data:""},po.propTypes={data:n().string};var Qr=(0,e.memo)(po);const ud=U.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 Ht=/^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/,md=/^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/,pd=/[*+-]\s/;function gd(t){if(t.getOption("disableInput"))return uo().Pass;for(var o=t.listSelections(),r=[],a=0;a<o.length;a++){var s=o[a].head,l=t.getStateAfter(s.line),c=l.list!==!1,d=l.quote!==0,p=t.getLine(s.line),m=Ht.exec(p),u=/^\s*$/.test(p.slice(0,s.ch));if(!o[a].empty()||!c&&!d||!m||u){t.execCommand("newlineAndIndent");return}if(md.test(p)){var h=d&&/>\s*$/.test(p),E=!/>\s*$/.test(p);(h||E)&&t.replaceRange("",{line:s.line,ch:0},{line:s.line,ch:s.ch+1}),r[a]=`
|
|
737
|
+
`}else{var g=m[1],b=m[5],C=!(pd.test(m[2])||m[2].indexOf(">")>=0),L=C?parseInt(m[3],10)+1+m[4]:m[2].replace("x"," ");r[a]=`
|
|
738
|
+
`+g+L+b,C&&fd(t,s)}}t.replaceSelections(r)}function fd(t,o){var r=o.line,a=0,s=0,l=Ht.exec(t.getLine(r)),c=l[1];do{a+=1;var d=r+a,p=t.getLine(d),m=Ht.exec(p);if(m){var u=m[1],h=parseInt(l[3],10)+a-s,E=parseInt(m[3],10),g=E;if(c===u&&!isNaN(E))h===E&&(g=E+1),h>E&&(g=h+1),t.replaceRange(p.replace(Ht,u+g+m[4]+m[5]),{line:d,ch:0},{line:d,ch:p.length});else{if(c.length>u.length||c.length<u.length&&a===1)return;s+=1}}}while(m)}var hd=gd;const Le=(0,U.ZP)(Me.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
|
+
`,Ed=(0,U.ZP)(Le)`
|
|
748
|
+
svg {
|
|
749
|
+
width: ${8/16}rem;
|
|
750
|
+
height: ${8/16}rem;
|
|
751
|
+
}
|
|
752
|
+
`,Kr=(0,U.ZP)(Me.o)`
|
|
753
|
+
margin-left: ${({theme:t})=>t.spaces[4]};
|
|
754
|
+
`,Yr=(0,U.ZP)(Me.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
|
+
`,yd=(0,U.ZP)(Me.o)`
|
|
763
|
+
margin-right: ${({theme:t})=>`${t.spaces[2]}`};
|
|
764
|
+
`,bd=U.ZP.div`
|
|
765
|
+
position: relative;
|
|
766
|
+
height: calc(100% - 48px);
|
|
767
|
+
`,vd=(0,U.ZP)(Nn.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 mg=i(27217);const go=({disabled:t,editorRef:o,error:r,isPreviewMode:a,isExpandMode:s,name:l,onChange:c,placeholder:d,textareaRef:p,value:m})=>{const u=(0,e.useRef)(c);return(0,e.useEffect)(()=>{o.current=uo().fromTextArea(p.current,{lineWrapping:!0,extraKeys:{Enter:"newlineAndIndentContinueMarkdownList",Tab:!1,"Shift-Tab":!1},readOnly:!1,smartIndent:!1,placeholder:d,spellcheck:!0,inputStyle:"contenteditable"}),uo().commands.newlineAndIndentContinueMarkdownList=hd,o.current.on("change",h=>{u.current({target:{name:l,value:h.getValue(),type:"wysiwyg"}})})},[o,p,l,d]),(0,e.useEffect)(()=>{m&&!o.current.hasFocus()&&o.current.setValue(m)},[o,m]),(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(bd,null,e.createElement(ud,{isExpandMode:s,disabled:t||a},e.createElement("textarea",{ref:p})),a&&e.createElement(Qr,{data:m}))};go.defaultProps={disabled:!1,error:void 0,isPreviewMode:!1,isExpandMode:!1,placeholder:"",value:""},go.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 Cd=go,Rd=i(71933),Md=i(67563);const Td=(t,o)=>`${t}${Math.floor(o*255).toString(16).padStart(2,0)}`,Dd=(0,U.ZP)(D.k)`
|
|
781
|
+
background: ${({theme:t})=>Td(t.colors.neutral800,.2)};
|
|
782
|
+
`,Od=(0,U.ZP)(Q.x)`
|
|
783
|
+
border-right: 1px solid ${({theme:t})=>t.colors.neutral200};
|
|
784
|
+
`,Id=(0,U.ZP)(Nn.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
|
+
`,fo=({children:t,isExpandMode:o,error:r,previewContent:a,onCollapse:s})=>{const{formatMessage:l}=(0,H.Z)();return(0,f.F5)(o),o?e.createElement(Rd.h,{role:"dialog","aria-modal":!1},e.createElement(Md.i,{onEscape:s},e.createElement(Dd,{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:4,justifyContent:"center",onClick:s},e.createElement(Q.x,{background:"neutral0",hasRadius:!0,shadow:"popupShadow",overflow:"hidden",width:"70%",height:"70%",onClick:c=>c.stopPropagation()},e.createElement(D.k,{height:"100%",alignItems:"flex-start"},e.createElement(Od,{flex:"1",height:"100%"},t),e.createElement(D.k,{alignItems:"start",direction:"column",flex:1,height:"100%",width:"100%"},e.createElement(D.k,{height:(0,f.Q1)(48),background:"neutral100",justifyContent:"flex-end",shrink:0,width:"100%"},e.createElement(Id,{onClick:s},e.createElement(W.Z,null,l({id:"components.Wysiwyg.collapse",defaultMessage:"Collapse"})),e.createElement(cr.Z,null))),e.createElement(Q.x,{position:"relative",height:"100%",width:"100%"},e.createElement(Qr,{data:a})))))))):e.createElement(Q.x,{borderColor:r?"danger600":"neutral200",borderStyle:"solid",borderWidth:"1px",hasRadius:!0},t)};fo.defaultProps={error:void 0,previewContent:""},fo.propTypes={children:n().node.isRequired,error:n().string,isExpandMode:n().bool.isRequired,previewContent:n().string,onCollapse:n().func.isRequired};const Xr=(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},Jr=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}},_r=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},ea=(t,o)=>{const r=t.current.getSelection();let a;if(r){const s=Xr(o,r);t.current.replaceSelection(s),t.current.focus()}else{a=Jr(o),t.current.replaceSelection(a.editedText),t.current.focus();const{line:s,ch:l}=t.current.getCursor(),c=l-a.selection.end,d=l-a.selection.end-a.selection.start;t.current.setSelection({line:s,ch:d},{line:s,ch:c})}},Pd=(t,o)=>{const r=t.current.getDoc(),a=o==="BulletList"?"- ":"1. ";if(r.somethingSelected()){const s=r.listSelections();let l=null;t.current.operation(function(){s.forEach(function(c){const d=[c.head.line,c.anchor.line].sort();l==null&&(l=r.getLine(d[0]).startsWith(a));for(let p=d[0];p<=d[1];p++)if(l)r.getLine(p).startsWith(a)&&r.replaceRange("",{line:p,ch:0},{line:p,ch:a.length});else{const m=o==="BulletList"?"- ":`${p+1}. `;r.replaceRange(m,{line:p,ch:0})}})})}else{let{line:s}=r.getCursor();const l=_r(o),c=t.current.getLine(s),d=l+c;t.current.setSelection({line:s,ch:0},{line:s,ch:c.length}),t.current.replaceSelection(d)}t.current.focus()},Sd=(t,o)=>{let{line:r}=t.current.getCursor();const a=_r(o),s=t.current.getLine(r),l=s.replace(/#{1,6}\s/g,"").trim(),c=a+l;t.current.setSelection({line:r,ch:0},{line:r,ch:s.length}),t.current.replaceSelection(c),setTimeout(()=>{const d=t.current.getLine(r).length;t.current.focus(),t.current.setCursor({line:r,ch:d})},0)},Zd=(t,o)=>{let{line:r,ch:a}=t.current.getCursor();o.forEach((s,l)=>{let c=t.current.getLine(r).length;t.current.setCursor({line:r,ch:c}),(l>0||l===0&&a!==0)&&(c=t.current.getLine(r).length,t.current.setCursor({line:r,ch:c}),r++,t.current.replaceSelection(`
|
|
803
|
+
`)),s.mime.includes("image")?t.current.replaceSelection(``):t.current.replaceSelection(`[${s.alt}](${s.url})`)}),setTimeout(()=>t.current.focus(),0)},xd=(t,o,r,a,s)=>{const l=Xr(o,s),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.replaceSelection(""),t.current.setCursor({line:r,ch:a}),t.current.replaceSelection(`
|
|
804
|
+
`),t.current.replaceSelection(l),o==="Code"){let{line:d}=t.current.getCursor();t.current.setCursor({line:d-1,ch:s.length})}t.current.replaceRange(c,{line:r+4,ch:0},{line:1/0,ch:1/0}),t.current.focus()},Ld=(t,o,r,a)=>{const s=Jr(o),l=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:c}=t.current.getCursor(),d=c-s.selection.end,p=c-s.selection.end-s.selection.start;t.current.setSelection({line:r,ch:p},{line:r,ch:d})}t.current.replaceRange(l,{line:r+2,ch:0},{line:1/0,ch:1/0}),t.current.focus()},kd=(t,o)=>{const r=t.current.getSelection();let{line:a}=t.current.getCursor(),s=t.current.getLine(a).length;r?xd(t,o,a,s,r):Ld(t,o,a,s)},ho=({onToggleExpand:t})=>{const{formatMessage:o}=(0,H.Z)();return e.createElement(Q.x,{padding:2,background:"neutral100",hasRadius:!0},e.createElement(D.k,{justifyContent:"flex-end",alignItems:"flex-end"},e.createElement(vd,{id:"expand",onClick:t},e.createElement(W.Z,null,o({id:"components.WysiwygBottomControls.fullscreen",defaultMessage:"Expand"})),e.createElement(dr.Z,null))))};ho.defaultProps={onToggleExpand(){}},ho.propTypes={onToggleExpand:n().func};var Ad=ho,ta=i(5383),Fd=i(20063);const Eo=({disabled:t,editorRef:o,isExpandMode:r,isPreviewMode:a,onActionClick:s,onToggleMediaLib:l,onTogglePreviewMode:c})=>{const[d,p]=(0,e.useState)(!1),{formatMessage:m}=(0,H.Z)(),u=m({id:"components.Wysiwyg.selectOptions.title",defaultMessage:"Add a title"}),h=(0,e.useRef)(),E=()=>{p(g=>!g)};return t||a?e.createElement(D.k,{padding:2,background:"neutral100",justifyContent:"space-between"},e.createElement(na,null,e.createElement(Ue.P,{disabled:!0,placeholder:u,size:"S",label:u},e.createElement(Re.W,{value:"h1"},"h1"),e.createElement(Re.W,{value:"h2"},"h2"),e.createElement(Re.W,{value:"h3"},"h3"),e.createElement(Re.W,{value:"h4"},"h4"),e.createElement(Re.W,{value:"h5"},"h5"),e.createElement(Re.W,{value:"h6"},"h6")),e.createElement(Kr,null,e.createElement(Le,{disabled:!0,id:"Bold",label:"Bold",name:"Bold",icon:e.createElement(pn.Z,null)}),e.createElement(Le,{disabled:!0,id:"Italic",label:"Italic",name:"Italic",icon:e.createElement(gn.Z,null)}),e.createElement(Le,{disabled:!0,id:"Underline",label:"Underline",name:"Underline",icon:e.createElement(En.Z,null)})),e.createElement(Yr,{disabled:!0,id:"more",label:"More",icon:e.createElement(Gn.Z,null)})),!r&&e.createElement(ue.z,{onClick:c,variant:"tertiary",id:"preview"},m({id:"components.Wysiwyg.ToggleMode.markdown-mode",defaultMessage:"Markdown mode"}))):e.createElement(D.k,{padding:2,background:"neutral100",justifyContent:"space-between"},e.createElement(na,null,e.createElement(Ue.P,{placeholder:u,label:u,size:"S",onChange:g=>s(g,o)},e.createElement(Re.W,{value:"h1"},"h1"),e.createElement(Re.W,{value:"h2"},"h2"),e.createElement(Re.W,{value:"h3"},"h3"),e.createElement(Re.W,{value:"h4"},"h4"),e.createElement(Re.W,{value:"h5"},"h5"),e.createElement(Re.W,{value:"h6"},"h6")),e.createElement(Kr,null,e.createElement(Le,{onClick:()=>s("Bold",o),id:"Bold",label:"Bold",name:"Bold",icon:e.createElement(pn.Z,null)}),e.createElement(Le,{onClick:()=>s("Italic",o),id:"Italic",label:"Italic",name:"Italic",icon:e.createElement(gn.Z,null)}),e.createElement(Le,{onClick:()=>s("Underline",o),id:"Underline",label:"Underline",name:"Underline",icon:e.createElement(En.Z,null)})),e.createElement(Yr,{ref:h,onClick:E,id:"more",label:"More",icon:e.createElement(Gn.Z,null)}),d&&e.createElement(ta.J2,{onDismiss:E,centered:!0,source:h,spacing:4,id:"popover"},e.createElement(D.k,null,e.createElement(yd,null,e.createElement(Le,{onClick:()=>s("Strikethrough",o,E),id:"Strikethrough",label:"Strikethrough",name:"Strikethrough",icon:e.createElement(fr.Z,null)}),e.createElement(Le,{onClick:()=>s("BulletList",o,E),id:"BulletList",label:"BulletList",name:"BulletList",icon:e.createElement(ir.Z,null)}),e.createElement(Le,{onClick:()=>s("NumberList",o,E),id:"NumberList",label:"NumberList",name:"NumberList",icon:e.createElement(Fd.Z,null)})),e.createElement(Me.o,null,e.createElement(Le,{onClick:()=>s("Code",o,E),id:"Code",label:"Code",name:"Code",icon:e.createElement(lr.Z,null)}),e.createElement(Le,{onClick:()=>{E(),l()},id:"Image",label:"Image",name:"Image",icon:e.createElement(pr.Z,null)}),e.createElement(Ed,{onClick:()=>s("Link",o,E),id:"Link",label:"Link",name:"Link",icon:e.createElement(mr.Z,null)}),e.createElement(Le,{onClick:()=>s("Quote",o,E),id:"Quote",label:"Quote",name:"Quote",icon:e.createElement(gr.Z,null)}))))),c&&e.createElement(ue.z,{onClick:c,variant:"tertiary",id:"preview"},m({id:"components.Wysiwyg.ToggleMode.preview-mode",defaultMessage:"Preview mode"})))};Eo.defaultProps={isPreviewMode:!1,onActionClick(){},onToggleMediaLib(){},onTogglePreviewMode:void 0},Eo.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 $d=Eo;const na=(0,U.ZP)(D.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
|
+
`,Bd=(0,U.ZP)(Q.x)`
|
|
818
|
+
svg path {
|
|
819
|
+
fill: ${({theme:t})=>t.colors.neutral500};
|
|
820
|
+
}
|
|
821
|
+
`,wd=(0,U.ZP)(W.Z)`
|
|
822
|
+
line-height: 0;
|
|
823
|
+
`,yo=({hint:t,disabled:o,error:r,intlLabel:a,labelAction:s,name:l,onChange:c,placeholder:d,value:p,required:m})=>{const{formatMessage:u}=(0,H.Z)(),h=(0,e.useRef)(null),E=(0,e.useRef)(null),[g,b]=(0,e.useState)(!1),[C,L]=(0,e.useState)(!1),[v,R]=(0,e.useState)(!1),{components:x}=(0,f.yX)(),V=x["media-library"],M=()=>L(T=>!T),O=()=>b(T=>!T),j=()=>{b(!1),R(T=>!T)},$=(T,X,G)=>{switch(T){case"Link":case"Strikethrough":{ea(X,T),G();break}case"Code":case"Quote":{kd(X,T),G();break}case"Bold":case"Italic":case"Underline":{ea(X,T);break}case"BulletList":case"NumberList":{Pd(X,T),G();break}case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{Sd(X,T);break}default:}},P=T=>{const X=T.map(G=>({alt:G.alternativeText||G.name,url:(0,f.CR)(G.url),mime:G.mime}));Zd(E,X),L(!1)},N=d?u({id:d.id,defaultMessage:d.defaultMessage},{...d.values}):"",Y=a.id?u({id:a.id,defaultMessage:a.defaultMessage},{...a.values}):l;return e.createElement(e.Fragment,null,e.createElement(D.k,{direction:"column",alignItems:"stretch",gap:1},e.createElement(D.k,{gap:1},e.createElement(W.Z,{variant:"pi",fontWeight:"bold",textColor:"neutral800"},Y,m&&e.createElement(wd,{textColor:"danger600"},"*")),s&&e.createElement(Bd,{paddingLeft:1},s)),e.createElement(fo,{isExpandMode:v,error:r,previewContent:p,onCollapse:j},e.createElement($d,{isExpandMode:v,editorRef:E,isPreviewMode:g,onActionClick:$,onToggleMediaLib:M,onTogglePreviewMode:v?void 0:O,disabled:o}),e.createElement(Cd,{disabled:o,isExpandMode:v,editorRef:E,error:r,isPreviewMode:g,name:l,onChange:c,placeholder:N,textareaRef:h,value:p}),!v&&e.createElement(Ad,{onToggleExpand:j})),e.createElement(Nc,{hint:t,name:l,error:r})),r&&e.createElement(Q.x,{paddingTop:1},e.createElement(W.Z,{variant:"pi",textColor:"danger600","data-strapi-field-error":!0},r)),C&&e.createElement(V,{onClose:M,onSelectAssets:P}))};yo.defaultProps={disabled:!1,error:"",labelAction:void 0,placeholder:null,required:!1,value:"",hint:""},yo.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 Nd=yo;function Wd(t,o){return r=>{const a=o(r.keys);return e.createElement(t,{...r,...a})}}var jd=Wd,zd=(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}))],Vd=i(59578),Ud=i.n(Vd),qd=(t="")=>{switch(Ud()(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 Hd(t){const{createActionAllowedFields:o,formErrors:r,isCreatingEntry:a,modifiedData:s,onChange:l,readActionAllowedFields:c,shouldNotRunValidations:d,updateActionAllowedFields:p}=(0,f.Wq)(),m=(0,e.useMemo)(()=>a?o:p,[a,o,p]),u=(0,e.useMemo)(()=>a?[]:c,[a,c]),h=w()(s,t,null);return{allowedFields:m,formErrors:r,isCreatingEntry:a,onChange:l,readableFields:u,shouldNotRunValidations:d,value:h}}var Gd=Hd,oa=["type","model","via","collection","default","plugin","enum","regex","pluginOptions"];function bo({allowedFields:t,componentUid:o,fieldSchema:r,formErrors:a,isCreatingEntry:s,keys:l,labelAction:c,metadatas:d,onChange:p,readableFields:m,shouldNotRunValidations:u,queryInfos:h,value:E,size:g,customFieldInputs:b}){const{fields:C}=(0,f.yX)(),{formatMessage:L}=(0,H.Z)(),{contentType:v}=(0,be.PL)(),R=(0,e.useMemo)(()=>!w()(d,"editable",!0),[d]),{type:x,customField:V}=r,M=w()(a,[l],null),O=(0,e.useMemo)(()=>(0,y.Ts)(l),[l]),j=(0,e.useMemo)(()=>{const k=lc()(r,u?[...oa,"required","minLength"]:oa),z=r.regex||null;if(z){const ne=new RegExp(z);ne&&(k.regex=ne)}return k},[r,u]),$=(0,e.useMemo)(()=>w()(j,["required"],!1),[j]),P=(0,e.useMemo)(()=>{const k=w()(v,["attributes"],{});return w()(k,[O[0],"type"],null)==="dynamiczone"},[v,O]),N=qd(x),Y=x==="media"&&!E?[]:E,T=(0,e.useMemo)(()=>{const k=O.join(".");if(t.includes(k))return!0;if(P)return t.includes(O[0]);if(O.length>1){const ne=kt()(O,O.length-1).join(".");return t.includes(ne)}return!1},[t,O,P]),X=(0,e.useMemo)(()=>{const k=O.join(".");if(m.includes(k))return!0;if(P)return m.includes(O[0]);if(O.length>1){const ne=kt()(O,O.length-1).join(".");return m.includes(ne)}return!1},[m,O,P]),G=(0,e.useMemo)(()=>X||T,[T,X]),J=(0,e.useMemo)(()=>s?R:X&&!T?!0:R,[R,s,T,X]),F=(0,e.useMemo)(()=>zd(r.enum||[],$),[r,$]),{label:S,description:I,placeholder:A,visible:q}=d;if(q===!1)return null;if(!G)return e.createElement(f.X0,{description:I?{id:I,defaultMessage:I}:null,intlLabel:{id:S,defaultMessage:S},labelAction:c,error:M&&L(M),name:l,required:$});if(x==="relation")return e.createElement(wc,{...d,...r,componentUid:o,description:d.description?L({id:d.description,defaultMessage:d.description}):void 0,intlLabel:{id:d.label,defaultMessage:d.label},labelAction:c,isUserAllowedToEditField:T,isUserAllowedToReadField:X,name:l,placeholder:d.placeholder?{id:d.placeholder,defaultMessage:d.placeholder}:null,queryInfos:h,size:g,value:E,error:M&&L(M)});const K={uid:hc,media:C.media,wysiwyg:Nd,...C,...b};return e.createElement(f.jm,{attribute:r,autoComplete:"new-password",intlLabel:{id:S,defaultMessage:S},isNullable:N==="bool"&&[null,void 0].includes(r.default),description:I?{id:I,defaultMessage:I}:null,disabled:J,error:M,labelAction:c,contentTypeUID:v.uid,customInputs:K,multiple:r.multiple||!1,name:l,onChange:p,options:F,placeholder:A?{id:A,defaultMessage:A}:null,required:r.required||!1,step:Qd(x),type:V||N,value:Y,withDefaultValue:!1})}bo.defaultProps={componentUid:void 0,formErrors:{},labelAction:void 0,size:void 0,value:null,queryInfos:{},customFieldInputs:{}},bo.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 Qd=t=>{switch(t){case"float":case"decimal":return .01;default:return 1}},Kd=(0,e.memo)(bo,Fe());var vo=jd(Kd,Gd);const Co=({componentUid:t,isFromDynamicZone:o,isNested:r,name:a})=>{const{getComponentLayout:s}=(0,be.PL)(),c=(0,e.useMemo)(()=>s(t),[t,s]).layouts.edit,{lazyComponentStore:d}=Kn();return e.createElement(Q.x,{background:o?"":"neutral100",paddingLeft:6,paddingRight:6,paddingTop:6,paddingBottom:6,hasRadius:r,borderColor:r?"neutral200":""},e.createElement(D.k,{direction:"column",alignItems:"stretch",gap:6},c.map((p,m)=>e.createElement(Se.r,{gap:4,key:m},p.map(({name:u,size:h,metadatas:E,fieldSchema:g,queryInfos:b})=>{const C=g.type==="component",L=`${a}.${u}`;if(C){const v=g.component;return e.createElement(ve.P,{col:h,s:12,xs:12,key:u},e.createElement(Gt,{componentUid:v,intlLabel:{id:E.label,defaultMessage:E.label},isNested:!0,isRepeatable:g.repeatable,max:g.max,min:g.min,name:L,required:g.required||!1}))}return e.createElement(ve.P,{col:h,key:u,s:12,xs:12},e.createElement(vo,{componentUid:t,keys:L,fieldSchema:g,metadatas:E,queryInfos:b,size:h,customFieldInputs:d}))})))))};Co.defaultProps={isFromDynamicZone:!1,isNested:!1},Co.propTypes={componentUid:n().string.isRequired,isFromDynamicZone:n().bool,isNested:n().bool,name:n().string.isRequired};var Yd=Co;const Xd=(0,U.ZP)(Q.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
|
+
`,Jd=(0,U.ZP)(Q.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
|
+
`,Ro=({children:t,error:o})=>{const{formatMessage:r}=(0,H.Z)();return e.createElement(Ar.k,{attributeName:"data-strapi-accordion-toggle"},t,o&&e.createElement(Q.x,{paddingTop:1},e.createElement(W.Z,{variant:"pi",textColor:"danger600"},r({id:o.id,defaultMessage:o.defaultMessage},{...o.values}))))};Ro.defaultProps={error:void 0},Ro.propTypes={children:n().node.isRequired,error:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object})};var _d=i(41119),ra=i.n(_d);const eu=U.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 tu=()=>e.createElement(eu,{padding:6,background:"primary100"});const nu=(0,U.ZP)(Me.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
|
+
`,ou=(0,U.ZP)(D.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
|
+
`,Mo=({componentFieldName:t,componentUid:o,fields:r,index:a,isOpen:s,isReadOnly:l,mainField:c,moveComponentField:d,onClickToggle:p,toggleCollapses:m,onGrabItem:u,onDropItem:h,onCancel:E})=>{const{modifiedData:g,removeRepeatableField:b,triggerFormValidation:C}=(0,f.Wq)(),L=ra()(w()(g,[...t.split("."),c],"")),v=(0,e.useRef)(null),{formatMessage:R}=(0,H.Z)(),x=t.split(".").slice(0,-1).join("."),[{handlerId:V,isDragging:M,handleKeyDown:O},j,$,P,N]=(0,jr.Y)(!l,{type:`${y._Q.COMPONENT}_${x}`,index:a,item:{displayedValue:L},onMoveItem:d,onStart(){m()},onEnd(){C()},onGrabItem:u,onDropItem:h,onCancel:E});(0,e.useEffect)(()=>{N((0,Ot.rX)(),{captureDraggingState:!1})},[N,a]);const Y=(0,y.FE)(v,P),T=(0,y.FE)(j,$),{lazyComponentStore:X}=Kn();return e.createElement(Q.x,{ref:T},M?e.createElement(tu,null):e.createElement(zn.U,{expanded:s,onToggle:p,id:t,size:"S"},e.createElement(Vn.B,{action:l?null:e.createElement(ou,{gap:0,expanded:s},e.createElement(nu,{expanded:s,noBorder:!0,onClick:()=>{b(t),m()},label:R({id:(0,y.OB)("containers.Edit.delete"),defaultMessage:"Delete"}),icon:e.createElement(Xe.Z,null)}),e.createElement(Me.h,{className:"drag-handle",ref:Y,forwardedAs:"div",role:"button",noBorder:!0,tabIndex:0,onClick:G=>G.stopPropagation(),"data-handler-id":V,label:R({id:(0,y.OB)("components.DragHandle-label"),defaultMessage:"Drag"}),onKeyDown:O},e.createElement(ot.Z,null))),title:L,togglePosition:"left"}),e.createElement(Un.v,null,e.createElement(D.k,{direction:"column",alignItems:"stretch",background:"neutral100",padding:6,gap:6},r.map((G,J)=>e.createElement(Se.r,{gap:4,key:J},G.map(({name:F,fieldSchema:S,metadatas:I,queryInfos:A,size:q})=>{const K=S.type==="component",k=`${t}.${F}`;if(K){const z=S.component;return e.createElement(ve.P,{col:q,s:12,xs:12,key:F},e.createElement(Gt,{componentUid:z,intlLabel:{id:I.label,defaultMessage:I.label},isRepeatable:S.repeatable,isNested:!0,name:k,max:S.max,min:S.min,required:S.required}))}return e.createElement(ve.P,{key:k,col:q,s:12,xs:12},e.createElement(vo,{componentUid:o,fieldSchema:S,keys:k,metadatas:I,queryInfos:A,size:q,customFieldInputs:X}))})))))))};Mo.defaultProps={componentUid:void 0,fields:[],isReadOnly:!1,isOpen:!1,onGrabItem:void 0,onDropItem:void 0,onCancel:void 0,toggleCollapses(){}},Mo.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 ru=(0,e.memo)(Mo);function au(t,o={}){return Object.keys(o).filter(r=>r.startsWith(t)).map(r=>r.split(".").slice(0,t.split(".").length+1).join("."))}const su=(0,U.ZP)(eo.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
|
+
`,To=({componentUid:t,componentValue:o,componentValueLength:r,isReadOnly:a,max:s,min:l,name:c})=>{const{addRepeatableComponentToField:d,formErrors:p,moveComponentField:m}=(0,f.Wq)(),u=(0,f.lm)(),{formatMessage:h}=(0,H.Z)(),[E,g]=(0,e.useState)(""),[b,C]=(0,e.useState)(""),{getComponentLayout:L,components:v}=(0,be.PL)(),R=(0,e.useMemo)(()=>L(t),[t,L]),x=(0,e.useMemo)(()=>(0,y.Uo)(o||[])+1,[o]),V=au(c,p),M=l-r,O=w()(p,c,{id:""}).id.includes("min"),j=()=>{g("")},$=()=>{a||(r<s?(d(c,R,v,O),g(x)):r>=s&&u({type:"info",message:{id:(0,y.OB)("components.notification.info.maximum-requirement")}}))},P=(I,A)=>{C(h({id:(0,y.OB)("dnd.reorder"),defaultMessage:"{item}, moved. New position in list: {position}."},{item:`${c}.${A}`,position:T(I)})),m({name:c,newIndex:I,currentIndex:A})},N=w()(R,["settings","mainField"],"id"),Y=I=>()=>{g(E===I?"":I)},T=I=>`${I+1} of ${r}`,X=I=>{C(h({id:(0,y.OB)("dnd.cancel-item"),defaultMessage:"{item}, dropped. Re-order cancelled."},{item:`${c}.${I}`}))},G=I=>{C(h({id:(0,y.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:`${c}.${I}`,position:T(I)}))},J=I=>{C(h({id:(0,y.OB)("dnd.drop-item"),defaultMessage:"{item}, dropped. Final position in list: {position}."},{item:`${c}.${I}`,position:T(I)}))};let F=p[c];if(O?F={id:(0,y.OB)("components.DynamicZone.missing-components"),defaultMessage:"There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}",values:{number:M}}:V.some(I=>I.split(".").length>1)&&!O&&(F={id:(0,y.OB)("components.RepeatableComponent.error-message"),defaultMessage:"The component(s) contain error(s)"}),r===0)return e.createElement($r,{error:F,isReadOnly:a,onClick:$});const S=`${c}-item-instructions`;return e.createElement(Q.x,{hasRadius:!0},e.createElement(st.T,{id:S},h({id:(0,y.OB)("dnd.instructions"),defaultMessage:"Press spacebar to grab and re-order"})),e.createElement(st.T,{"aria-live":"assertive"},b),e.createElement(Ro,{error:F,ariaDescribedBy:S},e.createElement(Jd,{"aria-describedby":S},o.map(({__temp_key__:I},A)=>e.createElement(ru,{componentFieldName:`${c}.${A}`,componentUid:t,fields:R.layouts.edit,key:I,index:A,isOpen:E===I,isReadOnly:a,mainField:N,moveComponentField:P,onClickToggle:Y(I),toggleCollapses:j,onCancel:X,onDropItem:J,onGrabItem:G}))),e.createElement(Xd,null,e.createElement(D.k,{justifyContent:"center",height:"48px",background:"neutral0"},e.createElement(su,{disabled:a,onClick:$,startIcon:e.createElement(ft.Z,null)},h({id:(0,y.OB)("containers.EditView.add.new-entry"),defaultMessage:"Add an entry"}))))))};To.defaultProps={componentValue:null,componentValueLength:0,isReadOnly:!1,max:1/0,min:0},To.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 iu=(0,e.memo)(To);const lu=(0,U.ZP)(Q.x)`
|
|
910
|
+
svg path {
|
|
911
|
+
fill: ${({theme:t})=>t.colors.neutral500};
|
|
912
|
+
}
|
|
913
|
+
`,Do=({intlLabel:t,id:o,labelAction:r,name:a,numberOfEntries:s,showNumberOfEntries:l,required:c})=>{const{formatMessage:d}=(0,H.Z)(),p=t?.id?d(t):a;return e.createElement(Q.x,{paddingBottom:1},e.createElement(D.k,null,e.createElement(W.Z,{textColor:"neutral800",htmlFor:o||a,variant:"pi",fontWeight:"bold",as:"label"},p,l&&e.createElement(e.Fragment,null,"\xA0(",s,")"),c&&e.createElement(W.Z,{textColor:"danger600"},"*")),r&&e.createElement(lu,{paddingLeft:1},r)))};Do.defaultProps={id:void 0,labelAction:void 0,numberOfEntries:0,required:!1,showNumberOfEntries:!1},Do.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 cu=Do;function du(t,o){return r=>{const a=o(r);return e.createElement(t,{...r,...a})}}var uu=du;function mu({isFromDynamicZone:t,name:o}){const{addNonRepeatableComponentToField:r,createActionAllowedFields:a,isCreatingEntry:s,modifiedData:l,removeComponentFromField:c,readActionAllowedFields:d,updateActionAllowedFields:p,formErrors:m}=(0,f.Wq)(),{contentType:u}=(0,be.PL)(),h=(0,e.useMemo)(()=>{const R=w()(u,["attributes"],{});return Object.keys(R).filter(V=>w()(R,[V,"type"],"")==="dynamiczone")},[u]),E=(0,e.useMemo)(()=>s?a:p,[s,a,p]),g=w()(l,o,null),b=(0,e.useMemo)(()=>(0,y.Ts)(o),[o]),C=(0,e.useMemo)(()=>t&&s||E.filter(V=>V===b[0]).length>0?!0:E.map(V=>V.split(".")).filter(V=>V.length<b.length?!1:kt()(V,b.length).join(".")===b.join(".")).length>0,[t,s,E,b]),L=(0,e.useMemo)(()=>t||h.includes(b[0])?!0:(s?[]:d).map(V=>V.split(".")).filter(V=>V.length<b.length?!1:kt()(V,b.length).join(".")===b.join(".")).length>0,[t,h,b,s,d]),v=(0,e.useMemo)(()=>s||C?!1:L,[C,L,s]);return{addNonRepeatableComponentToField:r,formErrors:m,hasChildrenAllowedFields:C,hasChildrenReadableFields:L,isCreatingEntry:s,isReadOnly:v,removeComponentFromField:c,componentValue:g}}var pu=mu;const Oo=({addNonRepeatableComponentToField:t,componentUid:o,intlLabel:r,isCreatingEntry:a,isFromDynamicZone:s,isRepeatable:l,isNested:c,labelAction:d,max:p,min:m,name:u,hasChildrenAllowedFields:h,hasChildrenReadableFields:E,isReadOnly:g,componentValue:b,removeComponentFromField:C,required:L})=>{const{formatMessage:v}=(0,H.Z)(),R=ac()(b),x=b!==null||s,V=!l&&x&&!s&&h,{getComponentLayout:M,components:O}=(0,be.PL)(),j=(0,e.useMemo)(()=>M(o),[o,M]);if(!h&&a)return e.createElement(f.X0,{labelAction:d,intlLabel:r,name:u});if(!h&&!a&&!E)return e.createElement(f.X0,{labelAction:d,intlLabel:r,name:u});const $=()=>{t(u,j,O)};return e.createElement(Q.x,null,e.createElement(D.k,{justifyContent:"space-between"},r&&e.createElement(cu,{intlLabel:r,labelAction:d,name:u,numberOfEntries:R,showNumberOfEntries:l,required:L}),V&&e.createElement(Me.h,{label:v({id:(0,y.OB)("components.reset-entry"),defaultMessage:"Reset Entry"}),icon:e.createElement(Xe.Z,null),noBorder:!0,onClick:()=>{C(u,o)}})),e.createElement(D.k,{direction:"column",alignItems:"stretch",gap:1},!l&&!x&&e.createElement($r,{isReadOnly:g,onClick:$}),!l&&x&&e.createElement(Yd,{componentUid:o,isFromDynamicZone:s,isNested:c,name:u}),l&&e.createElement(iu,{componentValue:b,componentValueLength:R,componentUid:o,isReadOnly:g,max:p,min:m,name:u})))};Oo.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},Oo.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 gu=(0,e.memo)(Oo,Fe());var Gt=uu(gu,pu);const Io=({componentUid:t,formErrors:o,index:r,isFieldAllowed:a,name:s,onRemoveComponentClick:l,onMoveComponent:c,onGrabItem:d,onDropItem:p,onCancel:m,dynamicComponentsByCategory:u,onAddComponent:h})=>{const[E,g]=(0,e.useState)(!0),{formatMessage:b}=(0,H.Z)(),{getComponentLayout:C}=(0,be.PL)(),{modifiedData:L}=(0,f.Wq)(),{icon:v,friendlyName:R,mainValue:x}=(0,e.useMemo)(()=>{const F=C(t),{info:{icon:S,displayName:I}}=F,A=w()(F,["settings","mainField"],"id"),q=w()(L,[s,r,A])??"",K=A==="id"?"":String(q).trim(),k=K.length>0?` - ${K}`:K;return{friendlyName:I,icon:S,mainValue:k}},[t,C,L,s,r]),V=Object.keys(o).filter(F=>{const S=F.split(".");return`${S[0]}.${S[1]}`==`${s}.${r}`});let M;V.length>0&&(M=b({id:(0,y.OB)("components.DynamicZone.error-message"),defaultMessage:"The component contains error(s)"}));const O=()=>{g(F=>!F)},[{handlerId:j,isDragging:$,handleKeyDown:P},N,Y,T,X]=(0,be.Y9)(a,{type:`${y._Q.DYNAMIC_ZONE}_${s}`,index:r,item:{displayedValue:`${R}${x}`,icon:v},onMoveItem:c,onGrabItem:d,onDropItem:p,onCancel:m});(0,e.useEffect)(()=>{X((0,Ot.rX)(),{captureDraggingState:!1})},[X,r]);const G=(0,y.FE)(N,Y),J=a?e.createElement(fu,{gap:0,expanded:E},e.createElement(hu,{noBorder:!0,label:b({id:(0,y.OB)("components.DynamicZone.delete-label"),defaultMessage:"Delete {name}"},{name:R}),onClick:l},e.createElement(Xe.Z,null)),e.createElement(Me.h,{forwardedAs:"div",role:"button",noBorder:!0,tabIndex:0,onClick:F=>F.stopPropagation(),"data-handler-id":j,ref:T,label:b({id:(0,y.OB)("components.DragHandle-label"),defaultMessage:"Drag"}),onKeyDown:P},e.createElement(ot.Z,null)),e.createElement(ge.fC,null,e.createElement(ge.xz,{size:"S",endIcon:void 0,paddingLeft:2,paddingRight:2},e.createElement(Gn.Z,{"aria-hidden":!0,focusable:!1}),e.createElement(st.T,{as:"span"},b({id:(0,y.OB)("components.DynamicZone.more-actions"),defaultMessage:"More actions"}))),e.createElement(ge.VY,null,e.createElement(ge.rl,null,e.createElement(ge.fF,null,b({id:(0,y.OB)("components.DynamicZone.add-item-above"),defaultMessage:"Add component above"})),e.createElement(ge.tu,null,Object.entries(u).map(([F,S])=>e.createElement(e.Fragment,{key:F},e.createElement(ge.__,null,F),S.map(({componentUid:I,info:{displayName:A}})=>e.createElement(Fr.sN,{key:I,onSelect:()=>h(I,r)},A)))))),e.createElement(ge.rl,null,e.createElement(ge.fF,null,b({id:(0,y.OB)("components.DynamicZone.add-item-below"),defaultMessage:"Add component below"})),e.createElement(ge.tu,null,Object.entries(u).map(([F,S])=>e.createElement(e.Fragment,{key:F},e.createElement(ge.__,null,F),S.map(({componentUid:I,info:{displayName:A}})=>e.createElement(Fr.sN,{key:I,onSelect:()=>h(I,r+1)},A))))))))):null;return e.createElement(Cu,{as:"li",width:"100%"},e.createElement(D.k,{justifyContent:"center"},e.createElement(bu,{background:"neutral200"})),e.createElement(Eu,{ref:G,hasRadius:!0},$?e.createElement(vu,{padding:6,background:"primary100"}):e.createElement(zn.U,{expanded:E,onToggle:O,size:"S",error:M},e.createElement(Vn.B,{startIcon:e.createElement(Pt,{icon:v,showBackground:!1,size:"S"}),action:J,title:`${R}${x}`,togglePosition:"left"}),e.createElement(Un.v,null,e.createElement(yu,{background:"neutral0"},e.createElement(Gt,{componentUid:t,icon:v,name:`${s}.${r}`,isFromDynamicZone:!0}))))))},fu=(0,U.ZP)(D.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
|
+
`,hu=(0,U.ZP)(Me.h)`
|
|
923
|
+
background-color: transparent;
|
|
924
|
+
|
|
925
|
+
svg path {
|
|
926
|
+
fill: ${({theme:t,expanded:o})=>o?t.colors.primary600:t.colors.neutral600};
|
|
927
|
+
}
|
|
928
|
+
`,Eu=(0,U.ZP)(Q.x)`
|
|
929
|
+
> div:first-child {
|
|
930
|
+
box-shadow: ${({theme:t})=>t.shadows.tableShadow};
|
|
931
|
+
}
|
|
932
|
+
`,yu=(0,U.ZP)(Q.x)`
|
|
933
|
+
border-radius: 0 0 ${({theme:t})=>t.spaces[1]} ${({theme:t})=>t.spaces[1]};
|
|
934
|
+
`,bu=(0,U.ZP)(Q.x)`
|
|
935
|
+
width: ${({theme:t})=>t.spaces[2]};
|
|
936
|
+
height: ${({theme:t})=>t.spaces[4]};
|
|
937
|
+
`,vu=U.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
|
+
`,Cu=(0,U.ZP)(Q.x)`
|
|
944
|
+
list-style: none;
|
|
945
|
+
padding: 0;
|
|
946
|
+
margin: 0;
|
|
947
|
+
`;Io.defaultProps={dynamicComponentsByCategory:{},formErrors:{},index:0,isFieldAllowed:!0,onAddComponent:void 0,onGrabItem:void 0,onDropItem:void 0,onCancel:void 0},Io.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 Po=({label:t,labelAction:o,name:r,numberOfComponents:a,required:s,intlDescription:l})=>{const{formatMessage:c}=(0,H.Z)(),d=c({id:t||r,defaultMessage:t||r});return e.createElement(D.k,{justifyContent:"center"},e.createElement(Q.x,{paddingTop:3,paddingBottom:3,paddingRight:4,paddingLeft:4,borderRadius:26,background:"neutral0",shadow:"filterShadow",color:"neutral500"},e.createElement(D.k,{direction:"column",justifyContent:"center"},e.createElement(D.k,{maxWidth:(0,f.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(Q.x,{paddingLeft:1},o)),l&&e.createElement(Q.x,{paddingTop:1,maxWidth:(0,f.Q1)(356)},e.createElement(W.Z,{variant:"pi",textColor:"neutral600",ellipsis:!0},c(l))))))};Po.defaultProps={intlDescription:void 0,label:"",labelAction:void 0,numberOfComponents:0,required:!1},Po.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 So=({name:t,labelAction:o,fieldSchema:r,metadatas:a})=>{const{max:s=1/0,min:l=-1/0,components:c=[],required:d=!1}=r,[p,m]=(0,e.useState)(!1),[u,h]=(0,e.useState)(""),{addComponentToDynamicZone:E,createActionAllowedFields:g,isCreatingEntry:b,formErrors:C,modifiedData:L,moveComponentField:v,removeComponentFromDynamicZone:R,readActionAllowedFields:x,updateActionAllowedFields:V}=(0,f.Wq)(),M=(0,e.useMemo)(()=>(L?.[t]??[]).map(Z=>({componentUid:Z.__component,id:Z.id??Z.__temp_key__})),[L,t]),{getComponentLayout:O,components:j}=(0,be.PL)(),$=(0,e.useMemo)(()=>c.reduce((Z,te)=>{const{category:me,info:Ze,attributes:ke}=O(te),de={componentUid:te,info:Ze,attributes:ke};return Z[me]||(Z[me]=[]),Z[me]=[...Z[me],de],Z},{}),[c,O]),{formatMessage:P}=(0,H.Z)(),N=(0,f.lm)(),Y=(0,e.useMemo)(()=>(b?g:V).includes(t),[t,b,g,V]),T=(0,e.useMemo)(()=>(b?[]:x).includes(t),[t,b,x]),X=M.length,G=a.description?{id:a.description,defaultMessage:a.description}:null,J=C[t],F=l-X,S=!!J,I=(Z,te)=>{m(!1);const me=O(Z);E(t,me,j,S,te)},A=()=>{X<s?m(Z=>!Z):N({type:"info",message:{id:(0,y.OB)("components.notification.info.maximum-requirement")}})},q=(Z,te)=>{h(P({id:(0,y.OB)("dnd.reorder"),defaultMessage:"{item}, moved. New position in list: {position}."},{item:`${t}.${te}`,position:K(Z)})),v({name:t,newIndex:Z,currentIndex:te})},K=Z=>`${Z+1} of ${M.length}`,k=Z=>{h(P({id:(0,y.OB)("dnd.cancel-item"),defaultMessage:"{item}, dropped. Re-order cancelled."},{item:`${t}.${Z}`}))},z=Z=>{h(P({id:(0,y.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:K(Z)}))},ne=Z=>{h(P({id:(0,y.OB)("dnd.drop-item"),defaultMessage:"{item}, dropped. Final position in list: {position}."},{item:`${t}.${Z}`,position:K(Z)}))},ce=(Z,te)=>()=>{R(Z,te)},he=()=>p?P({id:"app.utils.close-label",defaultMessage:"Close"}):S&&J.id.includes("max")?P({id:"components.Input.error.validation.max",defaultMessage:"The value is too high."}):S&&J.id.includes("min")?P({id:(0,y.OB)("components.DynamicZone.missing-components"),defaultMessage:"There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"},{number:F}):P({id:(0,y.OB)("components.DynamicZone.add-component"),defaultMessage:"Add a component to {componentName}"},{componentName:a.label||t});if(!Y&&(b||!T&&!b))return e.createElement(f.X0,{description:G,intlLabel:{id:a.label,defaultMessage:a.label},labelAction:o,name:t});const fe=`${t}-item-instructions`;return e.createElement(D.k,{direction:"column",alignItems:"stretch",gap:6},X>0&&e.createElement(Q.x,null,e.createElement(Po,{intlDescription:G,label:a.label,labelAction:o,name:t,numberOfComponents:X,required:d}),e.createElement(st.T,{id:fe},P({id:(0,y.OB)("dnd.instructions"),defaultMessage:"Press spacebar to grab and re-order"})),e.createElement(st.T,{"aria-live":"assertive"},u),e.createElement("ol",{"aria-describedby":fe},M.map(({componentUid:Z,id:te},me)=>e.createElement(Io,{componentUid:Z,formErrors:C,key:`${Z}-${te}`,index:me,isFieldAllowed:Y,name:t,onMoveComponent:q,onRemoveComponentClick:ce(t,me),onCancel:k,onDropItem:ne,onGrabItem:z,onAddComponent:I,dynamicComponentsByCategory:$})))),e.createElement(D.k,{justifyContent:"center"},e.createElement(Wn,{hasError:S,isDisabled:!Y,isOpen:p,onClick:A},he())),e.createElement(Hn,{dynamicComponentsByCategory:$,isOpen:p,onClickAddComponent:I}))};So.defaultProps={fieldSchema:{},labelAction:null},So.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 Ru=i(86834),We=i.n(Ru),aa=i(12788),Zo=i(99526),Mu=i(10268),sa=i.n(Mu),Tu=i(56236),Du=i.n(Tu),Ou=i(77236),Iu=i.n(Ou),Pu=i(85973),Su=i.n(Pu);const Zu=({browserState:t,serverState:o},r,a)=>{const s=o,l=t,c=(m,u)=>w()(m,["attributes",u,"type"],""),d=(m,u)=>w()(m,["attributes",...u],""),p=(m,u,h,E)=>Object.keys(m).reduce((g,b)=>{const C=E?`${E}.${b}`:b,L=c(h,b),v=w()(m,b),R=w()(u,b),x=d(h,[b,"component"]),V=d(h,[b,"repeatable"]);let M;switch(L){case"json":M=JSON.parse(v);break;case"time":{M=v,v&&v.split(":").length<3&&(M=`${v}:00`);break}case"media":d(h,[b,"multiple"])===!0?M=v?v.filter(O=>!(O instanceof File)):null:M=w()(v,0)instanceof File?null:w()(v,"id",null);break;case"component":V?M=v&&v.map((O,j)=>p(O,(R??[])[j],a[x],`${C}.${j}`)):M=v&&p(v,R,a[x],C);break;case"relation":{const O=Nr(s,l)(C).join(".");let j=w()(s,O,[]);const $=v.reduce((N,Y,T,X)=>{const G=j.find(F=>F.id===Y.id),J=X[T+1];if(!G||G.__temp_key__!==Y.__temp_key__){const F=J?{before:J.id}:{end:!0};return[...N,{id:Y.id,position:F}]}return N},[]);M={disconnect:j.reduce((N,Y)=>v.find(T=>T.id===Y.id)?N:[...N,{id:Y.id}],[]),connect:$.reverse()};break}case"dynamiczone":M=v.map((O,j)=>p(O,(R??[])[j],a[O.__component],`${C}.${j}`));break;default:M=xu(v,"id")}return g[b]=M,g},{});return p(t,o,r,"")},xu=(t,o)=>Iu()(t)?t.map(r=>r[o]?r[o]:r):Su()(t)?t[o]:t;var Lu=Zu;const Qt=(t,o=()=>!1,r=void 0)=>{const a=(s,l,{ignoreFalseyValues:c=!1,path:d=[],parent:p=l}={})=>Object.entries(l).reduce((m,[u,h])=>{if(c&&(m==null||m[u]===void 0||m[u]===null))return m;if(o(h,{path:[...d,u],parent:p})&&(m[u]=typeof r=="function"?r(m[u],{path:[...d,u],parent:m}):r),h.type==="component"){const E=t[h.component].attributes;!h.repeatable&&m[u]&&typeof m[u]=="object"?m[u]=a(m[u],E,{ignoreFalseyValues:c,path:[...d,u],parent:l[u]}):h.repeatable&&Array.isArray(m[u])&&(m[u]=m[u].map((g,b)=>a(g,E,{ignoreFalseyValues:c,path:[...d,u,b],parent:l[u]})))}else h.type==="dynamiczone"&&Array.isArray(m[u])&&(m[u]=m[u].map((E,g)=>{const b=t[E.__component].attributes;return a(E,b,{ignoreFalseyValues:c,path:[...d,u,g],parent:l[u]})}));return m},{...s});return a};var ia=(t,o,r,a)=>{const s=t.slice();return s.splice(o,1),s.splice(r,0,a),s};const ku={componentsDataStructure:{},contentTypeDataStructure:{},formErrors:{},initialData:{},modifiedData:null,shouldCheckErrors:!1,modifiedDZName:null,publishConfirmation:{show:!1,draftCount:0}};var Au=(t,o)=>(0,xn.ZP)(t,r=>{switch(o.type){case"ADD_NON_REPEATABLE_COMPONENT_TO_FIELD":{const{componentLayoutData:a,allComponents:s}=o,l={...t.componentsDataStructure[a.uid]},d=Qt(s,p=>p.type==="relation",[])(l,a.attributes);ae()(r,["modifiedData",...o.keys],d);break}case"ADD_COMPONENT_TO_DYNAMIC_ZONE":case"ADD_REPEATABLE_COMPONENT_TO_FIELD":{const{keys:a,allComponents:s,componentLayoutData:l,shouldCheckErrors:c,position:d=void 0}=o;c&&(r.shouldCheckErrors=!t.shouldCheckErrors),o.type==="ADD_COMPONENT_TO_DYNAMIC_ZONE"&&(r.modifiedDZName=a[0]);const p=[...w()(t,["modifiedData",...a],[])];let m=d;m===void 0?m=p.length:m<0&&(m=0);const u=o.type==="ADD_COMPONENT_TO_DYNAMIC_ZONE"?{...t.componentsDataStructure[l.uid],__component:l.uid,__temp_key__:(0,y.Uo)(p)+1}:{...t.componentsDataStructure[l.uid],__temp_key__:(0,y.Uo)(p)+1},E=Qt(s,g=>g.type==="relation",[])(u,l.attributes);p.splice(m,0,E),ae()(r,["modifiedData",...a],p);break}case"LOAD_RELATION":{const{initialDataPath:a,modifiedDataPath:s,value:l}=o,c=w()(t,a),d=w()(t,s),p=c?l.filter(h=>!c.some(E=>E.id===h.id)):l,m=(0,Zo.zJ)(null,d[0]?.__temp_key__,p.length),u=p.map((h,E)=>({...h,__temp_key__:m[E]}));ae()(r,a,sa()([...u,...c],"id")),ae()(r,s,sa()([...u,...d],"id"));break}case"CONNECT_RELATION":{const a=["modifiedData",...o.keys],{value:s,toOneRelation:l}=o;if(l)ae()(r,a,[s]);else{const c=w()(t,a),[d]=(0,Zo.zJ)(c.at(-1)?.__temp_key__,null,1),p=[...c,{...s,__temp_key__:d}];ae()(r,a,p)}break}case"DISCONNECT_RELATION":{const a=["modifiedData",...o.keys],{id:s}=o,c=w()(t,[...a]).filter(d=>d.id!==s);ae()(r,a,c);break}case"MOVE_COMPONENT_FIELD":case"REORDER_RELATION":{const{oldIndex:a,newIndex:s,keys:l}=o,c=["modifiedData",...l],d=w()(t,[...c]),p=d[a],m=[...d];if(o.type==="REORDER_RELATION"){const u=a>s?d[s-1]?.__temp_key__:d[s]?.__temp_key__,h=a>s?d[s]?.__temp_key__:d[s+1]?.__temp_key__,[E]=(0,Zo.zJ)(u,h,1);m.splice(a,1),m.splice(s,0,{...p,__temp_key__:E})}else m.splice(a,1),m.splice(s,0,p);ae()(r,c,m);break}case"INIT_FORM":{const{initialValues:a,components:s={},attributes:l={},setModifiedDataOnly:c}=o,d=Ye()(a),m=Qt(s,E=>E.type==="relation",(E,{path:g})=>{const b=g[g.length-1];return E&&(b==="createdBy"||b==="updatedBy")?E:t.modifiedData?.id===d.id&&w()(t.modifiedData,g)?w()(t.modifiedData,g):[]})(d,l),h=Qt(s,E=>E.type==="dynamiczone"||E.type==="component"&&!E.repeatable,E=>Array.isArray(E)?E.map((g,b)=>({...g,__temp_key__:b})):{...E,__temp_key__:0})(m,l,{ignoreFalseyValues:!0});c||(r.initialData=h),r.modifiedData=h,r.formErrors={},r.modifiedDZName=null,r.shouldCheckErrors=!1;break}case"MOVE_COMPONENT_UP":case"MOVE_COMPONENT_DOWN":{const{currentIndex:a,dynamicZoneName:s,shouldCheckErrors:l}=o;l&&(r.shouldCheckErrors=!t.shouldCheckErrors);const c=t.modifiedData[s],d=o.type==="MOVE_COMPONENT_UP"?a-1:a+1,p=t.modifiedData[s][a],m=ia(c,a,d,p);ae()(r,["modifiedData",o.dynamicZoneName],m);break}case"MOVE_FIELD":{const a=w()(t,["modifiedData",...o.keys],[]).slice(),s=w()(t,["modifiedData",...o.keys,o.dragIndex]),l=ia(a,o.dragIndex,o.overIndex,s);ae()(r,["modifiedData",...o.keys],l);break}case"ON_CHANGE":{const[a]=o.keys;if(o.shouldSetInitialValue&&ae()(r,["initialData",...o.keys],o.value),o.keys.length===2&&w()(t,["modifiedData",a])===null){ae()(r,["modifiedData",a],{[o.keys[1]]:o.value});break}ae()(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];ae()(r,a,null);break}case"REMOVE_PASSWORD_FIELD":{Du()(r,["modifiedData",...o.keys]);break}case"REMOVE_REPEATABLE_FIELD":{const a=o.keys.length-1,s=["modifiedData",...kt()(o.keys,a)];Object.keys(t.formErrors).length>0&&(r.shouldCheckErrors=!t.shouldCheckErrors);const c=w()(t,s).slice();c.splice(parseInt(o.keys[a],10),1),ae()(r,s,c);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 xo=({allLayoutData:t,allowedActions:{canRead:o,canUpdate:r},children:a,componentsDataStructure:s,contentTypeDataStructure:l,createActionAllowedFields:c,from:d,initialValues:p,isCreatingEntry:m,isLoadingForData:u,isSingleType:h,onPost:E,onPublish:g,onDraftRelationCheck:b,onPut:C,onUnpublish:L,readActionAllowedFields:v,redirectToPreviousPage:R,slug:x,status:V,updateActionAllowedFields:M})=>{const[O,j]=e.useState(!1),[$,P]=(0,e.useReducer)(Au,ku),{formErrors:N,initialData:Y,modifiedData:T,modifiedDZName:X,shouldCheckErrors:G,publishConfirmation:J}=$,{setModifiedDataOnly:F}=(0,re.v9)(Bn),S=(0,re.I0)(),I=(0,f.lm)(),{lockApp:A,unlockApp:q}=(0,f.o1)(),K=w()(t,["contentType"],{}),k=(0,e.useMemo)(()=>w()(K,["options","draftAndPublish"],!1),[K]),z=(0,e.useMemo)(()=>k&&!Y.publishedAt,[k,Y.publishedAt]),{trackUsage:ne}=(0,f.rS)(),{formatMessage:ce}=(0,H.Z)(),he=(0,e.useRef)(ne),fe=(0,e.useMemo)(()=>u||m?!1:o===!1&&r===!1,[u,m,o,r]);(0,e.useEffect)(()=>{V==="resolved"?q():A()},[A,q,V]),(0,e.useEffect)(()=>{u||Je()},[G]),(0,e.useEffect)(()=>{const B=Object.keys(N);if(B.length>0){const _=B[0],ie=document.getElementById(_);ie&&ie.focus()}},[N]),(0,e.useEffect)(()=>{fe&&I({type:"info",message:{id:(0,y.OB)("permissions.not-allowed.update")}})},[fe,I]),(0,e.useEffect)(()=>{P({type:"SET_DEFAULT_DATA_STRUCTURES",componentsDataStructure:s,contentTypeDataStructure:l})},[s,l]);const{components:Z}=t,te=(0,be.zH)(p);(0,e.useEffect)(()=>{p&&K?.attributes&&!Fe()(te,p)&&(P({type:"INIT_FORM",initialValues:p,components:Z,attributes:K.attributes,setModifiedDataOnly:F}),F&&S(_l()))},[p,K,Z,F,S,te]);const me=(0,e.useCallback)(B=>(_,ie,Ie,Be=!1,it=void 0)=>{he.current("didAddComponentToDynamicZone"),P({type:B,keys:_.split("."),position:it,componentLayoutData:ie,allComponents:Ie,shouldCheckErrors:Be})},[]),Ze=me("ADD_COMPONENT_TO_DYNAMIC_ZONE"),ke=(0,e.useCallback)((B,_,ie)=>{P({type:"ADD_NON_REPEATABLE_COMPONENT_TO_FIELD",keys:B.split("."),componentLayoutData:_,allComponents:ie})},[]),de=(0,e.useCallback)(({name:B,value:_,toOneRelation:ie})=>{P({type:"CONNECT_RELATION",keys:B.split("."),value:_,toOneRelation:ie})},[]),Ae=(0,e.useCallback)(({target:{initialDataPath:B,modifiedDataPath:_,value:ie,modifiedDataOnly:Ie}})=>{P({type:"LOAD_RELATION",modifiedDataPath:_,initialDataPath:B,value:ie,modifiedDataOnly:Ie})},[]),je=me("ADD_REPEATABLE_COMPONENT_TO_FIELD"),De=(0,e.useMemo)(()=>{const B={isCreatingEntry:m,isDraft:z,isFromComponent:!1};return(0,y.Ex)(K,{components:t.components||{}},B)},[t.components,K,m,z]),Je=(0,e.useCallback)(async(B={})=>{let _={};const ie=Ye()(T);We()(ie)||ae()(ie,B.path,B.value);try{await De.validate(ie,{abortEarly:!1})}catch(Ie){_=(0,f.CJ)(Ie),X&&(_=Object.keys(_).reduce((Be,it)=>(it.split(".")[0]!==X&&(Be[it]=_[it]),Be),{}))}P({type:"SET_FORM_ERRORS",errors:_})},[X,T,De]),Bt=(0,e.useCallback)(({target:{name:B,value:_,type:ie}},Ie=!1)=>{let Be=_;if(["text","textarea","string","email","uid","select","select-one","number"].includes(ie)&&!_&&_!==0&&(Be=null),ie==="password"&&!_){P({type:"REMOVE_PASSWORD_FIELD",keys:B.split(".")});return}P({type:"ON_CHANGE",keys:B.split("."),value:Be,shouldSetInitialValue:Ie})},[]),pt=(0,e.useCallback)((B,_)=>Lu({browserState:B,serverState:_},K,t.components),[t.components,K]),Ee=(0,e.useMemo)(()=>k?z?{status:"draft"}:{}:{},[k,z]),Ce=(0,e.useCallback)(async B=>(B.preventDefault(),P({type:"RESET_PUBLISH_CONFIRMATION"})),[]),_e=(0,e.useCallback)(async B=>{B.preventDefault();let _={};try{await De.validate(T,{abortEarly:!1})}catch(ie){_=(0,f.CJ)(ie)}try{if(We()(_)){const ie=pt(T,Y);(0,aa.flushSync)(()=>{j(!0)}),m?await E(ie,Ee):await C(ie,Ee),j(!1)}}catch(ie){j(!1),_={..._,...(0,f.nn)(ie,{getTrad:y.OB})}}P({type:"SET_FORM_ERRORS",errors:_})},[pt,m,T,Y,E,C,Ee,De]),on=(0,e.useCallback)(async()=>{const B=(0,y.Ex)(K,{components:w()(t,"components",{})},{isCreatingEntry:m,isDraft:!1,isFromComponent:!1}),_=await b();if(!J.show&&_>0){P({type:"SET_PUBLISH_CONFIRMATION",publishConfirmation:{show:!0,draftCount:_}});return}P({type:"RESET_PUBLISH_CONFIRMATION"});let ie={};try{await B.validate(T,{abortEarly:!1})}catch(Ie){ie=(0,f.CJ)(Ie)}try{We()(ie)&&((0,aa.flushSync)(()=>{j(!0)}),await g(),j(!1))}catch(Ie){j(!1),ie={...ie,...(0,f.nn)(Ie,{getTrad:y.OB})}}P({type:"SET_FORM_ERRORS",errors:ie})},[t,K,m,T,J.show,g,b]),He=(0,e.useCallback)(B=>{const _=Object.keys(N).some(Ie=>Ie.split(".")[0]===B);return!We()(N)&&_},[N]),er=(0,e.useCallback)((B,_)=>{he.current("changeComponentsOrder"),P({type:"MOVE_COMPONENT_DOWN",dynamicZoneName:B,currentIndex:_,shouldCheckErrors:He(B)})},[He]),rn=(0,e.useCallback)((B,_)=>{he.current("changeComponentsOrder"),P({type:"MOVE_COMPONENT_UP",dynamicZoneName:B,currentIndex:_,shouldCheckErrors:He(B)})},[He]),tr=(0,e.useCallback)(({name:B,newIndex:_,currentIndex:ie})=>{P({type:"MOVE_COMPONENT_FIELD",keys:B.split("."),newIndex:_,oldIndex:ie})},[]),nr=(0,e.useCallback)(({name:B,id:_})=>{P({type:"DISCONNECT_RELATION",keys:B.split("."),id:_})},[]),or=(0,e.useCallback)(({name:B,oldIndex:_,newIndex:ie})=>{P({type:"REORDER_RELATION",keys:B.split("."),oldIndex:_,newIndex:ie})},[]),rr=(0,e.useCallback)((B,_)=>{he.current("removeComponentFromDynamicZone"),P({type:"REMOVE_COMPONENT_FROM_DYNAMIC_ZONE",dynamicZoneName:B,index:_,shouldCheckErrors:He(B)})},[He]),ee=(0,e.useCallback)((B,_)=>{P({type:"REMOVE_COMPONENT_FROM_FIELD",keys:B.split("."),componentUid:_})},[]),se=(0,e.useCallback)((B,_)=>{P({type:"REMOVE_REPEATABLE_FIELD",keys:B.split("."),componentUid:_})},[]),oe=(0,e.useCallback)(()=>{P({type:"TRIGGER_FORM_VALIDATION"})},[]);return fe?e.createElement(le.l_,{to:d}):T?e.createElement(f.W1.Provider,{value:{addComponentToDynamicZone:Ze,addNonRepeatableComponentToField:ke,addRepeatableComponentToField:je,allLayoutData:t,checkFormErrors:Je,createActionAllowedFields:c,formErrors:N,hasDraftAndPublish:k,initialData:Y,isCreatingEntry:m,isSingleType:h,shouldNotRunValidations:z,status:V,layout:K,modifiedData:T,moveComponentField:tr,moveComponentDown:er,moveComponentUp:rn,onChange:Bt,onPublish:on,onUnpublish:L,readActionAllowedFields:v,redirectToPreviousPage:R,removeComponentFromDynamicZone:rr,removeComponentFromField:ee,removeRepeatableField:se,relationConnect:de,relationDisconnect:nr,relationLoad:Ae,relationReorder:or,slug:x,triggerFormValidation:oe,updateActionAllowedFields:M,onPublishPromptDismissal:Ce,publishConfirmation:J}},u||!m&&!Y.id?e.createElement(Te.o,{"aria-busy":"true"},e.createElement(f.dO,null)):e.createElement(e.Fragment,null,O?null:e.createElement(le.NL,{when:!Fe()(T,Y),message:ce({id:"global.prompt.unsaved"})}),e.createElement("form",{noValidate:!0,onSubmit:_e},a))):null};xo.defaultProps={from:"/",initialValues:null,redirectToPreviousPage(){}},xo.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 Fu=xo;const $u=(t={})=>Object.values(t).reduce((o,r)=>Object.assign(o,r),{});var la=(t={})=>{const{plugins:o,_q:r,...a}={...t,...$u(t.plugins)};return r&&(a._q=encodeURIComponent(r)),a};const ca=({allLayoutData:t,children:o,slug:r})=>{const a=(0,Ne.useQueryClient)(),{trackUsage:s}=(0,f.rS)(),{push:l}=(0,le.k6)(),{setCurrentStep:c}=(0,f.c1)(),d=(0,e.useRef)(s),[p,m]=(0,e.useState)(!0),[{query:u,rawQuery:h}]=(0,f.Kx)(),E=(0,e.useMemo)(()=>la(u),[u]),g=(0,f.lm)(),b=(0,re.I0)(),{formatAPIError:C}=(0,f.So)(y.OB),L=(0,f.kY)(),{post:v,put:R,del:x}=L,{componentsDataStructure:V,contentTypeDataStructure:M,data:O,isLoading:j,status:$}=(0,re.v9)(Bn),P=(0,e.useCallback)(S=>{const I=(0,y.kc)(S,t.contentType,t.components);return(0,f.dU)(I,t.contentType,t.components)},[t]);(0,e.useEffect)(()=>()=>{b(xr())},[b]),(0,e.useEffect)(()=>{const S=Object.keys(t.components).reduce((q,K)=>{const k=(0,y.Di)(w()(t,["components",K,"attributes"],{}),t.components);return q[K]=(0,f.dU)(k,t.components[K],t.components),q},{}),I=(0,y.Di)(t.contentType.attributes,t.components),A=(0,f.dU)(I,t.contentType,t.components);b(Lr(S,A))},[t,b]),(0,e.useEffect)(()=>{const I=qe.default.CancelToken.source();return(async q=>{b(Vt()),m(!0);try{const{data:K}=await L.get(`/content-manager/single-types/${r}`,{cancelToken:q.token,params:E});b(Fn(P(K))),m(!1)}catch(K){if(qe.default.isCancel(K))return;const k=w()(K,"response.status",null);k===404&&b($n(h,!0)),k===403&&(g({type:"info",message:{id:(0,y.OB)("permissions.not-allowed.update")}}),l("/"))}})(I),()=>I.cancel("Operation canceled by the user.")},[L,P,l,r,b,E,h,g]);const N=(0,e.useCallback)(S=>{g({type:"warning",message:C(S)})},[g,C]),Y=(0,e.useCallback)(async S=>{try{d.current("willDeleteEntry",S);const{data:I}=await x(`/content-manager/single-types/${r}`,{params:E});return g({type:"success",message:{id:(0,y.OB)("success.record.delete")}}),d.current("didDeleteEntry",S),m(!0),b($n(h,!0)),Promise.resolve(I)}catch(I){return d.current("didNotDeleteEntry",{error:I,...S}),N(I),Promise.reject(I)}},[x,r,E,g,b,h,N]),T=(0,e.useCallback)(async(S,I)=>{const A=`/content-manager/single-types/${r}`;try{b(pe("submit-pending"));const{data:q}=await R(A,S,{params:u});return d.current("didCreateEntry",I),g({type:"success",message:{id:(0,y.OB)("success.record.save")}}),c("contentManager.success"),a.invalidateQueries(["relation"]),b(at(P(q))),m(!1),b(pe("resolved")),Promise.resolve(q)}catch(q){return d.current("didNotCreateEntry",{error:q,trackerProperty:I}),N(q),b(pe("resolved")),Promise.reject(q)}},[R,P,N,r,b,u,g,c,a]),X=(0,e.useCallback)(async()=>{try{d.current("willCheckDraftRelations");const S=`/content-manager/single-types/${r}/actions/countDraftRelations`;b(pe("draft-relation-check-pending"));const I=await L.get(S);return d.current("didCheckDraftRelations"),b(pe("resolved")),I.data.data}catch(S){return N(S),b(pe("resolved")),Promise.reject(S)}},[L,N,r,b]),G=(0,e.useCallback)(async()=>{try{d.current("willPublishEntry");const S=`/content-manager/single-types/${r}/actions/publish`;b(pe("publish-pending"));const{data:I}=await v(S,{},{params:E});return d.current("didPublishEntry"),g({type:"success",message:{id:(0,y.OB)("success.record.publish")}}),b(at(P(I))),b(pe("resolved")),Promise.resolve(I)}catch(S){return N(S),b(pe("resolved")),Promise.reject(S)}},[r,b,v,E,g,P,N]),J=(0,e.useCallback)(async(S,I)=>{const A=`/content-manager/single-types/${r}`;try{d.current("willEditEntry",I),b(pe("submit-pending"));const{data:q}=await R(A,S,{params:u});return g({type:"success",message:{id:(0,y.OB)("success.record.save")}}),d.current("didEditEntry",{trackerProperty:I}),a.invalidateQueries(["relation"]),b(at(P(q))),b(pe("resolved")),Promise.resolve(q)}catch(q){return N(q),d.current("didNotEditEntry",{error:q,trackerProperty:I}),b(pe("resolved")),Promise.reject(q)}},[R,P,N,r,b,u,g,a]),F=(0,e.useCallback)(async()=>{const S=`/content-manager/single-types/${r}/actions/unpublish`;b(pe("unpublish-pending"));try{d.current("willUnpublishEntry");const{data:I}=await v(S,{},{params:E});d.current("didUnpublishEntry"),g({type:"success",message:{id:(0,y.OB)("success.record.unpublish")}}),b(at(P(I))),b(pe("resolved"))}catch(I){b(pe("resolved")),N(I)}},[r,b,v,E,g,P,N]);return o({componentsDataStructure:V,contentTypeDataStructure:M,data:O,isCreatingEntry:p,isLoadingForData:j,onDelete:Y,onPost:T,onDraftRelationCheck:X,onPublish:G,onPut:J,onUnpublish:F,redirectionLink:"/",status:$})};ca.propTypes={allLayoutData:n().shape({components:n().object.isRequired,contentType:n().object.isRequired}).isRequired,children:n().func.isRequired,slug:n().string.isRequired};var Bu=(0,e.memo)(ca);function wu(t,o){return r=>{const a=o();return e.createElement(t,{...r,...a})}}var Nu=wu;function Wu(){const{hasDraftAndPublish:t,modifiedData:o}=(0,f.Wq)();let r={};return t&&(r=We()(o.publishedAt)?{status:"draft"}:{status:"published"}),{hasDraftAndPublish:t,trackerProperty:r}}var ju=Wu;const da=({onDelete:t,trackerProperty:o})=>{const[r,a]=(0,e.useState)(!1),[s,l]=(0,e.useState)(!1),{formatMessage:c}=(0,H.Z)(),{formatAPIError:d}=(0,f.So)(y.OB),p=(0,f.lm)(),m=()=>a(h=>!h),u=async()=>{try{l(!0),await t(o),l(!1),m()}catch(h){l(!1),m(),p({type:"warning",message:d(h)})}};return e.createElement(e.Fragment,null,e.createElement(ue.z,{onClick:m,size:"S",startIcon:e.createElement(Xe.Z,null),variant:"danger-light"},c({id:(0,y.OB)("containers.Edit.delete-entry"),defaultMessage:"Delete this entry"})),e.createElement(f.QH,{isConfirmButtonLoading:s,isOpen:r,onConfirm:u,onToggleDialog:m}))};da.propTypes={onDelete:n().func.isRequired,trackerProperty:n().object.isRequired};const zu=(0,e.memo)(da,Fe());var Vu=Nu(zu,ju),Uu=i(56243);function qu(t,o){return r=>{const a=o();return e.createElement(t,{...r,...a})}}var Hu=qu;function Gu(){const{initialData:t,hasDraftAndPublish:o}=(0,f.Wq)(),r=t.publishedAt!==void 0&&t.publishedAt!==null;return{hasDraftAndPublish:o,isPublished:r}}var Qu=Gu;const Ku=(0,U.ZP)(Uu.Z)`
|
|
948
|
+
width: ${(0,f.Q1)(6)};
|
|
949
|
+
height: ${(0,f.Q1)(6)};
|
|
950
|
+
* {
|
|
951
|
+
fill: ${({theme:t,$bulletColor:o})=>t.colors[o]};
|
|
952
|
+
}
|
|
953
|
+
`,ua=({hasDraftAndPublish:t,isPublished:o})=>{const{formatMessage:r}=(0,H.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(Q.x,{hasRadius:!0,as:"aside",paddingTop:4,paddingBottom:4,paddingLeft:5,paddingRight:5,...s.box},e.createElement(Q.x,{as:D.k},e.createElement(Ku,{$bulletColor:s.bulletColor}),e.createElement(Q.x,{paddingLeft:3},e.createElement(W.Z,{textColor:s.textColor},r({id:(0,y.OB)("containers.Edit.information.editing"),defaultMessage:"Editing"}),"\xA0"),e.createElement(W.Z,{fontWeight:"bold",textColor:s.textColor},o&&r({id:(0,y.OB)("containers.Edit.information.publishedVersion"),defaultMessage:"published version"}),!o&&r({id:(0,y.OB)("containers.Edit.information.draftVersion"),defaultMessage:"draft version"})))))};ua.propTypes={hasDraftAndPublish:n().bool.isRequired,isPublished:n().bool.isRequired};var Yu=Hu(ua,Qu);const Lo=({columns:t,customFieldInputs:o})=>e.createElement(Se.r,{gap:4},t.map(({fieldSchema:r,labelAction:a,metadatas:s,name:l,size:c,queryInfos:d})=>{if(r.type==="component"){const{component:m,max:u,min:h,repeatable:E=!1,required:g=!1}=r;return e.createElement(ve.P,{col:c,s:12,xs:12,key:m},e.createElement(Gt,{componentUid:m,labelAction:a,isRepeatable:E,intlLabel:{id:s.label,defaultMessage:s.label},max:u,min:h,name:l,required:g}))}return e.createElement(ve.P,{col:c,key:l,s:12,xs:12},e.createElement(vo,{size:c,fieldSchema:r,keys:l,labelAction:a,metadatas:s,queryInfos:d,customFieldInputs:o}))}));Lo.defaultProps={customFieldInputs:{}},Lo.propTypes={columns:n().array.isRequired,customFieldInputs:n().object};var Xu=Lo,Kt=i(22342),Yt=i(96166),Xt=i(88693);function Ju(t,o){return r=>{const a=o();return e.createElement(t,{...r,...a})}}var _u=Ju;function em(){const{initialData:t,isCreatingEntry:o,isSingleType:r,status:a,layout:s,hasDraftAndPublish:l,modifiedData:c,onPublish:d,onUnpublish:p,publishConfirmation:m,onPublishPromptDismissal:u}=(0,f.Wq)();return{initialData:t,isCreatingEntry:o,isSingleType:r,status:a,layout:s,hasDraftAndPublish:l,modifiedData:c,onPublish:d,onUnpublish:p,publishConfirmation:m,onPublishPromptDismissal:u}}var tm=em;const ma=(0,U.ZP)(D.k)`
|
|
954
|
+
text-align: center;
|
|
955
|
+
`,pa=({allowedActions:{canUpdate:t,canCreate:o,canPublish:r},initialData:a,isCreatingEntry:s,isSingleType:l,hasDraftAndPublish:c,layout:d,modifiedData:p,onPublish:m,onUnpublish:u,status:h,publishConfirmation:{show:E,draftCount:g},onPublishPromptDismissal:b})=>{const{goBack:C}=(0,le.k6)(),[L,v]=(0,e.useState)(!1),{formatMessage:R}=(0,H.Z)(),x=w()(d,["settings","mainField"],"id"),V=w()(d,["info","displayName"],"NOT FOUND"),M=!Fe()(a,p)||s&&!We()(p);let j=R({id:(0,y.OB)("containers.Edit.pluginHeader.title.new"),defaultMessage:"Create an entry"});!s&&!l&&(j=a[x]||V),l&&(j=V);let $=null;if(s&&o&&($=e.createElement(D.k,{gap:2},c&&e.createElement(ue.z,{disabled:!0,startIcon:e.createElement(we.Z,null),variant:"secondary"},R({id:"app.utils.publish",defaultMessage:"Publish"})),e.createElement(ue.z,{disabled:!M,loading:h==="submit-pending",type:"submit"},R({id:(0,y.OB)("containers.Edit.submit"),defaultMessage:"Save"})))),!s&&t){const T=c&&r,X=!We()(a.publishedAt),G=X?h==="unpublish-pending":h==="publish-pending",J=X?{id:"app.utils.unpublish",defaultMessage:"Unpublish"}:{id:"app.utils.publish",defaultMessage:"Publish"},F=X?()=>v(!0):()=>m();$=e.createElement(D.k,null,T&&e.createElement(ue.z,{disabled:M,loading:G,onClick:F,startIcon:e.createElement(we.Z,null),variant:"secondary"},R(J)),e.createElement(Q.x,{paddingLeft:T?2:0},e.createElement(ue.z,{disabled:!M,loading:h==="submit-pending",type:"submit"},R({id:(0,y.OB)("containers.Edit.submit"),defaultMessage:"Save"}))))}const P=()=>v(T=>!T),N=()=>{P(),u()},Y=`${R({id:(0,y.OB)("api.id"),defaultMessage:"API ID "})} : ${d.apiID}`;return e.createElement(e.Fragment,null,e.createElement(Oe.T,{title:j.toString(),primaryAction:$,subtitle:Y,navigationAction:e.createElement(f.rU,{startIcon:e.createElement(dt.Z,null),onClick:T=>{T.preventDefault(),C()},to:"/"},R({id:"global.back",defaultMessage:"Back"}))}),e.createElement(Kt.V,{onClose:P,title:"Confirmation",labelledBy:"confirmation",describedBy:"confirm-description",isOpen:L},e.createElement(Yt.a,{icon:e.createElement(At.Z,null)},e.createElement(D.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(D.k,{justifyContent:"center",style:{textAlign:"center"}},e.createElement(W.Z,{id:"confirm-description"},R({id:(0,y.OB)("popUpWarning.warning.unpublish"),defaultMessage:"Unpublish this content will automatically change it to a draft."},{br:()=>e.createElement("br",null)}))),e.createElement(D.k,{justifyContent:"center",style:{textAlign:"center"}},e.createElement(W.Z,{id:"confirm-description"},R({id:(0,y.OB)("popUpWarning.warning.unpublish-question"),defaultMessage:"Are you sure you want to unpublish it?"}))))),e.createElement(Xt.c,{startAction:e.createElement(ue.z,{onClick:P,variant:"tertiary"},R({id:"components.popUpWarning.button.cancel",defaultMessage:"Cancel"})),endAction:e.createElement(ue.z,{variant:"danger-light",onClick:N},R({id:"components.popUpWarning.button.confirm",defaultMessage:"Confirm"}))})),e.createElement(Kt.V,{onClose:b,title:R({id:(0,y.OB)("popUpWarning.warning.has-draft-relations.title"),defaultMessage:"Confirmation"}),labelledBy:"confirmation",describedBy:"confirm-description",isOpen:E},e.createElement(Yt.a,{icon:e.createElement(At.Z,null)},e.createElement(D.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(ma,{justifyContent:"center"},e.createElement(W.Z,{id:"confirm-description"},g,R({id:(0,y.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:T=>e.createElement(W.Z,{fontWeight:"bold"},T),count:g}))),e.createElement(ma,{justifyContent:"center"},e.createElement(W.Z,{id:"confirm-description"},R({id:(0,y.OB)("popUpWarning.warning.publish-question"),defaultMessage:"Do you still want to publish?"}))))),e.createElement(Xt.c,{startAction:e.createElement(ue.z,{onClick:b,variant:"tertiary"},R({id:"components.popUpWarning.button.cancel",defaultMessage:"Cancel"})),endAction:e.createElement(ue.z,{variant:"success",onClick:m},R({id:(0,y.OB)("popUpwarning.warning.has-draft-relations.button-confirm"),defaultMessage:"Publish"}))})))};pa.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 nm=(0,e.memo)(pa,Fe());var om=_u(nm,tm);const rm=t=>(0,e.useEffect)(t,am),am=[];var ko=i(98865);function sm(){return e.createElement(ko.d.Root,null,e.createElement(ko.d.Title,null),e.createElement(ko.d.Body,null))}var Ao=i(98178),im=t=>{if(!t.layouts)return[];const o=t.layouts.edit,r=t.attributes,a=c=>w()(r,[c,"type"],"");let s=0;const l=[];return o.forEach(c=>{const d=c.some(({name:p})=>a(p)==="dynamiczone");l[s]||(l[s]=[]),d?(s=s===0&&We()(l[0])?0:s+1,l[s]||(l[s]=[]),l[s].push(c),s+=1):l[s].push(c)}),l.filter(c=>c.length>0)},lm=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)]},cm=i(3704),dm=i.n(cm),um=i(91815),mm=i.n(um),pm=(t,o)=>{const r=a=>{const s=(0,f.ZT)(t,[{action:`plugin::content-manager.explorer.${a}`,subject:o}]);return mm()(dm()(s,"properties.fields"))};return{createActionAllowedFields:r("create"),readActionAllowedFields:r("read"),updateActionAllowedFields:r("update")}};const Fo=t=>t["content-manager_editViewLayoutManager"].currentLayout,gm=(0,Ao.P1)(Fo,t=>im(t?.contentType??{})),fm=(0,Ao.P1)(Fo,t=>lm(t)),hm=[{action:"plugin::content-type-builder.read",subject:null}],$o=({allowedActions:t,isSingleType:o,goBack:r,slug:a,id:s,origin:l,userPermissions:c})=>{const{trackUsage:d}=(0,f.rS)(),{formatMessage:p}=(0,H.Z)(),m=(0,re.v9)(Pe._),u=(0,le.TH)(),h=(0,f.lm)(),E=(0,xt.c)(sm,async()=>(await i.e(4724).then(i.bind(i,91130))).InformationBoxEE);rm(()=>{u?.state&&"error"in u.state&&h({type:"warning",message:u.state.error,timeout:5e3})});const{layout:g,formattedContentTypeLayout:b,customFieldUids:C}=(0,re.v9)(P=>({layout:Fo(P),formattedContentTypeLayout:gm(P),customFieldUids:fm(P)})),{isLazyLoading:L,lazyComponentStore:v}=Kn(C),{createActionAllowedFields:R,readActionAllowedFields:x,updateActionAllowedFields:V}=pm(c,a),M=o?m.contentManager.singleTypesConfigurations:m.contentManager.collectionTypesConfigurations,O=`/content-manager/${o?"singleType":"collectionType"}/${a}/configurations/edit`,j=o?Bu:ec,$=P=>P.every(N=>N.every(Y=>Y.fieldSchema.type==="dynamiczone"));return L?e.createElement(f.dO,null):E?e.createElement(j,{allLayoutData:g,slug:a,id:s,origin:l},({componentsDataStructure:P,contentTypeDataStructure:N,data:Y,isCreatingEntry:T,isLoadingForData:X,onDelete:G,onPost:J,onPublish:F,onDraftRelationCheck:S,onPut:I,onUnpublish:A,redirectionLink:q,status:K})=>e.createElement(Fu,{allowedActions:t,allLayoutData:g,createActionAllowedFields:R,componentsDataStructure:P,contentTypeDataStructure:N,from:q,initialValues:Y,isCreatingEntry:T,isLoadingForData:X,isSingleType:o,onPost:J,onPublish:F,onDraftRelationCheck:S,onPut:I,onUnpublish:A,readActionAllowedFields:x,redirectToPreviousPage:r,slug:a,status:K,updateActionAllowedFields:V},e.createElement(Te.o,{"aria-busy":K!=="resolved"},e.createElement(om,{allowedActions:t}),e.createElement(tt.D,null,e.createElement(Se.r,{gap:4},e.createElement(ve.P,{col:9,s:12},e.createElement(D.k,{direction:"column",alignItems:"stretch",gap:6},b.map((k,z)=>{if($(k)){const{0:{0:{name:ne,fieldSchema:ce,metadatas:he,labelAction:fe}}}=k;return e.createElement(Q.x,{key:z},e.createElement(Se.r,{gap:4},e.createElement(ve.P,{col:12,s:12,xs:12},e.createElement(So,{name:ne,fieldSchema:ce,labelAction:fe,metadatas:he}))))}return e.createElement(Q.x,{key:z,hasRadius:!0,background:"neutral0",shadow:"tableShadow",paddingLeft:6,paddingRight:6,paddingTop:6,paddingBottom:6,borderColor:"neutral150"},e.createElement(D.k,{direction:"column",alignItems:"stretch",gap:6},k.map((ne,ce)=>e.createElement(Xu,{columns:ne,customFieldInputs:v,key:ce}))))}))),e.createElement(ve.P,{col:3,s:12},e.createElement(D.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(Yu,null),e.createElement(Q.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(E,null),e.createElement(zt,{area:"contentManager.editView.informations"})),e.createElement(Q.x,{as:"aside","aria-labelledby":"links"},e.createElement(D.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(zt,{area:"contentManager.editView.right-links",slug:a}),a!=="strapi::administrator"&&e.createElement(f.jW,{permissions:hm},e.createElement(f.Qj,{onClick:()=>{d("willEditEditLayout")},size:"S",startIcon:e.createElement(nt.Z,null),style:{width:"100%"},to:`/plugins/content-type-builder/content-types/${a}`,variant:"secondary"},p({id:(0,y.OB)("link-to-ctb"),defaultMessage:"Edit the model"}))),e.createElement(f.jW,{permissions:M},e.createElement(f.Qj,{size:"S",startIcon:e.createElement(fn.Z,null),style:{width:"100%"},to:O,variant:"secondary"},p({id:"app.links.configure-view",defaultMessage:"Configure the view"}))),t.canDelete&&!T&&e.createElement(Vu,{onDelete:G})))))))))):null};$o.defaultProps={id:null,isSingleType:!1,origin:null,userPermissions:[]},$o.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 Em=$o;const Bo=t=>{const o=(0,e.useMemo)(()=>(0,y.TA)(t.slug),[t.slug]),{isLoading:r,allowedActions:a}=(0,f.ss)(o,t.userPermissions);return r?e.createElement(f.dO,null):e.createElement(Em,{...t,allowedActions:a})};Bo.defaultProps={permissions:[]},Bo.propTypes={permissions:n().array,slug:n().string.isRequired,userPermissions:n().array.isRequired};var ym=(0,e.memo)(Bo,Fe()),bm=i(53634);const ga=({layout:t,...o})=>{const r=(0,re.v9)(bm.Z),a=(0,re.I0)(),[{query:s}]=(0,f.Kx)(),{runHookWaterfall:l}=(0,f.j1)(),{permissions:c,isValid:d}=(0,be.r5)(s,o.slug,"editView");return(0,e.useEffect)(()=>{const p=l(jt.Eo,{layout:t,query:s});return a(Yl(p.layout,s)),()=>{a(Kl())}},[t,a,s,l]),!r||!d?e.createElement(f.dO,null):e.createElement(ym,{...o,userPermissions:c})};ga.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 Jt=ga,_t=i(33348);const vm=(0,U.ZP)(D.k)`
|
|
956
|
+
svg {
|
|
957
|
+
width: ${32/16}rem;
|
|
958
|
+
height: ${24/16}rem;
|
|
959
|
+
margin-right: ${({theme:t})=>t.spaces[3]};
|
|
960
|
+
}
|
|
961
|
+
`,fa=({attributes:t,fieldForm:o,fieldToEdit:r,onCloseModal:a,onChangeEditLabel:s,onSubmit:l,type:c})=>{const{formatMessage:d}=(0,H.Z)(),p=t[r].relationType;let m=!["media","relation"].includes(c);return["oneWay","oneToOne","manyToOne"].includes(p)&&(m=!0),e.createElement(vn.P,{onClose:a,labelledBy:"title"},e.createElement("form",{onSubmit:l},e.createElement(Cn.x,null,e.createElement(vm,null,e.createElement(Tr,{type:c}),e.createElement(W.Z,{fontWeight:"bold",textColor:"neutral800",as:"h2",id:"title"},d({id:(0,y.OB)("containers.ListSettingsView.modal-form.edit-label"),defaultMessage:"Edit {fieldName}"},{fieldName:Dt()(r)})))),e.createElement(Rn.f,null,e.createElement(Se.r,{gap:4},e.createElement(ve.P,{s:12,col:6},e.createElement(In.o,{id:"label-input",label:d({id:(0,y.OB)("form.Input.label"),defaultMessage:"Label"}),name:"label",onChange:u=>s(u),value:o.label,hint:d({id:(0,y.OB)("form.Input.label.inputDescription"),defaultMessage:"This value overrides the label displayed in the table's head"})})),m&&e.createElement(ve.P,{s:12,col:6},e.createElement(Zt.s,{"data-testid":"Enable sort on this field",checked:o.sortable,label:d({id:(0,y.OB)("form.Input.sort.field"),defaultMessage:"Enable sort on this field"}),name:"sortable",onChange:u=>s({target:{name:"sortable",value:u.target.checked}}),onLabel:d({id:"app.components.ToggleCheckbox.on-label",defaultMessage:"on"}),offLabel:d({id:"app.components.ToggleCheckbox.off-label",defaultMessage:"off"})})))),e.createElement(Mn.m,{startActions:e.createElement(ue.z,{onClick:a,variant:"tertiary"},d({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endActions:e.createElement(ue.z,{type:"submit"},d({id:"global.finish",defaultMessage:"Finish"}))})))};fa.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};const wo=({contentTypeOptions:t,modifiedData:o,onChange:r,sortOptions:a})=>{const{formatMessage:s,locale:l}=(0,H.Z)(),c=(0,f.Xe)(l,{sensitivity:"base"}),p=(0,xt.c)(a,async()=>(await i.e(78).then(i.bind(i,10078))).REVIEW_WORKFLOW_STAGE_SORT_OPTION_NAME,{combine(u,h){return[...u,{...h,label:s(h.label)}]},defaultValue:a,enabled:!!t?.reviewWorkflows}).sort((u,h)=>c.compare(u.label,h.label)),{settings:m}=o;return e.createElement(D.k,{direction:"column",alignItems:"stretch",gap:4},e.createElement(W.Z,{variant:"delta",as:"h2"},s({id:(0,y.OB)("containers.SettingPage.settings"),defaultMessage:"Settings"})),e.createElement(D.k,{justifyContent:"space-between",gap:4},e.createElement(Q.x,{width:"100%"},e.createElement(Zt.s,{label:s({id:(0,y.OB)("form.Input.search"),defaultMessage:"Enable search"}),onChange:u=>{r({target:{name:"settings.searchable",value:u.target.checked}})},onLabel:s({id:"app.components.ToggleCheckbox.on-label",defaultMessage:"on"}),offLabel:s({id:"app.components.ToggleCheckbox.off-label",defaultMessage:"off"}),name:"settings.searchable",checked:m.searchable})),e.createElement(Q.x,{width:"100%"},e.createElement(Zt.s,{label:s({id:(0,y.OB)("form.Input.filters"),defaultMessage:"Enable filters"}),onChange:u=>{r({target:{name:"settings.filterable",value:u.target.checked}})},onLabel:s({id:"app.components.ToggleCheckbox.on-label",defaultMessage:"on"}),offLabel:s({id:"app.components.ToggleCheckbox.off-label",defaultMessage:"off"}),name:"settings.filterable",checked:m.filterable})),e.createElement(Q.x,{width:"100%"},e.createElement(Zt.s,{label:s({id:(0,y.OB)("form.Input.bulkActions"),defaultMessage:"Enable bulk actions"}),onChange:u=>{r({target:{name:"settings.bulkable",value:u.target.checked}})},onLabel:s({id:"app.components.ToggleCheckbox.on-label",defaultMessage:"on"}),offLabel:s({id:"app.components.ToggleCheckbox.off-label",defaultMessage:"off"}),name:"settings.bulkable",checked:m.bulkable}))),e.createElement(Se.r,{gap:4},e.createElement(ve.P,{s:12,col:6},e.createElement(Ue.P,{label:s({id:(0,y.OB)("form.Input.pageEntries"),defaultMessage:"Entries per page"}),hint:s({id:(0,y.OB)("form.Input.pageEntries.inputDescription"),defaultMessage:"Note: You can override this value in the Collection Type settings page."}),onChange:u=>r({target:{name:"settings.pageSize",value:u}}),name:"settings.pageSize",value:o.settings.pageSize||""},[10,20,50,100].map(u=>e.createElement(Re.W,{key:u,value:u},u)))),e.createElement(ve.P,{s:12,col:3},e.createElement(Ue.P,{label:s({id:(0,y.OB)("form.Input.defaultSort"),defaultMessage:"Default sort attribute"}),onChange:u=>r({target:{name:"settings.defaultSortBy",value:u}}),name:"settings.defaultSortBy",value:o.settings.defaultSortBy||""},p.map(({value:u,label:h})=>e.createElement(Re.W,{key:u,value:u},h)))),e.createElement(ve.P,{s:12,col:3},e.createElement(Ue.P,{label:s({id:(0,y.OB)("form.Input.sort.order"),defaultMessage:"Default sort order"}),onChange:u=>r({target:{name:"settings.defaultSortOrder",value:u}}),name:"settings.defaultSortOrder",value:o.settings.defaultSortOrder||""},["ASC","DESC"].map(u=>e.createElement(Re.W,{key:u,value:u},u))))))};wo.defaultProps={modifiedData:{},sortOptions:[]},wo.propTypes={contentTypeOptions:n().object.isRequired,modifiedData:n().object,onChange:n().func.isRequired,sortOptions:n().arrayOf(n().shape({value:n().string,label:n().string}).isRequired)};const No=(0,U.ZP)(D.k)`
|
|
962
|
+
height: ${({theme:t})=>t.spaces[7]};
|
|
963
|
+
|
|
964
|
+
&:last-child {
|
|
965
|
+
padding: 0 ${({theme:t})=>t.spaces[3]};
|
|
966
|
+
}
|
|
967
|
+
`,Cm=(0,U.ZP)(No)`
|
|
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
|
+
`,Rm=(0,U.ZP)(D.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
|
+
`,Mm=(0,U.ZP)(W.Z)`
|
|
988
|
+
max-width: ${72/16}rem;
|
|
989
|
+
`;function $t({labelField:t,transparent:o,isSibling:r}){return e.createElement(Rm,{background:r?"neutral100":"primary100",display:"inline-flex",gap:3,hasRadius:!0,justifyContent:"space-between",transparent:o,isSibling:r,"max-height":(0,f.Q1)(32),maxWidth:"min-content",opacity:o?0:1},e.createElement(D.k,{gap:3},e.createElement(Cm,{alignItems:"center",cursor:"all-scroll",padding:3},e.createElement(ot.Z,null)),e.createElement(Mm,{textColor:r?void 0:"primary600",fontWeight:"bold",ellipsis:!0},t)),e.createElement(D.k,null,e.createElement(No,{alignItems:"center"},e.createElement(nt.Z,null)),e.createElement(No,{alignItems:"center"},e.createElement(Ut.Z,null))))}$t.defaultProps={isSibling:!1,transparent:!1},$t.propTypes={isSibling:n().bool,labelField:n().string.isRequired,transparent:n().bool};const Wo=U.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
|
+
`,ha=(0,U.ZP)(Wo)`
|
|
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
|
+
`,Tm=(0,U.ZP)(D.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
|
+
${ha} {
|
|
1034
|
+
border-right: 1px solid ${({theme:t})=>t.colors.primary200};
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
`,Dm=(0,U.ZP)(Q.x)`
|
|
1038
|
+
&:last-child {
|
|
1039
|
+
padding-right: ${({theme:t})=>t.spaces[3]};
|
|
1040
|
+
}
|
|
1041
|
+
`,Ea=({index:t,isDraggingSibling:o,labelField:r,onClickEditField:a,onMoveField:s,onRemoveField:l,name:c,setIsDraggingSibling:d})=>{const{formatMessage:p}=(0,H.Z)(),m=(0,e.useRef)(null),u=(0,e.useRef)(null),[,h]=(0,e.useState)(!1),E=(0,e.useRef)(),g=()=>{E.current&&E.current.click()},[,b]=(0,Nt.useDrop)({accept:y._Q.FIELD,hover(x,V){if(!u.current)return;const M=x.index,O=t;if(M===O)return;const j=u.current.getBoundingClientRect(),$=(j.right-j.left)/2,N=V.getClientOffset().x-j.left;M>O&&N>$||M<O&&N<$||(s(M,O),x.index=O)}}),[{isDragging:C},L,v]=(0,Nt.useDrag)({type:y._Q.FIELD,item(){return{index:t,labelField:r,name:c}},collect:x=>({isDragging:x.isDragging()}),end(){d(!1)}});(0,e.useEffect)(()=>{v((0,Ot.rX)(),{captureDraggingState:!1})},[v]),(0,e.useEffect)(()=>{C&&d(!0)},[C,d]),(0,e.useEffect)(()=>{o||h(x=>!x)},[o]);const R={dragRef:L(m),dropRef:b(u)};return e.createElement(Dm,{ref:R?R.dropRef:null},C&&e.createElement($t,{transparent:!0,labelField:r}),!C&&o&&e.createElement($t,{isSibling:!0,labelField:r}),!C&&!o&&e.createElement(Tm,{borderColor:"neutral150",background:"neutral100",hasRadius:!0,justifyContent:"space-between",onClick:g,isDragging:C},e.createElement(D.k,{gap:3},e.createElement(ha,{as:"span","aria-label":p({id:(0,y.OB)("components.DraggableCard.move.field"),defaultMessage:"Move {item}"},{item:r}),onClick:x=>x.stopPropagation(),ref:R.dragRef,type:"button"},e.createElement(ot.Z,null)),e.createElement(W.Z,{fontWeight:"bold"},r)),e.createElement(D.k,{paddingLeft:3},e.createElement(Wo,{ref:E,onClick:x=>{x.stopPropagation(),a(c)},"aria-label":p({id:(0,y.OB)("components.DraggableCard.edit.field"),defaultMessage:"Edit {item}"},{item:r}),type:"button"},e.createElement(nt.Z,null)),e.createElement(Wo,{onClick:l,"data-testid":`delete-${c}`,"aria-label":p({id:(0,y.OB)("components.DraggableCard.delete.field"),defaultMessage:"Delete {item}"},{item:r}),type:"button"},e.createElement(Ut.Z,null)))))};Ea.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 Om=Ea;const ya=({displayedFields:t,listRemainingFields:o,metadatas:r,onAddField:a,onClickEditField:s,onMoveField:l,onRemoveField:c})=>{const{formatMessage:d}=(0,H.Z)(),[p,m]=(0,e.useState)(!1),[u,h]=(0,e.useState)(null),E=(0,e.useRef)();function g(...C){h("add"),a(...C)}function b(...C){h("remove"),c(...C)}return(0,e.useEffect)(()=>{u==="add"&&E?.current&&(E.current.scrollLeft=E.current.scrollWidth)},[t,u]),e.createElement(D.k,{alignItems:"stretch",direction:"column",gap:4},e.createElement(W.Z,{variant:"delta",as:"h2"},d({id:(0,y.OB)("containers.SettingPage.view"),defaultMessage:"View"})),e.createElement(D.k,{padding:4,borderColor:"neutral300",borderStyle:"dashed",borderWidth:"1px",hasRadius:!0},e.createElement(Q.x,{flex:"1",overflow:"scroll hidden",ref:E},e.createElement(D.k,{gap:3},t.map((C,L)=>e.createElement(Om,{key:C,index:L,isDraggingSibling:p,onMoveField:l,onClickEditField:s,onRemoveField:v=>b(v,L),name:C,labelField:r[C].list.label||C,setIsDraggingSibling:m})))),e.createElement(ge.fC,null,e.createElement(ge.xz,{paddingLeft:2,paddingRight:2,justifyContent:"center",endIcon:null,disabled:o.length<=0,variant:"tertiary"},e.createElement(st.T,{as:"span"},d({id:(0,y.OB)("components.FieldSelect.label"),defaultMessage:"Add a field"})),e.createElement(ft.Z,{"aria-hidden":!0,focusable:!1,style:{position:"relative",top:2}})),e.createElement(ge.VY,null,o.map(C=>e.createElement(ge.ck,{key:C,onSelect:()=>g(C)},r[C].list.label||C))))))};ya.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};const Im=["media","richtext","dynamiczone","relation","component","json"],jo={fieldForm:{},fieldToEdit:"",initialData:{},modifiedData:{}};var Pm=(t=jo,o)=>(0,xn.ZP)(t,r=>{const a=["modifiedData","layouts","list"];switch(o.type){case"ADD_FIELD":{const s=w()(t,a,[]);ae()(r,a,[...s,o.item]);break}case"MOVE_FIELD":{const s=w()(t,a,[]),{originalIndex:l,atIndex:c}=o;ae()(r,a,(0,y.W3)(s,l,c));break}case"ON_CHANGE":{ae()(r,["modifiedData",...o.keys.split(".")],o.value);break}case"ON_CHANGE_FIELD_METAS":{ae()(r,["fieldForm",o.name],o.value);break}case"REMOVE_FIELD":{const s=w()(t,a,[]);ae()(r,a,s.filter((l,c)=>o.index!==c));break}case"SET_FIELD_TO_EDIT":{const{fieldToEdit:s}=o;r.fieldToEdit=s,r.fieldForm.label=w()(r,["modifiedData","metadatas",s,"list","label"],""),r.fieldForm.sortable=w()(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"];ae()(r,[...s,"label"],t.fieldForm.label),ae()(r,[...s,"sortable"],t.fieldForm.sortable);break}default:return r}});const ba=({layout:t,slug:o})=>{const{put:r}=(0,f.kY)(),{formatMessage:a}=(0,H.Z)(),{trackUsage:s}=(0,f.rS)(),l=(0,be.fi)(),c=(0,f.lm)(),{refetchData:d}=(0,e.useContext)(Tt),[p,m]=(0,e.useState)(!1),u=()=>m(A=>!A),[{fieldToEdit:h,fieldForm:E,initialData:g,modifiedData:b},C]=(0,e.useReducer)(Pm,jo,()=>({...jo,initialData:t,modifiedData:t})),L=Object.keys(E).length!==0,{attributes:v,options:R}=t,x=b.layouts.list,V=()=>{const{settings:{pageSize:A,defaultSortBy:q,defaultSortOrder:K},kind:k,uid:z}=g,ne=`${q}:${K}`,ce=`${(0,_t.stringify)({page:1,pageSize:A,sort:ne},{encode:!1})}${l?`&${l}`:""}`;return`/content-manager/${k}/${z}?${ce}`},M=({target:{name:A,value:q}})=>{C({type:"ON_CHANGE",keys:A,value:A==="settings.pageSize"?parseInt(q,10):q})},{isLoading:O,mutate:j}=(0,Ne.useMutation)(A=>r(`/content-manager/content-types/${o}/configuration`,A),{onSuccess(){s("didEditListSettings"),d()},onError(){c({type:"warning",message:{id:"notification.error"}})}}),$=async()=>{const{layouts:A,settings:q,metadatas:K}=b;j({layouts:A,settings:q,metadatas:K})},P=A=>{C({type:"ADD_FIELD",item:A})},N=(A,q)=>{A.stopPropagation(),x.length===1?c({type:"info",message:{id:(0,y.OB)("notification.info.minimumFields")}}):C({type:"REMOVE_FIELD",index:q})},Y=A=>{A.preventDefault(),u(),s("willSaveContentTypeLayout")},T=A=>{C({type:"SET_FIELD_TO_EDIT",fieldToEdit:A})},X=()=>{C({type:"UNSET_FIELD_TO_EDIT"})},G=A=>{A.preventDefault(),C({type:"SUBMIT_FIELD_FORM"}),X()},J=({target:{name:A,value:q}})=>{C({type:"ON_CHANGE_FIELD_METAS",name:A,value:q})},F=Object.entries(v).filter(([A,q])=>(0,y.ko)(q)&&!x.includes(A)).map(([A])=>A).sort(),S=Object.entries(v).filter(([,A])=>!Im.includes(A.type)).map(([A])=>({value:A,label:t.metadatas[A].list.label})),I=(A,q)=>{C({type:"MOVE_FIELD",originalIndex:A,atIndex:q})};return e.createElement(Ge.A,null,e.createElement(Te.o,{"aria-busy":O},e.createElement("form",{onSubmit:Y},e.createElement(Oe.T,{navigationAction:e.createElement(f.rU,{startIcon:e.createElement(dt.Z,null),to:V,id:"go-back"},a({id:"global.back",defaultMessage:"Back"})),primaryAction:e.createElement(ue.z,{size:"S",startIcon:e.createElement(we.Z,null),disabled:Fe()(b,g),type:"submit"},a({id:"global.save",defaultMessage:"Save"})),subtitle:a({id:(0,y.OB)("components.SettingsViewWrapper.pluginHeader.description.list-settings"),defaultMessage:"Define the settings of the list view."}),title:a({id:(0,y.OB)("components.SettingsViewWrapper.pluginHeader.title"),defaultMessage:"Configure the view - {name}"},{name:Dt()(b.info.displayName)})}),e.createElement(tt.D,null,e.createElement(D.k,{alignItems:"stretch",background:"neutral0",direction:"column",gap:6,hasRadius:!0,shadow:"tableShadow",paddingTop:6,paddingBottom:6,paddingLeft:7,paddingRight:7},e.createElement(wo,{contentTypeOptions:R,modifiedData:b,onChange:M,sortOptions:S}),e.createElement(cn.i,null),e.createElement(ya,{listRemainingFields:F,displayedFields:x,onAddField:P,onClickEditField:T,onMoveField:I,onRemoveField:N,metadatas:b.metadatas}))),e.createElement(f.QH,{bodyText:{id:(0,y.OB)("popUpWarning.warning.updateAllSettings"),defaultMessage:"This will modify all your settings"},iconRightButton:e.createElement(we.Z,null),isConfirmButtonLoading:O,isOpen:p,onToggleDialog:u,onConfirm:$,variantRightButton:"success-light"})),L&&e.createElement(fa,{attributes:v,fieldForm:E,fieldToEdit:h,onChangeEditLabel:J,onCloseModal:X,onSubmit:G,type:v?.[h]?.type??"text"})))};ba.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 Sm=ba,vt=i(93088);const Zm=()=>({type:vt.ZA}),xm=(t,o)=>({type:vt.Id,pagination:t,data:o}),va=()=>({type:vt.MP});function Lm(){return{type:vt.c2}}const km=({components:t,contentType:o})=>{const{layouts:r}=o;return{contentType:o,components:t,displayedHeaders:r.list,type:vt.Zz}},Ca=t=>({type:vt.Rp,target:t});var zo=i(94638),Ra=i(99223),Ma=i(94547),$e=i(19786),Am=i(12301),Fm=i(59177),Ta=i(6680),Da=i(97108);const Oa=({displayedFilters:t})=>{const[o,r]=(0,e.useState)(!1),{formatMessage:a}=(0,H.Z)(),s=(0,e.useRef)(),{trackUsage:l}=(0,f.rS)(),c=()=>{o||l("willFilterEntries"),r(d=>!d)};return e.createElement(e.Fragment,null,e.createElement(Q.x,{paddingTop:1,paddingBottom:1},e.createElement(ue.z,{variant:"tertiary",ref:s,startIcon:e.createElement(ur.Z,null),onClick:c,size:"S"},a({id:"app.utils.filters",defaultMessage:"Filters"})),o&&e.createElement(f.J5,{displayedFilters:t,isVisible:o,onToggle:c,source:s})),e.createElement(f.W$,{filtersSchema:t}))};Oa.propTypes={displayedFilters:n().arrayOf(n().shape({name:n().string.isRequired,metadatas:n().shape({label:n().string}),fieldSchema:n().shape({type:n().string})})).isRequired};const Vo=({value:t,onChange:o})=>{const{formatMessage:r}=(0,H.Z)(),{users:a,isLoading:s}=(0,Da.R)();return e.createElement(Wr.hQ,{value:t,"aria-label":r({id:"content-manager.components.Filters.usersSelect.label",defaultMessage:"Search and select an user to filter"}),onChange:o,loading:s},a.map(l=>e.createElement(no.O,{key:l.id,value:l.id.toString()},(0,y.Gf)(l,r))))};Vo.propTypes={onChange:n().func.isRequired,value:n().string},Vo.defaultProps={value:""};const $m=["json","component","media","richtext","dynamiczone","password"],Bm=["createdAt","updatedAt"],wm=["createdBy","updatedBy"],Nm=(t,o)=>{const{allPermissions:r}=(0,f.vn)(),a=(0,f.ZT)(r,[{action:"plugin::content-manager.explorer.read",subject:o}]),s=(0,f.ZT)(r,[{action:"admin::users.read",subject:null}]).length>0;return["id",...(a?.[0]?.properties?.fields??[]).filter(d=>{const p=t?.attributes?.[d]??{};return!(!p.type||$m.includes(p.type))}),...Bm,...s?wm:[]]};var Ia=i(82884),Wm=i(47765);const Pa=({area:t,...o})=>{const r=Sr(t);return r?e.createElement("ul",null,r.map(a=>a.Component(o)?e.createElement(Q.x,{key:a.name,padding:3,style:{textAlign:"center"}},e.createElement(a.Component,{...o})):null)):null};Pa.propTypes={area:n().string.isRequired};var en=Pa;const Sa=({isConfirmButtonLoading:t,isOpen:o,onToggleDialog:r,onConfirm:a})=>{const{formatMessage:s}=(0,H.Z)();return e.createElement(Kt.V,{onClose:r,title:s({id:"app.components.ConfirmDialog.title",defaultMessage:"Confirmation"}),labelledBy:"confirmation",describedBy:"confirm-description",isOpen:o},e.createElement(Yt.a,{icon:e.createElement(At.Z,null)},e.createElement(D.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(D.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(D.k,null,e.createElement(en,{area:"contentManager.listView.deleteModalAdditionalInfos"})))),e.createElement(Xt.c,{startAction:e.createElement(ue.z,{onClick:r,variant:"tertiary"},s({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endAction:e.createElement(ue.z,{onClick:a,variant:"danger-light",startIcon:e.createElement(Xe.Z,null),id:"confirm-delete",loading:t},s({id:"app.components.Button.confirm",defaultMessage:"Confirm"}))}))};Sa.propTypes={isConfirmButtonLoading:n().bool.isRequired,isOpen:n().bool.isRequired,onConfirm:n().func.isRequired,onToggleDialog:n().func.isRequired};const Za=t=>t.stopPropagation(),xa=({rowId:t,index:o})=>{const{selectedEntries:r,onSelectRow:a}=(0,f.Sh)(),{formatMessage:s}=(0,H.Z)(),l=r.findIndex(d=>d===t)!==-1,c=s({id:"app.component.table.select.one-entry",defaultMessage:"Select {target}"},{target:o+1});return e.createElement($e.Td,{onClick:Za},e.createElement(Ia.C,{"aria-label":c,checked:l,onChange:()=>{a({name:t,value:!l})}}))};xa.propTypes={rowId:n().number.isRequired,index:n().number.isRequired};const Uo=({rowId:t,index:o,canCreate:r,canDelete:a,setIsConfirmDeleteRowOpen:s,handleCloneClick:l})=>{const{formatMessage:c}=(0,H.Z)(),{trackUsage:d}=(0,f.rS)(),{setSelectedEntries:p}=(0,f.Sh)(),m=(0,be.fi)(),{location:{pathname:u}}=(0,le.k6)(),h=c({id:"content-manager.components.ListViewTable.row-line",defaultMessage:"item line {number}"},{number:o+1});return e.createElement($e.Td,null,e.createElement(D.k,{gap:1,justifyContent:"end",onClick:Za},e.createElement(Me.h,{forwardedAs:It.rU,onClick:()=>{d("willEditEntryFromButton")},to:{pathname:`${u}/${t}`,state:{from:u},search:m},label:c({id:"app.component.table.edit",defaultMessage:"Edit {target}"},{target:h}),noBorder:!0},e.createElement(nt.Z,null)),r&&e.createElement(Me.h,{onClick:l(t),label:c({id:"app.component.table.duplicate",defaultMessage:"Duplicate {target}"},{target:h}),noBorder:!0},e.createElement(Wm.Z,null)),a&&e.createElement(Me.h,{onClick:()=>{d("willDeleteEntryFromList"),p([t]),s(!0)},label:c({id:"global.delete-target",defaultMessage:"Delete {target}"},{target:h}),noBorder:!0},e.createElement(Xe.Z,null))))};Uo.defaultProps={canCreate:!1,canDelete:!1},Uo.propTypes={rowId:n().number.isRequired,index:n().number.isRequired,setIsConfirmDeleteRowOpen:n().func.isRequired,handleCloneClick:n().func.isRequired,canCreate:n().bool,canDelete:n().bool};const La=({children:t,onConfirmDelete:o,isConfirmDeleteRowOpen:r,setIsConfirmDeleteRowOpen:a})=>{const[s,l]=e.useState(!1),{selectedEntries:c,setSelectedEntries:d}=(0,f.Sh)(),p=async()=>{try{l(!0),await o(c[0]),a(!1),l(!1),d([])}catch{l(!1),a(!1)}};return e.createElement(f.iA.Body,null,t,e.createElement(Sa,{isConfirmButtonLoading:s,onConfirm:p,onToggleDialog:()=>a(!r),isOpen:r}))};La.propTypes={children:n().node.isRequired,onConfirmDelete:n().func.isRequired,isConfirmDeleteRowOpen:n().bool.isRequired,setIsConfirmDeleteRowOpen:n().func.isRequired};const tn={CheckboxDataCell:xa,EntityActionsDataCell:Uo,Root:La};var jm=i(14090);const Ct=()=>t=>t["content-manager_listView"]||jm.E,zm=()=>(0,Ao.P1)(Ct(),t=>t),ka=t=>{const{displayedHeaders:o}=t["content-manager_listView"];return o};var Vm=zm;const nn=({onToggleDialog:t,isOpen:o,dialogBody:r,endAction:a})=>{const{formatMessage:s}=(0,H.Z)();return e.createElement(Kt.V,{onClose:t,title:s({id:"app.components.ConfirmDialog.title",defaultMessage:"Confirmation"}),isOpen:o},e.createElement(Yt.a,{icon:e.createElement(At.Z,null)},e.createElement(D.k,{direction:"column",alignItems:"stretch",gap:2},r)),e.createElement(Xt.c,{startAction:e.createElement(ue.z,{onClick:t,variant:"tertiary"},s({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endAction:a}))};nn.propTypes={isOpen:n().bool.isRequired,onToggleDialog:n().func.isRequired,dialogBody:n().node.isRequired,endAction:n().node.isRequired};const qo={isConfirmButtonLoading:n().bool.isRequired,isOpen:n().bool.isRequired,onConfirm:n().func.isRequired,onToggleDialog:n().func.isRequired},Um=t=>e.createElement(W.Z,{fontWeight:"bold"},t),Aa=({isOpen:t,onToggleDialog:o,isConfirmButtonLoading:r,onConfirm:a})=>{const{formatMessage:s}=(0,H.Z)(),{get:l}=(0,f.kY)(),{selectedEntries:c}=(0,f.Sh)(),d=(0,f.lm)(),{formatAPIError:p}=(0,f.So)(y.OB),{contentType:{uid:m}}=(0,re.v9)(Ct()),{data:u,isLoading:h,isError:E}=(0,Ne.useQuery)(["content-manager","draft-relations",m,c],async()=>{const{data:{data:g}}=await l(`/content-manager/collection-types/${m}/actions/countManyEntriesDraftRelations`,{params:{ids:c}});return g},{enabled:c.length>0,onError(g){d({type:"warning",message:p(g)})}});return E?null:e.createElement(nn,{isOpen:t&&!h,onToggleDialog:o,dialogBody:e.createElement(e.Fragment,null,e.createElement(W.Z,{id:"confirm-description",textAlign:"center"},u>0&&s({id:(0,y.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:Um,count:u,entities:c.length}),s({id:(0,y.OB)("popUpWarning.bodyMessage.contentType.publish.all"),defaultMessage:"Are you sure you want to publish these entries?"})),e.createElement(en,{area:"contentManager.listView.publishModalAdditionalInfos"})),endAction:e.createElement(ue.z,{onClick:a,variant:"secondary",startIcon:e.createElement(we.Z,null),loading:r},s({id:"app.utils.publish",defaultMessage:"Publish"}))})};Aa.propTypes=qo;var Fa=i(23866),qm=i(88890),Hm=i(5074);const Gm=(0,U.ZP)(W.Z)`
|
|
1042
|
+
max-width: 300px;
|
|
1043
|
+
`,Ho=({validationErrors:t,isPublished:o})=>{const{formatMessage:r}=(0,H.Z)();if(t){const a=Object.entries(t).map(([s,l])=>r({id:`${l.id}.withField`,defaultMessage:l.defaultMessage},{field:s})).join(" ");return e.createElement(D.k,{gap:2},e.createElement(ht.J,{color:"danger600",as:qm.Z}),e.createElement(Ft.u,{description:a},e.createElement(Gm,{textColor:"danger600",variant:"omega",fontWeight:"semiBold",ellipsis:!0},a)))}return o?e.createElement(D.k,{gap:2},e.createElement(ht.J,{color:"success600",as:Yn.Z}),e.createElement(W.Z,{textColor:"success600",fontWeight:"bold"},r({id:"content-manager.bulk-publish.already-published",defaultMessage:"Already Published"}))):e.createElement(D.k,{gap:2},e.createElement(ht.J,{color:"success600",as:Yn.Z}),e.createElement(W.Z,null,r({id:"app.utils.ready-to-publish",defaultMessage:"Ready to publish"})))};Ho.defaultProps={validationErrors:void 0,isPublished:!1},Ho.propTypes={validationErrors:n().shape({[n().string]:n().shape({id:n().string,defaultMessage:n().string})}),isPublished:n().bool};const Go=({isPublishing:t,rowsToDisplay:o,entriesToPublish:r,validationErrors:a})=>{const{location:{pathname:s}}=(0,le.k6)(),{formatMessage:l}=(0,H.Z)(),c=(0,re.v9)(Ct()),{mainField:d}=c.contentType.settings,p=d!=null&&d!=="id",m=u=>l({id:"content-manager.components.ListViewTable.row-line",defaultMessage:"item line {number}"},{number:u+1});return e.createElement(f.iA.Content,null,e.createElement(f.iA.Head,null,e.createElement(f.iA.HeaderCheckboxCell,null),e.createElement(f.iA.HeaderCell,{fieldSchemaType:"number",label:"id",name:"id"}),p&&e.createElement(f.iA.HeaderCell,{fieldSchemaType:"string",label:"name",name:"name"}),e.createElement(f.iA.HeaderCell,{fieldSchemaType:"string",label:"status",name:"status"})),e.createElement(f.iA.LoadingBody,null),e.createElement(f.iA.Body,null,o.map((u,h)=>e.createElement(Ma.Tr,{key:u.id},e.createElement(tn.CheckboxDataCell,{rowId:u.id,index:h}),e.createElement($e.Td,null,e.createElement(W.Z,null,u.id)),p&&e.createElement($e.Td,null,e.createElement(W.Z,null,u[d])),e.createElement($e.Td,null,t&&r.includes(u.id)?e.createElement(D.k,{gap:2},e.createElement(W.Z,null,l({id:"content-manager.success.record.publishing",defaultMessage:"Publishing..."})),e.createElement(Fa.a,{small:!0})):e.createElement(Ho,{validationErrors:a[u.id],isPublished:u.publishedAt!==null})),e.createElement($e.Td,null,e.createElement(Me.h,{forwardedAs:It.rU,to:{pathname:`${s}/${u.id}`,state:{from:s}},label:l({id:"app.component.table.edit",defaultMessage:"Edit {target}"},{target:m(h)}),noBorder:!0,target:"_blank",marginLeft:"auto"},e.createElement(nt.Z,null)))))))};Go.defaultProps={isPublishing:!1,rowsToDisplay:[],entriesToPublish:[],validationErrors:{}},Go.propTypes={isPublishing:n().bool,rowsToDisplay:n().arrayOf(n().object),entriesToPublish:n().arrayOf(n().number),validationErrors:n().shape({[n().string]:n().shape({id:n().string,defaultMessage:n().string})})};const $a=t=>e.createElement(W.Z,{fontWeight:"bold"},t),Qo=({toggleModal:t,refetchModalData:o,setEntriesToFetch:r,setSelectedListViewEntries:a,validationErrors:s})=>{const{formatMessage:l}=(0,H.Z)(),{selectedEntries:c,rows:d,onSelectRow:p,isLoading:m,isFetching:u}=(0,f.Sh)(),[h,E]=e.useState(!1),[g,b]=e.useState([]),[C,L]=e.useState(0),v=d.filter(({id:T})=>c.includes(T)&&!s[T]).map(({id:T})=>T),{post:R}=(0,f.kY)(),x=(0,f.lm)(),{contentType:V}=(0,re.v9)(Ct()),M=g.filter(({id:T})=>c.includes(T)&&s[T]).length,O=g.filter(({id:T,publishedAt:X})=>c.includes(T)&&X).length,j=c.length-M-O,$=(0,Ne.useMutation)(T=>R(`/content-manager/collection-types/${V.uid}/actions/bulkPublish`,T),{onSuccess(){const T=g.filter(G=>(v.includes(G.id)&&p({name:G.id,value:!1}),!v.includes(G.id)));b(T);const X=T.map(({id:G})=>G);r(X),a(X),T.length===0&&t(),x({type:"success",message:{id:"content-manager.success.record.publish",defaultMessage:"Published"}})},onError(T){x({type:"warning",message:(0,Hm.Z)(T)})}}),P=()=>E(T=>!T),N=async()=>{P();const{data:T}=await $.mutateAsync({ids:v});L(T.count)},Y=()=>C?l({id:(0,y.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:C,withErrorsCount:M,b:$a}):l({id:(0,y.OB)("containers.ListPage.selectedEntriesModal.selectedCount"),defaultMessage:"<b>{alreadyPublishedCount}</b> {alreadyPublishedCount, plural, =0 {entries} one {entry} other {entries}} already published. <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:M,alreadyPublishedCount:O,b:$a});return e.useEffect(()=>{d.length>0&&b(d)},[d]),e.createElement(vn.P,{onClose:t,labelledBy:"title"},e.createElement(Cn.x,null,e.createElement(W.Z,{fontWeight:"bold",textColor:"neutral800",as:"h2",id:"title"},l({id:(0,y.OB)("containers.ListPage.selectedEntriesModal.title"),defaultMessage:"Publish entries"}))),e.createElement(Rn.f,null,e.createElement(W.Z,null,Y()),e.createElement(Q.x,{marginTop:5},e.createElement(Go,{isPublishing:$.isLoading,rowsToDisplay:g,entriesToPublish:v,validationErrors:s}))),e.createElement(Mn.m,{startActions:e.createElement(ue.z,{onClick:t,variant:"tertiary"},l({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endActions:e.createElement(D.k,{gap:2},e.createElement(ue.z,{onClick:o,variant:"tertiary",loading:u},l({id:"app.utils.refresh",defaultMessage:"Refresh"})),e.createElement(ue.z,{onClick:P,disabled:c.length===0||c.length===M||m,loading:$.isLoading},l({id:"app.utils.publish",defaultMessage:"Publish"})))}),e.createElement(Aa,{isOpen:h,onToggleDialog:P,isConfirmButtonLoading:$.isLoading,onConfirm:N}))};Qo.defaultProps={validationErrors:{}},Qo.propTypes={toggleModal:n().func.isRequired,refetchModalData:n().func.isRequired,setEntriesToFetch:n().func.isRequired,setSelectedListViewEntries:n().func.isRequired,validationErrors:n().shape({[n().string]:n().shape({id:n().string,defaultMessage:n().string})})};const Ba=({onToggle:t})=>{const{selectedEntries:o,setSelectedEntries:r}=(0,f.Sh)(),{contentType:a,components:s}=(0,re.v9)(Ct()),[l,c]=e.useState(o),[{query:{sort:d}}]=(0,f.Kx)(),p={page:1,pageSize:l.length,sort:d,filters:{id:{$in:l}}},{get:m}=(0,f.kY)(),{data:u,isLoading:h,isFetching:E,refetch:g}=(0,Ne.useQuery)(["entries",a.uid,p],async()=>{const{data:b}=await m(`content-manager/collection-types/${a.uid}`,{params:p});if(b.results){const C=(0,y.Ex)(a,{components:s},{isDraft:!1}),L={};return{rows:b.results.map(R=>{try{return C.validateSync(R,{abortEarly:!1}),R}catch(x){return L[R.id]=(0,f.CJ)(x),R}}),validationErrors:L}}return{rows:[],validationErrors:{}}});return e.createElement(f.iA.Root,{rows:u?.rows,defaultSelectedEntries:o,colCount:4,isLoading:h,isFetching:E},e.createElement(Qo,{setSelectedListViewEntries:r,setEntriesToFetch:c,toggleModal:t,refetchModalData:g,validationErrors:u?.validationErrors}))};Ba.propTypes={onToggle:n().func.isRequired};var Qm=Ba;const wa=({isOpen:t,onToggleDialog:o,isConfirmButtonLoading:r,onConfirm:a})=>{const{formatMessage:s}=(0,H.Z)();return e.createElement(nn,{isOpen:t,onToggleDialog:o,dialogBody:e.createElement(e.Fragment,null,e.createElement(W.Z,{id:"confirm-description",textAlign:"center"},s({id:(0,y.OB)("popUpWarning.bodyMessage.contentType.unpublish.all"),defaultMessage:"Are you sure you want to unpublish these entries?"})),e.createElement(en,{area:"contentManager.listView.unpublishModalAdditionalInfos"})),endAction:e.createElement(ue.z,{onClick:a,variant:"secondary",startIcon:e.createElement(we.Z,null),loading:r},s({id:"app.utils.unpublish",defaultMessage:"Unpublish"}))})};wa.propTypes=qo;const Na=({isOpen:t,onToggleDialog:o,isConfirmButtonLoading:r,onConfirm:a})=>{const{formatMessage:s}=(0,H.Z)();return e.createElement(nn,{isOpen:t,onToggleDialog:o,dialogBody:e.createElement(e.Fragment,null,e.createElement(W.Z,{id:"confirm-description",textAlign:"center"},s({id:(0,y.OB)("popUpWarning.bodyMessage.contentType.delete.all"),defaultMessage:"Are you sure you want to delete these entries?"})),e.createElement(en,{area:"contentManager.listView.deleteModalAdditionalInfos"})),endAction:e.createElement(ue.z,{onClick:a,variant:"danger-light",startIcon:e.createElement(Xe.Z,null),id:"confirm-delete",loading:r},s({id:"app.components.Button.confirm",defaultMessage:"Confirm"}))})};Na.propTypes=qo;const Ko=({showPublish:t,showDelete:o,onConfirmDeleteAll:r,onConfirmUnpublishAll:a,refetchData:s})=>{const{formatMessage:l}=(0,H.Z)(),{trackUsage:c}=(0,f.rS)(),{data:d}=(0,re.v9)(Ct()),{selectedEntries:p,setSelectedEntries:m}=(0,f.Sh)(),[u,h]=e.useState(!1),[E,g]=e.useState(!1),[b,C]=e.useState(null),L=d.filter(P=>p.includes(P.id)),v=t&&L.some(P=>!P.publishedAt),R=t&&L.some(P=>P.publishedAt),x=()=>{b==="delete"?C(null):(C("delete"),c("willBulkDeleteEntries"))},V=()=>{b==="unpublish"?C(null):(C("unpublish"),c("willBulkUnpublishEntries"))},M=async(P,N)=>{try{h(!0),await P(p),h(!1),N(),m([])}catch{h(!1),N()}},O=()=>M(r,x),j=()=>M(a,V),$=()=>{g(P=>(P&&s(),!P))};return e.createElement(e.Fragment,null,v&&e.createElement(e.Fragment,null,e.createElement(ue.z,{variant:"tertiary",onClick:$},l({id:"app.utils.publish",defaultMessage:"Publish"})),E&&e.createElement(Qm,{onToggle:$})),R&&e.createElement(e.Fragment,null,e.createElement(ue.z,{variant:"tertiary",onClick:V},l({id:"app.utils.unpublish",defaultMessage:"Unpublish"})),e.createElement(wa,{isOpen:b==="unpublish",onToggleDialog:V,isConfirmButtonLoading:u,onConfirm:j})),o&&e.createElement(e.Fragment,null,e.createElement(ue.z,{variant:"danger-light",onClick:x},l({id:"global.delete",defaultMessage:"Delete"})),e.createElement(Na,{isOpen:b==="delete",onToggleDialog:x,isConfirmButtonLoading:u,onConfirm:O})))};Ko.defaultProps={showPublish:!1,showDelete:!1,onConfirmDeleteAll(){},onConfirmUnpublishAll(){},refetchData(){}},Ko.propTypes={showPublish:n().bool,showDelete:n().bool,onConfirmDeleteAll:n().func,onConfirmUnpublishAll:n().func,refetchData:n().func};var Km=Ko,Ym=i(96315);const Wa=({type:t,value:o})=>{const{formatDate:r,formatTime:a,formatNumber:s}=(0,H.Z)();let l=o;if(t==="date"&&(l=r((0,Ym.Z)(o),{dateStyle:"full"})),t==="datetime"&&(l=r(o,{dateStyle:"full",timeStyle:"short"})),t==="time"){const[c,d,p]=o.split(":"),m=new Date;m.setHours(c),m.setMinutes(d),m.setSeconds(p),l=a(m,{numeric:"auto",style:"short"})}return["float","decimal"].includes(t)&&(l=s(o,{maximumFractionDigits:20})),["integer","biginteger"].includes(t)&&(l=s(o,{maximumFractionDigits:0})),ra()(l)};Wa.propTypes={type:n().string.isRequired,value:n().any.isRequired};var Rt=Wa,Xm=i(69033);const Jm=(0,U.ZP)(D.k)`
|
|
1044
|
+
position: relative;
|
|
1045
|
+
border-radius: 50%;
|
|
1046
|
+
width: 26px;
|
|
1047
|
+
height: 26px;
|
|
1048
|
+
border: 1px solid ${({theme:t})=>t.colors.neutral200};
|
|
1049
|
+
background: ${({theme:t})=>t.colors.neutral150};
|
|
1050
|
+
padding-left: 1px;
|
|
1051
|
+
|
|
1052
|
+
span {
|
|
1053
|
+
line-height: 0.6rem;
|
|
1054
|
+
font-size: 0.6rem;
|
|
1055
|
+
}
|
|
1056
|
+
`,ja=({children:t,...o})=>e.createElement(Jm,{justifyContent:"center",alignItems:"center",as:"span",...o},e.createElement(W.Z,{variant:"sigma",textColor:"neutral600"},t));ja.propTypes={children:n().string.isRequired};var za=ja;const Yo=({url:t,mime:o,alternativeText:r,name:a,ext:s,formats:l})=>{const c=(0,f.CR)(t);if(o.includes("image")){const m=l?.thumbnail?.url||null,u=(0,f.CR)(m)||c;return e.createElement(Xm.q,{src:u,alt:r||a,preview:!0})}const d=(0,f.mD)(s),p=a.length>100?`${a.substring(0,100)}...`:a;return e.createElement(Ft.u,{description:p},e.createElement(za,null,d))};Yo.defaultProps={alternativeText:null,formats:null},Yo.propTypes={alternativeText:n().string,ext:n().string.isRequired,formats:n().object,mime:n().string.isRequired,name:n().string.isRequired,url:n().string.isRequired};var Va=Yo,_m=i(25898);const Ua=({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(za,{key:a,preview:!1},s)}return r>3?null:e.createElement(Va,{key:a,...o})}));Ua.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=Ua,qa=i(6518);const Ha=({fieldSchema:t,metadatas:o,name:r,entityId:a,value:s,contentType:l})=>{const{formatMessage:c}=(0,H.Z)(),{notifyStatus:d}=(0,zo.G)(),[p,m]=(0,e.useState)(!1),{get:u}=(0,f.kY)(),{data:h,status:E}=(0,Ne.useQuery)([t.targetModel,a],async()=>{const{data:{results:g,pagination:b}}=await u(`/content-manager/relations/${l.uid}/${a}/${r.split(".")[0]}`);return{results:g,pagination:b}},{enabled:p,staleTime:0,select:g=>({...g,results:[...g.results].reverse()})});return(0,e.useEffect)(()=>{h&&d(c({id:(0,y.OB)("DynamicTable.relation-loaded"),defaultMessage:"Relations have been loaded"}))},[h,c,d]),e.createElement(ge.fC,{onOpenChange:g=>m(g)},e.createElement(np,{onClick:g=>g.stopPropagation()},e.createElement(D.k,{gap:1,wrap:"nowrap"},e.createElement(qa.C,null,s.count),c({id:"content-manager.containers.ListPage.items",defaultMessage:"{number, plural, =0 {items} one {item} other {items}}"},{number:s.count}))),e.createElement(ge.VY,null,E!=="success"&&e.createElement(ge.ck,{disabled:!0},e.createElement(Fa.a,{small:!0},c({id:(0,y.OB)("ListViewTable.relation-loading"),defaultMessage:"Relations are loading"}))),E==="success"&&e.createElement(e.Fragment,null,h?.results.map(g=>e.createElement(ge.ck,{key:g.id,disabled:!0},e.createElement(tp,{ellipsis:!0},e.createElement(Rt,{type:o.mainField.schema.type,value:g[o.mainField.name]||g.id})))),h?.pagination.total>10&&e.createElement(ge.ck,{"aria-disabled":!0,"aria-label":c({id:(0,y.OB)("ListViewTable.relation-more"),defaultMessage:"This relation contains more entities than displayed"})},e.createElement(W.Z,null,"\u2026")))))};Ha.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,U.ZP)(W.Z)`
|
|
1057
|
+
max-width: 500px;
|
|
1058
|
+
`,np=(0,U.ZP)(ge.xz)`
|
|
1059
|
+
svg {
|
|
1060
|
+
width: ${6/16}rem;
|
|
1061
|
+
height: ${4/16}rem;
|
|
1062
|
+
}
|
|
1063
|
+
`;var op=Ha;const rp=(0,U.ZP)(W.Z)`
|
|
1064
|
+
max-width: 500px;
|
|
1065
|
+
`,Ga=({metadatas:t,value:o})=>e.createElement(rp,{textColor:"neutral800",ellipsis:!0},e.createElement(Rt,{type:t.mainField.schema.type,value:o[t.mainField.name]??o.id}));Ga.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=Ga;const sp=(0,U.ZP)(W.Z)`
|
|
1066
|
+
max-width: 500px;
|
|
1067
|
+
`,Qa=({value:t,metadatas:o})=>{const{formatMessage:r}=(0,H.Z)(),{mainField:{type:a,name:s}}=o;return e.createElement(ge.fC,null,e.createElement(ip,{onClick:l=>l.stopPropagation()},e.createElement(qa.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(ge.VY,null,t.map(l=>e.createElement(ge.ck,{key:l.id,disabled:!0},e.createElement(sp,{ellipsis:!0},e.createElement(Rt,{type:a,value:l[s]||l.id}))))))};Qa.propTypes={metadatas:n().shape({mainField:n().shape({name:n().string,type:n().string,value:n().string})}).isRequired,value:n().array.isRequired};const ip=(0,U.ZP)(ge.xz)`
|
|
1068
|
+
svg {
|
|
1069
|
+
width: ${6/16}rem;
|
|
1070
|
+
height: ${4/16}rem;
|
|
1071
|
+
}
|
|
1072
|
+
`;var lp=Qa;const cp=(0,U.ZP)(W.Z)`
|
|
1073
|
+
max-width: 250px;
|
|
1074
|
+
`,Ka=({value:t,metadatas:o})=>{const{mainField:r}=o,a=t[r.name];return e.createElement(Ft.u,{label:a},e.createElement(cp,{textColor:"neutral800",ellipsis:!0},e.createElement(Rt,{type:r.type,value:a})))};Ka.propTypes={metadatas:n().shape({mainField:n().shape({name:n().string,type:n().string,value:n().string})}).isRequired,value:n().object.isRequired};var dp=Ka,up=i(80022),Ya=i.n(up),Xa=i(73347);function Ja(t){return["oneToOne","manyToOne","oneToOneMorph"].includes(t)}function mp(t,o,r,a){if(t==="component"){const{mainField:{name:s,type:l}}=r;if(a?.repeatable)return o.length>0;const c=o?.[s];return s==="id"&&![void 0,null].includes(c)?!0:(0,Xa.Z)(l)&&l!=="biginteger"&&s!=="id"?Ya()(c):!We()(c)}return t==="relation"?Ja(a.relation)?!We()(o):o?.count>0:(0,Xa.Z)(t)&&t!=="biginteger"?Ya()(o):t==="boolean"?o!==null:!We()(o)}const _a=(0,U.ZP)(W.Z)`
|
|
1075
|
+
max-width: 300px;
|
|
1076
|
+
`,Xo=({content:t,fieldSchema:o,metadatas:r,name:a,rowId:s,contentType:l})=>{const{type:c}=o;if(!mp(c,t,r,o))return e.createElement(W.Z,{textColor:"neutral800"},"-");switch(c){case"media":return o.multiple?e.createElement(ep,{value:t}):e.createElement(Va,{...t});case"relation":return Ja(o.relation)?e.createElement(ap,{metadatas:r,value:t}):e.createElement(op,{fieldSchema:o,metadatas:r,value:t,name:a,entityId:s,contentType:l});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(Ft.u,{description:t},e.createElement(_a,{ellipsis:!0,textColor:"neutral800"},e.createElement(Rt,{type:c,value:t})));default:return e.createElement(_a,{ellipsis:!0,textColor:"neutral800"},e.createElement(Rt,{type:c,value:t}))}};Xo.defaultProps={content:void 0},Xo.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=Xo;const gp=(0,U.ZP)(D.k)`
|
|
1077
|
+
:hover {
|
|
1078
|
+
background-color: ${t=>t.theme.colors.primary100};
|
|
1079
|
+
}
|
|
1080
|
+
`,es=({layout:t})=>{const o=(0,re.I0)(),r=(0,re.v9)(ka),{trackUsage:a}=(0,f.rS)(),{formatMessage:s,locale:l}=(0,H.Z)(),c=(0,f.Xe)(l,{sensitivity:"base"}),d=Object.keys(t.contentType.attributes).filter(h=>(0,y.ko)(t.contentType.attributes[h])).map(h=>({name:h,label:t.contentType.metadatas[h].list.label})).sort((h,E)=>c.compare(h.label,E.label)),p=r.map(({name:h})=>h),m=h=>{a("didChangeDisplayedFields"),o(Ca({name:h,value:p.includes(h)}))},u=()=>{o(va())};return e.createElement(D.k,{as:"fieldset",direction:"column",alignItems:"stretch",gap:3},e.createElement(D.k,{justifyContent:"space-between"},e.createElement(W.Z,{as:"legend",variant:"pi",fontWeight:"bold"},s({id:"containers.ListPage.displayedFields",defaultMessage:"Displayed fields"})),e.createElement(eo.A,{onClick:u},s({id:"app.components.Button.reset",defaultMessage:"Reset"}))),e.createElement(D.k,{direction:"column",alignItems:"stretch"},d.map(h=>{const E=p.includes(h.name);return e.createElement(gp,{wrap:"wrap",gap:2,as:"label",background:E?"primary100":"transparent",hasRadius:!0,padding:2,key:h.name},e.createElement(Ia.C,{onChange:()=>m(h.name),value:E,name:h.name}),e.createElement(W.Z,{fontSize:1},h.label))})))};es.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 ts=({slug:t,layout:o})=>{const[r,a]=e.useState(!1),s=e.useRef(),l=(0,re.v9)(Pe._),{formatMessage:c}=(0,H.Z)(),d=()=>{a(p=>!p)};return e.createElement(e.Fragment,null,e.createElement(Me.h,{icon:e.createElement(mn.Z,null),label:c({id:"components.ViewSettings.tooltip",defaultMessage:"View Settings"}),ref:s,onClick:d}),r&&e.createElement(ta.J2,{placement:"bottom-end",source:s,onDismiss:d,padding:2},e.createElement(D.k,{alignItems:"stretch",direction:"column",gap:3},e.createElement(f.jW,{permissions:l.contentManager.collectionTypesConfigurations},e.createElement(f.Qj,{size:"S",startIcon:e.createElement(fn.Z,null),to:`${t}/configurations/list`,variant:"secondary"},c({id:"app.links.configure-view",defaultMessage:"Configure the view"}))),e.createElement(es,{layout:o}))))};ts.propTypes={slug:n().string.isRequired,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 fp=null,hp=()=>null,Ep=[],yp=[...["createdBy","updatedBy"],"strapi_assignee"];function ns({canCreate:t,canDelete:o,canRead:r,canPublish:a,data:s,getData:l,getDataSucceeded:c,isLoading:d,layout:p,pagination:m,slug:u}){const{total:h}=m,{contentType:E}=p,{info:g,options:b,metadatas:C,settings:{bulkable:L,filterable:v,searchable:R}}=E,[x,V]=e.useState(!1),M=(0,f.lm)(),{trackUsage:O}=(0,f.rS)(),{allPermissions:j,refetchPermissions:$}=(0,f.vn)(),P=e.useRef(O),N=e.useRef($),{notifyStatus:Y}=(0,zo.G)(),{formatAPIError:T}=(0,f.So)(y.OB),X=Nm(E,u),[{query:G}]=(0,f.Kx)(),{pathname:J}=(0,le.TH)(),{push:F}=(0,le.k6)(),{formatMessage:S,locale:I}=(0,H.Z)(),A=(0,f.kY)(),q=(0,f.Xe)(I,{sensitivity:"base"}),K=G?.filters?.$and?.reduce((ee,se)=>{const[oe,B]=Object.entries(se)[0],_=B.id?.$eq||B.id?.$ne;return yp.includes(oe)&&!ee.includes(_)&&ee.push(_),ee},[])??[],{users:k,isLoading:z}=(0,Da.R)({filter:{id:{in:K}}},{enabled:K.length>0&&(0,f.ZT)(j,[{action:"admin::users.read",subject:null}]).length>0});(0,f.go)();const ne=e.useMemo(()=>la(G),[G]),ce=(0,_t.stringify)({plugins:G.plugins},{encode:!1}),he=X.map(ee=>{const se=E.attributes[ee],{type:oe,enum:B}=se,_={name:"didFilterEntries",properties:{useRelation:oe==="relation"}},{mainField:ie,label:Ie}=C[ee].list,Be={name:ee,metadatas:{label:S({id:Ie,defaultMessage:Ie})},fieldSchema:{type:oe,options:B,mainField:ie},trackedEvent:_};return se.type==="relation"&&se.target==="admin::user"&&(Be.metadatas={...Be.metadatas,customOperators:[{intlLabel:{id:"components.FilterOptions.FILTER_TYPES.$eq",defaultMessage:"is"},value:"$eq"},{intlLabel:{id:"components.FilterOptions.FILTER_TYPES.$ne",defaultMessage:"is not"},value:"$ne"}],customInput:Vo,options:k.map(it=>({label:(0,y.Gf)(it,S),customValue:it.id.toString()}))},Be.fieldSchema.mainField={name:"id"}),Be}),fe=b?.draftAndPublish??!1,Z=b?.reviewWorkflows??!1,te=(0,xt.c)(fp,async()=>(await i.e(6158).then(i.bind(i,76158))).REVIEW_WORKFLOW_COLUMNS_EE,{enabled:!!b?.reviewWorkflows}),me=(0,xt.c)(hp,async()=>{const{ReviewWorkflowsStageEE:ee,ReviewWorkflowsAssigneeEE:se}=await i.e(1227).then(i.bind(i,21227));return{ReviewWorkflowsStageEE:ee,ReviewWorkflowsAssigneeEE:se}},{enabled:Z}),Ze=(0,xt.c)(Ep,async()=>(await i.e(4174).then(i.bind(i,84174))).REVIEW_WORKFLOW_FILTERS,{combine(ee,se){return[...ee,...se.filter(oe=>oe.name==="strapi_assignee"?(0,f.ZT)(j,[{action:"admin::users.read",subject:null}]).length>0:!0).map(oe=>({...oe,metadatas:{...oe.metadatas,...oe.name==="strapi_stage"?{uid:E.uid}:{},label:S(oe.metadatas.label),options:oe.name==="strapi_assignee"&&k.map(B=>({label:(0,y.Gf)(B,S),customValue:B.id.toString()}))}}))]},defaultValue:[],enabled:Z&&!z}),{post:ke,del:de}=A,Ae=(0,Ne.useMutation)(ee=>ke(`/content-manager/collection-types/${E.uid}/actions/bulkUnpublish`,ee),{onSuccess(){M({type:"success",message:{id:"content-manager.success.record.unpublish",defaultMessage:"Unpublished"}}),De(`/content-manager/collection-types/${u}`,{params:ne})},onError(ee){M({type:"warning",message:T(ee)})}}),je=e.useRef(""),De=e.useCallback(async(ee,se)=>{l();try{const{data:{results:oe,pagination:B}}=await A.get(ee,se);if(B.page>B.pageCount&&B.pageCount>0){const _={...ne,page:B.pageCount};F({pathname:J,state:{from:J},search:(0,_t.stringify)(_)});return}Y(S({id:(0,y.OB)("utils.data-loaded"),defaultMessage:"{number, plural, =1 {# entry has} other {# entries have}} successfully been loaded"},{number:B.count})),c(B,oe)}catch(oe){if(qe.default.isCancel(oe))return;if((oe?.response?.status??null)===403){await N.current(),M({type:"info",message:{id:(0,y.OB)("permissions.not-allowed.update")}}),F("/");return}M({type:"warning",message:{id:(0,y.OB)("error.model.fetch")}})}},[S,l,c,Y,F,M,A,ne,J]),Je=e.useCallback(async ee=>{try{await ke(`/content-manager/collection-types/${u}/actions/bulkDelete`,{ids:ee}),De(`/content-manager/collection-types/${u}`,{params:ne}),P.current("didBulkDeleteEntries")}catch(se){M({type:"warning",message:T(se)})}},[u,M,T,ke,De,ne]),Bt=e.useCallback(async ee=>{try{await de(`/content-manager/collection-types/${u}/${ee}`);const se=`/content-manager/collection-types/${u}`;De(se,{params:ne}),M({type:"success",message:{id:(0,y.OB)("success.record.delete")}})}catch(se){M({type:"warning",message:T(se)})}},[u,M,T,de,De,ne]),pt=ee=>Ae.mutateAsync({ids:ee});e.useEffect(()=>{const se=qe.default.CancelToken.source(),oe=r,B=`/content-manager/collection-types/${u}`;return oe&&B.includes(je.current)&&De(B,{cancelToken:se.token,params:ne}),()=>{je.current=u,se.cancel("Operation canceled by the user.")}},[r,l,u,ne,c,De]);const Ee=S({id:(0,y.OB)("header.name"),defaultMessage:"Content"}),Ce=S({id:g.displayName,defaultMessage:g.displayName||Ee}),{runHookWaterfall:_e}=(0,f.j1)(),on=(0,re.v9)(ka),He=e.useMemo(()=>{const se=_e(jt.No,{displayedHeaders:on,layout:p}).displayedHeaders.map(oe=>{const{metadatas:B}=oe;if(oe.fieldSchema.type==="relation"){const _=`${oe.name}.${oe.metadatas.mainField.name}`;return{...oe,metadatas:{...B,label:S({id:(0,y.OB)(`containers.ListPage.table-headers.${oe.name}`),defaultMessage:B.label})},name:_}}return{...oe,metadatas:{...B,label:S({id:(0,y.OB)(`containers.ListPage.table-headers.${oe.name}`),defaultMessage:B.label})}}});return fe&&se.push({key:"__published_at_temp_key__",name:"publishedAt",fieldSchema:{type:"custom"},metadatas:{label:S({id:(0,y.OB)("containers.ListPage.table-headers.publishedAt"),defaultMessage:"publishedAt"}),searchable:!1,sortable:!0}}),te&&(te.map(oe=>(typeof oe.metadatas.label!="string"&&(oe.metadatas.label=S(oe.metadatas.label)),oe)),se.push(...te)),se},[_e,on,p,te,fe,S]),er=r?S({id:(0,y.OB)("pages.ListView.header-subtitle"),defaultMessage:"{number, plural, =0 {# entries} one {# entry} other {# entries}} found"},{number:h}):null,rn=ee=>t?e.createElement(ue.z,{...ee,forwardedAs:It.rU,onClick:()=>{const se=fe?{status:"draft"}:{};P.current("willCreateEntry",se)},to:{pathname:`${J}/create`,search:G.plugins?ce:""},startIcon:e.createElement(ft.Z,null),style:{textDecoration:"none"}},S({id:(0,y.OB)("HeaderLayout.button.label-add-entry"),defaultMessage:"Create new entry"})):null,tr=ee=>()=>{O("willEditEntryFromList"),F({pathname:`${J}/${ee}`,state:{from:J},search:ce})},nr=ee=>async()=>{try{const{data:se}=await ke(`/content-manager/collection-types/${E.uid}/auto-clone/${ee}?${ce}`);"id"in se&&F({pathname:`${J}/${se.id}`,state:{from:J},search:ce})}catch(se){se instanceof Fm.d7&&F({pathname:`${J}/create/clone/${ee}`,state:{from:J,error:T(se)},search:ce})}},or=He.length+2,rr=()=>{De(`/content-manager/collection-types/${u}`,{params:ne})};return me?e.createElement(Te.o,{"aria-busy":d},e.createElement(Oe.T,{primaryAction:rn(),subtitle:er,title:Ce,navigationAction:e.createElement(f.rU,{startIcon:e.createElement(dt.Z,null),to:"/content-manager/"},S({id:"global.back",defaultMessage:"Back"}))}),!r&&e.createElement(Ra.Z,{endActions:e.createElement(zt,{area:"contentManager.listView.actions"})}),r&&e.createElement(Ra.Z,{endActions:e.createElement(e.Fragment,null,e.createElement(zt,{area:"contentManager.listView.actions"}),e.createElement(ts,{slug:u,layout:p})),startActions:e.createElement(e.Fragment,null,R&&e.createElement(f.m,{label:S({id:"app.component.search.label",defaultMessage:"Search for {target}"},{target:Ce}),placeholder:S({id:"global.search",defaultMessage:"Search"}),trackedEvent:"didSearch"}),v&&!z&&e.createElement(Oa,{displayedFilters:[...he,...Ze].sort((ee,se)=>q.compare(ee.metadatas.label,se.metadatas.label))}))}),e.createElement(tt.D,null,r?e.createElement(D.k,{gap:4,direction:"column",alignItems:"stretch"},e.createElement(f.iA.Root,{rows:s,isLoading:d,colCount:or},e.createElement(f.iA.ActionBar,null,e.createElement(Km,{showPublish:a&&fe,showDelete:o,onConfirmDeleteAll:Je,onConfirmUnpublishAll:pt,refetchData:rr})),e.createElement(f.iA.Content,null,e.createElement(f.iA.Head,null,e.createElement(f.iA.HeaderCheckboxCell,null),He.map(({fieldSchema:ee,key:se,name:oe,metadatas:B})=>e.createElement(f.iA.HeaderCell,{key:se,name:oe,fieldSchemaType:ee.type,relationFieldName:B.mainField?.name,isSortable:B.sortable,label:B.label})),e.createElement(f.iA.HeaderHiddenActionsCell,null)),e.createElement(f.iA.LoadingBody,null),e.createElement(f.iA.EmptyBody,{contentType:Ce,aciton:rn({variant:"secondary"})}),e.createElement(tn.Root,{onConfirmDelete:Bt,isConfirmDeleteRowOpen:x,setIsConfirmDeleteRowOpen:V},s.map((ee,se)=>e.createElement(Ma.Tr,{cursor:"pointer",key:s.id,onClick:tr(ee.id)},e.createElement(tn.CheckboxDataCell,{rowId:ee.id,index:se}),He.map(({key:oe,name:B,cellFormatter:_,...ie})=>{if(fe&&B==="publishedAt")return e.createElement($e.Td,{key:oe},e.createElement(to.q,{width:"min-content",showBullet:!1,variant:ee.publishedAt?"success":"secondary",size:"S"},e.createElement(W.Z,{fontWeight:"bold",textColor:`${ee.publishedAt?"success":"secondary"}700`},S({id:(0,y.OB)(`containers.List.${ee.publishedAt?"published":"draft"}`),defaultMessage:ee.publishedAt?"Published":"Draft"}))));if(Z){if(B==="strapi_stage")return e.createElement($e.Td,{key:oe},ee.strapi_stage?e.createElement(me.ReviewWorkflowsStageEE,{color:ee.strapi_stage.color??Am.W.colors.primary600,name:ee.strapi_stage.name}):e.createElement(W.Z,{textColor:"neutral800"},"-"));if(B==="strapi_assignee")return e.createElement($e.Td,{key:oe},ee.strapi_assignee?e.createElement(me.ReviewWorkflowsAssigneeEE,{firstname:ee.strapi_assignee.firstname,lastname:ee?.strapi_assignee?.lastname,displayname:ee?.strapi_assignee?.username}):e.createElement(W.Z,{textColor:"neutral800"},"-"))}return["createdBy","updatedBy"].includes(B.split(".")[0])?e.createElement($e.Td,{key:oe},e.createElement(W.Z,{textColor:"neutral800"},(0,y.Gf)(ee[B.split(".")[0]],S))):typeof _=="function"?e.createElement($e.Td,{key:oe},_(ee,{key:oe,name:B,...ie})):e.createElement($e.Td,{key:oe},e.createElement(pp,{content:ee[B.split(".")[0]],name:B,contentType:p.contentType,...ie,rowId:ee.id}))}),(o||a)&&L&&e.createElement(tn.EntityActionsDataCell,{rowId:ee.id,index:se,setIsConfirmDeleteRowOpen:V,canCreate:t,canDelete:o,handleCloneClick:nr})))))),e.createElement(D.k,{alignItems:"flex-end",justifyContent:"space-between"},e.createElement(f.v4,{trackedEvent:"willChangeNumberOfEntriesPerPage"}),e.createElement(f.tU,{pagination:{pageCount:m?.pageCount||1}}))):e.createElement(f.ZF,null))):null}ns.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 bp=Vm();function vp(t){return(0,Ta.bindActionCreators)({getData:Zm,getDataSucceeded:xm,onChangeListHeaders:Ca,onResetListHeaders:va},t)}const Cp=(0,re.$j)(bp,vp);var Rp=(0,Ta.compose)(Cp)(e.memo(ns,Fe()));const Jo=t=>{const o=(0,e.useMemo)(()=>(0,y.TA)(t.slug),[t.slug]),{isLoading:r,allowedActions:a}=(0,f.ss)(o,t.permissions);return r?e.createElement(f.dO,null):e.createElement(Rp,{...t,...a})};Jo.defaultProps={permissions:[]},Jo.propTypes={permissions:n().array,slug:n().string.isRequired};var Mp=(0,e.memo)(Jo,(t,o)=>{const r=(0,f.e5)(t,o);return Object.keys(r).filter(s=>s!=="state").length>0});const os=({layout:t,...o})=>{const r=(0,re.I0)(),{replace:a}=(0,le.k6)(),[{query:s,rawQuery:l}]=(0,f.Kx)(),{permissions:c,isValid:d}=(0,be.r5)(s,o.slug,"listView"),p=(0,be.Ky)(o.slug);return(0,e.useEffect)(()=>{l||a(p)},[l,a,p]),(0,e.useEffect)(()=>{r(km(t))},[r,t]),(0,e.useEffect)(()=>()=>{r(Lm())},[r]),d?e.createElement(Mp,{...o,layout:t,permissions:c}):null};os.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 Tp=os,Dp=()=>e.createElement(Q.x,{padding:8},e.createElement(f.Hn,null));const rs=({match:{params:{slug:t},url:o}})=>{const r=(0,re.v9)(Pe._),{isLoading:a,layout:s,updateLayout:l}=(0,be.zE)(t),{rawContentTypeLayout:c,rawComponentsLayouts:d}=(0,e.useMemo)(()=>{let h={},E={};return s.contentType&&(h=(0,y.du)(s.contentType)),s.components&&(E=Object.keys(s.components).reduce((g,b)=>(g[b]=(0,y.du)(s.components[b]),g),{})),{rawContentTypeLayout:h,rawComponentsLayouts:E}},[s]);if((s?.contentType?.uid??null)!==t||a)return e.createElement(f.dO,null);const m=({location:{state:h},history:{goBack:E},match:{params:{id:g,origin:b}}},C)=>e.createElement(C,{slug:t,layout:s,state:h,goBack:E,id:g,origin:b}),u=[{path:"create/clone/:origin",comp:Jt},{path:"create",comp:Jt},{path:":id",comp:Jt},{path:"",comp:Tp}].map(({path:h,comp:E})=>e.createElement(le.AW,{key:h,path:`${o}/${h}`,render:g=>m(g,E)}));return e.createElement(sn.ErrorBoundary,{FallbackComponent:Dp},e.createElement(wt.Provider,{value:s},e.createElement(le.rs,null,e.createElement(le.AW,{path:`${o}/configurations/list`},e.createElement(f.O4,{permissions:r.contentManager.collectionTypesConfigurations},e.createElement(Sm,{layout:c,slug:t,updateLayout:l}))),e.createElement(le.AW,{path:`${o}/configurations/edit`},e.createElement(f.O4,{permissions:r.contentManager.collectionTypesConfigurations},e.createElement(An,{components:d,isContentTypeView:!0,mainLayout:c,slug:t,updateLayout:l}))),u)))};rs.propTypes={match:n().shape({url:n().string.isRequired,params:n().shape({slug:n().string.isRequired}).isRequired}).isRequired};var Op=(0,e.memo)(rs),as=i(4214);const Ip=()=>{const[{isLoading:t,data:o},r]=(0,e.useReducer)(as.Z,as.q),a=(0,e.useMemo)(gt.Vo,[]),{schemas:s}=(0,re.v9)(p=>a(p),re.wU),l=(0,re.v9)(Pe._),{uid:c}=(0,le.UO)(),{get:d}=(0,f.kY)();return(0,e.useEffect)(()=>{const m=qe.default.CancelToken.source();return(async h=>{try{r(Vt());const{data:{data:E}}=await d(`/content-manager/components/${c}/configuration`,{cancelToken:h.token});r(Fn((0,y.w8)(E,s,"component")))}catch(E){if(qe.default.isCancel(E))return;console.error(E)}})(m),()=>{m.cancel("Operation canceled by the user.")}},[c,s,d]),t?e.createElement(f.dO,null):e.createElement(f.O4,{permissions:l.contentManager.componentsConfigurations},e.createElement(An,{components:o.components,mainLayout:o.component,slug:c}))};var Pp=(0,e.memo)(Ip),Sp=i(9695),Zp=i(54725),xp=()=>{const{formatMessage:t}=(0,H.Z)();return(0,f.go)(),e.createElement(Te.o,null,e.createElement(Oe.T,{title:t({id:(0,y.OB)("header.name"),defaultMessage:"Content"})}),e.createElement(tt.D,null,e.createElement(Sp.x,{action:e.createElement(f.Qj,{variant:"secondary",startIcon:e.createElement(ft.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(Zp.Z,{width:"10rem"}),shadow:"tableShadow"})))},Lp=()=>{const{formatMessage:t}=(0,H.Z)();return(0,f.go)(),e.createElement(Te.o,null,e.createElement(Oe.T,{title:t({id:(0,y.OB)("header.name"),defaultMessage:"Content"})}),e.createElement(tt.D,null,e.createElement(f.ZF,null)))};const ss=({match:{params:{slug:t},url:o}})=>{const r=(0,re.v9)(Pe._),{isLoading:a,layout:s,updateLayout:l}=(0,be.zE)(t),{rawContentTypeLayout:c,rawComponentsLayouts:d}=(0,e.useMemo)(()=>{let p={},m={};return s.contentType&&(m=(0,y.du)(s.contentType)),s.components&&(p=Object.keys(s.components).reduce((u,h)=>(u[h]=(0,y.du)(s.components[h]),u),{})),{rawContentTypeLayout:m,rawComponentsLayouts:p}},[s]);return a?e.createElement(f.dO,null):e.createElement(wt.Provider,{value:s},e.createElement(le.rs,null,e.createElement(le.AW,{path:`${o}/configurations/edit`},e.createElement(f.O4,{permissions:r.contentManager.singleTypesConfigurations},e.createElement(An,{components:d,isContentTypeView:!0,mainLayout:c,slug:t,updateLayout:l}))),e.createElement(le.AW,{path:o,render:({location:{state:p},history:{goBack:m}})=>e.createElement(Jt,{layout:s,slug:t,isSingleType:!0,state:p,goBack:m})})))};ss.propTypes={match:n().shape({url:n().string.isRequired,params:n().shape({slug:n().string.isRequired}).isRequired}).isRequired};var kp=(0,e.memo)(ss),Ap=i(16899);const Fp=(0,U.ZP)(D.k)`
|
|
1081
|
+
border-radius: 50%;
|
|
1082
|
+
|
|
1083
|
+
svg {
|
|
1084
|
+
height: ${6/16}rem;
|
|
1085
|
+
width: ${11/16}rem;
|
|
1086
|
+
> path {
|
|
1087
|
+
fill: ${({theme:t})=>t.colors.neutral600};
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
`,$p=U.ZP.button`
|
|
1091
|
+
border: none;
|
|
1092
|
+
background: transparent;
|
|
1093
|
+
display: block;
|
|
1094
|
+
width: 100%;
|
|
1095
|
+
text-align: unset;
|
|
1096
|
+
padding: 0;
|
|
1097
|
+
`;function is({displayedValue:t}){return e.createElement(D.k,{background:"neutral0",borderColor:"neutral200",justifyContent:"space-between",gap:3,padding:3,width:(0,f.Q1)(300)},e.createElement($p,{type:"button"},e.createElement(D.k,{gap:6},e.createElement(Fp,{alignItems:"center",justifyContent:"center",background:"neutral200",height:(0,f.Q1)(32),width:(0,f.Q1)(32)},e.createElement(Ap.Z,null)),e.createElement(D.k,{maxWidth:(0,f.Q1)(150)},e.createElement(W.Z,{textColor:"neutral700",ellipsis:!0},t)))),e.createElement(D.k,{gap:2},e.createElement(Me.h,{noBorder:!0},e.createElement(Xe.Z,null)),e.createElement(Me.h,{noBorder:!0},e.createElement(ot.Z,null))))}is.propTypes={displayedValue:n().string.isRequired};const ls=({status:t,displayedValue:o,width:r})=>{const{formatMessage:a}=(0,H.Z)(),s={[mt.DRAFT]:a({id:(0,y.OB)("relation.publicationState.draft"),defaultMessage:"Draft"}),[mt.PUBLISHED]:a({id:(0,y.OB)("relation.publicationState.published"),defaultMessage:"Published"})},l=t===mt.DRAFT?"secondary":"success";return e.createElement(Q.x,{style:{width:r}},e.createElement(D.k,{paddingTop:2,paddingBottom:2,paddingLeft:2,paddingRight:4,hasRadius:!0,borderSize:1,background:"neutral0",borderColor:"neutral200",justifyContent:"space-between"},e.createElement(zr,{gap:1},e.createElement(Me.h,{noBorder:!0},e.createElement(ot.Z,null)),e.createElement(Vr,{maxWidth:"100%",justifyContent:"space-between"},e.createElement(Q.x,{minWidth:0,paddingTop:1,paddingBottom:1,paddingRight:4},e.createElement(Ur,null,e.createElement(W.Z,{textColor:"primary600",ellipsis:!0},o))),t&&e.createElement(to.q,{variant:l,showBullet:!1,size:"S"},e.createElement(W.Z,{fontWeight:"bold",textColor:`${l}700`},s[t])))),e.createElement(Q.x,{paddingLeft:4},e.createElement(qr,{type:"button"},e.createElement(ht.J,{width:"12px",as:Ut.Z})))))};ls.propTypes={status:n().string.isRequired,displayedValue:n().string.isRequired,width:n().number.isRequired};var Bp=i(90700),wp=i(78090),Np=i(77013),Wp=i(79318),jp=i(66618),zp=()=>{const[t,o]=(0,e.useState)(""),{formatMessage:r,locale:a}=(0,H.Z)(),s=(0,e.useMemo)(gt.KQ,[]),{collectionTypeLinks:l,singleTypeLinks:c}=(0,re.v9)(s,re.wU),{startsWith:d}=(0,f.L0)(a,{sensitivity:"base"}),p=(0,f.Xe)(a,{sensitivity:"base"}),m=(0,e.useMemo)(()=>[{id:"collectionTypes",title:{id:(0,Ve.Z)("components.LeftMenu.collection-types"),defaultMessage:"Collection Types"},searchable:!0,links:l},{id:"singleTypes",title:{id:(0,Ve.Z)("components.LeftMenu.single-types"),defaultMessage:"Single Types"},searchable:!0,links:c}].map(g=>({...g,links:g.links.filter(b=>d(b.title,t)).sort((b,C)=>p.compare(b.title,C.title)).map(b=>({...b,title:r({id:b.title,defaultMessage:b.title})}))})),[l,t,c,d,r,p]),u=()=>{o("")},h=({target:{value:g}})=>{o(g)},E=r({id:(0,Ve.Z)("header.name"),defaultMessage:"Content"});return e.createElement(Bp.m,{ariaLabel:E},e.createElement(wp.p,{label:E,searchable:!0,value:t,onChange:h,onClear:u,searchLabel:r({id:"content-manager.components.LeftMenu.Search.label",defaultMessage:"Search for a content type"})}),e.createElement(Np.Z,null,m.map(g=>{const b=r({id:g.title.id,defaultMessage:g.title.defaultMessage},g.title.values);return e.createElement(Wp.D,{key:g.id,label:b,badgeLabel:g.links.length.toString()},g.links.map(C=>{const L=C.search?`?${C.search}`:"";return e.createElement(jp.E,{as:It.OL,key:C.uid,to:`${C.to}${L}`},C.title)}))})))},_o=i(70475);const Vp=()=>({type:_o.fn}),Up=()=>({type:_o.sZ}),qp=({authorizedCollectionTypeLinks:t,authorizedSingleTypeLinks:o,contentTypeSchemas:r,components:a,fieldSizes:s})=>({type:_o.IX,data:{authorizedCollectionTypeLinks:t,authorizedSingleTypeLinks:o,components:a,contentTypeSchemas:r,fieldSizes:s}});var cs=(t,o)=>o.map(({permissions:r})=>(0,f.qX)(t,r)),Hp=i(81346),Gp=i.n(Hp);const ds=(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}],l=[{action:"plugin::content-manager.explorer.read",subject:a.uid}],c=o==="collectionTypes"?s:l,d=r.find(({uid:m})=>m===a.uid);let p=null;if(d){const m={page:1,pageSize:d.settings.pageSize,sort:`${d.settings.defaultSortBy}:${d.settings.defaultSortOrder}`};p=(0,_t.stringify)(m,{encode:!1})}return{permissions:c,search:p,kind:a.kind,title:a.info.displayName,to:`/content-manager/${a.kind}/${a.uid}`,uid:a.uid,name:a.uid,isDisplayed:a.isDisplayed}});var Qp=(t,o)=>{const r=Object.entries(Gp()(t,"kind")).map(([l,c])=>({name:l,links:c})),[a,s]=Ke()(r,"name");return{collectionTypeSectionLinks:ds(a?.links||[],"collectionTypes",o),singleTypeSectionLinks:ds(s?.links??[],"singleTypes")}},Kp=async({models:t,userPermissions:o,toggleNotification:r})=>{const{get:a}=(0,f.tg)();try{const{data:{data:s}}=await a("/content-manager/content-types-settings"),{collectionTypeSectionLinks:l,singleTypeSectionLinks:c}=Qp(t,s),d=await Promise.all(cs(o,l)),p=l.filter((h,E)=>d[E]),m=await Promise.all(cs(o,c)),u=c.filter((h,E)=>m[E]);return{authorizedCollectionTypeLinks:p,authorizedSingleTypeLinks:u}}catch(s){return console.error(s),r({type:"warning",message:{id:"notification.error"}}),{authorizedCollectionTypeLinks:[],authorizedSingleTypeLinks:[]}}},Yp=()=>{const t=(0,re.I0)(),o=(0,f.lm)(),r=(0,re.v9)((0,gt.Yg)()),a=(0,e.useRef)(),{allPermissions:s}=(0,f.vn)(),{runHookWaterfall:l}=(0,f.j1)(),d=qe.default.CancelToken.source(),{notifyStatus:p}=(0,zo.G)(),{formatMessage:m}=(0,H.Z)(),{get:u}=(0,f.kY)(),h=async()=>{t(Vp());try{const{data:{data:{components:E,contentTypes:g,fieldSizes:b}}}=await u("/content-manager/init",{cancelToken:d.token});p(m({id:(0,y.OB)("App.schemas.data-loaded"),defaultMessage:"The schemas have been successfully loaded."}));const C=await Kp({models:g,userPermissions:s,toggleNotification:o}),{ctLinks:L}=l(jt.LK,{ctLinks:C.authorizedCollectionTypeLinks,models:g}),{stLinks:v}=l(jt.dV,{stLinks:C.authorizedSingleTypeLinks,models:g}),R=qp({authorizedCollectionTypeLinks:L,authorizedSingleTypeLinks:v,contentTypeSchemas:g,components:E,fieldSizes:b});t(R)}catch(E){if(qe.default.isCancel(E))return;console.error(E),o({type:"warning",message:{id:"notification.error"}})}};return a.current=h,(0,e.useEffect)(()=>(a.current(),()=>{d.cancel("Operation canceled by the user."),t(Up())}),[t,o]),{...r,refetchData:a.current}};function Xp({type:t,item:o}){if([ct.Z.EDIT_FIELD,ct.Z.FIELD].includes(t))return e.createElement($t,{labelField:o.labelField});const[r]=t.split("_");switch(r){case ct.Z.COMPONENT:case ct.Z.DYNAMIC_ZONE:return e.createElement(is,{displayedValue:o.displayedValue});case ct.Z.RELATION:return e.createElement(ls,{displayedValue:o.displayedValue,status:o.status,width:o.width});default:return null}}const us=()=>{const t=(0,le.$B)("/content-manager/:kind/:uid"),{status:o,collectionTypeLinks:r,singleTypeLinks:a,models:s,refetchData:l}=Yp(),c=Ke()([...r,...a],g=>g.title.toLowerCase()),{pathname:d}=(0,le.TH)(),{formatMessage:p}=(0,H.Z)(),{startSection:m}=(0,f.c1)(),u=(0,e.useRef)(m),h=(0,re.v9)(Pe._);if((0,e.useEffect)(()=>{u.current&&u.current("contentManager")},[]),o==="loading")return e.createElement(Te.o,{"aria-busy":"true"},e.createElement(Oe.T,{title:p({id:(0,Ve.Z)("header.name"),defaultMessage:"Content"})}),e.createElement(f.dO,null));const E=s.filter(({isDisplayed:g})=>g);return c.length===0&&E.length>0&&d!=="/content-manager/403"?e.createElement(le.l_,{to:"/content-manager/403"}):E.length===0&&d!=="/content-manager/no-content-types"?e.createElement(le.l_,{to:"/content-manager/no-content-types"}):!t&&c.length>0?e.createElement(le.l_,{to:`${c[0].to}${c[0].search?`?${c[0].search}`:""}`}):e.createElement(Ge.A,{sideNav:e.createElement(zp,null)},e.createElement(lt.r,{renderItem:Xp}),e.createElement(Tt.Provider,{value:{refetchData:l}},e.createElement(le.rs,null,e.createElement(le.AW,{path:"/content-manager/components/:uid/configurations/edit"},e.createElement(f.O4,{permissions:h.contentManager.componentsConfigurations},e.createElement(Pp,null))),e.createElement(le.AW,{path:"/content-manager/collectionType/:slug",component:Op}),e.createElement(le.AW,{path:"/content-manager/singleType/:slug",component:kp}),e.createElement(le.AW,{path:"/content-manager/403"},e.createElement(Lp,null)),e.createElement(le.AW,{path:"/content-manager/no-content-types"},e.createElement(xp,null)),e.createElement(le.AW,{path:"",component:f.Hn}))))};function Jp(){const{formatMessage:t}=(0,H.Z)();return e.createElement(e.Fragment,null,e.createElement(ze.q,{title:t({id:(0,Ve.Z)("plugin.name"),defaultMessage:"Content Manager"})}),e.createElement(us,null))}},98865:function(an,et,i){"use strict";i.d(et,{d:function(){return wt}});var e=i(32735),Te=i(87933),Oe=i(49372),Ge=i(72850),f=i(9026),Qe=i(19565),Ke=i(60216),ze=i.n(Ke),H=i(67879),re=i(69997);const le=60*1e3,lt=le*60,Pe=lt*24,Mt=Pe*30,Tt=Pe*365;var ct=ye=>ye<le?{unit:"second",value:-Math.round(ye/1e3)}:ye<lt?{unit:"minute",value:-Math.round(ye/le)}:ye<Pe?{unit:"hour",value:-Math.round(ye/lt)}:ye<Mt?{unit:"day",value:-Math.round(ye/Pe)}:ye<Tt?{unit:"month",value:-Math.round(ye/Mt)}:{unit:"year",value:-Math.round(ye/Tt)};const xe=()=>{const{formatMessage:ye}=(0,H.Z)();return e.createElement(Te.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(Oe.Z,{variant:"sigma",textColor:"neutral600",id:"additional-information"},ye({id:(0,re.OB)("containers.Edit.information"),defaultMessage:"Information"})),e.createElement(Ge.x,null,e.createElement(f.i,null)))},n=({label:ye,value:be})=>e.createElement(Te.k,{justifyContent:"space-between"},e.createElement(Oe.Z,{as:"dt",fontWeight:"bold",textColor:"neutral800",variant:"pi"},ye),e.createElement(Oe.Z,{as:"dd",variant:"pi",textColor:"neutral600"},be));n.defaultProps={value:"-"},n.propTypes={label:ze().string.isRequired,value:ze().string};const sn=()=>{const{formatMessage:ye,formatRelativeTime:be}=(0,H.Z)(),{initialData:y,isCreatingEntry:ue}=(0,Qe.Wq)(),tt=(0,e.useRef)(Date.now()),Q=(Se,ve)=>{const Ue=y[ve]??{},Re=(0,re.Gf)(Ue,ye),dt=(y[Se]?new Date(y[Se]).getTime():Date.now())-tt.current,{unit:we,value:dn}=ct(-dt);return{at:be(dn,we,{numeric:"auto"}),by:ue?"-":Re}},D=Q("updatedAt","updatedBy"),W=Q("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(n,{label:ye({id:(0,re.OB)("containers.Edit.information.created"),defaultMessage:"Created"}),value:W.at}),e.createElement(n,{label:ye({id:(0,re.OB)("containers.Edit.information.by"),defaultMessage:"By"}),value:W.by})),e.createElement(Te.k,{direction:"column",alignItems:"stretch",gap:2,as:"dl"},e.createElement(n,{label:ye({id:(0,re.OB)("containers.Edit.information.lastUpdate"),defaultMessage:"Last update"}),value:D.at}),e.createElement(n,{label:ye({id:(0,re.OB)("containers.Edit.information.by"),defaultMessage:"By"}),value:D.by})))},ln=({children:ye})=>e.createElement(Te.k,{direction:"column",alignItems:"stretch",gap:4},ye);ln.propTypes={children:ze().oneOfType([ze().arrayOf(ze().node),ze().node]).isRequired};const wt={Root:ln,Title:xe,Body:sn}},97108:function(an,et,i){"use strict";i.d(et,{R:function(){return Oe}});var e=i(19565),Te=i(20108);function Oe(Ge={},f={}){const{id:Qe="",...Ke}=Ge,{get:ze}=(0,e.kY)(),{data:H,isError:re,isLoading:le,refetch:lt}=(0,Te.useQuery)(["users",Qe,Ke],async()=>{const{data:{data:Mt}}=await ze(`/admin/users/${Qe}`,{params:Ke});return Mt},f);let Pe=[];return Qe&&H?Pe=[H]:Array.isArray(H?.results)&&(Pe=H.results),{users:Pe,pagination:H?.pagination??null,isLoading:le,isError:re,refetch:lt}}},99097:function(an,et,i){"use strict";var e=i(32735);const Te=(Oe,Ge)=>{const[f,Qe]=(0,e.useState)(Oe);return(0,e.useEffect)(()=>{const Ke=setTimeout(()=>{Qe(Oe)},Ge);return()=>{clearTimeout(Ke)}},[Oe,Ge]),f};et.Z=Te},57544:function(){},59599:function(){},42310:function(){},33842:function(){},85695:function(){}}]);
|