@contentful/field-editor-reference 5.9.0 → 5.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/dist/cjs/__fixtures__/FakeSdk.js +183 -0
  2. package/dist/cjs/__fixtures__/asset/index.js +37 -0
  3. package/dist/cjs/__fixtures__/content-type/index.js +16 -0
  4. package/dist/cjs/__fixtures__/entry/index.js +33 -0
  5. package/dist/cjs/__fixtures__/fixtures.js +71 -0
  6. package/dist/cjs/__fixtures__/locale/index.js +40 -0
  7. package/dist/cjs/__fixtures__/space/index.js +16 -0
  8. package/dist/cjs/assets/MultipleMediaEditor.js +86 -0
  9. package/dist/cjs/assets/SingleMediaEditor.js +69 -0
  10. package/dist/cjs/assets/WrappedAssetCard/AssetCardActions.js +125 -0
  11. package/dist/cjs/assets/WrappedAssetCard/FetchingWrappedAssetCard.js +171 -0
  12. package/dist/cjs/assets/WrappedAssetCard/WrappedAssetCard.js +159 -0
  13. package/dist/cjs/assets/WrappedAssetCard/WrappedAssetLink.js +130 -0
  14. package/dist/cjs/assets/index.js +24 -0
  15. package/dist/cjs/common/EntityStore.js +420 -0
  16. package/dist/cjs/common/MultipleReferenceEditor.js +164 -0
  17. package/dist/cjs/common/ReferenceEditor.js +74 -0
  18. package/dist/cjs/common/SingleReferenceEditor.js +118 -0
  19. package/dist/cjs/common/SortableLinkList.js +95 -0
  20. package/dist/cjs/common/customCardTypes.js +44 -0
  21. package/dist/cjs/common/useAccessApi.js +19 -0
  22. package/dist/cjs/common/useContentTypePermissions.js +54 -0
  23. package/dist/cjs/common/useEditorPermissions.js +77 -0
  24. package/dist/cjs/common/useEditorPermissions.spec.js +205 -0
  25. package/dist/cjs/components/AssetThumbnail/AssetThumbnail.js +62 -0
  26. package/dist/cjs/components/CreateEntryLinkButton/CreateEntryLinkButton.js +102 -0
  27. package/dist/cjs/components/CreateEntryLinkButton/CreateEntryLinkButton.spec.js +254 -0
  28. package/dist/cjs/components/CreateEntryLinkButton/CreateEntryMenuTrigger.js +199 -0
  29. package/dist/cjs/components/CreateEntryLinkButton/CreateEntryMenuTrigger.spec.js +190 -0
  30. package/dist/cjs/components/CreateEntryLinkButton/useGlobalMouseUp.js +19 -0
  31. package/dist/cjs/components/LinkActions/CombinedLinkActions.js +167 -0
  32. package/dist/cjs/components/LinkActions/LinkActions.js +123 -0
  33. package/dist/cjs/components/LinkActions/LinkEntityActions.js +186 -0
  34. package/dist/cjs/components/LinkActions/NoLinkPermissionsInfo.js +54 -0
  35. package/dist/cjs/components/LinkActions/helpers.js +78 -0
  36. package/dist/cjs/components/LinkActions/redesignStyles.js +44 -0
  37. package/dist/cjs/components/LinkActions/styles.js +33 -0
  38. package/dist/cjs/components/MissingEntityCard/MissingEntityCard.js +75 -0
  39. package/dist/cjs/components/MissingEntityCard/styles.js +29 -0
  40. package/dist/cjs/components/ScheduledIconWithTooltip/ScheduleTooltip.js +75 -0
  41. package/dist/cjs/components/ScheduledIconWithTooltip/ScheduledIconWithTooltip.js +81 -0
  42. package/dist/cjs/components/ScheduledIconWithTooltip/formatDateAndTime.js +45 -0
  43. package/dist/cjs/components/SpaceName/SpaceName.js +91 -0
  44. package/dist/cjs/components/index.js +44 -0
  45. package/dist/cjs/entries/MultipleEntryReferenceEditor.js +86 -0
  46. package/dist/cjs/entries/SingleEntryReferenceEditor.js +74 -0
  47. package/dist/cjs/entries/WrappedEntryCard/FetchingWrappedEntryCard.js +189 -0
  48. package/dist/cjs/entries/WrappedEntryCard/WrappedEntryCard.js +181 -0
  49. package/dist/cjs/entries/index.js +24 -0
  50. package/dist/cjs/index.js +92 -0
  51. package/dist/cjs/resources/Cards/ContentfulEntryCard.js +87 -0
  52. package/dist/cjs/resources/Cards/ResourceCard.js +111 -0
  53. package/dist/cjs/resources/Cards/UnsupportedEntityCard.js +64 -0
  54. package/dist/cjs/resources/MultipleResourceReferenceEditor.js +157 -0
  55. package/dist/cjs/resources/MultipleResourceReferenceEditor.spec.js +297 -0
  56. package/dist/cjs/resources/SingleResourceReferenceEditor.js +87 -0
  57. package/dist/cjs/resources/SingleResourceReferenceEditor.spec.js +161 -0
  58. package/dist/cjs/resources/index.js +19 -0
  59. package/dist/cjs/resources/testHelpers/resourceEditorHelpers.js +121 -0
  60. package/dist/cjs/resources/useResourceLinkActions.js +88 -0
  61. package/dist/cjs/types.js +22 -0
  62. package/dist/cjs/utils/fromFieldValidations.js +54 -0
  63. package/dist/esm/__fixtures__/FakeSdk.js +173 -0
  64. package/dist/esm/__fixtures__/asset/index.js +6 -0
  65. package/dist/esm/__fixtures__/content-type/index.js +2 -0
  66. package/dist/esm/__fixtures__/entry/index.js +5 -0
  67. package/dist/esm/__fixtures__/fixtures.js +6 -0
  68. package/dist/esm/__fixtures__/locale/index.js +15 -0
  69. package/dist/esm/__fixtures__/space/index.js +2 -0
  70. package/dist/esm/assets/MultipleMediaEditor.js +37 -0
  71. package/dist/esm/assets/SingleMediaEditor.js +20 -0
  72. package/dist/esm/assets/WrappedAssetCard/AssetCardActions.js +63 -0
  73. package/dist/esm/assets/WrappedAssetCard/FetchingWrappedAssetCard.js +122 -0
  74. package/dist/esm/assets/WrappedAssetCard/WrappedAssetCard.js +105 -0
  75. package/dist/esm/assets/WrappedAssetCard/WrappedAssetLink.js +76 -0
  76. package/dist/esm/assets/index.js +3 -0
  77. package/dist/esm/common/EntityStore.js +347 -0
  78. package/dist/esm/common/MultipleReferenceEditor.js +111 -0
  79. package/dist/esm/common/ReferenceEditor.js +20 -0
  80. package/dist/esm/common/SingleReferenceEditor.js +70 -0
  81. package/dist/esm/common/SortableLinkList.js +41 -0
  82. package/dist/esm/common/customCardTypes.js +1 -0
  83. package/dist/esm/common/useAccessApi.js +9 -0
  84. package/dist/esm/common/useContentTypePermissions.js +44 -0
  85. package/dist/esm/common/useEditorPermissions.js +67 -0
  86. package/dist/esm/common/useEditorPermissions.spec.js +201 -0
  87. package/dist/esm/components/AssetThumbnail/AssetThumbnail.js +13 -0
  88. package/dist/esm/components/CreateEntryLinkButton/CreateEntryLinkButton.js +48 -0
  89. package/dist/esm/components/CreateEntryLinkButton/CreateEntryLinkButton.spec.js +206 -0
  90. package/dist/esm/components/CreateEntryLinkButton/CreateEntryMenuTrigger.js +145 -0
  91. package/dist/esm/components/CreateEntryLinkButton/CreateEntryMenuTrigger.spec.js +142 -0
  92. package/dist/esm/components/CreateEntryLinkButton/useGlobalMouseUp.js +9 -0
  93. package/dist/esm/components/LinkActions/CombinedLinkActions.js +118 -0
  94. package/dist/esm/components/LinkActions/LinkActions.js +66 -0
  95. package/dist/esm/components/LinkActions/LinkEntityActions.js +127 -0
  96. package/dist/esm/components/LinkActions/NoLinkPermissionsInfo.js +5 -0
  97. package/dist/esm/components/LinkActions/helpers.js +57 -0
  98. package/dist/esm/components/LinkActions/redesignStyles.js +18 -0
  99. package/dist/esm/components/LinkActions/styles.js +10 -0
  100. package/dist/esm/components/MissingEntityCard/MissingEntityCard.js +26 -0
  101. package/dist/esm/components/MissingEntityCard/styles.js +11 -0
  102. package/dist/esm/components/ScheduledIconWithTooltip/ScheduleTooltip.js +18 -0
  103. package/dist/esm/components/ScheduledIconWithTooltip/ScheduledIconWithTooltip.js +32 -0
  104. package/dist/esm/components/ScheduledIconWithTooltip/formatDateAndTime.js +19 -0
  105. package/dist/esm/components/SpaceName/SpaceName.js +37 -0
  106. package/dist/esm/components/index.js +8 -0
  107. package/dist/esm/entries/MultipleEntryReferenceEditor.js +37 -0
  108. package/dist/esm/entries/SingleEntryReferenceEditor.js +25 -0
  109. package/dist/esm/entries/WrappedEntryCard/FetchingWrappedEntryCard.js +135 -0
  110. package/dist/esm/entries/WrappedEntryCard/WrappedEntryCard.js +127 -0
  111. package/dist/esm/entries/index.js +3 -0
  112. package/dist/esm/index.js +7 -0
  113. package/dist/esm/resources/Cards/ContentfulEntryCard.js +38 -0
  114. package/dist/esm/resources/Cards/ResourceCard.js +62 -0
  115. package/dist/esm/resources/Cards/UnsupportedEntityCard.js +15 -0
  116. package/dist/esm/resources/MultipleResourceReferenceEditor.js +104 -0
  117. package/dist/esm/resources/MultipleResourceReferenceEditor.spec.js +254 -0
  118. package/dist/esm/resources/SingleResourceReferenceEditor.js +33 -0
  119. package/dist/esm/resources/SingleResourceReferenceEditor.spec.js +118 -0
  120. package/dist/esm/resources/index.js +2 -0
  121. package/dist/esm/resources/testHelpers/resourceEditorHelpers.js +103 -0
  122. package/dist/esm/resources/useResourceLinkActions.js +78 -0
  123. package/dist/esm/types.js +1 -0
  124. package/dist/esm/utils/fromFieldValidations.js +39 -0
  125. package/dist/{__fixtures__ → types/__fixtures__}/FakeSdk.d.ts +8 -8
  126. package/dist/{__fixtures__ → types/__fixtures__}/asset/index.d.ts +6 -6
  127. package/dist/{__fixtures__ → types/__fixtures__}/content-type/index.d.ts +2 -2
  128. package/dist/{__fixtures__ → types/__fixtures__}/entry/index.d.ts +5 -5
  129. package/dist/{__fixtures__ → types/__fixtures__}/fixtures.d.ts +6 -6
  130. package/dist/{__fixtures__ → types/__fixtures__}/locale/index.d.ts +42 -42
  131. package/dist/{__fixtures__ → types/__fixtures__}/space/index.d.ts +2 -2
  132. package/dist/{assets → types/assets}/MultipleMediaEditor.d.ts +10 -10
  133. package/dist/types/assets/SingleMediaEditor.d.ts +10 -0
  134. package/dist/{assets → types/assets}/WrappedAssetCard/AssetCardActions.d.ts +11 -11
  135. package/dist/{assets → types/assets}/WrappedAssetCard/FetchingWrappedAssetCard.d.ts +17 -17
  136. package/dist/{assets → types/assets}/WrappedAssetCard/WrappedAssetCard.d.ts +24 -24
  137. package/dist/{assets → types/assets}/WrappedAssetCard/WrappedAssetLink.d.ts +16 -16
  138. package/dist/{assets → types/assets}/index.d.ts +3 -3
  139. package/dist/{common → types/common}/EntityStore.d.ts +62 -62
  140. package/dist/{common → types/common}/MultipleReferenceEditor.d.ts +25 -25
  141. package/dist/{common → types/common}/ReferenceEditor.d.ts +46 -46
  142. package/dist/{common → types/common}/SingleReferenceEditor.d.ts +24 -24
  143. package/dist/{common → types/common}/SortableLinkList.d.ts +19 -19
  144. package/dist/{common → types/common}/customCardTypes.d.ts +29 -29
  145. package/dist/types/common/useAccessApi.d.ts +16 -0
  146. package/dist/{common → types/common}/useContentTypePermissions.d.ts +17 -17
  147. package/dist/{common → types/common}/useEditorPermissions.d.ts +17 -17
  148. package/dist/types/common/useEditorPermissions.spec.d.ts +1 -0
  149. package/dist/{components → types/components}/AssetThumbnail/AssetThumbnail.d.ts +7 -7
  150. package/dist/{components → types/components}/CreateEntryLinkButton/CreateEntryLinkButton.d.ts +19 -19
  151. package/dist/types/components/CreateEntryLinkButton/CreateEntryLinkButton.spec.d.ts +1 -0
  152. package/dist/{components → types/components}/CreateEntryLinkButton/CreateEntryMenuTrigger.d.ts +31 -31
  153. package/dist/types/components/CreateEntryLinkButton/CreateEntryMenuTrigger.spec.d.ts +1 -0
  154. package/dist/{components → types/components}/CreateEntryLinkButton/useGlobalMouseUp.d.ts +1 -1
  155. package/dist/{components → types/components}/LinkActions/CombinedLinkActions.d.ts +10 -10
  156. package/dist/{components → types/components}/LinkActions/LinkActions.d.ts +26 -26
  157. package/dist/{components → types/components}/LinkActions/LinkEntityActions.d.ts +24 -24
  158. package/dist/types/components/LinkActions/NoLinkPermissionsInfo.d.ts +2 -0
  159. package/dist/{components → types/components}/LinkActions/helpers.d.ts +26 -26
  160. package/dist/{components → types/components}/LinkActions/redesignStyles.d.ts +3 -3
  161. package/dist/{components → types/components}/LinkActions/styles.d.ts +2 -2
  162. package/dist/{components → types/components}/MissingEntityCard/MissingEntityCard.d.ts +8 -8
  163. package/dist/{components → types/components}/MissingEntityCard/styles.d.ts +2 -2
  164. package/dist/{components → types/components}/ScheduledIconWithTooltip/ScheduleTooltip.d.ts +11 -11
  165. package/dist/{components → types/components}/ScheduledIconWithTooltip/ScheduledIconWithTooltip.d.ts +10 -10
  166. package/dist/{components → types/components}/ScheduledIconWithTooltip/formatDateAndTime.d.ts +15 -15
  167. package/dist/types/components/SpaceName/SpaceName.d.ts +6 -0
  168. package/dist/{components → types/components}/index.d.ts +9 -9
  169. package/dist/{entries → types/entries}/MultipleEntryReferenceEditor.d.ts +3 -3
  170. package/dist/{entries → types/entries}/SingleEntryReferenceEditor.d.ts +8 -8
  171. package/dist/{entries → types/entries}/WrappedEntryCard/FetchingWrappedEntryCard.d.ts +18 -18
  172. package/dist/{entries → types/entries}/WrappedEntryCard/WrappedEntryCard.d.ts +35 -35
  173. package/dist/{entries → types/entries}/index.d.ts +3 -3
  174. package/dist/{index.d.ts → types/index.d.ts} +9 -8
  175. package/dist/{resources → types/resources}/Cards/ContentfulEntryCard.d.ts +21 -21
  176. package/dist/{resources → types/resources}/Cards/ResourceCard.d.ts +12 -12
  177. package/dist/{resources → types/resources}/Cards/UnsupportedEntityCard.d.ts +4 -4
  178. package/dist/{resources → types/resources}/MultipleResourceReferenceEditor.d.ts +7 -7
  179. package/dist/types/resources/MultipleResourceReferenceEditor.spec.d.ts +1 -0
  180. package/dist/{resources → types/resources}/SingleResourceReferenceEditor.d.ts +7 -7
  181. package/dist/types/resources/SingleResourceReferenceEditor.spec.d.ts +1 -0
  182. package/dist/{resources → types/resources}/index.d.ts +2 -2
  183. package/dist/{resources → types/resources}/testHelpers/resourceEditorHelpers.d.ts +50 -50
  184. package/dist/{resources → types/resources}/useResourceLinkActions.d.ts +7 -7
  185. package/dist/{types.d.ts → types/types.d.ts} +104 -104
  186. package/dist/{utils → types/utils}/fromFieldValidations.d.ts +21 -21
  187. package/package.json +25 -11
  188. package/CHANGELOG.md +0 -860
  189. package/dist/assets/SingleMediaEditor.d.ts +0 -10
  190. package/dist/common/useAccessApi.d.ts +0 -16
  191. package/dist/components/LinkActions/NoLinkPermissionsInfo.d.ts +0 -2
  192. package/dist/components/SpaceName/SpaceName.d.ts +0 -6
  193. package/dist/field-editor-reference.cjs.development.js +0 -2753
  194. package/dist/field-editor-reference.cjs.development.js.map +0 -1
  195. package/dist/field-editor-reference.cjs.production.min.js +0 -2
  196. package/dist/field-editor-reference.cjs.production.min.js.map +0 -1
  197. package/dist/field-editor-reference.esm.js +0 -2727
  198. package/dist/field-editor-reference.esm.js.map +0 -1
  199. package/dist/index.js +0 -8
