@strapi/admin 4.9.0-exp.90df253ba90fd6879eb56a720a1f80d04ff745b8 → 4.9.1
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/.eslintignore +4 -0
- package/.eslintrc.js +14 -0
- package/admin/src/components/LocalesProvider/__mocks__/useLocalesProvider.js +7 -0
- package/admin/src/content-manager/components/DynamicZone/utils/select.js +1 -1
- package/admin/src/content-manager/components/EditViewDataManagerProvider/reducer.js +3 -1
- package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/findAllAndReplace.js +10 -3
- package/admin/src/content-manager/components/FieldComponent/utils/select.js +2 -1
- package/admin/src/content-manager/components/InputUID/endActionStyle.js +4 -13
- package/admin/src/content-manager/components/InputUID/index.js +94 -71
- package/admin/src/content-manager/components/Inputs/utils/getInputType.js +1 -1
- package/admin/src/content-manager/components/Inputs/utils/select.js +1 -1
- package/admin/src/content-manager/hooks/useContentTypeLayout/index.js +1 -2
- package/admin/src/content-manager/hooks/useFetchContentTypeLayout/utils/formatLayouts.js +4 -1
- package/admin/src/content-manager/pages/App/index.js +2 -2
- package/admin/src/content-manager/pages/CollectionTypeRecursivePath/index.js +1 -2
- package/admin/src/content-manager/pages/EditSettingsView/init.js +3 -1
- package/admin/src/content-manager/pages/EditSettingsView/utils/createPossibleMainFieldsForModelsAndComponents.js +2 -4
- package/admin/src/content-manager/pages/EditView/DeleteLink/utils/select.js +1 -1
- package/admin/src/content-manager/pages/EditView/utils/createAttributesLayout.js +2 -1
- package/admin/src/content-manager/pages/EditView/utils/getFieldsActionMatchingPermissions.js +2 -1
- package/admin/src/content-manager/utils/checkIfAttributeIsDisplayable.js +1 -1
- package/admin/src/content-manager/utils/createDefaultForm.js +2 -2
- package/admin/src/content-manager/utils/formatLayoutToApi.js +2 -1
- package/admin/src/content-manager/utils/getFieldName.js +1 -1
- package/admin/src/content-manager/utils/mergeMetasWithSchema.js +1 -1
- package/admin/src/content-manager/utils/paths.js +1 -1
- package/admin/src/content-manager/utils/removePasswordFieldsFromData.js +1 -1
- package/admin/src/hooks/useConfigurations/__mocks__/index.js +7 -0
- package/admin/src/hooks/useRegenerate/index.js +12 -7
- package/admin/src/hooks/useSettingsForm/index.js +3 -3
- package/admin/src/hooks/useSettingsForm/reducer.js +3 -1
- package/admin/src/hooks/useSettingsMenu/reducer.js +1 -1
- package/admin/src/pages/AuthPage/components/Register/index.js +46 -38
- package/admin/src/pages/AuthPage/reducer.js +1 -1
- package/admin/src/pages/MarketplacePage/components/EmptyNpmPackageSearch/index.js +2 -2
- package/admin/src/pages/SettingsPage/components/Tokens/FormHead/index.js +4 -0
- package/admin/src/pages/SettingsPage/components/Tokens/Regenerate/index.js +5 -3
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/CollapsableContentType/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/reducer.js +1 -1
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/utils/transformPermissionsData.js +6 -8
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/ConditionsModal/utils/createDefaultConditionsForm.js +1 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/ContentTypeCollapse/Collapse/utils/generateCheckboxesActions.js +2 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/ContentTypeCollapse/CollapsePropertyMatrix/ActionRow/utils/getRowLabelCheckboxeState.js +2 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/GlobalActions/utils/getRowLabelCheckboxesState.js +1 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/reducer.js +6 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/utils/createDefaultCTFormFromLayout.js +5 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/utils/createDefaultPluginsFormFromLayout.js +1 -2
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/utils/formatContentTypesPermissionToAPI.js +2 -2
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/utils/updateConditionsToFalse.js +4 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/utils/updateValues.js +1 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/PluginsAndSettings/SubCategory/utils/formatActions.js +1 -1
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/utils/createArrayOfValues.js +2 -1
- package/admin/src/pages/SettingsPage/pages/Roles/ListPage/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/index.js +47 -5
- package/admin/src/pages/SettingsPage/pages/TransferTokens/ListView/index.js +27 -5
- package/admin/src/pages/SettingsPage/pages/Users/ProtectedEditPage/index.js +2 -2
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/utils/formatData.js +1 -7
- package/admin/src/permissions/index.js +1 -1
- package/admin/src/translations/en.json +1 -0
- package/admin/src/utils/getAttributesToDisplay.js +2 -4
- package/admin/src/utils/getExistingActions.js +1 -3
- package/admin/src/utils/sortLinks.js +1 -1
- package/build/1387.84b454d3.chunk.js +1 -0
- package/build/1657.45231968.chunk.js +168 -0
- package/build/3081.bcf9a12f.chunk.js +108 -0
- package/build/462.8fff7f3b.chunk.js +71 -0
- package/build/4628.20631dd1.chunk.js +1 -0
- package/build/5542.b8240e3f.chunk.js +70 -0
- package/build/5563.905daa13.chunk.js +79 -0
- package/build/6404.68405699.chunk.js +100 -0
- package/build/7259.b7d00cea.chunk.js +1 -0
- package/build/8694.6522968d.chunk.js +247 -0
- package/build/9347.058ddb22.chunk.js +1 -0
- package/build/Admin-authenticatedApp.a168aa38.chunk.js +79 -0
- package/build/Admin_InternalErrorPage.15c6bf07.chunk.js +1 -0
- package/build/Admin_homePage.da2181fe.chunk.js +73 -0
- package/build/Admin_marketplace.99e25059.chunk.js +31 -0
- package/build/Admin_pluginsPage.f6b52ee9.chunk.js +6 -0
- package/build/Admin_profilePage.9112cffc.chunk.js +15 -0
- package/build/Admin_settingsPage.cb63220f.chunk.js +79 -0
- package/build/Upload_ConfigureTheView.eaaec495.chunk.js +1 -0
- package/build/admin-app.8cde5b22.chunk.js +110 -0
- package/build/admin-edit-roles-page.4f1858e9.chunk.js +280 -0
- package/build/admin-edit-users.7e14d85f.chunk.js +10 -0
- package/build/admin-roles-list.97e198f9.chunk.js +31 -0
- package/build/admin-users.d02de059.chunk.js +34 -0
- package/build/api-tokens-create-page.97595e12.chunk.js +1 -0
- package/build/api-tokens-edit-page.cd36e30e.chunk.js +1 -0
- package/build/api-tokens-list-page.6757c7b9.chunk.js +16 -0
- package/build/audit-logs-settings-page.ca9a3c46.chunk.js +76 -0
- package/build/content-manager.ba088a66.chunk.js +1132 -0
- package/build/content-type-builder-list-view.9c2c020c.chunk.js +214 -0
- package/build/content-type-builder.fef159db.chunk.js +126 -0
- package/build/email-settings-page.1095e1ab.chunk.js +10 -0
- package/build/{en-json.01a88a30.chunk.js → en-json.b052667a.chunk.js} +1 -1
- package/build/{highlight.js.26ef649f.chunk.js → highlight.js.28a1547e.chunk.js} +2 -2
- package/build/i18n-settings-page.7d80aae0.chunk.js +60 -0
- package/build/index.html +1 -1
- package/build/main.0df5f5ca.js +2280 -0
- package/build/{runtime~main.a40b1b57.js → runtime~main.03cdff31.js} +2 -2
- package/build/sso-settings-page.1dd4886e.chunk.js +1 -0
- package/build/transfer-tokens-create-page.ec2ca215.chunk.js +1 -0
- package/build/transfer-tokens-edit-page.22bf28e5.chunk.js +1 -0
- package/build/transfer-tokens-list-page.cf8c77f2.chunk.js +16 -0
- package/build/upload-settings.945fdcfa.chunk.js +13 -0
- package/build/upload-translation-fr-json.baab9911.chunk.js +1 -0
- package/build/{upload-translation-th-json.3847dae0.chunk.js → upload-translation-th-json.98d35574.chunk.js} +1 -1
- package/build/upload.a86b1054.chunk.js +33 -0
- package/build/users-advanced-settings-page.5b5a9baa.chunk.js +8 -0
- package/build/users-email-settings-page.e5506eb4.chunk.js +23 -0
- package/build/users-providers-settings-page.e32089c2.chunk.js +28 -0
- package/build/users-roles-settings-page.9359e4d1.chunk.js +30 -0
- package/build/webhook-edit-page.213f0075.chunk.js +75 -0
- package/build/webhook-list-page.5beb2a5c.chunk.js +71 -0
- package/ee/server/bootstrap.js +3 -0
- package/ee/server/register.js +3 -2
- package/ee/server/services/audit-logs.js +75 -16
- package/ee/server/utils/persisted-tables.js +49 -0
- package/jest.config.front.js +1 -6
- package/package.json +27 -25
- package/server/middlewares/data-transfer.js +4 -1
- package/server/services/permission/permissions-manager/sanitize.js +2 -0
- package/webpack.config.js +1 -1
- package/build/2637.679b590b.chunk.js +0 -1
- package/build/4049.64715f20.chunk.js +0 -1
- package/build/5563.451e91ee.chunk.js +0 -30
- package/build/7112.2bf13da3.chunk.js +0 -14
- package/build/7259.7744297b.chunk.js +0 -1
- package/build/8469.853c822b.chunk.js +0 -1
- package/build/8580.b0dcf37c.chunk.js +0 -98
- package/build/9816.01ee964f.chunk.js +0 -2
- package/build/Admin-authenticatedApp.5aa08bf5.chunk.js +0 -79
- package/build/Admin_InternalErrorPage.4ad8b0df.chunk.js +0 -1
- package/build/Admin_homePage.1411fb7c.chunk.js +0 -68
- package/build/Admin_marketplace.0f6c8ee2.chunk.js +0 -22
- package/build/Admin_pluginsPage.15e3b0fd.chunk.js +0 -1
- package/build/Admin_profilePage.d2a8f9ab.chunk.js +0 -15
- package/build/Admin_settingsPage.489ec4eb.chunk.js +0 -9
- package/build/Upload_ConfigureTheView.34dde278.chunk.js +0 -1
- package/build/admin-app.4b313104.chunk.js +0 -112
- package/build/admin-edit-roles-page.3b196317.chunk.js +0 -216
- package/build/admin-edit-users.af3b0f15.chunk.js +0 -10
- package/build/admin-roles-list.0ad504a7.chunk.js +0 -2
- package/build/admin-users.af8c3123.chunk.js +0 -11
- package/build/api-tokens-create-page.2a6e22bd.chunk.js +0 -1
- package/build/api-tokens-edit-page.fa38cd63.chunk.js +0 -1
- package/build/api-tokens-list-page.93f24348.chunk.js +0 -16
- package/build/audit-logs-settings-page.7be97e82.chunk.js +0 -1
- package/build/content-manager.f530e141.chunk.js +0 -1139
- package/build/content-type-builder-list-view.cf38fe2f.chunk.js +0 -191
- package/build/content-type-builder.6ecd201d.chunk.js +0 -126
- package/build/email-settings-page.4bdbef9a.chunk.js +0 -3
- package/build/i18n-settings-page.2bb5be96.chunk.js +0 -1
- package/build/main.43b93ff3.js +0 -3843
- package/build/sso-settings-page.5a8588ef.chunk.js +0 -1
- package/build/transfer-tokens-create-page.a1f14bb1.chunk.js +0 -1
- package/build/transfer-tokens-edit-page.00ee1c74.chunk.js +0 -1
- package/build/transfer-tokens-list-page.ce37354b.chunk.js +0 -16
- package/build/upload-settings.0200561d.chunk.js +0 -1
- package/build/upload-translation-fr-json.84429734.chunk.js +0 -1
- package/build/upload.c7da1611.chunk.js +0 -13
- package/build/users-advanced-settings-page.c0cae03a.chunk.js +0 -1
- package/build/users-email-settings-page.a3c80419.chunk.js +0 -1
- package/build/users-providers-settings-page.5f86e45c.chunk.js +0 -1
- package/build/users-roles-settings-page.b02986df.chunk.js +0 -30
- package/build/webhook-edit-page.a2a2b7bb.chunk.js +0 -23
- package/build/webhook-list-page.029957a4.chunk.js +0 -1
|
@@ -1,1139 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_strapi_admin=self.webpackChunk_strapi_admin||[]).push([[994],{58153:function(Ou,Zn,D){"use strict";D.r(Zn),D.d(Zn,{App:function(){return rs},default:function(){return Du}});var t=D(32735),os=D(99357),oe=D(5141),h=D(13478),i=D(39161),Z=D(5636),ss=D(98978),Qn=D.n(ss),qe=D(72041),C=e=>`content-manager.${e}`,Le=D(74506),Ee=D(60216),n=D.n(Ee),Kn=(0,t.createContext)();function Ct({attributes:e,buttonData:r,children:o,goTo:s,layout:a,metadatas:c,moveItem:l,moveRow:d,onAddData:u,relationsLayout:m,removeField:g,selectedItemName:f,setEditFieldToSelect:p,...y}){return t.createElement(Kn.Provider,{value:{attributes:e,buttonData:r,goTo:s,layout:a,metadatas:c,moveItem:l,moveRow:d,onAddData:u,relationsLayout:m,removeField:g,selectedItemName:f,setEditFieldToSelect:p,...y}},o)}Ct.defaultProps={attributes:{},buttonData:[],goTo(){},layout:[],metadatas:{},moveItem(){},moveRow(){},onAddData(){},relationsLayout:[],removeField(){},selectedItemName:null,setEditFieldToSelect(){}},Ct.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};var Yn=Ct,he={COMPONENT:"component",EDIT_FIELD:"editField",FIELD:"field",DYNAMIC_ZONE:"dynamicZone",RELATION:"relation"},q=D(83292),L=D(57269),Xn=e=>e.length>20?`${e.substring(0,20)}...`:e;const Rt=(0,q.default)(i.Flex)`
|
|
2
|
-
height: ${({theme:e})=>e.spaces[7]};
|
|
3
|
-
|
|
4
|
-
&:last-child {
|
|
5
|
-
padding: 0 ${({theme:e})=>e.spaces[3]};
|
|
6
|
-
}
|
|
7
|
-
`,Jn=(0,q.default)(Rt)`
|
|
8
|
-
padding: 0 ${({theme:e})=>e.spaces[3]};
|
|
9
|
-
border-right: 1px solid ${({theme:e})=>e.colors.neutral150};
|
|
10
|
-
cursor: all-scroll;
|
|
11
|
-
|
|
12
|
-
svg {
|
|
13
|
-
width: ${12/16}rem;
|
|
14
|
-
height: ${12/16}rem;
|
|
15
|
-
}
|
|
16
|
-
`,as=(0,q.default)(i.Flex)`
|
|
17
|
-
display: inline-flex;
|
|
18
|
-
max-height: ${32/16}rem;
|
|
19
|
-
opacity: ${({transparent:e})=>e?0:1};
|
|
20
|
-
background-color: ${({theme:e,isSibling:r})=>r?e.colors.neutral100:e.colors.primary100};
|
|
21
|
-
border: 1px solid
|
|
22
|
-
${({theme:e,isSibling:r})=>r?e.colors.neutral150:e.colors.primary200};
|
|
23
|
-
|
|
24
|
-
svg {
|
|
25
|
-
width: ${10/16}rem;
|
|
26
|
-
height: ${10/16}rem;
|
|
27
|
-
|
|
28
|
-
path {
|
|
29
|
-
fill: ${({theme:e,isSibling:r})=>r?void 0:e.colors.primary600};
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
${i.Typography} {
|
|
34
|
-
color: ${({theme:e,isSibling:r})=>r?void 0:e.colors.primary600};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
${Jn} {
|
|
38
|
-
border-right: 1px solid
|
|
39
|
-
${({theme:e,isSibling:r})=>r?e.colors.neutral150:e.colors.primary200};
|
|
40
|
-
}
|
|
41
|
-
`,vt=({labelField:e,transparent:r,isSibling:o})=>{const s=Xn(e);return t.createElement(as,{hasRadius:!0,justifyContent:"space-between",transparent:r,isSibling:o},t.createElement(i.Flex,{gap:3},t.createElement(Jn,{alignItems:"center"},t.createElement(L.Drag,null)),t.createElement(i.Typography,{fontWeight:"bold"},s)),t.createElement(i.Flex,{paddingLeft:3},t.createElement(Rt,{alignItems:"center"},t.createElement(L.Pencil,null)),t.createElement(Rt,{alignItems:"center"},t.createElement(L.Cross,null))))};vt.defaultProps={isSibling:!1,transparent:!1},vt.propTypes={isSibling:n().bool,labelField:n().string.isRequired,transparent:n().bool};var Tt=vt;const is=(0,q.default)(i.Box)`
|
|
42
|
-
border: 1px solid ${({theme:e})=>e.colors.neutral200};
|
|
43
|
-
`,ls=(0,q.default)(i.Box)`
|
|
44
|
-
height: ${32/16}rem;
|
|
45
|
-
width: ${32/16}rem;
|
|
46
|
-
border-radius: 50%;
|
|
47
|
-
display: flex;
|
|
48
|
-
align-items: center;
|
|
49
|
-
justify-content: center;
|
|
50
|
-
|
|
51
|
-
svg {
|
|
52
|
-
height: ${6/16}rem;
|
|
53
|
-
width: ${11/16}rem;
|
|
54
|
-
> path {
|
|
55
|
-
fill: ${({theme:e})=>e.colors.neutral600};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
`,cs=q.default.button`
|
|
59
|
-
border: none;
|
|
60
|
-
background: transparent;
|
|
61
|
-
display: block;
|
|
62
|
-
width: 100%;
|
|
63
|
-
text-align: unset;
|
|
64
|
-
padding: 0;
|
|
65
|
-
`,er=({displayedValue:e})=>t.createElement(is,{paddingLeft:3,paddingRight:3,paddingTop:3,paddingBottom:3,hasRadius:!0,background:"neutral0",width:(0,h.pxToRem)(300)},t.createElement(i.Flex,{justifyContent:"space-between"},t.createElement(cs,{type:"button"},t.createElement(i.Flex,null,t.createElement(ls,{background:"neutral200"},t.createElement(L.CarretDown,null)),t.createElement(i.Flex,{gap:2,paddingLeft:6,maxWidth:(0,h.pxToRem)(150)},t.createElement(i.Typography,{textColor:"neutral700",ellipsis:!0},e)))),t.createElement(i.Box,{paddingLeft:3},t.createElement(i.Flex,null,t.createElement(i.IconButton,{noBorder:!0},t.createElement(L.Trash,null)),t.createElement(i.Box,{paddingLeft:2},t.createElement(i.IconButton,{noBorder:!0},t.createElement(L.Drag,null)))))));er.propTypes={displayedValue:n().string.isRequired};var tr=er,ds=D(99381),Te=D.n(ds),rt=(e,r,o)=>{if(Array.isArray(e)&&r>=0&&o>=0&&r<=e.length-1&&o<=e.length-1){const s=Te()(e),a=s.splice(r,1);return s.splice(o,0,a[0]),s}return e},te=D(92891),nr=e=>{const r=e.type;return r==="relation"?!(0,te.toLower)(e.relationType).includes("morph"):!["json","dynamiczone","richtext","password"].includes(r)&&!!r};const us=(e,r)=>{typeof e=="function"?e(r):e!=null&&(e.current=r)},ot=(...e)=>r=>e.forEach(o=>us(o,r)),rr=(e,r)=>Object.keys(e).reduce((o,s)=>{const a=(0,te.get)(e,[s],{}),{default:c,component:l,type:d,required:u,min:m,repeatable:g}=a;if(c!==void 0&&(o[s]=c),d==="component"){const f=(0,te.get)(r,[l,"attributes"],{}),p=rr(f,r);if(u===!0&&(o[s]=g===!0?[]:p),m&&g===!0&&u){o[s]=[];for(let y=0;y<m;y+=1)o[s].push(p)}}return d==="dynamiczone"&&u===!0&&(o[s]=[]),o},{});var st=rr,at=({layouts:e,metadatas:r,...o})=>{const s=e.list.map(l=>l.name?l.name:l),a=Object.keys(r).reduce((l,d)=>{const u=(0,te.get)(r,[d],{});let m=u.edit;return m.mainField&&(m={...m,mainField:u.edit.mainField.name}),{...l,[d]:{edit:m,list:(0,te.omit)(u.list,["mainField"])}}},{}),c=e.edit.map(l=>l.map(({name:d,size:u})=>({name:d,size:u})));return{...o,layouts:{edit:c,list:s},metadatas:a}};const ms=(e,r)=>e.map(o=>({...o,subject:r}));var or=e=>{const r={create:[{action:"plugin::content-manager.explorer.create",subject:null}],delete:[{action:"plugin::content-manager.explorer.delete",subject:null}],publish:[{action:"plugin::content-manager.explorer.publish",subject:null}],read:[{action:"plugin::content-manager.explorer.read",subject:null}],update:[{action:"plugin::content-manager.explorer.update",subject:null}]};return Object.keys(r).reduce((o,s)=>(o[s]=ms(r[s],e),o),{})},sr=e=>e.split(".").filter(r=>(0,te.isNaN)(parseInt(r,10))),Mt=e=>{if(e.length===0)return-1;const r=Math.max.apply(Math,e.map(o=>o.__temp_key__??0));return Number.isNaN(r)?-1:r},ce=e=>`/content-manager/${e}`,ar=(e,r,o)=>{const s=d=>r.find(u=>u.uid===d),a=Object.assign({},e),c=e[o].uid,l=s(c);return(0,te.set)(a,[o],{...e[o],...l}),Object.keys(e.components).forEach(d=>{const u=s(d);(0,te.set)(a,["components",d],{...e.components[d],...u})}),a},ir=(e,r,o)=>{const s=(a,c)=>Object.keys(a).reduce((l,d)=>{const u=(0,h.getType)(c,d),m=(0,te.get)(a,d),g=(0,h.getOtherInfos)(c,[d,"component"]),f=(0,h.getOtherInfos)(c,[d,"repeatable"]);return u==="dynamiczone"?(l[d]=m.map(p=>s(p,o[p.__component])),l):u==="component"?(f?l[d]=m&&m.map(p=>s(p,o[g])):l[d]=m&&s(m,o[g]),l):(u!=="password"&&(l[d]=m),l)},{});return s(e,r)};const Se={DRAFT:"draft",PUBLISHED:"published"},Dt=5,ps=10;var Ue=D(51968);const gs=(e,r,{onCancel:o,onDropItem:s,onGrabItem:a,onMoveItem:c})=>{const[l,d]=(0,t.useState)(!1),u=p=>{l&&(p==="UP"?c(r-1,r):p==="DOWN"&&c(r+1,r))},m=()=>{l?(s&&s(r),d(!1)):(a&&a(r),d(!0))},g=()=>{l&&(d(!1),o&&o(r))};return p=>{if(e&&!(p.key==="Tab"&&!l))switch(p.preventDefault(),p.key){case" ":case"Enter":m();break;case"Escape":g();break;case"ArrowDown":case"ArrowRight":u("DOWN");break;case"ArrowUp":case"ArrowLeft":u("UP");break;default:}}},kt=(e,{type:r="STRAPI_DND",index:o,item:s={},onStart:a,onEnd:c,onGrabItem:l,onDropItem:d,onCancel:u,onMoveItem:m,dropSensitivity:g="regular"})=>{const f=(0,t.useRef)(null),[{handlerId:p},y]=(0,Le.useDrop)({accept:r,collect(R){return{handlerId:R.getHandlerId()}},hover(R,S){if(!f.current)return;const A=R.index,T=o;if(A!==T){if(g==="regular"){const k=f.current.getBoundingClientRect(),F=(k.bottom-k.top)/2,z=S.getClientOffset().y-k.top;if(A<T&&z<F||A>T&&z>F)return}m(T,A),R.index=T}}}),[{isDragging:b},v,I]=(0,Le.useDrag)({type:r,item(){a&&a();const{width:R}=f.current?.getBoundingClientRect()??{};return{index:o,width:R,...s}},end(){c&&c()},canDrag:e,isDragging:s.id?R=>s.id===R.getItem().id:void 0,collect:R=>({isDragging:R.isDragging()})}),E=gs(e,o,{onGrabItem:l,onDropItem:d,onCancel:u,onMoveItem:m});return[{handlerId:p,isDragging:b,handleKeyDown:E},f,y,v,I]},it=50,Be=4,lr=(0,q.default)(i.Flex)`
|
|
66
|
-
width: 100%;
|
|
67
|
-
/* Used to prevent endAction to be pushed out of container */
|
|
68
|
-
min-width: 0;
|
|
69
|
-
|
|
70
|
-
& > div[role='button'] {
|
|
71
|
-
cursor: all-scroll;
|
|
72
|
-
}
|
|
73
|
-
`,cr=(0,q.default)(i.Flex)`
|
|
74
|
-
width: 100%;
|
|
75
|
-
/* Used to prevent endAction to be pushed out of container */
|
|
76
|
-
min-width: 0;
|
|
77
|
-
`,It=({ariaDescribedBy:e,children:r,displayValue:o,canDrag:s,disabled:a,endAction:c,iconButtonAriaLabel:l,style:d,id:u,index:m,name:g,onCancel:f,onDropItem:p,onGrabItem:y,status:b,updatePositionOfRelation:v,...I})=>{const[{handlerId:E,isDragging:R,handleKeyDown:S},A,T,k,F]=kt(s&&!a,{type:`${he.RELATION}_${g}`,index:m,item:{displayedValue:o,status:b,id:u},onGrabItem:y,onDropItem:p,onCancel:f,onMoveItem:v,dropSensitivity:"immediate"}),_=ot(A,k);return(0,t.useEffect)(()=>{F((0,Ue.rX)())},[F]),t.createElement(i.Box,{style:d,as:"li",ref:T,"aria-describedby":e,cursor:s?"all-scroll":"default"},R?t.createElement(fs,null):t.createElement(i.Flex,{paddingTop:2,paddingBottom:2,paddingLeft:s?2:4,paddingRight:4,hasRadius:!0,borderSize:1,borderColor:"neutral200",background:a?"neutral150":"neutral0",justifyContent:"space-between",ref:s?_:void 0,"data-handler-id":E,...I},t.createElement(lr,{gap:1},s?t.createElement(i.IconButton,{forwardedAs:"div",role:"button",tabIndex:0,"aria-label":l,noBorder:!0,onKeyDown:S,disabled:a},t.createElement(L.Drag,null)):null,t.createElement(cr,{justifyContent:"space-between"},r)),c&&t.createElement(i.Box,{paddingLeft:4},c)))},fs=()=>t.createElement(i.Box,{paddingTop:2,paddingBottom:2,paddingLeft:4,paddingRight:4,hasRadius:!0,borderStyle:"dashed",borderColor:"primary600",borderWidth:"1px",background:"primary100",height:`calc(100% - ${Be}px)`});It.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},It.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};var hs=D(54450);const xt=({children:e,loadMore:r,search:o,totalNumberOfRelations:s,size:a,...c})=>t.createElement(t.Fragment,null,t.createElement(i.Flex,{paddingBottom:s>0?3:0,gap:2,justifyContent:"space-between",alignItems:"end",wrap:"wrap"},t.createElement(i.Flex,{direction:"column",alignItems:"stretch",basis:a<=6?"100%":"70%",gap:1,...c},o),r),e);xt.defaultProps={search:void 0,loadMore:void 0,totalNumberOfRelations:0},xt.propTypes={children:n().node.isRequired,search:n().node,loadMore:n().node,size:n().number.isRequired,totalNumberOfRelations:n().number};const ys=(0,q.default)(i.Box)`
|
|
78
|
-
position: relative;
|
|
79
|
-
overflow-x: hidden;
|
|
80
|
-
overflow-y: auto;
|
|
81
|
-
|
|
82
|
-
&:before,
|
|
83
|
-
&:after {
|
|
84
|
-
position: absolute;
|
|
85
|
-
width: 100%;
|
|
86
|
-
height: 4px;
|
|
87
|
-
z-index: 1;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
&:before {
|
|
91
|
-
/* TODO: as for DS Table component we would need this to be handled by the DS theme */
|
|
92
|
-
content: '';
|
|
93
|
-
background: linear-gradient(rgba(3, 3, 5, 0.2) 0%, rgba(0, 0, 0, 0) 100%);
|
|
94
|
-
top: 0;
|
|
95
|
-
opacity: ${({overflowDirection:e})=>e==="top-bottom"||e==="top"?1:0};
|
|
96
|
-
transition: opacity 0.2s ease-in-out;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
&:after {
|
|
100
|
-
/* TODO: as for DS Table component we would need this to be handled by the DS theme */
|
|
101
|
-
content: '';
|
|
102
|
-
background: linear-gradient(0deg, rgba(3, 3, 5, 0.2) 0%, rgba(0, 0, 0, 0) 100%);
|
|
103
|
-
bottom: 0;
|
|
104
|
-
opacity: ${({overflowDirection:e})=>e==="top-bottom"||e==="bottom"?1:0};
|
|
105
|
-
transition: opacity 0.2s ease-in-out;
|
|
106
|
-
}
|
|
107
|
-
`,wt=({children:e,overflow:r,...o})=>t.createElement(ys,{overflowDirection:r,...o},e);wt.defaultProps={overflow:""},wt.propTypes={children:n().node.isRequired,overflow:n().oneOf(["top-bottom","bottom","top",""])};var bs=D(65384);const Es=q.default.div`
|
|
108
|
-
flex-shrink: 0;
|
|
109
|
-
width: ${(0,h.pxToRem)(6)};
|
|
110
|
-
height: ${(0,h.pxToRem)(6)};
|
|
111
|
-
margin-right: ${({theme:e})=>e.spaces[2]};
|
|
112
|
-
background-color: ${({theme:e,isDraft:r})=>e.colors[r?"secondary600":"success600"]};
|
|
113
|
-
border-radius: 50%;
|
|
114
|
-
`,dr=e=>{const{formatMessage:r}=(0,Z.useIntl)(),o=bs.components.Option,{publicationState:s,mainField:a,id:c}=e.data;if(s){const l=s==="draft",d={id:C("components.Select.draft-info-title"),defaultMessage:"State: Draft"},u={id:C("components.Select.publish-info-title"),defaultMessage:"State: Published"},m=r(l?d:u);return t.createElement(o,{...e},t.createElement(i.Flex,null,t.createElement(Es,{title:m,isDraft:l}),t.createElement(i.Typography,{ellipsis:!0},a??c)))}return t.createElement(o,{...e},a??c)};dr.propTypes={isFocused:n().bool.isRequired,data:n().shape({id:n().number.isRequired,isDraft:n().bool,mainField:n().string,publicationState:n().oneOfType([n().string,n().bool])}).isRequired};var le=D(4409),ur=e=>e["content-manager_editViewLayoutManager"].currentLayout,De=()=>{const e=(0,le.useSelector)(ur),r=(0,t.useCallback)(o=>(0,te.get)(e,["components",o],{}),[e]);return{...e,getComponentLayout:r}},ye=D(55721);const mr=(e,r)=>r.find(o=>o.uid===e),Cs=(e,r)=>{const o=Rs(e,r),s=pr(o.contentType,r),a=vs(o.contentType,o.components);return(0,te.set)(o,["contentType","layouts","edit"],s),(0,te.set)(o,["contentType","layouts","list"],a),Object.keys(o.components).forEach(c=>{const l=pr(o.components[c],r);(0,te.set)(o,["components",c,"layouts","edit"],l)}),o},Rs=(e,r)=>{const o=ar((0,te.cloneDeep)(e),r,"contentType"),{components:s,contentType:a}=o,c=l=>Object.keys(l.metadatas).reduce((d,u)=>{const m=(0,te.get)(l,["attributes",u],{});let g=l.metadatas[u];if(m.type==="relation"){const f=mr(m.targetModel,r),p=g.edit.mainField,y={name:p,schema:(0,te.get)(f,["attributes",p])};g={list:{...g.list,mainField:y},edit:{...g.edit,mainField:y}}}return d[u]=g,d},{});return(0,te.set)(o,["contentType","metadatas"],c(a)),Object.keys(s).forEach(l=>{const d=s[l],u=c(d);(0,te.set)(o,["components",l,"metadatas"],u)}),o},pr=(e,r)=>e.layouts.edit.reduce((o,s)=>{const a=s.map(c=>{const l=(0,te.get)(e,["attributes",c.name],{}),d={...c,fieldSchema:l,metadatas:(0,te.get)(e,["metadatas",c.name,"edit"],{})};if(l.type==="relation"){const m=mr(l.targetModel,r).pluginOptions||{};(0,te.set)(d,"targetModelPluginOptions",m),(0,te.set)(d,"queryInfos",{shouldDisplayRelationLink:Ts(e,c.name,r)})}return d});return o.push(a),o},[]),vs=(e,r)=>e.layouts.list.reduce((s,a)=>{const c=(0,te.get)(e,["attributes",a],{}),l=(0,te.get)(e,["metadatas",a,"list"],{}),d=c.type;if(d==="relation")return s.push({key:`__${a}_key__`,name:a,fieldSchema:c,metadatas:l}),s;if(d==="component"){const u=r[c.component],m=u.settings.mainField,g=u.attributes[m];return s.push({key:`__${a}_key__`,name:a,fieldSchema:c,metadatas:{...l,mainField:{...g,name:m}}}),s}return s.push({key:`__${a}_key__`,name:a,fieldSchema:c,metadatas:l}),s},[]),Ts=(e,r,o)=>{const s=(0,te.get)(e,["attributes",r,"targetModel"],"");return Ms(o).includes(s)},Ms=e=>e.filter(r=>r.isDisplayed).map(({uid:r})=>r);var gr=Cs,lt=D(97889);const Ds={error:null,isLoading:!0,layout:{},layouts:{}};var ks=(e,r)=>(0,lt.default)(e,o=>{switch(r.type){case"GET_DATA":{o.isLoading=!0,o.error=null,o.layout={};break}case"GET_DATA_SUCCEEDED":{const s=r.data.contentType.uid;o.layout=r.data,o.layouts[s]=r.data,o.isLoading=!1;break}case"GET_DATA_ERROR":{o.isLoading=!1,o.error=r.error;break}case"SET_LAYOUT_FROM_STATE":{o.error=null,o.layout=e.layouts[r.uid];break}case"UPDATE_LAYOUT":{const s=e.layout;o.layout={...s,contentType:{uid:s.contentType.uid,...r.newLayout.contentType}},o.layouts[s.contentType.uid]={...s,contentType:{uid:s.contentType.uid,...r.newLayout.contentType}};break}default:return o}}),He=D(98178),Is=D(34947);const Ge=()=>e=>e["content-manager_app"]||Is.E,Yu=()=>createSelector(Ge(),e=>e),Xu=()=>createSelector(Ge(),e=>e.models),xs=()=>(0,He.P1)(Ge(),e=>({collectionTypeLinks:e.collectionTypeLinks,singleTypeLinks:e.singleTypeLinks})),Ft=()=>(0,He.P1)(Ge(),({components:e,models:r})=>({schemas:[...e,...r]}));var Ju=null,fr=e=>{const[{error:r,isLoading:o,layout:s,layouts:a},c]=(0,t.useReducer)(ks,Ds),l=(0,t.useMemo)(Ft,[]),{schemas:d}=(0,le.useSelector)(p=>l(p),le.shallowEqual),u=(0,t.useRef)(!0),{get:m}=(0,h.useFetchClient)(),g=(0,t.useCallback)(async(p,y)=>{if(a[p]){c({type:"SET_LAYOUT_FROM_STATE",uid:p});return}c({type:"GET_DATA"});try{const b=ce(`content-types/${p}/configuration`),{data:{data:v}}=await m(b,{cancelToken:y.token});c({type:"GET_DATA_SUCCEEDED",data:gr(v,d)})}catch(b){if(ye.Z.isCancel(b))return;u.current&&console.error(b),u.current&&c({type:"GET_DATA_ERROR",error:b})}},[a,d,m]);(0,t.useEffect)(()=>()=>{u.current=!1},[]),(0,t.useEffect)(()=>{const y=ye.Z.CancelToken.source();return g(e,y),()=>{y.cancel("Operation canceled by the user.")}},[e,g]);const f=(0,t.useCallback)(p=>{c({type:"UPDATE_LAYOUT",newLayout:gr(p,d)})},[d]);return{error:r,isLoading:o,layout:s,updateLayout:f}},ws=e=>e["content-manager_app"].collectionTypeLinks,Me=D(33348),Fs=D(33795),P=D.n(Fs),Ls=D(85973),hr=D.n(Ls);const yr=(e,r)=>Object.keys(e).reduce((o,s)=>{const a=e[s],c=P()(r,[s],a);return hr()(a)?{...o,[s]:yr(a,c)}:(o[s]=c,o)},{});var Ss=(e,r,o)=>{const s=e.find(({to:g})=>g.includes(r));if(!s)return"/";const{to:a,search:c}=s,l=(0,Me.parse)(c),d=(0,Me.parse)(o.substring(1)),u=yr(l,d);return`${a}?${(0,Me.stringify)(u,{encode:!1})}`},br=e=>{const[{rawQuery:r}]=(0,h.useQueryParams)(),o=(0,le.useSelector)(ws);return Ss(o,e,r)},Pe=()=>(0,t.useContext)(Kn),Er=()=>{const{search:e}=(0,oe.useLocation)(),r=e?(0,Me.parse)(e.substring(1)):{};return r.plugins?(0,Me.stringify)({plugins:r.plugins},{encode:!1}):""},Cr=D(89334);const Ps=(e,r,o)=>({type:Cr.m,permissions:e,__meta__:{plugins:r,containerName:o}}),As=()=>({type:Cr.Q}),Os=e=>e["content-manager_rbacManager"].permissions,$s=e=>e.rbacProvider.collectionTypesRelatedPermissions;var Rr=(e,r,o="listView")=>{const s=(0,le.useSelector)($s),a=(0,le.useSelector)(Os),c=(0,le.useDispatch)(),l=s[r];return(0,t.useEffect)(()=>l?(c(Ps(l,e?e.plugins:null,o)),()=>{c(As())}):()=>{},[l,c,e,o]),a};const im=(0,t.createContext)();var lm=null;const cm=()=>useContext(WysiwygContext);var dm=null;const vr=e=>{const r=(0,t.useRef)();return(0,t.useEffect)(()=>{r.current=e},[e]),r.current},Tr=(0,q.default)(i.Link)`
|
|
115
|
-
display: block;
|
|
116
|
-
|
|
117
|
-
> span {
|
|
118
|
-
white-space: nowrap;
|
|
119
|
-
overflow: hidden;
|
|
120
|
-
text-overflow: ellipsis;
|
|
121
|
-
display: block;
|
|
122
|
-
}
|
|
123
|
-
`,Mr=q.default.button`
|
|
124
|
-
svg path {
|
|
125
|
-
fill: ${({theme:e,disabled:r})=>r?e.colors.neutral600:e.colors.neutral500};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
&:hover svg path,
|
|
129
|
-
&:focus svg path {
|
|
130
|
-
fill: ${({theme:e,disabled:r})=>!r&&e.colors.neutral600};
|
|
131
|
-
}
|
|
132
|
-
`,Lt=({canReorder:e,description:r,disabled:o,error:s,iconButtonAriaLabel:a,id:c,name:l,numberOfRelationsToDisplay:d,label:u,labelAction:m,labelLoadMore:g,labelDisconnectRelation:f,listAriaDescription:p,liveText:y,loadingMessage:b,onCancel:v,onDropItem:I,onGrabItem:E,noRelationsMessage:R,onRelationConnect:S,onRelationLoadMore:A,onRelationDisconnect:T,onRelationReorder:k,onSearchNextPage:F,onSearch:_,placeholder:z,publicationStateTranslations:B,required:U,relations:$,searchResults:G,size:W})=>{const[K,N]=(0,t.useState)(null),[X,M]=(0,t.useState)(""),x=(0,t.useRef)(),Q=(0,t.useRef)(),{data:j}=G,O=$.data,V=O.length??0,H=(0,t.useMemo)(()=>V>d?Math.min(V,d)*(it+Be)+it/2:Math.min(V,d)*(it+Be),[V,d]),ae=!!g&&$.hasNextPage,w=(0,t.useMemo)(()=>j.flat().filter(Boolean).map(J=>({...J,value:J.id,label:J.mainField})),[j]);(0,t.useEffect)(()=>{if(V<=d)return M("");const J=Re=>{const Hn=Re.target.parentNode.scrollHeight,Fe=Re.target.scrollHeight-Re.target.scrollTop;return Re.target.scrollTop===0?M("bottom"):M(Fe===Hn?"top":"top-bottom")},me=Q?.current;return!$.isLoading&&O.length>0&&me&&Q.current.addEventListener("scroll",J),()=>{me&&me.removeEventListener("scroll",J)}},[$,O,d,V]);const[re,de]=(0,t.useState)(!1),pe=(0,t.useRef)(),We=(0,t.useRef)([]);(0,t.useEffect)(()=>(w.length>0&&We.current.length===0&&de(J=>(J&&(pe.current=setTimeout(()=>{de(!0)},10)),!1)),()=>{We.current=w||[]}),[w]),(0,t.useEffect)(()=>()=>{pe.current&&clearTimeout(pe.current)},[]);const Je=()=>{de(!1)},et=()=>{de(!0),_()},tt=(J,me)=>{k&&J>=0&&J<O.length&&k(me,J)},be=vr(O.length),Ce=(0,t.useRef)(),nt=()=>{Ce.current="loadMore",A()};(0,t.useEffect)(()=>{Ce.current==="onChange"&&O.length!==be?x.current.scrollToItem(O.length,"end"):Ce.current==="loadMore"&&O.length!==be&&x.current.scrollToItem(0,"start"),Ce.current=void 0},[be,O]);const we=`${l}-item-instructions`;return t.createElement(i.Field,{error:s,name:l,hint:r,id:c,required:U},t.createElement(xt,{totalNumberOfRelations:V,size:W,search:t.createElement(t.Fragment,null,t.createElement(i.FieldLabel,{action:m},u),t.createElement(h.ReactSelect,{menuPosition:"absolute",menuPlacement:"auto",components:{Option:dr},options:w,isDisabled:o,isLoading:G.isLoading,error:s,inputId:c,isSearchable:!0,isClear:!0,loadingMessage:()=>b,onChange:J=>{N(null),S(J),Ce.current="onChange"},onInputChange:J=>{N(J),_(J)},onMenuClose:Je,onMenuOpen:et,menuIsOpen:re,noOptionsMessage:()=>R,onMenuScrollToBottom:()=>{G.hasNextPage&&F()},placeholder:z,name:l,value:K})),loadMore:ae&&t.createElement(i.TextButton,{disabled:$.isLoading||$.isFetchingNextPage,onClick:nt,loading:$.isLoading||$.isFetchingNextPage,startIcon:t.createElement(L.Refresh,null)},g)},O.length>0&&t.createElement(wt,{overflow:X},t.createElement(i.VisuallyHidden,{id:we},p),t.createElement(i.VisuallyHidden,{"aria-live":"assertive"},y),t.createElement(hs.t7,{height:H,ref:x,outerRef:Q,itemCount:V,itemSize:it+Be,itemData:{name:l,ariaDescribedBy:we,canDrag:e,disabled:o,handleCancel:v,handleDropItem:I,handleGrabItem:E,iconButtonAriaLabel:a,labelDisconnectRelation:f,onRelationDisconnect:T,publicationStateTranslations:B,relations:O,updatePositionOfRelation:tt},itemKey:J=>`${O[J].mainField}_${O[J].id}`,innerElementType:"ol"},St)),(r||s)&&t.createElement(i.Box,{paddingTop:2},t.createElement(i.FieldHint,null),t.createElement(i.FieldError,null))))},qs=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}),Bs=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});Lt.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:[]}},Lt.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:Bs,size:n().number.isRequired,relations:qs};const St=({data:e,index:r,style:o})=>{const{ariaDescribedBy:s,canDrag:a,disabled:c,handleCancel:l,handleDropItem:d,handleGrabItem:u,iconButtonAriaLabel:m,name:g,labelDisconnectRelation:f,onRelationDisconnect:p,publicationStateTranslations:y,relations:b,updatePositionOfRelation:v}=e,{publicationState:I,href:E,mainField:R,id:S}=b[r],A=I==="draft"?"secondary":"success";return t.createElement(It,{ariaDescribedBy:s,canDrag:a,disabled:c,displayValue:String(R??S),iconButtonAriaLabel:m,id:S,index:r,name:g,endAction:t.createElement(Mr,{"data-testid":`remove-relation-${S}`,disabled:c,type:"button",onClick:()=>p(b[r]),"aria-label":f},t.createElement(i.Icon,{width:"12px",as:L.Cross})),onCancel:l,onDropItem:d,onGrabItem:u,status:I||void 0,style:{...o,bottom:o.bottom??0+Be,height:o.height??0-Be},updatePositionOfRelation:v},t.createElement(i.Box,{minWidth:0,paddingTop:1,paddingBottom:1,paddingRight:4},t.createElement(i.Tooltip,{description:R??`${S}`},E?t.createElement(Tr,{to:E},R??S):t.createElement(i.Typography,{textColor:c?"neutral600":"primary600",ellipsis:!0},R??S))),I&&t.createElement(i.Status,{variant:A,showBullet:!1,size:"S"},t.createElement(i.Typography,{fontWeight:"bold",textColor:`${A}700`},y[I])))};St.defaultProps={data:{}},St.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 Ns=Lt;const Dr=({status:e,displayedValue:r,width:o})=>{const{formatMessage:s}=(0,Z.useIntl)(),a={[Se.DRAFT]:s({id:C("relation.publicationState.draft"),defaultMessage:"Draft"}),[Se.PUBLISHED]:s({id:C("relation.publicationState.published"),defaultMessage:"Published"})},c=e===Se.DRAFT?"secondary":"success";return t.createElement(i.Box,{style:{width:o}},t.createElement(i.Flex,{paddingTop:2,paddingBottom:2,paddingLeft:2,paddingRight:4,hasRadius:!0,borderSize:1,background:"neutral0",borderColor:"neutral200",justifyContent:"space-between"},t.createElement(lr,{gap:1},t.createElement(i.IconButton,{noBorder:!0},t.createElement(L.Drag,null)),t.createElement(cr,{maxWidth:"100%",justifyContent:"space-between"},t.createElement(i.Box,{minWidth:0,paddingTop:1,paddingBottom:1,paddingRight:4},t.createElement(Tr,null,t.createElement(i.Typography,{textColor:"primary600",ellipsis:!0},r))),e&&t.createElement(i.Status,{variant:c,showBullet:!1,size:"S"},t.createElement(i.Typography,{fontWeight:"bold",textColor:`${c}700`},a[e])))),t.createElement(i.Box,{paddingLeft:4},t.createElement(Mr,{type:"button"},t.createElement(i.Icon,{width:"12px",as:L.Cross})))))};Dr.propTypes={status:n().string.isRequired,displayedValue:n().string.isRequired,width:n().number.isRequired};const js={position:"fixed",pointerEvents:"none",zIndex:100,left:0,top:0,width:"100%",height:"100%"};function Vs(e,r,o){if(!e||!r)return{display:"none"};const{x:s,y:a}=o,c=`translate(${s}px, ${a}px)`;return{transform:c,WebkitTransform:c}}var _s=()=>{const{itemType:e,isDragging:r,item:o,initialOffset:s,currentOffset:a,mouseOffset:c}=(0,Le.useDragLayer)(d=>({item:d.getItem(),itemType:d.getItemType(),initialOffset:d.getInitialSourceClientOffset(),currentOffset:d.getSourceClientOffset(),isDragging:d.isDragging(),mouseOffset:d.getClientOffset()}));if(!r)return null;const[l]=e.split("_");return t.createElement(Yn,null,t.createElement("div",{style:js},t.createElement("div",{style:Vs(s,a,c),className:"col-md-2"},[he.EDIT_FIELD,he.FIELD].includes(e)&&t.createElement(Tt,{labelField:o.labelField}),l===he.COMPONENT&&t.createElement(tr,{displayedValue:o.displayedValue}),l===he.DYNAMIC_ZONE&&t.createElement(tr,{displayedValue:o.displayedValue}),l===he.RELATION&&t.createElement(Dr,{displayedValue:o.displayedValue,status:o.status,width:o.width}))))},kr=(0,t.createContext)(),zs=D(47533),Ir=(0,t.createContext)(),ct=D(70836),xr=D(4460);const Ws=()=>({type:xr.c}),Us=(e,r)=>({type:xr.O,layout:e,query:r});var Hs=D(8266),ke=D.n(Hs),Gs=D(66694),Zs=()=>(0,t.useContext)(Gs.ux),wr=e=>{const{getAdminInjectedComponents:r}=Zs(),[o,s,a]=e.split(".");return r(o,s,a)};const Fr=({area:e,...r})=>wr(e).map(s=>t.createElement(s.Component,{key:s.name,...r}));Fr.propTypes={area:n().string.isRequired};var dt=Fr;function Qs(e,r){return o=>{const s=r(o.name);return t.createElement(e,{...o,...s})}}var Ks=Qs;function Ys(e){const{addComponentToDynamicZone:r,createActionAllowedFields:o,isCreatingEntry:s,formErrors:a,modifiedData:c,moveComponentField:l,removeComponentFromDynamicZone:d,readActionAllowedFields:u,updateActionAllowedFields:m}=(0,h.useCMEditViewDataManager)(),g=(0,t.useMemo)(()=>(0,te.get)(c,[e],[]).map(y=>({componentUid:y.__component,id:y.id??y.__temp_key__})),[c,e]),f=(0,t.useMemo)(()=>(s?o:m).includes(e),[e,s,o,m]),p=(0,t.useMemo)(()=>(s?[]:u).includes(e),[e,s,u]);return{addComponentToDynamicZone:r,formErrors:a,isCreatingEntry:s,isFieldAllowed:f,isFieldReadable:p,moveComponentField:l,removeComponentFromDynamicZone:d,dynamicDisplayedComponents:g}}var Xs=Ys,Js=D(61868),ea=D.n(Js);function ta(e,r){return o=>{const s=r(o);return t.createElement(e,{...o,...s})}}var na=ta;function ra({isFromDynamicZone:e,name:r}){const{addNonRepeatableComponentToField:o,createActionAllowedFields:s,isCreatingEntry:a,modifiedData:c,removeComponentFromField:l,readActionAllowedFields:d,updateActionAllowedFields:u,formErrors:m}=(0,h.useCMEditViewDataManager)(),{contentType:g}=De(),f=(0,t.useMemo)(()=>{const R=(0,te.get)(g,["attributes"],{});return Object.keys(R).filter(A=>(0,te.get)(R,[A,"type"],"")==="dynamiczone")},[g]),p=(0,t.useMemo)(()=>a?s:u,[a,s,u]),y=(0,te.get)(c,r,null),b=(0,t.useMemo)(()=>sr(r),[r]),v=(0,t.useMemo)(()=>e&&a||p.filter(A=>A===b[0]).length>0?!0:p.map(A=>A.split(".")).filter(A=>A.length<b.length?!1:(0,te.take)(A,b.length).join(".")===b.join(".")).length>0,[e,a,p,b]),I=(0,t.useMemo)(()=>e||f.includes(b[0])?!0:(a?[]:d).map(A=>A.split(".")).filter(A=>A.length<b.length?!1:(0,te.take)(A,b.length).join(".")===b.join(".")).length>0,[e,f,b,a,d]),E=(0,t.useMemo)(()=>a||v?!1:I,[v,I,a]);return{addNonRepeatableComponentToField:o,formErrors:m,hasChildrenAllowedFields:v,hasChildrenReadableFields:I,isCreatingEntry:a,isReadOnly:E,removeComponentFromField:l,componentValue:y}}var oa=ra;const sa=(0,q.default)(i.Box)`
|
|
133
|
-
svg path {
|
|
134
|
-
fill: ${({theme:e})=>e.colors.neutral500};
|
|
135
|
-
}
|
|
136
|
-
`,Pt=({intlLabel:e,id:r,labelAction:o,name:s,numberOfEntries:a,showNumberOfEntries:c,required:l})=>{const{formatMessage:d}=(0,Z.useIntl)(),u=e?.id?d(e):s;return t.createElement(i.Box,{paddingBottom:1},t.createElement(i.Flex,null,t.createElement(i.Typography,{textColor:"neutral800",htmlFor:r||s,variant:"pi",fontWeight:"bold",as:"label"},u,c&&t.createElement(t.Fragment,null,"\xA0(",a,")"),l&&t.createElement(i.Typography,{textColor:"danger600"},"*")),o&&t.createElement(sa,{paddingLeft:1},o)))};Pt.defaultProps={id:void 0,labelAction:void 0,numberOfEntries:0,required:!1,showNumberOfEntries:!1},Pt.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 aa=Pt;const ia=q.default.span`
|
|
137
|
-
> svg {
|
|
138
|
-
width: ${(0,h.pxToRem)(24)};
|
|
139
|
-
height: ${(0,h.pxToRem)(24)};
|
|
140
|
-
> circle {
|
|
141
|
-
fill: ${({theme:e})=>e.colors.primary200};
|
|
142
|
-
}
|
|
143
|
-
> path {
|
|
144
|
-
fill: ${({theme:e})=>e.colors.primary600};
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
`,At=({error:e,isReadOnly:r,onClick:o})=>{const{formatMessage:s}=(0,Z.useIntl)();return t.createElement(t.Fragment,null,t.createElement(i.Box,{as:"button",background:"neutral100",borderColor:e?"danger600":"neutral200",disabled:r,hasRadius:!0,onClick:o,paddingTop:9,paddingBottom:9,type:"button"},t.createElement(i.Flex,{direction:"column",gap:2},t.createElement(i.Flex,{justifyContent:"center",style:{cursor:r?"not-allowed":"inherit"}},t.createElement(ia,null,t.createElement(L.PlusCircle,null))),t.createElement(i.Flex,{justifyContent:"center"},t.createElement(i.Typography,{textColor:"primary600",variant:"pi",fontWeight:"bold"},s({id:C("components.empty-repeatable"),defaultMessage:"No entry yet. Click on the button below to add one."}))))),e?.id&&t.createElement(i.Typography,{textColor:"danger600",variant:"pi"},s(e,{...e.values})))};At.defaultProps={error:void 0,isReadOnly:!1},At.propTypes={error:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}),isReadOnly:n().bool,onClick:n().func.isRequired};var Lr=At,la=D(9086),ca=D.n(la),da=D(88708),Ot=D.n(da),ua=D(87702),$t=D.n(ua),hm=D(27217),ma=D(88591),pa=D.n(ma),qt=D(59845),ga=D(20871),fa=D.n(ga),ha=D(48375),Sr=D.n(ha),ya=D(31089),ba=D.n(ya),Ea=D(16043),Ca=D.n(Ea),Ra=D(5109),va=D.n(Ra),Ta=D(47955),Ma=D.n(Ta),Da=D(95706),ka=D.n(Da),Ia=D(6658),xa=D.n(Ia),wa=D(36407),Fa=D.n(wa);(async()=>{await D.e(7347).then(D.bind(D,98362))})();const Ne=new(pa())({html:!0,xhtmlOut:!1,breaks:!0,langPrefix:"language-",linkify:!0,typographer:!0,highlight(e,r){if(r&&r!=="auto"&&(0,qt.getLanguage)(r))return'<pre class="hljs language-'+Ne.utils.escapeHtml(r.toLowerCase())+'"><code>'+(0,qt.highlight)(r,e,!0).value+"</code></pre>";if(r==="auto"){const o=(0,qt.highlightAuto)(e);return'<pre class="hljs language-'+Ne.utils.escapeHtml(o.language)+'"><code>'+o.value+"</code></pre>"}return'<pre class="hljs"><code>'+Ne.utils.escapeHtml(e)+"</code></pre>"}}).use(fa()).use(Sr(),"warning").use(Sr(),"tip").use(ba()).use(Ca()).use(va()).use(Ma()).use(ka()).use(xa()).use(Fa());Ne.renderer.rules.footnote_ref=(e,r,o,s,a)=>'<sup class="footnote-ref"><span>'+a.rules.footnote_caption(e,r,o,s,a)+"</span></sup>",Ne.renderer.rules.footnote_anchor=()=>' <span class="footnote-backref">\u21A9\uFE0E</span>';var La=Ne,Sa=D(13993),Pr=D.n(Sa);const Pa={...Pr().defaults,allowedTags:!1,allowedAttributes:{"*":["href","align","alt","center","width","height","type","controls","target"],img:["src","alt"],source:["src","type"]}};var Aa=e=>Pr()(e,Pa),Oa=q.default.div`
|
|
148
|
-
position: absolute;
|
|
149
|
-
top: 0;
|
|
150
|
-
width: 100%;
|
|
151
|
-
height: 100%;
|
|
152
|
-
overflow: auto;
|
|
153
|
-
padding: ${({theme:e})=>`${e.spaces[3]} ${e.spaces[4]}`};
|
|
154
|
-
font-size: ${14/16}rem;
|
|
155
|
-
background-color: ${({theme:e})=>e.colors.neutral0};
|
|
156
|
-
color: ${({theme:e})=>e.colors.neutral800};
|
|
157
|
-
line-height: ${({theme:e})=>e.lineHeights[6]};
|
|
158
|
-
|
|
159
|
-
h1,
|
|
160
|
-
h2,
|
|
161
|
-
h3,
|
|
162
|
-
h4,
|
|
163
|
-
h5,
|
|
164
|
-
h6 {
|
|
165
|
-
margin-block-start: ${({theme:e})=>e.spaces[2]};
|
|
166
|
-
margin-block-end: ${({theme:e})=>e.spaces[2]};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
p {
|
|
170
|
-
margin-bottom: ${({theme:e})=>e.spaces[2]};
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
h1 {
|
|
174
|
-
font-size: ${36/16}rem;
|
|
175
|
-
font-weight: 600;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
h2 {
|
|
179
|
-
font-size: ${30/16}rem;
|
|
180
|
-
font-weight: 500;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
h3 {
|
|
184
|
-
font-size: ${24/16}rem;
|
|
185
|
-
font-weight: 500;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
h4 {
|
|
189
|
-
font-size: ${20/16}rem;
|
|
190
|
-
font-weight: 500;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
strong {
|
|
194
|
-
font-weight: 800;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
em {
|
|
198
|
-
font-style: italic;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
blockquote {
|
|
202
|
-
margin-top: ${({theme:e})=>e.spaces[8]};
|
|
203
|
-
margin-bottom: ${({theme:e})=>e.spaces[7]};
|
|
204
|
-
font-size: ${14/16}rem;
|
|
205
|
-
font-weight: 400;
|
|
206
|
-
border-left: 4px solid ${({theme:e})=>e.colors.neutral150};
|
|
207
|
-
font-style: italic;
|
|
208
|
-
padding: ${({theme:e})=>e.spaces[2]} ${({theme:e})=>e.spaces[5]};
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
img {
|
|
212
|
-
max-width: 100%;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
table {
|
|
216
|
-
thead {
|
|
217
|
-
background: ${({theme:e})=>e.colors.neutral150};
|
|
218
|
-
|
|
219
|
-
th {
|
|
220
|
-
padding: ${({theme:e})=>e.spaces[4]};
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
tr {
|
|
224
|
-
border: 1px solid ${({theme:e})=>e.colors.neutral200};
|
|
225
|
-
}
|
|
226
|
-
th,
|
|
227
|
-
td {
|
|
228
|
-
padding: ${({theme:e})=>e.spaces[4]};
|
|
229
|
-
border: 1px solid ${({theme:e})=>e.colors.neutral200};
|
|
230
|
-
border-bottom: 0;
|
|
231
|
-
border-top: 0;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
pre,
|
|
236
|
-
code {
|
|
237
|
-
font-size: ${14/16}rem;
|
|
238
|
-
border-radius: 4px;
|
|
239
|
-
/*
|
|
240
|
-
Hard coded since the color is the same between themes,
|
|
241
|
-
theme.colors.neutral800 changes between themes.
|
|
242
|
-
|
|
243
|
-
Matches the color of the JSON Input component.
|
|
244
|
-
*/
|
|
245
|
-
background-color: #32324d;
|
|
246
|
-
max-width: 100%;
|
|
247
|
-
overflow: auto;
|
|
248
|
-
padding: ${({theme:e})=>e.spaces[2]};
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/* Inline code */
|
|
252
|
-
p,
|
|
253
|
-
pre,
|
|
254
|
-
td {
|
|
255
|
-
> code {
|
|
256
|
-
color: #839496;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
ol {
|
|
261
|
-
list-style-type: decimal;
|
|
262
|
-
margin-block-start: ${({theme:e})=>e.spaces[4]};
|
|
263
|
-
margin-block-end: ${({theme:e})=>e.spaces[4]};
|
|
264
|
-
margin-inline-start: 0px;
|
|
265
|
-
margin-inline-end: 0px;
|
|
266
|
-
padding-inline-start: ${({theme:e})=>e.spaces[4]};
|
|
267
|
-
|
|
268
|
-
ol,
|
|
269
|
-
ul {
|
|
270
|
-
margin-block-start: 0px;
|
|
271
|
-
margin-block-end: 0px;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
ul {
|
|
276
|
-
list-style-type: disc;
|
|
277
|
-
margin-block-start: ${({theme:e})=>e.spaces[4]};
|
|
278
|
-
margin-block-end: ${({theme:e})=>e.spaces[4]};
|
|
279
|
-
margin-inline-start: 0px;
|
|
280
|
-
margin-inline-end: 0px;
|
|
281
|
-
padding-inline-start: ${({theme:e})=>e.spaces[4]};
|
|
282
|
-
|
|
283
|
-
ul,
|
|
284
|
-
ol {
|
|
285
|
-
margin-block-start: 0px;
|
|
286
|
-
margin-block-end: 0px;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
`;const Bt=({data:e})=>{const r=(0,t.useMemo)(()=>Aa(La.render(e.replaceAll("\\n",`
|
|
290
|
-
`)||"")),[e]);return t.createElement(Oa,null,t.createElement("div",{dangerouslySetInnerHTML:{__html:r}}))};Bt.defaultProps={data:""},Bt.propTypes={data:n().string};var Ar=(0,t.memo)(Bt);const $a=q.default.div`
|
|
291
|
-
cursor: ${({disabled:e})=>e?"not-allowed !important":"auto"};
|
|
292
|
-
height: 100%;
|
|
293
|
-
/* BASICS */
|
|
294
|
-
.CodeMirror-placeholder {
|
|
295
|
-
color: ${({theme:e})=>e.colors.neutral600} !important;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
.CodeMirror {
|
|
299
|
-
/* Set height, width, borders, and global font properties here */
|
|
300
|
-
font-size: ${14/16}rem;
|
|
301
|
-
height: ${({isExpandMode:e})=>e?"100%":"290px"};
|
|
302
|
-
color: ${({theme:e})=>e.colors.neutral800};
|
|
303
|
-
direction: ltr;
|
|
304
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
|
|
305
|
-
'Open Sans', 'Helvetica Neue', sans-serif;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/* PADDING */
|
|
309
|
-
|
|
310
|
-
.CodeMirror-lines {
|
|
311
|
-
padding: ${({theme:e})=>`${e.spaces[3]} ${e.spaces[4]}`};
|
|
312
|
-
/* Vertical padding around content */
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
.CodeMirror-scrollbar-filler,
|
|
316
|
-
.CodeMirror-gutter-filler {
|
|
317
|
-
/* The little square between H and V scrollbars */
|
|
318
|
-
background-color: ${({theme:e})=>`${e.colors.neutral0}`};
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/* GUTTER */
|
|
322
|
-
|
|
323
|
-
.CodeMirror-gutters {
|
|
324
|
-
border-right: 1px solid #ddd;
|
|
325
|
-
background-color: #f7f7f7;
|
|
326
|
-
white-space: nowrap;
|
|
327
|
-
}
|
|
328
|
-
.CodeMirror-linenumbers {
|
|
329
|
-
}
|
|
330
|
-
.CodeMirror-linenumber {
|
|
331
|
-
padding: 0 3px 0 5px;
|
|
332
|
-
min-width: 20px;
|
|
333
|
-
text-align: right;
|
|
334
|
-
color: #999;
|
|
335
|
-
white-space: nowrap;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
.CodeMirror-guttermarker {
|
|
339
|
-
color: black;
|
|
340
|
-
}
|
|
341
|
-
.CodeMirror-guttermarker-subtle {
|
|
342
|
-
color: #999;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/* CURSOR */
|
|
346
|
-
|
|
347
|
-
.CodeMirror-cursor {
|
|
348
|
-
border-left: 1px solid black;
|
|
349
|
-
border-right: none;
|
|
350
|
-
width: 0;
|
|
351
|
-
}
|
|
352
|
-
/* Shown when moving in bi-directional text */
|
|
353
|
-
.CodeMirror div.CodeMirror-secondarycursor {
|
|
354
|
-
border-left: 1px solid silver;
|
|
355
|
-
}
|
|
356
|
-
.cm-fat-cursor .CodeMirror-cursor {
|
|
357
|
-
width: auto;
|
|
358
|
-
border: 0 !important;
|
|
359
|
-
background: #7e7;
|
|
360
|
-
}
|
|
361
|
-
.cm-fat-cursor div.CodeMirror-cursors {
|
|
362
|
-
/* z-index: 1; */
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
.cm-fat-cursor-mark {
|
|
366
|
-
background-color: rgba(20, 255, 20, 0.5);
|
|
367
|
-
-webkit-animation: blink 1.06s steps(1) infinite;
|
|
368
|
-
-moz-animation: blink 1.06s steps(1) infinite;
|
|
369
|
-
animation: blink 1.06s steps(1) infinite;
|
|
370
|
-
}
|
|
371
|
-
.cm-animate-fat-cursor {
|
|
372
|
-
width: auto;
|
|
373
|
-
border: 0;
|
|
374
|
-
-webkit-animation: blink 1.06s steps(1) infinite;
|
|
375
|
-
-moz-animation: blink 1.06s steps(1) infinite;
|
|
376
|
-
animation: blink 1.06s steps(1) infinite;
|
|
377
|
-
background-color: #7e7;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/* Can style cursor different in overwrite (non-insert) mode */
|
|
381
|
-
.CodeMirror-overwrite .CodeMirror-cursor {
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
.cm-tab {
|
|
385
|
-
display: inline-block;
|
|
386
|
-
text-decoration: inherit;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
.CodeMirror-rulers {
|
|
390
|
-
position: absolute;
|
|
391
|
-
left: 0;
|
|
392
|
-
right: 0;
|
|
393
|
-
top: -50px;
|
|
394
|
-
bottom: 0;
|
|
395
|
-
overflow: hidden;
|
|
396
|
-
}
|
|
397
|
-
.CodeMirror-ruler {
|
|
398
|
-
border-left: 1px solid #ccc;
|
|
399
|
-
top: 0;
|
|
400
|
-
bottom: 0;
|
|
401
|
-
position: absolute;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/* DEFAULT THEME */
|
|
405
|
-
|
|
406
|
-
.cm-header,
|
|
407
|
-
.cm-strong {
|
|
408
|
-
font-weight: bold;
|
|
409
|
-
}
|
|
410
|
-
.cm-em {
|
|
411
|
-
font-style: italic;
|
|
412
|
-
}
|
|
413
|
-
.cm-link {
|
|
414
|
-
text-decoration: underline;
|
|
415
|
-
}
|
|
416
|
-
.cm-strikethrough {
|
|
417
|
-
text-decoration: line-through;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
.CodeMirror-composing {
|
|
421
|
-
border-bottom: 2px solid;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
/* Default styles for common addons */
|
|
425
|
-
|
|
426
|
-
div.CodeMirror span.CodeMirror-matchingbracket {
|
|
427
|
-
color: #0b0;
|
|
428
|
-
}
|
|
429
|
-
div.CodeMirror span.CodeMirror-nonmatchingbracket {
|
|
430
|
-
color: #a22;
|
|
431
|
-
}
|
|
432
|
-
.CodeMirror-matchingtag {
|
|
433
|
-
background: rgba(255, 150, 0, 0.3);
|
|
434
|
-
}
|
|
435
|
-
.CodeMirror-activeline-background {
|
|
436
|
-
background: #e8f2ff;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
/* STOP */
|
|
440
|
-
|
|
441
|
-
/* The rest of this file contains styles related to the mechanics of
|
|
442
|
-
the editor. You probably shouldn't touch them. */
|
|
443
|
-
|
|
444
|
-
.CodeMirror {
|
|
445
|
-
position: relative;
|
|
446
|
-
overflow: hidden;
|
|
447
|
-
background: ${({theme:e})=>`${e.colors.neutral0}`};
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
.CodeMirror-scroll {
|
|
451
|
-
overflow: scroll !important; /* Things will break if this is overridden */
|
|
452
|
-
/* 50px is the magic margin used to hide the element's real scrollbars */
|
|
453
|
-
/* See overflow: hidden in .CodeMirror */
|
|
454
|
-
margin-bottom: -50px;
|
|
455
|
-
margin-right: -50px;
|
|
456
|
-
padding-bottom: 50px;
|
|
457
|
-
height: 100%;
|
|
458
|
-
outline: none; /* Prevent dragging from highlighting the element */
|
|
459
|
-
position: relative;
|
|
460
|
-
}
|
|
461
|
-
.CodeMirror-sizer {
|
|
462
|
-
position: relative;
|
|
463
|
-
border-right: 50px solid transparent;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
|
467
|
-
before actual scrolling happens, thus preventing shaking and
|
|
468
|
-
flickering artifacts. */
|
|
469
|
-
.CodeMirror-vscrollbar,
|
|
470
|
-
.CodeMirror-hscrollbar,
|
|
471
|
-
.CodeMirror-scrollbar-filler,
|
|
472
|
-
.CodeMirror-gutter-filler {
|
|
473
|
-
position: absolute;
|
|
474
|
-
z-index: 1;
|
|
475
|
-
display: none;
|
|
476
|
-
outline: none;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
.CodeMirror-vscrollbar {
|
|
480
|
-
right: 0;
|
|
481
|
-
top: 0;
|
|
482
|
-
overflow-x: hidden;
|
|
483
|
-
overflow-y: scroll;
|
|
484
|
-
}
|
|
485
|
-
.CodeMirror-hscrollbar {
|
|
486
|
-
bottom: 0;
|
|
487
|
-
left: 0;
|
|
488
|
-
overflow-y: hidden;
|
|
489
|
-
overflow-x: scroll;
|
|
490
|
-
}
|
|
491
|
-
.CodeMirror-scrollbar-filler {
|
|
492
|
-
right: 0;
|
|
493
|
-
bottom: 0;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
.CodeMirror-lines {
|
|
497
|
-
cursor: text;
|
|
498
|
-
min-height: 1px; /* prevents collapsing before first draw */
|
|
499
|
-
}
|
|
500
|
-
/* Reset some styles that the rest of the page might have set */
|
|
501
|
-
.CodeMirror pre.CodeMirror-line,
|
|
502
|
-
.CodeMirror pre.CodeMirror-line-like {
|
|
503
|
-
-moz-border-radius: 0;
|
|
504
|
-
-webkit-border-radius: 0;
|
|
505
|
-
border-radius: 0;
|
|
506
|
-
border-width: 0;
|
|
507
|
-
background: transparent;
|
|
508
|
-
font-family: inherit;
|
|
509
|
-
font-size: inherit;
|
|
510
|
-
margin: 0;
|
|
511
|
-
white-space: pre;
|
|
512
|
-
word-wrap: normal;
|
|
513
|
-
line-height: 1.5;
|
|
514
|
-
color: inherit;
|
|
515
|
-
/* z-index: 2; */
|
|
516
|
-
position: relative;
|
|
517
|
-
overflow: visible;
|
|
518
|
-
-webkit-tap-highlight-color: transparent;
|
|
519
|
-
-webkit-font-variant-ligatures: contextual;
|
|
520
|
-
font-variant-ligatures: contextual;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
.CodeMirror pre.CodeMirror-line-like {
|
|
524
|
-
z-index: 2;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
.CodeMirror-wrap pre.CodeMirror-line,
|
|
528
|
-
.CodeMirror-wrap pre.CodeMirror-line-like {
|
|
529
|
-
word-wrap: break-word;
|
|
530
|
-
white-space: pre-wrap;
|
|
531
|
-
word-break: normal;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
.CodeMirror-linebackground {
|
|
535
|
-
position: absolute;
|
|
536
|
-
left: 0;
|
|
537
|
-
right: 0;
|
|
538
|
-
top: 0;
|
|
539
|
-
bottom: 0;
|
|
540
|
-
z-index: 0;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
.CodeMirror-linewidget {
|
|
544
|
-
position: relative;
|
|
545
|
-
/* z-index: 2; */
|
|
546
|
-
padding: 0.1px; /* Force widget margins to stay inside of the container */
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
.CodeMirror-widget {
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
.CodeMirror-rtl pre {
|
|
553
|
-
direction: rtl;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
.CodeMirror-code {
|
|
557
|
-
outline: none;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
/* Force content-box sizing for the elements where we expect it */
|
|
561
|
-
.CodeMirror-scroll,
|
|
562
|
-
.CodeMirror-sizer,
|
|
563
|
-
.CodeMirror-gutter,
|
|
564
|
-
.CodeMirror-gutters,
|
|
565
|
-
.CodeMirror-linenumber {
|
|
566
|
-
-moz-box-sizing: content-box;
|
|
567
|
-
box-sizing: content-box;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
.CodeMirror-measure {
|
|
571
|
-
position: absolute;
|
|
572
|
-
width: 100%;
|
|
573
|
-
height: 0;
|
|
574
|
-
overflow: hidden;
|
|
575
|
-
visibility: hidden;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
.CodeMirror-cursor {
|
|
579
|
-
position: absolute;
|
|
580
|
-
pointer-events: none;
|
|
581
|
-
border-color: ${({theme:e})=>`${e.colors.neutral800}`};
|
|
582
|
-
}
|
|
583
|
-
.CodeMirror-measure pre {
|
|
584
|
-
position: static;
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
div.CodeMirror-cursors {
|
|
588
|
-
visibility: hidden;
|
|
589
|
-
position: relative;
|
|
590
|
-
+ div {
|
|
591
|
-
z-index: 0 !important;
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
div.CodeMirror-dragcursors {
|
|
596
|
-
visibility: visible;
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
.CodeMirror-focused div.CodeMirror-cursors {
|
|
600
|
-
visibility: visible;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
.CodeMirror-selected {
|
|
604
|
-
background: ${({theme:e})=>e.colors.neutral200};
|
|
605
|
-
/* z-index: -10; */
|
|
606
|
-
}
|
|
607
|
-
.CodeMirror-crosshair {
|
|
608
|
-
cursor: crosshair;
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
/* Used to force a border model for a node */
|
|
612
|
-
.cm-force-border {
|
|
613
|
-
padding-right: 0.1px;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
/* See issue #2901 */
|
|
617
|
-
.cm-tab-wrap-hack:after {
|
|
618
|
-
content: '';
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
/* Help users use markselection to safely style text background */
|
|
622
|
-
span.CodeMirror-selectedtext {
|
|
623
|
-
background: none;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
span {
|
|
627
|
-
color: ${({theme:e})=>e.colors.neutral800} !important;
|
|
628
|
-
}
|
|
629
|
-
`,fe=(0,q.default)(i.IconButton)`
|
|
630
|
-
padding: ${({theme:e})=>e.spaces[2]};
|
|
631
|
-
/* Trick to prevent the outline from overflowing because of the general outline-offset */
|
|
632
|
-
outline-offset: -2px !important;
|
|
633
|
-
|
|
634
|
-
svg {
|
|
635
|
-
width: ${18/16}rem;
|
|
636
|
-
height: ${18/16}rem;
|
|
637
|
-
}
|
|
638
|
-
`,qa=(0,q.default)(fe)`
|
|
639
|
-
svg {
|
|
640
|
-
width: ${8/16}rem;
|
|
641
|
-
height: ${8/16}rem;
|
|
642
|
-
}
|
|
643
|
-
`,Or=(0,q.default)(i.IconButtonGroup)`
|
|
644
|
-
margin-left: ${({theme:e})=>e.spaces[4]};
|
|
645
|
-
`,$r=(0,q.default)(i.IconButton)`
|
|
646
|
-
margin: ${({theme:e})=>`0 ${e.spaces[2]}`};
|
|
647
|
-
padding: ${({theme:e})=>e.spaces[2]};
|
|
648
|
-
|
|
649
|
-
svg {
|
|
650
|
-
width: ${18/16}rem;
|
|
651
|
-
height: ${18/16}rem;
|
|
652
|
-
}
|
|
653
|
-
`,Ba=(0,q.default)(i.IconButtonGroup)`
|
|
654
|
-
margin-right: ${({theme:e})=>`${e.spaces[2]}`};
|
|
655
|
-
`,Na=q.default.div`
|
|
656
|
-
position: relative;
|
|
657
|
-
height: calc(100% - 48px);
|
|
658
|
-
`,ja=(0,q.default)(i.BaseButton)`
|
|
659
|
-
background-color: transparent;
|
|
660
|
-
border: none;
|
|
661
|
-
align-items: center;
|
|
662
|
-
|
|
663
|
-
svg {
|
|
664
|
-
margin-left: ${({theme:e})=>`${e.spaces[2]}`};
|
|
665
|
-
path {
|
|
666
|
-
fill: ${({theme:e})=>e.colors.neutral700};
|
|
667
|
-
width: ${12/16}rem;
|
|
668
|
-
height: ${12/16}rem;
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
`;var ut=/^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/,Va=/^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/,_a=/[*+-]\s/;function za(e){if(e.getOption("disableInput"))return $t().Pass;for(var r=e.listSelections(),o=[],s=0;s<r.length;s++){var a=r[s].head,c=e.getStateAfter(a.line),l=c.list!==!1,d=c.quote!==0,u=e.getLine(a.line),m=ut.exec(u),g=/^\s*$/.test(u.slice(0,a.ch));if(!r[s].empty()||!l&&!d||!m||g){e.execCommand("newlineAndIndent");return}if(Va.test(u)){var f=d&&/>\s*$/.test(u),p=!/>\s*$/.test(u);(f||p)&&e.replaceRange("",{line:a.line,ch:0},{line:a.line,ch:a.ch+1}),o[s]=`
|
|
672
|
-
`}else{var y=m[1],b=m[5],v=!(_a.test(m[2])||m[2].indexOf(">")>=0),I=v?parseInt(m[3],10)+1+m[4]:m[2].replace("x"," ");o[s]=`
|
|
673
|
-
`+y+I+b,v&&Wa(e,a)}}e.replaceSelections(o)}function Wa(e,r){var o=r.line,s=0,a=0,c=ut.exec(e.getLine(o)),l=c[1];do{s+=1;var d=o+s,u=e.getLine(d),m=ut.exec(u);if(m){var g=m[1],f=parseInt(c[3],10)+s-a,p=parseInt(m[3],10),y=p;if(l===g&&!isNaN(p))f===p&&(y=p+1),f>p&&(y=f+1),e.replaceRange(u.replace(ut,g+y+m[4]+m[5]),{line:d,ch:0},{line:d,ch:u.length});else{if(l.length>g.length||l.length<g.length&&s===1)return;a+=1}}}while(m)}var Ua=za;const Nt=({disabled:e,editorRef:r,error:o,isPreviewMode:s,isExpandMode:a,name:c,onChange:l,placeholder:d,textareaRef:u,value:m})=>{const g=(0,t.useRef)(l);return(0,t.useEffect)(()=>{r.current=$t().fromTextArea(u.current,{lineWrapping:!0,extraKeys:{Enter:"newlineAndIndentContinueMarkdownList",Tab:!1,"Shift-Tab":!1},readOnly:!1,smartIndent:!1,placeholder:d,spellcheck:!0,inputStyle:"contenteditable"}),$t().commands.newlineAndIndentContinueMarkdownList=Ua,r.current.on("change",f=>{g.current({target:{name:c,value:f.getValue(),type:"wysiwyg"}})})},[r,u,c,d]),(0,t.useEffect)(()=>{m&&!r.current.hasFocus()&&r.current.setValue(m)},[r,m]),(0,t.useEffect)(()=>{s||e?r.current.setOption("readOnly","nocursor"):r.current.setOption("readOnly",!1)},[e,s,r]),(0,t.useEffect)(()=>{o?r.current.setOption("screenReaderLabel",o):r.current.setOption("screenReaderLabel","Editor")},[r,o]),t.createElement(Na,null,t.createElement($a,{isExpandMode:a,disabled:e||s},t.createElement("textarea",{ref:u})),s&&t.createElement(Ar,{data:m}))};Nt.defaultProps={disabled:!1,error:void 0,isPreviewMode:!1,isExpandMode:!1,placeholder:"",value:""},Nt.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 Ha=Nt;const jt=({disabled:e,editorRef:r,isExpandMode:o,isPreviewMode:s,onActionClick:a,onToggleMediaLib:c,onTogglePreviewMode:l})=>{const[d,u]=(0,t.useState)(!1),{formatMessage:m}=(0,Z.useIntl)(),g=m({id:"components.Wysiwyg.selectOptions.title",defaultMessage:"Add a title"}),f=(0,t.useRef)(),p=()=>{u(y=>!y)};return e||s?t.createElement(i.Box,{padding:2,background:"neutral100"},t.createElement(i.Flex,{justifyContent:"space-between"},t.createElement(i.Flex,null,t.createElement(i.Select,{disabled:!0,id:"selectTitle",placeholder:g,size:"S","aria-label":g},t.createElement(i.Option,{value:"h1"},"h1"),t.createElement(i.Option,{value:"h2"},"h2"),t.createElement(i.Option,{value:"h3"},"h3"),t.createElement(i.Option,{value:"h4"},"h4"),t.createElement(i.Option,{value:"h5"},"h5"),t.createElement(i.Option,{value:"h6"},"h6")),t.createElement(Or,null,t.createElement(fe,{disabled:!0,id:"Bold",label:"Bold",name:"Bold",icon:t.createElement(L.Bold,null)}),t.createElement(fe,{disabled:!0,id:"Italic",label:"Italic",name:"Italic",icon:t.createElement(L.Italic,null)}),t.createElement(fe,{disabled:!0,id:"Underline",label:"Underline",name:"Underline",icon:t.createElement(L.Underline,null)})),t.createElement($r,{disabled:!0,id:"more",label:"More",icon:t.createElement(L.More,null)})),!o&&t.createElement(i.Button,{onClick:l,variant:"tertiary",id:"preview"},m({id:"components.Wysiwyg.ToggleMode.markdown-mode",defaultMessage:"Markdown mode"})))):t.createElement(i.Box,{padding:2,background:"neutral100"},t.createElement(i.Flex,{justifyContent:"space-between"},t.createElement(i.Flex,null,t.createElement(i.Select,{id:"selectTitle",placeholder:g,size:"S",onChange:y=>a(y,r)},t.createElement(i.Option,{value:"h1"},"h1"),t.createElement(i.Option,{value:"h2"},"h2"),t.createElement(i.Option,{value:"h3"},"h3"),t.createElement(i.Option,{value:"h4"},"h4"),t.createElement(i.Option,{value:"h5"},"h5"),t.createElement(i.Option,{value:"h6"},"h6")),t.createElement(Or,null,t.createElement(fe,{onClick:()=>a("Bold",r),id:"Bold",label:"Bold",name:"Bold",icon:t.createElement(L.Bold,null)}),t.createElement(fe,{onClick:()=>a("Italic",r),id:"Italic",label:"Italic",name:"Italic",icon:t.createElement(L.Italic,null)}),t.createElement(fe,{onClick:()=>a("Underline",r),id:"Underline",label:"Underline",name:"Underline",icon:t.createElement(L.Underline,null)})),t.createElement($r,{ref:f,onClick:p,id:"more",label:"More",icon:t.createElement(L.More,null)}),d&&t.createElement(i.Popover,{centered:!0,source:f,spacing:4,id:"popover"},t.createElement(i.FocusTrap,{onEscape:p,restoreFocus:!1},t.createElement(i.Flex,null,t.createElement(Ba,null,t.createElement(fe,{onClick:()=>a("Strikethrough",r,p),id:"Strikethrough",label:"Strikethrough",name:"Strikethrough",icon:t.createElement(L.StrikeThrough,null)}),t.createElement(fe,{onClick:()=>a("BulletList",r,p),id:"BulletList",label:"BulletList",name:"BulletList",icon:t.createElement(L.BulletList,null)}),t.createElement(fe,{onClick:()=>a("NumberList",r,p),id:"NumberList",label:"NumberList",name:"NumberList",icon:t.createElement(L.NumberList,null)})),t.createElement(i.IconButtonGroup,null,t.createElement(fe,{onClick:()=>a("Code",r,p),id:"Code",label:"Code",name:"Code",icon:t.createElement(L.Code,null)}),t.createElement(fe,{onClick:()=>{p(),c()},id:"Image",label:"Image",name:"Image",icon:t.createElement(L.Picture,null)}),t.createElement(qa,{onClick:()=>a("Link",r,p),id:"Link",label:"Link",name:"Link",icon:t.createElement(L.Link,null)}),t.createElement(fe,{onClick:()=>a("Quote",r,p),id:"Quote",label:"Quote",name:"Quote",icon:t.createElement(L.Quote,null)})))))),l&&t.createElement(i.Button,{onClick:l,variant:"tertiary",id:"preview"},m({id:"components.Wysiwyg.ToggleMode.preview-mode",defaultMessage:"Preview mode"}))))};jt.defaultProps={isPreviewMode:!1,onActionClick(){},onToggleMediaLib(){},onTogglePreviewMode:void 0},jt.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 Ga=jt;const Vt=({onToggleExpand:e})=>{const{formatMessage:r}=(0,Z.useIntl)();return t.createElement(i.Box,{padding:2,background:"neutral100",hasRadius:!0},t.createElement(i.Flex,{justifyContent:"flex-end",alignItems:"flex-end"},t.createElement(ja,{id:"expand",onClick:e},t.createElement(i.Typography,null,r({id:"components.WysiwygBottomControls.fullscreen",defaultMessage:"Expand"})),t.createElement(L.Expand,null))))};Vt.defaultProps={onToggleExpand(){}},Vt.propTypes={onToggleExpand:n().func};var Za=Vt;const _t=({id:e,error:r,name:o,hint:s})=>s.length===0||r?null:t.createElement(i.Typography,{as:"p",variant:"pi",id:`${e||o}-hint`,textColor:"neutral600"},s);_t.defaultProps={id:void 0,error:void 0,hint:""},_t.propTypes={hint:n().oneOfType([n().string,n().array]),error:n().string,id:n().string,name:n().string.isRequired};var Qa=_t;const qr=(e,r)=>{let o;switch(e){case"Strikethrough":o=`~~${r}~~`;break;case"Bold":o=`**${r}**`;break;case"Italic":o=`_${r}_`;break;case"Underline":o=`<u>${r}</u>`;break;case"Code":o=`\`\`\`
|
|
674
|
-
${r}
|
|
675
|
-
\`\`\``;break;case"Link":o=`[${r}](link)`;break;case"Quote":o=`>${r}`;break;default:o=r}return o},Br=e=>{let r,o={start:e.length,end:0};switch(e){case"Strikethrough":r=`~~${e}~~`,o.end=2;break;case"Bold":r=`**${e}**`,o.end=2;break;case"Italic":r=`_${e}_`,o.end=1;break;case"alt":r=`[${e}]()`,o.end=3;break;case"Underline":r=`<u>${e}</u>`,o.end=4;break;case"Code":r=`\`\`\`
|
|
676
|
-
${e}
|
|
677
|
-
\`\`\``,o.end=3;break;case"Link":r=`[${e}](link)`,o.end=7;break;case"Quote":r=`>${e}`,o.end=0;break;default:r=""}return{editedText:r,selection:o}},Nr=e=>{let r;switch(e){case"BulletList":r="- ";break;case"NumberList":r="1. ";break;case"h1":r="# ";break;case"h2":r="## ";break;case"h3":r="### ";break;case"h4":r="#### ";break;case"h5":r="##### ";break;case"h6":r="###### ";break;default:return""}return r},jr=(e,r)=>{const o=e.current.getSelection();let s;if(o){const a=qr(r,o);e.current.replaceSelection(a),e.current.focus()}else{s=Br(r),e.current.replaceSelection(s.editedText),e.current.focus();const{line:a,ch:c}=e.current.getCursor(),l=c-s.selection.end,d=c-s.selection.end-s.selection.start;e.current.setSelection({line:a,ch:d},{line:a,ch:l})}},Ka=(e,r)=>{const o=e.current.getDoc(),s=r==="BulletList"?"- ":"1. ";if(o.somethingSelected()){const a=o.listSelections();let c=null;e.current.operation(function(){a.forEach(function(l){const d=[l.head.line,l.anchor.line].sort();c==null&&(c=o.getLine(d[0]).startsWith(s));for(let u=d[0];u<=d[1];u++)if(c)o.getLine(u).startsWith(s)&&o.replaceRange("",{line:u,ch:0},{line:u,ch:s.length});else{const m=r==="BulletList"?"- ":`${u+1}. `;o.replaceRange(m,{line:u,ch:0})}})})}else{let{line:a}=o.getCursor();const c=Nr(r),l=e.current.getLine(a),d=c+l;e.current.setSelection({line:a,ch:0},{line:a,ch:l.length}),e.current.replaceSelection(d)}e.current.focus()},Ya=(e,r)=>{let{line:o}=e.current.getCursor();const s=Nr(r),a=e.current.getLine(o),c=a.replace(/#{1,6}\s/g,"").trim(),l=s+c;e.current.setSelection({line:o,ch:0},{line:o,ch:a.length}),e.current.replaceSelection(l),setTimeout(()=>{const d=e.current.getLine(o).length;e.current.focus(),e.current.setCursor({line:o,ch:d})},0)},Xa=(e,r)=>{let{line:o,ch:s}=e.current.getCursor();r.forEach((a,c)=>{let l=e.current.getLine(o).length;e.current.setCursor({line:o,ch:l}),(c>0||c===0&&s!==0)&&(l=e.current.getLine(o).length,e.current.setCursor({line:o,ch:l}),o++,e.current.replaceSelection(`
|
|
678
|
-
`)),a.mime.includes("image")?e.current.replaceSelection(``):e.current.replaceSelection(`[${a.alt}](${a.url})`)}),setTimeout(()=>e.current.focus(),0)},Ja=(e,r,o,s,a)=>{const c=qr(r,a),l=e.current.getRange({line:o+1,ch:0},{line:1/0,ch:1/0});if(e.current.replaceRange("",{line:o+1,ch:0},{line:1/0,ch:1/0}),e.current.replaceSelection(""),e.current.setCursor({line:o,ch:s}),e.current.replaceSelection(`
|
|
679
|
-
`),e.current.replaceSelection(c),r==="Code"){let{line:d}=e.current.getCursor();e.current.setCursor({line:d-1,ch:a.length})}e.current.replaceRange(l,{line:o+4,ch:0},{line:1/0,ch:1/0}),e.current.focus()},ei=(e,r,o,s)=>{const a=Br(r),c=e.current.getRange({line:o+1,ch:0},{line:1/0,ch:1/0});if(e.current.replaceRange("",{line:o+1,ch:0},{line:1/0,ch:1/0}),e.current.setCursor({line:o,ch:s}),e.current.replaceSelection(`
|
|
680
|
-
`),e.current.replaceSelection(a.editedText),r==="Code")o+=2,e.current.setSelection({line:o,ch:0},{line:o,ch:4});else{o+=1;let{ch:l}=e.current.getCursor(),d=l-a.selection.end,u=l-a.selection.end-a.selection.start;e.current.setSelection({line:o,ch:u},{line:o,ch:d})}e.current.replaceRange(c,{line:o+2,ch:0},{line:1/0,ch:1/0}),e.current.focus()},ti=(e,r)=>{const o=e.current.getSelection();let{line:s}=e.current.getCursor(),a=e.current.getLine(s).length;o?Ja(e,r,s,a,o):ei(e,r,s,a)},ni=(e,r)=>`${e}${Math.floor(r*255).toString(16).padStart(2,0)}`,ri=(0,q.default)(i.Flex)`
|
|
681
|
-
background: ${({theme:e})=>ni(e.colors.neutral800,.2)};
|
|
682
|
-
`,oi=(0,q.default)(i.Box)`
|
|
683
|
-
border-right: 1px solid ${({theme:e})=>e.colors.neutral200};
|
|
684
|
-
`,si=(0,q.default)(i.BaseButton)`
|
|
685
|
-
background-color: transparent;
|
|
686
|
-
border: none;
|
|
687
|
-
align-items: center;
|
|
688
|
-
|
|
689
|
-
svg {
|
|
690
|
-
margin-left: ${({theme:e})=>`${e.spaces[2]}`};
|
|
691
|
-
|
|
692
|
-
path {
|
|
693
|
-
fill: ${({theme:e})=>e.colors.neutral700};
|
|
694
|
-
width: ${12/16}rem;
|
|
695
|
-
height: ${12/16}rem;
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
`,zt=({children:e,isExpandMode:r,error:o,previewContent:s,onCollapse:a})=>{const{formatMessage:c}=(0,Z.useIntl)();return(0,h.useLockScroll)(r),r?t.createElement(i.Portal,{role:"dialog","aria-modal":!1},t.createElement(i.FocusTrap,{onEscape:a},t.createElement(ri,{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:4,justifyContent:"center",onClick:a},t.createElement(i.Box,{background:"neutral0",hasRadius:!0,shadow:"popupShadow",overflow:"hidden",width:"70%",height:"70%",onClick:l=>l.stopPropagation()},t.createElement(i.Flex,{height:"100%",alignItems:"flex-start"},t.createElement(oi,{flex:"1",height:"100%"},e),t.createElement(i.Flex,{alignItems:"start",direction:"column",flex:1,height:"100%",width:"100%"},t.createElement(i.Flex,{height:(0,h.pxToRem)(48),background:"neutral100",justifyContent:"flex-end",shrink:0,width:"100%"},t.createElement(si,{onClick:a},t.createElement(i.Typography,null,c({id:"components.Wysiwyg.collapse",defaultMessage:"Collapse"})),t.createElement(L.Collapse,null))),t.createElement(i.Box,{position:"relative",height:"100%",width:"100%"},t.createElement(Ar,{data:s})))))))):t.createElement(i.Box,{borderColor:o?"danger600":"neutral200",borderStyle:"solid",borderWidth:"1px",hasRadius:!0},e)};zt.defaultProps={error:void 0,previewContent:""},zt.propTypes={children:n().node.isRequired,error:n().string,isExpandMode:n().bool.isRequired,previewContent:n().string,onCollapse:n().func.isRequired};const ai=(0,q.default)(i.Box)`
|
|
699
|
-
svg path {
|
|
700
|
-
fill: ${({theme:e})=>e.colors.neutral500};
|
|
701
|
-
}
|
|
702
|
-
`,ii=(0,q.default)(i.Typography)`
|
|
703
|
-
line-height: 0;
|
|
704
|
-
`,Wt=({hint:e,disabled:r,error:o,intlLabel:s,labelAction:a,name:c,onChange:l,placeholder:d,value:u,required:m})=>{const{formatMessage:g}=(0,Z.useIntl)(),f=(0,t.useRef)(null),p=(0,t.useRef)(null),[y,b]=(0,t.useState)(!1),[v,I]=(0,t.useState)(!1),[E,R]=(0,t.useState)(!1),{components:S}=(0,h.useLibrary)(),A=S["media-library"],T=()=>I($=>!$),k=()=>b($=>!$),F=()=>{b(!1),R($=>!$)},_=($,G,W)=>{switch($){case"Link":case"Strikethrough":{jr(G,$),W();break}case"Code":case"Quote":{ti(G,$),W();break}case"Bold":case"Italic":case"Underline":{jr(G,$);break}case"BulletList":case"NumberList":{Ka(G,$),W();break}case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{Ya(G,$);break}default:}},z=$=>{const G=$.map(W=>({alt:W.alternativeText||W.name,url:(0,h.prefixFileUrlWithBackendUrl)(W.url),mime:W.mime}));Xa(p,G),I(!1)},B=d?g({id:d.id,defaultMessage:d.defaultMessage},{...d.values}):"",U=s.id?g({id:s.id,defaultMessage:s.defaultMessage},{...s.values}):c;return t.createElement(t.Fragment,null,t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:1},t.createElement(i.Flex,{gap:1},t.createElement(i.Typography,{variant:"pi",fontWeight:"bold",textColor:"neutral800"},U,m&&t.createElement(ii,{textColor:"danger600"},"*")),a&&t.createElement(ai,{paddingLeft:1},a)),t.createElement(zt,{isExpandMode:E,error:o,previewContent:u,onCollapse:F},t.createElement(Ga,{isExpandMode:E,editorRef:p,isPreviewMode:y,onActionClick:_,onToggleMediaLib:T,onTogglePreviewMode:E?void 0:k,disabled:r}),t.createElement(Ha,{disabled:r,isExpandMode:E,editorRef:p,error:o,isPreviewMode:y,name:c,onChange:l,placeholder:B,textareaRef:f,value:u}),!E&&t.createElement(Za,{onToggleExpand:F})),t.createElement(Qa,{hint:e,name:c,error:o})),o&&t.createElement(i.Box,{paddingTop:1},t.createElement(i.Typography,{variant:"pi",textColor:"danger600","data-strapi-field-error":!0},o)),v&&t.createElement(A,{onClose:T,onSelectAssets:z}))};Wt.defaultProps={disabled:!1,error:"",labelAction:void 0,placeholder:null,required:!1,value:"",hint:""},Wt.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 li=Wt,Vr=(e,r)=>{const[o,s]=(0,t.useState)(e);return(0,t.useEffect)(()=>{const a=setTimeout(()=>{s(e)},r);return()=>{clearTimeout(a)}},[e,r]),o},ci=/^[A-Za-z0-9-_.~]*$/;const di=(0,q.default)(i.Box)`
|
|
705
|
-
position: relative;
|
|
706
|
-
`,ui=(0,q.default)(i.FieldAction)`
|
|
707
|
-
svg {
|
|
708
|
-
height: 1rem;
|
|
709
|
-
width: 1rem;
|
|
710
|
-
path {
|
|
711
|
-
fill: ${({theme:e})=>e.colors.neutral400};
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
svg:hover {
|
|
716
|
-
path {
|
|
717
|
-
fill: ${({theme:e})=>e.colors.primary600};
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
`,Ut=(0,q.default)(i.Flex)`
|
|
721
|
-
position: absolute;
|
|
722
|
-
right: ${({theme:e})=>e.spaces[6]};
|
|
723
|
-
width: 100px;
|
|
724
|
-
pointer-events: none;
|
|
725
|
-
|
|
726
|
-
svg {
|
|
727
|
-
margin-right: ${({theme:e})=>e.spaces[1]};
|
|
728
|
-
height: ${12/16}rem;
|
|
729
|
-
width: ${12/16}rem;
|
|
730
|
-
path {
|
|
731
|
-
fill: ${({theme:e,notAvailable:r})=>r?e.colors.danger600:e.colors.success600};
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
`,mi=q.keyframes`
|
|
735
|
-
from {
|
|
736
|
-
transform: rotate(0deg);
|
|
737
|
-
}
|
|
738
|
-
to {
|
|
739
|
-
transform: rotate(359deg);
|
|
740
|
-
}
|
|
741
|
-
`,pi=(0,q.default)(i.Flex)`
|
|
742
|
-
animation: ${mi} 2s infinite linear;
|
|
743
|
-
`,Ht=({attribute:e,contentTypeUID:r,hint:o,disabled:s,error:a,intlLabel:c,labelAction:l,name:d,onChange:u,value:m,placeholder:g,required:f})=>{const{modifiedData:p,initialData:y,layout:b}=(0,h.useCMEditViewDataManager)(),[v,I]=(0,t.useState)(!1),[E,R]=(0,t.useState)(null),S=Vr(m,300),A=(0,t.useRef)(),T=y[d],{formatMessage:k}=(0,Z.useIntl)(),F=P()(b,["options","timestamps",0]),_=!y[F],z=Vr(p[e.targetField],300),[B,U]=(0,t.useState)(!1),[$,G]=(0,t.useState)(null),{post:W}=(0,h.useFetchClient)(),K=c.id?k({id:c.id,defaultMessage:c.defaultMessage},{...c.values}):d,N=g?k({id:g.id,defaultMessage:g.defaultMessage},{...g.values}):"";A.current=async(j=!1)=>{I(!0);const O=ce("uid/generate");try{const{data:{data:V}}=await W(O,{contentTypeUID:r,field:d,data:p});u({target:{name:d,value:V,type:"text"}},j),I(!1)}catch{I(!1)}};const X=async()=>{I(!0);const j=ce("uid/check-availability");if(m)try{const{data:O}=await W(j,{contentTypeUID:r,field:d,value:m?m.trim():""});R(O),I(!1)}catch{I(!1)}};(0,t.useEffect)(()=>{!m&&e.required&&A.current(!0)},[]),(0,t.useEffect)(()=>{S&&S.trim().match(ci)&&S!==T&&X(),S||R(null)},[S,T]),(0,t.useEffect)(()=>{let j;return E&&E.isAvailable&&(j=setTimeout(()=>{R(null)},4e3)),()=>{j&&clearTimeout(j)}},[E]),(0,t.useEffect)(()=>{!B&&_&&z&&p[e.targetField]&&!m&&A.current(!0)},[z,B,_]);const M=()=>{G(k({id:"content-manager.components.uid.regenerate",defaultMessage:"Regenerate"}))},x=()=>{G(null)},Q=j=>{j.target.value&&_&&U(!0),u(j)};return t.createElement(i.TextInput,{disabled:s,error:a,endAction:t.createElement(di,null,E&&E.isAvailable&&!$&&t.createElement(Ut,{alignItems:"center",justifyContent:"flex-end"},t.createElement(L.CheckCircle,null),t.createElement(i.Typography,{textColor:"success600",variant:"pi"},k({id:"content-manager.components.uid.available",defaultMessage:"Available"}))),E&&!E.isAvailable&&!$&&t.createElement(Ut,{notAvailable:!0,alignItems:"center",justifyContent:"flex-end"},t.createElement(L.ExclamationMarkCircle,null),t.createElement(i.Typography,{textColor:"danger600",variant:"pi"},k({id:"content-manager.components.uid.unavailable",defaultMessage:"Unavailable"}))),$&&t.createElement(Ut,{alignItems:"center",justifyContent:"flex-end"},t.createElement(i.Typography,{textColor:"primary600",variant:"pi"},$)),t.createElement(ui,{onClick:()=>A.current(),label:"regenerate",onMouseEnter:M,onMouseLeave:x},v?t.createElement(pi,null,t.createElement(L.Loader,null)):t.createElement(L.Refresh,null))),hint:o,label:K,labelAction:l,name:d,onChange:Q,placeholder:N,value:m||"",required:f})};Ht.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])},Ht.defaultProps={disabled:!1,error:void 0,labelAction:void 0,placeholder:void 0,value:"",required:!1,hint:""};var gi=Ht,fi=D(88423),Gt=D.n(fi),Ae=D(84968);function hi(e,r){return o=>{const s=r(o);return t.createElement(e,{...o,...s})}}var yi=hi;function bi({componentUid:e,isUserAllowedToEditField:r,isUserAllowedToReadField:o,name:s,queryInfos:a}){const{isCreatingEntry:c,createActionAllowedFields:l,readActionAllowedFields:d,updateActionAllowedFields:u,slug:m,modifiedData:g}=(0,h.useCMEditViewDataManager)(),f=(0,t.useMemo)(()=>r===!0?!0:(c?l:u).includes(s),[c,l,s,r,u]),p=(0,t.useMemo)(()=>o?!0:(c?[]:d).includes(s),[c,o,s,d]),y=s.split(".");let b;e&&(b=P()(g,y.slice(0,-1))?.id);const v=(0,t.useMemo)(()=>c?null:e?b?ce(`relations/${e}/${b}/${y.at(-1)}`):null:ce(`relations/${m}/${g.id}/${s.split(".").at(-1)}`),[c,e,m,g.id,s,b,y]),I=(0,t.useMemo)(()=>ce(e?`relations/${e}/${s.split(".").at(-1)}`:`relations/${m}/${s.split(".").at(-1)}`),[e,m,s]);return{componentId:b,isComponentRelation:Boolean(e),queryInfos:{...a,endpoints:{search:I,relation:v}},isCreatingEntry:c,isFieldAllowed:f,isFieldReadable:p}}var Ei=bi;function Ci(e,r){return`${ce(`collectionType/${e}/${r??""}`)}`}const Zt=(e,{shouldAddLink:r,mainFieldName:o,targetModel:s})=>{const a={...e};return r&&(a.href=Ci(s,a.id)),a.publicationState=!1,a?.publishedAt!==void 0&&(a.publicationState=a.publishedAt?Se.PUBLISHED:Se.DRAFT),a.mainField=a[o],a},Ri=(e,{shouldAddLink:r=!1,mainFieldName:o,targetModel:s}={})=>[...e].map(a=>Zt(a,{shouldAddLink:r,mainFieldName:o,targetModel:s})),vi=(e,{mainFieldName:r})=>{const{data:o}=e,{pages:s=[]}=o??{};return{...e,data:s.map(a=>a?.results.map(c=>Zt(c,{mainFieldName:r}))).filter(Boolean).flat()}},Ti=(e=[],r=[])=>{const o=e.reduce((a,c)=>r.find(l=>l.id===c.id)?a:[...a,c.id],[]),s=r.reduce((a,c)=>e.find(l=>l.id===c.id)?a:[...a,c.id],[]);return[o,s]},Mi=e=>{const r=t.useRef(e);return t.useEffect(()=>{r.current=e}),t.useMemo(()=>(...o)=>r.current?.(...o),[])},Di=(e,{relation:r,search:o})=>{const[s,a]=(0,t.useState)({}),[c,l]=(0,t.useState)(0),{get:d}=(0,h.useFetchClient)(),u=async({pageParam:T=1})=>{try{const{data:k}=await d(r?.endpoint,{params:{...r.pageParams??{},page:T}});return l(T),k}catch{return null}},m=async({pageParam:T=1})=>{try{const{data:k}=await d(o.endpoint,{params:{...o.pageParams??{},...s,page:T}});return k}catch{return null}},{onLoad:g,normalizeArguments:f={}}=r,p=(0,Ae.useInfiniteQuery)(["relation",...e],u,{cacheTime:0,enabled:r.enabled,getNextPageParam(T){const k=!T?.pagination;if(!(!T||k||T?.pagination.page>=T?.pagination.pageCount))return T.pagination.page+1},select:T=>({...T,pages:T.pages.map(k=>{if(!k)return k;const{data:F,results:_,pagination:z}=k,B=!!F;let U=[];return B?U=[F]:_&&(U=[..._].reverse()),{pagination:z,results:U}})})}),{pageGoal:y}=r,{status:b,data:v,fetchNextPage:I,hasNextPage:E}=p;(0,t.useEffect)(()=>{y>c&&E&&b==="success"&&I({pageParam:c+1})},[y,c,I,E,b]);const R=Mi(g);(0,t.useEffect)(()=>{if(b==="success"&&v&&v.pages?.at(-1)?.results&&R){const T=Ri(v.pages.at(-1).results,f);R(T)}},[b,R,v]);const S=(0,Ae.useInfiniteQuery)(["relation",...e,"search",JSON.stringify(s)],m,{enabled:Object.keys(s).length>0,getNextPageParam(T){if(!(!T?.pagination||T.pagination.page>=T.pagination.pageCount))return T.pagination.page+1}});return{relations:p,search:S,searchFor:(T,k={})=>{a({...k,_q:T})}}},_r=(e,r)=>o=>{const s=o.split(".");return s.reduce((a,c,l)=>{const d=(0,te.get)(e,a),u=(0,te.get)(r,[...s.slice(0,l),c,"__temp_key__"]);if(Array.isArray(d)&&typeof u=="number"){const m=d.findIndex(g=>g.__temp_key__===u);return a.push(m.toString()),a}return a.push(c),a},[])},Qt=({error:e,componentId:r,isComponentRelation:o,editable:s,description:a,intlLabel:c,isCreatingEntry:l,isFieldAllowed:d,isFieldReadable:u,labelAction:m,mainField:g,name:f,queryInfos:{endpoints:p,defaultParams:y,shouldDisplayRelationLink:b},placeholder:v,required:I,relationType:E,size:R,targetModel:S})=>{const[A,T]=(0,t.useState)(""),{formatMessage:k}=(0,Z.useIntl)(),{slug:F,initialData:_,modifiedData:z,relationConnect:B,relationDisconnect:U,relationLoad:$,relationReorder:G}=(0,h.useCMEditViewDataManager)(),W=f.split("."),K=_r(_,z)(f),N=P()(z,f,[]),X=Math.ceil(P()(_,f,[]).length/Dt),{relations:M,search:x,searchFor:Q}=Di([F,K.join("."),z.id,y],{relation:{enabled:!!p.relation,endpoint:p.relation,pageGoal:X,pageParams:{...y,pageSize:Dt},onLoad(J){$({target:{initialDataPath:["initialData",...K],modifiedDataPath:["modifiedData",...W],value:J}})},normalizeArguments:{mainFieldName:g.name,shouldAddLink:b,targetModel:S}},search:{endpoint:p.search,pageParams:{...y,entityId:l?void 0:o?r:_.id,pageSize:ps}}}),j=(0,t.useMemo)(()=>E.toLowerCase().includes("morph"),[E]),O=["oneWay","oneToOne","manyToOne","oneToManyMorph","oneToOneMorph"].includes(E),V=(0,t.useMemo)(()=>j?!0:l?!s:!d&&u||!s,[j,l,s,d,u]),H=J=>{const me=Zt(J,{mainFieldName:g.name,shouldAddLink:b,targetModel:S});B({name:f,value:me,toOneRelation:O})},ae=J=>{U({name:f,id:J.id})},w=()=>{M.fetchNextPage()},re=(J="")=>{const[me,Re]=Ti(N,P()(_,f));Q(J,{idsToInclude:Re,idsToOmit:me})},de=()=>{x.fetchNextPage()},pe=J=>`${J+1} of ${N.length}`,We=(J,me)=>{const Re=N[J];T(k({id:C("dnd.reorder"),defaultMessage:"{item}, moved. New position in list: {position}."},{item:Re.mainField??Re.id,position:pe(me)})),G({name:f,newIndex:me,oldIndex:J})},Je=J=>{const me=N[J];T(k({id:C("dnd.grab-item"),defaultMessage:"{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel."},{item:me.mainField??me.id,position:pe(J)}))},et=J=>{const me=N[J];T(k({id:C("dnd.drop-item"),defaultMessage:"{item}, dropped. Final position in list: {position}."},{item:me.mainField??me.id,position:pe(J)}))},tt=J=>{const me=N[J];T(k({id:C("dnd.cancel-item"),defaultMessage:"{item}, dropped. Re-order cancelled."},{item:me.mainField??me.id}))};if(!d&&l||!l&&!d&&!u)return t.createElement(h.NotAllowedInput,{name:f,intlLabel:c,labelAction:m});const be=N.length,Ce=(P()(_,K)??[]).length,nt=M.data?.pages[0]?.pagination?.total??0,we=!M.data&&be===Ce?be:be-Ce+nt;return t.createElement(Ns,{error:e,canReorder:!O,description:a,disabled:V,iconButtonAriaLabel:k({id:C("components.RelationInput.icon-button-aria-label"),defaultMessage:"Drag"}),id:f,label:`${k({id:c.id,defaultMessage:c.defaultMessage})} ${we>0?`(${we})`:""}`,labelAction:m,labelLoadMore:l?null:k({id:C("relation.loadMore"),defaultMessage:"Load More"}),labelDisconnectRelation:k({id:C("relation.disconnect"),defaultMessage:"Remove"}),listAriaDescription:k({id:C("dnd.instructions"),defaultMessage:"Press spacebar to grab and re-order"}),listHeight:320,liveText:A,loadingMessage:k({id:C("relation.isLoading"),defaultMessage:"Relations are loading"}),name:f,noRelationsMessage:k({id:C("relation.notAvailable"),defaultMessage:"No relations available"}),numberOfRelationsToDisplay:Dt,onDropItem:et,onGrabItem:Je,onCancel:tt,onRelationConnect:H,onRelationDisconnect:ae,onRelationLoadMore:w,onRelationReorder:We,onSearch:J=>re(J),onSearchNextPage:()=>de(),placeholder:k(v||{id:C("relation.add"),defaultMessage:"Add relation"}),publicationStateTranslations:{[Se.DRAFT]:k({id:C("relation.publicationState.draft"),defaultMessage:"Draft"}),[Se.PUBLISHED]:k({id:C("relation.publicationState.published"),defaultMessage:"Published"})},relations:Gt()({...M,data:N},"data","hasNextPage","isFetchingNextPage","isLoading","isSuccess"),required:I,searchResults:vi(x,{mainFieldName:g.name}),size:R})};Qt.defaultProps={componentId:void 0,editable:!0,error:void 0,description:"",labelAction:null,isComponentRelation:!1,isFieldAllowed:!0,placeholder:null,required:!1},Qt.propTypes={componentId: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,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 ki=(0,t.memo)(Qt);var Ii=yi(ki,Ei);function xi(e,r){return o=>{const s=r(o.keys);return t.createElement(e,{...o,...s})}}var wi=xi,Fi=(e,r=!1)=>[{metadatas:{intlLabel:{id:"components.InputSelect.option.placeholder",defaultMessage:"Choose here"},disabled:r,hidden:r},key:"__enum_option_null",value:""},...e.map(o=>({metadatas:{intlLabel:{id:o,defaultMessage:o},hidden:!1,disabled:!1},key:o,value:o}))],Li=(e="")=>{switch((0,te.toLower)(e)){case"boolean":return"bool";case"biginteger":return"text";case"decimal":case"float":case"integer":return"number";case"date":case"datetime":case"time":return e;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 e||"text"}},Si=e=>{let r;return e==="float"||e==="decimal"?r=.01:r=1,r};function Pi(e){const{createActionAllowedFields:r,formErrors:o,isCreatingEntry:s,modifiedData:a,onChange:c,readActionAllowedFields:l,shouldNotRunValidations:d,updateActionAllowedFields:u}=(0,h.useCMEditViewDataManager)(),m=(0,t.useMemo)(()=>s?r:u,[s,r,u]),g=(0,t.useMemo)(()=>s?[]:l,[s,l]),f=(0,te.get)(a,e,null);return{allowedFields:m,formErrors:o,isCreatingEntry:s,onChange:c,readableFields:g,shouldNotRunValidations:d,value:f}}var Ai=Pi,zr=["type","model","via","collection","default","plugin","enum","regex","pluginOptions"];function Kt({allowedFields:e,componentUid:r,fieldSchema:o,formErrors:s,isCreatingEntry:a,keys:c,labelAction:l,metadatas:d,onChange:u,readableFields:m,shouldNotRunValidations:g,queryInfos:f,value:p,size:y,customFieldInputs:b}){const{fields:v}=(0,h.useLibrary)(),{formatMessage:I}=(0,Z.useIntl)(),{contentType:E}=De(),R=(0,t.useMemo)(()=>!P()(d,"editable",!0),[d]),{type:S,customField:A}=o,T=P()(s,[c],null),k=(0,t.useMemo)(()=>sr(c),[c]),F=(0,t.useMemo)(()=>{const H=ca()(o,g?[...zr,"required","minLength"]:zr),ae=o.regex||null;if(ae){const w=new RegExp(ae);w&&(H.regex=w)}return H},[o,g]),_=(0,t.useMemo)(()=>P()(F,["required"],!1),[F]),z=(0,t.useMemo)(()=>{const H=P()(E,["attributes"],{});return P()(H,[k[0],"type"],null)==="dynamiczone"},[E,k]),B=(0,t.useMemo)(()=>Li(S),[S]),U=(0,t.useMemo)(()=>S==="media"&&!p?[]:p,[S,p]),$=(0,t.useMemo)(()=>Si(S),[S]),G=(0,t.useMemo)(()=>{const H=k.join(".");if(e.includes(H))return!0;if(z)return e.includes(k[0]);if(k.length>1){const w=Ot()(k,k.length-1).join(".");return e.includes(w)}return!1},[e,k,z]),W=(0,t.useMemo)(()=>{const H=k.join(".");if(m.includes(H))return!0;if(z)return m.includes(k[0]);if(k.length>1){const w=Ot()(k,k.length-1).join(".");return m.includes(w)}return!1},[m,k,z]),K=(0,t.useMemo)(()=>W||G,[G,W]),N=(0,t.useMemo)(()=>a?R:W&&!G?!0:R,[R,a,G,W]),X=(0,t.useMemo)(()=>Fi(o.enum||[],_),[o,_]),{label:M,description:x,placeholder:Q,visible:j}=d,O=(0,t.useMemo)(()=>{if(!d.step||B!=="datetime"&&B!=="time")return $;if(!U)return d.step;let H;return B==="datetime"?H=parseInt(U.substr(14,2),10):B==="time"&&(H=parseInt(U.slice(-2),10)),H%d.step===0?d.step:$},[B,U,d.step,$]);if(j===!1)return null;if(!K)return t.createElement(h.NotAllowedInput,{description:x?{id:x,defaultMessage:x}:null,intlLabel:{id:M,defaultMessage:M},labelAction:l,error:T&&I(T),name:c,required:_});if(S==="relation")return t.createElement(Ii,{...d,...o,componentUid:r,description:d.description?I({id:d.description,defaultMessage:d.description}):void 0,intlLabel:{id:d.label,defaultMessage:d.label},labelAction:l,isUserAllowedToEditField:G,isUserAllowedToReadField:W,name:c,placeholder:d.placeholder?{id:d.placeholder,defaultMessage:d.placeholder}:null,queryInfos:f,size:y,value:p,error:T&&I(T)});const V={uid:gi,media:v.media,wysiwyg:li,...v,...b};return t.createElement(h.GenericInput,{attribute:o,autoComplete:"new-password",intlLabel:{id:M,defaultMessage:M},isNullable:B==="bool"&&[null,void 0].includes(o.default),description:x?{id:x,defaultMessage:x}:null,disabled:N,error:T,labelAction:l,contentTypeUID:E.uid,customInputs:V,multiple:o.multiple||!1,name:c,onChange:u,options:X,placeholder:Q?{id:Q,defaultMessage:Q}:null,required:o.required||!1,step:O,type:A||B,value:U,withDefaultValue:!1})}Kt.defaultProps={componentUid:void 0,formErrors:{},labelAction:void 0,size:void 0,value:null,queryInfos:{},customFieldInputs:{}},Kt.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 Oi=(0,t.memo)(Kt,ke());var Yt=wi(Oi,Ai);const Ze=new Map;var Xt=(e=[])=>{const[r,o]=(0,t.useState)(Object.fromEntries(Ze)),s=e.filter(u=>!Ze.get(u)),[a,c]=(0,t.useState)(()=>!!s.length),l=(0,h.useCustomFields)();(0,t.useEffect)(()=>{const u=g=>{o(g),c(!1)},m=async(g,f)=>{const p=await Promise.all(f);g.forEach((y,b)=>{Ze.set(y,p[b].default)}),u(Object.fromEntries(Ze))};if(s.length>0){c(!0);const g=s.map(f=>l.get(f).components.Input());g.length>0&&m(s,g)}},[s,l]);const d=(0,t.useCallback)(()=>{Ze.clear(),o({})},[]);return{isLazyLoading:a,lazyComponentStore:r,cleanup:d}};const Jt=({componentUid:e,isFromDynamicZone:r,isNested:o,name:s})=>{const{getComponentLayout:a}=De(),l=(0,t.useMemo)(()=>a(e),[e,a]).layouts.edit,{lazyComponentStore:d}=Xt();return t.createElement(i.Box,{background:r?"":"neutral100",paddingLeft:6,paddingRight:6,paddingTop:6,paddingBottom:6,hasRadius:o,borderColor:o?"neutral200":""},t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:6},l.map((u,m)=>t.createElement(i.Grid,{gap:4,key:m},u.map(({name:g,size:f,metadatas:p,fieldSchema:y,queryInfos:b})=>{const v=y.type==="component",I=`${s}.${g}`;if(v){const E=y.component;return t.createElement(i.GridItem,{col:f,s:12,xs:12,key:g},t.createElement(mt,{componentUid:E,intlLabel:{id:p.label,defaultMessage:p.label},isNested:!0,isRepeatable:y.repeatable,max:y.max,min:y.min,name:I,required:y.required||!1}))}return t.createElement(i.GridItem,{col:f,key:g,s:12,xs:12},t.createElement(Yt,{componentUid:e,keys:I,fieldSchema:y,metadatas:p,queryInfos:b,size:f,customFieldInputs:d}))})))))};Jt.defaultProps={isFromDynamicZone:!1,isNested:!1},Jt.propTypes={componentUid:n().string.isRequired,isFromDynamicZone:n().bool,isNested:n().bool,name:n().string.isRequired};var $i=Jt,qi=D(41119),Wr=D.n(qi);const Bi=q.default.span`
|
|
744
|
-
display: block;
|
|
745
|
-
background-color: ${({theme:e})=>e.colors.primary100};
|
|
746
|
-
outline: 1px dashed ${({theme:e})=>e.colors.primary500};
|
|
747
|
-
outline-offset: -1px;
|
|
748
|
-
padding: ${({theme:e})=>e.spaces[6]};
|
|
749
|
-
`;var Ni=()=>t.createElement(Bi,{padding:6,background:"primary100"});const ji=(0,q.default)(i.IconButton)`
|
|
750
|
-
background-color: transparent;
|
|
751
|
-
|
|
752
|
-
svg {
|
|
753
|
-
path {
|
|
754
|
-
fill: ${({theme:e,expanded:r})=>r?e.colors.primary600:e.colors.neutral600};
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
&:hover {
|
|
759
|
-
svg {
|
|
760
|
-
path {
|
|
761
|
-
fill: ${({theme:e})=>e.colors.primary600};
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
`,Vi=(0,q.default)(i.Flex)`
|
|
766
|
-
& .drag-handle {
|
|
767
|
-
background: unset;
|
|
768
|
-
|
|
769
|
-
svg {
|
|
770
|
-
path {
|
|
771
|
-
fill: ${({theme:e,expanded:r})=>r?e.colors.primary600:void 0};
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
&:hover {
|
|
776
|
-
svg {
|
|
777
|
-
path {
|
|
778
|
-
/* keeps the hover style of the accordion */
|
|
779
|
-
fill: ${({theme:e})=>e.colors.primary600};
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
`,en=({componentFieldName:e,componentUid:r,fields:o,index:s,isOpen:a,isReadOnly:c,mainField:l,moveComponentField:d,onClickToggle:u,toggleCollapses:m,onGrabItem:g,onDropItem:f,onCancel:p})=>{const{modifiedData:y,removeRepeatableField:b,triggerFormValidation:v}=(0,h.useCMEditViewDataManager)(),I=Wr()(P()(y,[...e.split("."),l],"")),E=(0,t.useRef)(null),{formatMessage:R}=(0,Z.useIntl)(),[S]=e.split("."),[{handlerId:A,isDragging:T,handleKeyDown:k},F,_,z,B]=kt(!c,{type:`${he.COMPONENT}_${S}`,index:s,item:{displayedValue:I},onMoveItem:d,onStart(){m()},onEnd(){v()},onGrabItem:g,onDropItem:f,onCancel:p});(0,t.useEffect)(()=>{B((0,Ue.rX)(),{captureDraggingState:!1})},[B,s]);const U=ot(E,z),$=ot(F,_),{lazyComponentStore:G}=Xt();return t.createElement(i.Box,{ref:$},T?t.createElement(Ni,null):t.createElement(i.Accordion,{expanded:a,onToggle:u,id:e,size:"S"},t.createElement(i.AccordionToggle,{action:c?null:t.createElement(Vi,{gap:0,expanded:a},t.createElement(ji,{expanded:a,noBorder:!0,onClick:()=>{b(e),m()},label:R({id:C("containers.Edit.delete"),defaultMessage:"Delete"}),icon:t.createElement(L.Trash,null)}),t.createElement(i.IconButton,{className:"drag-handle",ref:U,forwardedAs:"div",role:"button",noBorder:!0,tabIndex:0,onClick:W=>W.stopPropagation(),"data-handler-id":A,label:R({id:C("components.DragHandle-label"),defaultMessage:"Drag"}),onKeyDown:k},t.createElement(L.Drag,null))),title:I,togglePosition:"left"}),t.createElement(i.AccordionContent,null,t.createElement(i.Flex,{direction:"column",alignItems:"stretch",background:"neutral100",padding:6,gap:6},o.map((W,K)=>t.createElement(i.Grid,{gap:4,key:K},W.map(({name:N,fieldSchema:X,metadatas:M,queryInfos:x,size:Q})=>{const j=X.type==="component",O=`${e}.${N}`;if(j){const V=X.component;return t.createElement(i.GridItem,{col:Q,s:12,xs:12,key:N},t.createElement(mt,{componentUid:V,intlLabel:{id:M.label,defaultMessage:M.label},isRepeatable:X.repeatable,isNested:!0,name:O,max:X.max,min:X.min,required:X.required}))}return t.createElement(i.GridItem,{key:O,col:Q,s:12,xs:12},t.createElement(Yt,{componentUid:r,fieldSchema:X,keys:O,metadatas:M,queryInfos:x,size:Q,customFieldInputs:G}))})))))))};en.defaultProps={componentUid:void 0,fields:[],isReadOnly:!1,isOpen:!1,onGrabItem:void 0,onDropItem:void 0,onCancel:void 0,toggleCollapses(){}},en.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 _i=(0,t.memo)(en);const zi=(0,q.default)(i.Box)`
|
|
785
|
-
overflow: hidden;
|
|
786
|
-
border-bottom: 1px solid ${({theme:e})=>e.colors.neutral200};
|
|
787
|
-
border-right: 1px solid ${({theme:e})=>e.colors.neutral200};
|
|
788
|
-
border-left: 1px solid ${({theme:e})=>e.colors.neutral200};
|
|
789
|
-
border-radius: 0 0 ${({theme:e})=>e.borderRadius} ${({theme:e})=>e.borderRadius};
|
|
790
|
-
`,Wi=(0,q.default)(i.Box)`
|
|
791
|
-
border-bottom: none;
|
|
792
|
-
|
|
793
|
-
/* add the borders and make sure the top is transparent to avoid jumping with the hover effect */
|
|
794
|
-
& > div > div {
|
|
795
|
-
border: 1px solid ${({theme:e})=>e.colors.neutral200};
|
|
796
|
-
border-top-color: transparent;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
/* the top accordion _does_ need a border though */
|
|
800
|
-
& > div:first-child > div {
|
|
801
|
-
border-top: 1px solid ${({theme:e})=>e.colors.neutral200};
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
/* Reset all the border-radius' */
|
|
805
|
-
& > div > div,
|
|
806
|
-
& > div > div > div {
|
|
807
|
-
border-radius: unset;
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
/* Give the border radius back to the first accordion */
|
|
811
|
-
& > div:first-child > div,
|
|
812
|
-
& > div:first-child > div > div {
|
|
813
|
-
border-radius: ${({theme:e})=>e.borderRadius} ${({theme:e})=>e.borderRadius} 0 0;
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
& > div > div[data-strapi-expanded='true'] {
|
|
817
|
-
border: 1px solid ${({theme:e})=>e.colors.primary600};
|
|
818
|
-
}
|
|
819
|
-
`,tn=({children:e,error:r})=>{const{formatMessage:o}=(0,Z.useIntl)();return t.createElement(i.KeyboardNavigable,{attributeName:"data-strapi-accordion-toggle"},e,r&&t.createElement(i.Box,{paddingTop:1},t.createElement(i.Typography,{variant:"pi",textColor:"danger600"},o({id:r.id,defaultMessage:r.defaultMessage},{...r.values}))))};tn.defaultProps={error:void 0},tn.propTypes={children:n().node.isRequired,error:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object})};function Ui(e,r={}){return Object.keys(r).filter(o=>o.startsWith(e)).map(o=>o.split(".").slice(0,e.split(".").length+1).join("."))}const Hi=(0,q.default)(i.TextButton)`
|
|
820
|
-
height: 100%;
|
|
821
|
-
width: 100%;
|
|
822
|
-
border-radius: 0 0 4px 4px;
|
|
823
|
-
display: flex;
|
|
824
|
-
justify-content: center;
|
|
825
|
-
span {
|
|
826
|
-
font-weight: 600;
|
|
827
|
-
font-size: 14px;
|
|
828
|
-
}
|
|
829
|
-
`,nn=({componentUid:e,componentValue:r,componentValueLength:o,isReadOnly:s,max:a,min:c,name:l})=>{const{addRepeatableComponentToField:d,formErrors:u,moveComponentField:m}=(0,h.useCMEditViewDataManager)(),g=(0,h.useNotification)(),{formatMessage:f}=(0,Z.useIntl)(),[p,y]=(0,t.useState)(""),[b,v]=(0,t.useState)(""),{getComponentLayout:I,components:E}=De(),R=(0,t.useMemo)(()=>I(e),[e,I]),S=(0,t.useMemo)(()=>Mt(r||[])+1,[r]),A=Ui(l,u),T=c-o,k=P()(u,l,{id:""}).id.includes("min"),F=()=>{y("")},_=()=>{s||(o<a?(d(l,R,E,k),y(S)):o>=a&&g({type:"info",message:{id:C("components.notification.info.maximum-requirement")}}))},z=(M,x)=>{v(f({id:C("dnd.reorder"),defaultMessage:"{item}, moved. New position in list: {position}."},{item:`${l}.${x}`,position:$(M)})),m({name:l,newIndex:M,currentIndex:x})},B=P()(R,["settings","mainField"],"id"),U=M=>()=>{y(p===M?"":M)},$=M=>`${M+1} of ${o}`,G=M=>{v(f({id:C("dnd.cancel-item"),defaultMessage:"{item}, dropped. Re-order cancelled."},{item:`${l}.${M}`}))},W=M=>{v(f({id:C("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:`${l}.${M}`,position:$(M)}))},K=M=>{v(f({id:C("dnd.drop-item"),defaultMessage:"{item}, dropped. Final position in list: {position}."},{item:`${l}.${M}`,position:$(M)}))};let N=u[l];if(k?N={id:C("components.DynamicZone.missing-components"),defaultMessage:"There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}",values:{number:T}}:A.some(M=>M.split(".").length>1)&&!k&&(N={id:C("components.RepeatableComponent.error-message"),defaultMessage:"The component(s) contain error(s)"}),o===0)return t.createElement(Lr,{error:N,isReadOnly:s,onClick:_});const X=`${l}-item-instructions`;return t.createElement(i.Box,{hasRadius:!0},t.createElement(i.VisuallyHidden,{id:X},f({id:C("dnd.instructions"),defaultMessage:"Press spacebar to grab and re-order"})),t.createElement(i.VisuallyHidden,{"aria-live":"assertive"},b),t.createElement(tn,{error:N,ariaDescribedBy:X},t.createElement(Wi,{"aria-describedby":X},r.map(({__temp_key__:M},x)=>t.createElement(_i,{componentFieldName:`${l}.${x}`,componentUid:e,fields:R.layouts.edit,key:M,index:x,isOpen:p===M,isReadOnly:s,mainField:B,moveComponentField:z,onClickToggle:U(M),toggleCollapses:F,onCancel:G,onDropItem:K,onGrabItem:W}))),t.createElement(zi,null,t.createElement(i.Flex,{justifyContent:"center",height:"48px",background:"neutral0"},t.createElement(Hi,{disabled:s,onClick:_,startIcon:t.createElement(L.Plus,null)},f({id:C("containers.EditView.add.new-entry"),defaultMessage:"Add an entry"}))))))};nn.defaultProps={componentValue:null,componentValueLength:0,isReadOnly:!1,max:1/0,min:0},nn.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 Gi=(0,t.memo)(nn);const rn=({addNonRepeatableComponentToField:e,componentUid:r,intlLabel:o,isCreatingEntry:s,isFromDynamicZone:a,isRepeatable:c,isNested:l,labelAction:d,max:u,min:m,name:g,hasChildrenAllowedFields:f,hasChildrenReadableFields:p,isReadOnly:y,componentValue:b,removeComponentFromField:v,required:I})=>{const{formatMessage:E}=(0,Z.useIntl)(),R=ea()(b),S=b!==null||a,A=!c&&S&&!a&&f,{getComponentLayout:T,components:k}=De(),F=(0,t.useMemo)(()=>T(r),[r,T]);if(!f&&s)return t.createElement(h.NotAllowedInput,{labelAction:d,intlLabel:o,name:g});if(!f&&!s&&!p)return t.createElement(h.NotAllowedInput,{labelAction:d,intlLabel:o,name:g});const _=()=>{e(g,F,k)};return t.createElement(i.Box,null,t.createElement(i.Flex,{justifyContent:"space-between"},o&&t.createElement(aa,{intlLabel:o,labelAction:d,name:g,numberOfEntries:R,showNumberOfEntries:c,required:I}),A&&t.createElement(i.IconButton,{label:E({id:C("components.reset-entry"),defaultMessage:"Reset Entry"}),icon:t.createElement(L.Trash,null),noBorder:!0,onClick:()=>{v(g,r)}})),t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:1},!c&&!S&&t.createElement(Lr,{isReadOnly:y,onClick:_}),!c&&S&&t.createElement($i,{componentUid:r,isFromDynamicZone:a,isNested:l,name:g}),c&&t.createElement(Gi,{componentValue:b,componentValueLength:R,componentUid:r,isReadOnly:y,max:u,min:m,name:g})))};rn.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},rn.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 Zi=(0,t.memo)(rn,ke());var mt=na(Zi,oa);const Qi=(0,q.default)(i.Flex)`
|
|
830
|
-
/*
|
|
831
|
-
we need to remove the background from the button but we can't
|
|
832
|
-
wrap the element in styled because it breaks the forwardedAs which
|
|
833
|
-
we need for drag handler to work on firefox
|
|
834
|
-
*/
|
|
835
|
-
div[role='button'] {
|
|
836
|
-
background: transparent;
|
|
837
|
-
}
|
|
838
|
-
`,Ki=(0,q.default)(i.IconButton)`
|
|
839
|
-
background-color: transparent;
|
|
840
|
-
|
|
841
|
-
svg path {
|
|
842
|
-
fill: ${({theme:e,expanded:r})=>r?e.colors.primary600:e.colors.neutral600};
|
|
843
|
-
}
|
|
844
|
-
`,Yi=(0,q.default)(i.Box)`
|
|
845
|
-
> div:first-child {
|
|
846
|
-
box-shadow: ${({theme:e})=>e.shadows.tableShadow};
|
|
847
|
-
}
|
|
848
|
-
`,Xi=(0,q.default)(i.Box)`
|
|
849
|
-
border-radius: 0 0 ${({theme:e})=>e.spaces[1]} ${({theme:e})=>e.spaces[1]};
|
|
850
|
-
`,Ji=(0,q.default)(i.Box)`
|
|
851
|
-
width: ${({theme:e})=>e.spaces[2]};
|
|
852
|
-
height: ${({theme:e})=>e.spaces[4]};
|
|
853
|
-
`,el=q.default.span`
|
|
854
|
-
display: block;
|
|
855
|
-
background-color: ${({theme:e})=>e.colors.primary100};
|
|
856
|
-
outline: 1px dashed ${({theme:e})=>e.colors.primary500};
|
|
857
|
-
outline-offset: -1px;
|
|
858
|
-
padding: ${({theme:e})=>e.spaces[6]};
|
|
859
|
-
`,tl=(0,q.default)(i.Box)`
|
|
860
|
-
list-style: none;
|
|
861
|
-
padding: 0;
|
|
862
|
-
margin: 0;
|
|
863
|
-
`,on=({componentUid:e,formErrors:r,index:o,isFieldAllowed:s,name:a,onRemoveComponentClick:c,onMoveComponent:l,onGrabItem:d,onDropItem:u,onCancel:m})=>{const[g,f]=(0,t.useState)(!0),{formatMessage:p}=(0,Z.useIntl)(),{getComponentLayout:y}=De(),{modifiedData:b}=(0,h.useCMEditViewDataManager)(),{icon:v,friendlyName:I,mainValue:E}=(0,t.useMemo)(()=>{const W=y(e),{info:{icon:K,displayName:N}}=W,X=P()(W,["settings","mainField"],"id"),M=P()(b,[a,o,X])??"",x=X==="id"?"":String(M).trim(),Q=x.length>0?` - ${x}`:x;return{friendlyName:N,icon:K,mainValue:Q}},[e,y,b,a,o]),R=Object.keys(r).filter(W=>{const K=W.split(".");return`${K[0]}.${K[1]}`==`${a}.${o}`});let S;R.length>0&&(S=p({id:C("components.DynamicZone.error-message"),defaultMessage:"The component contains error(s)"}));const A=()=>{f(W=>!W)},[{handlerId:T,isDragging:k,handleKeyDown:F},_,z,B,U]=kt(s,{type:`${he.DYNAMIC_ZONE}_${a}`,index:o,item:{displayedValue:`${I}${E}`,icon:v},onMoveItem:l,onGrabItem:d,onDropItem:u,onCancel:m});(0,t.useEffect)(()=>{U((0,Ue.rX)(),{captureDraggingState:!1})},[U,o]);const $=ot(_,z),G=s?t.createElement(Qi,{gap:0,expanded:g},t.createElement(Ki,{noBorder:!0,label:p({id:C("components.DynamicZone.delete-label"),defaultMessage:"Delete {name}"},{name:I}),onClick:c},t.createElement(L.Trash,null)),t.createElement(i.IconButton,{forwardedAs:"div",role:"button",noBorder:!0,tabIndex:0,onClick:W=>W.stopPropagation(),"data-handler-id":T,ref:B,label:p({id:C("components.DragHandle-label"),defaultMessage:"Drag"}),onKeyDown:F},t.createElement(L.Drag,null))):null;return t.createElement(tl,{as:"li"},t.createElement(i.Flex,{justifyContent:"center"},t.createElement(Ji,{background:"neutral200"})),t.createElement(Yi,{ref:$,hasRadius:!0},k?t.createElement(el,{padding:6,background:"primary100"}):t.createElement(i.Accordion,{expanded:g,onToggle:A,size:"S",error:S},t.createElement(i.AccordionToggle,{action:G,title:`${I}${E}`,togglePosition:"left"}),t.createElement(i.AccordionContent,null,t.createElement(Xi,{background:"neutral0"},t.createElement(mt,{componentUid:e,icon:v,name:`${a}.${o}`,isFromDynamicZone:!0}))))))};on.defaultProps={formErrors:{},index:0,isFieldAllowed:!0,onGrabItem:void 0,onDropItem:void 0,onCancel:void 0},on.propTypes={componentUid:n().string.isRequired,formErrors:n().object,index:n().number,isFieldAllowed:n().bool,name:n().string.isRequired,onGrabItem:n().func,onDropItem:n().func,onCancel:n().func,onMoveComponent:n().func.isRequired,onRemoveComponentClick:n().func.isRequired};var nl=on;const sn=(0,q.default)(L.PlusCircle)`
|
|
864
|
-
transform: ${({$isOpen:e})=>e?"rotate(45deg)":"rotate(0deg)"};
|
|
865
|
-
> circle {
|
|
866
|
-
fill: ${({theme:e,$hasError:r})=>r?e.colors.danger200:e.colors.neutral150};
|
|
867
|
-
}
|
|
868
|
-
> path {
|
|
869
|
-
fill: ${({theme:e,$hasError:r})=>r?e.colors.danger600:e.colors.neutral600};
|
|
870
|
-
}
|
|
871
|
-
`,rl=(0,q.default)(i.BaseButton)`
|
|
872
|
-
border-radius: 26px;
|
|
873
|
-
border-color: ${({theme:e})=>e.colors.neutral150};
|
|
874
|
-
background: ${({theme:e})=>e.colors.neutral0};
|
|
875
|
-
padding-top: ${({theme:e})=>e.spaces[3]};
|
|
876
|
-
padding-right: ${({theme:e})=>e.spaces[4]};
|
|
877
|
-
padding-bottom: ${({theme:e})=>e.spaces[3]};
|
|
878
|
-
padding-left: ${({theme:e})=>e.spaces[4]};
|
|
879
|
-
|
|
880
|
-
box-shadow: ${({theme:e})=>e.shadows.filterShadow};
|
|
881
|
-
|
|
882
|
-
svg {
|
|
883
|
-
height: ${({theme:e})=>e.spaces[6]};
|
|
884
|
-
width: ${({theme:e})=>e.spaces[6]};
|
|
885
|
-
> path {
|
|
886
|
-
fill: ${({theme:e})=>e.colors.neutral600};
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
&:hover {
|
|
890
|
-
color: ${({theme:e})=>e.colors.primary600} !important;
|
|
891
|
-
${i.Typography} {
|
|
892
|
-
color: ${({theme:e})=>e.colors.primary600} !important;
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
${sn} {
|
|
896
|
-
> circle {
|
|
897
|
-
fill: ${({theme:e})=>e.colors.primary600};
|
|
898
|
-
}
|
|
899
|
-
> path {
|
|
900
|
-
fill: ${({theme:e})=>e.colors.neutral100};
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
&:active {
|
|
905
|
-
${i.Typography} {
|
|
906
|
-
color: ${({theme:e})=>e.colors.primary600};
|
|
907
|
-
}
|
|
908
|
-
${sn} {
|
|
909
|
-
> circle {
|
|
910
|
-
fill: ${({theme:e})=>e.colors.primary600};
|
|
911
|
-
}
|
|
912
|
-
> path {
|
|
913
|
-
fill: ${({theme:e})=>e.colors.neutral100};
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
`,ol=(0,q.default)(i.Box)`
|
|
918
|
-
height: 100%;
|
|
919
|
-
`,an=({hasError:e,hasMaxError:r,hasMinError:o,isDisabled:s,isOpen:a,label:c,missingComponentNumber:l,name:d,onClick:u})=>{const{formatMessage:m}=(0,Z.useIntl)(),g=m({id:C("components.DynamicZone.add-component"),defaultMessage:"Add a component to {componentName}"},{componentName:c||d}),f=m({id:"app.utils.close-label",defaultMessage:"Close"});let p=a?f:g;return r&&!a&&(p=m({id:"components.Input.error.validation.max",defaultMessage:"The value is too high."})),o&&!a&&(p=m({id:C("components.DynamicZone.missing-components"),defaultMessage:"There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"},{number:l})),t.createElement(i.Flex,{justifyContent:"center"},t.createElement(i.Box,{style:{cursor:s?"not-allowed":"pointer"}},t.createElement(rl,{type:"button",onClick:u,disabled:s,hasError:e},t.createElement(i.Flex,null,t.createElement(ol,{"aria-hidden":!0,paddingRight:2},t.createElement(sn,{$isOpen:a,$hasError:e&&!a})),t.createElement(i.Typography,{variant:"pi",fontWeight:"bold",textColor:e&&!a?"danger600":"neutral500"},p)))))};an.defaultProps={hasError:!1,hasMaxError:!1,hasMinError:!1,isDisabled:!1,isOpen:!1,label:"",missingComponentNumber:0},an.propTypes={label:n().string,hasError:n().bool,hasMaxError:n().bool,hasMinError:n().bool,isDisabled:n().bool,isOpen:n().bool,missingComponentNumber:n().number,name:n().string.isRequired,onClick:n().func.isRequired};var sl=an;const al=(0,q.default)(i.Box)`
|
|
920
|
-
border-radius: ${(0,h.pxToRem)(26)};
|
|
921
|
-
`,ln=({label:e,labelAction:r,name:o,numberOfComponents:s,required:a,intlDescription:c})=>{const{formatMessage:l}=(0,Z.useIntl)(),d=l({id:e||o,defaultMessage:e||o});return t.createElement(i.Flex,{justifyContent:"center"},t.createElement(i.Box,null,t.createElement(al,{paddingTop:3,paddingBottom:3,paddingRight:4,paddingLeft:4,background:"neutral0",shadow:"filterShadow",color:"neutral500"},t.createElement(i.Flex,{direction:"column",justifyContent:"center"},t.createElement(i.Flex,{maxWidth:(0,h.pxToRem)(356)},t.createElement(i.Typography,{variant:"pi",textColor:"neutral600",fontWeight:"bold",ellipsis:!0},d,"\xA0"),t.createElement(i.Typography,{variant:"pi",textColor:"neutral600",fontWeight:"bold"},"(",s,")"),a&&t.createElement(i.Typography,{textColor:"danger600"},"*"),r&&t.createElement(i.Box,{paddingLeft:1},r)),c&&t.createElement(i.Box,{paddingTop:1,maxWidth:(0,h.pxToRem)(356)},t.createElement(i.Typography,{variant:"pi",textColor:"neutral600",ellipsis:!0},l(c)))))))};ln.defaultProps={intlDescription:void 0,label:"",labelAction:void 0,numberOfComponents:0,required:!1},ln.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};var il=ln,ll=D(81346),Ur=D.n(ll);const pt=5,gt=8,cl=(0,q.default)(i.Flex)`
|
|
922
|
-
border-radius: ${({showBackground:e})=>e?"50%":0};
|
|
923
|
-
color: ${({theme:e})=>e.colors.neutral600};
|
|
924
|
-
height: ${({theme:e,size:r})=>e.spaces[r==="S"?pt:gt]};
|
|
925
|
-
width: ${({theme:e,size:r})=>e.spaces[r==="S"?pt:gt]};
|
|
926
|
-
|
|
927
|
-
svg {
|
|
928
|
-
height: ${({theme:e,size:r})=>e.spaces[r==="S"?pt-2:gt-3]};
|
|
929
|
-
width: ${({theme:e,size:r})=>e.spaces[r==="S"?pt-2:gt-3]};
|
|
930
|
-
}
|
|
931
|
-
`;function ft({showBackground:e=!0,size:r="M"}){return t.createElement(cl,{alignItems:"center",background:e?"neutral200":null,justifyContent:"center",size:r,showBackground:e},t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},t.createElement("path",{d:"M216.3 2c4.8-2.6 10.5-2.6 15.3 0L422.3 106c5.1 2.8 8.3 8.2 8.3 14s-3.2 11.2-8.3 14L231.7 238c-4.8 2.6-10.5 2.6-15.3 0L25.7 134c-5.1-2.8-8.3-8.2-8.3-14s3.2-11.2 8.3-14L216.3 2zM23.7 170l176 96c5.1 2.8 8.3 8.2 8.3 14V496c0 5.6-3 10.9-7.8 13.8s-10.9 3-15.8 .3L8.3 414C3.2 411.2 0 405.9 0 400V184c0-5.6 3-10.9 7.8-13.8s10.9-3 15.8-.3zm400.7 0c5-2.7 11-2.6 15.8 .3s7.8 8.1 7.8 13.8V400c0 5.9-3.2 11.2-8.3 14l-176 96c-5 2.7-11 2.6-15.8-.3s-7.8-8.1-7.8-13.8V280c0-5.9 3.2-11.2 8.3-14l176-96z",fill:"currentColor"})))}ft.defaultProps={showBackground:!0,size:"M"},ft.propTypes={showBackground:n().bool,size:n().string};const dl=(0,q.default)(i.Box)`
|
|
932
|
-
flex-shrink: 0;
|
|
933
|
-
height: ${(0,h.pxToRem)(84)};
|
|
934
|
-
border: 1px solid ${({theme:e})=>e.colors.neutral200};
|
|
935
|
-
background: ${({theme:e})=>e.colors.neutral100};
|
|
936
|
-
border-radius: ${({theme:e})=>e.borderRadius};
|
|
937
|
-
display: flex;
|
|
938
|
-
justify-content: center;
|
|
939
|
-
align-items: center;
|
|
940
|
-
|
|
941
|
-
&:focus,
|
|
942
|
-
&:hover {
|
|
943
|
-
border: 1px solid ${({theme:e})=>e.colors.primary200};
|
|
944
|
-
background: ${({theme:e})=>e.colors.primary100};
|
|
945
|
-
|
|
946
|
-
${i.Typography} {
|
|
947
|
-
color: ${({theme:e})=>e.colors.primary600};
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
/* > Flex > ComponentIcon */
|
|
951
|
-
> div > div:first-child {
|
|
952
|
-
background: ${({theme:e})=>e.colors.primary200};
|
|
953
|
-
color: ${({theme:e})=>e.colors.primary600};
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
`;function cn({children:e,onClick:r}){return t.createElement(dl,{as:"button",type:"button",onClick:r,hasRadius:!0},t.createElement(i.Flex,{direction:"column",gap:1,alignItems:"center",justifyContent:"center"},t.createElement(ft,null),t.createElement(i.Typography,{variant:"pi",fontWeight:"bold",textColor:"neutral600"},e)))}cn.defaultProps={onClick(){}},cn.propTypes={children:n().node.isRequired,onClick:n().func};const ul=q.default.div`
|
|
957
|
-
display: grid;
|
|
958
|
-
grid-template-columns: repeat(auto-fit, ${140/16}rem);
|
|
959
|
-
grid-gap: ${({theme:e})=>e.spaces[1]};
|
|
960
|
-
`,dn=({category:e,components:r,variant:o,isOpen:s,onAddComponent:a,onToggle:c})=>{const{formatMessage:l}=(0,Z.useIntl)(),d=()=>{c(e)};return t.createElement(i.Accordion,{expanded:s,onToggle:d,size:"S"},t.createElement(i.AccordionToggle,{variant:o,title:l({id:e,defaultMessage:e}),togglePosition:"left"}),t.createElement(i.AccordionContent,null,t.createElement(i.Box,{paddingTop:4,paddingBottom:4,paddingLeft:3,paddingRight:3},t.createElement(ul,null,r.map(({componentUid:u,info:{displayName:m}})=>t.createElement(cn,{key:u,onClick:a(u)},l({id:m,defaultMessage:m})))))))};dn.defaultProps={components:[],isOpen:!1,variant:"primary"},dn.propTypes={category:n().string.isRequired,components:n().array,isOpen:n().bool,onAddComponent:n().func.isRequired,onToggle:n().func.isRequired,variant:n().oneOf(["primary","secondary"])};var ml=dn;const un=({components:e,isOpen:r,onClickAddComponent:o})=>{const{formatMessage:s}=(0,Z.useIntl)(),{getComponentLayout:a}=De(),[c,l]=(0,t.useState)(""),d=(0,t.useMemo)(()=>{const g=e.map(p=>{const{category:y,info:b}=a(p);return{componentUid:p,category:y,info:b}}),f=Ur()(g,"category");return Object.keys(f).reduce((p,y)=>(p.push({category:y,components:f[y]}),p),[])},[e,a]);(0,t.useEffect)(()=>{r&&d.length>0&&l(d[0].category)},[r,d]);const u=g=>()=>{o(g),l("")},m=g=>{l(f=>f===g?"":g)};return r?t.createElement(i.Box,{paddingBottom:6},t.createElement(i.Box,{paddingTop:6,paddingBottom:6,paddingLeft:5,paddingRight:5,background:"neutral0",shadow:"tableShadow",borderColor:"neutral150",hasRadius:!0},t.createElement(i.Flex,{justifyContent:"center"},t.createElement(i.Typography,{fontWeight:"bold",textColor:"neutral600"},s({id:C("components.DynamicZone.ComponentPicker-label"),defaultMessage:"Pick one component"}))),t.createElement(i.Box,{paddingTop:2},t.createElement(i.KeyboardNavigable,{attributeName:"data-strapi-accordion-toggle"},d.map(({category:g,components:f},p)=>t.createElement(ml,{key:g,category:g,components:f,onAddComponent:u,isOpen:g===c,onToggle:m,variant:p%2===1?"primary":"secondary"})))))):null};un.defaultProps={components:[],isOpen:!1},un.propTypes={components:n().array,isOpen:n().bool,onClickAddComponent:n().func.isRequired};var pl=un;const mn=({name:e,addComponentToDynamicZone:r,formErrors:o,isCreatingEntry:s,isFieldAllowed:a,isFieldReadable:c,labelAction:l,moveComponentField:d,removeComponentFromDynamicZone:u,dynamicDisplayedComponents:m,fieldSchema:g,metadatas:f})=>{const[p,y]=(0,t.useState)(!1),[b,v]=(0,t.useState)(""),{formatMessage:I}=(0,Z.useIntl)(),E=(0,h.useNotification)(),{getComponentLayout:R,components:S}=De(),A=m.length,T=f.description?{id:f.description,defaultMessage:f.description}:null,{max:k=1/0,min:F=-1/0}=g,_=(0,t.useMemo)(()=>Object.keys(o).filter(O=>O===e).map(O=>o[O]),[o,e]),z=F-A,B=_.length>0,U=_.length>0&&P()(_,[0,"id"],"").includes("min"),$=B&&P()(_,[0,"id"],"")==="components.Input.error.validation.max",G=O=>{y(!1);const V=R(O);r(e,V,S,B)},W=()=>{A<k?y(O=>!O):E({type:"info",message:{id:C("components.notification.info.maximum-requirement")}})},K=(O,V)=>{v(I({id:C("dnd.reorder"),defaultMessage:"{item}, moved. New position in list: {position}."},{item:`${e}.${V}`,position:N(O)})),d({name:e,newIndex:O,currentIndex:V})},N=O=>`${O+1} of ${m.length}`,X=O=>{v(I({id:C("dnd.cancel-item"),defaultMessage:"{item}, dropped. Re-order cancelled."},{item:`${e}.${O}`}))},M=O=>{v(I({id:C("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:`${e}.${O}`,position:N(O)}))},x=O=>{v(I({id:C("dnd.drop-item"),defaultMessage:"{item}, dropped. Final position in list: {position}."},{item:`${e}.${O}`,position:N(O)}))},Q=(O,V)=>()=>{u(O,V)};if(!a&&(s||!c&&!s))return t.createElement(h.NotAllowedInput,{description:T,intlLabel:{id:f.label,defaultMessage:f.label},labelAction:l,name:e});const j=`${e}-item-instructions`;return t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:6},A>0&&t.createElement(i.Box,null,t.createElement(il,{intlDescription:T,label:f.label,labelAction:l,name:e,numberOfComponents:A,required:g.required||!1}),t.createElement(i.VisuallyHidden,{id:j},I({id:C("dnd.instructions"),defaultMessage:"Press spacebar to grab and re-order"})),t.createElement(i.VisuallyHidden,{"aria-live":"assertive"},b),t.createElement("ol",{"aria-describedby":j},m.map(({componentUid:O,id:V},H)=>t.createElement(nl,{componentUid:O,formErrors:o,key:`${O}-${V}`,index:H,isFieldAllowed:a,name:e,onMoveComponent:K,onRemoveComponentClick:Q(e,H),onCancel:X,onDropItem:x,onGrabItem:M})))),t.createElement(sl,{hasError:B,hasMaxError:$,hasMinError:U,isDisabled:!a,label:f.label,missingComponentNumber:z,isOpen:p,name:e,onClick:W}),t.createElement(pl,{isOpen:p,components:g.components??[],onClickAddComponent:G}))};mn.defaultProps={dynamicDisplayedComponents:[],fieldSchema:{max:1/0,min:-1/0},labelAction:null},mn.propTypes={addComponentToDynamicZone:n().func.isRequired,dynamicDisplayedComponents:n().arrayOf(n().shape({componentUid:n().string.isRequired,id:n().number.isRequired})),fieldSchema:n().shape({components:n().array.isRequired,max:n().number,min:n().number,required:n().bool}),formErrors:n().object.isRequired,isCreatingEntry:n().bool.isRequired,isFieldAllowed:n().bool.isRequired,isFieldReadable:n().bool.isRequired,labelAction:n().element,metadatas:n().shape({description:n().string,label:n().string}).isRequired,moveComponentField:n().func.isRequired,name:n().string.isRequired,removeComponentFromDynamicZone:n().func.isRequired};const gl=(0,t.memo)(mn,ke());var fl=Ks(gl,Xs),Ie=D(41578);const ht=()=>({type:Ie.ZA}),pn=e=>({type:Ie.Id,data:e}),gn=(e,r=!1)=>({type:Ie.TP,rawQuery:e,isSingleType:r}),Hr=()=>({type:Ie.c2}),Gr=(e,r)=>({type:Ie.w7,componentsDataStructure:e,contentTypeDataStructure:r}),ie=e=>({type:Ie.d0,status:e}),xe=e=>({type:Ie.t9,data:e}),hl=()=>({type:Ie.tE});var fn=e=>e["content-manager_editViewCrudReducer"];const hn=({allLayoutData:e,children:r,slug:o,id:s,origin:a})=>{const c=(0,Ae.useQueryClient)(),l=(0,h.useNotification)(),{setCurrentStep:d}=(0,h.useGuidedTour)(),{trackUsage:u}=(0,h.useTracking)(),{push:m,replace:g}=(0,oe.useHistory)(),[{rawQuery:f}]=(0,h.useQueryParams)(),p=(0,le.useDispatch)(),{componentsDataStructure:y,contentTypeDataStructure:b,data:v,isLoading:I,status:E}=(0,le.useSelector)(fn),R=br(o),{formatAPIError:S}=(0,h.useAPIErrorHandler)(C),A=(0,t.useRef)(!0),T=(0,t.useRef)(u),k=(0,t.useRef)(e),F=(0,h.useFetchClient)(),{put:_,post:z,del:B}=F,U=s===null,$=(0,t.useMemo)(()=>U&&!a?null:ce(`collection-types/${o}/${a||s}`),[o,s,U,a]),G=(0,t.useCallback)(V=>a?(0,h.contentManagementUtilRemoveFieldsFromData)(V,k.current.contentType,k.current.components):V,[a]),W=(0,t.useCallback)(V=>{const H=ir(V,k.current.contentType,k.current.components);return(0,h.formatContentTypeData)(H,k.current.contentType,k.current.components)},[]);(0,t.useEffect)(()=>{const V=Object.keys(e.components).reduce((w,re)=>{const de=st(P()(e,["components",re,"attributes"],{}),e.components);return w[re]=(0,h.formatContentTypeData)(de,e.components[re],e.components),w},{}),H=st(e.contentType.attributes,e.components),ae=(0,h.formatContentTypeData)(H,e.contentType,e.components);p(Gr(V,ae))},[e,p]),(0,t.useEffect)(()=>()=>{p(Hr())},[p]),(0,t.useEffect)(()=>{const H=ye.Z.CancelToken.source(),ae=async re=>{p(ht());try{const{data:de}=await F.get($,{cancelToken:re.token});p(pn(W(G(de))))}catch(de){if(ye.Z.isCancel(de))return;const pe=P()(de,"response.status",null);if(pe===404){m(R);return}pe===403&&(l({type:"info",message:{id:C("permissions.not-allowed.update")}}),m(R))}},w=async()=>{await p(ht()),await p(gn(f))};return A.current?($?ae(H):w(),()=>{H.cancel("Operation canceled by the user.")}):()=>{}},[F,G,W,m,$,p,f,R,l]);const K=(0,t.useCallback)(V=>{l({type:"warning",message:S(V)})},[l,S]),N=(0,t.useCallback)(async V=>{try{T.current("willDeleteEntry",V);const{data:H}=await B(ce(`collection-types/${o}/${s}`));return l({type:"success",message:{id:C("success.record.delete")}}),T.current("didDeleteEntry",V),Promise.resolve(H)}catch(H){return T.current("didNotDeleteEntry",{error:H,...V}),Promise.reject(H)}},[s,o,l,B]),X=(0,t.useCallback)(()=>{g(R)},[R,g]),M=(0,t.useCallback)(async(V,H)=>{const ae=`${ce(`collection-types/${o}`)}${f}`;try{p(ie("submit-pending"));const{data:w}=await z(ae,V);return T.current("didCreateEntry",H),l({type:"success",message:{id:C("success.record.save")}}),d("contentManager.success"),c.invalidateQueries(["relation"]),p(xe(W(w))),p(ie("resolved")),g(`/content-manager/collectionType/${o}/${w.id}${f}`),Promise.resolve(w)}catch(w){return K(w),T.current("didNotCreateEntry",{error:w,trackerProperty:H}),p(ie("resolved")),Promise.reject(w)}},[W,K,g,o,p,f,l,d,c,z]),x=(0,t.useCallback)(async()=>{try{T.current("willCheckDraftRelations");const V=ce(`collection-types/${o}/${s}/actions/numberOfDraftRelations`);p(ie("draft-relation-check-pending"));const H=await F.get(V);return T.current("didCheckDraftRelations"),p(ie("resolved")),H.data.data}catch(V){return K(V),p(ie("resolved")),Promise.reject(V)}},[K,s,o,p,F]),Q=(0,t.useCallback)(async()=>{try{T.current("willPublishEntry");const V=ce(`collection-types/${o}/${s}/actions/publish`);p(ie("publish-pending"));const{data:H}=await z(V);return T.current("didPublishEntry"),p(xe(W(H))),p(ie("resolved")),l({type:"success",message:{id:C("success.record.publish")}}),Promise.resolve(H)}catch(V){return K(V),p(ie("resolved")),Promise.reject(V)}},[W,K,s,o,p,l,z]),j=(0,t.useCallback)(async(V,H)=>{const ae=ce(`collection-types/${o}/${s}`);try{T.current("willEditEntry",H),p(ie("submit-pending"));const{data:w}=await _(ae,V);return T.current("didEditEntry",{trackerProperty:H}),l({type:"success",message:{id:C("success.record.save")}}),c.invalidateQueries(["relation"]),p(xe(W(w))),p(ie("resolved")),Promise.resolve(w)}catch(w){return T.current("didNotEditEntry",{error:w,trackerProperty:H}),K(w),p(ie("resolved")),Promise.reject(w)}},[W,K,o,s,p,l,c,_]),O=(0,t.useCallback)(async()=>{const V=ce(`collection-types/${o}/${s}/actions/unpublish`);p(ie("unpublish-pending"));try{T.current("willUnpublishEntry");const{data:H}=await z(V);return T.current("didUnpublishEntry"),l({type:"success",message:{id:C("success.record.unpublish")}}),p(xe(W(H))),p(ie("resolved")),Promise.resolve(H)}catch(H){return p(ie("resolved")),K(H),Promise.reject(H)}},[W,K,s,o,p,l,z]);return r({componentsDataStructure:y,contentTypeDataStructure:b,data:v,isCreatingEntry:U,isLoadingForData:I,onDelete:N,onDeleteSucceeded:X,onPost:M,onPublish:Q,onDraftRelationCheck:x,onPut:j,onUnpublish:O,status:E,redirectionLink:R})};hn.defaultProps={id:null,origin:null},hn.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 yl=(0,t.memo)(hn,ke()),bl=D(86834),ge=D.n(bl),El=D(89793),Qe=D.n(El),Cl=D(3040),ne=D.n(Cl),Rl=D(56236),vl=D.n(Rl),Tl=D(10268),Zr=D.n(Tl),yn=D(99526),Qr=(e,r,o,s)=>{const a=e.slice();return a.splice(r,1),a.splice(o,0,s),a},Ml=D(77236),Dl=D.n(Ml);const kl=({browserState:e,serverState:r},o,s)=>{const a=r,c=e,l=(m,g)=>P()(m,["attributes",g,"type"],""),d=(m,g)=>P()(m,["attributes",...g],""),u=(m,g,f,p)=>Object.keys(m).reduce((y,b)=>{const v=p?`${p}.${b}`:b,I=l(f,b),E=P()(m,b),R=P()(g,b),S=d(f,[b,"component"]),A=d(f,[b,"repeatable"]);let T;switch(I){case"json":T=JSON.parse(E);break;case"time":{T=E,E&&E.split(":").length<3&&(T=`${E}:00`);break}case"media":d(f,[b,"multiple"])===!0?T=E?E.filter(k=>!(k instanceof File)):null:T=P()(E,0)instanceof File?null:P()(E,"id",null);break;case"component":A?T=E&&E.map((k,F)=>u(k,(R??[])[F],s[S],`${v}.${F}`)):T=E&&u(E,R,s[S],v);break;case"relation":{const k=_r(a,c)(v).join(".");let F=P()(a,k,[]);const _=E.reduce((B,U,$,G)=>{const W=F.find(N=>N.id===U.id),K=G[$+1];if(!W||W.__temp_key__!==U.__temp_key__){const N=K?{before:K.id}:{end:!0};return[...B,{id:U.id,position:N}]}return B},[]);T={disconnect:F.reduce((B,U)=>E.find($=>$.id===U.id)?B:[...B,{id:U.id}],[]),connect:_.reverse()};break}case"dynamiczone":T=E.map((k,F)=>u(k,(R??[])[F],s[k.__component],`${v}.${F}`));break;default:T=Il(E,"id")}return y[b]=T,y},{});return u(e,r,o,"")},Il=(e,r)=>Dl()(e)?e.map(o=>o[r]?o[r]:o):hr()(e)?e[r]:e;var xl=kl,wl=D(51355),Fl=D.n(wl),Ll=D(95919),Sl=D.n(Ll),Pl=D(78746),je=D.n(Pl),ue=D(5173);function Ke(e){return["integer","biginteger","decimal","float","number"].includes(e)}ue.kM(ue.nK,"defined",function(){return this.test("defined",h.translatedErrors.required,e=>e!==void 0)}),ue.kM(ue.IX,"notEmptyMin",function(e){return this.test("notEmptyMin",h.translatedErrors.min,r=>ge()(r)?!0:r.length>=e)}),ue.kM(ue.Z_,"isInferior",function(e,r){return this.test("isInferior",e,function(o){return!o||Number.isNaN(je()(o))?!0:je()(r)>=je()(o)})}),ue.kM(ue.Z_,"isSuperior",function(e,r){return this.test("isSuperior",e,function(o){return!o||Number.isNaN(je()(o))?!0:je()(o)>=je()(r)})});const Al=e=>P()(e,["attributes"],{}),bn=(e,{components:r},o={isCreatingEntry:!0,isDraft:!0,isFromComponent:!1})=>{const s=Al(e);return ue.Ry().shape(Object.keys(s).reduce((a,c)=>{const l=s[c];if(l.type!=="relation"&&l.type!=="component"&&l.type!=="dynamiczone"){const d=Ol(l.type,l,o);a[c]=d}if(l.type==="relation"&&(a[c]=["oneWay","oneToOne","manyToOne","oneToManyMorph","oneToOneMorph"].includes(l.relationType)?ue.Ry().nullable():ue.IX().nullable()),l.type==="component"){const d=bn(r[l.component],{components:r},{...o,isFromComponent:!0});if(l.repeatable===!0){const{min:m,max:g,required:f}=l;let p=ue.Vo(y=>{let b=ue.IX().of(d);return m?f?b=b.min(m,h.translatedErrors.min):f!==!0&&ge()(y)?b=b.nullable():b=b.min(m,h.translatedErrors.min):f&&!o.isDraft&&(b=b.min(1,h.translatedErrors.required)),g&&(b=b.max(g,h.translatedErrors.max)),b});return a[c]=p,a}const u=ue.Vo(m=>m!==void 0?l.required===!0&&!o.isDraft?d.defined():d.nullable():l.required===!0?ue.Ry().defined():ue.Ry().nullable());return a[c]=u,a}if(l.type==="dynamiczone"){let d=ue.IX().of(ue.Vo(({__component:g})=>bn(r[g],{components:r},{...o,isFromComponent:!0})));const{max:u,min:m}=l;m?l.required?d=d.test("min",h.translatedErrors.min,g=>o.isCreatingEntry?g&&g.length>=m:g===void 0?!0:g!==null&&g.length>=m).test("required",h.translatedErrors.required,g=>o.isCreatingEntry?g!==null||g!==void 0:g===void 0?!0:g!==null):d=d.notEmptyMin(m):l.required&&!o.isDraft&&(d=d.test("required",h.translatedErrors.required,g=>o.isCreatingEntry?g!==null||g!==void 0:g===void 0?!0:g!==null)),u&&(d=d.max(u,h.translatedErrors.max)),a[c]=d}return a},{}))},Ol=(e,r,o)=>{let s=ue.nK();return["string","uid","text","richtext","email","password","enumeration"].includes(e)&&(s=ue.Z_()),e==="json"&&(s=ue.nK(h.translatedErrors.json).test("isJSON",h.translatedErrors.json,a=>{if(!a||!a.length)return!0;try{return JSON.parse(a),!0}catch{return!1}}).nullable().test("required",h.translatedErrors.required,a=>!(r.required&&(!a||!a.length)))),e==="email"&&(s=s.email(h.translatedErrors.email)),["number","integer","float","decimal"].includes(e)&&(s=ue.Rx().transform(a=>Sl()(a)?void 0:a).typeError()),e==="biginteger"&&(s=ue.Z_().matches(/^-?\d*$/)),["date","datetime"].includes(e)&&(s=ue.hT()),Object.keys(r).forEach(a=>{const c=r[a];if(c||!Fl()(c)&&Number.isInteger(Math.floor(c))||c===0)switch(a){case"required":{o.isDraft||(e==="password"&&o.isCreatingEntry&&(s=s.required(h.translatedErrors.required)),e!=="password"&&(o.isCreatingEntry?s=s.required(h.translatedErrors.required):s=s.test("required",h.translatedErrors.required,l=>l===void 0&&!o.isFromComponent?!0:Ke(e)?l===0?!0:!!l:e==="boolean"?l!=null:e==="date"||e==="datetime"?typeof l=="string"?!ge()(l):!ge()(l?.toString()):!ge()(l))));break}case"max":{e==="biginteger"?s=s.isInferior(h.translatedErrors.max,c):s=s.max(c,h.translatedErrors.max);break}case"maxLength":s=s.max(c,h.translatedErrors.maxLength);break;case"min":{e==="biginteger"?s=s.isSuperior(h.translatedErrors.min,c):s=s.min(c,h.translatedErrors.min);break}case"minLength":{o.isDraft||(s=s.min(c,h.translatedErrors.minLength));break}case"regex":s=s.matches(new RegExp(c),{message:h.translatedErrors.regex,excludeEmptyString:!r.required});break;case"lowercase":["text","textarea","email","string"].includes(e)&&(s=s.strict().lowercase());break;case"uppercase":["text","textarea","email","string"].includes(e)&&(s=s.strict().uppercase());break;case"positive":Ke(e)&&(s=s.positive());break;case"negative":Ke(e)&&(s=s.negative());break;default:s=s.nullable()}}),s};var Kr=bn;const yt=(e,r=()=>!1,o=void 0)=>{const s=(a,c,{ignoreFalseyValues:l=!1,path:d=[]}={})=>Object.entries(c).reduce((u,[m,g])=>{if(l&&(u==null||u[m]===void 0||u[m]===null))return u;if(r(g,{path:[...d,m],parent:u})&&(u[m]=typeof o=="function"?o(u[m],{path:[...d,m],parent:u}):o),g.type==="component"){const f=e[g.component].attributes;g.repeatable?g.repeatable&&Array.isArray(u[m])&&(u[m]=u[m].map((p,y)=>s(p,f,{ignoreFalseyValues:l,path:[...d,m,y]}))):u[m]=s(u[m],f,{ignoreFalseyValues:l,path:[...d,m]})}else g.type==="dynamiczone"&&Array.isArray(u[m])&&(u[m]=u[m].map((f,p)=>{const y=e[f.__component].attributes;return s(f,y,{ignoreFalseyValues:l,path:[...d,m,p]})}));return u},{...a});return s},$l={componentsDataStructure:{},contentTypeDataStructure:{},formErrors:{},initialData:{},modifiedData:null,shouldCheckErrors:!1,modifiedDZName:null,publishConfirmation:{show:!1,draftCount:0}};var ql=(e,r)=>(0,lt.default)(e,o=>{switch(r.type){case"ADD_NON_REPEATABLE_COMPONENT_TO_FIELD":{const{componentLayoutData:s,allComponents:a}=r,c={...e.componentsDataStructure[s.uid]},d=yt(a,u=>u.type==="relation",[])(c,s.attributes);ne()(o,["modifiedData",...r.keys],d);break}case"ADD_COMPONENT_TO_DYNAMIC_ZONE":case"ADD_REPEATABLE_COMPONENT_TO_FIELD":{const{keys:s,allComponents:a,componentLayoutData:c,shouldCheckErrors:l}=r;l&&(o.shouldCheckErrors=!e.shouldCheckErrors),r.type==="ADD_COMPONENT_TO_DYNAMIC_ZONE"&&(o.modifiedDZName=s[0]);const d=P()(e,["modifiedData",...s],[]),u=r.type==="ADD_COMPONENT_TO_DYNAMIC_ZONE"?{...e.componentsDataStructure[c.uid],__component:c.uid,__temp_key__:Mt(d)+1}:{...e.componentsDataStructure[c.uid],__temp_key__:Mt(d)+1},g=yt(a,p=>p.type==="relation",[])(u,c.attributes),f=Array.isArray(d)?[...d,g]:[g];ne()(o,["modifiedData",...s],f);break}case"LOAD_RELATION":{const{initialDataPath:s,modifiedDataPath:a,value:c}=r,l=P()(e,s),d=P()(e,a),u=l?c.filter(f=>!l.some(p=>p.id===f.id)):c,m=(0,yn.zJ)(null,d[0]?.__temp_key__,u.length),g=u.map((f,p)=>({...f,__temp_key__:m[p]}));ne()(o,s,Zr()([...g,...l],"id")),ne()(o,a,Zr()([...g,...d],"id"));break}case"CONNECT_RELATION":{const s=["modifiedData",...r.keys],{value:a,toOneRelation:c}=r;if(c)ne()(o,s,[a]);else{const l=P()(e,s),[d]=(0,yn.zJ)(l.at(-1)?.__temp_key__,null,1),u=[...l,{...a,__temp_key__:d}];ne()(o,s,u)}break}case"DISCONNECT_RELATION":{const s=["modifiedData",...r.keys],{id:a}=r,l=P()(e,[...s]).filter(d=>d.id!==a);ne()(o,s,l);break}case"MOVE_COMPONENT_FIELD":case"REORDER_RELATION":{const{oldIndex:s,newIndex:a,keys:c}=r,l=["modifiedData",...c],d=P()(e,[...l]),u=d[s],m=[...d];if(r.type==="REORDER_RELATION"){const[g]=(0,yn.zJ)(d[a-1]?.__temp_key__,d[a]?.__temp_key__,1);m.splice(s,1),m.splice(a,0,{...u,__temp_key__:g})}else m.splice(s,1),m.splice(a,0,u);ne()(o,l,m);break}case"INIT_FORM":{const{initialValues:s,components:a={},attributes:c={},setModifiedDataOnly:l}=r,d=Te()(s),m=yt(a,p=>p.type==="relation",(p,{path:y})=>e.modifiedData?.id===d.id&&P()(e.modifiedData,y)?P()(e.modifiedData,y):[])(d,c),f=yt(a,p=>p.type==="dynamiczone"||p.type==="component"&&!p.repeatable,p=>Array.isArray(p)?p.map((y,b)=>({...y,__temp_key__:b})):{...p,__temp_key__:0})(m,c,{ignoreFalseyValues:!0});l||(o.initialData=f),o.modifiedData=f,o.formErrors={},o.modifiedDZName=null,o.shouldCheckErrors=!1;break}case"MOVE_COMPONENT_UP":case"MOVE_COMPONENT_DOWN":{const{currentIndex:s,dynamicZoneName:a,shouldCheckErrors:c}=r;c&&(o.shouldCheckErrors=!e.shouldCheckErrors);const l=e.modifiedData[a],d=r.type==="MOVE_COMPONENT_UP"?s-1:s+1,u=e.modifiedData[a][s],m=Qr(l,s,d,u);ne()(o,["modifiedData",r.dynamicZoneName],m);break}case"MOVE_FIELD":{const s=P()(e,["modifiedData",...r.keys],[]).slice(),a=P()(e,["modifiedData",...r.keys,r.dragIndex]),c=Qr(s,r.dragIndex,r.overIndex,a);ne()(o,["modifiedData",...r.keys],c);break}case"ON_CHANGE":{const[s]=r.keys;if(r.shouldSetInitialValue&&ne()(o,["initialData",...r.keys],r.value),r.keys.length===2&&P()(e,["modifiedData",s])===null){ne()(o,["modifiedData",s],{[r.keys[1]]:r.value});break}ne()(o,["modifiedData",...r.keys],r.value);break}case"REMOVE_COMPONENT_FROM_DYNAMIC_ZONE":{r.shouldCheckErrors&&(o.shouldCheckErrors=!e.shouldCheckErrors),o.modifiedData[r.dynamicZoneName].splice(r.index,1);break}case"REMOVE_COMPONENT_FROM_FIELD":{const s=["modifiedData",...r.keys];ne()(o,s,null);break}case"REMOVE_PASSWORD_FIELD":{vl()(o,["modifiedData",...r.keys]);break}case"REMOVE_REPEATABLE_FIELD":{const s=r.keys.length-1,a=["modifiedData",...Ot()(r.keys,s)];Object.keys(e.formErrors).length>0&&(o.shouldCheckErrors=!e.shouldCheckErrors);const l=P()(e,a).slice();l.splice(parseInt(r.keys[s],10),1),ne()(o,a,l);break}case"SET_DEFAULT_DATA_STRUCTURES":{o.componentsDataStructure=r.componentsDataStructure,o.contentTypeDataStructure=r.contentTypeDataStructure;break}case"SET_FORM_ERRORS":{o.modifiedDZName=null,o.formErrors=r.errors;break}case"TRIGGER_FORM_VALIDATION":{Object.keys(e.formErrors).length>0&&(o.shouldCheckErrors=!e.shouldCheckErrors);break}case"SET_PUBLISH_CONFIRMATION":{o.publishConfirmation={...r.publishConfirmation};break}case"RESET_PUBLISH_CONFIRMATION":{o.publishConfirmation={...e.publishConfirmation,show:!1};break}default:return o}});const En=({allLayoutData:e,allowedActions:{canRead:r,canUpdate:o},children:s,componentsDataStructure:a,contentTypeDataStructure:c,createActionAllowedFields:l,from:d,initialValues:u,isCreatingEntry:m,isLoadingForData:g,isSingleType:f,onPost:p,onPublish:y,onDraftRelationCheck:b,onPut:v,onUnpublish:I,readActionAllowedFields:E,redirectToPreviousPage:R,slug:S,status:A,updateActionAllowedFields:T})=>{const[k,F]=(0,t.useReducer)(ql,$l),{formErrors:_,initialData:z,modifiedData:B,modifiedDZName:U,shouldCheckErrors:$,publishConfirmation:G}=k,{setModifiedDataOnly:W}=(0,le.useSelector)(fn),K=(0,le.useDispatch)(),N=(0,h.useNotification)(),{lockApp:X,unlockApp:M}=(0,h.useOverlayBlocker)(),x=P()(e,["contentType"],{}),Q=(0,t.useMemo)(()=>P()(x,["options","draftAndPublish"],!1),[x]),j=(0,t.useMemo)(()=>Q&&!z.publishedAt,[Q,z.publishedAt]),{trackUsage:O}=(0,h.useTracking)(),{formatMessage:V}=(0,Z.useIntl)(),H=(0,t.useRef)(O),ae=(0,t.useMemo)(()=>g||m?!1:r===!1&&o===!1,[g,m,r,o]);(0,t.useEffect)(()=>{A==="resolved"?M():X()},[X,M,A]),(0,t.useEffect)(()=>{g||Ce()},[$]),(0,t.useEffect)(()=>{const ee=Object.keys(_);if(ee.length>0){const Y=ee[0],se=document.getElementById(Y);se&&se.focus()}},[_]),(0,t.useEffect)(()=>{ae&&N({type:"info",message:{id:C("permissions.not-allowed.update")}})},[ae,N]),(0,t.useEffect)(()=>{F({type:"SET_DEFAULT_DATA_STRUCTURES",componentsDataStructure:a,contentTypeDataStructure:c})},[a,c]);const{components:w}=e,re=vr(u);(0,t.useEffect)(()=>{u&&x?.attributes&&!Qe()(re,u)&&(F({type:"INIT_FORM",initialValues:u,components:w,attributes:x.attributes,setModifiedDataOnly:W}),W&&K(hl()))},[u,x,w,W,K,re]);const de=(0,t.useCallback)(ee=>(Y,se,ve,$e=!1)=>{H.current("didAddComponentToDynamicZone"),F({type:ee,keys:Y.split("."),componentLayoutData:se,allComponents:ve,shouldCheckErrors:$e})},[]),pe=de("ADD_COMPONENT_TO_DYNAMIC_ZONE"),We=(0,t.useCallback)((ee,Y,se)=>{F({type:"ADD_NON_REPEATABLE_COMPONENT_TO_FIELD",keys:ee.split("."),componentLayoutData:Y,allComponents:se})},[]),Je=(0,t.useCallback)(({name:ee,value:Y,toOneRelation:se})=>{F({type:"CONNECT_RELATION",keys:ee.split("."),value:Y,toOneRelation:se})},[]),et=(0,t.useCallback)(({target:{initialDataPath:ee,modifiedDataPath:Y,value:se}})=>{F({type:"LOAD_RELATION",modifiedDataPath:Y,initialDataPath:ee,value:se})},[]),tt=de("ADD_REPEATABLE_COMPONENT_TO_FIELD"),be=(0,t.useMemo)(()=>{const ee={isCreatingEntry:m,isDraft:j,isFromComponent:!1};return Kr(x,{components:e.components||{}},ee)},[e.components,x,m,j]),Ce=(0,t.useCallback)(async(ee={})=>{let Y={};const se=Te()(B);ge()(se)||ne()(se,ee.path,ee.value);try{await be.validate(se,{abortEarly:!1})}catch(ve){Y=(0,h.getYupInnerErrors)(ve),U&&(Y=Object.keys(Y).reduce(($e,Gn)=>(Gn.split(".")[0]!==U&&($e[Gn]=Y[Gn]),$e),{}))}F({type:"SET_FORM_ERRORS",errors:Y})},[U,B,be]),nt=(0,t.useCallback)(({target:{name:ee,value:Y,type:se}},ve=!1)=>{let $e=Y;if(["text","textarea","string","email","uid","select","select-one","number"].includes(se)&&!Y&&Y!==0&&($e=null),se==="password"&&!Y){F({type:"REMOVE_PASSWORD_FIELD",keys:ee.split(".")});return}F({type:"ON_CHANGE",keys:ee.split("."),value:$e,shouldSetInitialValue:ve})},[]),we=(0,t.useCallback)((ee,Y)=>xl({browserState:ee,serverState:Y},x,e.components),[e.components,x]),J=(0,t.useMemo)(()=>Q?j?{status:"draft"}:{}:{},[Q,j]),me=(0,t.useCallback)(async ee=>(ee.preventDefault(),F({type:"RESET_PUBLISH_CONFIRMATION"})),[]),Re=(0,t.useCallback)(async ee=>{ee.preventDefault();let Y={};try{await be.validate(B,{abortEarly:!1})}catch(se){Y=(0,h.getYupInnerErrors)(se)}try{if(ge()(Y)){const se=we(B,z);m?await p(se,J):await v(se,J)}}catch(se){Y={...Y,...(0,h.getAPIInnerErrors)(se,{getTrad:C})}}F({type:"SET_FORM_ERRORS",errors:Y})},[we,m,B,z,p,v,J,be]),Hn=(0,t.useCallback)(async()=>{const ee=Kr(x,{components:P()(e,"components",{})},{isCreatingEntry:m,isDraft:!1,isFromComponent:!1}),Y=await b();if(!G.show&&Y>0){F({type:"SET_PUBLISH_CONFIRMATION",publishConfirmation:{show:!0,draftCount:Y}});return}F({type:"RESET_PUBLISH_CONFIRMATION"});let se={};try{await ee.validate(B,{abortEarly:!1})}catch(ve){se=(0,h.getYupInnerErrors)(ve)}try{ge()(se)&&await y()}catch(ve){se={...se,...(0,h.getAPIInnerErrors)(ve,{getTrad:C})}}F({type:"SET_FORM_ERRORS",errors:se})},[e,x,m,B,G.show,y,b]),Fe=(0,t.useCallback)(ee=>{const Y=Object.keys(_).some(ve=>ve.split(".")[0]===ee);return!ge()(_)&&Y},[_]),ku=(0,t.useCallback)((ee,Y)=>{H.current("changeComponentsOrder"),F({type:"MOVE_COMPONENT_DOWN",dynamicZoneName:ee,currentIndex:Y,shouldCheckErrors:Fe(ee)})},[Fe]),Iu=(0,t.useCallback)((ee,Y)=>{H.current("changeComponentsOrder"),F({type:"MOVE_COMPONENT_UP",dynamicZoneName:ee,currentIndex:Y,shouldCheckErrors:Fe(ee)})},[Fe]),xu=(0,t.useCallback)(({name:ee,newIndex:Y,currentIndex:se})=>{F({type:"MOVE_COMPONENT_FIELD",keys:ee.split("."),newIndex:Y,oldIndex:se})},[]),wu=(0,t.useCallback)(({name:ee,id:Y})=>{F({type:"DISCONNECT_RELATION",keys:ee.split("."),id:Y})},[]),Fu=(0,t.useCallback)(({name:ee,oldIndex:Y,newIndex:se})=>{F({type:"REORDER_RELATION",keys:ee.split("."),oldIndex:Y,newIndex:se})},[]),Lu=(0,t.useCallback)((ee,Y)=>{H.current("removeComponentFromDynamicZone"),F({type:"REMOVE_COMPONENT_FROM_DYNAMIC_ZONE",dynamicZoneName:ee,index:Y,shouldCheckErrors:Fe(ee)})},[Fe]),Su=(0,t.useCallback)((ee,Y)=>{F({type:"REMOVE_COMPONENT_FROM_FIELD",keys:ee.split("."),componentUid:Y})},[]),Pu=(0,t.useCallback)((ee,Y)=>{F({type:"REMOVE_REPEATABLE_FIELD",keys:ee.split("."),componentUid:Y})},[]),Au=(0,t.useCallback)(()=>{F({type:"TRIGGER_FORM_VALIDATION"})},[]);return ae?t.createElement(oe.Redirect,{to:d}):B?t.createElement(h.ContentManagerEditViewDataManagerContext.Provider,{value:{addComponentToDynamicZone:pe,addNonRepeatableComponentToField:We,addRepeatableComponentToField:tt,allLayoutData:e,checkFormErrors:Ce,createActionAllowedFields:l,formErrors:_,hasDraftAndPublish:Q,initialData:z,isCreatingEntry:m,isSingleType:f,shouldNotRunValidations:j,status:A,layout:x,modifiedData:B,moveComponentField:xu,moveComponentDown:ku,moveComponentUp:Iu,onChange:nt,onPublish:Hn,onUnpublish:I,readActionAllowedFields:E,redirectToPreviousPage:R,removeComponentFromDynamicZone:Lu,removeComponentFromField:Su,removeRepeatableField:Pu,relationConnect:Je,relationDisconnect:wu,relationLoad:et,relationReorder:Fu,slug:S,triggerFormValidation:Au,updateActionAllowedFields:T,onPublishPromptDismissal:me,publishConfirmation:G}},g||!m&&!z.id?t.createElement(i.Main,{"aria-busy":"true"},t.createElement(h.LoadingIndicatorPage,null)):t.createElement(t.Fragment,null,t.createElement(oe.Prompt,{when:!Qe()(B,z),message:V({id:"global.prompt.unsaved"})}),t.createElement("form",{noValidate:!0,onSubmit:Re},s))):null};En.defaultProps={from:"/",initialValues:null,redirectToPreviousPage(){}},En.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 Bl=En,Oe=e=>ce(`single-types/${e}`),Nl=e=>Object.values(e||{}).reduce((r,o)=>Object.assign(r,o),{}),Yr=(e={})=>{const{plugins:r,_q:o,...s}={...e,...Nl(e.plugins)};return o&&ne()(s,"_q",encodeURIComponent(o)),`${(0,Me.stringify)(s,{encode:!1,addQueryPrefix:!0})}`};const Xr=({allLayoutData:e,children:r,slug:o})=>{const s=(0,Ae.useQueryClient)(),{trackUsage:a}=(0,h.useTracking)(),{push:c}=(0,oe.useHistory)(),{setCurrentStep:l}=(0,h.useGuidedTour)(),d=(0,t.useRef)(a),[u,m]=(0,t.useState)(!0),[{query:g,rawQuery:f}]=(0,h.useQueryParams)(),p=Yr(g),y=(0,h.useNotification)(),b=(0,le.useDispatch)(),{formatAPIError:v}=(0,h.useAPIErrorHandler)(C),I=(0,h.useFetchClient)(),{post:E,put:R,del:S}=I,{componentsDataStructure:A,contentTypeDataStructure:T,data:k,isLoading:F,status:_}=(0,le.useSelector)(fn),z=(0,t.useCallback)(M=>{const x=ir(M,e.contentType,e.components);return(0,h.formatContentTypeData)(x,e.contentType,e.components)},[e]);(0,t.useEffect)(()=>()=>{b(Hr())},[b]),(0,t.useEffect)(()=>{const M=Object.keys(e.components).reduce((j,O)=>{const V=st(P()(e,["components",O,"attributes"],{}),e.components);return j[O]=(0,h.formatContentTypeData)(V,e.components[O],e.components),j},{}),x=st(e.contentType.attributes,e.components),Q=(0,h.formatContentTypeData)(x,e.contentType,e.components);b(Gr(M,Q))},[e,b]),(0,t.useEffect)(()=>{const x=ye.Z.CancelToken.source();return(async j=>{b(ht()),m(!0);try{const{data:O}=await I.get(Oe(`${o}${p}`),{cancelToken:j.token});b(pn(z(O))),m(!1)}catch(O){if(ye.Z.isCancel(O))return;const V=P()(O,"response.status",null);V===404&&b(gn(f,!0)),V===403&&(y({type:"info",message:{id:C("permissions.not-allowed.update")}}),c("/"))}})(x),()=>x.cancel("Operation canceled by the user.")},[I,z,c,o,b,p,f,y]);const B=(0,t.useCallback)(M=>{y({type:"warning",message:v(M)})},[y,v]),U=(0,t.useCallback)(async M=>{try{d.current("willDeleteEntry",M);const{data:x}=await S(Oe(`${o}${p}`));return y({type:"success",message:{id:C("success.record.delete")}}),d.current("didDeleteEntry",M),Promise.resolve(x)}catch(x){return d.current("didNotDeleteEntry",{error:x,...M}),B(x),Promise.reject(x)}},[S,o,B,y,p]),$=(0,t.useCallback)(()=>{m(!0),b(gn(f,!0))},[b,f]),G=(0,t.useCallback)(async(M,x)=>{const Q=Oe(`${o}${f}`);try{b(ie("submit-pending"));const{data:j}=await R(Q,M);return d.current("didCreateEntry",x),y({type:"success",message:{id:C("success.record.save")}}),l("contentManager.success"),s.invalidateQueries(["relation"]),b(xe(z(j))),m(!1),b(ie("resolved")),Promise.resolve(j)}catch(j){return d.current("didNotCreateEntry",{error:j,trackerProperty:x}),B(j),b(ie("resolved")),Promise.reject(j)}},[R,z,B,o,b,f,y,l,s]),W=(0,t.useCallback)(async()=>{try{d.current("willCheckDraftRelations");const M=Oe(`${o}/actions/numberOfDraftRelations`);b(ie("draft-relation-check-pending"));const x=await I.get(M);return d.current("didCheckDraftRelations"),b(ie("resolved")),x.data.data}catch(M){return B(M),b(ie("resolved")),Promise.reject(M)}},[I,B,o,b]),K=(0,t.useCallback)(async()=>{try{d.current("willPublishEntry");const M=Oe(`${o}/actions/publish${p}`);b(ie("publish-pending"));const{data:x}=await E(M);return d.current("didPublishEntry"),y({type:"success",message:{id:C("success.record.publish")}}),b(xe(z(x))),b(ie("resolved")),Promise.resolve(x)}catch(M){return B(M),b(ie("resolved")),Promise.reject(M)}},[E,z,B,o,p,b,y]),N=(0,t.useCallback)(async(M,x)=>{const Q=Oe(`${o}${f}`);try{d.current("willEditEntry",x),b(ie("submit-pending"));const{data:j}=await R(Q,M);return y({type:"success",message:{id:C("success.record.save")}}),d.current("didEditEntry",{trackerProperty:x}),s.invalidateQueries(["relation"]),b(xe(z(j))),b(ie("resolved")),Promise.resolve(j)}catch(j){return B(j),d.current("didNotEditEntry",{error:j,trackerProperty:x}),b(ie("resolved")),Promise.reject(j)}},[R,z,B,o,b,f,y,s]),X=(0,t.useCallback)(async()=>{const M=Oe(`${o}/actions/unpublish${p}`);b(ie("unpublish-pending"));try{d.current("willUnpublishEntry");const{data:x}=await E(M);d.current("didUnpublishEntry"),y({type:"success",message:{id:C("success.record.unpublish")}}),b(xe(z(x))),b(ie("resolved"))}catch(x){b(ie("resolved")),B(x)}},[E,z,y,B,o,b,p]);return r({componentsDataStructure:A,contentTypeDataStructure:T,data:k,isCreatingEntry:u,isLoadingForData:F,onDelete:U,onDeleteSucceeded:$,onPost:G,onDraftRelationCheck:W,onPublish:K,onPut:N,onUnpublish:X,redirectionLink:"/",status:_})};Xr.propTypes={allLayoutData:n().shape({components:n().object.isRequired,contentType:n().object.isRequired}).isRequired,children:n().func.isRequired,slug:n().string.isRequired};var jl=(0,t.memo)(Xr);function Vl(e,r){return o=>{const s=r();return t.createElement(e,{...o,...s})}}var _l=Vl;function zl(){const{initialData:e,hasDraftAndPublish:r}=(0,h.useCMEditViewDataManager)(),o=e.publishedAt!==void 0&&e.publishedAt!==null;return{hasDraftAndPublish:r,isPublished:o}}var Wl=zl;const Ul=(0,q.default)(L.Dot)`
|
|
961
|
-
width: ${(0,h.pxToRem)(6)};
|
|
962
|
-
height: ${(0,h.pxToRem)(6)};
|
|
963
|
-
* {
|
|
964
|
-
fill: ${({theme:e,$bulletColor:r})=>e.colors[r]};
|
|
965
|
-
}
|
|
966
|
-
`,Jr=({hasDraftAndPublish:e,isPublished:r})=>{const{formatMessage:o}=(0,Z.useIntl)();if(!e)return null;const s={draft:{textColor:"secondary700",bulletColor:"secondary600",box:{background:"secondary100",borderColor:"secondary200"}},published:{textColor:"success700",bulletColor:"success600",box:{background:"success100",borderColor:"success200"}}},a=r?s.published:s.draft;return t.createElement(i.Box,{hasRadius:!0,as:"aside",paddingTop:4,paddingBottom:4,paddingLeft:5,paddingRight:5,...a.box},t.createElement(i.Box,{as:i.Flex},t.createElement(Ul,{$bulletColor:a.bulletColor}),t.createElement(i.Box,{paddingLeft:3},t.createElement(i.Typography,{textColor:a.textColor},o({id:C("containers.Edit.information.editing"),defaultMessage:"Editing"}),"\xA0"),t.createElement(i.Typography,{fontWeight:"bold",textColor:a.textColor},r&&o({id:C("containers.Edit.information.publishedVersion"),defaultMessage:"published version"}),!r&&o({id:C("containers.Edit.information.draftVersion"),defaultMessage:"draft version"})))))};Jr.propTypes={hasDraftAndPublish:n().bool.isRequired,isPublished:n().bool.isRequired};var Hl=_l(Jr,Wl);const Cn=60*1e3,Rn=Cn*60,bt=Rn*24,eo=bt*30,to=bt*365;var Gl=e=>e<Cn?{unit:"second",value:-Math.round(e/1e3)}:e<Rn?{unit:"minute",value:-Math.round(e/Cn)}:e<bt?{unit:"hour",value:-Math.round(e/Rn)}:e<eo?{unit:"day",value:-Math.round(e/bt)}:e<to?{unit:"month",value:-Math.round(e/eo)}:{unit:"year",value:-Math.round(e/to)},no=D(64421);const Ye=({label:e,value:r})=>t.createElement(i.Flex,{justifyContent:"space-between"},t.createElement(i.Typography,{as:"dt",fontWeight:"bold",textColor:"neutral600"},e),t.createElement(i.Typography,{as:"dd"},r));Ye.propTypes={label:n().string.isRequired,value:n().string.isRequired};var Zl=()=>{const{formatMessage:e,formatRelativeTime:r}=(0,Z.useIntl)(),{initialData:o,isCreatingEntry:s}=(0,h.useCMEditViewDataManager)(),a=(0,t.useRef)(Date.now()),c=(u,m)=>{const{firstname:g,lastname:f,username:p}=o[m]??{},y=g??"",b=f??"",v=p??(0,no.Pp)(y,b),E=(o[u]?new Date(o[u]).getTime():Date.now())-a.current,{unit:R,value:S}=Gl(-E);return{at:r(S,R,{numeric:"auto"}),by:s?"-":v}},l=c("updatedAt","updatedBy"),d=c("createdAt","createdBy");return t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:2},t.createElement(i.Typography,{variant:"sigma",textColor:"neutral600",id:"additional-information"},e({id:C("containers.Edit.information"),defaultMessage:"Information"})),t.createElement(i.Box,{paddingBottom:4},t.createElement(i.Divider,null)),t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:4},t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:2,as:"dl"},t.createElement(Ye,{label:e({id:C("containers.Edit.information.created"),defaultMessage:"Created"}),value:d.at}),t.createElement(Ye,{label:e({id:C("containers.Edit.information.by"),defaultMessage:"By"}),value:d.by})),t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:2,as:"dl"},t.createElement(Ye,{label:e({id:C("containers.Edit.information.lastUpdate"),defaultMessage:"Last update"}),value:l.at}),t.createElement(Ye,{label:e({id:C("containers.Edit.information.by"),defaultMessage:"By"}),value:l.by}))))};function Ql(e,r){return o=>{const s=r();return t.createElement(e,{...o,...s})}}var Kl=Ql;function Yl(){const{initialData:e,isCreatingEntry:r,isSingleType:o,status:s,layout:a,hasDraftAndPublish:c,modifiedData:l,onPublish:d,onUnpublish:u,publishConfirmation:m,onPublishPromptDismissal:g}=(0,h.useCMEditViewDataManager)();return{initialData:e,isCreatingEntry:r,isSingleType:o,status:s,layout:a,hasDraftAndPublish:c,modifiedData:l,onPublish:d,onUnpublish:u,publishConfirmation:m,onPublishPromptDismissal:g}}var Xl=Yl;const ro=(0,q.default)(i.Flex)`
|
|
967
|
-
text-align: center;
|
|
968
|
-
`,oo=({allowedActions:{canUpdate:e,canCreate:r,canPublish:o},initialData:s,isCreatingEntry:a,isSingleType:c,hasDraftAndPublish:l,layout:d,modifiedData:u,onPublish:m,onUnpublish:g,status:f,publishConfirmation:{show:p,draftCount:y},onPublishPromptDismissal:b})=>{const{goBack:v}=(0,oe.useHistory)(),[I,E]=(0,t.useState)(!1),{formatMessage:R}=(0,Z.useIntl)(),S=P()(d,["settings","mainField"],"id"),A=P()(d,["info","displayName"],"NOT FOUND"),T=!Qe()(s,u)||a&&!ge()(u);let F=R({id:C("containers.Edit.pluginHeader.title.new"),defaultMessage:"Create an entry"});!a&&!c&&(F=s[S]||A),c&&(F=A);let _=null;if(a&&r&&(_=t.createElement(i.Flex,{gap:2},l&&t.createElement(i.Button,{disabled:!0,startIcon:t.createElement(L.Check,null),variant:"secondary"},R({id:"app.utils.publish",defaultMessage:"Publish"})),t.createElement(i.Button,{disabled:!T,loading:f==="submit-pending",type:"submit"},R({id:C("containers.Edit.submit"),defaultMessage:"Save"})))),!a&&e){const $=l&&o,G=!ge()(s.publishedAt),W=G?f==="unpublish-pending":f==="publish-pending",K=G?{id:"app.utils.unpublish",defaultMessage:"Unpublish"}:{id:"app.utils.publish",defaultMessage:"Publish"},N=G?()=>E(!0):()=>m();_=t.createElement(i.Flex,null,$&&t.createElement(i.Button,{disabled:T,loading:W,onClick:N,startIcon:t.createElement(L.Check,null),variant:"secondary"},R(K)),t.createElement(i.Box,{paddingLeft:$?2:0},t.createElement(i.Button,{disabled:!T,loading:f==="submit-pending",type:"submit"},R({id:C("containers.Edit.submit"),defaultMessage:"Save"}))))}const z=()=>E($=>!$),B=()=>{z(),g()},U=`${R({id:C("api.id"),defaultMessage:"API ID "})} : ${d.apiID}`;return t.createElement(t.Fragment,null,t.createElement(i.HeaderLayout,{title:F.toString(),primaryAction:_,subtitle:U,navigationAction:t.createElement(h.Link,{startIcon:t.createElement(L.ArrowLeft,null),onClick:$=>{$.preventDefault(),v()},to:"/"},R({id:"global.back",defaultMessage:"Back"}))}),t.createElement(i.Dialog,{onClose:z,title:"Confirmation",labelledBy:"confirmation",describedBy:"confirm-description",isOpen:I},t.createElement(i.DialogBody,{icon:t.createElement(L.ExclamationMarkCircle,null)},t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:2},t.createElement(i.Flex,{justifyContent:"center",style:{textAlign:"center"}},t.createElement(i.Typography,{id:"confirm-description"},R({id:C("popUpWarning.warning.unpublish"),defaultMessage:"Unpublish this content will automatically change it to a draft."},{br:()=>t.createElement("br",null)}))),t.createElement(i.Flex,{justifyContent:"center",style:{textAlign:"center"}},t.createElement(i.Typography,{id:"confirm-description"},R({id:C("popUpWarning.warning.unpublish-question"),defaultMessage:"Are you sure you want to unpublish it?"}))))),t.createElement(i.DialogFooter,{startAction:t.createElement(i.Button,{onClick:z,variant:"tertiary"},R({id:"components.popUpWarning.button.cancel",defaultMessage:"Cancel"})),endAction:t.createElement(i.Button,{variant:"danger-light",onClick:B},R({id:"components.popUpWarning.button.confirm",defaultMessage:"Confirm"}))})),t.createElement(i.Dialog,{onClose:b,title:R({id:C("popUpWarning.warning.has-draft-relations.title"),defaultMessage:"Confirmation"}),labelledBy:"confirmation",describedBy:"confirm-description",isOpen:p},t.createElement(i.DialogBody,{icon:t.createElement(L.ExclamationMarkCircle,null)},t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:2},t.createElement(ro,{justifyContent:"center"},t.createElement(i.Typography,{id:"confirm-description"},y,R({id:C("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.createElement(i.Typography,{fontWeight:"bold"},$),count:y}))),t.createElement(ro,{justifyContent:"center"},t.createElement(i.Typography,{id:"confirm-description"},R({id:C("popUpWarning.warning.publish-question"),defaultMessage:"Do you still want to publish?"}))))),t.createElement(i.DialogFooter,{startAction:t.createElement(i.Button,{onClick:b,variant:"tertiary"},R({id:"components.popUpWarning.button.cancel",defaultMessage:"Cancel"})),endAction:t.createElement(i.Button,{variant:"success",onClick:m},R({id:C("popUpwarning.warning.has-draft-relations.button-confirm"),defaultMessage:"Publish"}))})))};oo.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 Jl=(0,t.memo)(oo,ke());var ec=Kl(Jl,Xl),tc=e=>{if(!e.layouts)return[];const r=e.layouts.edit,o=e.attributes,s=l=>(0,te.get)(o,[l,"type"],"");let a=0;const c=[];return r.forEach(l=>{const d=l.some(({name:u})=>s(u)==="dynamiczone");c[a]||(c[a]=[]),d?(a=a===0&&(0,te.isEmpty)(c[0])?0:a+1,c[a]||(c[a]=[]),c[a].push(l),a+=1):c[a].push(l)}),c.filter(l=>l.length>0)},nc=(e,r)=>{const o=s=>{const a=(0,h.findMatchingPermissions)(e,[{action:`plugin::content-manager.explorer.${s}`,subject:r}]);return(0,te.uniq)((0,te.flatMap)(a,"properties.fields"))};return{createActionAllowedFields:o("create"),readActionAllowedFields:o("read"),updateActionAllowedFields:o("update")}},rc=e=>{if(!e)return[];const o=[...e.contentType.layouts.edit,...Object.values(e.components).flatMap(a=>a.layouts.edit)].flat().filter(a=>a.fieldSchema.customField).map(a=>a.fieldSchema.customField);return[...new Set(o)]};function oc(e,r){return o=>{const s=r();return t.createElement(e,{...o,...s})}}var sc=oc;function ac(){const{hasDraftAndPublish:e,modifiedData:r}=(0,h.useCMEditViewDataManager)();let o={};return e&&(o=(0,te.isEmpty)(r.publishedAt)?{status:"draft"}:{status:"published"}),{hasDraftAndPublish:e,trackerProperty:o}}var ic=ac;const so=({isCreatingEntry:e,onDelete:r,onDeleteSucceeded:o,trackerProperty:s})=>{const[a,c]=(0,t.useState)(!1),[l,d]=(0,t.useState)(!1),{formatMessage:u}=(0,Z.useIntl)(),{formatAPIError:m}=(0,h.useAPIErrorHandler)(C),g=(0,h.useNotification)(),f=()=>c(y=>!y),p=async()=>{try{d(!0),await r(s),d(!1),f(),o()}catch(y){d(!1),f(),g({type:"warning",message:m(y)})}};return e?null:t.createElement(t.Fragment,null,t.createElement(i.Button,{onClick:f,size:"S",startIcon:t.createElement(L.Trash,null),variant:"danger-light"},u({id:C("containers.Edit.delete-entry"),defaultMessage:"Delete this entry"})),t.createElement(h.ConfirmDialog,{isConfirmButtonLoading:l,isOpen:a,onConfirm:p,onToggleDialog:f}))};so.propTypes={isCreatingEntry:n().bool.isRequired,onDelete:n().func.isRequired,onDeleteSucceeded:n().func.isRequired,trackerProperty:n().object.isRequired};const lc=(0,t.memo)(so,ke());var cc=sc(lc,ic);const vn=({columns:e,customFieldInputs:r})=>t.createElement(i.Grid,{gap:4},e.map(({fieldSchema:o,labelAction:s,metadatas:a,name:c,size:l,queryInfos:d})=>{if(o.type==="component"){const{component:m,max:g,min:f,repeatable:p=!1,required:y=!1}=o;return t.createElement(i.GridItem,{col:l,s:12,xs:12,key:m},t.createElement(mt,{componentUid:m,labelAction:s,isRepeatable:p,intlLabel:{id:a.label,defaultMessage:a.label},max:g,min:f,name:c,required:y}))}return t.createElement(i.GridItem,{col:l,key:c,s:12,xs:12},t.createElement(Yt,{size:l,fieldSchema:o,keys:c,labelAction:s,metadatas:a,queryInfos:d,customFieldInputs:r}))}));vn.defaultProps={customFieldInputs:{}},vn.propTypes={columns:n().array.isRequired,customFieldInputs:n().object};var dc=vn;const Tn=e=>e["content-manager_editViewLayoutManager"].currentLayout,uc=(0,He.P1)(Tn,e=>tc(e?.contentType??{})),mc=(0,He.P1)(Tn,e=>rc(e)),ao=qe.Z.contentManager,pc=[{action:"plugin::content-type-builder.read",subject:null}],Mn=({allowedActions:e,isSingleType:r,goBack:o,slug:s,id:a,origin:c,userPermissions:l})=>{const{trackUsage:d}=(0,h.useTracking)(),{formatMessage:u}=(0,Z.useIntl)(),{layout:m,formattedContentTypeLayout:g,customFieldUids:f}=(0,le.useSelector)(T=>({layout:Tn(T),formattedContentTypeLayout:uc(T),customFieldUids:mc(T)})),{isLazyLoading:p,lazyComponentStore:y}=Xt(f),{createActionAllowedFields:b,readActionAllowedFields:v,updateActionAllowedFields:I}=nc(l,s),E=r?ao.singleTypesConfigurations:ao.collectionTypesConfigurations,R=`/content-manager/${r?"singleType":"collectionType"}/${s}/configurations/edit`,S=r?jl:yl,A=T=>T.every(k=>k.every(F=>F.fieldSchema.type==="dynamiczone"));return p?t.createElement(h.LoadingIndicatorPage,null):t.createElement(S,{allLayoutData:m,slug:s,id:a,origin:c},({componentsDataStructure:T,contentTypeDataStructure:k,data:F,isCreatingEntry:_,isLoadingForData:z,onDelete:B,onDeleteSucceeded:U,onPost:$,onPublish:G,onDraftRelationCheck:W,onPut:K,onUnpublish:N,redirectionLink:X,status:M})=>t.createElement(Bl,{allowedActions:e,allLayoutData:m,createActionAllowedFields:b,componentsDataStructure:T,contentTypeDataStructure:k,from:X,initialValues:F,isCreatingEntry:_,isLoadingForData:z,isSingleType:r,onPost:$,onPublish:G,onDraftRelationCheck:W,onPut:K,onUnpublish:N,readActionAllowedFields:v,redirectToPreviousPage:o,slug:s,status:M,updateActionAllowedFields:I},t.createElement(i.Main,{"aria-busy":M!=="resolved"},t.createElement(ec,{allowedActions:e}),t.createElement(i.ContentLayout,null,t.createElement(i.Grid,{gap:4},t.createElement(i.GridItem,{col:9,s:12},t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:6},g.map((x,Q)=>{if(A(x)){const{0:{0:{name:j,fieldSchema:O,metadatas:V,labelAction:H}}}=x;return t.createElement(i.Box,{key:Q},t.createElement(i.Grid,{gap:4},t.createElement(i.GridItem,{col:12,s:12,xs:12},t.createElement(fl,{name:j,fieldSchema:O,labelAction:H,metadatas:V}))))}return t.createElement(i.Box,{key:Q,hasRadius:!0,background:"neutral0",shadow:"tableShadow",paddingLeft:6,paddingRight:6,paddingTop:6,paddingBottom:6,borderColor:"neutral150"},t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:6},x.map((j,O)=>t.createElement(dc,{columns:j,customFieldInputs:y,key:O}))))}))),t.createElement(i.GridItem,{col:3,s:12},t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:2},t.createElement(Hl,null),t.createElement(i.Box,{as:"aside","aria-labelledby":"additional-information",background:"neutral0",borderColor:"neutral150",hasRadius:!0,paddingBottom:4,paddingLeft:4,paddingRight:4,paddingTop:6,shadow:"tableShadow"},t.createElement(Zl,null),t.createElement(dt,{area:"contentManager.editView.informations"})),t.createElement(i.Box,{as:"aside","aria-labelledby":"links"},t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:2},t.createElement(dt,{area:"contentManager.editView.right-links",slug:s}),s!=="strapi::administrator"&&t.createElement(h.CheckPermissions,{permissions:pc},t.createElement(h.LinkButton,{onClick:()=>{d("willEditEditLayout")},size:"S",startIcon:t.createElement(L.Pencil,null),style:{width:"100%"},to:`/plugins/content-type-builder/content-types/${s}`,variant:"secondary"},u({id:C("link-to-ctb"),defaultMessage:"Edit the model"}))),t.createElement(h.CheckPermissions,{permissions:E},t.createElement(h.LinkButton,{size:"S",startIcon:t.createElement(L.Layer,null),style:{width:"100%"},to:R,variant:"secondary"},u({id:"app.links.configure-view",defaultMessage:"Configure the view"}))),e.canDelete&&t.createElement(cc,{isCreatingEntry:_,onDelete:B,onDeleteSucceeded:U}))))))))))};Mn.defaultProps={id:null,isSingleType:!1,origin:null,userPermissions:[]},Mn.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 gc=(0,t.memo)(Mn);const Dn=e=>{const r=(0,t.useMemo)(()=>or(e.slug),[e.slug]),{isLoading:o,allowedActions:s}=(0,h.useRBAC)(r,e.userPermissions);return o?t.createElement(h.LoadingIndicatorPage,null):t.createElement(gc,{...e,allowedActions:s})};Dn.defaultProps={permissions:[]},Dn.propTypes={permissions:n().array,slug:n().string.isRequired,userPermissions:n().array.isRequired};var fc=(0,t.memo)(Dn,ke());const io=({layout:e,...r})=>{const o=(0,le.useSelector)(ur),s=(0,le.useDispatch)(),[{query:a}]=(0,h.useQueryParams)(),{runHookWaterfall:c}=(0,h.useStrapiApp)(),l=Rr(a,r.slug,"editView");return(0,t.useEffect)(()=>{const d=c(ct.Eo,{layout:e,query:a});return s(Us(d.layout,a)),()=>{s(Ws())}},[e,s,a,c]),!o||!l?t.createElement(h.LoadingIndicatorPage,null):t.createElement(fc,{...r,userPermissions:l})};io.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 Et=io,hc=D(23940),Xe=D.n(hc),yc=D(3704),bc=D.n(yc);const kn=e=>e.reduce((r,o)=>r+o.size,0),Ec=e=>e.reduce((r,o,s)=>{const a={rowId:s,rowContent:o};return r.concat(a)},[]),Ve=e=>e.reduce((r,o)=>{let s=[];const a=o.rowContent.reduce((d,u)=>{const m=kn(d);return u.name==="_TEMP_"||(m+u.size<=12?d.push(u):s.push(u)),d},[]),c=r.length===0?0:Math.max.apply(Math,r.map(d=>d.rowId))+1,l=kn(a);if(l<12&&a.push({name:"_TEMP_",size:12-l}),r.push({rowId:c,rowContent:a}),s.length>0){const d=kn(s);d<12&&s.push({name:"_TEMP_",size:12-d}),r.push({rowId:c+1,rowContent:s}),s=[]}return r},[]).filter(r=>r.rowContent.length>0).filter(r=>r.rowContent.length===1?r.rowContent[0].name!=="_TEMP_":!0),Cc=e=>e.reduce((r,o)=>{const s=o.rowContent.filter(a=>a.name!=="_TEMP_");return r.concat([s])},[]),lo=e=>{switch(e){case"boolean":case"date":case"integer":case"float":case"biginteger":case"decimal":case"time":return 4;case"json":case"component":case"richtext":case"dynamiczone":return 12;default:return 6}},Rc=(e,r=[])=>r.reduce((o,{rowContent:s})=>{const a=s.find(c=>c.name===e)?.size??null;return a&&(o=a),o},null),vc=(e,r,o=[])=>o.map(s=>(s.rowContent=s.rowContent.map(a=>a.name===e?{...a,size:r}:a),s)),In={fieldForm:{},componentLayouts:{},metaToEdit:"",initialData:{},metaForm:{},modifiedData:{}};var Tc=(e=In,r)=>(0,lt.default)(e,o=>{const s=["modifiedData","layouts","edit"];switch(r.type){case"MOVE_ROW":{const a=P()(e,s,[]),{fromIndex:c,toIndex:l}=r;ne()(o,s,rt(a,c,l));break}case"ON_ADD_FIELD":{const a=Te()(e),c=lo(P()(a,["modifiedData","attributes",r.name,"type"],"")),l=P()(a,s,[]).length,d=[...s,l-1,"rowContent"],u=P()(a,d,[]);let m=P()(a,s,[]);Array.isArray(u)?ne()(m,[l>0?l-1:0,"rowContent"],[...u,{name:r.name,size:c}]):ne()(m,[l>0?l-1:0,"rowContent"],[{name:r.name,size:c}]);const g=Ve(m);ne()(o,s,g);break}case"ON_CHANGE":{ne()(o,["modifiedData",...r.keys],r.value);break}case"ON_CHANGE_META":{ne()(o,["metaForm","metadata",...r.keys],r.value);break}case"ON_CHANGE_SIZE":{ne()(o,["metaForm","size"],r.value);break}case"ON_RESET":{o.modifiedData=e.initialData;break}case"REMOVE_FIELD":{const a=P()(e,[...s,r.rowIndex,"rowContent"],[]);let c=Te()(e);if(a.length===1||a.length===2&&P()(a,[1,"name"],"")==="_TEMP_"){const d=P()(e,s,[]);ne()(c,s,d.filter((u,m)=>r.rowIndex!==m))}else ne()(c,[...s,r.rowIndex,"rowContent"],a.filter((d,u)=>u!==r.fieldIndex));const l=Ve(P()(c,s,[]));ne()(o,s,l);break}case"REORDER_DIFF_ROW":{const a=P()(e,[...s,r.dragRowIndex,"rowContent"],[]),c=P()(e,[...s,r.hoverRowIndex,"rowContent"],[]),l=P()(e,[...s,r.dragRowIndex,"rowContent",r.dragIndex],{}),d=[...c,l];let u=Te()(e);ne()(u,[...s,r.dragRowIndex,"rowContent"],a.filter((g,f)=>r.dragIndex!==f)),ne()(u,[...s,r.hoverRowIndex,"rowContent"],rt(d,d.length-1,r.hoverIndex));const m=Ve(P()(u,s,[]));ne()(o,s,m);break}case"REORDER_ROW":{const a=Te()(e),c=P()(a,[...s,r.dragRowIndex,"rowContent"],[]);ne()(a,[...s,r.dragRowIndex,"rowContent"],rt(c,r.dragIndex,r.hoverIndex));const l=Ve(P()(a,s,[]));ne()(o,s,l);break}case"SET_FIELD_TO_EDIT":{o.metaToEdit=r.name,o.metaForm={metadata:P()(e,["modifiedData","metadatas",r.name,"edit"],{}),size:Rc(r.name,e.modifiedData?.layouts?.edit)??lo()};break}case"SUBMIT_META_FORM":{ne()(o,["modifiedData","metadatas",e.metaToEdit,"edit"],e.metaForm.metadata);const a=Te()(P()(e,s,[])),c=vc(e.metaToEdit,e.metaForm.size,a);c.length>0&&ne()(o,s,Ve(c));break}case"SUBMIT_SUCCEEDED":{o.initialData=e.modifiedData;break}case"UNSET_FIELD_TO_EDIT":{o.metaToEdit="",o.metaForm={};break}default:return o}}),Mc=(e,r,o)=>{let s=(0,te.cloneDeep)(r);return(0,te.set)(s,["layouts","edit"],Ve(Ec(r.layouts.edit))),{...e,initialData:s,modifiedData:s,componentLayouts:o}};const co=({componentUid:e})=>{const{componentLayouts:r}=Pe(),{formatMessage:o}=(0,Z.useIntl)(),s=P()(r,[e],{}),a=P()(s,["layouts","edit"],[]);return t.createElement(i.Box,{padding:3},a.map((c,l)=>t.createElement(i.Grid,{gap:4,key:l},c.map(d=>t.createElement(i.GridItem,{key:d.name,col:d.size},t.createElement(i.Box,{paddingTop:2},t.createElement(i.Flex,{alignItems:"center",background:"neutral0",paddingLeft:3,paddingRight:3,height:`${32/16}rem`,hasRadius:!0,borderColor:"neutral200"},t.createElement(i.Typography,{textColor:"neutral800"},d.name))))))),t.createElement(i.Box,{paddingTop:2},t.createElement(h.Link,{startIcon:t.createElement(L.Cog,null),to:`/content-manager/components/${e}/configurations/edit`},o({id:C("components.FieldItem.linkToComponentLayout"),defaultMessage:"Set the component's layout"}))))};co.propTypes={componentUid:n().string.isRequired};var Dc=co;const kc=(0,q.default)(i.Flex)`
|
|
969
|
-
text-decoration: none;
|
|
970
|
-
|
|
971
|
-
&:focus,
|
|
972
|
-
&:hover {
|
|
973
|
-
${({theme:e})=>`
|
|
974
|
-
background-color: ${e.colors.primary100};
|
|
975
|
-
border-color: ${e.colors.primary200};
|
|
976
|
-
|
|
977
|
-
${i.Typography} {
|
|
978
|
-
color: ${e.colors.primary600};
|
|
979
|
-
}
|
|
980
|
-
`}
|
|
981
|
-
|
|
982
|
-
/* > ComponentIcon */
|
|
983
|
-
> div:first-child {
|
|
984
|
-
background: ${({theme:e})=>e.colors.primary200};
|
|
985
|
-
color: ${({theme:e})=>e.colors.primary600};
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
`,uo=({components:e})=>{const{componentLayouts:r}=Pe();return t.createElement(i.Flex,{gap:2,overflow:"scroll hidden",padding:3},e.map(o=>t.createElement(kc,{hasRadius:!0,background:"neutral0",justifyContent:"center",alignItems:"center",height:`${84/16}rem`,minWidth:`${140/16}rem`,key:o,padding:2,direction:"column",borderColor:"neutral200",as:oe.Link,to:`/content-manager/components/${o}/configurations/edit`},t.createElement(ft,null),t.createElement(i.Box,{paddingTop:1},t.createElement(i.Typography,{fontSize:1,textColor:"neutral600",fontWeight:"bold"},r?.[o]?.info?.displayName??"")))))};uo.propTypes={components:n().arrayOf(n().string).isRequired};var Ic=uo;const mo=(0,q.default)(i.IconButton)`
|
|
989
|
-
background-color: transparent;
|
|
990
|
-
path {
|
|
991
|
-
fill: ${({theme:e})=>e.colors.neutral600};
|
|
992
|
-
}
|
|
993
|
-
`,xn=({attribute:e,onEditField:r,onDeleteField:o,children:s})=>{const{formatMessage:a}=(0,Z.useIntl)();return t.createElement(i.Box,{overflow:"hidden",width:"100%"},t.createElement(i.Flex,{paddingLeft:3,alignItems:"center",justifyContent:"space-between"},t.createElement(i.Typography,{fontWeight:"semiBold",textColor:"neutral800",ellipsis:!0},s),t.createElement(i.Flex,null,t.createElement(mo,{label:a({id:C("containers.ListSettingsView.modal-form.edit-label"),defaultMessage:"Edit {fieldName}"},{fieldName:s}),onClick:r,icon:t.createElement(L.Pencil,null),noBorder:!0}),t.createElement(mo,{label:a({id:"global.delete-target",defaultMessage:"Delete {target}"},{target:s}),"data-testid":"delete-field",onClick:o,icon:t.createElement(L.Trash,null),noBorder:!0}))),e?.type==="component"&&t.createElement(Dc,{componentUid:e.component}),e?.type==="dynamiczone"&&t.createElement(Ic,{components:e.components}))};xn.defaultProps={attribute:void 0},xn.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 xc=xn;const wc=(0,q.default)(i.Flex)`
|
|
994
|
-
position: relative;
|
|
995
|
-
${({isFirst:e,isLast:r,hasHorizontalPadding:o})=>e?`
|
|
996
|
-
padding-right: 4px;
|
|
997
|
-
`:r?`
|
|
998
|
-
padding-left: 4px;
|
|
999
|
-
`:o?`
|
|
1000
|
-
padding: 0 4px;
|
|
1001
|
-
`:""}
|
|
1002
|
-
${({showRightCarret:e,showLeftCarret:r,theme:o})=>e?`
|
|
1003
|
-
&:after {
|
|
1004
|
-
content: '';
|
|
1005
|
-
position: absolute;
|
|
1006
|
-
right: -1px;
|
|
1007
|
-
background-color: ${o.colors.primary600};
|
|
1008
|
-
width: 2px;
|
|
1009
|
-
height: 100%;
|
|
1010
|
-
align-self: stretch;
|
|
1011
|
-
z-index: 1;
|
|
1012
|
-
}
|
|
1013
|
-
`:r?`
|
|
1014
|
-
&:before {
|
|
1015
|
-
content: '';
|
|
1016
|
-
position: absolute;
|
|
1017
|
-
left: -1px;
|
|
1018
|
-
background-color: ${o.colors.primary600};
|
|
1019
|
-
width: 2px;
|
|
1020
|
-
height: 100%;
|
|
1021
|
-
align-self: stretch;
|
|
1022
|
-
z-index: 1;
|
|
1023
|
-
}
|
|
1024
|
-
`:""};
|
|
1025
|
-
`,Fc=(0,q.default)(L.Drag)`
|
|
1026
|
-
height: ${12/16}rem;
|
|
1027
|
-
width: ${12/16}rem;
|
|
1028
|
-
path {
|
|
1029
|
-
fill: ${({theme:e})=>e.colors.neutral600};
|
|
1030
|
-
}
|
|
1031
|
-
`,Lc=(0,q.default)(i.Flex)`
|
|
1032
|
-
display: ${({dragStart:e})=>e?"none":"flex"};
|
|
1033
|
-
opacity: ${({isDragging:e,isFullSize:r,isHidden:o})=>e&&!r?.2:e&&r||o?0:1};
|
|
1034
|
-
`,Sc=(0,q.default)(i.Flex)`
|
|
1035
|
-
cursor: all-scroll;
|
|
1036
|
-
border-right: 1px solid ${({theme:e})=>e.colors.neutral200};
|
|
1037
|
-
`,wn=({attribute:e,children:r,index:o,lastIndex:s,moveItem:a,moveRow:c,name:l,onDeleteField:d,onEditField:u,rowIndex:m,size:g})=>{const[f,p]=(0,t.useState)(!1),y=l==="_TEMP_",{setIsDraggingSibling:b}=Pe(),v=g===12,I=(0,t.useRef)(null),E=(0,t.useRef)(null),[{clientOffset:R,isOver:S},A]=(0,Le.useDrop)({accept:he.EDIT_FIELD,hover(N,X){if(!E.current||N.size!==12)return;const M=X.getItem().index,x=o,Q=X.getItem().rowIndex,j=m;if(M===x&&Q===j)return;const O=E.current.getBoundingClientRect(),V=(O.bottom-O.top)/2,ae=X.getClientOffset().y-O.top;Q<j&&ae<V||Q>j&&ae>V||(c(Q,j),N.rowIndex=j,N.itemIndex=x)},drop(N,X){if(!E.current)return;const M=X.getItem().index,x=o,Q=X.getItem().rowIndex,j=m;if(N.size===12||M===x&&Q===j)return;const O=E.current.getBoundingClientRect();if(Math.abs(X.getClientOffset().x-O.left)>O.width/1.8){a(M,x+1,Q,j),N.itemIndex=x+1,N.rowIndex=j;return}a(M,x,Q,j),N.itemIndex=x,N.rowIndex=j},collect:N=>({canDrop:N.canDrop(),clientOffset:N.getClientOffset(),isOver:N.isOver(),isOverCurrent:N.isOver({shallow:!0}),itemType:N.getItemType()})}),[{isDragging:T,getItem:k},F,_]=(0,Le.useDrag)({type:he.EDIT_FIELD,item(){return b(!0),{index:o,labelField:r,rowIndex:m,name:l,size:g}},canDrag(){return l!=="_TEMP_"},collect:N=>({isDragging:N.isDragging(),getItem:N.getItem()}),end(){b(!1)}});(0,t.useEffect)(()=>{_((0,Ue.rX)(),{captureDraggingState:!0})},[_]);const z={dragRef:F(I),dropRef:A(E)};let B=!1,U=!1;if(E.current&&R){const N=E.current.getBoundingClientRect();B=S&&k.size!==12&&Math.abs(R.x-N.left)<N.width/2,U=S&&k.size!==12&&Math.abs(R.x-N.left)>N.width/2,l==="_TEMP_"&&(B=S&&k.size!==12,U=!1)}const $=()=>e&&v?`${74/16}rem`:`${32/16}rem`,G=o===0&&!v,W=o===s&&!v,K=o!==0&&!v;return t.createElement(i.GridItem,{col:g},t.createElement(wc,{ref:z.dropRef,showLeftCarret:B,showRightCarret:U,isFirst:G,isLast:W,hasHorizontalPadding:K,onDrag:()=>{v&&!f&&p(!0)},onDragEnd:()=>{v&&p(!1)}},f&&v&&t.createElement(i.Box,{width:"100%",height:"2px",background:"primary600"}),t.createElement(Lc,{width:v&&f?0:"100%",borderColor:"neutral150",hasRadius:!0,background:"neutral100",minHeight:$(),alignItems:"stretch",isDragging:T,dragStart:f,isFullSize:v,isHidden:y},t.createElement(Sc,{as:"span",type:"button",ref:z.dragRef,onClick:N=>N.stopPropagation(),alignItems:"center",paddingLeft:3,paddingRight:3,tabIndex:-1},t.createElement(Fc,null)),!y&&t.createElement(xc,{attribute:e,onEditField:u,onDeleteField:d},r))))};wn.defaultProps={attribute:void 0},wn.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 Pc=wn;const po=({rowItem:e,onRemoveField:r,rowId:o,rowIndex:s,index:a,lastIndex:c})=>{const{setEditFieldToSelect:l,attributes:d,modifiedData:u,moveRow:m,moveItem:g}=Pe(),f=P()(d,[e.name],{}),p=P()(u,["metadatas",e.name,"edit","label"],"");return t.createElement(Pc,{onEditField:()=>l(e.name),onDeleteField:()=>r(o,a),attribute:f,index:a,lastIndex:c,rowIndex:s,name:e.name,size:e.size,moveRow:m,moveItem:g},p||e.name)};po.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 Ac=po;const go=({row:e,onRemoveField:r,rowIndex:o})=>t.createElement(i.Grid,null,e.rowContent.map((s,a)=>t.createElement(Ac,{key:s.name,rowItem:s,index:a,rowId:e.rowId,onRemoveField:r,rowIndex:o,lastIndex:e.rowContent.length-1})));go.propTypes={onRemoveField:n().func.isRequired,row:n().object.isRequired,rowIndex:n().number.isRequired};var Oc=go;const $c=[{action:"plugin::content-type-builder.read",subject:null}];var qc=()=>{const{trackUsage:e}=(0,h.useTracking)(),{formatMessage:r}=(0,Z.useIntl)(),{slug:o,modifiedData:s,isContentTypeView:a}=Pe(),c=a?"content-types":"components",l=`/plugins/content-type-builder/${c==="content-types"?c:"component-categories"}`,d=P()(s,"category",""),u=c==="content-types"?o:`${d}/${o}`,m=()=>{e("willEditEditLayout")};return o==="strapi::administrator"?null:t.createElement(h.CheckPermissions,{permissions:$c},t.createElement(h.LinkButton,{to:`${l}/${u}`,onClick:m,size:"S",startIcon:t.createElement(L.Pencil,null),variant:"secondary"},r({id:C(`edit-settings-view.link-to-ctb.${c}`),defaultMessage:"Edit the content type"})))};const fo=({editLayout:e,fields:r,onRemoveField:o,onAddField:s})=>{const{formatMessage:a}=(0,Z.useIntl)();return t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:4},t.createElement(i.Flex,{justifyContent:"space-between"},t.createElement("div",null,t.createElement(i.Box,null,t.createElement(i.Typography,{fontWeight:"bold"},a({id:C("containers.ListPage.displayedFields"),defaultMessage:"Displayed fields"}))),t.createElement(i.Box,null,t.createElement(i.Typography,{variant:"pi",textColor:"neutral600"},a({id:"containers.SettingPage.editSettings.description",defaultMessage:"Drag & drop the fields to build the layout"})))),t.createElement(qc,null)),t.createElement(i.Box,{padding:4,hasRadius:!0,borderStyle:"dashed",borderWidth:"1px",borderColor:"neutral300"},t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:2},e.map((c,l)=>t.createElement(Oc,{key:c.rowId,row:c,rowIndex:l,onRemoveField:o})),t.createElement(i.SimpleMenu,{id:"label",label:a({id:C("containers.SettingPage.add.field"),defaultMessage:"Insert another field"}),as:i.Button,"data-testid":"add-field",fullWidth:!0,startIcon:t.createElement(L.Plus,null),endIcon:null,variant:"secondary",disabled:r.length===0},r.map(c=>t.createElement(i.MenuItem,{key:c,onClick:()=>s(c)},c))))))};fo.propTypes={editLayout:n().array.isRequired,fields:n().array.isRequired,onAddField:n().func.isRequired,onRemoveField:n().func.isRequired};var Bc=fo;const ho={biginteger:t.createElement(L.Number,null),boolean:t.createElement(L.Boolean,null),date:t.createElement(L.Date,null),datetime:t.createElement(L.Date,null),decimal:t.createElement(L.Number,null),email:t.createElement(L.Email,null),enum:t.createElement(L.Enumeration,null),enumeration:t.createElement(L.Enumeration,null),file:t.createElement(L.Media,null),files:t.createElement(L.Media,null),float:t.createElement(L.Number,null),integer:t.createElement(L.Number,null),media:t.createElement(L.Media,null),number:t.createElement(L.Number,null),relation:t.createElement(L.Relation,null),string:t.createElement(L.Text,null),text:t.createElement(L.Text,null),richtext:t.createElement(L.Text,null),time:t.createElement(L.Date,null),timestamp:t.createElement(L.Date,null),json:t.createElement(L.Json,null),uid:t.createElement(L.Uid,null),component:t.createElement(L.Component,null),dynamiczone:t.createElement(L.DynamicZone,null)},Fn=({type:e,customFieldUid:r})=>{const o=(0,h.useCustomFields)();let s=ho[e];if(r){const c=o.get(r).icon;c&&(s=t.createElement(i.Box,{marginRight:3,width:7,height:6},t.createElement(c,null)))}return ho[e]?s:null};Fn.defaultProps={customFieldUid:null},Fn.propTypes={type:n().string.isRequired,customFieldUid:n().string};var yo=Fn,Nc=e=>e.reduce((r,o)=>{const s=(0,te.get)(o,["attributes"],{}),a=Object.keys(s).filter(c=>!["boolean","component","dynamiczone","json","media","password","relation","text","richtext"].includes((0,te.get)(s,[c,"type"],"")));return r[o.uid]=a,r},{}),bo=e=>{let r;switch(e){case"description":case"label":case"placeholder":r="text";break;case"mainField":r="select";break;case"editable":r="bool";break;default:r=""}const o=C(e==="mainField"?"containers.SettingPage.editSettings.entry.title":`form.Input.${e}`);return{type:r,label:{id:o}}};const Ln=({type:e,options:r,onChange:o,value:s,name:a,...c})=>{const{formatMessage:l}=(0,Z.useIntl)();switch(e){case"text":return t.createElement(i.TextInput,{onChange:o,value:s,name:a,...c});case"bool":return t.createElement(i.ToggleInput,{onChange:d=>{o({target:{name:a,value:d.target.checked}})},checked:s,name:a,onLabel:l({id:"app.components.ToggleCheckbox.on-label",defaultMessage:"On"}),offLabel:l({id:"app.components.ToggleCheckbox.off-label",defaultMessage:"Off"}),...c});case"select":return t.createElement(i.Select,{value:s,name:a,onChange:d=>o({target:{name:a,value:d}}),...c},r.map(d=>t.createElement(i.Option,{key:d,value:d},d)));default:return null}};Ln.defaultProps={options:void 0},Ln.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 jc=Ln;const Vc=[[4,"33%"],[6,"50%"],[8,"66%"],[12,"100%"]],_c=["dynamiczone","component","json","richtext"],zc=[1,5,10,15,30,60],Wc=["datetime","time"],Eo=({onMetaChange:e,onSizeChange:r})=>{const{formatMessage:o}=(0,Z.useIntl)(),{modifiedData:s,selectedField:a,attributes:c,fieldForm:l}=Pe(),d=(0,t.useMemo)(Ft,[]),{schemas:u}=(0,le.useSelector)(E=>d(E),le.shallowEqual),m=(0,t.useMemo)(()=>{if(!a)return[];const E=P()(s,["metadatas",a,"edit"],{});return Object.keys(E).filter(R=>R!=="visible")},[a,s]),g=(0,t.useMemo)(()=>Nc(u),[u]),f=(0,t.useCallback)(E=>{if(E!=="relation"&&E!=="component")return[];const R=E==="component"?"component":"targetModel",S=P()(s,["attributes",a,R],"");return P()(g,[S],[])},[a,g,s]),p=m.map(E=>{const R=P()(c,[a,"type"]);return["component","dynamiczone"].includes(R)&&!["label","description"].includes(E)||R==="component"&&E!=="label"||["media","json","boolean"].includes(R)&&E==="placeholder"||E==="step"?null:t.createElement(i.GridItem,{col:6,key:E},t.createElement(jc,{type:bo(E).type,hint:E==="mainField"?o({id:C("containers.SettingPage.editSettings.relation-field.description")}):"",label:o({id:P()(bo(E),"label.id","app.utils.defaultMessage")}),name:E,onChange:e,value:P()(l,["metadata",E],""),options:f(R)}))}),y=!_c.includes(c[a].type),b=t.createElement(i.GridItem,{col:6,key:"size"},t.createElement(i.Select,{value:l?.size,name:"size",onChange:E=>{r({name:a,value:E})},label:o({id:C("containers.SettingPage.editSettings.size.label"),defaultMessage:"Size"})},Vc.map(([E,R])=>t.createElement(i.Option,{key:E,value:E},R)))),v=Wc.includes(c[a].type),I=t.createElement(i.GridItem,{col:6,key:"step"},t.createElement(i.Select,{value:P()(l,["metadata","step"],1),name:"step",onChange:E=>e({target:{name:"step",value:E}}),label:o({id:C("containers.SettingPage.editSettings.step.label"),defaultMessage:"Time interval (minutes)"})},zc.map(E=>t.createElement(i.Option,{key:E,value:E},E))));return t.createElement(t.Fragment,null,p,y&&b,v&&I)};Eo.propTypes={onMetaChange:n().func.isRequired,onSizeChange:n().func.isRequired};var Uc=Eo;const Hc=(0,q.default)(i.Flex)`
|
|
1038
|
-
svg {
|
|
1039
|
-
width: ${32/16}rem;
|
|
1040
|
-
height: ${24/16}rem;
|
|
1041
|
-
margin-right: ${({theme:e})=>e.spaces[3]};
|
|
1042
|
-
}
|
|
1043
|
-
`,Sn=({onToggle:e,onMetaChange:r,onSizeChange:o,onSubmit:s,type:a,customFieldUid:c})=>{const{selectedField:l}=Pe(),{formatMessage:d}=(0,Z.useIntl)(),u=()=>a==="timestamp"?"date":["decimal","float","integer","biginter"].includes(a)?"number":a;return t.createElement(i.ModalLayout,{onClose:e,labelledBy:"title"},t.createElement("form",{onSubmit:s},t.createElement(i.ModalHeader,null,t.createElement(Hc,null,t.createElement(yo,{type:u(),customFieldUid:c}),t.createElement(i.Typography,{fontWeight:"bold",textColor:"neutral800",as:"h2",id:"title"},d({id:C("containers.ListSettingsView.modal-form.edit-label"),defaultMessage:"Edit {fieldName}"},{fieldName:Xe()(l)})))),t.createElement(i.ModalBody,null,t.createElement(i.Grid,{gap:4},t.createElement(Uc,{onMetaChange:r,onSizeChange:o}))),t.createElement(i.ModalFooter,{startActions:t.createElement(i.Button,{onClick:e,variant:"tertiary"},d({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endActions:t.createElement(i.Button,{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 Gc=Sn,Zc=(e,r,o)=>{const{put:s}=(0,h.getFetchClient)();return s(ce(o?`content-types/${r}/configuration`:`components/${r}/configuration`),e)};const Pn=({mainLayout:e,components:r,isContentTypeView:o,slug:s,updateLayout:a})=>{const[c,l]=(0,t.useReducer)(Tc,In,()=>Mc(In,e,r)),[d,u]=(0,t.useState)(!1),{trackUsage:m}=(0,h.useTracking)(),g=(0,h.useNotification)(),{goBack:f}=(0,oe.useHistory)(),[p,y]=(0,t.useState)(!1),[b,v]=(0,t.useState)(!1),{componentLayouts:I,initialData:E,modifiedData:R,metaToEdit:S,metaForm:A}=c,{formatMessage:T}=(0,Z.useIntl)(),k=P()(e,["info","displayName"],""),F=P()(R,["attributes"],{}),_=Object.keys(F).filter(w=>{const re=P()(F,[w,"type"],"");return!["dynamiczone","json","text","relation","component","boolean","media","password","richtext","timestamp"].includes(re)&&!!re}),z=P()(R,["layouts","edit"],[]),B=bc()(z,"rowContent"),U=Object.keys(R.attributes).filter(w=>P()(R,["metadatas",w,"edit","visible"],!1)===!0).filter(w=>B.findIndex(re=>re.name===w)===-1).sort(),$=({target:{name:w,value:re}})=>{l({type:"ON_CHANGE",keys:w.split("."),value:re})},G=()=>{y(w=>!w)},W=()=>{v(w=>!w)},K=({target:{name:w,value:re}})=>{l({type:"ON_CHANGE_META",keys:w.split("."),value:re})},N=({name:w,value:re})=>{l({type:"ON_CHANGE_SIZE",name:w,value:re})},X=w=>{w.preventDefault(),l({type:"SUBMIT_META_FORM"}),G()},M=w=>{w.preventDefault(),W()},x=(0,Ae.useMutation)(w=>Zc(w,s,o),{onSuccess({data:w}){a&&a(w.data),l({type:"SUBMIT_SUCCEEDED"}),W(),m("didEditEditSettings")},onError(){g({type:"warning",message:{id:"notification.error"}})}}),{isLoading:Q}=x,j=()=>{const w=Gt()(Te()(R),["layouts","metadatas","settings"]);ne()(w,"layouts.edit",Cc(w.layouts.edit)),x.mutate(w)},O=(w,re)=>{l({type:"MOVE_RELATION",fromIndex:w,toIndex:re})},V=(w,re)=>{l({type:"MOVE_FIELD",fromIndex:w,toIndex:re})},H=(w,re,de,pe)=>{l(de===pe?{type:"REORDER_ROW",dragRowIndex:de,dragIndex:w,hoverIndex:re}:{type:"REORDER_DIFF_ROW",dragIndex:w,hoverIndex:re,dragRowIndex:de,hoverRowIndex:pe})},ae=(w,re)=>{l({type:"MOVE_ROW",fromIndex:w,toIndex:re})};return t.createElement(Yn,{isContentTypeView:o,attributes:F,modifiedData:R,slug:s,componentLayouts:I,selectedField:S,fieldForm:A,onMoveRelation:O,onMoveField:V,moveRow:ae,moveItem:H,setEditFieldToSelect:w=>{l({type:"SET_FIELD_TO_EDIT",name:w}),G()},isDraggingSibling:d,setIsDraggingSibling:u},t.createElement(i.Main,null,t.createElement("form",{onSubmit:M},t.createElement(i.HeaderLayout,{title:T({id:C("components.SettingsViewWrapper.pluginHeader.title"),defaultMessage:`Configure the view - ${Xe()(k)}`},{name:Xe()(k)}),subtitle:T({id:C("components.SettingsViewWrapper.pluginHeader.description.edit-settings"),defaultMessage:"Customize how the edit view will look like."}),navigationAction:t.createElement(h.Link,{startIcon:t.createElement(L.ArrowLeft,null),onClick:w=>{w.preventDefault(),f()},to:"/"},T({id:"global.back",defaultMessage:"Back"})),primaryAction:t.createElement(i.Button,{disabled:Qe()(E,R),startIcon:t.createElement(L.Check,null),type:"submit"},T({id:"global.save",defaultMessage:"Save"}))}),t.createElement(i.ContentLayout,null,t.createElement(i.Box,{background:"neutral0",hasRadius:!0,shadow:"filterShadow",paddingTop:6,paddingBottom:6,paddingLeft:7,paddingRight:7},t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:4},t.createElement(i.Typography,{variant:"delta",as:"h2"},T({id:C("containers.SettingPage.settings"),defaultMessage:"Settings"})),t.createElement(i.Grid,null,t.createElement(i.GridItem,{col:6,s:12},t.createElement(i.Select,{label:T({id:C("containers.SettingPage.editSettings.entry.title"),defaultMessage:"Entry title"}),hint:T({id:C("containers.SettingPage.editSettings.entry.title.description"),defaultMessage:"Set the display field of your entry"}),onChange:w=>{$({target:{name:"settings.mainField",value:w===""?null:w}})},value:R.settings.mainField},_.map(w=>t.createElement(i.Option,{key:w,value:w},w))))),t.createElement(i.Box,{paddingTop:2,paddingBottom:2},t.createElement(i.Divider,null)),t.createElement(i.Typography,{variant:"delta",as:"h3"},T({id:C("containers.SettingPage.view"),defaultMessage:"View"})),t.createElement(Bc,{attributes:F,editLayout:z,fields:U,onAddField:w=>{l({type:"ON_ADD_FIELD",name:w})},onRemoveField:(w,re)=>{l({type:"REMOVE_FIELD",rowIndex:w,fieldIndex:re})}})))),t.createElement(h.ConfirmDialog,{bodyText:{id:C("popUpWarning.warning.updateAllSettings"),defaultMessage:"This will modify all your settings"},iconRightButton:t.createElement(L.Check,null),isConfirmButtonLoading:Q,isOpen:b,onToggleDialog:W,onConfirm:j,variantRightButton:"success-light"})),p&&t.createElement(Gc,{onSubmit:X,onToggle:G,onMetaChange:K,onSizeChange:N,type:P()(F,[S,"type"],""),customFieldUid:P()(F,[S,"customField"],"")})))};Pn.defaultProps={isContentTypeView:!1,updateLayout:null},Pn.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=Pn,_e=D(37617);const Qc=()=>({type:_e.ZA}),Kc=(e,r)=>({type:_e.Id,pagination:e,data:r}),Yc=()=>({type:_e.MP});function Xc(){return{type:_e.c2}}const Jc=({components:e,contentType:r})=>{const{layouts:o}=r;return{contentType:r,components:e,displayedHeaders:o.list,type:_e.Zz}},On=e=>({type:_e.Rp,target:e});var Co=D(13055),ed=D(70664);const td=()=>e=>e["content-manager_listView"]||ed.E,nd=()=>(0,He.P1)(td(),e=>e),Ro=e=>{const{displayedHeaders:r}=e["content-manager_listView"];return r};var rd=nd;const od=(0,q.default)(i.Flex)`
|
|
1044
|
-
position: relative;
|
|
1045
|
-
border-radius: 50%;
|
|
1046
|
-
width: 26px;
|
|
1047
|
-
height: 26px;
|
|
1048
|
-
border: 1px solid ${({theme:e})=>e.colors.neutral200};
|
|
1049
|
-
background: ${({theme:e})=>e.colors.neutral150};
|
|
1050
|
-
padding-left: 1px;
|
|
1051
|
-
|
|
1052
|
-
span {
|
|
1053
|
-
line-height: 0.6rem;
|
|
1054
|
-
font-size: 0.6rem;
|
|
1055
|
-
}
|
|
1056
|
-
`,vo=({children:e,...r})=>t.createElement(od,{justifyContent:"center",alignItems:"center",as:"span",...r},t.createElement(i.Typography,{variant:"sigma",textColor:"neutral600"},e));vo.propTypes={children:n().string.isRequired};var To=vo;const $n=({url:e,mime:r,alternativeText:o,name:s,ext:a,formats:c})=>{const l=(0,h.prefixFileUrlWithBackendUrl)(e);if(r.includes("image")){const m=c?.thumbnail?.url||null,g=(0,h.prefixFileUrlWithBackendUrl)(m)||l;return t.createElement(i.Avatar,{src:g,alt:o||s,preview:!0})}const d=(0,h.getFileExtension)(a),u=s.length>100?`${s.substring(0,100)}...`:s;return t.createElement(i.Tooltip,{description:u},t.createElement(To,null,d))};$n.defaultProps={alternativeText:null,formats:null},$n.propTypes={alternativeText:n().string,ext:n().string.isRequired,formats:n().object,mime:n().string.isRequired,name:n().string.isRequired,url:n().string.isRequired};var Mo=$n;const Do=({value:e})=>t.createElement(i.AvatarGroup,null,e.map((r,o)=>{const s=`${r.id}${o}`;if(o===3){const a=`+${e.length-3}`;return t.createElement(To,{key:s,preview:!1},a)}return o>3?null:t.createElement(Mo,{key:s,...r})}));Do.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 sd=Do,ad=D(51064),id=D.n(ad);const ko=({type:e,value:r})=>{const{formatDate:o,formatTime:s,formatNumber:a}=(0,Z.useIntl)();let c=r;if(e==="date"&&(c=o(id()(r),{dateStyle:"full"})),e==="datetime"&&(c=o(r,{dateStyle:"full",timeStyle:"short"})),e==="time"){const[l,d,u]=r.split(":"),m=new Date;m.setHours(l),m.setMinutes(d),m.setSeconds(u),c=s(m,{numeric:"auto",style:"short"})}return["float","decimal"].includes(e)&&(c=a(r,{maximumFractionDigits:20})),["integer","biginteger"].includes(e)&&(c=a(r,{maximumFractionDigits:0})),Wr()(c)};ko.propTypes={type:n().string.isRequired,value:n().any.isRequired};var ze=ko;const ld=(0,q.default)(i.Typography)`
|
|
1057
|
-
max-width: 500px;
|
|
1058
|
-
`,cd=async(e,r,o)=>{const{data:{results:s,pagination:a}}=await o(e);return r(),{results:s,pagination:a}},Io=({fieldSchema:e,metadatas:r,name:o,entityId:s,value:a,contentType:c})=>{const{formatMessage:l}=(0,Z.useIntl)(),{notifyStatus:d}=(0,i.useNotifyAT)(),u=(0,t.useMemo)(()=>ce(`relations/${c.uid}/${s}/${o.split(".")[0]}`),[s,o,c]),[m,g]=(0,t.useState)(!1),{get:f}=(0,h.useFetchClient)(),p=t.createElement(i.Flex,{gap:1,wrap:"nowrap"},t.createElement(i.Badge,null,a.count),l({id:"content-manager.containers.ListPage.items",defaultMessage:"{number, plural, =0 {items} one {item} other {items}}"},{number:a.count})),y=()=>{const I=l({id:C("DynamicTable.relation-loaded"),defaultMessage:"Relations have been loaded"});d(I)},{data:b,status:v}=(0,Ae.useQuery)([e.targetModel,s],()=>cd(u,y,f),{enabled:m,staleTime:0,select:I=>({...I,results:[...I.results].reverse()})});return t.createElement(i.Box,{...h.stopPropagation},t.createElement(i.SimpleMenu,{label:p,size:"S",onOpen:()=>g(!0),onClose:()=>g(!1)},v!=="success"&&t.createElement(i.MenuItem,{"aria-disabled":!0},t.createElement(i.Loader,{small:!0},l({id:C("DynamicTable.relation-loading"),defaultMessage:"Relations are loading"}))),v==="success"&&t.createElement(t.Fragment,null,b?.results.map(I=>t.createElement(i.MenuItem,{key:I.id,"aria-disabled":!0},t.createElement(ld,{ellipsis:!0},t.createElement(ze,{type:r.mainField.schema.type,value:I[r.mainField.name]||I.id})))),b?.pagination.total>10&&t.createElement(i.MenuItem,{"aria-disabled":!0,"aria-label":l({id:C("DynamicTable.relation-more"),defaultMessage:"This relation contains more entities than displayed"})},t.createElement(i.Typography,null,"\u2026")))))};Io.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};var dd=Io;const ud=(0,q.default)(i.Typography)`
|
|
1059
|
-
max-width: 500px;
|
|
1060
|
-
`,xo=({metadatas:e,value:r})=>t.createElement(ud,{textColor:"neutral800",ellipsis:!0},t.createElement(ze,{type:e.mainField.schema.type,value:r[e.mainField.name]??r.id}));xo.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 md=xo;const pd=(0,q.default)(i.Typography)`
|
|
1061
|
-
max-width: 500px;
|
|
1062
|
-
`,wo=({value:e,metadatas:r})=>{const{formatMessage:o}=(0,Z.useIntl)(),{mainField:{type:s,name:a}}=r,c=t.createElement(t.Fragment,null,t.createElement(i.Badge,null,e.length)," ",o({id:"content-manager.containers.ListPage.items",defaultMessage:"{number, plural, =0 {items} one {item} other {items}}"},{number:e.length}));return t.createElement(i.Box,{...h.stopPropagation},t.createElement(i.SimpleMenu,{label:c,size:"S"},e.map(l=>t.createElement(i.MenuItem,{key:l.id,"aria-disabled":!0},t.createElement(pd,{ellipsis:!0},t.createElement(ze,{type:s,value:l[a]||l.id}))))))};wo.propTypes={metadatas:n().shape({mainField:n().shape({name:n().string,type:n().string,value:n().string})}).isRequired,value:n().array.isRequired};var gd=wo;const fd=(0,q.default)(i.Typography)`
|
|
1063
|
-
max-width: 250px;
|
|
1064
|
-
`,Fo=({value:e,metadatas:r})=>{const{mainField:o}=r,s=e[o.name];return t.createElement(i.Tooltip,{label:s},t.createElement(fd,{textColor:"neutral800",ellipsis:!0},t.createElement(ze,{type:o.type,value:s})))};Fo.propTypes={metadatas:n().shape({mainField:n().shape({name:n().string,type:n().string,value:n().string})}).isRequired,value:n().object.isRequired};var hd=Fo,yd=D(80022),Lo=D.n(yd);function So(e){return["oneToOne","manyToOne","oneToOneMorph"].includes(e)}function bd(e,r,o,s){if(e==="component"){const{mainField:{name:a,type:c}}=o;if(s?.repeatable)return r.length>0;const l=r?.[a];return a==="id"&&![void 0,null].includes(l)?!0:Ke(c)&&c!=="biginteger"&&a!=="id"?Lo()(l):!ge()(l)}return e==="relation"?So(s.relation)?!ge()(r):r?.count>0:Ke(e)&&e!=="biginteger"?Lo()(r):e==="boolean"?r!==null:!ge()(r)}const Po=(0,q.default)(i.Typography)`
|
|
1065
|
-
max-width: 300px;
|
|
1066
|
-
`,qn=({content:e,fieldSchema:r,metadatas:o,name:s,rowId:a,contentType:c})=>{const{type:l}=r;if(!bd(l,e,o,r))return t.createElement(i.Typography,{textColor:"neutral800"},"-");switch(l){case"media":return r.multiple?t.createElement(sd,{value:e}):t.createElement(Mo,{...e});case"relation":return So(r.relation)?t.createElement(md,{metadatas:o,value:e}):t.createElement(dd,{fieldSchema:r,metadatas:o,value:e,name:s,entityId:a,contentType:c});case"component":return r.repeatable===!0?t.createElement(gd,{value:e,metadatas:o}):t.createElement(hd,{value:e,metadatas:o});case"string":return t.createElement(i.Tooltip,{description:e},t.createElement(Po,{ellipsis:!0,textColor:"neutral800"},t.createElement(ze,{type:l,value:e})));default:return t.createElement(Po,{ellipsis:!0,textColor:"neutral800"},t.createElement(ze,{type:l,value:e}))}};qn.defaultProps={content:void 0},qn.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 Ed=qn;const Bn=({canCreate:e,canDelete:r,contentType:o,headers:s,entriesToDelete:a,onClickDelete:c,onSelectRow:l,withMainAction:d,withBulkActions:u,rows:m})=>{const{push:g,location:{pathname:f}}=(0,oe.useHistory)(),{formatMessage:p}=(0,Z.useIntl)(),{trackUsage:y}=(0,h.useTracking)(),b=Er();return t.createElement(i.Tbody,null,m.map((v,I)=>{const E=a.findIndex(S=>S===v.id)!==-1,R=p({id:"content-manager.components.DynamicTable.row-line",defaultMessage:"item line {number}"},{number:I});return t.createElement(i.Tr,{key:v.id,...(0,h.onRowClick)({fn(){y("willEditEntryFromList"),g({pathname:`${f}/${v.id}`,state:{from:f},search:b})},condition:u})},d&&t.createElement(i.Td,{...h.stopPropagation},t.createElement(i.BaseCheckbox,{"aria-label":p({id:"app.component.table.select.one-entry",defaultMessage:"Select {target}"},{target:(0,no.Pp)(v.firstname,v.lastname)}),checked:E,onChange:()=>{l({name:v.id,value:!E})}})),s.map(({key:S,cellFormatter:A,name:T,...k})=>t.createElement(i.Td,{key:S},typeof A=="function"?A(v,{key:S,name:T,...k}):t.createElement(Ed,{content:v[T.split(".")[0]],name:T,contentType:o,...k,rowId:v.id}))),u&&t.createElement(i.Td,null,t.createElement(i.Flex,{justifyContent:"end",...h.stopPropagation},t.createElement(i.IconButton,{forwardedAs:oe.Link,onClick:()=>{y("willEditEntryFromButton")},to:{pathname:`${f}/${v.id}`,state:{from:f},search:b},label:p({id:"app.component.table.edit",defaultMessage:"Edit {target}"},{target:R}),noBorder:!0,icon:t.createElement(L.Pencil,null)}),e&&t.createElement(i.Box,{paddingLeft:1},t.createElement(i.IconButton,{forwardedAs:oe.Link,to:{pathname:`${f}/create/clone/${v.id}`,state:{from:f},search:b},label:p({id:"app.component.table.duplicate",defaultMessage:"Duplicate {target}"},{target:R}),noBorder:!0,icon:t.createElement(L.Duplicate,null)})),r&&t.createElement(i.Box,{paddingLeft:1},t.createElement(i.IconButton,{onClick:()=>{y("willDeleteEntryFromList"),c(v.id)},label:p({id:"global.delete-target",defaultMessage:"Delete {target}"},{target:R}),noBorder:!0,icon:t.createElement(L.Trash,null)})))))}))};Bn.defaultProps={canCreate:!1,canDelete:!1,entriesToDelete:[],onClickDelete(){},onSelectRow(){},rows:[],withBulkActions:!1,withMainAction:!1},Bn.propTypes={canCreate:n().bool,canDelete:n().bool,contentType:n().shape({uid:n().string.isRequired}).isRequired,entriesToDelete:n().array,headers:n().array.isRequired,onClickDelete:n().func,onSelectRow:n().func,rows:n().array,withBulkActions:n().bool,withMainAction:n().bool};var Cd=Bn;const Ao=({area:e,...r})=>{const o=wr(e);return o?t.createElement("ul",null,o.map(s=>s.Component(r)?t.createElement(i.Box,{key:s.name,padding:3,style:{textAlign:"center"}},t.createElement(s.Component,{...r})):null)):null};Ao.propTypes={area:n().string.isRequired};var Oo=Ao;const $o=({isConfirmButtonLoading:e,isOpen:r,onToggleDialog:o,onConfirm:s})=>{const{formatMessage:a}=(0,Z.useIntl)();return t.createElement(i.Dialog,{onClose:o,title:a({id:"app.components.ConfirmDialog.title",defaultMessage:"Confirmation"}),labelledBy:"confirmation",describedBy:"confirm-description",isOpen:r},t.createElement(i.DialogBody,{icon:t.createElement(L.ExclamationMarkCircle,null)},t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:2},t.createElement(i.Flex,{justifyContent:"center"},t.createElement(i.Typography,{id:"confirm-description"},a({id:C("popUpWarning.bodyMessage.contentType.delete.all"),defaultMessage:"Are you sure you want to delete these entries?"}))),t.createElement(i.Flex,null,t.createElement(Oo,{area:"contentManager.listView.deleteModalAdditionalInfos"})))),t.createElement(i.DialogFooter,{startAction:t.createElement(i.Button,{onClick:o,variant:"tertiary"},a({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endAction:t.createElement(i.Button,{onClick:s,variant:"danger-light",startIcon:t.createElement(L.Trash,null),id:"confirm-delete",loading:e},a({id:"app.components.Button.confirm",defaultMessage:"Confirm"}))}))};$o.propTypes={isConfirmButtonLoading:n().bool.isRequired,isOpen:n().bool.isRequired,onConfirm:n().func.isRequired,onToggleDialog:n().func.isRequired};var Rd=$o;const qo=({isConfirmButtonLoading:e,isOpen:r,onToggleDialog:o,onConfirm:s})=>{const{formatMessage:a}=(0,Z.useIntl)();return t.createElement(i.Dialog,{onClose:o,title:a({id:"app.components.ConfirmDialog.title",defaultMessage:"Confirmation"}),labelledBy:"confirmation",describedBy:"confirm-description",isOpen:r},t.createElement(i.DialogBody,{icon:t.createElement(L.ExclamationMarkCircle,null)},t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:2},t.createElement(i.Flex,{justifyContent:"center"},t.createElement(i.Typography,{id:"confirm-description"},a({id:"components.popUpWarning.message",defaultMessage:"Are you sure you want to delete this?"}))),t.createElement(i.Flex,null,t.createElement(Oo,{area:"contentManager.listView.deleteModalAdditionalInfos"})))),t.createElement(i.DialogFooter,{startAction:t.createElement(i.Button,{onClick:o,variant:"tertiary"},a({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endAction:t.createElement(i.Button,{onClick:s,variant:"danger-light",startIcon:t.createElement(L.Trash,null),id:"confirm-delete",loading:e},a({id:"app.components.Button.confirm",defaultMessage:"Confirm"}))}))};qo.propTypes={isConfirmButtonLoading:n().bool.isRequired,isOpen:n().bool.isRequired,onConfirm:n().func.isRequired,onToggleDialog:n().func.isRequired};var vd=qo;const Td=(0,q.default)(i.Status)`
|
|
1067
|
-
width: min-content;
|
|
1068
|
-
`,Nn=({canCreate:e,canDelete:r,contentTypeName:o,action:s,isBulkable:a,isLoading:c,onConfirmDelete:l,onConfirmDeleteAll:d,layout:u,rows:m})=>{const{runHookWaterfall:g}=(0,h.useStrapiApp)(),f=u.contentType.options.draftAndPublish||!1,{formatMessage:p}=(0,Z.useIntl)(),y=(0,le.useSelector)(Ro),b=(0,t.useMemo)(()=>{const I=g(ct.No,{displayedHeaders:y,layout:u}).displayedHeaders.map(E=>{const{metadatas:R}=E;if(E.fieldSchema.type==="relation"){const S=`${E.name}.${E.metadatas.mainField.name}`;return{...E,metadatas:{...R,label:p({id:C(`containers.ListPage.table-headers.${E.name}`),defaultMessage:R.label})},name:S}}return{...E,metadatas:{...R,label:p({id:C(`containers.ListPage.table-headers.${E.name}`),defaultMessage:R.label})}}});return f?[...I,{key:"__published_at_temp_key__",name:"publishedAt",fieldSchema:{type:"custom"},metadatas:{label:p({id:C("containers.ListPage.table-headers.publishedAt"),defaultMessage:"publishedAt"}),searchable:!1,sortable:!0},cellFormatter(E){const R=E.publishedAt,S=R?"success":"secondary";return t.createElement(Td,{showBullet:!1,variant:S,size:"S"},t.createElement(i.Typography,{fontWeight:"bold",textColor:`${S}700`},p({id:C(`containers.List.${R?"published":"draft"}`),defaultMessage:R?"Published":"Draft"})))}}]:I},[g,y,u,f,p]);return t.createElement(h.DynamicTable,{components:{ConfirmDialogDelete:vd,ConfirmDialogDeleteAll:Rd},contentType:o,action:s,isLoading:c,headers:b,onConfirmDelete:l,onConfirmDeleteAll:d,onOpenDeleteAllModalTrackedEvent:"willBulkDeleteEntries",rows:m,withBulkActions:!0,withMainAction:r&&a},t.createElement(Cd,{canCreate:e,canDelete:r,contentType:u.contentType,headers:b,rows:m,withBulkActions:!0,withMainAction:r&&a}))};Nn.defaultProps={action:void 0},Nn.propTypes={canCreate:n().bool.isRequired,canDelete:n().bool.isRequired,contentTypeName:n().string.isRequired,action:n().node,isBulkable:n().bool.isRequired,isLoading:n().bool.isRequired,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}).isRequired}).isRequired,onConfirmDelete:n().func.isRequired,onConfirmDeleteAll:n().func.isRequired,rows:n().array.isRequired};var Md=Nn;const Dd=["json","component","media","richtext","dynamiczone","password"],kd=["createdAt","updatedAt"];var Id=(e,r)=>{const{allPermissions:o}=(0,h.useRBACProvider)(),s=(0,h.findMatchingPermissions)(o,[{action:"plugin::content-manager.explorer.read",subject:r}]),a=P()(s,["0","properties","fields"],[]);return Object.keys(P()(e,["attributes"]),{}).filter(d=>{const u=P()(e,["attributes",d],{});return!(!u.type||Dd.includes(u.type)||!a.includes(d)&&d!=="id"&&!kd.includes(d))}).sort()};const Bo=({displayedFilters:e})=>{const[r,o]=(0,t.useState)(!1),{formatMessage:s}=(0,Z.useIntl)(),a=(0,t.useRef)(),{trackUsage:c}=(0,h.useTracking)(),l=()=>{r||c("willFilterEntries"),o(d=>!d)};return t.createElement(t.Fragment,null,t.createElement(i.Box,{paddingTop:1,paddingBottom:1},t.createElement(i.Button,{variant:"tertiary",ref:a,startIcon:t.createElement(L.Filter,null),onClick:l,size:"S"},s({id:"app.utils.filters",defaultMessage:"Filters"})),r&&t.createElement(h.FilterPopoverURLQuery,{displayedFilters:e,isVisible:r,onToggle:l,source:a})),t.createElement(h.FilterListURLQuery,{filtersSchema:e}))};Bo.propTypes={displayedFilters:n().arrayOf(n().shape({name:n().string.isRequired,metadatas:n().shape({label:n().string}),fieldSchema:n().shape({type:n().string})})).isRequired};var xd=Bo;const No=({contentType:e,slug:r,metadatas:o})=>{const{formatMessage:s}=(0,Z.useIntl)(),c=Id(e,r).map(l=>{const d=e.attributes[l],{type:u,enum:m}=d,g={name:"didFilterEntries",properties:{useRelation:u==="relation"}},{mainField:f,label:p}=o[l].list;return{name:l,metadatas:{label:s({id:p,defaultMessage:p})},fieldSchema:{type:u,options:m,mainField:f},trackedEvent:g}});return t.createElement(xd,{displayedFilters:c})};No.propTypes={contentType:n().object.isRequired,metadatas:n().object.isRequired,slug:n().string.isRequired};var wd=No,Fd=e=>Object.keys(e).reduce((o,s)=>{const a=e[s];return nr(a)&&o.push(s),o},[]).sort();const jo=({layout:e})=>{const r=(0,le.useDispatch)(),o=(0,le.useSelector)(Ro),{trackUsage:s}=(0,h.useTracking)(),{formatMessage:a}=(0,Z.useIntl)(),c=Fd(e.contentType.attributes).map(u=>{const m=e.contentType.metadatas[u].list;return{name:u,intlLabel:{id:m.label,defaultMessage:m.label}}}),l=o.map(({name:u})=>u),d=u=>{if(s("didChangeDisplayedFields"),u.length<l.length){const m=l.filter(g=>u.indexOf(g)===-1);r(On({name:m[0],value:!0}))}else{const m=u.filter(g=>l.indexOf(g)===-1);r(On({name:m[0],value:!1}))}};return t.createElement(i.Box,{paddingTop:1,paddingBottom:1},t.createElement(i.Select,{"aria-label":"change displayed fields",value:l,onChange:d,customizeContent:u=>a({id:C("select.currently.selected"),defaultMessage:"{count} currently selected"},{count:u.length}),multi:!0,size:"S"},c.map(u=>t.createElement(i.Option,{key:u.name,value:u.name},a({id:u.intlLabel.id||u.name,defaultMessage:u.intlLabel.defaultMessage||u.name})))))};jo.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};var Ld=(0,t.memo)(jo);const jn=({pagination:e})=>t.createElement(i.Box,{paddingTop:4},t.createElement(i.Flex,{alignItems:"flex-end",justifyContent:"space-between"},t.createElement(h.PageSizeURLQuery,{trackedEvent:"willChangeNumberOfEntriesPerPage"}),t.createElement(h.PaginationURLQuery,{pagination:e})));jn.defaultProps={pagination:{pageCount:0,pageSize:10,total:0}},jn.propTypes={pagination:n().shape({page:n().number,pageCount:n().number,pageSize:n().number,total:n().number})};var Sd=jn;const Pd=qe.Z.contentManager,Ad=(0,q.default)(i.Box)`
|
|
1069
|
-
svg {
|
|
1070
|
-
path {
|
|
1071
|
-
fill: ${({theme:e})=>e.colors.neutral900};
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
`;function Vo({canCreate:e,canDelete:r,canRead:o,data:s,getData:a,getDataSucceeded:c,isLoading:l,layout:d,pagination:u,slug:m}){const{total:g}=u,{contentType:{metadatas:f,settings:{bulkable:p,filterable:y,searchable:b}}}=d,v=(0,h.useNotification)(),{trackUsage:I}=(0,h.useTracking)(),{refetchPermissions:E}=(0,h.useRBACProvider)(),R=(0,t.useRef)(I),S=(0,t.useRef)(E),{notifyStatus:A}=(0,i.useNotifyAT)(),{formatAPIError:T}=(0,h.useAPIErrorHandler)(C);(0,h.useFocusWhenNavigate)();const[{query:k}]=(0,h.useQueryParams)(),F=Yr(k),_=(0,Me.stringify)({plugins:k.plugins},{encode:!1}),{pathname:z}=(0,oe.useLocation)(),{push:B}=(0,oe.useHistory)(),{formatMessage:U}=(0,Z.useIntl)(),$=d.contentType,G=P()($,"options.draftAndPublish",!1),W=(0,h.useFetchClient)(),{post:K,del:N}=W,X=(0,t.useRef)(""),M=(0,t.useCallback)(async(ae,w)=>{a();try{const re=w?{cancelToken:w.token}:null,{data:{results:de,pagination:pe}}=await W.get(ae,re);A(U({id:C("utils.data-loaded"),defaultMessage:"{number, plural, =1 {# entry has} other {# entries have}} successfully been loaded"},{number:pe.count})),c(pe,de)}catch(re){if(ye.Z.isCancel(re))return;if(P()(re,"response.status",null)===403){await S.current(),v({type:"info",message:{id:C("permissions.not-allowed.update")}}),B("/");return}v({type:"warning",message:{id:C("error.model.fetch")}})}},[U,a,c,A,B,v,W]),x=(0,t.useCallback)(async ae=>{try{await K(ce(`collection-types/${m}/actions/bulkDelete`),{ids:ae});const w=ce(`collection-types/${m}${F}`);M(w),R.current("didBulkDeleteEntries")}catch(w){v({type:"warning",message:T(w)})}},[M,F,m,v,T,K]),Q=(0,t.useCallback)(async ae=>{try{await N(ce(`collection-types/${m}/${ae}`));const w=ce(`collection-types/${m}${F}`);M(w),v({type:"success",message:{id:C("success.record.delete")}})}catch(w){v({type:"warning",message:T(w)})}},[m,F,M,v,T,N]);(0,t.useEffect)(()=>{const w=ye.Z.CancelToken.source(),re=o,de=ce(`collection-types/${m}${F}`);return re&&de.includes(X.current)&&M(de,w),()=>{X.current=m,w.cancel("Operation canceled by the user.")}},[o,a,m,F,c,M]);const j=U({id:C("header.name"),defaultMessage:"Content"}),O=U({id:$.info.displayName,defaultMessage:$.info.displayName||j}),V=o?U({id:C("pages.ListView.header-subtitle"),defaultMessage:"{number, plural, =0 {# entries} one {# entry} other {# entries}} found"},{number:g}):null,H=ae=>e?t.createElement(i.Button,{...ae,forwardedAs:oe.Link,onClick:()=>{const w=G?{status:"draft"}:{};R.current("willCreateEntry",w)},to:{pathname:`${z}/create`,search:k.plugins?_:""},startIcon:t.createElement(L.Plus,null),style:{textDecoration:"none"}},U({id:C("HeaderLayout.button.label-add-entry"),defaultMessage:"Create new entry"})):null;return t.createElement(i.Main,{"aria-busy":l},t.createElement(i.HeaderLayout,{primaryAction:H(),subtitle:V,title:O,navigationAction:t.createElement(h.Link,{startIcon:t.createElement(L.ArrowLeft,null),to:"/content-manager/"},U({id:"global.back",defaultMessage:"Back"}))}),!o&&t.createElement(i.ActionLayout,{endActions:t.createElement(dt,{area:"contentManager.listView.actions"})}),o&&t.createElement(i.ActionLayout,{endActions:t.createElement(t.Fragment,null,t.createElement(dt,{area:"contentManager.listView.actions"}),t.createElement(Ld,{layout:d}),t.createElement(h.CheckPermissions,{permissions:Pd.collectionTypesConfigurations},t.createElement(Ad,{paddingTop:1,paddingBottom:1},t.createElement(i.IconButton,{onClick:()=>{I("willEditListLayout")},forwardedAs:oe.Link,to:{pathname:`${m}/configurations/list`,search:_},icon:t.createElement(L.Cog,null),label:U({id:"app.links.configure-view",defaultMessage:"Configure the view"})})))),startActions:t.createElement(t.Fragment,null,b&&t.createElement(h.SearchURLQuery,{label:U({id:"app.component.search.label",defaultMessage:"Search for {target}"},{target:O}),placeholder:U({id:"global.search",defaultMessage:"Search"}),trackedEvent:"didSearch"}),y&&t.createElement(wd,{contentType:$,slug:m,metadatas:f}))}),t.createElement(i.ContentLayout,null,o?t.createElement(t.Fragment,null,t.createElement(Md,{canCreate:e,canDelete:r,contentTypeName:O,onConfirmDeleteAll:x,onConfirmDelete:Q,isBulkable:p,isLoading:l,layout:d,rows:s,action:H({variant:"secondary"})}),t.createElement(Sd,{pagination:{pageCount:u?.pageCount||1}})):t.createElement(h.NoPermissions,null)))}Vo.propTypes={canCreate:n().bool.isRequired,canDelete:n().bool.isRequired,canRead:n().bool.isRequired,data:n().array.isRequired,layout:n().exact({components:n().object.isRequired,contentType:n().shape({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 Od=rd();function $d(e){return(0,Co.bindActionCreators)({getData:Qc,getDataSucceeded:Kc,onChangeListHeaders:On,onResetListHeaders:Yc},e)}const qd=(0,le.connect)(Od,$d);var Bd=(0,Co.compose)(qd)((0,t.memo)(Vo,ke()));const Vn=e=>{const r=(0,t.useMemo)(()=>or(e.slug),[e.slug]),{isLoading:o,allowedActions:s}=(0,h.useRBAC)(r,e.permissions);return o?t.createElement(h.LoadingIndicatorPage,null):t.createElement(Bd,{...e,...s})};Vn.defaultProps={permissions:[]},Vn.propTypes={permissions:n().array,slug:n().string.isRequired};var Nd=(0,t.memo)(Vn,(e,r)=>{const o=(0,h.difference)(e,r);return Object.keys(o).filter(a=>a!=="state").length>0});const _o=({layout:e,...r})=>{const o=(0,le.useDispatch)(),{replace:s}=(0,oe.useHistory)(),[{query:a,rawQuery:c}]=(0,h.useQueryParams)(),l=Rr(a,r.slug,"listView"),d=br(r.slug);return(0,t.useEffect)(()=>{c||s(d)},[c,s,d]),(0,t.useEffect)(()=>{o(Jc(e))},[o,e]),(0,t.useEffect)(()=>()=>{o(Xc())},[o]),l?t.createElement(Nd,{...r,layout:e,permissions:l}):null};_o.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 jd=_o,Vd=(e,r)=>{const{put:o}=(0,h.getFetchClient)();return o(ce(`content-types/${r}/configuration`),e)};const _n=({modifiedData:e,onChange:r,sortOptions:o})=>{const{formatMessage:s}=(0,Z.useIntl)(),{settings:a,metadatas:c}=e;return t.createElement(i.Flex,{direction:"column",alignItems:"stretch",gap:4},t.createElement(i.Typography,{variant:"delta",as:"h2"},s({id:C("containers.SettingPage.settings"),defaultMessage:"Settings"})),t.createElement(i.Flex,{justifyContent:"space-between",gap:4},t.createElement(i.Box,{width:"100%"},t.createElement(i.ToggleInput,{label:s({id:C("form.Input.search"),defaultMessage:"Enable search"}),onChange:l=>{r({target:{name:"settings.searchable",value:l.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:a.searchable})),t.createElement(i.Box,{width:"100%"},t.createElement(i.ToggleInput,{label:s({id:C("form.Input.filters"),defaultMessage:"Enable filters"}),onChange:l=>{r({target:{name:"settings.filterable",value:l.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:a.filterable})),t.createElement(i.Box,{width:"100%"},t.createElement(i.ToggleInput,{label:s({id:C("form.Input.bulkActions"),defaultMessage:"Enable bulk actions"}),onChange:l=>{r({target:{name:"settings.bulkable",value:l.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:a.bulkable}))),t.createElement(i.Grid,{gap:4},t.createElement(i.GridItem,{s:12,col:6},t.createElement(i.Select,{label:s({id:C("form.Input.pageEntries"),defaultMessage:"Entries per page"}),hint:s({id:C("form.Input.pageEntries.inputDescription"),defaultMessage:"Note: You can override this value in the Collection Type settings page."}),onChange:l=>r({target:{name:"settings.pageSize",value:l}}),name:"settings.pageSize",value:e.settings.pageSize||""},[10,20,50,100].map(l=>t.createElement(i.Option,{key:l,value:l},l)))),t.createElement(i.GridItem,{s:12,col:3},t.createElement(i.Select,{label:s({id:C("form.Input.defaultSort"),defaultMessage:"Default sort attribute"}),onChange:l=>r({target:{name:"settings.defaultSortBy",value:l}}),name:"settings.defaultSortBy",value:e.settings.defaultSortBy||""},o.map(l=>t.createElement(i.Option,{key:l,value:l},c[l].list.label||l)))),t.createElement(i.GridItem,{s:12,col:3},t.createElement(i.Select,{label:s({id:C("form.Input.sort.order"),defaultMessage:"Default sort order"}),onChange:l=>r({target:{name:"settings.defaultSortOrder",value:l}}),name:"settings.defaultSortOrder",value:e.settings.defaultSortOrder||""},["ASC","DESC"].map(l=>t.createElement(i.Option,{key:l,value:l},l))))))};_n.defaultProps={modifiedData:{},sortOptions:[]},_n.propTypes={modifiedData:n().object,onChange:n().func.isRequired,sortOptions:n().array};var _d=_n;const zn=q.default.button`
|
|
1075
|
-
display: flex;
|
|
1076
|
-
align-items: center;
|
|
1077
|
-
height: ${({theme:e})=>e.spaces[7]};
|
|
1078
|
-
|
|
1079
|
-
&:last-child {
|
|
1080
|
-
padding: 0 ${({theme:e})=>e.spaces[3]};
|
|
1081
|
-
}
|
|
1082
|
-
`,zo=(0,q.default)(zn)`
|
|
1083
|
-
padding: 0 ${({theme:e})=>e.spaces[3]};
|
|
1084
|
-
border-right: 1px solid ${({theme:e})=>e.colors.neutral150};
|
|
1085
|
-
cursor: all-scroll;
|
|
1086
|
-
|
|
1087
|
-
svg {
|
|
1088
|
-
width: ${12/16}rem;
|
|
1089
|
-
height: ${12/16}rem;
|
|
1090
|
-
}
|
|
1091
|
-
`,zd=(0,q.default)(i.Flex)`
|
|
1092
|
-
max-height: ${32/16}rem;
|
|
1093
|
-
cursor: pointer;
|
|
1094
|
-
|
|
1095
|
-
svg {
|
|
1096
|
-
width: ${10/16}rem;
|
|
1097
|
-
height: ${10/16}rem;
|
|
1098
|
-
|
|
1099
|
-
path {
|
|
1100
|
-
fill: ${({theme:e})=>e.colors.neutral600};
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
&:hover {
|
|
1105
|
-
background-color: ${({theme:e})=>e.colors.primary100};
|
|
1106
|
-
border-color: ${({theme:e})=>e.colors.primary200};
|
|
1107
|
-
|
|
1108
|
-
svg {
|
|
1109
|
-
path {
|
|
1110
|
-
fill: ${({theme:e})=>e.colors.primary600};
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
${i.Typography} {
|
|
1115
|
-
color: ${({theme:e})=>e.colors.primary600};
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
${zo} {
|
|
1119
|
-
border-right: 1px solid ${({theme:e})=>e.colors.primary200};
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
`,Wd=(0,q.default)(i.Box)`
|
|
1123
|
-
&:last-child {
|
|
1124
|
-
padding-right: ${({theme:e})=>e.spaces[3]};
|
|
1125
|
-
}
|
|
1126
|
-
`,Wo=({index:e,isDraggingSibling:r,labelField:o,onClickEditField:s,onMoveField:a,onRemoveField:c,name:l,setIsDraggingSibling:d})=>{const{formatMessage:u}=(0,Z.useIntl)(),m=(0,t.useRef)(null),g=(0,t.useRef)(null),[,f]=(0,t.useState)(!1),p=(0,t.useRef)(),y=Xn(o),b=()=>{p.current&&p.current.click()},[,v]=(0,Le.useDrop)({accept:he.FIELD,hover(A,T){if(!g.current)return;const k=A.index,F=e;if(k===F)return;const _=g.current.getBoundingClientRect(),z=(_.right-_.left)/2,U=T.getClientOffset().x-_.left;k>F&&U>z||k<F&&U<z||(a(k,F),A.index=F)}}),[{isDragging:I},E,R]=(0,Le.useDrag)({type:he.FIELD,item(){return{index:e,labelField:o,name:l}},collect:A=>({isDragging:A.isDragging()}),end(){d(!1)}});(0,t.useEffect)(()=>{R((0,Ue.rX)(),{captureDraggingState:!1})},[R]),(0,t.useEffect)(()=>{I&&d(!0)},[I,d]),(0,t.useEffect)(()=>{r||f(A=>!A)},[r]);const S={dragRef:E(m),dropRef:v(g)};return t.createElement(Wd,{ref:S?S.dropRef:null},I&&t.createElement(Tt,{transparent:!0,labelField:y}),!I&&r&&t.createElement(Tt,{isSibling:!0,labelField:y}),!I&&!r&&t.createElement(zd,{borderColor:"neutral150",background:"neutral100",hasRadius:!0,justifyContent:"space-between",onClick:b,isDragging:I},t.createElement(i.Flex,{gap:3},t.createElement(zo,{as:"span","aria-label":u({id:C("components.DraggableCard.move.field"),defaultMessage:"Move {item}"},{item:o}),onClick:A=>A.stopPropagation(),ref:S.dragRef,type:"button"},t.createElement(L.Drag,null)),t.createElement(i.Typography,{fontWeight:"bold"},y)),t.createElement(i.Flex,{paddingLeft:3},t.createElement(zn,{ref:p,onClick:A=>{A.stopPropagation(),s(l)},"aria-label":u({id:C("components.DraggableCard.edit.field"),defaultMessage:"Edit {item}"},{item:o}),type:"button"},t.createElement(L.Pencil,null)),t.createElement(zn,{onClick:c,"data-testid":`delete-${l}`,"aria-label":u({id:C("components.DraggableCard.delete.field"),defaultMessage:"Delete {item}"},{item:o}),type:"button"},t.createElement(L.Cross,null)))))};Wo.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 Ud=Wo;const Uo=(0,q.default)(i.Box)`
|
|
1127
|
-
flex: ${({size:e})=>e};
|
|
1128
|
-
`,Hd=(0,q.default)(Uo)`
|
|
1129
|
-
overflow-x: scroll;
|
|
1130
|
-
overflow-y: hidden;
|
|
1131
|
-
`,Gd=(0,q.default)(Uo)`
|
|
1132
|
-
max-width: ${32/16}rem;
|
|
1133
|
-
`,Ho=({displayedFields:e,listRemainingFields:r,metadatas:o,onAddField:s,onClickEditField:a,onMoveField:c,onRemoveField:l})=>{const{formatMessage:d}=(0,Z.useIntl)(),[u,m]=(0,t.useState)(!1),[g,f]=(0,t.useState)(null),p=(0,t.useRef)();function y(...v){f("add"),s(...v)}function b(...v){f("remove"),l(...v)}return(0,t.useEffect)(()=>{g==="add"&&p?.current&&(p.current.scrollLeft=p.current.scrollWidth)},[e,g]),t.createElement(t.Fragment,null,t.createElement(i.Box,{paddingBottom:4},t.createElement(i.Typography,{variant:"delta",as:"h2"},d({id:C("containers.SettingPage.view"),defaultMessage:"View"}))),t.createElement(i.Flex,{paddingTop:4,paddingLeft:4,paddingRight:4,borderColor:"neutral300",borderStyle:"dashed",borderWidth:"1px",hasRadius:!0},t.createElement(Hd,{size:"1",paddingBottom:4,ref:p},t.createElement(i.Flex,{gap:3},e.map((v,I)=>t.createElement(Ud,{key:v,index:I,isDraggingSibling:u,onMoveField:c,onClickEditField:a,onRemoveField:E=>b(E,I),name:v,labelField:o[v].list.label||v,setIsDraggingSibling:m})))),t.createElement(Gd,{size:"auto",paddingBottom:4},t.createElement(i.SimpleMenu,{label:d({id:C("components.FieldSelect.label"),defaultMessage:"Add a field"}),as:i.IconButton,icon:t.createElement(L.Plus,null),disabled:r.length<=0,"data-testid":"add-field"},r.map(v=>t.createElement(i.MenuItem,{key:v,onClick:()=>y(v)},o[v].list.label||v))))))};Ho.propTypes={displayedFields:Ee.PropTypes.array.isRequired,listRemainingFields:Ee.PropTypes.array.isRequired,metadatas:Ee.PropTypes.objectOf(Ee.PropTypes.shape({list:Ee.PropTypes.shape({label:Ee.PropTypes.string})})).isRequired,onAddField:Ee.PropTypes.func.isRequired,onClickEditField:Ee.PropTypes.func.isRequired,onMoveField:Ee.PropTypes.func.isRequired,onRemoveField:Ee.PropTypes.func.isRequired};var Zd=Ho;const Qd=(0,q.default)(i.Flex)`
|
|
1134
|
-
svg {
|
|
1135
|
-
width: ${32/16}rem;
|
|
1136
|
-
height: ${24/16}rem;
|
|
1137
|
-
margin-right: ${({theme:e})=>e.spaces[3]};
|
|
1138
|
-
}
|
|
1139
|
-
`,Go=({attributes:e,fieldForm:r,fieldToEdit:o,onCloseModal:s,onChangeEditLabel:a,onSubmit:c,type:l})=>{const{formatMessage:d}=(0,Z.useIntl)(),u=e[o].relationType;let m=!["media","relation"].includes(l);return["oneWay","oneToOne","manyToOne"].includes(u)&&(m=!0),t.createElement(i.ModalLayout,{onClose:s,labelledBy:"title"},t.createElement("form",{onSubmit:c},t.createElement(i.ModalHeader,null,t.createElement(Qd,null,t.createElement(yo,{type:l}),t.createElement(i.Typography,{fontWeight:"bold",textColor:"neutral800",as:"h2",id:"title"},d({id:C("containers.ListSettingsView.modal-form.edit-label"),defaultMessage:"Edit {fieldName}"},{fieldName:Xe()(o)})))),t.createElement(i.ModalBody,null,t.createElement(i.Grid,{gap:4},t.createElement(i.GridItem,{s:12,col:6},t.createElement(i.TextInput,{id:"label-input",label:d({id:C("form.Input.label"),defaultMessage:"Label"}),name:"label",onChange:g=>a(g),value:r.label,hint:d({id:C("form.Input.label.inputDescription"),defaultMessage:"This value overrides the label displayed in the table's head"})})),m&&t.createElement(i.GridItem,{s:12,col:6},t.createElement(i.ToggleInput,{"data-testid":"Enable sort on this field",checked:r.sortable,label:d({id:C("form.Input.sort.field"),defaultMessage:"Enable sort on this field"}),name:"sortable",onChange:g=>a({target:{name:"sortable",value:g.target.checked}}),onLabel:d({id:"app.components.ToggleCheckbox.on-label",defaultMessage:"on"}),offLabel:d({id:"app.components.ToggleCheckbox.off-label",defaultMessage:"off"})})))),t.createElement(i.ModalFooter,{startActions:t.createElement(i.Button,{onClick:s,variant:"tertiary"},d({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endActions:t.createElement(i.Button,{type:"submit"},d({id:"global.finish",defaultMessage:"Finish"}))})))};Go.propTypes={attributes:n().objectOf(n().shape({relationType:n().string})).isRequired,fieldForm:n().shape({label:n().string,sortable:n().bool}).isRequired,fieldToEdit:n().string.isRequired,onChangeEditLabel:n().func.isRequired,onCloseModal:n().func.isRequired,onSubmit:n().func.isRequired,type:n().string.isRequired};var Kd=Go,Yd=(e,r)=>({...e,initialData:r,modifiedData:r});const Wn={fieldForm:{},fieldToEdit:"",initialData:{},modifiedData:{}};var Xd=(e=Wn,r)=>(0,lt.default)(e,o=>{const s=["modifiedData","layouts","list"];switch(r.type){case"ADD_FIELD":{const a=P()(e,s,[]);ne()(o,s,[...a,r.item]);break}case"MOVE_FIELD":{const a=P()(e,s,[]),{originalIndex:c,atIndex:l}=r;ne()(o,s,rt(a,c,l));break}case"ON_CHANGE":{ne()(o,["modifiedData",...r.keys.split(".")],r.value);break}case"ON_CHANGE_FIELD_METAS":{ne()(o,["fieldForm",r.name],r.value);break}case"REMOVE_FIELD":{const a=P()(e,s,[]);ne()(o,s,a.filter((c,l)=>r.index!==l));break}case"SET_FIELD_TO_EDIT":{const{fieldToEdit:a}=r;o.fieldToEdit=a,o.fieldForm.label=P()(o,["modifiedData","metadatas",a,"list","label"],""),o.fieldForm.sortable=P()(o,["modifiedData","metadatas",a,"list","sortable"],"");break}case"UNSET_FIELD_TO_EDIT":{o.fieldForm={},o.fieldToEdit="";break}case"SUBMIT_FIELD_FORM":{const a=["modifiedData","metadatas",e.fieldToEdit,"list"];ne()(o,[...a,"label"],e.fieldForm.label),ne()(o,[...a,"sortable"],e.fieldForm.sortable);break}default:return o}});const Jd=["media","richtext","dynamiczone","relation","component","json"],Zo=({layout:e,slug:r})=>{const{formatMessage:o}=(0,Z.useIntl)(),{trackUsage:s}=(0,h.useTracking)(),a=Er(),c=(0,h.useNotification)(),{refetchData:l}=(0,t.useContext)(kr),[d,u]=(0,t.useState)(!1),m=()=>u(M=>!M),[g,f]=(0,t.useReducer)(Xd,Wn,()=>Yd(Wn,e)),{fieldToEdit:p,fieldForm:y,initialData:b,modifiedData:v}=g,I=!ge()(y),{attributes:E}=e,R=v.layouts.list,S=()=>{const{settings:{pageSize:M,defaultSortBy:x,defaultSortOrder:Q},kind:j,uid:O}=b,V=`${x}:${Q}`,H=`${(0,Me.stringify)({page:1,pageSize:M,sort:V},{encode:!1})}${a?`&${a}`:""}`;return`/content-manager/${j}/${O}?${H}`},A=({target:{name:M,value:x}})=>{f({type:"ON_CHANGE",keys:M,value:M==="settings.pageSize"?parseInt(x,10):x})},T=async()=>{const M=Gt()(v,["layouts","settings","metadatas"]);$.mutate(M)},k=M=>{f({type:"ADD_FIELD",item:M})},F=(M,x)=>{M.stopPropagation(),R.length===1?c({type:"info",message:{id:C("notification.info.minimumFields")}}):f({type:"REMOVE_FIELD",index:x})},_=M=>{M.preventDefault(),m(),s("willSaveContentTypeLayout")},z=M=>{f({type:"SET_FIELD_TO_EDIT",fieldToEdit:M})},B=()=>{f({type:"UNSET_FIELD_TO_EDIT"})},U=M=>{M.preventDefault(),f({type:"SUBMIT_FIELD_FORM"})},$=(0,Ae.useMutation)(M=>Vd(M,r),{onSuccess(){s("didEditListSettings"),l()},onError(){c({type:"warning",message:{id:"notification.error"}})}}),{isLoading:G}=$,W=({target:{name:M,value:x}})=>{f({type:"ON_CHANGE_FIELD_METAS",name:M,value:x})},K=Object.entries(E).reduce((M,x)=>{const[Q,j]=x,O=nr(j),V=R.includes(Q);return O&&!V&&M.push(Q),M},[]).sort(),N=Object.entries(E).reduce((M,x)=>{const[Q,{type:j}]=x;return Jd.includes(j)||M.push(Q),M},[]),X=(M,x)=>{f({type:"MOVE_FIELD",originalIndex:M,atIndex:x})};return t.createElement(i.Layout,null,t.createElement(i.Main,{"aria-busy":G},t.createElement("form",{onSubmit:_},t.createElement(i.HeaderLayout,{navigationAction:t.createElement(h.Link,{startIcon:t.createElement(L.ArrowLeft,null),to:S,id:"go-back"},o({id:"global.back",defaultMessage:"Back"})),primaryAction:t.createElement(i.Button,{size:"S",startIcon:t.createElement(L.Check,null),disabled:Qe()(v,b),type:"submit"},o({id:"global.save",defaultMessage:"Save"})),subtitle:o({id:C("components.SettingsViewWrapper.pluginHeader.description.list-settings"),defaultMessage:"Define the settings of the list view."}),title:o({id:C("components.SettingsViewWrapper.pluginHeader.title"),defaultMessage:"Configure the view - {name}"},{name:Xe()(v.info.displayName)})}),t.createElement(i.ContentLayout,null,t.createElement(i.Box,{background:"neutral0",hasRadius:!0,shadow:"tableShadow",paddingTop:6,paddingBottom:6,paddingLeft:7,paddingRight:7},t.createElement(_d,{modifiedData:v,onChange:A,sortOptions:N}),t.createElement(i.Box,{paddingTop:6,paddingBottom:6},t.createElement(i.Divider,null)),t.createElement(Zd,{listRemainingFields:K,displayedFields:R,onAddField:k,onClickEditField:z,onMoveField:X,onRemoveField:F,metadatas:v.metadatas}))),t.createElement(h.ConfirmDialog,{bodyText:{id:C("popUpWarning.warning.updateAllSettings"),defaultMessage:"This will modify all your settings"},iconRightButton:t.createElement(L.Check,null),isConfirmButtonLoading:G,isOpen:d,onToggleDialog:m,onConfirm:T,variantRightButton:"success-light"})),I&&t.createElement(Kd,{attributes:E,fieldForm:y,fieldToEdit:p,onChangeEditLabel:W,onCloseModal:B,onSubmit:U,type:P()(E,[p,"type"],"text")})))};Zo.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 eu=(0,t.memo)(Zo),tu=()=>t.createElement(i.Box,{padding:8},t.createElement(h.AnErrorOccurred,null));const Qo=qe.Z.contentManager,Ko=({match:{params:{slug:e},url:r}})=>{const{isLoading:o,layout:s,updateLayout:a}=fr(e),{rawContentTypeLayout:c,rawComponentsLayouts:l}=(0,t.useMemo)(()=>{let g={},f={};return s.contentType&&(g=at(s.contentType)),s.components&&(f=Object.keys(s.components).reduce((p,y)=>(p[y]=at(s.components[y]),p),{})),{rawContentTypeLayout:g,rawComponentsLayouts:f}},[s]);if((0,te.get)(s,["contentType","uid"],null)!==e||o)return t.createElement(h.LoadingIndicatorPage,null);const u=({location:{state:g},history:{goBack:f},match:{params:{id:p,origin:y}}},b)=>t.createElement(b,{slug:e,layout:s,state:g,goBack:f,id:p,origin:y}),m=[{path:"create/clone/:origin",comp:Et},{path:"create",comp:Et},{path:":id",comp:Et},{path:"",comp:jd}].map(({path:g,comp:f})=>t.createElement(oe.Route,{key:g,path:`${r}/${g}`,render:p=>u(p,f)}));return t.createElement(zs.ErrorBoundary,{FallbackComponent:tu},t.createElement(Ir.Provider,{value:s},t.createElement(oe.Switch,null,t.createElement(oe.Route,{path:`${r}/configurations/list`},t.createElement(h.CheckPagePermissions,{permissions:Qo.collectionTypesConfigurations},t.createElement(eu,{layout:c,slug:e,updateLayout:a}))),t.createElement(oe.Route,{path:`${r}/configurations/edit`},t.createElement(h.CheckPagePermissions,{permissions:Qo.collectionTypesConfigurations},t.createElement(An,{components:l,isContentTypeView:!0,mainLayout:c,slug:e,updateLayout:a}))),m)))};Ko.propTypes={match:n().shape({url:n().string.isRequired,params:n().shape({slug:n().string.isRequired}).isRequired}).isRequired};var nu=(0,t.memo)(Ko),Yo=D(57678);const ru=qe.Z.contentManager,ou=()=>{const[{isLoading:e,data:r},o]=(0,t.useReducer)(Yo.Z,Yo.q),s=(0,t.useMemo)(Ft,[]),{schemas:a}=(0,le.useSelector)(d=>s(d),le.shallowEqual),{uid:c}=(0,oe.useParams)(),{get:l}=(0,h.useFetchClient)();return(0,t.useEffect)(()=>{const u=ye.Z.CancelToken.source();return(async g=>{try{o(ht());const{data:{data:f}}=await l(ce(`components/${c}/configuration`),{cancelToken:g.token});o(pn(ar(f,a,"component")))}catch(f){if(ye.Z.isCancel(f))return;console.error(f)}})(u),()=>{u.cancel("Operation canceled by the user.")}},[c,a,l]),e?t.createElement(h.LoadingIndicatorPage,null):t.createElement(h.CheckPagePermissions,{permissions:ru.componentsConfigurations},t.createElement(An,{components:r.components,mainLayout:r.component,slug:c}))};var su=(0,t.memo)(ou),au=()=>{const{formatMessage:e}=(0,Z.useIntl)();return(0,h.useFocusWhenNavigate)(),t.createElement(i.Main,null,t.createElement(i.HeaderLayout,{title:e({id:C("header.name"),defaultMessage:"Content"})}),t.createElement(i.ContentLayout,null,t.createElement(i.EmptyStateLayout,{action:t.createElement(h.LinkButton,{variant:"secondary",startIcon:t.createElement(L.Plus,null),to:"/plugins/content-type-builder/content-types/create-content-type"},e({id:"app.components.HomePage.create",defaultMessage:"Create your first Content-type"})),content:e({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:t.createElement(L.EmptyDocuments,{width:"10rem"}),shadow:"tableShadow"})))},iu=()=>{const{formatMessage:e}=(0,Z.useIntl)();return(0,h.useFocusWhenNavigate)(),t.createElement(i.Main,null,t.createElement(i.HeaderLayout,{title:e({id:C("header.name"),defaultMessage:"Content"})}),t.createElement(i.ContentLayout,null,t.createElement(h.NoPermissions,null)))};const lu=qe.Z.contentManager,Xo=({match:{params:{slug:e},url:r}})=>{const{isLoading:o,layout:s,updateLayout:a}=fr(e),{rawContentTypeLayout:c,rawComponentsLayouts:l}=(0,t.useMemo)(()=>{let d={},u={};return s.contentType&&(u=at(s.contentType)),s.components&&(d=Object.keys(s.components).reduce((m,g)=>(m[g]=at(s.components[g]),m),{})),{rawContentTypeLayout:u,rawComponentsLayouts:d}},[s]);return o?t.createElement(h.LoadingIndicatorPage,null):t.createElement(Ir.Provider,{value:s},t.createElement(oe.Switch,null,t.createElement(oe.Route,{path:`${r}/configurations/edit`},t.createElement(h.CheckPagePermissions,{permissions:lu.singleTypesConfigurations},t.createElement(An,{components:l,isContentTypeView:!0,mainLayout:c,slug:e,updateLayout:a}))),t.createElement(oe.Route,{path:r,render:({location:{state:d},history:{goBack:u}})=>t.createElement(Et,{layout:s,slug:e,isSingleType:!0,state:d,goBack:u})})))};Xo.propTypes={match:n().shape({url:n().string.isRequired,params:n().shape({slug:n().string.isRequired}).isRequired}).isRequired};var cu=(0,t.memo)(Xo),du=D(61590),uu=D(64669),mu=D(77013),pu=D(79318),gu=D(66618),fu=D(58469),hu=D(39935),Jo=D.n(hu),es=(e,r)=>r?(0,fu.ZP)(e,r.toLowerCase(),{keys:[o=>o.title.toLowerCase()]}):e.sort((o,s)=>{const a=Jo()(o.title),c=Jo()(s.title);return a<c?-1:a>c?1:0}),yu=()=>{const[e,r]=(0,t.useState)(""),{formatMessage:o}=(0,Z.useIntl)(),s=(0,t.useMemo)(xs,[]),{collectionTypeLinks:a,singleTypeLinks:c}=(0,le.useSelector)(y=>s(y),le.shallowEqual),l=y=>y.map(b=>({...b,title:o({id:b.title,defaultMessage:b.title})})),d=l(a),u=l(c),m=[{id:"collectionTypes",title:{id:C("components.LeftMenu.collection-types"),defaultMessage:"Collection Types"},searchable:!0,links:es(d,e)},{id:"singleTypes",title:{id:C("components.LeftMenu.single-types"),defaultMessage:"Single Types"},searchable:!0,links:es(u,e)}],g=()=>{r("")},f=({target:{value:y}})=>{r(y)},p=o({id:C("header.name"),defaultMessage:"Content"});return t.createElement(du.m,{ariaLabel:p},t.createElement(uu.p,{label:p,searchable:!0,value:e,onChange:f,onClear:g,searchLabel:o({id:"content-manager.components.LeftMenu.Search.label",defaultMessage:"Search for a content type"})}),t.createElement(mu.Z,null,m.map(y=>{const b=o({id:y.title.id,defaultMessage:y.title.defaultMessage},y.title.values);return t.createElement(pu.D,{key:y.id,label:b,badgeLabel:y.links.length.toString()},y.links.map(v=>{const I=v.search?`?${v.search}`:"";return t.createElement(gu.E,{as:oe.NavLink,key:v.uid,to:`${v.to}${I}`},v.title)}))})))},Un=D(92886);const bu=()=>({type:Un.ZA}),Eu=()=>({type:Un.c2}),Cu=(e,r,o,s)=>({type:Un.ix,data:{authorizedCtLinks:e,authorizedStLinks:r,components:s,contentTypeSchemas:o}}),ts=(e,r,o=[])=>e.filter(s=>s.isDisplayed).map(s=>{const a=[{action:"plugin::content-manager.explorer.create",subject:s.uid},{action:"plugin::content-manager.explorer.read",subject:s.uid}],c=[{action:"plugin::content-manager.explorer.read",subject:s.uid}],l=r==="collectionTypes"?a:c,d=o.find(({uid:m})=>m===s.uid);let u=null;if(d){const m={page:1,pageSize:d.settings.pageSize,sort:`${d.settings.defaultSortBy}:${d.settings.defaultSortOrder}`};u=(0,Me.stringify)(m,{encode:!1})}return{permissions:l,search:u,kind:s.kind,title:s.info.displayName,to:`/content-manager/${s.kind}/${s.uid}`,uid:s.uid,name:s.uid,isDisplayed:s.isDisplayed}});var Ru=(e,r)=>{const o=Object.entries(Ur()(e,"kind")).map(([c,l])=>({name:c,links:l})),[s,a]=Qn()(o,"name");return{collectionTypesSectionLinks:ts(s?.links||[],"collectionTypes",r),singleTypesSectionLinks:ts(a?.links??[],"singleTypes")}},ns=(e,r)=>r.map(({permissions:o})=>(0,h.hasPermissions)(e,o)),vu=async(e,r,o)=>{const{get:s}=(0,h.getFetchClient)();try{const{data:{data:a}}=await s(ce("content-types-settings")),{collectionTypesSectionLinks:c,singleTypesSectionLinks:l}=Ru(e,a),d=ns(r,c),u=await Promise.all(d),m=c.filter((y,b)=>u[b]),g=ns(r,l),f=await Promise.all(g),p=l.filter((y,b)=>f[b]);return{authorizedCtLinks:m,authorizedStLinks:p}}catch(a){return console.error(a),o({type:"warning",message:{id:"notification.error"}}),{authorizedCtLinks:[],authorizedStLinks:[],contentTypes:[]}}},Tu=()=>{const e=(0,le.useDispatch)(),r=(0,h.useNotification)(),o=(0,le.useSelector)(Ge()),s=(0,t.useRef)(),{allPermissions:a}=(0,h.useRBACProvider)(),{runHookWaterfall:c}=(0,h.useStrapiApp)(),d=ye.Z.CancelToken.source(),{notifyStatus:u}=(0,i.useNotifyAT)(),{formatMessage:m}=(0,Z.useIntl)(),{get:g}=(0,h.useFetchClient)(),f=async()=>{e(bu());try{const[{data:{data:p}},{data:{data:y}}]=await Promise.all(["components","content-types"].map(S=>g(ce(S),{cancelToken:d.token})));u(m({id:C("App.schemas.data-loaded"),defaultMessage:"The schemas have been successfully loaded."}));const{authorizedCtLinks:b,authorizedStLinks:v}=await vu(y,a,r),{ctLinks:I}=c(ct.LK,{ctLinks:b,models:y}),{stLinks:E}=c(ct.dV,{stLinks:v,models:y}),R=Cu(I,E,y,p);e(R)}catch(p){if(ye.Z.isCancel(p))return;console.error(p),r({type:"warning",message:{id:"notification.error"}})}};return s.current=f,(0,t.useEffect)(()=>(s.current(),()=>{d.cancel("Operation canceled by the user."),e(Eu())}),[e,r]),{...o,refetchData:s.current}};const Mu=qe.Z.contentManager,rs=()=>{const e=(0,oe.useRouteMatch)("/content-manager/:kind/:uid"),{status:r,collectionTypeLinks:o,singleTypeLinks:s,models:a,refetchData:c}=Tu(),l=Qn()([...o,...s],p=>p.title.toLowerCase()),{pathname:d}=(0,oe.useLocation)(),{formatMessage:u}=(0,Z.useIntl)(),{startSection:m}=(0,h.useGuidedTour)(),g=(0,t.useRef)(m);if((0,t.useEffect)(()=>{g.current&&g.current("contentManager")},[]),r==="loading")return t.createElement(i.Main,{"aria-busy":"true"},t.createElement(i.HeaderLayout,{title:u({id:C("header.name"),defaultMessage:"Content"})}),t.createElement(h.LoadingIndicatorPage,null));const f=a.filter(({isDisplayed:p})=>p);return l.length===0&&f.length>0&&d!=="/content-manager/403"?t.createElement(oe.Redirect,{to:"/content-manager/403"}):f.length===0&&d!=="/content-manager/no-content-types"?t.createElement(oe.Redirect,{to:"/content-manager/no-content-types"}):!e&&l.length>0?t.createElement(oe.Redirect,{to:`${l[0].to}${l[0].search?`?${l[0].search}`:""}`}):t.createElement(i.Layout,{sideNav:t.createElement(yu,null)},t.createElement(_s,null),t.createElement(kr.Provider,{value:{refetchData:c}},t.createElement(oe.Switch,null,t.createElement(oe.Route,{path:"/content-manager/components/:uid/configurations/edit"},t.createElement(h.CheckPagePermissions,{permissions:Mu.componentsConfigurations},t.createElement(su,null))),t.createElement(oe.Route,{path:"/content-manager/collectionType/:slug",component:nu}),t.createElement(oe.Route,{path:"/content-manager/singleType/:slug",component:cu}),t.createElement(oe.Route,{path:"/content-manager/403"},t.createElement(iu,null)),t.createElement(oe.Route,{path:"/content-manager/no-content-types"},t.createElement(au,null)),t.createElement(oe.Route,{path:"",component:h.NotFound}))))};function Du(){const{formatMessage:e}=(0,Z.useIntl)();return t.createElement(t.Fragment,null,t.createElement(os.Helmet,{title:e({id:C("plugin.name"),defaultMessage:"Content Manager"})}),t.createElement(rs,null))}},57544:function(){},59599:function(){},42310:function(){},33842:function(){},85695:function(){}}]);
|