@@ -1,2 +0,0 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),i=require("@contentful/f36-components"),s=require("@contentful/f36-icons"),a=e(require("@contentful/f36-tokens")),o=require("emotion"),r=e(require("lodash/get")),l=e(require("moment")),c=require("@contentful/field-editor-shared"),d=e(require("deep-equal")),u=require("@tanstack/react-query"),m=e(require("constate")),y=require("contentful-management"),p=e(require("p-queue")),E=e(require("lodash/isNumber")),f=e(require("array-move")),g=require("react-sortable-hoc"),v=e(require("@contentful/mimetype")),C=require("react-intersection-observer");const k={"bottom-left":"bottom-start","bottom-right":"bottom-end"},h={wrapper:o.css({position:"relative"}),inputWrapper:o.css({position:"relative",padding:"0 "+a.spacing2Xs}),searchInput:o.css({paddingRight:a.spacingXl,textOverflow:"ellipsis"}),searchIcon:o.css({position:"absolute",right:a.spacingM,top:a.spacingS,zIndex:Number(a.zIndexDefault),fill:a.gray600}),separator:o.css({background:a.gray200,margin:"10px 0"}),dropdownList:o.css({borderColor:a.gray200})},b=({contentTypes:e,suggestedContentTypeId:a,contentTypesLabel:o,onSelect:l,testId:c,dropdownSettings:d={position:"bottom-left"},customDropdownItems:u,children:m})=>{const[y,p]=t.useState(!1),[E,f]=t.useState(!1),[g,v]=t.useState(""),C=t.useRef(null),b=t.useRef(null),I=t.useRef(null),[T,A]=t.useState(),x=e.length>1||!!u,D=()=>p(!1);t.useEffect(()=>{y&&setTimeout(()=>{var e,t;null==(e=b.current)||null==(t=e.querySelector("input"))||t.focus({preventScroll:!0})},200)},[y]),t.useEffect(()=>{var e;y&&!T&&A(null==(e=I.current)?void 0:e.clientWidth)},[y,T]);const M=e=>{D();const t=l(e.sys.id);t&&"function"==typeof t.then&&(f(!0),t.then(()=>f(!1),()=>f(!1)))};t.useEffect(()=>{y||v("")},[y]);const L=e.length>5,w=a?300:250,S=e.find(e=>e.sys.id===a),R=e.filter(e=>!g||r(e,"name","Untitled").toLowerCase().includes(g.toLowerCase()));return n.createElement("span",{className:h.wrapper,ref:C,"data-test-id":c},n.createElement(i.Menu,{placement:k[d.position],isAutoalignmentEnabled:d.isAutoalignmentEnabled,isOpen:y,onClose:D,onOpen:()=>{x?p(!0):M(e[0])}},n.createElement(i.Menu.Trigger,null,m({isOpen:y,isSelecting:E})),y&&n.createElement(i.Menu.List,{className:h.dropdownList,style:{width:null!=T?T+"px":void 0,maxHeight:w+"px"},ref:I,testId:"add-entry-menu"},Boolean(u)&&n.createElement(n.Fragment,null,u,n.createElement(i.Menu.Divider,null)),L&&n.createElement(n.Fragment,null,n.createElement("div",{ref:b,className:h.inputWrapper},n.createElement(i.TextInput,{className:h.searchInput,placeholder:"Search all content types",testId:"add-entry-menu-search",value:g,onChange:e=>v(e.target.value)}),n.createElement(s.SearchIcon,{className:h.searchIcon})),n.createElement(i.Menu.Divider,null)),g&&((N=R.length)?n.createElement(i.Menu.SectionTitle,{testId:"add-entru-menu-search-results"},N," result",N>1?"s":""):null),S&&!g&&n.createElement(n.Fragment,null,n.createElement(i.Menu.SectionTitle,null,"Suggested Content Type"),n.createElement(i.Menu.Item,{testId:"suggested",onClick:()=>M(S)},r(S,"name")),n.createElement(i.Menu.Divider,null)),!g&&n.createElement(i.Menu.SectionTitle,null,o),R.length?R.map((e,t)=>n.createElement(i.Menu.Item,{testId:"contentType",key:`${r(e,"name")}-${t}`,onClick:()=>M(e)},r(e,"name","Untitled"))):n.createElement(i.Menu.Item,{testId:"add-entru-menu-search-results"},"No results found"))));var N};b.defaultProps={testId:"create-entry-button-menu-trigger",contentTypesLabel:"All Content Types"};const I={spinnerMargin:o.css({marginRight:a.spacingXs}),action:void 0},T={...I,action:o.css({textDecoration:"none",fontWeight:"bold",maxWidth:"300px"})},A=({contentTypes:e,onSelect:t,customDropdownItems:a,text:o,testId:l,hasPlusIcon:c=!1,useExperimentalStyles:d,suggestedContentTypeId:u,dropdownSettings:m,disabled:y=!1})=>{const p=(e=e.sort((e,t)=>e.name.localeCompare(t.name))).find(e=>e.sys.id===u),E=o||"Add "+r(p||(1===e.length?e[0]:{}),"name","entry"),f=e.length>1||a,g=c?n.createElement(s.PlusIcon,null):void 0,v=d?T:I;return n.createElement(b,{contentTypes:e,suggestedContentTypeId:u,contentTypesLabel:d?"New content":void 0,onSelect:t,testId:l,dropdownSettings:m,customDropdownItems:a},({isSelecting:e})=>n.createElement(i.Button,{endIcon:f?n.createElement(s.ChevronDownIcon,null):void 0,variant:"secondary",className:v.action,isDisabled:y||e,startIcon:e?void 0:g,size:"small",testId:"create-entry-link-button",isLoading:e},E))};function x(){return n.createElement(i.Paragraph,null,"You don't have permission to view this content or this field is not correctly configured. Contact your administrator for help.")}const D=o.css({display:"flex",width:"100%",marginTop:a.spacingS}),M=o.css({marginRight:a.spacingXl}),L={createNew:e=>null!=e&&e.contentType?`Create new ${e.contentType} and link`:"Create new entry and link",linkExisting:e=>null!=e&&e.canLinkMultiple?"Link existing entries":"Link existing entry"},w={createNew:()=>"Create new asset and link",linkExisting:e=>null!=e&&e.canLinkMultiple?"Link existing assets":"Link existing asset"},S={dropdown:"linkEditor.dropdown",createAndLink:"linkEditor.createAndLink",createAndLinkWrapper:"create-entry-button-menu-trigger",linkExisting:"linkEditor.linkExisting"};function R(e){if(e.isFull)return null;const n={..."Entry"===e.entityType?L:w,...e.actionLabels};return t.createElement("div",{className:D},e.canCreateEntity&&t.createElement(t.Fragment,null,"Entry"===e.entityType&&t.createElement(A,{testId:S.createAndLink,disabled:e.isDisabled,text:n.createNew({contentType:1===e.contentTypes.length?e.contentTypes[0].name:void 0}),contentTypes:e.contentTypes,hasPlusIcon:!0,onSelect:t=>t?e.onCreate(t,e.itemsLength):Promise.resolve()}),"Asset"===e.entityType&&t.createElement(i.Button,{isDisabled:e.isDisabled,testId:S.createAndLink,onClick:()=>{e.onCreate(void 0,e.itemsLength)},variant:"secondary",startIcon:t.createElement(s.PlusIcon,null),size:"small"},n.createNew()),t.createElement("span",{className:M})),e.canLinkEntity&&t.createElement(i.Button,{isDisabled:e.isDisabled,testId:S.linkExisting,onClick:()=>{e.onLinkExisting()},variant:"secondary",startIcon:t.createElement(s.LinkIcon,null),size:"small"},n.linkExisting({canLinkMultiple:e.canLinkMultiple})),!e.canCreateEntity&&!e.canLinkEntity&&t.createElement(x,null))}const N=o.css({display:"flex",border:"1px dashed "+a.gray500,borderRadius:a.borderRadiusMedium,justifyContent:"center",padding:a.spacingXl}),H=o.css({textDecoration:"none",fontWeight:"bold"}),P={...S,actionsWrapper:"link-actions-menu-trigger"};function q(e){return e.isFull?null:t.createElement("div",{className:"Asset"!==e.entityType||e.isEmpty?N:""},!e.canCreateEntity&&!e.canLinkEntity&&t.createElement(x,null),"Entry"===e.entityType&&t.createElement(B,{...e}),"Asset"===e.entityType&&t.createElement(z,{...e}))}function B(e){return e.canCreateEntity?t.createElement(A,{testId:P.actionsWrapper,disabled:e.isDisabled,text:e.combinedActionsLabel||"Add content",contentTypes:e.contentTypes,hasPlusIcon:!0,useExperimentalStyles:!0,dropdownSettings:{position:"bottom-left"},onSelect:t=>t?e.onCreate(t):Promise.resolve(),customDropdownItems:e.canLinkEntity?t.createElement(i.Menu.Item,{testId:P.linkExisting,onClick:()=>{e.onLinkExisting()}},"Add existing content"):void 0}):e.canLinkEntity?t.createElement(i.Button,{isDisabled:e.isDisabled,testId:P.linkExisting,className:H,onClick:()=>{e.onLinkExisting()},variant:"secondary",startIcon:t.createElement(s.LinkIcon,null),size:"small"},"Add existing content"):null}function z(e){const[n,a]=t.useState(!1);return e.canLinkEntity&&e.canCreateEntity?t.createElement(i.Menu,{isOpen:n,onClose:()=>{a(!1)},onOpen:()=>{a(!0)}},t.createElement(i.Menu.Trigger,null,t.createElement(i.Button,{endIcon:t.createElement(s.ChevronDownIcon,null),isDisabled:e.isDisabled,testId:P.actionsWrapper,className:H,variant:"secondary",startIcon:t.createElement(s.PlusIcon,null),size:"small"},"Add media")),n&&t.createElement(i.Menu.List,{testId:P.dropdown},t.createElement(i.Menu.Item,{testId:P.linkExisting,onClick:()=>{e.onLinkExisting()}},"Add existing media"),t.createElement(i.Menu.Item,{testId:P.createAndLink,onClick:()=>{e.onCreate()}},"Add new media"))):e.canLinkEntity?t.createElement(i.Button,{isDisabled:e.isDisabled,testId:P.linkExisting,className:H,onClick:()=>{e.onLinkExisting()},variant:"secondary",startIcon:t.createElement(s.PlusIcon,null),size:"small"},"Add existing media"):e.canCreateEntity?t.createElement(i.Button,{isDisabled:e.isDisabled,testId:P.createAndLink,className:H,onClick:()=>{e.onCreate()},variant:"secondary",startIcon:t.createElement(s.PlusIcon,null),size:"small"},"Add media"):null}const U=o.css({position:"relative"}),F=o.css({display:"flex",alignItems:"center",width:"135px",height:"160px",textAlign:"center"});function O(e){return n.createElement(i.Card,{className:U,testId:"cf-ui-missing-entry-card"},n.createElement(i.Flex,{alignItems:"center",justifyContent:"space-between"},n.createElement("div",{className:e.asSquare?F:""},n.createElement(i.SectionHeading,{marginBottom:"none"},e.entityType," is missing or inaccessible")),!e.isDisabled&&e.onRemove&&n.createElement(i.IconButton,{variant:"transparent",icon:n.createElement(s.CloseIcon,{variant:"muted"}),"aria-label":"Delete",onClick:()=>{e.onRemove&&e.onRemove()}})))}const V=e=>e.map(e=>e.sys.id);function $(e){var n;const{sdk:i,editorPermissions:s,entityType:a,canLinkMultiple:o,isDisabled:r,actionLabels:l,itemsLength:c}=e,d=null==(n=s.validations.numberOfLinks)?void 0:n.max,u=i.field.getValue(),m=Array.isArray(u)?u.length:u?1:0,y=!!d&&d<=m,p=0===m,E=t.useCallback((t,n=c,i)=>{e.onCreate(t.sys.id,n),e.onAction&&e.onAction({type:"create_and_link",entity:a,entityData:t,slide:i,index:n})},[a,e.onCreate,e.onAction]),f=t.useCallback((t,n=c)=>{e.onLink(t.map(e=>e.sys.id),n),t.forEach((t,i)=>{e.onAction&&e.onAction({type:"select_and_link",entity:a,entityData:t,index:void 0===n?void 0:n+i})})},[a,e.onLink,e.onAction]),g=t.useCallback(async(e,t)=>{const{entity:n,slide:s}=await async function(e){if("Entry"===e.entityType){if(!e.contentTypeId)return{};const{entity:t,slide:n}=await e.sdk.navigator.openNewEntry(e.contentTypeId,{slideIn:!0});return{entity:t,slide:n}}{const{entity:t,slide:n}=await e.sdk.navigator.openNewAsset({slideIn:!0});return{entity:t,slide:n}}}({sdk:i,entityType:a,contentTypeId:e});n&&E(n,t,s)},[i,a,E]),v=t.useCallback(async e=>{const t=await async function(e){return"Entry"===e.entityType?await e.sdk.dialogs.selectSingleEntry({locale:e.sdk.field.locale,contentTypes:V(e.editorPermissions.readableContentTypes)}):e.sdk.dialogs.selectSingleAsset({locale:e.sdk.field.locale,mimetypeGroups:e.editorPermissions.validations.mimetypeGroups})}({sdk:i,entityType:a,editorPermissions:s});t&&f([t],e)},[i,a,f]),C=t.useCallback(async e=>{const t=await async function(e){var t,n;const i=e.sdk.field.getValue(),s=Array.isArray(i)?i.length:i?1:0,a=Math.max(((null==(t=e.editorPermissions.validations.numberOfLinks)?void 0:t.min)||1)-s,1),o=((null==(n=e.editorPermissions.validations.numberOfLinks)?void 0:n.max)||Infinity)-s;return"Entry"===e.entityType?await e.sdk.dialogs.selectMultipleEntries({locale:e.sdk.field.locale,contentTypes:V(e.editorPermissions.readableContentTypes),min:a,max:o}):e.sdk.dialogs.selectMultipleAssets({locale:e.sdk.field.locale,mimetypeGroups:e.editorPermissions.validations.mimetypeGroups,min:a,max:o})}({sdk:i,entityType:a,editorPermissions:s});t&&0!==t.length&&f(t,e)},[i,a,f]);return t.useMemo(()=>({entityType:a,canLinkMultiple:o,isDisabled:r,isEmpty:p,isFull:y,canCreateEntity:s.canCreateEntity,canLinkEntity:s.canLinkEntity,contentTypes:s.creatableContentTypes,onCreate:g,onLinkExisting:o?C:v,actionLabels:l,onCreated:E,onLinkedExisting:f,itemsLength:c}),[a,o,r,p,y,s.canCreateEntity,s.canLinkEntity,l,s.creatableContentTypes.map(e=>e.sys.id).join(":"),g,v,C,E,f,c])}function W({renderCustomActions:e,...n}){return e?e(n):t.createElement(R,{...n})}function Y({renderCustomActions:e,...n}){return e?e(n):t.createElement(q,{...n})}const j=({job:e,jobsCount:t})=>{return`Will ${e.action.toLowerCase()} ${(n=e.scheduledFor.datetime,`${((e,t)=>{switch(l().startOf("day").diff(l(e).startOf("day"),"days")){case 0:return"Today, "+l(e).format("DD MMM YYYY");case-1:return"Tomorrow, "+l(e).format("DD MMM YYYY");case 1:return"Yesterday, "+l(e).format("DD MMM YYYY");default:return l(e).format("ddd, DD MMM YYYY")}})(n)} at ${(e=>l.utc(e).local().format("h:mm A"))(n)}`).toLowerCase()}\n ${t>1?`+ ${t-1} more`:""}`;var n},Q=({job:e,jobsCount:t,children:s})=>n.createElement(i.Tooltip,{placement:"top",testId:e.sys.id,as:"div",content:j({job:e,jobsCount:t})},s),_=({entityType:e,entityId:t,getEntityScheduledActions:i,children:s})=>{const[a,o]=n.useState({type:"loading"});if(n.useEffect(()=>{i(e,t).then(e=>{o({type:"loaded",jobs:e})}).catch(e=>{o({type:"error",error:e})})},[]),"loading"===a.type||"error"===a.type)return null;const r=a.jobs??[];return 0===r.length?null:n.createElement(Q,{job:r[0],jobsCount:r.length},s)};function X(e){return n.createElement("img",{alt:e.file.fileName,src:e.file.url+"?w=70&h=70&fit=thumb",height:70,width:70})}const G=new p({concurrency:50});class K extends Error{constructor(e){super(e),this.isUnsupportedError=void 0,this.isUnsupportedError=!0}}const[J,Z,ee,te]=m((function(e){const n=e.sdk.ids.space,i=e.sdk.ids.environmentAlias??e.sdk.ids.environment,s=t.useMemo(()=>[e.sdk.ids.environmentAlias,e.sdk.ids.environment],[e.sdk.ids.environmentAlias,e.sdk.ids.environment]),a=u.useQueryClient(),o=a.getQueryCache(),r=t.useRef({}),l=t.useMemo(()=>y.createClient({apiAdapter:e.sdk.cmaAdapter},{type:"plain"}),[e.sdk.cmaAdapter]),c=t.useMemo(()=>e.queryConcurrency?new p({concurrency:e.queryConcurrency}):G,[e.queryConcurrency]),d=t.useCallback((function(e,t,n={}){const{priority:i,...s}=n;return a.fetchQuery(e,()=>c.add(()=>t({cmaClient:l}),{priority:i}),s)}),[a,c,l]),m=t.useCallback((function(e,t,s){const a=(null==s?void 0:s.spaceId)??n,o=(null==s?void 0:s.environmentId)??i;return d([e,t,a,o],({cmaClient:n})=>{if("Entry"===e)return n.entry.get({entryId:t,spaceId:a,environmentId:o});if("Asset"===e)return n.asset.get({assetId:t,spaceId:a,environmentId:o});throw new K("Unsupported entity type")},s)}),[d,n,i]),E=t.useCallback((function(e,t,s){const a=(null==s?void 0:s.spaceId)??n,o=(null==s?void 0:s.environmentId)??i;return d(["scheduled-actions",e,"scheduledActionEntityId",a,o],async({cmaClient:e})=>(await e.scheduledActions.getMany({spaceId:a,query:{"environment.sys.id":o,"sys.status[in]":"scheduled",order:"scheduledFor.datetime",limit:500}})).items,s).then(e=>e.filter(e=>e.entity.sys.id===t))}),[d,n,i]),f=t.useCallback((function(e,t,n){return d(["Resource",e,t],()=>{if("Contentful:Entry"===e)return async function(e){const{urn:t,fetch:n,options:i}=e,s=t.split(":",6)[5],[,a,,o]=s.split("/"),[r,l]=await Promise.all([n(["space",a],({cmaClient:e})=>e.space.get({spaceId:a}),i),n(["entry",a,"master",o],({cmaClient:e})=>e.entry.get({spaceId:a,environmentId:"master",entryId:o}),i)]),c=l.sys.contentType.sys.id,[d,u]=await Promise.all([n(["contentType",a,"master",c],({cmaClient:e})=>e.contentType.get({contentTypeId:c,spaceId:a,environmentId:"master"}),i),n(["defaultLocale",a,"master"],async({cmaClient:e})=>{var t;return null==(t=(await e.locale.getMany({spaceId:a,environmentId:"master",query:{limit:100}})).items.find(e=>e.default))?void 0:t.code},i)]);return{defaultLocaleCode:u,resource:l,space:r,contentType:d}}({fetch:d,urn:t,options:n});throw new K("Unsupported resource type")},n)}),[d]),g=t.useCallback(e=>(e=>Array.isArray(e)&&("Entry"===e[0]||"Asset"===e[0])&&4===e.length)(e)&&e[2]===n&&s.includes(e[3]),[n,s]),v=e.sdk.space.onEntityChanged,C=e.sdk.navigator.onSlideInNavigation;return t.useEffect(()=>{function e(){return o.findAll({type:"active",predicate:e=>g(e.queryKey)})}if("function"!=typeof v)return C(({oldSlideLevel:t,newSlideLevel:n})=>{t>n&&e().forEach(e=>{a.invalidateQueries(e.queryKey)})});const t=({queryKey:e,queryHash:t})=>{const[n,i]=e;r.current[t]=v(n,i,t=>{a.setQueryData(e,t)})};e().forEach(t);const n=o.subscribe(e=>{if(!e)return;const{type:n,query:i}=e,{queryKey:s,queryHash:a}=i;var o,l;g(s)&&("added"===n&&t(i),"removed"===n&&(null==(o=(l=r.current)[a])||o.call(l)))});return()=>{n(),Object.values(r.current).forEach(e=>e()),r.current={}}},[v,o,g,a,m,C]),{ids:e.sdk.ids,cmaClient:l,fetch:d,getResource:f,getEntity:m,getEntityScheduledActions:E}}),({fetch:e})=>e,({getResource:e,getEntity:t,getEntityScheduledActions:n})=>({getResource:e,getEntity:t,getEntityScheduledActions:n}),({ids:e})=>({environment:e.environmentAlias??e.environment,space:e.space}));function ne(e,t,n){const{space:i,environment:s}=te(),{getEntity:a}=ee(),o=[e,t,(null==n?void 0:n.spaceId)??i,(null==n?void 0:n.environmentId)??s],{status:r,data:l}=u.useQuery(o,()=>a(e,t,n),{enabled:null==n?void 0:n.enabled});return{status:r,data:l}}function ie(e,t,n){const i=["Resource",e,t],{getResource:s}=ee(),{status:a,data:o,error:r}=u.useQuery(i,()=>s(e,t,n),{enabled:null==n?void 0:n.enabled});return{status:a,data:o,error:r}}function se({children:e,...i}){const s=t.useMemo(()=>{const e=new u.QueryCache;return new u.QueryClient({queryCache:e,defaultOptions:{queries:{useErrorBoundary:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!0,refetchOnMount:!1,staleTime:Infinity,retry:!1}}})},[]);return n.createElement(u.QueryClientProvider,{client:s},n.createElement(J,{...i},e))}function ae(e){return t.createElement(se,{sdk:e.sdk},t.createElement(c.FieldConnector,{throttle:0,field:e.sdk.field,isInitiallyDisabled:e.isInitiallyDisabled,isEqualValues:(e,t)=>d(e,t)},e.children))}ae.defaultProps={isInitiallyDisabled:!0,hasCardEditActions:!0};const oe=()=>Promise.resolve(!0);function re(e){return{canPerformAction:e.can,canPerformActionOnEntryOfType:e.canPerformActionOnEntryOfType??oe}}function le(e){const{sdk:n,entityType:i,parameters:s}=e,a=t.useMemo(()=>function(e){var t;const n=[...e.validations,...(null==(t=e.items)?void 0:t.validations)??[]],i=n.find(e=>"linkContentType"in e),s=n.find(e=>"linkMimetypeGroup"in e),a=n.find(e=>"size"in e),o=a&&a.size||{},r=o.min,l=o.max;let c=void 0;return E(r)&&E(l)?c={type:"min-max",min:r,max:l}:E(r)?c={type:"min",min:r,max:void 0}:E(l)&&(c={type:"max",max:l,min:void 0}),{contentTypes:(null==i?void 0:i.linkContentType)??void 0,mimetypeGroups:(null==s?void 0:s.linkMimetypeGroup)??void 0,numberOfLinks:c}}(e.sdk.field),[e.sdk.field]),[o,r]=t.useState(!0),[l,c]=t.useState(!0),{creatableContentTypes:d,readableContentTypes:u,availableContentTypes:m}=function(e){const n=t.useMemo(()=>"Asset"===e.entityType?[]:e.validations.contentTypes?e.allContentTypes.filter(t=>{var n;return null==(n=e.validations.contentTypes)?void 0:n.includes(t.sys.id)}):e.allContentTypes,[e.allContentTypes,e.validations.contentTypes,e.entityType]),[i,s]=t.useState(n),[a,o]=t.useState(n),{canPerformActionOnEntryOfType:r}=re(e.sdk.access);return t.useEffect(()=>{function e(e){return async function(t,n){const i=Symbol();return(await Promise.all(t.map(async t=>{return await(n=t,r(e,n.sys.id))?t:i;var n}))).filter(e=>e!==i)}(n)}!async function(){const t=await e("create"),n=await e("read");s(t),o(n)}()},[n]),{creatableContentTypes:i,readableContentTypes:a,availableContentTypes:n}}({...e,validations:a}),{canPerformAction:y}=re(n.access);return t.useEffect(()=>{!1!==s.instance.showCreateEntityAction?async function(){if("Asset"===i){const e=await y("create","Asset")||!0;r(e)}"Entry"===i&&r(d.length>0||!0)}():r(!1)},[i,s.instance,d]),t.useEffect(()=>{!1!==s.instance.showLinkEntityAction?async function(){if("Asset"===i){const e=await y("read","Asset")||!0;c(e)}"Entry"===i&&c(!0)}():c(!1)},[i,s.instance,u]),{canCreateEntity:o,canLinkEntity:l,creatableContentTypes:d,readableContentTypes:u,availableContentTypes:m,validations:a}}function ce(e){const{setValue:n,entityType:i}=e,s=le(e),a=t.useCallback(e=>{n({sys:{type:"Link",linkType:i,id:e}})},[n,i]),o=t.useCallback(e=>{const[t]=e;n({sys:{type:"Link",linkType:i,id:t}})},[n,i]),r=$({...e,canLinkMultiple:!1,editorPermissions:s,onCreate:a,onLink:o}),l=t.useCallback((t,n,i)=>!!e.renderCustomCard&&e.renderCustomCard(t,r,i),[r]);return e.entityId?e.children({...e,renderCustomCard:e.renderCustomCard&&l}):t.createElement(W,{renderCustomActions:e.renderCustomActions,...r})}function de(e){const n=e.sdk.space.getCachedContentTypes();return t.createElement(ae,{...e},({value:i,setValue:s,disabled:a,externalReset:o})=>t.createElement(ce,{...e,key:o+"-reference",entityId:i?i.sys.id:"",isDisabled:a,setValue:s,allContentTypes:n}))}de.defaultProps={hasCardEditActions:!0,hasCardRemoveActions:!0};const ue={spaceIcon:o.css({flexShrink:0,fill:a.purple600}),spaceName:o.css({color:a.gray700,fontSize:a.fontSizeS,fontWeight:a.fontWeightDemiBold,maxWidth:"80px",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"})};function me(e){return t.createElement(i.Tooltip,{placement:"top",as:"div",content:"Space: "+e.spaceName},t.createElement(i.Flex,{alignItems:"center",gap:"spacingXs",marginRight:"spacingS"},t.createElement(s.FolderOpenTrimmedIcon,{className:ue.spaceIcon,size:"tiny","aria-label":"Source space"}),t.createElement(i.Text,{className:ue.spaceName},e.spaceName)))}const{getEntryTitle:ye,getEntityDescription:pe,getEntryStatus:Ee,getEntryImage:fe}=c.entityHelpers,ge={scheduleIcon:o.css({marginRight:a.spacing2Xs})};function ve(e){var n;const[a,o]=t.useState(null),{contentType:r}=e;t.useEffect(()=>{e.entry&&fe({entry:e.entry,contentType:r,localeCode:e.localeCode,defaultLocaleCode:e.defaultLocaleCode},e.getAsset).then(e=>{o(e)}).catch(()=>{o(null)})},[e.entry,e.getAsset,r,e.localeCode,e.defaultLocaleCode]);const l=Ee(null==(n=e.entry)?void 0:n.sys);if("deleted"===l)return t.createElement(O,{entityType:"Entry",isDisabled:e.isDisabled,onRemove:e.onRemove});const d=ye({entry:e.entry,contentType:r,localeCode:e.localeCode,defaultLocaleCode:e.defaultLocaleCode,defaultTitle:"Untitled"}),u=pe({entity:e.entry,contentType:r,localeCode:e.localeCode,defaultLocaleCode:e.defaultLocaleCode});return t.createElement(i.EntryCard,{as:e.entryUrl?"a":"article",href:e.entryUrl,title:d,description:u,contentType:null==r?void 0:r.name,size:e.size,isSelected:e.isSelected,status:l,icon:e.spaceName?t.createElement(me,{spaceName:e.spaceName}):t.createElement(_,{getEntityScheduledActions:e.getEntityScheduledActions,entityType:"Entry",entityId:e.entry.sys.id},t.createElement(s.ClockIcon,{className:ge.scheduleIcon,size:"small",variant:"muted",testId:"schedule-icon"})),thumbnailElement:a&&c.isValidImage(a)?t.createElement(X,{file:a}):void 0,dragHandleRender:e.renderDragHandle,withDragHandle:!!e.renderDragHandle,actions:e.onEdit||e.onRemove?[e.hasCardEditActions&&e.onEdit?t.createElement(i.MenuItem,{key:"edit",testId:"edit",onClick:()=>{e.onEdit&&e.onEdit()}},"Edit"):null,e.hasCardRemoveActions&&e.onRemove?t.createElement(i.MenuItem,{key:"delete",testId:"delete",onClick:()=>{e.onRemove&&e.onRemove()}},"Remove"):null,e.hasCardMoveActions&&(e.onMoveTop||e.onMoveBottom)?t.createElement(i.MenuDivider,{key:"divider"}):null,e.hasCardMoveActions&&e.onMoveTop?t.createElement(i.MenuItem,{key:"move-top",onClick:()=>e.onMoveTop&&e.onMoveTop(),testId:"move-top"},"Move to top"):null,e.hasCardMoveActions&&e.onMoveBottom?t.createElement(i.MenuItem,{key:"move-bottom",onClick:()=>e.onMoveBottom&&e.onMoveBottom(),testId:"move-bottom"},"Move to bottom"):null].filter(e=>e):[],onClick:e.isClickable?t=>{if(t.preventDefault(),e.onClick)return e.onClick(t);e.onEdit&&e.onEdit()}:void 0})}function Ce(e){const{data:n,status:s}=ne("Entry",e.entryId),{getEntityScheduledActions:a}=ee(),o=t.useCallback(()=>a("Entry",e.entryId),[a,e.entryId]),l="link"===e.viewType?"small":"default",{getEntity:c}=ee(),d=e=>c("Asset",e),u=async()=>{const t=await async function(e,t,n){let i;if(n.bulkEditing)try{return i=(await e.navigator.openBulkEditor(e.entry.getSys().id,{fieldId:e.field.id,locale:e.field.locale,index:n.index??0})).slide,i}catch(e){}return i=(await e.navigator.openEntry(t,{slideIn:!0})).slide,i}(e.sdk,e.entryId,{bulkEditing:e.parameters.instance.bulkEditing,index:e.index});e.onAction&&e.onAction({entity:"Entry",type:"edit",id:e.entryId,contentTypeId:r(n,"sys.contentType.sys.id"),slide:t})},m=()=>{e.onRemove(),e.onAction&&e.onAction({entity:"Entry",type:"delete",id:e.entryId,contentTypeId:r(n,"sys.contentType.sys.id")})};return t.useEffect(()=>{n&&e.onAction&&e.onAction({type:"rendered",entity:"Entry"})},[n]),t.useMemo(()=>{if("error"===s){const n=t.createElement(O,{entityType:"Entry",isDisabled:e.isDisabled,onRemove:m});return e.renderCustomMissingEntityCard?e.renderCustomMissingEntityCard({defaultCard:n,entity:{id:e.entryId,type:"Entry"}}):n}if("loading"===s)return t.createElement(i.EntryCard,{size:l,isLoading:!0});const a={index:e.index,entity:n,entityUrl:e.getEntityUrl&&e.getEntityUrl(n.sys.id),contentType:e.allContentTypes.find(e=>e.sys.id===n.sys.contentType.sys.id),isDisabled:e.isDisabled,size:l,localeCode:e.sdk.field.locale,defaultLocaleCode:e.sdk.locales.default,renderDragHandle:e.renderDragHandle,onEdit:u,onRemove:m,onMoveTop:e.onMoveTop,onMoveBottom:e.onMoveBottom,isBeingDragged:e.isBeingDragged},{hasCardEditActions:r,hasCardMoveActions:c,hasCardRemoveActions:y}=e;function p(e){const n={...a,...e,hasCardEditActions:r,hasCardMoveActions:c,hasCardRemoveActions:y,getAsset:d,getEntityScheduledActions:o,entry:(null==e?void 0:e.entity)||a.entity,entryUrl:(null==e?void 0:e.entityUrl)||a.entityUrl};return t.createElement(ve,{...n})}if(e.renderCustomCard){const t=e.renderCustomCard(a,{},p);if(!1!==t)return t}return p()},[e,s,n])}function ke(e){return t.createElement(de,{...e,entityType:"Entry"},({allContentTypes:n,isDisabled:i,entityId:s,setValue:a,renderCustomCard:o,hasCardRemoveActions:r,hasCardEditActions:l})=>t.createElement(Ce,{...e,allContentTypes:n,isDisabled:i,entryId:s,renderCustomCard:o,hasCardEditActions:l,hasCardRemoveActions:r,onRemove:()=>{a(null)}}))}function he(e,t,n,i,s=n.length){const a=i.map(e=>({sys:{type:"Link",linkType:t,id:e}})),o=Array.from(n);o.splice(s,0,...a),e(o)}ve.defaultProps={isClickable:!0,hasCardEditActions:!0,hasCardMoveActions:!0,hasCardRemoveActions:!0},ke.defaultProps={isInitiallyDisabled:!0};const be=[],Ie={sys:{id:"null-value"}};function Te(e){const{setValue:n,entityType:i,setIndexToUpdate:s}=e,a=le(e),o=t.useMemo(()=>(e.items||[]).map(e=>e||Ie),[e.items]),r=t.useCallback((e,t)=>{t instanceof MouseEvent&&document.body.classList.add("grabbing"),t.preventDefault()},[]),l=t.useCallback(({oldIndex:t,newIndex:i})=>{e.onSortingEnd&&e.onSortingEnd({oldIndex:t,newIndex:i});const a=f(o,t,i);n(a),s&&s(void 0),document.body.classList.remove("grabbing")},[o,e,s,n]),c=t.useCallback((e,t)=>{const i=f(o,e,t);n(i)},[o,n]),d=t.useCallback((e,t)=>he(n,i,o,[e],t),[n,o,i]),u=t.useCallback((e,t)=>he(n,i,o,e,t),[n,o,i]),m=$({...e,canLinkMultiple:!0,editorPermissions:a,onCreate:d,onLink:u,itemsLength:o.length}),y=t.useCallback((t,n,i)=>!!e.renderCustomCard&&e.renderCustomCard(t,m,i),[m]);return t.createElement(t.Fragment,null,e.children({...e,onSortStart:r,onSortEnd:l,onMove:c,renderCustomCard:e.renderCustomCard&&y}),t.createElement(W,{renderCustomActions:e.renderCustomActions,...m}))}function Ae(e){const n=e.sdk.space.getCachedContentTypes();return t.createElement(ae,{...e},({value:i,disabled:s,setValue:a,externalReset:o})=>t.createElement(Te,{...e,items:i||be,isDisabled:s,setValue:a,key:o+"-list",allContentTypes:n}))}Ae.defaultProps={hasCardEditActions:!0};const xe={container:o.css({position:"relative"}),item:o.css({marginBottom:a.spacingM,zIndex:a.zIndexModal})},De=e=>{const t=g.SortableHandle(()=>e.drag);return n.createElement(t,null)},Me=g.SortableElement(e=>n.createElement("div",{className:xe.item},e.children)),Le=g.SortableContainer(e=>n.createElement("div",{className:o.cx(xe.container,e.className)},e.items.map((t,i)=>n.createElement(Me,{disabled:e.isDisabled,key:`${t.sys.urn??t.sys.id}-${i}`,index:i},e.children({items:e.items,isDisabled:e.isDisabled,item:t,index:i,DragHandle:e.isDisabled?void 0:De})))));function we(e){return n.createElement(Le,{distance:1,...e},e.children)}function Se(e){const{entityFile:t}=e,s=r(t,"fileName"),a=r(t,"contentType"),o=r(t,"details.size"),l=r(t,"details.image");return[n.createElement(i.Menu.SectionTitle,{key:"file-section"},"File info"),s&&n.createElement(i.Menu.Item,{key:"file-name"},n.createElement(i.Text,{isTruncated:!0},s)),a&&n.createElement(i.Menu.Item,{key:"file-type"},n.createElement(i.Text,{isTruncated:!0},a)),o&&n.createElement(i.Menu.Item,{key:"file-size"},c.shortenStorageUnit(o,"B")),l&&n.createElement(i.Menu.Item,{key:"file-dimentions"},`${l.width} × ${l.height}`)].filter(e=>e)}function Re(e){const{entityFile:t,isDisabled:s,onEdit:a,onRemove:o}=e;return[n.createElement(i.Menu.SectionTitle,{key:"section-title"},"Actions"),a?n.createElement(i.Menu.Item,{key:"edit",onClick:a,testId:"card-action-edit"},"Edit"):null,t?n.createElement(i.Menu.Item,{key:"download",onClick:()=>{"string"==typeof t.url&&window.open(t.url,"_blank","noopener,noreferrer")},testId:"card-action-download"},"Download"):null,o?n.createElement(i.Menu.Item,{key:"remove",disabled:s,onClick:o,testId:"card-action-remove"},"Remove"):null].filter(e=>e)}const Ne={image:"image",video:"video",audio:"audio",richtext:"richtext",presentation:"presentation",spreadsheet:"spreadsheet",pdfdocument:"pdf",archive:"archive",plaintext:"plaintext",code:"code",markup:"markup"},He={scheduleIcon:o.css({marginRight:a.spacing2Xs})};function Pe(e){if(!e)return"archive";const t=v.getGroupLabel({type:e.contentType,fallbackFileName:e.fileName});return Ne[t]||"archive"}const qe=e=>{const{className:t,onEdit:a,getAssetUrl:o,onRemove:r,size:l,isDisabled:d,isSelected:u,isClickable:m}=e,y=c.entityHelpers.getEntryStatus(e.asset.sys);if("deleted"===y)return n.createElement(O,{entityType:"Asset",asSquare:!0,isDisabled:e.isDisabled,onRemove:e.onRemove});const p=c.entityHelpers.getAssetTitle({asset:e.asset,localeCode:e.localeCode,defaultLocaleCode:e.defaultLocaleCode,defaultTitle:"Untitled"}),E=e.asset.fields.file?e.asset.fields.file[e.localeCode]||e.asset.fields.file[e.defaultLocaleCode]:void 0,f=o?o(e.asset.sys.id):void 0;return n.createElement(i.AssetCard,{as:f?"a":"article",type:Pe(E),title:p,className:t,isSelected:u,href:f,status:y,icon:n.createElement(_,{getEntityScheduledActions:e.getEntityScheduledActions,entityType:"Asset",entityId:e.asset.sys.id},n.createElement(s.ClockIcon,{className:He.scheduleIcon,size:"small",variant:"muted",testId:"schedule-icon"})),src:E&&E.url?"small"===l?E.url+"?w=150&h=150&fit=thumb":E.url+"?h=300":"",onClick:m?e=>{e.preventDefault(),a&&a()}:void 0,onKeyDown:m?e=>{"Enter"===e.key&&a&&(e.preventDefault(),a())}:void 0,dragHandleRender:e.renderDragHandle,withDragHandle:!!e.renderDragHandle,actions:[...Re({entityFile:E,isDisabled:d,onEdit:a,onRemove:r}),...E?Se({entityFile:E}):[]].filter(e=>e),size:l})};qe.defaultProps={isClickable:!0};const Be={scheduleIcon:o.css({marginRight:a.spacing2Xs})},ze=e=>{const{className:t,href:a,onEdit:o,onRemove:r,isDisabled:l}=e,d=c.entityHelpers.getEntryStatus(e.asset.sys);if("deleted"===d)return n.createElement(O,{entityType:"Asset",isDisabled:e.isDisabled,onRemove:e.onRemove});const u=c.entityHelpers.getAssetTitle({asset:e.asset,localeCode:e.localeCode,defaultLocaleCode:e.defaultLocaleCode,defaultTitle:"Untitled"}),m=e.asset.fields.file?e.asset.fields.file[e.localeCode]||e.asset.fields.file[e.defaultLocaleCode]:void 0;return n.createElement(i.EntryCard,{as:a?"a":"article",contentType:"Asset",title:u,className:t,href:a,size:"small",status:d,thumbnailElement:m&&c.isValidImage(m)?n.createElement(X,{file:m}):void 0,icon:n.createElement(_,{getEntityScheduledActions:e.getEntityScheduledActions,entityType:"Asset",entityId:e.asset.sys.id},n.createElement(s.ClockIcon,{className:Be.scheduleIcon,size:"small",variant:"muted",testId:"schedule-icon"})),onClick:e=>{e.preventDefault(),o()},onKeyDown:e=>{"Enter"===e.key&&o&&(e.preventDefault(),o())},dragHandleRender:e.renderDragHandle,withDragHandle:!!e.renderDragHandle,actions:[Re({entityFile:m,isDisabled:l,onEdit:o,onRemove:r}),m?Se({entityFile:m}):null].filter(e=>e)})};function Ue(e){const{data:n,status:s}=ne("Asset",e.assetId),{getEntityScheduledActions:a}=ee(),o=t.useCallback(()=>a("Asset",e.assetId),[a,e.assetId]);t.useEffect(()=>{n&&e.onAction&&e.onAction({type:"rendered",entity:"Asset"})},[n]);const r=async()=>{const{slide:t}=await e.sdk.navigator.openAsset(e.assetId,{slideIn:!0});e.onAction&&e.onAction({entity:"Asset",type:"edit",id:e.assetId,contentTypeId:"",slide:t})},l=()=>{e.onRemove(),e.onAction&&e.onAction({entity:"Asset",type:"delete",id:e.assetId,contentTypeId:""})};return t.useMemo(()=>{if("error"===s){const n=t.createElement(O,{entityType:"Asset",asSquare:"link"!==e.viewType,isDisabled:e.isDisabled,onRemove:l});return e.renderCustomMissingEntityCard?e.renderCustomMissingEntityCard({defaultCard:n,entity:{id:e.assetId,type:"Asset"}}):n}const{getEntityUrl:a}=e,c="big_card"===e.viewType?"default":"small",d={asset:n,entityUrl:a&&a(e.assetId),size:c,isDisabled:e.isDisabled,localeCode:e.sdk.field.locale,defaultLocaleCode:e.sdk.locales.default,renderDragHandle:e.renderDragHandle,onEdit:r,onRemove:l};if("link"===e.viewType)return"loading"===s?t.createElement(i.EntryCard,{size:"small",isLoading:!0}):t.createElement(ze,{...d,href:d.entityUrl,getEntityScheduledActions:o});if("loading"===s)return t.createElement(i.AssetCard,{size:c,isLoading:!0});function u(e){const n={...d,...e,getEntityScheduledActions:o,asset:(null==e?void 0:e.entity)||d.asset,getAssetUrl:a};return t.createElement(qe,{...n})}if(e.renderCustomCard){const t={...d,entity:d.asset},n=e.renderCustomCard(t,{},u);if(!1!==n)return n}return u()},[e,s,n])}function Fe(e){return t.createElement(de,{...e,entityType:"Asset"},({entityId:n,isDisabled:i,setValue:s})=>t.createElement(Ue,{...e,viewType:"big_card",assetId:n,isDisabled:i,onRemove:()=>{s(null)}}))}Fe.defaultProps={isInitiallyDisabled:!0};const Oe=o.css({position:"relative",display:"flex",flexWrap:"wrap"});function Ve(e){return t.createElement(Ae,{...e,entityType:"Asset"},e=>t.createElement(we,{...e,className:o.cx({[Oe]:"card"===e.viewType}),axis:"card"===e.viewType?"xy":"y",useDragHandle:!0},({items:n,item:i,index:s,isDisabled:a,DragHandle:o})=>t.createElement(Ue,{...e,isDisabled:a,key:`${i.sys.id}-${s}`,assetId:i.sys.id,onRemove:()=>{e.setValue(n.filter((e,t)=>t!==s))},renderDragHandle:o})))}Ve.defaultProps={isInitiallyDisabled:!0};const $e=()=>Promise.resolve(),We=()=>Promise.resolve([]);function Ye({info:e,isDisabled:n,renderDragHandle:i,onRemove:s,onMoveTop:a,onMoveBottom:o,getEntryRouteHref:r}){const l=e.resource.sys,c=r({spaceId:l.space.sys.id,environmentId:l.environment.sys.id,entryId:l.id});return t.createElement(ve,{entry:e.resource,isDisabled:n,hasCardEditActions:!1,contentType:e.contentType,localeCode:e.defaultLocaleCode,defaultLocaleCode:e.defaultLocaleCode,size:"small",getAsset:$e,getEntityScheduledActions:We,spaceName:e.space.name,renderDragHandle:i,isClickable:!0,onEdit:()=>{window.open(c,"_blank","noopener,noreferrer")},hasCardRemoveActions:Boolean(s),onRemove:s,onMoveBottom:o,onMoveTop:a,entryUrl:c})}const je={card:o.css({position:"relative"})};function Qe(e){return n.createElement(i.Card,{className:je.card},n.createElement(i.SectionHeading,{marginBottom:"none"},"Resource type ",e.entityType," is currently not supported"))}function _e(){return t.createElement(i.EntryCard,{size:"small",isLoading:!0})}function Xe(e){const{resourceLink:n,inView:i,index:s=0}=e,a={priority:-1*s,enabled:i},{data:o,error:r}=ie(n.sys.linkType,n.sys.urn,a);return o||r?o?t.createElement(Ye,{info:o,...e}):"object"==typeof(l=r)&&!0===(null==l?void 0:l.isUnsupportedError)?t.createElement(Qe,{entityType:n.sys.linkType}):t.createElement(O,{entityType:"Entry",isDisabled:e.isDisabled,onRemove:e.onRemove}):t.createElement(_e,null);var l}function Ge(e){return e.resourceLink?t.createElement(Xe,{...e,resourceLink:e.resourceLink,getEntryRouteHref:e.getEntryRouteHref}):null}function Ke(e){const{ref:n,inView:i}=C.useInView({triggerOnce:!0,rootMargin:"300px 0px 0px 300px"});return t.createElement("div",{ref:n},t.createElement(Ge,{...e,inView:i}))}const Je=(e,t)=>({sys:{type:"ResourceLink",linkType:"Contentful:Entry",urn:e.sys.urn??`crn:${t}:::content:spaces/${e.sys.space.sys.id}/entries/${e.sys.id}`}});function Ze({dialogs:e,field:n,onAfterLink:i,apiUrl:s}){const a=t.useCallback(e=>{i&&e.forEach(i)},[i]),o=t.useMemo(()=>e=>{const t=((e,t,n)=>{if("Array"===e.type){const i=t.map(e=>Je(e,n));return[...e.getValue()||[],...i]}return Je(t[0],n)})(n,e,s);n.setValue(t),a(e)},[n,a,s]),r="Array"===n.type;return{onLinkExisting:t.useMemo(()=>{const t=r?async()=>await e.selectMultipleResourceEntries({allowedResources:n.allowedResources}):async()=>[await e.selectSingleResourceEntry({allowedResources:n.allowedResources})];return async()=>{const e=await t();e&&o(e)}},[e,n.allowedResources,r,o]),onLinkedExisting:o,entityType:"Entry",contentTypes:[],canCreateEntity:!1,canLinkMultiple:r,canLinkEntity:!0,isDisabled:!1,isEmpty:!1,isFull:!1,onCreate:async()=>{},onCreated:()=>{}}}function et(e){const{setValue:n,items:i,apiUrl:s}=e,a=t.useCallback((e,t)=>t.preventDefault(),[]),o=t.useCallback(({oldIndex:e,newIndex:t})=>{const s=f(i,e,t);n(s)},[i,n]),r=t.useCallback((e,t)=>{const s=f(i,e,t);n(s)},[i,n]),l=t.useCallback(e=>{n(i.filter((t,n)=>n!==e))},[i,n]),{dialogs:c,field:d}=e.sdk,u=Ze({dialogs:c,field:d,apiUrl:s});return t.createElement(t.Fragment,null,e.children({...e,onSortStart:a,onSortEnd:o,onMove:r,onRemoteItemAtIndex:l}),t.createElement(Y,{...u,renderCustomActions:e.renderCustomActions}))}function tt({listLength:e,index:n,onMove:i,onRemoteItemAtIndex:s,children:a}){const o=t.useMemo(()=>n>0?()=>i(n,0):void 0,[n,i]),r=t.useMemo(()=>n<e-1?()=>i(n,e-1):void 0,[n,i,e]),l=t.useCallback(()=>s(n),[n,s]);return t.createElement(t.Fragment,null,a({onMoveBottom:r,onMoveTop:o,onRemove:l}))}const nt=[];exports.AssetThumbnail=X,exports.CombinedLinkActions=q,exports.CreateEntryLinkButton=A,exports.CreateEntryMenuTrigger=b,exports.EntityProvider=se,exports.MissingEntityCard=O,exports.MultipleEntryReferenceEditor=function(e){const[n,i]=t.useState(void 0),s=({index:e})=>{i(e)};return t.createElement(Ae,{...e,entityType:"Entry",setIndexToUpdate:i},e=>t.createElement(we,{...e,axis:"y",useDragHandle:!0,updateBeforeSortStart:s},({items:i,item:s,index:a,isDisabled:o,DragHandle:r})=>{const l=i.length-1;return t.createElement(Ce,{...e,key:`${s.sys.id}-${a}`,index:a,allContentTypes:e.allContentTypes,isDisabled:o,entryId:s.sys.id,onRemove:()=>{e.setValue(i.filter((e,t)=>t!==a))},onMoveTop:0!==a?()=>e.onMove(a,0):void 0,onMoveBottom:a!==l?()=>e.onMove(a,l):void 0,renderDragHandle:r,isBeingDragged:a===n})}))},exports.MultipleMediaEditor=Ve,exports.MultipleResourceReferenceEditor=function(e){return t.createElement(se,{sdk:e.sdk},t.createElement(c.FieldConnector,{throttle:0,field:e.sdk.field,isInitiallyDisabled:e.isInitiallyDisabled,isEqualValues:d},({value:n,disabled:i,setValue:s,externalReset:a})=>t.createElement(et,{...e,items:n||nt,isDisabled:i,setValue:s,renderCustomActions:e.renderCustomActions,key:a+"-list"},i=>t.createElement(we,{...i},({item:s,isDisabled:a,DragHandle:o,index:r})=>t.createElement(tt,{index:r,onMove:i.onMove,onRemoteItemAtIndex:i.onRemoteItemAtIndex,listLength:(null==n?void 0:n.length)||0},({onMoveBottom:n,onMoveTop:i,onRemove:l})=>t.createElement(Ke,{index:r,resourceLink:s,isDisabled:a,renderDragHandle:o,onMoveTop:i,onMoveBottom:n,onRemove:l,getEntryRouteHref:e.getEntryRouteHref}))))))},exports.ScheduledIconWithTooltip=_,exports.SingleEntryReferenceEditor=ke,exports.SingleMediaEditor=Fe,exports.SingleResourceReferenceEditor=function(e){const{dialogs:n,field:i}=e.sdk,s=Ze({dialogs:n,field:i,apiUrl:e.apiUrl});return t.createElement(se,{sdk:e.sdk},t.createElement(c.FieldConnector,{throttle:0,field:e.sdk.field,isInitiallyDisabled:e.isInitiallyDisabled,isEqualValues:d},({value:n,disabled:i})=>n?t.createElement(Ke,{onRemove:()=>e.sdk.field.removeValue(),resourceLink:n,isDisabled:i,getEntryRouteHref:e.getEntryRouteHref}):t.createElement(Y,{...s,renderCustomActions:e.renderCustomActions})))},exports.SortableLinkList=we,exports.WrappedAssetCard=qe,exports.WrappedEntryCard=ve,exports.getScheduleTooltipContent=j,exports.useEntity=ne,exports.useEntityLoader=ee,exports.useResource=ie;
2
- //# sourceMappingURL=field-editor-reference.cjs.production.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"field-editor-reference.cjs.production.min.js","sources":["../src/components/CreateEntryLinkButton/CreateEntryMenuTrigger.tsx","../src/components/CreateEntryLinkButton/CreateEntryLinkButton.tsx","../src/components/LinkActions/NoLinkPermissionsInfo.tsx","../src/components/LinkActions/styles.ts","../src/components/LinkActions/LinkActions.tsx","../src/components/LinkActions/redesignStyles.ts","../src/components/LinkActions/CombinedLinkActions.tsx","../src/components/MissingEntityCard/styles.ts","../src/components/MissingEntityCard/MissingEntityCard.tsx","../src/components/LinkActions/helpers.ts","../src/components/LinkActions/LinkEntityActions.tsx","../src/components/ScheduledIconWithTooltip/formatDateAndTime.ts","../src/components/ScheduledIconWithTooltip/ScheduleTooltip.tsx","../src/components/ScheduledIconWithTooltip/ScheduledIconWithTooltip.tsx","../src/components/AssetThumbnail/AssetThumbnail.tsx","../src/common/EntityStore.tsx","../src/common/ReferenceEditor.tsx","../src/common/useAccessApi.ts","../src/common/useEditorPermissions.ts","../src/utils/fromFieldValidations.ts","../src/common/useContentTypePermissions.ts","../src/common/SingleReferenceEditor.tsx","../src/components/SpaceName/SpaceName.tsx","../src/entries/WrappedEntryCard/WrappedEntryCard.tsx","../src/entries/WrappedEntryCard/FetchingWrappedEntryCard.tsx","../src/entries/SingleEntryReferenceEditor.tsx","../src/common/MultipleReferenceEditor.tsx","../src/common/SortableLinkList.tsx","../src/assets/WrappedAssetCard/AssetCardActions.tsx","../src/assets/WrappedAssetCard/WrappedAssetCard.tsx","../src/assets/WrappedAssetCard/WrappedAssetLink.tsx","../src/assets/WrappedAssetCard/FetchingWrappedAssetCard.tsx","../src/assets/SingleMediaEditor.tsx","../src/assets/MultipleMediaEditor.tsx","../src/resources/Cards/ContentfulEntryCard.tsx","../src/resources/Cards/UnsupportedEntityCard.tsx","../src/resources/Cards/ResourceCard.tsx","../src/resources/useResourceLinkActions.ts","../src/resources/MultipleResourceReferenceEditor.tsx","../src/entries/MultipleEntryReferenceEditor.tsx","../src/resources/SingleResourceReferenceEditor.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport React, { useState, useRef, useEffect } from 'react';\n\nimport { TextInput, Menu, MenuProps } from '@contentful/f36-components';\nimport { SearchIcon } from '@contentful/f36-icons';\nimport tokens from '@contentful/f36-tokens';\nimport { css } from 'emotion';\nimport get from 'lodash/get';\n\nimport { ContentType } from '../../types';\n\nconst MAX_ITEMS_WITHOUT_SEARCH = 5;\n\nconst menuPlacementMap: {\n [key: string]: MenuProps['placement'];\n} = {\n 'bottom-left': 'bottom-start',\n 'bottom-right': 'bottom-end',\n};\n\nconst styles = {\n wrapper: css({\n position: 'relative',\n }),\n inputWrapper: css({\n position: 'relative',\n padding: `0 ${tokens.spacing2Xs}`,\n }),\n searchInput: css({\n paddingRight: tokens.spacingXl,\n textOverflow: 'ellipsis',\n }),\n searchIcon: css({\n position: 'absolute',\n right: tokens.spacingM,\n top: tokens.spacingS,\n zIndex: Number(tokens.zIndexDefault),\n fill: tokens.gray600,\n }),\n separator: css({\n background: tokens.gray200,\n margin: '10px 0',\n }),\n dropdownList: css({\n borderColor: tokens.gray200,\n }),\n};\n\ntype CreateEntryMenuTriggerChildProps = {\n isOpen: boolean;\n isSelecting: boolean;\n};\nexport type CreateEntryMenuTriggerChild = (\n props: CreateEntryMenuTriggerChildProps\n) => React.ReactElement;\nexport type CreateCustomEntryMenuItems = ({\n closeMenu,\n}: {\n closeMenu: Function;\n}) => React.ReactElement;\n\ninterface CreateEntryMenuTrigger {\n contentTypes: ContentType[];\n suggestedContentTypeId?: string;\n contentTypesLabel?: string;\n onSelect: (contentTypeId: string) => Promise<unknown>;\n testId?: string;\n dropdownSettings?: {\n isAutoalignmentEnabled?: boolean;\n position: 'bottom-left' | 'bottom-right';\n };\n customDropdownItems?: React.ReactNode;\n children: CreateEntryMenuTriggerChild;\n}\n\nexport const CreateEntryMenuTrigger = ({\n contentTypes,\n suggestedContentTypeId,\n contentTypesLabel,\n onSelect,\n testId,\n dropdownSettings = {\n position: 'bottom-left',\n },\n customDropdownItems,\n children,\n}: CreateEntryMenuTrigger) => {\n const [isOpen, setOpen] = useState(false);\n const [isSelecting, setSelecting] = useState(false);\n const [searchInput, setSearchInput] = useState('');\n const wrapper = useRef<any | null>(null);\n const textField = useRef<any | null>(null);\n const menuListRef = useRef<any | null>(null);\n /*\n By default, dropdown wraps it's content, so it's width = the width of the widest item\n During search, menu items change, and so the widest menu item can change\n This leads to menu always changing it's width\n To prevent this, we get the width of the menu item after the first mount of a dropdown (when all the content is displayed)\n And hardcode it through the class name. This way we ensure that even during search the menu will keep that max width\n That it had on initial mount and that fits any menu item in has\n */\n const [dropdownWidth, setDropdownWidth] = useState();\n\n const hasDropdown = contentTypes.length > 1 || !!customDropdownItems;\n\n const closeMenu = () => setOpen(false);\n\n useEffect(() => {\n if (isOpen) {\n setTimeout(() => {\n textField.current?.querySelector('input')?.focus({ preventScroll: true });\n }, 200);\n }\n }, [isOpen]);\n\n useEffect(() => {\n if (isOpen && !dropdownWidth) {\n setDropdownWidth(menuListRef.current?.clientWidth);\n }\n }, [isOpen, dropdownWidth]);\n\n const handleSelect = (item: ContentType) => {\n closeMenu();\n const res = onSelect(item.sys.id);\n\n // TODO: Convert to controllable component.\n if (res && typeof res.then === 'function') {\n setSelecting(true);\n res.then(\n () => setSelecting(false),\n () => setSelecting(false)\n );\n }\n };\n\n const handleMenuOpen = () => {\n if (hasDropdown) {\n setOpen(true);\n } else {\n handleSelect(contentTypes[0]);\n }\n };\n\n useEffect(() => {\n if (!isOpen) {\n setSearchInput('');\n }\n }, [isOpen]);\n\n const renderSearchResultsCount = (resultsLength: number) =>\n resultsLength ? (\n <Menu.SectionTitle testId=\"add-entru-menu-search-results\">\n {resultsLength} result{resultsLength > 1 ? 's' : ''}\n </Menu.SectionTitle>\n ) : null;\n\n const isSearchable = contentTypes.length > MAX_ITEMS_WITHOUT_SEARCH;\n const maxDropdownHeight = suggestedContentTypeId ? 300 : 250;\n const suggestedContentType = contentTypes.find((ct) => ct.sys.id === suggestedContentTypeId);\n const filteredContentTypes = contentTypes.filter(\n (ct) =>\n !searchInput || get(ct, 'name', 'Untitled').toLowerCase().includes(searchInput.toLowerCase())\n );\n\n return (\n <span className={styles.wrapper} ref={wrapper} data-test-id={testId}>\n <Menu\n placement={menuPlacementMap[dropdownSettings.position]}\n isAutoalignmentEnabled={dropdownSettings.isAutoalignmentEnabled}\n isOpen={isOpen}\n onClose={closeMenu}\n onOpen={handleMenuOpen}\n >\n <Menu.Trigger>{children({ isOpen, isSelecting })}</Menu.Trigger>\n\n {isOpen && (\n <Menu.List\n className={styles.dropdownList}\n style={{\n width: dropdownWidth != undefined ? `${dropdownWidth}px` : undefined,\n maxHeight: `${maxDropdownHeight}px`,\n }}\n ref={menuListRef}\n testId=\"add-entry-menu\"\n >\n {Boolean(customDropdownItems) && (\n <>\n {customDropdownItems}\n <Menu.Divider />\n </>\n )}\n\n {isSearchable && (\n <>\n <div ref={textField} className={styles.inputWrapper}>\n <TextInput\n className={styles.searchInput}\n placeholder=\"Search all content types\"\n testId=\"add-entry-menu-search\"\n value={searchInput}\n onChange={(e) => setSearchInput(e.target.value)}\n />\n <SearchIcon className={styles.searchIcon} />\n </div>\n <Menu.Divider />\n </>\n )}\n\n {searchInput && renderSearchResultsCount(filteredContentTypes.length)}\n {suggestedContentType && !searchInput && (\n <>\n <Menu.SectionTitle>Suggested Content Type</Menu.SectionTitle>\n <Menu.Item testId=\"suggested\" onClick={() => handleSelect(suggestedContentType)}>\n {get(suggestedContentType, 'name')}\n </Menu.Item>\n <Menu.Divider />\n </>\n )}\n {!searchInput && <Menu.SectionTitle>{contentTypesLabel}</Menu.SectionTitle>}\n {filteredContentTypes.length ? (\n filteredContentTypes.map((contentType, i) => (\n <Menu.Item\n testId=\"contentType\"\n key={`${get(contentType, 'name')}-${i}`}\n onClick={() => handleSelect(contentType)}\n >\n {get(contentType, 'name', 'Untitled')}\n </Menu.Item>\n ))\n ) : (\n <Menu.Item testId=\"add-entru-menu-search-results\">No results found</Menu.Item>\n )}\n </Menu.List>\n )}\n </Menu>\n </span>\n );\n};\n\nCreateEntryMenuTrigger.defaultProps = {\n testId: 'create-entry-button-menu-trigger',\n contentTypesLabel: 'All Content Types',\n};\n","import React from 'react';\n\nimport { Button } from '@contentful/f36-components';\nimport { ChevronDownIcon, PlusIcon } from '@contentful/f36-icons';\nimport tokens from '@contentful/f36-tokens';\nimport { css } from 'emotion';\nimport get from 'lodash/get';\n\nimport { ContentType } from '../../types';\nimport { CreateEntryMenuTrigger } from './CreateEntryMenuTrigger';\n\nconst standardStyles = {\n spinnerMargin: css({\n marginRight: tokens.spacingXs,\n }),\n action: undefined,\n};\nconst redesignStyles = {\n ...standardStyles,\n action: css({\n textDecoration: 'none',\n fontWeight: 'bold',\n maxWidth: '300px',\n }),\n};\n\ninterface CreateEntryLinkButtonProps {\n contentTypes: ContentType[];\n suggestedContentTypeId?: string;\n onSelect: (contentTypeId: string) => Promise<unknown>;\n customDropdownItems?: React.ReactNode;\n disabled?: boolean;\n hasPlusIcon?: boolean;\n useExperimentalStyles?: boolean;\n text?: string | React.ReactElement;\n testId?: string;\n dropdownSettings?: {\n isAutoalignmentEnabled?: boolean;\n position: 'bottom-left' | 'bottom-right';\n };\n}\n\nexport const CreateEntryLinkButton = ({\n contentTypes,\n onSelect,\n customDropdownItems,\n text,\n testId,\n hasPlusIcon = false,\n useExperimentalStyles,\n suggestedContentTypeId,\n dropdownSettings,\n disabled = false,\n}: CreateEntryLinkButtonProps) => {\n contentTypes = contentTypes.sort((a, b) => a.name.localeCompare(b.name));\n const suggestedContentType = contentTypes.find((ct) => ct.sys.id === suggestedContentTypeId);\n const buttonText =\n text ||\n `Add ${get(\n suggestedContentType || (contentTypes.length === 1 ? contentTypes[0] : {}),\n 'name',\n 'entry'\n )}`;\n const hasDropdown = contentTypes.length > 1 || customDropdownItems;\n\n // TODO: Introduce `icon: string` and remove `hasPlusIcon` or remove \"Plus\" if we keep new layout.\n const plusIcon = hasPlusIcon ? <PlusIcon /> : undefined;\n // TODO: Always use \"New content\" here if we fully switch to new layout.\n const contentTypesLabel = useExperimentalStyles ? 'New content' : undefined;\n const styles = useExperimentalStyles ? redesignStyles : standardStyles;\n\n return (\n <CreateEntryMenuTrigger\n contentTypes={contentTypes}\n suggestedContentTypeId={suggestedContentTypeId}\n contentTypesLabel={contentTypesLabel}\n onSelect={onSelect}\n testId={testId}\n dropdownSettings={dropdownSettings}\n customDropdownItems={customDropdownItems}\n >\n {({ isSelecting }) => (\n <Button\n endIcon={hasDropdown ? <ChevronDownIcon /> : undefined}\n variant=\"secondary\"\n className={styles.action}\n isDisabled={disabled || isSelecting} // (contentTypes && contentTypes.length === 0)}\n startIcon={isSelecting ? undefined : plusIcon}\n size=\"small\"\n testId=\"create-entry-link-button\"\n isLoading={isSelecting}\n >\n {buttonText}\n </Button>\n )}\n </CreateEntryMenuTrigger>\n );\n};\n","import React from 'react';\n\nimport { Paragraph } from '@contentful/f36-components';\n\nexport function NoLinkPermissionsInfo() {\n return (\n <Paragraph>\n You don&apos;t have permission to view this content or this field is not correctly configured.\n Contact your administrator for help.\n </Paragraph>\n );\n}\n","import tokens from '@contentful/f36-tokens';\nimport { css } from 'emotion';\n\nexport const container = css({\n display: 'flex',\n width: '100%',\n marginTop: tokens.spacingS,\n});\n\nexport const separator = css({\n marginRight: tokens.spacingXl,\n});\n","import * as React from 'react';\n\nimport { Button } from '@contentful/f36-components';\nimport { PlusIcon, LinkIcon } from '@contentful/f36-icons';\n\nimport {\n ContentEntityType,\n ContentType,\n ActionLabels,\n Entry,\n Asset,\n NavigatorSlideInfo,\n} from '../../types';\nimport { CreateEntryLinkButton } from '../CreateEntryLinkButton/CreateEntryLinkButton';\nimport { NoLinkPermissionsInfo } from './NoLinkPermissionsInfo';\nimport * as styles from './styles';\n\nexport interface LinkActionsProps {\n entityType: ContentEntityType;\n contentTypes: ContentType[];\n canCreateEntity: boolean;\n canLinkEntity: boolean;\n canLinkMultiple: boolean;\n isDisabled: boolean;\n isFull: boolean;\n isEmpty: boolean;\n onCreate: (contentType?: string, index?: number) => Promise<unknown>;\n onCreated: (entity: Entry | Asset, index?: number, slide?: NavigatorSlideInfo) => void;\n onLinkExisting: (index?: number) => void;\n onLinkedExisting: (entities: Array<Entry | Asset>, index?: number) => void;\n actionLabels?: Partial<ActionLabels>;\n combinedActionsLabel?: string | React.ReactElement;\n itemsLength?: number;\n}\n\nconst defaultEntryLabels: ActionLabels = {\n createNew: (props) =>\n props?.contentType ? `Create new ${props.contentType} and link` : 'Create new entry and link',\n linkExisting: (props) =>\n props?.canLinkMultiple ? 'Link existing entries' : 'Link existing entry',\n};\n\nconst defaultAssetLabels: ActionLabels = {\n createNew: () => `Create new asset and link`,\n linkExisting: (props) =>\n props?.canLinkMultiple ? 'Link existing assets' : 'Link existing asset',\n};\n\nexport const testIds = {\n dropdown: 'linkEditor.dropdown',\n createAndLink: 'linkEditor.createAndLink',\n createAndLinkWrapper: 'create-entry-button-menu-trigger',\n linkExisting: 'linkEditor.linkExisting',\n};\n\nexport function LinkActions(props: LinkActionsProps) {\n if (props.isFull) {\n return null; // Don't render link actions if we reached max allowed links.\n }\n const defaultLabels = props.entityType === 'Entry' ? defaultEntryLabels : defaultAssetLabels;\n const labels = {\n ...defaultLabels,\n ...props.actionLabels,\n };\n\n return (\n <div className={styles.container}>\n {props.canCreateEntity && (\n <>\n {props.entityType === 'Entry' && (\n <CreateEntryLinkButton\n testId={testIds.createAndLink}\n disabled={props.isDisabled}\n text={labels.createNew({\n contentType:\n props.contentTypes.length === 1 ? props.contentTypes[0].name : undefined,\n })}\n contentTypes={props.contentTypes}\n hasPlusIcon={true}\n onSelect={(contentTypeId) => {\n return contentTypeId\n ? props.onCreate(contentTypeId, props.itemsLength)\n : Promise.resolve();\n }}\n />\n )}\n {props.entityType === 'Asset' && (\n <Button\n isDisabled={props.isDisabled}\n testId={testIds.createAndLink}\n onClick={() => {\n props.onCreate(undefined, props.itemsLength);\n }}\n variant=\"secondary\"\n startIcon={<PlusIcon />}\n size=\"small\">\n {labels.createNew()}\n </Button>\n )}\n <span className={styles.separator} />\n </>\n )}\n {props.canLinkEntity && (\n <Button\n isDisabled={props.isDisabled}\n testId={testIds.linkExisting}\n onClick={() => {\n props.onLinkExisting();\n }}\n variant=\"secondary\"\n startIcon={<LinkIcon />}\n size=\"small\">\n {labels.linkExisting({ canLinkMultiple: props.canLinkMultiple })}\n </Button>\n )}\n\n {!props.canCreateEntity && !props.canLinkEntity && <NoLinkPermissionsInfo />}\n </div>\n );\n}\n","import tokens from '@contentful/f36-tokens';\nimport { css } from 'emotion';\n\nexport const container = css({\n display: 'flex',\n border: `1px dashed ${tokens.gray500}`,\n borderRadius: tokens.borderRadiusMedium,\n justifyContent: 'center',\n padding: tokens.spacingXl,\n});\n\nexport const action = css({\n textDecoration: 'none',\n fontWeight: 'bold',\n});\n\nexport const chevronIcon = css({\n float: 'right',\n marginLeft: tokens.spacingXs,\n marginRight: -tokens.spacing2Xs,\n});\n","import * as React from 'react';\n\nimport { Button, Menu } from '@contentful/f36-components';\nimport { LinkIcon, PlusIcon, ChevronDownIcon } from '@contentful/f36-icons';\n\nimport { CreateEntryLinkButton } from '../CreateEntryLinkButton/CreateEntryLinkButton';\nimport { testIds as sharedTextIds, LinkActionsProps } from './LinkActions';\nimport { NoLinkPermissionsInfo } from './NoLinkPermissionsInfo';\nimport * as styles from './redesignStyles';\n\nconst testIds = {\n ...sharedTextIds,\n actionsWrapper: 'link-actions-menu-trigger',\n};\n\n/**\n * Alternative, experimental alternative to <LinkActions /> that is planned to\n * replace the current default LinkActions in reference and media editors.\n *\n * Places both actions to create and link new, as well as link existing, behind\n * one action dropdown and introduces new copy for action labels.\n */\nexport function CombinedLinkActions(props: LinkActionsProps) {\n if (props.isFull) {\n return null; // Don't render link actions if we reached max allowed links.\n }\n // We don't want to render a spacious container in case there are are already\n // assets linked (in case of entries, always show it) as the border wouldn't be\n // nicely aligned with asset cards.\n const hideEmptyCard = props.entityType === 'Asset' && !props.isEmpty;\n return (\n <div className={hideEmptyCard ? '' : styles.container}>\n {!props.canCreateEntity && !props.canLinkEntity && <NoLinkPermissionsInfo />}\n {props.entityType === 'Entry' && <CombinedEntryLinkActions {...props} />}\n {props.entityType === 'Asset' && <CombinedAssetLinkActions {...props} />}\n </div>\n );\n}\n\nfunction CombinedEntryLinkActions(props: LinkActionsProps) {\n if (props.canCreateEntity) {\n return (\n <CreateEntryLinkButton\n testId={testIds.actionsWrapper}\n disabled={props.isDisabled}\n text={props.combinedActionsLabel || 'Add content'}\n contentTypes={props.contentTypes}\n hasPlusIcon={true}\n useExperimentalStyles={true}\n dropdownSettings={{\n position: 'bottom-left',\n }}\n onSelect={(contentTypeId) => {\n return contentTypeId ? props.onCreate(contentTypeId) : Promise.resolve();\n }}\n customDropdownItems={\n props.canLinkEntity ? (\n <Menu.Item\n testId={testIds.linkExisting}\n onClick={() => {\n props.onLinkExisting();\n }}>\n Add existing content\n </Menu.Item>\n ) : undefined\n }\n />\n );\n } else if (props.canLinkEntity) {\n return (\n <Button\n isDisabled={props.isDisabled}\n testId={testIds.linkExisting}\n className={styles.action}\n onClick={() => {\n props.onLinkExisting();\n }}\n variant=\"secondary\"\n startIcon={<LinkIcon />}\n size=\"small\">\n Add existing content\n </Button>\n );\n }\n return null;\n}\n\nfunction CombinedAssetLinkActions(props: LinkActionsProps) {\n const [isOpen, setOpen] = React.useState(false);\n\n if (!props.canLinkEntity || !props.canCreateEntity) {\n if (props.canLinkEntity) {\n return (\n <Button\n isDisabled={props.isDisabled}\n testId={testIds.linkExisting}\n className={styles.action}\n onClick={() => {\n props.onLinkExisting();\n }}\n variant=\"secondary\"\n startIcon={<PlusIcon />}\n size=\"small\">\n Add existing media\n </Button>\n );\n }\n if (props.canCreateEntity) {\n return (\n <Button\n isDisabled={props.isDisabled}\n testId={testIds.createAndLink}\n className={styles.action}\n onClick={() => {\n props.onCreate();\n }}\n variant=\"secondary\"\n startIcon={<PlusIcon />}\n size=\"small\">\n Add media\n </Button>\n );\n }\n return null;\n }\n\n // TODO: If we fully switch to this new layout, make a more generic `CreateEntityLinkButton`\n // that works without content types to cover asset use-case.\n return (\n <Menu\n isOpen={isOpen}\n onClose={() => {\n setOpen(false);\n }}\n onOpen={() => {\n setOpen(true);\n }}>\n <Menu.Trigger>\n <Button\n endIcon={<ChevronDownIcon />}\n isDisabled={props.isDisabled}\n testId={testIds.actionsWrapper}\n className={styles.action}\n variant=\"secondary\"\n startIcon={<PlusIcon />}\n size=\"small\">\n Add media\n </Button>\n </Menu.Trigger>\n {isOpen && (\n <Menu.List testId={testIds.dropdown}>\n <Menu.Item\n testId={testIds.linkExisting}\n onClick={() => {\n props.onLinkExisting();\n }}>\n Add existing media\n </Menu.Item>\n <Menu.Item\n testId={testIds.createAndLink}\n onClick={() => {\n props.onCreate();\n }}>\n Add new media\n </Menu.Item>\n </Menu.List>\n )}\n </Menu>\n );\n}\n","import { css } from 'emotion';\n\nexport const card = css({\n position: 'relative',\n});\n\nexport const squareCard = css({\n display: 'flex',\n alignItems: 'center',\n width: '135px',\n height: '160px',\n textAlign: 'center',\n});\n","import React from 'react';\n\nimport { Card, SectionHeading, IconButton, Flex } from '@contentful/f36-components';\nimport { CloseIcon } from '@contentful/f36-icons';\n\nimport { ContentEntityType } from '../../types';\nimport * as styles from './styles';\n\nexport function MissingEntityCard(props: {\n entityType: ContentEntityType;\n asSquare?: boolean;\n isDisabled: boolean;\n onRemove?: Function;\n}) {\n return (\n <Card className={styles.card} testId=\"cf-ui-missing-entry-card\">\n <Flex alignItems=\"center\" justifyContent=\"space-between\">\n <div className={props.asSquare ? styles.squareCard : ''}>\n <SectionHeading marginBottom=\"none\">\n {props.entityType} is missing or inaccessible\n </SectionHeading>\n </div>\n {!props.isDisabled && props.onRemove && (\n <IconButton\n variant=\"transparent\"\n icon={<CloseIcon variant=\"muted\" />}\n aria-label=\"Delete\"\n onClick={() => {\n props.onRemove && props.onRemove();\n }}\n />\n )}\n </Flex>\n </Card>\n );\n}\n","import { EditorPermissions } from '../../common/useEditorPermissions';\nimport { Asset, ContentType, ContentEntityType, Entry, FieldExtensionSDK } from '../../types';\n\nconst getContentTypeIds = (contentTypes: ContentType[]) => contentTypes.map((ct) => ct.sys.id);\n\nexport async function createEntity(props: {\n sdk: FieldExtensionSDK;\n entityType: ContentEntityType;\n contentTypeId?: string;\n}) {\n if (props.entityType === 'Entry') {\n if (!props.contentTypeId) {\n return {};\n }\n const { entity, slide } = await props.sdk.navigator.openNewEntry<Entry>(props.contentTypeId, {\n slideIn: true,\n });\n return { entity, slide };\n } else {\n const { entity, slide } = await props.sdk.navigator.openNewAsset({\n slideIn: true,\n });\n return { entity, slide };\n }\n}\n\nexport async function selectSingleEntity(props: {\n sdk: FieldExtensionSDK;\n entityType: ContentEntityType;\n editorPermissions: EditorPermissions;\n}) {\n if (props.entityType === 'Entry') {\n return await props.sdk.dialogs.selectSingleEntry<Entry>({\n locale: props.sdk.field.locale,\n contentTypes: getContentTypeIds(props.editorPermissions.readableContentTypes),\n });\n } else {\n return props.sdk.dialogs.selectSingleAsset<Asset>({\n locale: props.sdk.field.locale,\n mimetypeGroups: props.editorPermissions.validations.mimetypeGroups,\n });\n }\n}\n\nexport async function selectMultipleEntities(props: {\n sdk: FieldExtensionSDK;\n entityType: ContentEntityType;\n editorPermissions: EditorPermissions;\n}) {\n const value = props.sdk.field.getValue();\n\n const linkCount = Array.isArray(value) ? value.length : value ? 1 : 0;\n\n // TODO: Why not always set `min: 1` by default? Does it make sense to enforce\n // user to select as many entities as the field's \"min\" requires? What if e.g.\n // \"min\" is 4 and the user wants to insert 2 entities first, then create 2 new ones?\n const min = Math.max(\n (props.editorPermissions.validations.numberOfLinks?.min || 1) - linkCount,\n 1\n );\n // TODO: Consider same for max. If e.g. \"max\" is 4, we disable the button if the\n // user wants to select 5 but we show no information why the button is disabled.\n const max = (props.editorPermissions.validations.numberOfLinks?.max || +Infinity) - linkCount;\n\n if (props.entityType === 'Entry') {\n return await props.sdk.dialogs.selectMultipleEntries<Entry>({\n locale: props.sdk.field.locale,\n contentTypes: getContentTypeIds(props.editorPermissions.readableContentTypes),\n min,\n max,\n });\n } else {\n return props.sdk.dialogs.selectMultipleAssets<Asset>({\n locale: props.sdk.field.locale,\n mimetypeGroups: props.editorPermissions.validations.mimetypeGroups,\n min,\n max,\n });\n }\n}\n","import * as React from 'react';\nimport { useMemo } from 'react';\n\nimport { EditorPermissions } from '../../common/useEditorPermissions';\nimport {\n Action,\n ActionLabels,\n ContentEntityType,\n FieldExtensionSDK,\n Entry,\n Asset,\n NavigatorSlideInfo,\n} from '../../types';\nimport { CombinedLinkActions } from './CombinedLinkActions';\nimport { createEntity, selectMultipleEntities, selectSingleEntity } from './helpers';\nimport { LinkActions, LinkActionsProps } from './LinkActions';\n\ntype LinkEntityActionsProps = {\n entityType: ContentEntityType;\n canLinkMultiple: boolean;\n sdk: FieldExtensionSDK;\n isDisabled: boolean;\n editorPermissions: EditorPermissions;\n onCreate: (id: string, index?: number) => void;\n onLink: (ids: string[], index?: number) => void;\n onAction?: (action: Action) => void;\n actionLabels?: Partial<ActionLabels>;\n itemsLength?: number;\n};\n\nexport function useLinkActionsProps(props: LinkEntityActionsProps): LinkActionsProps {\n const {\n sdk,\n editorPermissions,\n entityType,\n canLinkMultiple,\n isDisabled,\n actionLabels,\n itemsLength,\n } = props;\n\n const maxLinksCount = editorPermissions.validations.numberOfLinks?.max;\n const value = sdk.field.getValue();\n const linkCount = Array.isArray(value) ? value.length : value ? 1 : 0;\n const isFull = !!maxLinksCount && maxLinksCount <= linkCount;\n const isEmpty = linkCount === 0;\n\n const onCreated = React.useCallback(\n (entity: Entry | Asset, index = itemsLength, slide?: NavigatorSlideInfo) => {\n props.onCreate(entity.sys.id, index);\n props.onAction &&\n props.onAction({\n type: 'create_and_link',\n entity: entityType,\n entityData: entity,\n slide,\n index,\n });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies\n [entityType, props.onCreate, props.onAction]\n );\n const onLinkedExisting = React.useCallback(\n (entities: Array<Entry | Asset>, index = itemsLength) => {\n props.onLink(\n entities.map((item) => item.sys.id),\n index\n );\n entities.forEach((entity, i) => {\n props.onAction &&\n props.onAction({\n type: 'select_and_link',\n entity: entityType,\n entityData: entity,\n index: index === undefined ? undefined : index + i,\n });\n });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies\n [entityType, props.onLink, props.onAction]\n );\n\n const onCreate = React.useCallback(\n async (contentTypeId?: string, index?: number) => {\n const { entity, slide } = await createEntity({ sdk, entityType, contentTypeId });\n if (!entity) {\n return;\n }\n\n onCreated(entity, index, slide);\n },\n [sdk, entityType, onCreated]\n );\n\n const onLinkExisting = React.useCallback(\n async (index?: number) => {\n const entity = await selectSingleEntity({\n sdk,\n entityType,\n editorPermissions,\n });\n if (!entity) {\n return;\n }\n\n onLinkedExisting([entity], index);\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies\n [sdk, entityType, onLinkedExisting]\n );\n\n const onLinkSeveralExisting = React.useCallback(\n async (index?: number) => {\n const entities = await selectMultipleEntities({\n sdk,\n entityType,\n editorPermissions,\n });\n\n if (!entities || entities.length === 0) {\n return;\n }\n onLinkedExisting(entities, index);\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies\n [sdk, entityType, onLinkedExisting]\n );\n\n // FIXME: The memoization might rerun every time due to the always changing callback identities above\n return useMemo(\n () => ({\n entityType,\n canLinkMultiple,\n isDisabled,\n isEmpty,\n isFull,\n canCreateEntity: editorPermissions.canCreateEntity,\n canLinkEntity: editorPermissions.canLinkEntity,\n contentTypes: editorPermissions.creatableContentTypes,\n onCreate,\n onLinkExisting: canLinkMultiple ? onLinkSeveralExisting : onLinkExisting,\n actionLabels,\n onCreated,\n onLinkedExisting,\n itemsLength,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies\n [\n entityType,\n canLinkMultiple,\n isDisabled,\n isEmpty,\n isFull,\n editorPermissions.canCreateEntity,\n editorPermissions.canLinkEntity,\n actionLabels,\n // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies\n editorPermissions.creatableContentTypes.map((ct) => ct.sys.id).join(':'),\n onCreate,\n onLinkExisting,\n onLinkSeveralExisting,\n onCreated,\n onLinkedExisting,\n itemsLength,\n ]\n );\n}\n\nexport function LinkEntityActions({\n renderCustomActions,\n ...props\n}: LinkActionsProps & {\n renderCustomActions?: (props: LinkActionsProps) => React.ReactElement;\n}) {\n return renderCustomActions ? renderCustomActions(props) : <LinkActions {...props} />;\n}\n\nexport function CombinedLinkEntityActions({\n renderCustomActions,\n ...props\n}: LinkActionsProps & {\n renderCustomActions?: (props: LinkActionsProps) => React.ReactElement;\n}) {\n return renderCustomActions ? renderCustomActions(props) : <CombinedLinkActions {...props} />;\n}\n","// eslint-disable-next-line -- TODO: describe this disable no-restricted-imports\nimport moment from 'moment';\n\ntype DateFormatFn = (date: Date | string, short?: boolean) => string;\n\n/**\n * @param {Date|string} date A valid constructor argument for moment()\n * @param {boolean=} short Render only Today/Tomorrow/Yesterday if valid. Defaults to false\n */\nexport const formatDate: DateFormatFn = (date, short) => {\n switch (moment().startOf('day').diff(moment(date).startOf('day'), 'days')) {\n case 0:\n return short ? 'Today' : `Today, ${moment(date).format('DD MMM YYYY')}`;\n case -1:\n return short ? 'Tomorrow' : `Tomorrow, ${moment(date).format('DD MMM YYYY')}`;\n case 1:\n return short ? 'Yesterday' : `Yesterday, ${moment(date).format('DD MMM YYYY')}`;\n default:\n return moment(date).format('ddd, DD MMM YYYY');\n }\n};\n\n/**\n * Returns the time portion of a date in the local time in the format H:MM AM/PM\n *\n * == Examples\n * * `T15:36:45.000Z` => 3:36 PM (if in +0:00 offset)\n */\nexport const formatTime: DateFormatFn = (date) => {\n return moment.utc(date).local().format('h:mm A');\n};\n\nexport const formatDateAndTime: DateFormatFn = (date, short) => {\n return `${formatDate(date, short)} at ${formatTime(date)}`;\n};\n","import React from 'react';\n\nimport { ScheduledAction } from '@contentful/app-sdk';\nimport { Tooltip } from '@contentful/f36-components';\n\nimport { formatDateAndTime } from './formatDateAndTime';\n\nexport const getScheduleTooltipContent = ({\n job,\n jobsCount,\n}: {\n job: ScheduledAction;\n jobsCount: number;\n}) => {\n return `Will ${job.action.toLowerCase()} ${formatDateAndTime(\n job.scheduledFor.datetime\n ).toLowerCase()}\n ${jobsCount > 1 ? `+ ${jobsCount - 1} more` : ''}`;\n};\n\nexport const ScheduleTooltip = ({\n job,\n jobsCount,\n children,\n}: {\n job: ScheduledAction;\n jobsCount: number;\n children: React.ReactElement;\n}) => {\n return (\n <Tooltip\n placement=\"top\"\n testId={job.sys.id}\n as=\"div\"\n content={getScheduleTooltipContent({ job, jobsCount })}>\n {children}\n </Tooltip>\n );\n};\n","import React from 'react';\n\nimport { SpaceAPI, ScheduledAction } from '@contentful/app-sdk';\n\nimport { ScheduleTooltip } from './ScheduleTooltip';\n\ntype ScheduledIconWithTooltipProps = {\n getEntityScheduledActions: SpaceAPI['getEntityScheduledActions'];\n entityType: 'Entry' | 'Asset';\n entityId: string;\n children: React.ReactElement;\n};\n\nexport const ScheduledIconWithTooltip = ({\n entityType,\n entityId,\n getEntityScheduledActions,\n children,\n}: ScheduledIconWithTooltipProps) => {\n const [status, setStatus] = React.useState<\n | { type: 'loading' }\n | { type: 'error'; error: Error }\n | { type: 'loaded'; jobs: ScheduledAction[] }\n >({ type: 'loading' });\n\n React.useEffect(() => {\n getEntityScheduledActions(entityType, entityId)\n .then((data) => {\n setStatus({ type: 'loaded', jobs: data });\n })\n .catch((e) => {\n setStatus({ type: 'error', error: e });\n });\n // This should only be ever called once. Following the eslint hint to add used\n // dependencies will cause page freeze (infinite loop)\n // eslint-disable-next-line -- TODO: describe this disable\n }, []);\n\n if (status.type === 'loading' || status.type === 'error') {\n return null;\n }\n\n const jobs = status.jobs ?? [];\n\n if (jobs.length === 0) {\n return null;\n }\n\n const mostRelevantJob = jobs[0];\n\n return (\n <ScheduleTooltip job={mostRelevantJob} jobsCount={jobs.length}>\n {children}\n </ScheduleTooltip>\n );\n};\n","import React from 'react';\n\nimport { File } from '../../types';\n\ninterface AssetThumbnailProps {\n file: File;\n}\n\nconst dimensions = { width: 70, height: 70 };\n\nexport function AssetThumbnail(props: AssetThumbnailProps) {\n return (\n <img\n alt={props.file.fileName}\n src={`${props.file.url}?w=${dimensions.width}&h=${dimensions.height}&fit=thumb`}\n height={dimensions.height}\n width={dimensions.width}\n />\n );\n}\n","import React, { useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport { BaseExtensionSDK } from '@contentful/app-sdk';\nimport {\n FetchQueryOptions,\n Query,\n QueryCache,\n QueryClient,\n QueryClientProvider,\n QueryKey,\n useQuery,\n useQueryClient,\n} from '@tanstack/react-query';\nimport constate from 'constate';\nimport { createClient, PlainClientAPI } from 'contentful-management';\nimport PQueue from 'p-queue';\n\nimport {\n Asset,\n ContentType,\n Entry,\n Resource,\n ResourceType,\n Space,\n ScheduledAction,\n} from '../types';\n\nexport type ResourceInfo<R extends Resource = Resource> = {\n resource: R;\n defaultLocaleCode: string;\n contentType: ContentType;\n space: Space;\n};\n\n// global queue for all requests, the actual number is picked without scientific research\nconst globalQueue = new PQueue({ concurrency: 50 });\n\ntype EntityStoreProps = {\n sdk: BaseExtensionSDK;\n queryConcurrency?: number;\n};\n\ntype FetchService = ReturnType<typeof useFetch>;\n\ntype GetOptions = {\n priority?: number;\n};\n\ntype GetEntityOptions = GetOptions & {\n spaceId?: string;\n environmentId?: string;\n};\n\ntype UseEntityOptions = GetEntityOptions & { enabled?: boolean };\n\ntype QueryEntityResult<E> = Promise<E>;\n\ntype GetResourceOptions = GetOptions;\n\ntype QueryResourceResult<R extends Resource = Resource> = QueryEntityResult<ResourceInfo<R>>;\n\ntype UseResourceOptions = GetResourceOptions & { enabled?: boolean };\n\n// all types of the union share the data property to ease destructuring downstream\ntype UseEntityResult<E> =\n | { status: 'idle'; data: never }\n | { status: 'loading'; data: never }\n | { status: 'error'; data: never }\n | { status: 'success'; data: E };\n\ntype FetchFunction<TQueryData> = (context: { cmaClient: PlainClientAPI }) => Promise<TQueryData>;\ntype FetchServiceOptions<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey\n> = FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey> & GetOptions;\ntype FetchParams = { fetch: FetchService; urn: string; options?: GetOptions };\n\ntype FetchableEntityType = 'Entry' | 'Asset';\ntype FetchableEntity = Entry | Asset;\n\ntype EntityQueryKey = [\n entityType: FetchableEntityType,\n entityId: string,\n spaceId: string,\n environmentId: string\n];\n\ntype ScheduledActionsQueryKey = ['scheduled-actions', ...EntityQueryKey];\n\nexport class UnsupportedError extends Error {\n isUnsupportedError: boolean;\n constructor(message: string) {\n super(message);\n this.isUnsupportedError = true;\n }\n}\n\nexport function isUnsupportedError(value: unknown): value is UnsupportedError {\n return (\n typeof value === 'object' && (value as UnsupportedError | null)?.isUnsupportedError === true\n );\n}\n\nconst isEntityQueryKey = (queryKey: QueryKey): queryKey is EntityQueryKey => {\n return (\n Array.isArray(queryKey) &&\n (queryKey[0] === 'Entry' || queryKey[0] === 'Asset') &&\n queryKey.length === 4\n );\n};\n\ntype ResourceQueryKey = [ident: 'Resource', resourceType: ResourceType, urn: string];\n\nasync function fetchContentfulEntry(params: FetchParams): Promise<ResourceInfo<Entry>> {\n const { urn, fetch, options } = params;\n const resourceId = urn.split(':', 6)[5];\n const [, spaceId, , entryId] = resourceId.split('/');\n const environmentId = 'master';\n\n const [space, entry] = await Promise.all([\n fetch(['space', spaceId], ({ cmaClient }) => cmaClient.space.get({ spaceId }), options),\n fetch(\n ['entry', spaceId, environmentId, entryId],\n ({ cmaClient }) =>\n cmaClient.entry.get({\n spaceId,\n environmentId,\n entryId,\n }),\n options\n ),\n ]);\n const contentTypeId = entry.sys.contentType.sys.id;\n const [contentType, defaultLocaleCode] = await Promise.all([\n fetch(\n ['contentType', spaceId, environmentId, contentTypeId],\n ({ cmaClient }) =>\n cmaClient.contentType.get({\n contentTypeId,\n spaceId,\n environmentId,\n }),\n options\n ),\n fetch(\n ['defaultLocale', spaceId, environmentId],\n async ({ cmaClient }) => {\n const locales = await cmaClient.locale.getMany({\n spaceId,\n environmentId,\n query: { limit: 100 },\n });\n const defaultLocaleCode = locales.items.find((locale) => locale.default)?.code as string;\n return defaultLocaleCode;\n },\n options\n ),\n ]);\n\n return {\n defaultLocaleCode,\n resource: entry,\n space: space,\n contentType: contentType,\n };\n}\n\nconst [InternalServiceProvider, useFetch, useEntityLoader, useCurrentIds] = constate(\n function useInitServices(props: EntityStoreProps) {\n const currentSpaceId = props.sdk.ids.space;\n const currentEnvironmentId = props.sdk.ids.environmentAlias ?? props.sdk.ids.environment;\n const environmentIds = useMemo(\n () => [props.sdk.ids.environmentAlias, props.sdk.ids.environment],\n [props.sdk.ids.environmentAlias, props.sdk.ids.environment]\n );\n const queryClient = useQueryClient();\n const queryCache = queryClient.getQueryCache();\n const entityChangeUnsubscribers = useRef<Record<string, Function>>({});\n const cmaClient = useMemo(\n () => createClient({ apiAdapter: props.sdk.cmaAdapter }, { type: 'plain' }),\n [props.sdk.cmaAdapter]\n );\n const queryQueue = useMemo(() => {\n if (props.queryConcurrency) {\n return new PQueue({ concurrency: props.queryConcurrency });\n }\n\n return globalQueue;\n }, [props.queryConcurrency]);\n\n const fetch = useCallback(\n function fetch<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey\n >(\n queryKey: TQueryKey,\n fn: FetchFunction<TQueryFnData>,\n options: FetchServiceOptions<TQueryFnData, TError, TData, TQueryKey> = {}\n ) {\n const { priority, ...queryOptions } = options;\n return queryClient.fetchQuery(\n queryKey,\n () => queryQueue.add(() => fn({ cmaClient }), { priority }),\n queryOptions\n );\n },\n [queryClient, queryQueue, cmaClient]\n );\n\n const getEntity = useCallback(\n function getEntity<E extends FetchableEntity>(\n entityType: FetchableEntityType,\n entityId: string,\n options?: GetEntityOptions\n ): QueryEntityResult<E> {\n const spaceId = options?.spaceId ?? currentSpaceId;\n const environmentId = options?.environmentId ?? currentEnvironmentId;\n const queryKey: EntityQueryKey = [entityType, entityId, spaceId, environmentId];\n\n return fetch(\n queryKey,\n ({ cmaClient }) => {\n if (entityType === 'Entry') {\n return cmaClient.entry.get({ entryId: entityId, spaceId, environmentId });\n }\n\n if (entityType === 'Asset') {\n return cmaClient.asset.get({ assetId: entityId, spaceId, environmentId });\n }\n\n throw new UnsupportedError('Unsupported entity type');\n },\n options\n );\n },\n [fetch, currentSpaceId, currentEnvironmentId]\n );\n\n /**\n * Fetch all scheduled actions for a given entity.\n * This function fetches all schedules for all entries and then returns\n * a filtered result based on the entityID provided.\n *\n * The result is then reused/cached for subsequent calls to this function.\n */\n const getEntityScheduledActions = useCallback(\n function getEntityScheduledActions(\n entityType: FetchableEntityType,\n entityId: string,\n options?: GetEntityOptions\n ): QueryEntityResult<ScheduledAction[]> {\n // This is fixed to force the cache to reuse previous results\n const fixedEntityCacheId = 'scheduledActionEntityId';\n\n // A space+environment combo can only have up to 500 scheduled actions\n // With this request we fetch all schedules and can reuse the results.\n // See https://www.contentful.com/developers/docs/references/content-management-api/#/reference/scheduled-actions/limitations\n const maxScheduledActions = 500;\n const spaceId = options?.spaceId ?? currentSpaceId;\n const environmentId = options?.environmentId ?? currentEnvironmentId;\n const queryKey: ScheduledActionsQueryKey = [\n 'scheduled-actions',\n entityType,\n fixedEntityCacheId,\n spaceId,\n environmentId,\n ];\n\n // Fetch + Filter by entity ID in the end\n return fetch(\n queryKey,\n async ({ cmaClient }) => {\n const response = await cmaClient.scheduledActions.getMany({\n spaceId,\n query: {\n 'environment.sys.id': environmentId,\n 'sys.status[in]': 'scheduled',\n order: 'scheduledFor.datetime',\n limit: maxScheduledActions,\n },\n });\n\n return response.items;\n },\n options\n ).then((items) => items.filter((action) => action.entity.sys.id === entityId));\n },\n [fetch, currentSpaceId, currentEnvironmentId]\n );\n\n const getResource = useCallback(\n function getResource<R extends Resource = Resource>(\n resourceType: ResourceType,\n urn: string,\n options?: GetResourceOptions\n ): QueryResourceResult<R> {\n const queryKey: ResourceQueryKey = ['Resource', resourceType, urn];\n return fetch(\n queryKey,\n () => {\n if (resourceType === 'Contentful:Entry') {\n return fetchContentfulEntry({\n fetch,\n urn,\n options,\n });\n }\n\n throw new UnsupportedError('Unsupported resource type');\n },\n options\n );\n },\n [fetch]\n );\n\n const isSameSpaceEntityQueryKey = useCallback(\n (queryKey: QueryKey) => {\n const isEntityKey = isEntityQueryKey(queryKey);\n const isSameSpaceEntityKey =\n isEntityKey && queryKey[2] === currentSpaceId && environmentIds.includes(queryKey[3]);\n\n return isSameSpaceEntityKey;\n },\n [currentSpaceId, environmentIds]\n );\n // @ts-expect-error ...\n const onEntityChanged = props.sdk.space.onEntityChanged;\n const onSlideInNavigation = props.sdk.navigator.onSlideInNavigation;\n\n useEffect(() => {\n function findSameSpaceQueries(): Query[] {\n return queryCache.findAll({\n type: 'active',\n predicate: (query) => isSameSpaceEntityQueryKey(query.queryKey),\n });\n }\n\n if (typeof onEntityChanged !== 'function') {\n return onSlideInNavigation(({ oldSlideLevel, newSlideLevel }) => {\n if (oldSlideLevel > newSlideLevel) {\n findSameSpaceQueries().forEach((query) => {\n // automatically refetches the query\n void queryClient.invalidateQueries(query.queryKey);\n });\n }\n }) as { (): void };\n }\n\n const subscribeQuery = ({ queryKey, queryHash }: Query) => {\n const [entityType, entityId] = queryKey;\n entityChangeUnsubscribers.current[queryHash] = onEntityChanged(\n entityType,\n entityId,\n (data: unknown) => {\n queryClient.setQueryData(queryKey, data);\n }\n );\n };\n findSameSpaceQueries().forEach(subscribeQuery);\n\n const unsubscribe = queryCache.subscribe((event) => {\n if (!event) {\n return;\n }\n\n const { type, query } = event;\n const { queryKey, queryHash } = query;\n\n if (!isSameSpaceEntityQueryKey(queryKey)) {\n return;\n }\n\n if (type === 'added') {\n subscribeQuery(query);\n }\n\n if (type === 'removed') {\n // calling unsubscribe\n entityChangeUnsubscribers.current[queryHash]?.();\n }\n });\n\n return () => {\n unsubscribe();\n Object.values(entityChangeUnsubscribers.current).forEach((off) => off());\n entityChangeUnsubscribers.current = {};\n };\n }, [\n onEntityChanged,\n queryCache,\n isSameSpaceEntityQueryKey,\n queryClient,\n getEntity,\n onSlideInNavigation,\n ]);\n\n return {\n ids: props.sdk.ids,\n cmaClient,\n fetch,\n getResource,\n getEntity,\n getEntityScheduledActions,\n };\n },\n ({ fetch }) => fetch,\n ({ getResource, getEntity, getEntityScheduledActions }) => ({\n getResource,\n getEntity,\n getEntityScheduledActions,\n }),\n ({ ids }) => ({\n environment: ids.environmentAlias ?? ids.environment,\n space: ids.space,\n })\n);\n\nexport function useEntity<E extends FetchableEntity>(\n entityType: FetchableEntityType,\n entityId: string,\n options?: UseEntityOptions\n): UseEntityResult<E> {\n const { space, environment } = useCurrentIds();\n const { getEntity } = useEntityLoader();\n const queryKey: EntityQueryKey = [\n entityType,\n entityId,\n options?.spaceId ?? space,\n options?.environmentId ?? environment,\n ];\n const { status, data } = useQuery(queryKey, () => getEntity(entityType, entityId, options), {\n enabled: options?.enabled,\n });\n return { status, data } as UseEntityResult<E>;\n}\n\nexport function useResource(resourceType: ResourceType, urn: string, options?: UseResourceOptions) {\n const queryKey: ResourceQueryKey = ['Resource', resourceType, urn];\n const { getResource } = useEntityLoader();\n const { status, data, error } = useQuery(\n queryKey,\n () => getResource(resourceType, urn, options),\n {\n enabled: options?.enabled,\n }\n );\n return { status, data, error };\n}\n\nfunction EntityProvider({ children, ...props }: React.PropsWithChildren<EntityStoreProps>) {\n const reactQueryClient = useMemo(() => {\n const queryCache = new QueryCache();\n const queryClient = new QueryClient({\n queryCache,\n defaultOptions: {\n queries: {\n useErrorBoundary: false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: true,\n refetchOnMount: false,\n staleTime: Infinity,\n retry: false,\n },\n },\n });\n\n return queryClient;\n }, []);\n\n return (\n <QueryClientProvider client={reactQueryClient}>\n <InternalServiceProvider {...props}>{children}</InternalServiceProvider>\n </QueryClientProvider>\n );\n}\n\nexport { EntityProvider, useEntityLoader };\n","import * as React from 'react';\n\nimport { FieldConnector } from '@contentful/field-editor-shared';\nimport deepEqual from 'deep-equal';\n\nimport type { LinkActionsProps } from '../components';\nimport { Action, ActionLabels, FieldExtensionSDK, ViewType } from '../types';\nimport { CustomCardRenderer, RenderCustomMissingEntityCard } from './customCardTypes';\nimport { EntityProvider } from './EntityStore';\n\n// TODO: Rename common base for reference/media editors to something neutral,\n// e.g. `LinkEditor<T>`.\n\nexport interface ReferenceEditorProps {\n /**\n * Whether or not the field should be disabled initially.\n */\n isInitiallyDisabled: boolean;\n hasCardEditActions: boolean;\n hasCardMoveActions?: boolean;\n hasCardRemoveActions?: boolean;\n sdk: FieldExtensionSDK;\n viewType: ViewType;\n renderCustomCard?: CustomCardRenderer;\n renderCustomActions?: (props: CustomActionProps) => React.ReactElement;\n renderCustomMissingEntityCard?: RenderCustomMissingEntityCard;\n getEntityUrl?: (entryId: string) => string;\n onAction?: (action: Action) => void;\n actionLabels?: Partial<ActionLabels>;\n parameters: {\n instance: {\n showCreateEntityAction?: boolean;\n showLinkEntityAction?: boolean;\n bulkEditing?: boolean;\n };\n };\n updateBeforeSortStart?: ({ index }: { index: number }) => void;\n onSortingEnd?: ({ oldIndex, newIndex }: { oldIndex: number; newIndex: number }) => void;\n}\n\nexport type CustomActionProps = LinkActionsProps;\n\nexport function ReferenceEditor<T>(\n props: ReferenceEditorProps & {\n children: FieldConnector<T>['props']['children'];\n }\n) {\n return (\n <EntityProvider sdk={props.sdk}>\n <FieldConnector<T>\n throttle={0}\n field={props.sdk.field}\n isInitiallyDisabled={props.isInitiallyDisabled}\n isEqualValues={(value1, value2) => {\n return deepEqual(value1, value2);\n }}\n >\n {props.children}\n </FieldConnector>\n </EntityProvider>\n );\n}\n\nReferenceEditor.defaultProps = {\n isInitiallyDisabled: true,\n hasCardEditActions: true,\n};\n","import type {\n AccessAPI,\n ArchiveableAction,\n CrudAction,\n PublishableAction,\n} from '@contentful/app-sdk';\n\ntype EntryAction = CrudAction | PublishableAction | ArchiveableAction;\n\ntype ExtendedAccessAPI = {\n canPerformActionOnEntryOfType: (action: EntryAction, contentTypeId: string) => Promise<boolean>;\n};\n\nconst AllowActionsOnContentType: ExtendedAccessAPI['canPerformActionOnEntryOfType'] = () =>\n Promise.resolve(true);\n\nexport function useAccessApi(accessApi: AccessAPI & Partial<ExtendedAccessAPI>) {\n const canPerformAction = accessApi.can;\n const canPerformActionOnEntryOfType =\n accessApi.canPerformActionOnEntryOfType ?? AllowActionsOnContentType;\n\n return { canPerformAction, canPerformActionOnEntryOfType };\n}\n","import { useEffect, useMemo, useState } from 'react';\n\nimport { ContentType, ContentEntityType, FieldExtensionSDK } from '../types';\nimport { fromFieldValidations } from '../utils/fromFieldValidations';\nimport { ReferenceEditorProps } from './ReferenceEditor';\nimport { useAccessApi } from './useAccessApi';\nimport { useContentTypePermissions } from './useContentTypePermissions';\n\nexport type EditorPermissionsProps = {\n sdk: FieldExtensionSDK;\n entityType: ContentEntityType;\n parameters: ReferenceEditorProps['parameters'];\n allContentTypes: ContentType[];\n};\n\nexport function useEditorPermissions(props: EditorPermissionsProps) {\n const { sdk, entityType, parameters } = props;\n const validations = useMemo(() => fromFieldValidations(props.sdk.field), [props.sdk.field]);\n const [canCreateEntity, setCanCreateEntity] = useState(true);\n const [canLinkEntity, setCanLinkEntity] = useState(true);\n const { creatableContentTypes, readableContentTypes, availableContentTypes } =\n useContentTypePermissions({ ...props, validations });\n const { canPerformAction } = useAccessApi(sdk.access);\n\n useEffect(() => {\n if (parameters.instance.showCreateEntityAction === false) {\n setCanCreateEntity(false);\n return;\n }\n\n async function checkCreateAccess() {\n if (entityType === 'Asset') {\n // Hardcoded `true` value following https://contentful.atlassian.net/browse/DANTE-486\n // TODO: refine permissions check in order to account for tags in rules\n const canCreate = (await canPerformAction('create', 'Asset')) || true;\n setCanCreateEntity(canCreate);\n }\n if (entityType === 'Entry') {\n // Hardcoded `true` value following https://contentful.atlassian.net/browse/DANTE-486\n // TODO: refine permissions check in order to account for tags in rules\n const canCreate = creatableContentTypes.length > 0 || true;\n setCanCreateEntity(canCreate);\n }\n }\n\n void checkCreateAccess();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies\n }, [entityType, parameters.instance, creatableContentTypes]);\n\n useEffect(() => {\n if (parameters.instance.showLinkEntityAction === false) {\n setCanLinkEntity(false);\n return;\n }\n\n async function checkLinkAccess() {\n if (entityType === 'Asset') {\n // Hardcoded `true` value following https://contentful.atlassian.net/browse/DANTE-486\n // TODO: refine permissions check in order to account for tags in rules\n const canRead = (await canPerformAction('read', 'Asset')) || true;\n setCanLinkEntity(canRead);\n }\n if (entityType === 'Entry') {\n // Hardcoded `true` value following https://contentful.atlassian.net/browse/DANTE-486\n // TODO: refine permissions check in order to account for tags in rules\n // TODO: always show every content type (it's just a filter) to avoid people not seeing\n // their (partly limited) content types\n const canRead = true;\n setCanLinkEntity(canRead);\n }\n }\n\n void checkLinkAccess();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies\n }, [entityType, parameters.instance, readableContentTypes]);\n\n return {\n canCreateEntity,\n canLinkEntity,\n creatableContentTypes,\n readableContentTypes,\n availableContentTypes,\n validations,\n };\n}\n\nexport type EditorPermissions = ReturnType<typeof useEditorPermissions>;\n","import { FieldAPI } from '@contentful/app-sdk';\nimport isNumber from 'lodash/isNumber';\n\ntype NumberOfLinksValidation =\n | { type: 'min-max'; min: number; max: number }\n | { type: 'min'; min: number; max: undefined }\n | { type: 'max'; max: number; min: undefined };\n\nexport type ReferenceValidations = {\n contentTypes?: string[];\n mimetypeGroups?: string[];\n numberOfLinks?: NumberOfLinksValidation;\n};\n\nexport function fromFieldValidations(field: FieldAPI): ReferenceValidations {\n // eslint-disable-next-line -- TODO: describe this disable @typescript-eslint/no-explicit-any\n const validations: Record<string, any>[] = [\n ...field.validations,\n ...(field.items?.validations ?? []),\n ];\n const linkContentTypeValidations = validations.find((v) => 'linkContentType' in v);\n const linkMimetypeGroupValidations = validations.find((v) => 'linkMimetypeGroup' in v);\n const sizeValidations = validations.find((v) => 'size' in v);\n const size = (sizeValidations && sizeValidations.size) || {};\n const min = size.min;\n const max = size.max;\n\n let numberOfLinks: NumberOfLinksValidation | undefined = undefined;\n\n if (isNumber(min) && isNumber(max)) {\n numberOfLinks = {\n type: 'min-max',\n min,\n max,\n };\n } else if (isNumber(min)) {\n numberOfLinks = {\n type: 'min',\n min,\n max: undefined,\n };\n } else if (isNumber(max)) {\n numberOfLinks = {\n type: 'max',\n max,\n min: undefined,\n };\n }\n\n const result: ReferenceValidations = {\n contentTypes: linkContentTypeValidations?.linkContentType ?? undefined,\n mimetypeGroups: linkMimetypeGroupValidations?.linkMimetypeGroup ?? undefined,\n numberOfLinks,\n // todo: there are multiple BE problems that need to be solved first, for now we don't want to apply size constraints\n // linkedFileSize: findValidation(field, 'assetFileSize', {}),\n // linkedImageDimensions: findValidation(field, 'assetImageDimensions', {})\n };\n\n return result;\n}\n","import { useEffect, useMemo, useState } from 'react';\n\nimport { ContentType, ContentEntityType, FieldExtensionSDK } from '../types';\nimport { ReferenceValidations } from '../utils/fromFieldValidations';\nimport { ReferenceEditorProps } from './ReferenceEditor';\nimport { useAccessApi } from './useAccessApi';\n\ntype ContentTypePermissionsProps = {\n sdk: FieldExtensionSDK;\n entityType: ContentEntityType;\n parameters: ReferenceEditorProps['parameters'];\n allContentTypes: ContentType[];\n validations: ReferenceValidations;\n};\n\ntype ContentTypePermissions = {\n creatableContentTypes: ContentType[];\n readableContentTypes: ContentType[];\n availableContentTypes: ContentType[];\n};\n\nasync function filter<T, S extends T>(arr: T[], predicate: (value: T) => Promise<boolean>) {\n // intentionally parallel as we assume it's cached in the implementation of the access api\n const fail = Symbol();\n const results = await Promise.all(\n arr.map(async (item) => ((await predicate(item)) ? item : fail))\n );\n\n return results.filter((x) => x !== fail) as S[];\n}\n\nexport function useContentTypePermissions(\n props: ContentTypePermissionsProps\n): ContentTypePermissions {\n const availableContentTypes = useMemo(() => {\n if (props.entityType === 'Asset') {\n return [];\n }\n\n if (props.validations.contentTypes) {\n return props.allContentTypes.filter((ct) =>\n props.validations.contentTypes?.includes(ct.sys.id)\n );\n }\n\n return props.allContentTypes;\n }, [props.allContentTypes, props.validations.contentTypes, props.entityType]);\n const [creatableContentTypes, setCreatableContentTypes] = useState(availableContentTypes);\n const [readableContentTypes, setReadableContentTypes] = useState(availableContentTypes);\n const { canPerformActionOnEntryOfType } = useAccessApi(props.sdk.access);\n\n useEffect(() => {\n function getContentTypes(action: 'create' | 'read') {\n return filter(availableContentTypes, (ct) =>\n canPerformActionOnEntryOfType(action, ct.sys.id)\n );\n }\n\n async function checkContentTypeAccess() {\n const creatable = await getContentTypes('create');\n const readable = await getContentTypes('read');\n setCreatableContentTypes(creatable);\n setReadableContentTypes(readable);\n }\n\n void checkContentTypeAccess();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies\n }, [availableContentTypes]);\n\n return {\n creatableContentTypes,\n readableContentTypes,\n availableContentTypes,\n };\n}\n","import * as React from 'react';\nimport { useCallback } from 'react';\n\nimport { LinkEntityActions } from '../components';\nimport { useLinkActionsProps } from '../components/LinkActions/LinkEntityActions';\nimport { ContentType, ContentEntityType, ReferenceValue } from '../types';\nimport { CustomEntityCardProps } from './customCardTypes';\nimport { ReferenceEditor, ReferenceEditorProps } from './ReferenceEditor';\nimport { useEditorPermissions } from './useEditorPermissions';\n\ntype ChildProps = {\n entityId: string;\n entityType: ContentEntityType;\n isDisabled: boolean;\n setValue: (value: ReferenceValue | null | undefined) => void;\n allContentTypes: ContentType[];\n renderCustomCard?: ReferenceEditorProps['renderCustomCard'];\n hasCardEditActions: boolean;\n hasCardRemoveActions?: boolean;\n};\n\ntype EditorProps = ReferenceEditorProps &\n ChildProps & {\n children: (props: ReferenceEditorProps & ChildProps) => React.ReactElement;\n };\n\nfunction Editor(props: EditorProps) {\n const { setValue, entityType } = props;\n const editorPermissions = useEditorPermissions(props);\n\n const onCreate = useCallback(\n (id: string) => void setValue({ sys: { type: 'Link', linkType: entityType, id } }),\n [setValue, entityType]\n );\n const onLink = useCallback(\n (ids: string[]) => {\n const [id] = ids;\n setValue({ sys: { type: 'Link', linkType: entityType, id } });\n },\n [setValue, entityType]\n );\n\n const linkActionsProps = useLinkActionsProps({\n ...props,\n canLinkMultiple: false,\n editorPermissions,\n onCreate,\n onLink,\n });\n // Inject card actions props into the given custom card renderer\n const customCardRenderer = useCallback(\n (cardProps: CustomEntityCardProps, _, renderDefaultCard) =>\n props.renderCustomCard\n ? props.renderCustomCard(cardProps, linkActionsProps, renderDefaultCard)\n : false,\n // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies\n [linkActionsProps]\n );\n\n if (!props.entityId) {\n return (\n <LinkEntityActions renderCustomActions={props.renderCustomActions} {...linkActionsProps} />\n );\n }\n\n return props.children({\n ...props,\n renderCustomCard: props.renderCustomCard && customCardRenderer,\n });\n}\n\nexport function SingleReferenceEditor(\n props: ReferenceEditorProps & {\n entityType: ContentEntityType;\n children: (props: ChildProps) => React.ReactElement;\n }\n) {\n const allContentTypes = props.sdk.space.getCachedContentTypes();\n\n return (\n <ReferenceEditor<ReferenceValue> {...props}>\n {({ value, setValue, disabled, externalReset }) => {\n return (\n <Editor\n {...props}\n key={`${externalReset}-reference`}\n entityId={value ? value.sys.id : ''}\n isDisabled={disabled}\n setValue={setValue}\n allContentTypes={allContentTypes}\n />\n );\n }}\n </ReferenceEditor>\n );\n}\n\nSingleReferenceEditor.defaultProps = {\n hasCardEditActions: true,\n hasCardRemoveActions: true,\n};\n","import * as React from 'react';\n\nimport { Flex, Text, Tooltip } from '@contentful/f36-components';\nimport { FolderOpenTrimmedIcon } from '@contentful/f36-icons';\nimport tokens from '@contentful/f36-tokens';\nimport { css } from 'emotion';\n\ninterface SpaceNameProps {\n spaceName: string;\n}\n\nconst styles = {\n spaceIcon: css({\n flexShrink: 0,\n fill: tokens.purple600,\n }),\n spaceName: css({\n color: tokens.gray700,\n fontSize: tokens.fontSizeS,\n fontWeight: tokens.fontWeightDemiBold,\n maxWidth: '80px',\n textOverflow: 'ellipsis',\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n }),\n};\n\nexport function SpaceName(props: SpaceNameProps) {\n return (\n <Tooltip placement=\"top\" as=\"div\" content={`Space: ${props.spaceName}`}>\n <Flex alignItems=\"center\" gap=\"spacingXs\" marginRight=\"spacingS\">\n <FolderOpenTrimmedIcon className={styles.spaceIcon} size=\"tiny\" aria-label=\"Source space\" />\n <Text className={styles.spaceName}>{props.spaceName}</Text>\n </Flex>\n </Tooltip>\n );\n}\n","import * as React from 'react';\n\nimport { SpaceAPI } from '@contentful/app-sdk';\nimport { EntryCard, MenuItem, MenuDivider } from '@contentful/f36-components';\nimport { ClockIcon } from '@contentful/f36-icons';\nimport tokens from '@contentful/f36-tokens';\nimport { entityHelpers, isValidImage } from '@contentful/field-editor-shared';\nimport { css } from 'emotion';\n\nimport { AssetThumbnail, MissingEntityCard, ScheduledIconWithTooltip } from '../../components';\nimport { SpaceName } from '../../components/SpaceName/SpaceName';\nimport { ContentType, Entry, File, RenderDragFn } from '../../types';\n\nconst { getEntryTitle, getEntityDescription, getEntryStatus, getEntryImage } = entityHelpers;\n\nconst styles = {\n scheduleIcon: css({\n marginRight: tokens.spacing2Xs,\n }),\n};\n\nexport interface WrappedEntryCardProps {\n getEntityScheduledActions: SpaceAPI['getEntityScheduledActions'];\n getAsset: (assetId: string) => Promise<unknown>;\n entryUrl?: string;\n size: 'small' | 'default' | 'auto';\n isDisabled: boolean;\n isSelected?: boolean;\n onRemove?: () => void;\n onEdit?: () => void;\n onClick?: (e: React.MouseEvent<HTMLElement>) => void;\n localeCode: string;\n defaultLocaleCode: string;\n contentType?: ContentType;\n spaceName?: string;\n entry: Entry;\n renderDragHandle?: RenderDragFn;\n isClickable?: boolean;\n onMoveTop?: () => void;\n onMoveBottom?: () => void;\n hasCardEditActions: boolean;\n hasCardMoveActions?: boolean;\n hasCardRemoveActions?: boolean;\n}\n\nconst defaultProps = {\n isClickable: true,\n hasCardEditActions: true,\n hasCardMoveActions: true,\n hasCardRemoveActions: true,\n};\n\nexport function WrappedEntryCard(props: WrappedEntryCardProps) {\n const [file, setFile] = React.useState<null | File>(null);\n\n const { contentType } = props;\n\n React.useEffect(() => {\n if (props.entry) {\n getEntryImage(\n {\n entry: props.entry,\n contentType,\n localeCode: props.localeCode,\n defaultLocaleCode: props.defaultLocaleCode,\n },\n props.getAsset\n )\n .then((file) => {\n setFile(file);\n })\n .catch(() => {\n setFile(null);\n });\n }\n }, [props.entry, props.getAsset, contentType, props.localeCode, props.defaultLocaleCode]);\n\n const status = getEntryStatus(props.entry?.sys);\n\n if (status === 'deleted') {\n return (\n <MissingEntityCard\n entityType=\"Entry\"\n isDisabled={props.isDisabled}\n onRemove={props.onRemove}\n />\n );\n }\n\n const title = getEntryTitle({\n entry: props.entry,\n contentType,\n localeCode: props.localeCode,\n defaultLocaleCode: props.defaultLocaleCode,\n defaultTitle: 'Untitled',\n });\n\n const description = getEntityDescription({\n entity: props.entry,\n contentType,\n localeCode: props.localeCode,\n defaultLocaleCode: props.defaultLocaleCode,\n });\n\n return (\n <EntryCard\n as={props.entryUrl ? 'a' : 'article'}\n href={props.entryUrl}\n title={title}\n description={description}\n contentType={contentType?.name}\n size={props.size}\n isSelected={props.isSelected}\n status={status}\n icon={\n props.spaceName ? (\n <SpaceName spaceName={props.spaceName} />\n ) : (\n <ScheduledIconWithTooltip\n getEntityScheduledActions={props.getEntityScheduledActions}\n entityType=\"Entry\"\n entityId={props.entry.sys.id}>\n <ClockIcon\n className={styles.scheduleIcon}\n size=\"small\"\n variant=\"muted\"\n testId=\"schedule-icon\"\n />\n </ScheduledIconWithTooltip>\n )\n }\n thumbnailElement={file && isValidImage(file) ? <AssetThumbnail file={file} /> : undefined}\n dragHandleRender={props.renderDragHandle}\n withDragHandle={!!props.renderDragHandle}\n actions={\n props.onEdit || props.onRemove\n ? [\n props.hasCardEditActions && props.onEdit ? (\n <MenuItem\n key=\"edit\"\n testId=\"edit\"\n onClick={() => {\n props.onEdit && props.onEdit();\n }}>\n Edit\n </MenuItem>\n ) : null,\n props.hasCardRemoveActions && props.onRemove ? (\n <MenuItem\n key=\"delete\"\n testId=\"delete\"\n onClick={() => {\n props.onRemove && props.onRemove();\n }}>\n Remove\n </MenuItem>\n ) : null,\n props.hasCardMoveActions && (props.onMoveTop || props.onMoveBottom) ? (\n <MenuDivider key=\"divider\" />\n ) : null,\n props.hasCardMoveActions && props.onMoveTop ? (\n <MenuItem\n key=\"move-top\"\n onClick={() => props.onMoveTop && props.onMoveTop()}\n testId=\"move-top\">\n Move to top\n </MenuItem>\n ) : null,\n props.hasCardMoveActions && props.onMoveBottom ? (\n <MenuItem\n key=\"move-bottom\"\n onClick={() => props.onMoveBottom && props.onMoveBottom()}\n testId=\"move-bottom\">\n Move to bottom\n </MenuItem>\n ) : null,\n ].filter((item) => item)\n : []\n }\n onClick={\n // Providing an onClick handler messes up with some rich text\n // features e.g. pressing ENTER on a card to add a new paragraph\n // underneath. It's crucial not to pass a custom handler when\n // isClickable is disabled which in the case of RT it's.\n props.isClickable\n ? (e: React.MouseEvent<HTMLElement>) => {\n e.preventDefault();\n if (props.onClick) return props.onClick(e);\n props.onEdit && props.onEdit();\n }\n : undefined\n }\n />\n );\n}\n\nWrappedEntryCard.defaultProps = defaultProps;\n","import * as React from 'react';\n\nimport { EntryCard } from '@contentful/f36-components';\nimport get from 'lodash/get';\n\nimport { CustomEntityCardProps, RenderCustomMissingEntityCard } from '../../common/customCardTypes';\nimport { useEntity, useEntityLoader } from '../../common/EntityStore';\nimport { ReferenceEditorProps } from '../../common/ReferenceEditor';\nimport { MissingEntityCard } from '../../components';\nimport type { LinkActionsProps } from '../../components';\nimport {\n ContentType,\n FieldExtensionSDK,\n NavigatorSlideInfo,\n RenderDragFn,\n Entry,\n} from '../../types';\nimport { WrappedEntryCard, WrappedEntryCardProps } from './WrappedEntryCard';\n\nexport type EntryCardReferenceEditorProps = ReferenceEditorProps & {\n entryId: string;\n index?: number;\n allContentTypes: ContentType[];\n isDisabled: boolean;\n onRemove: () => void;\n renderDragHandle?: RenderDragFn;\n hasCardEditActions: boolean;\n onMoveTop?: () => void;\n onMoveBottom?: () => void;\n renderCustomMissingEntityCard?: RenderCustomMissingEntityCard;\n isBeingDragged?: boolean;\n};\n\nasync function openEntry(\n sdk: FieldExtensionSDK,\n entryId: string,\n options: { bulkEditing?: boolean; index?: number }\n) {\n let slide: NavigatorSlideInfo | undefined;\n\n if (options.bulkEditing) {\n try {\n const result = await sdk.navigator.openBulkEditor(sdk.entry.getSys().id, {\n fieldId: sdk.field.id,\n locale: sdk.field.locale,\n index: options.index ?? 0,\n });\n slide = result.slide;\n return slide;\n } catch (e) {\n // we don't allow to open multiple bulk editors for performance reasons\n // proceed with a default openEntry\n }\n }\n\n const result = await sdk.navigator.openEntry(entryId, {\n slideIn: true,\n });\n slide = result.slide;\n\n return slide;\n}\n\nexport function FetchingWrappedEntryCard(props: EntryCardReferenceEditorProps) {\n const { data: entry, status } = useEntity<Entry>('Entry', props.entryId);\n const { getEntityScheduledActions } = useEntityLoader();\n const loadEntityScheduledActions = React.useCallback(\n () => getEntityScheduledActions('Entry', props.entryId),\n [getEntityScheduledActions, props.entryId]\n );\n\n const size = props.viewType === 'link' ? 'small' : 'default';\n const { getEntity } = useEntityLoader();\n const getAsset = (assetId: string) => getEntity('Asset', assetId);\n\n const onEdit = async () => {\n const slide = await openEntry(props.sdk, props.entryId, {\n bulkEditing: props.parameters.instance.bulkEditing,\n index: props.index,\n });\n props.onAction &&\n props.onAction({\n entity: 'Entry',\n type: 'edit',\n id: props.entryId,\n contentTypeId: get(entry, 'sys.contentType.sys.id'),\n slide,\n });\n };\n\n const onRemoveEntry = () => {\n props.onRemove();\n props.onAction &&\n props.onAction({\n entity: 'Entry',\n type: 'delete',\n id: props.entryId,\n contentTypeId: get(entry, 'sys.contentType.sys.id'),\n });\n };\n\n React.useEffect(() => {\n if (entry) {\n props.onAction && props.onAction({ type: 'rendered', entity: 'Entry' });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies\n }, [entry]);\n\n return React.useMemo(() => {\n if (status === 'error') {\n const card = (\n <MissingEntityCard\n entityType=\"Entry\"\n isDisabled={props.isDisabled}\n onRemove={onRemoveEntry}\n />\n );\n if (props.renderCustomMissingEntityCard) {\n return props.renderCustomMissingEntityCard({\n defaultCard: card,\n entity: {\n id: props.entryId,\n type: 'Entry',\n },\n });\n }\n return card;\n }\n if (status === 'loading') {\n return <EntryCard size={size} isLoading />;\n }\n const sharedCardProps: CustomEntityCardProps = {\n index: props.index,\n entity: entry,\n entityUrl: props.getEntityUrl && props.getEntityUrl(entry.sys.id),\n contentType: props.allContentTypes.find(\n (contentType) => contentType.sys.id === entry.sys.contentType.sys.id\n ),\n isDisabled: props.isDisabled,\n size,\n localeCode: props.sdk.field.locale,\n defaultLocaleCode: props.sdk.locales.default,\n renderDragHandle: props.renderDragHandle,\n onEdit,\n onRemove: onRemoveEntry,\n onMoveTop: props.onMoveTop,\n onMoveBottom: props.onMoveBottom,\n isBeingDragged: props.isBeingDragged,\n };\n\n const { hasCardEditActions, hasCardMoveActions, hasCardRemoveActions } = props;\n\n function renderDefaultCard(props?: CustomEntityCardProps) {\n const builtinCardProps: WrappedEntryCardProps = {\n ...sharedCardProps,\n ...props,\n hasCardEditActions,\n hasCardMoveActions,\n hasCardRemoveActions,\n getAsset,\n getEntityScheduledActions: loadEntityScheduledActions,\n entry: props?.entity || sharedCardProps.entity,\n entryUrl: props?.entityUrl || sharedCardProps.entityUrl,\n };\n\n return <WrappedEntryCard {...builtinCardProps} />;\n }\n\n if (props.renderCustomCard) {\n // LinkActionsProps are injected higher SingleReferenceEditor/MultipleReferenceEditor\n const renderedCustomCard = props.renderCustomCard(\n sharedCardProps,\n {} as LinkActionsProps,\n renderDefaultCard\n );\n // Only `false` indicates to render the original card. E.g. `null` would result in no card.\n if (renderedCustomCard !== false) {\n return renderedCustomCard;\n }\n }\n\n return renderDefaultCard();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies\n }, [props, status, entry]);\n}\n","import * as React from 'react';\n\nimport { ReferenceEditorProps } from '../common/ReferenceEditor';\nimport { SingleReferenceEditor } from '../common/SingleReferenceEditor';\nimport { FetchingWrappedEntryCard } from './WrappedEntryCard/FetchingWrappedEntryCard';\n\nexport function SingleEntryReferenceEditor(props: ReferenceEditorProps) {\n return (\n <SingleReferenceEditor {...props} entityType=\"Entry\">\n {({\n allContentTypes,\n isDisabled,\n entityId,\n setValue,\n renderCustomCard,\n hasCardRemoveActions,\n hasCardEditActions,\n }) => {\n return (\n <FetchingWrappedEntryCard\n {...props}\n allContentTypes={allContentTypes}\n isDisabled={isDisabled}\n entryId={entityId}\n renderCustomCard={renderCustomCard}\n hasCardEditActions={hasCardEditActions}\n hasCardRemoveActions={hasCardRemoveActions}\n onRemove={() => {\n setValue(null);\n }}\n />\n );\n }}\n </SingleReferenceEditor>\n );\n}\n\nSingleEntryReferenceEditor.defaultProps = {\n isInitiallyDisabled: true,\n};\n","import * as React from 'react';\nimport { useCallback } from 'react';\nimport { SortEndHandler, SortStartHandler } from 'react-sortable-hoc';\n\nimport arrayMove from 'array-move';\n\nimport { LinkEntityActions } from '../components';\nimport { useLinkActionsProps } from '../components/LinkActions/LinkEntityActions';\nimport { ReferenceValue, ContentEntityType, ContentType } from '../types';\nimport { CustomEntityCardProps } from './customCardTypes';\nimport { ReferenceEditor, ReferenceEditorProps } from './ReferenceEditor';\nimport { useEditorPermissions } from './useEditorPermissions';\n\ntype ChildProps = {\n entityType: ContentEntityType;\n items: ReferenceValue[];\n isDisabled: boolean;\n setValue: (value: ReferenceValue[]) => void;\n allContentTypes: ContentType[];\n onSortStart: SortStartHandler;\n onSortEnd: SortEndHandler;\n onMove: (oldIndex: number, newIndex: number) => void;\n};\n\ntype EditorProps = ReferenceEditorProps &\n Omit<ChildProps, 'onSortStart' | 'onSortEnd' | 'onMove'> & {\n children: (props: ReferenceEditorProps & ChildProps) => React.ReactElement;\n setIndexToUpdate?: React.Dispatch<React.SetStateAction<number | undefined>>;\n };\n\nfunction onLinkOrCreate(\n setValue: ChildProps['setValue'],\n entityType: ChildProps['entityType'],\n items: ChildProps['items'],\n ids: string[],\n index = items.length\n): void {\n const links: ReferenceValue[] = ids.map((id) => ({\n sys: { type: 'Link', linkType: entityType, id },\n }));\n const newItems = Array.from(items);\n newItems.splice(index, 0, ...links);\n setValue(newItems);\n}\n\nconst emptyArray: ReferenceValue[] = [];\nconst nullableValue = { sys: { id: 'null-value' } };\n\nfunction Editor(props: EditorProps) {\n const { setValue, entityType, setIndexToUpdate } = props;\n const editorPermissions = useEditorPermissions(props);\n\n const items = React.useMemo(() => {\n return (\n (props.items || [])\n // If null values have found their way into the persisted\n // value for the multiref field, replace them with an object\n // that has the shape of a Link to make the missing entry/asset\n // card render\n .map((link) => link || nullableValue)\n );\n }, [props.items]);\n\n const onSortStart: SortStartHandler = useCallback((_, event) => {\n if (event instanceof MouseEvent) {\n document.body.classList.add('grabbing');\n }\n event.preventDefault();\n }, []);\n const onSortEnd: SortEndHandler = useCallback(\n ({ oldIndex, newIndex }) => {\n // custom callback that is invoked *before* we sort the array\n // e.g. in Compose we want to sort the references in the referenceMap before re-rendering drag and drop\n props.onSortingEnd && props.onSortingEnd({ oldIndex, newIndex });\n const newItems = arrayMove(items, oldIndex, newIndex);\n setValue(newItems);\n setIndexToUpdate && setIndexToUpdate(undefined);\n document.body.classList.remove('grabbing');\n },\n [items, props, setIndexToUpdate, setValue]\n );\n const onMove = useCallback(\n (oldIndex, newIndex) => {\n const newItems = arrayMove(items, oldIndex, newIndex);\n setValue(newItems);\n },\n [items, setValue]\n );\n\n const onCreate = useCallback(\n (id: string, index?: number) => onLinkOrCreate(setValue, entityType, items, [id], index),\n [setValue, items, entityType]\n );\n\n const onLink = useCallback(\n (ids: string[], index?: number) => onLinkOrCreate(setValue, entityType, items, ids, index),\n [setValue, items, entityType]\n );\n\n const linkActionsProps = useLinkActionsProps({\n ...props,\n canLinkMultiple: true,\n editorPermissions,\n onCreate,\n onLink,\n itemsLength: items.length,\n });\n\n const customCardRenderer = useCallback(\n (cardProps: CustomEntityCardProps, _, renderDefaultCard) =>\n props.renderCustomCard\n ? props.renderCustomCard(cardProps, linkActionsProps, renderDefaultCard)\n : false,\n // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies\n [linkActionsProps]\n );\n\n return (\n <>\n {props.children({\n ...props,\n onSortStart: onSortStart,\n onSortEnd: onSortEnd,\n onMove,\n renderCustomCard: props.renderCustomCard && customCardRenderer,\n })}\n <LinkEntityActions renderCustomActions={props.renderCustomActions} {...linkActionsProps} />\n </>\n );\n}\n\nexport function MultipleReferenceEditor(\n props: ReferenceEditorProps & {\n entityType: ContentEntityType;\n children: (props: ReferenceEditorProps & ChildProps) => React.ReactElement;\n setIndexToUpdate?: React.Dispatch<React.SetStateAction<number | undefined>>;\n }\n) {\n const allContentTypes = props.sdk.space.getCachedContentTypes();\n\n return (\n <ReferenceEditor<ReferenceValue[]> {...props}>\n {({ value, disabled, setValue, externalReset }) => {\n return (\n <Editor\n {...props}\n items={value || emptyArray}\n isDisabled={disabled}\n setValue={setValue}\n key={`${externalReset}-list`}\n allContentTypes={allContentTypes}\n />\n );\n }}\n </ReferenceEditor>\n );\n}\n\nMultipleReferenceEditor.defaultProps = {\n hasCardEditActions: true,\n};\n","import React from 'react';\nimport {\n SortableContainer,\n SortableContainerProps,\n SortableElement,\n SortableHandle,\n} from 'react-sortable-hoc';\n\nimport tokens from '@contentful/f36-tokens';\nimport { css, cx } from 'emotion';\n\nimport { ReferenceEditorProps } from './ReferenceEditor';\n\nconst styles = {\n container: css({\n position: 'relative',\n }),\n item: css({\n marginBottom: tokens.spacingM,\n zIndex: tokens.zIndexModal, // setting this to an index above 99 fixes dragged item disappearing issue. Should not be higher than 100 so it does not overlap the asset modal.\n }),\n};\ntype SortableContainerChildProps<IType> = Pick<\n SortableLinkListProps<IType>,\n 'items' | 'isDisabled'\n> & {\n item: IType;\n index: number;\n DragHandle?: typeof DragHandle;\n};\n\ntype SortableLinkListProps<T> = ReferenceEditorProps & {\n items: T[];\n isDisabled: boolean;\n children: (props: SortableContainerChildProps<T>) => React.ReactElement;\n\n className?: string;\n};\n\nconst DragHandle = (props: { drag: React.ReactElement }) => {\n const SortableDragHandle = SortableHandle(() => props.drag);\n return <SortableDragHandle />;\n};\n\nconst SortableLink = SortableElement((props: { children: React.ReactElement }) => (\n <div className={styles.item}>{props.children}</div>\n));\n\nconst SortableLinkListInternal = SortableContainer((props: SortableLinkListProps<any>) => {\n return (\n <div className={cx(styles.container, props.className)}>\n {props.items.map((item, index) => (\n <SortableLink\n disabled={props.isDisabled}\n key={`${item.sys.urn ?? item.sys.id}-${index}`}\n index={index}\n >\n {props.children({\n items: props.items,\n isDisabled: props.isDisabled,\n item,\n index,\n DragHandle: props.isDisabled ? undefined : DragHandle,\n })}\n </SortableLink>\n ))}\n </div>\n );\n});\n\n// HOC does not support generics, so we mimic it via additional component\nexport function SortableLinkList<T>(props: SortableLinkListProps<T> & SortableContainerProps) {\n // with the default distance of 0 the drag start event is \"confused\" with the click event,\n // so the latter one isn't fired and click handlers on child elements don't work\n return (\n <SortableLinkListInternal distance={1} {...props}>\n {props.children}\n </SortableLinkListInternal>\n );\n}\n","import React from 'react';\n\nimport { Menu, Text } from '@contentful/f36-components';\nimport { shortenStorageUnit } from '@contentful/field-editor-shared';\nimport get from 'lodash/get';\n\nimport { File } from '../../types';\n\nfunction downloadAsset(url: string) {\n window.open(url, '_blank', 'noopener,noreferrer');\n}\n\nexport function renderAssetInfo(props: { entityFile: File }) {\n const { entityFile } = props;\n const fileName = get(entityFile, 'fileName');\n const mimeType = get(entityFile, 'contentType');\n const fileSize = get(entityFile, 'details.size');\n const image = get(entityFile, 'details.image');\n return [\n <Menu.SectionTitle key=\"file-section\">File info</Menu.SectionTitle>,\n fileName && (\n <Menu.Item key=\"file-name\">\n <Text isTruncated>{fileName}</Text>\n </Menu.Item>\n ),\n mimeType && (\n <Menu.Item key=\"file-type\">\n <Text isTruncated>{mimeType}</Text>\n </Menu.Item>\n ),\n fileSize && <Menu.Item key=\"file-size\">{shortenStorageUnit(fileSize, 'B')}</Menu.Item>,\n image && <Menu.Item key=\"file-dimentions\">{`${image.width} × ${image.height}`}</Menu.Item>,\n ].filter((item) => item);\n}\n\nexport function renderActions(props: {\n onEdit?: () => void;\n onRemove?: () => void;\n isDisabled: boolean;\n entityFile?: File;\n}) {\n const { entityFile, isDisabled, onEdit, onRemove } = props;\n\n return [\n <Menu.SectionTitle key=\"section-title\">Actions</Menu.SectionTitle>,\n onEdit ? (\n <Menu.Item key=\"edit\" onClick={onEdit} testId=\"card-action-edit\">\n Edit\n </Menu.Item>\n ) : null,\n entityFile ? (\n <Menu.Item\n key=\"download\"\n onClick={() => {\n if (typeof entityFile.url === 'string') {\n downloadAsset(entityFile.url);\n }\n }}\n testId=\"card-action-download\">\n Download\n </Menu.Item>\n ) : null,\n onRemove ? (\n <Menu.Item key=\"remove\" disabled={isDisabled} onClick={onRemove} testId=\"card-action-remove\">\n Remove\n </Menu.Item>\n ) : null,\n ].filter((item) => item);\n}\n","import React from 'react';\n\nimport { SpaceAPI } from '@contentful/app-sdk';\nimport { AssetCard } from '@contentful/f36-components';\nimport { ClockIcon } from '@contentful/f36-icons';\nimport tokens from '@contentful/f36-tokens';\nimport { entityHelpers } from '@contentful/field-editor-shared';\n// @ts-expect-error\nimport mimetype from '@contentful/mimetype';\nimport { css } from 'emotion';\n\nimport { MissingEntityCard, ScheduledIconWithTooltip } from '../../components';\nimport { File, Asset, RenderDragFn } from '../../types';\nimport { renderActions, renderAssetInfo } from './AssetCardActions';\n\nconst groupToIconMap = {\n image: 'image',\n video: 'video',\n audio: 'audio',\n richtext: 'richtext',\n presentation: 'presentation',\n spreadsheet: 'spreadsheet',\n pdfdocument: 'pdf',\n archive: 'archive',\n plaintext: 'plaintext',\n code: 'code',\n markup: 'markup',\n};\n\nconst styles = {\n scheduleIcon: css({\n marginRight: tokens.spacing2Xs,\n }),\n};\n\nexport interface WrappedAssetCardProps {\n getEntityScheduledActions: SpaceAPI['getEntityScheduledActions'];\n asset: Asset;\n localeCode: string;\n defaultLocaleCode: string;\n getAssetUrl?: (assetId: string) => string;\n className?: string;\n isSelected?: boolean;\n isDisabled: boolean;\n onEdit?: () => void;\n onRemove?: () => void;\n size: 'default' | 'small';\n renderDragHandle?: RenderDragFn;\n isClickable: boolean;\n}\n\nconst defaultProps = {\n isClickable: true,\n};\n\n// eslint-disable-next-line -- TODO: describe this disable @typescript-eslint/no-explicit-any\nfunction getFileType(file?: File): any {\n if (!file) {\n return 'archive';\n }\n\n const groupName: keyof typeof groupToIconMap = mimetype.getGroupLabel({\n type: file.contentType,\n fallbackFileName: file.fileName,\n });\n\n return groupToIconMap[groupName] || 'archive';\n}\n\nexport const WrappedAssetCard = (props: WrappedAssetCardProps) => {\n const { className, onEdit, getAssetUrl, onRemove, size, isDisabled, isSelected, isClickable } =\n props;\n\n const status = entityHelpers.getEntryStatus(props.asset.sys);\n\n if (status === 'deleted') {\n return (\n <MissingEntityCard\n entityType=\"Asset\"\n asSquare\n isDisabled={props.isDisabled}\n onRemove={props.onRemove}\n />\n );\n }\n\n const entityTitle = entityHelpers.getAssetTitle({\n asset: props.asset,\n localeCode: props.localeCode,\n defaultLocaleCode: props.defaultLocaleCode,\n defaultTitle: 'Untitled',\n });\n\n const entityFile = props.asset.fields.file\n ? props.asset.fields.file[props.localeCode] || props.asset.fields.file[props.defaultLocaleCode]\n : undefined;\n\n const href = getAssetUrl ? getAssetUrl(props.asset.sys.id) : undefined;\n\n return (\n <AssetCard\n as={href ? 'a' : 'article'}\n type={getFileType(entityFile)}\n title={entityTitle}\n className={className}\n isSelected={isSelected}\n href={href}\n status={status}\n icon={\n <ScheduledIconWithTooltip\n getEntityScheduledActions={props.getEntityScheduledActions}\n entityType=\"Asset\"\n entityId={props.asset.sys.id}\n >\n <ClockIcon\n className={styles.scheduleIcon}\n size=\"small\"\n variant=\"muted\"\n testId=\"schedule-icon\"\n />\n </ScheduledIconWithTooltip>\n }\n src={\n entityFile && entityFile.url\n ? size === 'small'\n ? `${entityFile.url}?w=150&h=150&fit=thumb`\n : `${entityFile.url}?h=300`\n : ''\n }\n onClick={\n // Providing an onClick handler messes up with some rich text\n // features e.g. pressing ENTER on a card to add a new paragraph\n // underneath. It's crucial not to pass a custom handler when\n // isClickable is disabled which in the case of RT it's.\n isClickable\n ? (e: React.MouseEvent<HTMLElement>) => {\n e.preventDefault();\n onEdit && onEdit();\n }\n : undefined\n }\n /* todo - remove this when onKeyDown is allowed as a prop for BaseCard in forma 36\n // @ts-expect-error */\n onKeyDown={\n isClickable\n ? (e: React.KeyboardEvent<HTMLElement>) => {\n if (e.key === 'Enter' && onEdit) {\n e.preventDefault();\n onEdit();\n }\n }\n : undefined\n }\n dragHandleRender={props.renderDragHandle}\n withDragHandle={!!props.renderDragHandle}\n actions={[\n ...renderActions({ entityFile, isDisabled: isDisabled, onEdit, onRemove }),\n ...(entityFile ? renderAssetInfo({ entityFile }) : []),\n ].filter((item) => item)}\n size={size}\n />\n );\n};\n\nWrappedAssetCard.defaultProps = defaultProps;\n","import React from 'react';\n\nimport { EntryCard } from '@contentful/f36-components';\nimport { ClockIcon } from '@contentful/f36-icons';\nimport tokens from '@contentful/f36-tokens';\nimport { entityHelpers, isValidImage, SpaceAPI } from '@contentful/field-editor-shared';\nimport { css } from 'emotion';\n\nimport { MissingEntityCard, ScheduledIconWithTooltip, AssetThumbnail } from '../../components';\nimport { Asset, RenderDragFn } from '../../types';\nimport { renderActions, renderAssetInfo } from './AssetCardActions';\n\nconst styles = {\n scheduleIcon: css({\n marginRight: tokens.spacing2Xs,\n }),\n};\n\nexport interface WrappedAssetLinkProps {\n getEntityScheduledActions: SpaceAPI['getEntityScheduledActions'];\n asset: Asset;\n localeCode: string;\n defaultLocaleCode: string;\n href?: string;\n className?: string;\n isDisabled: boolean;\n onEdit: () => void;\n onRemove: () => void;\n renderDragHandle?: RenderDragFn;\n}\n\nexport const WrappedAssetLink = (props: WrappedAssetLinkProps) => {\n const { className, href, onEdit, onRemove, isDisabled } = props;\n\n const status = entityHelpers.getEntryStatus(props.asset.sys);\n\n if (status === 'deleted') {\n return (\n <MissingEntityCard\n entityType=\"Asset\"\n isDisabled={props.isDisabled}\n onRemove={props.onRemove}\n />\n );\n }\n\n const entityTitle = entityHelpers.getAssetTitle({\n asset: props.asset,\n localeCode: props.localeCode,\n defaultLocaleCode: props.defaultLocaleCode,\n defaultTitle: 'Untitled',\n });\n\n const entityFile = props.asset.fields.file\n ? props.asset.fields.file[props.localeCode] || props.asset.fields.file[props.defaultLocaleCode]\n : undefined;\n\n return (\n <EntryCard\n as={href ? 'a' : 'article'}\n contentType=\"Asset\"\n title={entityTitle}\n className={className}\n href={href}\n size=\"small\"\n status={status}\n thumbnailElement={\n entityFile && isValidImage(entityFile) ? <AssetThumbnail file={entityFile} /> : undefined\n }\n icon={\n <ScheduledIconWithTooltip\n getEntityScheduledActions={props.getEntityScheduledActions}\n entityType=\"Asset\"\n entityId={props.asset.sys.id}\n >\n <ClockIcon\n className={styles.scheduleIcon}\n size=\"small\"\n variant=\"muted\"\n testId=\"schedule-icon\"\n />\n </ScheduledIconWithTooltip>\n }\n onClick={(e: React.MouseEvent<HTMLElement>) => {\n e.preventDefault();\n onEdit();\n }}\n onKeyDown={(e: React.KeyboardEvent<HTMLElement>) => {\n if (e.key === 'Enter' && onEdit) {\n e.preventDefault();\n onEdit();\n }\n }}\n dragHandleRender={props.renderDragHandle}\n withDragHandle={!!props.renderDragHandle}\n actions={[\n renderActions({ entityFile, isDisabled: isDisabled, onEdit, onRemove }),\n entityFile ? renderAssetInfo({ entityFile }) : null,\n ].filter((item) => item)}\n />\n );\n};\n","import * as React from 'react';\n\nimport { AssetCard, EntryCard } from '@contentful/f36-components';\n\nimport {\n CustomEntityCardProps,\n CustomCardRenderer,\n RenderCustomMissingEntityCard,\n} from '../../common/customCardTypes';\nimport { useEntity, useEntityLoader } from '../../common/EntityStore';\nimport { LinkActionsProps, MissingEntityCard } from '../../components';\nimport { Action, Asset, FieldExtensionSDK, ViewType, RenderDragFn } from '../../types';\nimport { WrappedAssetCard, WrappedAssetCardProps } from './WrappedAssetCard';\nimport { WrappedAssetLink } from './WrappedAssetLink';\n\ntype FetchingWrappedAssetCardProps = {\n assetId: string;\n isDisabled: boolean;\n sdk: FieldExtensionSDK;\n viewType: ViewType | 'big_card';\n onRemove: () => void;\n getEntityUrl?: (id: string) => string;\n onAction?: (action: Action) => void;\n renderDragHandle?: RenderDragFn;\n renderCustomCard?: CustomCardRenderer;\n renderCustomMissingEntityCard?: RenderCustomMissingEntityCard;\n};\n\nexport function FetchingWrappedAssetCard(props: FetchingWrappedAssetCardProps) {\n const { data: asset, status } = useEntity<Asset>('Asset', props.assetId);\n const { getEntityScheduledActions } = useEntityLoader();\n const loadEntityScheduledActions = React.useCallback(\n () => getEntityScheduledActions('Asset', props.assetId),\n [getEntityScheduledActions, props.assetId]\n );\n\n React.useEffect(() => {\n if (asset) {\n props.onAction && props.onAction({ type: 'rendered', entity: 'Asset' });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies\n }, [asset]);\n\n const onEdit = async () => {\n const { slide } = await props.sdk.navigator.openAsset(props.assetId, { slideIn: true });\n props.onAction &&\n props.onAction({\n entity: 'Asset',\n type: 'edit',\n id: props.assetId,\n contentTypeId: '',\n slide,\n });\n };\n\n const onRemove = () => {\n props.onRemove();\n props.onAction &&\n props.onAction({ entity: 'Asset', type: 'delete', id: props.assetId, contentTypeId: '' });\n };\n\n return React.useMemo(() => {\n if (status === 'error') {\n const card = (\n <MissingEntityCard\n entityType=\"Asset\"\n asSquare={props.viewType !== 'link'}\n isDisabled={props.isDisabled}\n onRemove={onRemove}\n />\n );\n if (props.renderCustomMissingEntityCard) {\n return props.renderCustomMissingEntityCard({\n defaultCard: card,\n entity: {\n id: props.assetId,\n type: 'Asset',\n },\n });\n }\n return card;\n }\n\n const { getEntityUrl } = props;\n const size = props.viewType === 'big_card' ? 'default' : 'small';\n const commonProps = {\n asset,\n entityUrl: getEntityUrl && getEntityUrl(props.assetId),\n size: size as 'default' | 'small',\n isDisabled: props.isDisabled,\n localeCode: props.sdk.field.locale,\n defaultLocaleCode: props.sdk.locales.default,\n renderDragHandle: props.renderDragHandle,\n onEdit,\n onRemove,\n };\n\n if (props.viewType === 'link') {\n if (status === 'loading') {\n return <EntryCard size=\"small\" isLoading />;\n }\n return (\n <WrappedAssetLink\n {...commonProps}\n href={commonProps.entityUrl}\n getEntityScheduledActions={loadEntityScheduledActions}\n />\n );\n }\n\n if (status === 'loading') {\n return <AssetCard size={size} isLoading />;\n }\n\n function renderDefaultCard(props?: CustomEntityCardProps) {\n // isClickable has a default value, so omit it from the props\n const builtinCardProps: Omit<WrappedAssetCardProps, 'isClickable'> = {\n ...commonProps,\n ...props,\n getEntityScheduledActions: loadEntityScheduledActions,\n asset: (props?.entity as Asset) || commonProps.asset,\n getAssetUrl: getEntityUrl,\n };\n\n return <WrappedAssetCard {...builtinCardProps} />;\n }\n\n if (props.renderCustomCard) {\n const customProps: CustomEntityCardProps = {\n ...commonProps,\n entity: commonProps.asset,\n };\n\n // LinkActionsProps are injected higher SingleReferenceEditor/MultipleReferenceEditor\n const renderedCustomCard = props.renderCustomCard(\n customProps,\n {} as LinkActionsProps,\n renderDefaultCard\n );\n // Only `false` indicates to render the original card. E.g. `null` would result in no card.\n if (renderedCustomCard !== false) {\n return renderedCustomCard;\n }\n }\n\n return renderDefaultCard();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies\n }, [props, status, asset]);\n}\n","import * as React from 'react';\n\nimport { ReferenceEditorProps } from '../common/ReferenceEditor';\nimport { SingleReferenceEditor } from '../common/SingleReferenceEditor';\nimport { FetchingWrappedAssetCard } from './WrappedAssetCard/FetchingWrappedAssetCard';\n\n// Omit<ReferenceEditorProps, 'hasCardEditActions'>;\n// does not work nice with <Props of={SingleMediaEditor} /> from docz\n// so the docs won't be generated for the props\ntype EditorProps = Pick<\n ReferenceEditorProps,\n Exclude<keyof ReferenceEditorProps, 'hasCardEditActions'>\n>;\n\nexport function SingleMediaEditor(props: EditorProps) {\n return (\n <SingleReferenceEditor {...props} entityType=\"Asset\">\n {({ entityId, isDisabled, setValue }) => (\n <FetchingWrappedAssetCard\n {...props}\n viewType=\"big_card\"\n assetId={entityId}\n isDisabled={isDisabled}\n onRemove={() => {\n setValue(null);\n }}\n />\n )}\n </SingleReferenceEditor>\n );\n}\n\nSingleMediaEditor.defaultProps = {\n isInitiallyDisabled: true,\n};\n","import * as React from 'react';\n\nimport { css, cx } from 'emotion';\n\nimport { MultipleReferenceEditor } from '../common/MultipleReferenceEditor';\nimport { ReferenceEditorProps } from '../common/ReferenceEditor';\nimport { SortableLinkList } from '../common/SortableLinkList';\nimport { ReferenceValue } from '../types';\nimport { FetchingWrappedAssetCard } from './WrappedAssetCard/FetchingWrappedAssetCard';\n\n// Omit<ReferenceEditorProps, 'hasCardEditActions'>;\n// does not work nice with <Props of={SingleMediaEditor} /> from docz\n// so the docs won't be generated for the props\ntype EditorProps = Pick<\n ReferenceEditorProps,\n Exclude<keyof ReferenceEditorProps, 'hasCardEditActions'>\n>;\n\nconst styles = {\n gridContainer: css({\n position: 'relative',\n display: 'flex',\n flexWrap: 'wrap',\n }),\n};\n\nexport function MultipleMediaEditor(props: EditorProps) {\n return (\n <MultipleReferenceEditor {...props} entityType=\"Asset\">\n {(childrenProps) => (\n <SortableLinkList<ReferenceValue>\n {...childrenProps}\n className={cx({ [styles.gridContainer]: childrenProps.viewType === 'card' })}\n axis={childrenProps.viewType === 'card' ? 'xy' : 'y'}\n useDragHandle={true}>\n {({ items, item, index, isDisabled, DragHandle }) => (\n <FetchingWrappedAssetCard\n {...childrenProps}\n isDisabled={isDisabled}\n key={`${item.sys.id}-${index}`}\n assetId={item.sys.id}\n onRemove={() => {\n childrenProps.setValue(items.filter((_value, i) => i !== index));\n }}\n renderDragHandle={DragHandle}\n />\n )}\n </SortableLinkList>\n )}\n </MultipleReferenceEditor>\n );\n}\n\nMultipleMediaEditor.defaultProps = {\n isInitiallyDisabled: true,\n};\n","import * as React from 'react';\n\nimport { Entry } from '@contentful/field-editor-shared';\n\nimport { WrappedEntryCard } from '../../entries';\nimport { RenderDragFn, ResourceInfo } from '../../types';\n\nexport type CardActionsHandlers = {\n onRemove?: VoidFunction;\n onMoveTop?: VoidFunction;\n onMoveBottom?: VoidFunction;\n};\n\nexport type EntryRoute = { spaceId: string; environmentId: string; entryId: string };\n\ntype ContentfulEntryCardProps = {\n info: ResourceInfo<Entry>;\n isDisabled: boolean;\n renderDragHandle?: RenderDragFn;\n getEntryRouteHref: (entryRoute: EntryRoute) => string;\n} & CardActionsHandlers;\n\n// assets are not shown for small cards (which we hardcode currently)\nconst resolveAsset = () => Promise.resolve();\n// we don't want to show scheduled actions for resources\nconst resolveScheduledActions = () => Promise.resolve([]);\n\nexport function ContentfulEntryCard({\n info,\n isDisabled,\n renderDragHandle,\n onRemove,\n onMoveTop,\n onMoveBottom,\n getEntryRouteHref,\n}: ContentfulEntryCardProps) {\n const resourceSys = info.resource.sys;\n const spaceId = resourceSys.space.sys.id;\n const environmentId = resourceSys.environment.sys.id;\n const entryId = resourceSys.id;\n\n const resourceHref = getEntryRouteHref({\n spaceId,\n environmentId,\n entryId,\n });\n\n // TODO: move this into `sdk.navigator.openEntry()`, note that it's signature only include the entry id (not a space or environment)\n const openEntryDetail = () => {\n window.open(resourceHref, '_blank', 'noopener,noreferrer');\n };\n\n return (\n <WrappedEntryCard\n entry={info.resource}\n isDisabled={isDisabled}\n hasCardEditActions={false}\n contentType={info.contentType}\n // we use the default locale from the space the entry belongs to\n // as we assume this gives a more consistent behaviour.\n // locales will inevitably differ from space to space, so it's likely\n // that the current locale does not exist in the \"remote\" space\n localeCode={info.defaultLocaleCode}\n defaultLocaleCode={info.defaultLocaleCode}\n size=\"small\"\n getAsset={resolveAsset}\n getEntityScheduledActions={resolveScheduledActions}\n spaceName={info.space.name}\n renderDragHandle={renderDragHandle}\n isClickable={true}\n onEdit={openEntryDetail}\n hasCardRemoveActions={Boolean(onRemove)}\n onRemove={onRemove}\n onMoveBottom={onMoveBottom}\n onMoveTop={onMoveTop}\n entryUrl={resourceHref}\n />\n );\n}\n","import React from 'react';\n\nimport { Card, SectionHeading } from '@contentful/f36-components';\nimport { css } from 'emotion';\n\nconst styles = {\n card: css({\n position: 'relative',\n }),\n};\n\nexport function UnsupportedEntityCard(props: { entityType: string }) {\n return (\n <Card className={styles.card}>\n <SectionHeading marginBottom=\"none\">\n Resource type {props.entityType} is currently not supported\n </SectionHeading>\n </Card>\n );\n}\n","import * as React from 'react';\nimport { useInView } from 'react-intersection-observer';\n\nimport { EntryCard } from '@contentful/f36-components';\nimport { SetRequired } from 'type-fest';\n\nimport { useResource, isUnsupportedError } from '../../common/EntityStore';\nimport { MissingEntityCard } from '../../components';\nimport { RenderDragFn, ResourceLink } from '../../types';\nimport { CardActionsHandlers, ContentfulEntryCard, EntryRoute } from './ContentfulEntryCard';\nimport { UnsupportedEntityCard } from './UnsupportedEntityCard';\n\ntype ResourceCardProps = {\n index?: number;\n resourceLink?: ResourceLink;\n isDisabled: boolean;\n renderDragHandle?: RenderDragFn;\n getEntryRouteHref: (entryRoute: EntryRoute) => string;\n} & CardActionsHandlers;\n\nfunction ResourceCardSkeleton() {\n return <EntryCard size=\"small\" isLoading />;\n}\n\nfunction ExistingResourceCard(\n props: SetRequired<ResourceCardProps, 'resourceLink'> & {\n inView: boolean;\n }\n) {\n const { resourceLink, inView, index = 0 } = props;\n const resourceOptions = { priority: index * -1, enabled: inView };\n const { data, error } = useResource(\n resourceLink.sys.linkType,\n resourceLink.sys.urn,\n resourceOptions\n );\n if (!data && !error) {\n return <ResourceCardSkeleton />;\n }\n\n if (data) {\n return <ContentfulEntryCard info={data} {...props} />;\n }\n\n if (isUnsupportedError(error)) {\n return <UnsupportedEntityCard entityType={resourceLink.sys.linkType} />;\n }\n\n return (\n <MissingEntityCard entityType=\"Entry\" isDisabled={props.isDisabled} onRemove={props.onRemove} />\n );\n}\n\nfunction ResourceCardWrapper(props: ResourceCardProps & { inView: boolean }) {\n if (!props.resourceLink) {\n return null;\n }\n\n return (\n <ExistingResourceCard\n {...props}\n resourceLink={props.resourceLink}\n getEntryRouteHref={props.getEntryRouteHref}\n />\n );\n}\n\nexport function ResourceCard(props: ResourceCardProps) {\n const { ref, inView } = useInView({ triggerOnce: true, rootMargin: '300px 0px 0px 300px' });\n\n // Forma does not offer us to pass refs, so we need an additional wrapper here\n return (\n <div ref={ref}>\n <ResourceCardWrapper {...props} inView={inView} />\n </div>\n );\n}\n","import { useCallback, useMemo } from 'react';\n\nimport { FieldAPI, FieldExtensionSDK } from '@contentful/app-sdk';\nimport { EntryProps, WithResourceName } from 'contentful-management';\n\nimport { LinkActionsProps } from '../components';\n\nconst toLinkItem = (entry: WithResourceName<EntryProps>, apiUrl: string) => ({\n sys: {\n type: 'ResourceLink',\n linkType: 'Contentful:Entry',\n urn:\n entry.sys.urn ??\n `crn:${apiUrl}:::content:spaces/${entry.sys.space.sys.id}/entries/${entry.sys.id}`,\n },\n});\n\nconst getUpdatedValue = (\n field: FieldAPI,\n entries: WithResourceName<EntryProps>[],\n apiUrl: string\n) => {\n const multiple = field.type === 'Array';\n if (multiple) {\n const linkItems = entries.map((entry) => toLinkItem(entry, apiUrl));\n const prevValue = field.getValue() || [];\n return [...prevValue, ...linkItems];\n } else {\n return toLinkItem(entries[0], apiUrl);\n }\n};\n\nexport function useResourceLinkActions({\n dialogs,\n field,\n onAfterLink,\n apiUrl,\n}: Pick<FieldExtensionSDK, 'field' | 'dialogs'> & {\n apiUrl: string;\n onAfterLink?: (e: EntryProps) => void;\n}): LinkActionsProps {\n const handleAfterLink = useCallback(\n (entries: EntryProps[]) => {\n if (!onAfterLink) {\n return;\n }\n entries.forEach(onAfterLink);\n },\n [onAfterLink]\n );\n\n const onLinkedExisting = useMemo(() => {\n return (entries: EntryProps[]) => {\n const updatedValue = getUpdatedValue(\n field,\n entries as WithResourceName<EntryProps>[],\n apiUrl\n );\n field.setValue(updatedValue);\n handleAfterLink(entries);\n };\n }, [field, handleAfterLink, apiUrl]);\n\n const multiple = field.type === 'Array';\n const onLinkExisting = useMemo(() => {\n const promptSelection = multiple\n ? async () =>\n // @ts-expect-error wait for update of app-sdk version\n await dialogs.selectMultipleResourceEntries({\n // @ts-expect-error wait for update of app-sdk version\n allowedResources: field.allowedResources,\n })\n : async () => [\n // @ts-expect-error wait for update of app-sdk version\n await dialogs.selectSingleResourceEntry({\n // @ts-expect-error wait for update of app-sdk version\n allowedResources: field.allowedResources,\n }),\n ];\n\n return async () => {\n const res = await promptSelection();\n if (!res) {\n return;\n }\n onLinkedExisting(res);\n };\n // @ts-expect-error wait for update of app-sdk version\n }, [dialogs, field.allowedResources, multiple, onLinkedExisting]);\n\n return {\n onLinkExisting,\n onLinkedExisting,\n // hardcoded values to match interface for standard reference field actions\n entityType: 'Entry',\n contentTypes: [],\n canCreateEntity: false,\n canLinkMultiple: multiple,\n canLinkEntity: true,\n isDisabled: false,\n isEmpty: false,\n isFull: false,\n // eslint-disable-next-line -- hardcoded values to match interface for standard reference field actions\n onCreate: async () => {},\n // eslint-disable-next-line -- hardcoded values to match interface for standard reference field actions\n onCreated: () => {},\n };\n}\n","import * as React from 'react';\nimport { useCallback } from 'react';\nimport { SortEndHandler, SortStartHandler } from 'react-sortable-hoc';\n\nimport { FieldConnector } from '@contentful/field-editor-shared';\nimport arrayMove from 'array-move';\nimport deepEqual from 'deep-equal';\n\nimport { EntityProvider } from '../common/EntityStore';\nimport { ReferenceEditorProps } from '../common/ReferenceEditor';\nimport { SortableLinkList } from '../common/SortableLinkList';\nimport { CombinedLinkEntityActions } from '../components/LinkActions/LinkEntityActions';\nimport { ResourceLink } from '../types';\nimport { EntryRoute } from './Cards/ContentfulEntryCard';\nimport { ResourceCard } from './Cards/ResourceCard';\nimport { useResourceLinkActions } from './useResourceLinkActions';\n\ntype ChildProps = {\n items: ResourceLink[];\n isDisabled: boolean;\n setValue: (value: ResourceLink[]) => void;\n onSortStart: SortStartHandler;\n onSortEnd: SortEndHandler;\n onMove: (oldIndex: number, newIndex: number) => void;\n onRemoteItemAtIndex: (index: number) => void;\n};\n\ntype EditorProps = ReferenceEditorProps &\n Omit<ChildProps, 'onSortStart' | 'onSortEnd' | 'onMove' | 'onRemoteItemAtIndex'> & {\n children: (props: ReferenceEditorProps & ChildProps) => React.ReactElement;\n apiUrl: string;\n };\n\nfunction ResourceEditor(props: EditorProps) {\n const { setValue, items, apiUrl } = props;\n\n const onSortStart: SortStartHandler = useCallback((_, event) => event.preventDefault(), []);\n const onSortEnd: SortEndHandler = useCallback(\n ({ oldIndex, newIndex }) => {\n const newItems = arrayMove(items, oldIndex, newIndex);\n setValue(newItems);\n },\n [items, setValue]\n );\n const onMove = useCallback(\n (oldIndex, newIndex) => {\n const newItems = arrayMove(items, oldIndex, newIndex);\n setValue(newItems);\n },\n [items, setValue]\n );\n\n const onRemoteItemAtIndex = useCallback(\n (index) => {\n setValue(items.filter((_v, i) => i !== index));\n },\n [items, setValue]\n );\n\n const { dialogs, field } = props.sdk;\n const linkActionsProps = useResourceLinkActions({\n dialogs,\n field,\n apiUrl,\n });\n\n return (\n <>\n {props.children({\n ...props,\n onSortStart,\n onSortEnd,\n onMove,\n onRemoteItemAtIndex,\n })}\n <CombinedLinkEntityActions\n {...linkActionsProps}\n renderCustomActions={props.renderCustomActions}\n />\n </>\n );\n}\n\n// provides memoized callbacks bound to a given item\nfunction WithPerItemCallbacks({\n listLength,\n index,\n onMove,\n onRemoteItemAtIndex,\n children,\n}: {\n listLength: number;\n index: number;\n onMove: (oldIndex: number, newIndex: number) => void;\n onRemoteItemAtIndex: (index: number) => void;\n children: (props: {\n onMoveTop: VoidFunction | undefined;\n onMoveBottom: VoidFunction | undefined;\n onRemove: VoidFunction | undefined;\n }) => React.ReactNode;\n}) {\n const handleMoveTop = React.useMemo(\n () => (index > 0 ? () => onMove(index, 0) : undefined),\n [index, onMove]\n );\n const handleMoveBottom = React.useMemo(\n () => (index < listLength - 1 ? () => onMove(index, listLength - 1) : undefined),\n [index, onMove, listLength]\n );\n const handleRemove = useCallback(() => onRemoteItemAtIndex(index), [index, onRemoteItemAtIndex]);\n\n return (\n <>\n {children({\n onMoveBottom: handleMoveBottom,\n onMoveTop: handleMoveTop,\n onRemove: handleRemove,\n })}\n </>\n );\n}\n\nconst EMPTY_ARRAY: ResourceLink[] = [];\n\nexport function MultipleResourceReferenceEditor(\n props: ReferenceEditorProps & {\n apiUrl: string;\n getEntryRouteHref: (entryRoute: EntryRoute) => string;\n }\n) {\n return (\n <EntityProvider sdk={props.sdk}>\n <FieldConnector<ResourceLink[]>\n throttle={0}\n field={props.sdk.field}\n isInitiallyDisabled={props.isInitiallyDisabled}\n isEqualValues={deepEqual}\n >\n {({ value, disabled, setValue, externalReset }) => {\n return (\n <ResourceEditor\n {...props}\n items={value || EMPTY_ARRAY}\n isDisabled={disabled}\n setValue={setValue}\n renderCustomActions={props.renderCustomActions}\n key={`${externalReset}-list`}\n >\n {(editorProps) => (\n <SortableLinkList<ResourceLink> {...editorProps}>\n {({ item, isDisabled, DragHandle, index }) => (\n <WithPerItemCallbacks\n index={index}\n onMove={editorProps.onMove}\n onRemoteItemAtIndex={editorProps.onRemoteItemAtIndex}\n listLength={value?.length || 0}\n >\n {({ onMoveBottom, onMoveTop, onRemove }) => (\n <ResourceCard\n index={index}\n resourceLink={item}\n isDisabled={isDisabled}\n renderDragHandle={DragHandle}\n onMoveTop={onMoveTop}\n onMoveBottom={onMoveBottom}\n onRemove={onRemove}\n getEntryRouteHref={props.getEntryRouteHref}\n />\n )}\n </WithPerItemCallbacks>\n )}\n </SortableLinkList>\n )}\n </ResourceEditor>\n );\n }}\n </FieldConnector>\n </EntityProvider>\n );\n}\n","import * as React from 'react';\n\nimport { MultipleReferenceEditor } from '../common/MultipleReferenceEditor';\nimport { ReferenceEditorProps } from '../common/ReferenceEditor';\nimport { SortableLinkList } from '../common/SortableLinkList';\nimport { ReferenceValue } from '../types';\nimport { FetchingWrappedEntryCard } from './WrappedEntryCard/FetchingWrappedEntryCard';\n\nexport function MultipleEntryReferenceEditor(props: ReferenceEditorProps) {\n const [indexToUpdate, setIndexToUpdate] = React.useState<number | undefined>(undefined);\n\n const updateBeforeSortStart = ({ index }: { index: number }) => {\n setIndexToUpdate(index);\n };\n\n return (\n <MultipleReferenceEditor {...props} entityType=\"Entry\" setIndexToUpdate={setIndexToUpdate}>\n {(childrenProps) => (\n <SortableLinkList<ReferenceValue>\n {...childrenProps}\n axis=\"y\"\n useDragHandle={true}\n updateBeforeSortStart={updateBeforeSortStart}\n >\n {({ items, item, index, isDisabled, DragHandle }) => {\n const lastIndex = items.length - 1;\n return (\n <FetchingWrappedEntryCard\n {...childrenProps}\n key={`${item.sys.id}-${index}`}\n index={index}\n allContentTypes={childrenProps.allContentTypes}\n isDisabled={isDisabled}\n entryId={item.sys.id}\n onRemove={() => {\n childrenProps.setValue(items.filter((_value, i) => i !== index));\n }}\n onMoveTop={index !== 0 ? () => childrenProps.onMove(index, 0) : undefined}\n onMoveBottom={\n index !== lastIndex ? () => childrenProps.onMove(index, lastIndex) : undefined\n }\n renderDragHandle={DragHandle}\n isBeingDragged={index === indexToUpdate}\n />\n );\n }}\n </SortableLinkList>\n )}\n </MultipleReferenceEditor>\n );\n}\n","import * as React from 'react';\n\nimport { FieldConnector } from '@contentful/field-editor-shared';\nimport deepEqual from 'deep-equal';\n\nimport { EntityProvider } from '../common/EntityStore';\nimport { ReferenceEditorProps } from '../common/ReferenceEditor';\nimport { CombinedLinkEntityActions } from '../components/LinkActions/LinkEntityActions';\nimport { ResourceLink } from '../types';\nimport { EntryRoute } from './Cards/ContentfulEntryCard';\nimport { ResourceCard } from './Cards/ResourceCard';\nimport { useResourceLinkActions } from './useResourceLinkActions';\n\nexport function SingleResourceReferenceEditor(\n props: ReferenceEditorProps & {\n getEntryRouteHref: (entryRoute: EntryRoute) => string;\n apiUrl: string;\n }\n) {\n const { dialogs, field } = props.sdk;\n const linkActionsProps = useResourceLinkActions({\n dialogs,\n field,\n apiUrl: props.apiUrl,\n });\n\n return (\n <EntityProvider sdk={props.sdk}>\n <FieldConnector<ResourceLink>\n throttle={0}\n field={props.sdk.field}\n isInitiallyDisabled={props.isInitiallyDisabled}\n isEqualValues={deepEqual}\n >\n {({ value, disabled }) => {\n return value ? (\n <ResourceCard\n onRemove={() => props.sdk.field.removeValue()}\n resourceLink={value}\n isDisabled={disabled}\n getEntryRouteHref={props.getEntryRouteHref}\n />\n ) : (\n <CombinedLinkEntityActions\n {...linkActionsProps}\n renderCustomActions={props.renderCustomActions}\n />\n );\n }}\n </FieldConnector>\n </EntityProvider>\n );\n}\n"],"names":["menuPlacementMap","styles","wrapper","css","position","inputWrapper","padding","tokens","spacing2Xs","searchInput","paddingRight","spacingXl","textOverflow","searchIcon","right","spacingM","top","spacingS","zIndex","Number","zIndexDefault","fill","gray600","separator","background","gray200","margin","dropdownList","borderColor","CreateEntryMenuTrigger","contentTypes","suggestedContentTypeId","contentTypesLabel","onSelect","testId","dropdownSettings","customDropdownItems","children","isOpen","setOpen","useState","isSelecting","setSelecting","setSearchInput","useRef","textField","menuListRef","dropdownWidth","setDropdownWidth","hasDropdown","length","closeMenu","useEffect","setTimeout","current","querySelector","focus","preventScroll","_menuListRef$current","clientWidth","handleSelect","item","res","sys","id","then","isSearchable","maxDropdownHeight","suggestedContentType","find","ct","filteredContentTypes","filter","get","toLowerCase","includes","React","className","ref","Menu","placement","isAutoalignmentEnabled","onClose","onOpen","Trigger","List","style","width","undefined","maxHeight","Boolean","Divider","TextInput","placeholder","value","onChange","e","target","SearchIcon","resultsLength","SectionTitle","Item","onClick","map","contentType","i","key","defaultProps","standardStyles","spinnerMargin","marginRight","spacingXs","action","redesignStyles","textDecoration","fontWeight","maxWidth","CreateEntryLinkButton","text","hasPlusIcon","useExperimentalStyles","disabled","sort","a","b","name","localeCompare","buttonText","plusIcon","PlusIcon","Button","endIcon","ChevronDownIcon","variant","isDisabled","startIcon","size","isLoading","NoLinkPermissionsInfo","Paragraph","container","display","marginTop","defaultEntryLabels","createNew","props","linkExisting","canLinkMultiple","defaultAssetLabels","testIds","dropdown","createAndLink","createAndLinkWrapper","LinkActions","isFull","labels","entityType","actionLabels","canCreateEntity","contentTypeId","onCreate","itemsLength","Promise","resolve","canLinkEntity","onLinkExisting","LinkIcon","border","gray500","borderRadius","borderRadiusMedium","justifyContent","sharedTextIds","actionsWrapper","CombinedLinkActions","isEmpty","CombinedEntryLinkActions","CombinedAssetLinkActions","combinedActionsLabel","card","squareCard","alignItems","height","textAlign","MissingEntityCard","Card","Flex","asSquare","SectionHeading","marginBottom","onRemove","IconButton","icon","CloseIcon","getContentTypeIds","useLinkActionsProps","sdk","editorPermissions","maxLinksCount","validations","numberOfLinks","_editorPermissions$va","max","field","getValue","linkCount","Array","isArray","onCreated","entity","index","slide","onAction","type","entityData","onLinkedExisting","entities","onLink","forEach","async","navigator","openNewEntry","slideIn","openNewAsset","createEntity","dialogs","selectSingleEntry","locale","readableContentTypes","selectSingleAsset","mimetypeGroups","selectSingleEntity","onLinkSeveralExisting","min","Math","selectMultipleEntries","selectMultipleAssets","selectMultipleEntities","useMemo","creatableContentTypes","join","LinkEntityActions","renderCustomActions","CombinedLinkEntityActions","getScheduleTooltipContent","job","jobsCount","date","scheduledFor","datetime","short","moment","startOf","diff","format","formatDate","utc","local","formatTime","ScheduleTooltip","Tooltip","as","content","ScheduledIconWithTooltip","entityId","getEntityScheduledActions","status","setStatus","data","jobs","catch","error","AssetThumbnail","alt","file","fileName","src","url","globalQueue","PQueue","concurrency","UnsupportedError","Error","constructor","message","isUnsupportedError","InternalServiceProvider","useFetch","useEntityLoader","useCurrentIds","constate","currentSpaceId","ids","space","currentEnvironmentId","environmentAlias","environment","environmentIds","queryClient","useQueryClient","queryCache","getQueryCache","entityChangeUnsubscribers","cmaClient","createClient","apiAdapter","cmaAdapter","queryQueue","queryConcurrency","fetch","useCallback","queryKey","fn","options","priority","queryOptions","fetchQuery","add","getEntity","spaceId","environmentId","entry","entryId","asset","assetId","scheduledActions","getMany","query","order","limit","items","getResource","resourceType","urn","params","resourceId","split","all","defaultLocaleCode","default","_locales$items$find","code","resource","fetchContentfulEntry","isSameSpaceEntityQueryKey","isEntityQueryKey","onEntityChanged","onSlideInNavigation","findSameSpaceQueries","findAll","predicate","oldSlideLevel","newSlideLevel","invalidateQueries","subscribeQuery","queryHash","setQueryData","unsubscribe","subscribe","event","Object","values","off","useEntity","useQuery","enabled","useResource","EntityProvider","reactQueryClient","QueryCache","QueryClient","defaultOptions","queries","useErrorBoundary","refetchOnWindowFocus","refetchOnReconnect","refetchOnMount","staleTime","Infinity","retry","QueryClientProvider","client","ReferenceEditor","FieldConnector","throttle","isInitiallyDisabled","isEqualValues","value1","value2","deepEqual","hasCardEditActions","AllowActionsOnContentType","useAccessApi","accessApi","canPerformAction","can","canPerformActionOnEntryOfType","useEditorPermissions","parameters","linkContentTypeValidations","v","linkMimetypeGroupValidations","sizeValidations","isNumber","linkContentType","linkMimetypeGroup","fromFieldValidations","setCanCreateEntity","setCanLinkEntity","availableContentTypes","allContentTypes","_props$validations$co","setCreatableContentTypes","setReadableContentTypes","access","getContentTypes","arr","fail","Symbol","x","creatable","readable","checkContentTypeAccess","useContentTypePermissions","instance","showCreateEntityAction","canCreate","checkCreateAccess","showLinkEntityAction","canRead","checkLinkAccess","Editor","setValue","linkType","linkActionsProps","customCardRenderer","cardProps","_","renderDefaultCard","renderCustomCard","SingleReferenceEditor","getCachedContentTypes","externalReset","hasCardRemoveActions","spaceIcon","flexShrink","purple600","spaceName","color","gray700","fontSize","fontSizeS","fontWeightDemiBold","overflow","whiteSpace","SpaceName","gap","FolderOpenTrimmedIcon","Text","getEntryTitle","getEntityDescription","getEntryStatus","getEntryImage","entityHelpers","scheduleIcon","WrappedEntryCard","setFile","localeCode","getAsset","_props$entry","title","defaultTitle","description","EntryCard","entryUrl","href","isSelected","ClockIcon","thumbnailElement","isValidImage","dragHandleRender","renderDragHandle","withDragHandle","actions","onEdit","MenuItem","hasCardMoveActions","onMoveTop","onMoveBottom","MenuDivider","isClickable","preventDefault","FetchingWrappedEntryCard","loadEntityScheduledActions","viewType","bulkEditing","openBulkEditor","getSys","fieldId","openEntry","onRemoveEntry","renderCustomMissingEntityCard","defaultCard","sharedCardProps","entityUrl","getEntityUrl","locales","isBeingDragged","builtinCardProps","renderedCustomCard","SingleEntryReferenceEditor","onLinkOrCreate","links","newItems","from","splice","emptyArray","nullableValue","setIndexToUpdate","link","onSortStart","MouseEvent","document","body","classList","onSortEnd","oldIndex","newIndex","onSortingEnd","arrayMove","remove","onMove","MultipleReferenceEditor","zIndexModal","DragHandle","SortableDragHandle","SortableHandle","drag","SortableLink","SortableElement","SortableLinkListInternal","SortableContainer","cx","SortableLinkList","distance","renderAssetInfo","entityFile","mimeType","fileSize","image","isTruncated","shortenStorageUnit","renderActions","window","open","groupToIconMap","video","audio","richtext","presentation","spreadsheet","pdfdocument","archive","plaintext","markup","getFileType","groupName","mimetype","getGroupLabel","fallbackFileName","WrappedAssetCard","getAssetUrl","entityTitle","getAssetTitle","fields","AssetCard","onKeyDown","WrappedAssetLink","FetchingWrappedAssetCard","openAsset","commonProps","customProps","SingleMediaEditor","flexWrap","MultipleMediaEditor","childrenProps","axis","useDragHandle","_value","resolveAsset","resolveScheduledActions","ContentfulEntryCard","info","getEntryRouteHref","resourceSys","resourceHref","UnsupportedEntityCard","ResourceCardSkeleton","ExistingResourceCard","resourceLink","inView","resourceOptions","ResourceCardWrapper","ResourceCard","useInView","triggerOnce","rootMargin","toLinkItem","apiUrl","useResourceLinkActions","onAfterLink","handleAfterLink","entries","updatedValue","linkItems","getUpdatedValue","multiple","promptSelection","selectMultipleResourceEntries","allowedResources","selectSingleResourceEntry","ResourceEditor","onRemoteItemAtIndex","_v","WithPerItemCallbacks","listLength","handleMoveTop","handleMoveBottom","handleRemove","EMPTY_ARRAY","indexToUpdate","updateBeforeSortStart","lastIndex","editorProps","removeValue"],"mappings":"ysBAYA,MAEMA,EAEF,eACa,8BACC,cAGZC,EAAS,CACbC,QAASC,MAAI,CACXC,SAAU,aAEZC,aAAcF,MAAI,CAChBC,SAAU,WACVE,aAAcC,EAAOC,aAEvBC,YAAaN,MAAI,CACfO,aAAcH,EAAOI,UACrBC,aAAc,aAEhBC,WAAYV,MAAI,CACdC,SAAU,WACVU,MAAOP,EAAOQ,SACdC,IAAKT,EAAOU,SACZC,OAAQC,OAAOZ,EAAOa,eACtBC,KAAMd,EAAOe,UAEfC,UAAWpB,MAAI,CACbqB,WAAYjB,EAAOkB,QACnBC,OAAQ,WAEVC,aAAcxB,MAAI,CAChByB,YAAarB,EAAOkB,WA+BXI,EAAyB,EACpCC,aAAAA,EACAC,uBAAAA,EACAC,kBAAAA,EACAC,SAAAA,EACAC,OAAAA,EACAC,iBAAAA,EAAmB,CACjB/B,SAAU,eAEZgC,oBAAAA,EACAC,SAAAA,YAEOC,EAAQC,GAAWC,YAAS,IAC5BC,EAAaC,GAAgBF,YAAS,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