@payloadcms/richtext-lexical 3.60.0-canary.0 → 3.60.0-internal.40d58c0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/client/RelationshipComponent-JXQOFHXF.js +2 -0
- package/dist/exports/client/RelationshipComponent-JXQOFHXF.js.map +7 -0
- package/dist/exports/client/{chunk-XNERFY6G.js → chunk-IBFFIWII.js} +2 -2
- package/dist/exports/client/{chunk-XNERFY6G.js.map → chunk-IBFFIWII.js.map} +2 -2
- package/dist/exports/client/chunk-O6XRT2H3.js +2 -0
- package/dist/exports/client/{chunk-BQCXN3B4.js.map → chunk-O6XRT2H3.js.map} +4 -4
- package/dist/exports/client/component-WT25HAJA.js +2 -0
- package/dist/exports/client/component-WT25HAJA.js.map +7 -0
- package/dist/exports/client/componentInline-ZHQ2OTFH.js +2 -0
- package/dist/exports/client/index.d.ts +1 -1
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +22 -22
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blocks/premade/CodeBlock/index.d.ts +3 -1
- package/dist/features/blocks/premade/CodeBlock/index.d.ts.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/index.js +7 -2
- package/dist/features/blocks/premade/CodeBlock/index.js.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts +2 -3
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +2 -3
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/heading/server/index.d.ts +1 -1
- package/dist/features/heading/server/index.d.ts.map +1 -1
- package/dist/features/heading/server/index.js.map +1 -1
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts +2 -3
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts.map +1 -1
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +1 -6
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/client/drawer/index.d.ts +3 -2
- package/dist/features/relationship/client/drawer/index.d.ts.map +1 -1
- package/dist/features/relationship/client/drawer/index.js +72 -59
- package/dist/features/relationship/client/drawer/index.js.map +1 -1
- package/dist/features/relationship/client/plugins/index.d.ts.map +1 -1
- package/dist/features/relationship/client/plugins/index.js +41 -49
- package/dist/features/relationship/client/plugins/index.js.map +1 -1
- package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts +13 -0
- package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts.map +1 -0
- package/dist/features/relationship/client/utils/useEnabledRelationships.js +64 -0
- package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -0
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +2 -3
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/upload/client/component/index.d.ts +1 -1
- package/dist/features/upload/client/component/index.d.ts.map +1 -1
- package/dist/features/upload/client/component/index.js +1 -11
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/drawer/index.d.ts +3 -2
- package/dist/features/upload/client/drawer/index.d.ts.map +1 -1
- package/dist/features/upload/client/drawer/index.js +8 -9
- package/dist/features/upload/client/drawer/index.js.map +1 -1
- package/dist/features/upload/client/index.d.ts +2 -1
- package/dist/features/upload/client/index.d.ts.map +1 -1
- package/dist/features/upload/client/index.js.map +1 -1
- package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
- package/dist/features/upload/client/plugin/index.js +72 -75
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/features/upload/server/index.d.ts +18 -3
- package/dist/features/upload/server/index.d.ts.map +1 -1
- package/dist/features/upload/server/index.js +6 -0
- package/dist/features/upload/server/index.js.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts +2 -3
- package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/nodeTypes.d.ts +23 -14
- package/dist/nodeTypes.d.ts.map +1 -1
- package/dist/nodeTypes.js.map +1 -1
- package/dist/utilities/buildEditorState.d.ts +47 -6
- package/dist/utilities/buildEditorState.d.ts.map +1 -1
- package/dist/utilities/buildEditorState.js +9 -1
- package/dist/utilities/buildEditorState.js.map +1 -1
- package/package.json +6 -6
- package/dist/exports/client/RelationshipComponent-TSIENULZ.js +0 -2
- package/dist/exports/client/RelationshipComponent-TSIENULZ.js.map +0 -7
- package/dist/exports/client/chunk-BQCXN3B4.js +0 -2
- package/dist/exports/client/component-CYFKY3IL.js +0 -2
- package/dist/exports/client/component-CYFKY3IL.js.map +0 -7
- package/dist/exports/client/componentInline-NGTRUSGB.js +0 -2
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.d.ts +0 -7
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.d.ts.map +0 -1
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js +0 -96
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js.map +0 -1
- /package/dist/exports/client/{componentInline-NGTRUSGB.js.map → componentInline-ZHQ2OTFH.js.map} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.60.0-
|
|
3
|
+
"version": "3.60.0-internal.40d58c0",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -373,8 +373,8 @@
|
|
|
373
373
|
"react-error-boundary": "4.1.2",
|
|
374
374
|
"ts-essentials": "10.0.3",
|
|
375
375
|
"uuid": "10.0.0",
|
|
376
|
-
"@payloadcms/
|
|
377
|
-
"@payloadcms/
|
|
376
|
+
"@payloadcms/translations": "3.60.0-internal.40d58c0",
|
|
377
|
+
"@payloadcms/ui": "3.60.0-internal.40d58c0"
|
|
378
378
|
},
|
|
379
379
|
"devDependencies": {
|
|
380
380
|
"@babel/cli": "7.27.2",
|
|
@@ -394,15 +394,15 @@
|
|
|
394
394
|
"esbuild-sass-plugin": "3.3.1",
|
|
395
395
|
"swc-plugin-transform-remove-imports": "4.0.4",
|
|
396
396
|
"@payloadcms/eslint-config": "3.28.0",
|
|
397
|
-
"payload": "3.60.0-
|
|
397
|
+
"payload": "3.60.0-internal.40d58c0"
|
|
398
398
|
},
|
|
399
399
|
"peerDependencies": {
|
|
400
400
|
"@faceless-ui/modal": "3.0.0",
|
|
401
401
|
"@faceless-ui/scroll-info": "2.0.0",
|
|
402
402
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
403
403
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
404
|
-
"@payloadcms/next": "3.60.0-
|
|
405
|
-
"payload": "3.60.0-
|
|
404
|
+
"@payloadcms/next": "3.60.0-internal.40d58c0",
|
|
405
|
+
"payload": "3.60.0-internal.40d58c0"
|
|
406
406
|
},
|
|
407
407
|
"engines": {
|
|
408
408
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";import{a as f}from"./chunk-DBWINSQN.js";import{a as b}from"./chunk-F26IQ5RE.js";import{jsx as t,jsxs as u}from"react/jsx-runtime";import{useLexicalComposerContext as S}from"@lexical/react/LexicalComposerContext.js";import{useLexicalEditable as j}from"@lexical/react/useLexicalEditable";import{getTranslation as B}from"@payloadcms/translations";import{Button as _,useConfig as L,usePayloadAPI as A,useTranslation as I}from"@payloadcms/ui";import{$getNodeByKey as P}from"lexical";import k,{useCallback as H,useReducer as K,useRef as M,useState as O}from"react";var e="lexical-relationship",g={depth:0},W=a=>{let{data:{relationTo:R,value:l},nodeKey:s}=a;if(typeof l=="object")throw new Error("Relationship value should be a string or number. The Lexical Relationship component should not receive the populated value object.");let C=M(null),[i]=S(),n=j(),{config:{routes:{api:v},serverURL:x},getEntityConfig:N}=L(),[o]=O(()=>N({collectionSlug:R})),{i18n:$,t:r}=I(),[m,w]=K(c=>c+1,0),[{data:d},{setParams:p}]=A(`${x}${v}/${o.slug}/${l}`,{initialParams:g}),{closeDocumentDrawer:h,DocumentDrawer:D,DocumentDrawerToggler:E}=b({id:l,collectionSlug:o.slug}),T=H(()=>{i.update(()=>{P(s)?.remove()})},[i,s]),y=k.useCallback(()=>{p({...g,cacheBust:m}),h(),w()},[m,p,h]);return u("div",{className:e,contentEditable:!1,ref:C,children:[u("div",{className:`${e}__wrap`,children:[t("p",{className:`${e}__label`,children:r("fields:labelRelationship",{label:o.labels?.singular?B(o.labels?.singular,$):o.slug})}),t(E,{className:`${e}__doc-drawer-toggler`,children:t("p",{className:`${e}__title`,children:d?d[o?.admin?.useAsTitle||"id"]:l})})]}),n&&u("div",{className:`${e}__actions`,children:[t(_,{buttonStyle:"icon-label",className:`${e}__swapButton`,disabled:!n,el:"button",icon:"swap",onClick:()=>{s&&i.dispatchCommand(f,{replace:{nodeKey:s}})},round:!0,tooltip:r("fields:swapRelationship")}),t(_,{buttonStyle:"icon-label",className:`${e}__removeButton`,disabled:!n,icon:"x",onClick:c=>{c.preventDefault(),T()},round:!0,tooltip:r("fields:removeRelationship")})]}),!!l&&t(D,{onSave:y})]})},Y=a=>t(W,{...a});export{Y as RelationshipComponent};
|
|
2
|
-
//# sourceMappingURL=RelationshipComponent-TSIENULZ.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/features/relationship/client/components/RelationshipComponent.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\nimport type { ElementFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button, useConfig, usePayloadAPI, useTranslation } from '@payloadcms/ui'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useReducer, useRef, useState } from 'react'\n\nimport type { RelationshipData } from '../../server/nodes/RelationshipNode.js'\n\nimport { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js'\nimport './index.scss'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\n\nconst baseClass = 'lexical-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n className?: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nconst Component: React.FC<Props> = (props) => {\n const {\n data: { relationTo, value },\n nodeKey,\n } = props\n\n if (typeof value === 'object') {\n throw new Error(\n 'Relationship value should be a string or number. The Lexical Relationship component should not receive the populated value object.',\n )\n }\n\n const relationshipElemRef = useRef<HTMLDivElement | null>(null)\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n\n const [relatedCollection] = useState(() => getEntityConfig({ collectionSlug: relationTo }))\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value}`,\n { initialParams },\n )\n\n const { closeDocumentDrawer, DocumentDrawer, DocumentDrawerToggler } = useLexicalDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey!)?.remove()\n })\n }, [editor, nodeKey])\n\n const updateRelationship = React.useCallback(() => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDocumentDrawer()\n dispatchCacheBust()\n }, [cacheBust, setParams, closeDocumentDrawer])\n\n return (\n <div className={baseClass} contentEditable={false} ref={relationshipElemRef}>\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: relatedCollection.labels?.singular\n ? getTranslation(relatedCollection.labels?.singular, i18n)\n : relatedCollection.slug,\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : value}\n </p>\n </DocumentDrawerToggler>\n </div>\n {isEditable && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swapButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"swap\"\n onClick={() => {\n if (nodeKey) {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n )}\n\n {!!value && <DocumentDrawer onSave={updateRelationship} />}\n </div>\n )\n}\n\nexport const RelationshipComponent = (props: Props): React.ReactNode => {\n return <Component {...props} />\n}\n"],
|
|
5
|
-
"mappings": "+IAGA,OAASA,6BAAAA,MAAiC,2CAC1C,OAASC,sBAAAA,MAA0B,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MAG1C,EAEa2B,EAAyBpE,GAC7B+C,EAAChD,EAAA,CAAW,GAAGC",
|
|
6
|
-
"names": ["useLexicalComposerContext", "useLexicalEditable", "getTranslation", "Button", "useConfig", "usePayloadAPI", "useTranslation", "$getNodeByKey", "React", "useCallback", "useReducer", "useRef", "useState", "baseClass", "initialParams", "depth", "Component", "props", "data", "relationTo", "value", "nodeKey", "Error", "relationshipElemRef", "useRef", "editor", "useLexicalComposerContext", "isEditable", "useLexicalEditable", "config", "routes", "api", "serverURL", "getEntityConfig", "useConfig", "relatedCollection", "useState", "collectionSlug", "i18n", "t", "useTranslation", "cacheBust", "dispatchCacheBust", "useReducer", "state", "setParams", "usePayloadAPI", "slug", "closeDocumentDrawer", "DocumentDrawer", "DocumentDrawerToggler", "useLexicalDocumentDrawer", "id", "removeRelationship", "useCallback", "update", "$getNodeByKey", "remove", "updateRelationship", "React", "_jsxs", "className", "contentEditable", "ref", "_jsx", "label", "labels", "singular", "getTranslation", "admin", "useAsTitle", "Button", "buttonStyle", "disabled", "el", "icon", "onClick", "dispatchCommand", "INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND", "replace", "round", "tooltip", "e", "preventDefault", "onSave", "RelationshipComponent"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as F}from"./chunk-BZZVLW4U.js";import{c as z}from"react/compiler-runtime";import{jsx as R}from"react/jsx-runtime";import{Drawer as G,EditDepthProvider as J,useModal as K}from"@payloadcms/ui";import"react";import{jsx as y,jsxs as M}from"react/jsx-runtime";import{useLexicalEditable as v}from"@lexical/react/useLexicalEditable";import{Form as T,FormSubmit as $,RenderFields as N,useDocumentForm as W,useDocumentInfo as k,useServerFunctions as B,useTranslation as L}from"@payloadcms/ui";import{abortAndIgnore as x}from"@payloadcms/ui/shared";import{deepCopyObjectSimpleWithoutReactComponents as O}from"payload/shared";import{useCallback as H,useEffect as I,useRef as U,useState as V}from"react";import{v4 as q}from"uuid";var j=({data:c,featureKey:e,fieldMapOverride:u,handleDrawerSubmit:m,schemaFieldsPathOverride:o,schemaPath:d,schemaPathSuffix:f})=>{let{t:p}=L(),{id:i,collectionSlug:a,getDocPreferences:l,globalSlug:s}=k(),{fields:t}=W(),n=v(),r=U(new AbortController),[h,w]=V(!1),{fieldProps:{featureClientSchemaMap:A}}=F(),{getFormState:b}=B(),S=o??`${d}.lexical_internal_feature.${e}${f?`.${f}`:""}`,g=u??A[e]?.[S];I(()=>{let C=new AbortController;return(async()=>{let{state:_}=await b({id:i,collectionSlug:a,data:c??{},docPermissions:{fields:!0},docPreferences:await l(),documentFormState:O(t),globalSlug:s,initialBlockData:c,operation:"update",readOnly:!n,renderAllFields:!0,schemaPath:S,signal:C.signal});w(_)})(),()=>{x(C)}},[S,i,c,b,a,n,s,l,t]);let E=H(async({formState:C})=>{x(r.current);let P=new AbortController;r.current=P;let{state:_}=await b({id:i,collectionSlug:a,docPermissions:{fields:!0},docPreferences:await l(),documentFormState:O(t),formState:C,globalSlug:s,initialBlockFormState:C,operation:"update",readOnly:!n,schemaPath:S,signal:P.signal});return _||C},[b,i,n,a,l,t,s,S]);return I(()=>()=>{x(r.current)},[]),h===!1?null:M(T,{beforeSubmit:[E],disableValidationOnSubmit:!0,fields:Array.isArray(g)?g:[],initialState:h,onChange:[E],onSubmit:m,uuid:q(),children:[y(N,{fields:Array.isArray(g)?g:[],forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:S,permissions:!0,readOnly:!n}),y($,{children:p("fields:saveChanges")})]})};var _e=c=>{let e=z(15),{className:u,data:m,drawerSlug:o,drawerTitle:d,featureKey:f,fieldMapOverride:p,handleDrawerSubmit:i,schemaFieldsPathOverride:a,schemaPath:l,schemaPathSuffix:s}=c,{closeModal:t}=K(),n=d??"",r;e[0]!==t||e[1]!==o||e[2]!==i?(r=(w,A)=>{t(o),setTimeout(()=>{i(w,A)},1)},e[0]=t,e[1]=o,e[2]=i,e[3]=r):r=e[3];let h;return e[4]!==u||e[5]!==m||e[6]!==o||e[7]!==f||e[8]!==p||e[9]!==a||e[10]!==l||e[11]!==s||e[12]!==n||e[13]!==r?(h=R(J,{children:R(G,{className:u,slug:o,title:n,children:R(j,{data:m,featureKey:f,fieldMapOverride:p,handleDrawerSubmit:r,schemaFieldsPathOverride:a,schemaPath:l,schemaPathSuffix:s})})}),e[4]=u,e[5]=m,e[6]=o,e[7]=f,e[8]=p,e[9]=a,e[10]=l,e[11]=s,e[12]=n,e[13]=r,e[14]=h):h=e[14],h};import{c as Q}from"react/compiler-runtime";import{jsx as X}from"react/jsx-runtime";import{useAuth as Y,useConfig as Z,useEntityVisibility as ee}from"@payloadcms/ui";import*as D from"react";var te=(c,e)=>c.filter(({slug:u,admin:{enableRichTextRelationship:m},upload:o})=>e?.visibleEntities?.collections.includes(u)?e?.uploads?m&&!!o:o?!1:m:!1),xe=c=>{let e=Q(12),{children:u,FallbackComponent:m,uploads:o,...d}=c,f=o===void 0?!1:o,{config:p}=Z(),{collections:i}=p,{user:a}=Y(),{visibleEntities:l}=ee(),s;e[0]!==i||e[1]!==f||e[2]!==a||e[3]!==l?(s=()=>te(i,{uploads:f,user:a,visibleEntities:l}).map(re),e[0]=i,e[1]=f,e[2]=a,e[3]=l,e[4]=s):s=e[4];let[t]=D.useState(s);if(!t.length)return m?X(m,{...d}):null;let n;if(e[5]!==u||e[6]!==t||e[7]!==d){let r;e[9]!==t||e[10]!==d?(r={...d,enabledCollectionSlugs:t},e[9]=t,e[10]=d,e[11]=r):r=e[11],n=D.cloneElement(u,r),e[5]=u,e[6]=t,e[7]=d,e[8]=n}else n=e[8];return n};function re(c){let{slug:e}=c;return e}import{createCommand as oe}from"lexical";var Fe=oe("INSERT_UPLOAD_WITH_DRAWER_COMMAND");export{_e as a,xe as b,Fe as c};
|
|
2
|
-
//# sourceMappingURL=chunk-BQCXN3B4.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";import{a as S,b as y,c as R}from"./chunk-BQCXN3B4.js";import{a as x}from"./chunk-INBEEENE.js";import{a as N}from"./chunk-F26IQ5RE.js";import{b as p}from"./chunk-BZZVLW4U.js";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{useLexicalComposerContext as Y}from"@lexical/react/LexicalComposerContext.js";import{useLexicalEditable as Z}from"@lexical/react/useLexicalEditable";import{getTranslation as E}from"@payloadcms/translations";import{Button as h,formatDrawerSlug as ee,Thumbnail as te,useConfig as oe,useEditDepth as ae,usePayloadAPI as le,useTranslation as ie}from"@payloadcms/ui";import{$getNodeByKey as L}from"lexical";import{isImage as re}from"payload/shared";import{useCallback as f,useId as se,useReducer as ne,useRef as de,useState as ce}from"react";var e="lexical-upload",P={depth:0},ue=d=>{let{data:{fields:T,relationTo:g,value:c},nodeKey:l}=d;if(typeof c=="object")throw new Error("Upload value should be a string or number. The Lexical Upload component should not receive the populated value object.");let{config:{routes:{api:U},serverURL:F},getEntityConfig:j}=oe(),I=de(null),{uuid:z}=p(),B=ae(),[i]=Y(),{editorConfig:k,fieldProps:{schemaPath:A}}=p(),u=Z(),{i18n:_,t:r}=ie(),[b,K]=ne(s=>s+1,0),[a]=ce(()=>j({collectionSlug:g})),M=se(),w=ee({slug:"lexical-upload-drawer-"+z+M,depth:B}),{toggleDrawer:O}=x(w,!0),{closeDocumentDrawer:D,DocumentDrawer:W,DocumentDrawerToggler:H}=N({id:c,collectionSlug:a.slug}),[{data:o},{setParams:v}]=le(`${F}${U}/${a.slug}/${c}`,{initialParams:P}),C=o?.thumbnailURL||o?.url,q=f(()=>{i.update(()=>{L(l)?.remove()})},[i,l]),G=f(s=>{v({...P,cacheBust:b}),K(),D()},[v,b,D]),$=k?.resolvedFeatureMap?.get("upload")?.sanitizedClientFeatureProps.collections?.[a.slug]?.hasExtraFields,J=f((s,V)=>{i.update(()=>{let m=L(l);if(m){let X={...m.getData(),fields:V};m.setData(X)}})},[i,l]),Q=C&&o?.width&&o?.height?o.width>o.height?"landscape":"portrait":"landscape";return n("div",{className:`${e} ${e}--${Q}`,"data-filename":o?.filename,ref:I,children:[n("div",{className:`${e}__card`,children:[n("div",{className:`${e}__media`,children:[t(te,{collectionSlug:g,fileSrc:re(o?.mimeType)?C:null,height:o?.height,size:"none",width:o?.width}),u&&t("div",{className:`${e}__overlay ${e}__floater`,children:n("div",{className:`${e}__actions`,role:"toolbar",children:[$?t(h,{buttonStyle:"icon-label",className:`${e}__upload-drawer-toggler`,disabled:!u,el:"button",icon:"edit",onClick:O,round:!0,size:"medium",tooltip:r("fields:editRelationship")}):null,t(h,{buttonStyle:"icon-label",className:`${e}__swap-drawer-toggler`,disabled:!u,el:"button",icon:"swap",onClick:()=>{i.dispatchCommand(R,{replace:{nodeKey:l}})},round:!0,size:"medium",tooltip:r("fields:swapUpload")}),t(h,{buttonStyle:"icon-label",className:`${e}__removeButton`,disabled:!u,icon:"x",onClick:s=>{s.preventDefault(),q()},round:!0,size:"medium",tooltip:r("fields:removeUpload")})]})})]}),n("div",{className:`${e}__metaOverlay ${e}__floater`,children:[t(H,{className:`${e}__doc-drawer-toggler`,children:t("strong",{className:`${e}__filename`,children:o?.filename||r("general:untitled")})}),t("div",{className:`${e}__collectionLabel`,children:E(a.labels.singular,_)})]})]}),c?t(W,{onSave:G}):null,$?t(S,{data:T,drawerSlug:w,drawerTitle:r("general:editLabel",{label:E(a.labels.singular,_)}),featureKey:"upload",handleDrawerSubmit:J,schemaPath:A,schemaPathSuffix:a.slug}):null]})},ye=d=>t(y,{...d,uploads:!0,children:t(ue,{...d})});export{ye as UploadComponent};
|
|
2
|
-
//# sourceMappingURL=component-CYFKY3IL.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/features/upload/client/component/index.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\nimport type { ClientCollectionConfig, Data, FormState, JsonObject } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n formatDrawerSlug,\n Thumbnail,\n useConfig,\n useEditDepth,\n usePayloadAPI,\n useTranslation,\n} from '@payloadcms/ui'\nimport { $getNodeByKey, type ElementFormatType } from 'lexical'\nimport { isImage } from 'payload/shared'\nimport React, { useCallback, useId, useReducer, useRef, useState } from 'react'\n\nimport type { BaseClientFeatureProps } from '../../../typesClient.js'\nimport type { UploadData } from '../../server/nodes/UploadNode.js'\nimport type { UploadFeaturePropsClient } from '../index.js'\nimport type { UploadNode } from '../nodes/UploadNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { FieldsDrawer } from '../../../../utilities/fieldsDrawer/Drawer.js'\nimport { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { EnabledRelationshipsCondition } from '../../../relationship/client/utils/EnabledRelationshipsCondition.js'\nimport './index.scss'\nimport { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\n\nconst baseClass = 'lexical-upload'\n\nconst initialParams = {\n depth: 0,\n}\n\nexport type ElementProps = {\n data: UploadData\n format?: ElementFormatType\n nodeKey: string\n}\n\nconst Component: React.FC<ElementProps> = (props) => {\n const {\n data: { fields, relationTo, value },\n nodeKey,\n } = props\n\n if (typeof value === 'object') {\n throw new Error(\n 'Upload value should be a string or number. The Lexical Upload component should not receive the populated value object.',\n )\n }\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n const uploadRef = useRef<HTMLDivElement | null>(null)\n const { uuid } = useEditorConfigContext()\n const editDepth = useEditDepth()\n const [editor] = useLexicalComposerContext()\n\n const {\n editorConfig,\n fieldProps: { schemaPath },\n } = useEditorConfigContext()\n const isEditable = useLexicalEditable()\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection] = useState<ClientCollectionConfig>(() =>\n getEntityConfig({ collectionSlug: relationTo }),\n )\n\n const componentID = useId()\n\n const extraFieldsDrawerSlug = formatDrawerSlug({\n slug: `lexical-upload-drawer-` + uuid + componentID, // There can be multiple upload components, each with their own drawer, in one single editor => separate them by componentID\n depth: editDepth,\n })\n\n // Need to use hook to initialize useEffect that restores cursor position\n const { toggleDrawer } = useLexicalDrawer(extraFieldsDrawerSlug, true)\n\n const { closeDocumentDrawer, DocumentDrawer, DocumentDrawerToggler } = useLexicalDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value}`,\n { initialParams },\n )\n\n const thumbnailSRC = data?.thumbnailURL || data?.url\n\n const removeUpload = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const updateUpload = useCallback(\n (data: Data) => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n dispatchCacheBust()\n closeDocumentDrawer()\n },\n [setParams, cacheBust, closeDocumentDrawer],\n )\n\n const hasExtraFields = (\n editorConfig?.resolvedFeatureMap?.get('upload')\n ?.sanitizedClientFeatureProps as BaseClientFeatureProps<UploadFeaturePropsClient>\n ).collections?.[relatedCollection.slug]?.hasExtraFields\n\n const onExtraFieldsDrawerSubmit = useCallback(\n (_: FormState, data: JsonObject) => {\n // Update lexical node (with key nodeKey) with new data\n editor.update(() => {\n const uploadNode: null | UploadNode = $getNodeByKey(nodeKey)\n if (uploadNode) {\n const newData: UploadData = {\n ...uploadNode.getData(),\n fields: data,\n }\n uploadNode.setData(newData)\n }\n })\n },\n [editor, nodeKey],\n )\n\n const aspectRatio =\n thumbnailSRC && data?.width && data?.height\n ? data.width > data.height\n ? 'landscape'\n : 'portrait'\n : 'landscape'\n\n return (\n <div\n className={`${baseClass} ${baseClass}--${aspectRatio}`}\n data-filename={data?.filename}\n ref={uploadRef}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__media`}>\n <Thumbnail\n collectionSlug={relationTo}\n fileSrc={isImage(data?.mimeType) ? thumbnailSRC : null}\n height={data?.height}\n size=\"none\"\n width={data?.width}\n />\n\n {isEditable && (\n <div className={`${baseClass}__overlay ${baseClass}__floater`}>\n <div className={`${baseClass}__actions`} role=\"toolbar\">\n {hasExtraFields ? (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={toggleDrawer}\n round\n size=\"medium\"\n tooltip={t('fields:editRelationship')}\n />\n ) : null}\n\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swap-drawer-toggler`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_UPLOAD_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n size=\"medium\"\n tooltip={t('fields:swapUpload')}\n />\n\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeUpload()\n }}\n round\n size=\"medium\"\n tooltip={t('fields:removeUpload')}\n />\n </div>\n </div>\n )}\n </div>\n\n <div className={`${baseClass}__metaOverlay ${baseClass}__floater`}>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <strong className={`${baseClass}__filename`}>\n {data?.filename || t('general:untitled')}\n </strong>\n </DocumentDrawerToggler>\n <div className={`${baseClass}__collectionLabel`}>\n {getTranslation(relatedCollection.labels.singular, i18n)}\n </div>\n </div>\n </div>\n\n {value ? <DocumentDrawer onSave={updateUpload} /> : null}\n {hasExtraFields ? (\n <FieldsDrawer\n data={fields}\n drawerSlug={extraFieldsDrawerSlug}\n drawerTitle={t('general:editLabel', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n featureKey=\"upload\"\n handleDrawerSubmit={onExtraFieldsDrawerSubmit}\n schemaPath={schemaPath}\n schemaPathSuffix={relatedCollection.slug}\n />\n ) : null}\n </div>\n )\n}\n\nexport const UploadComponent = (props: ElementProps): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <Component {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],
|
|
5
|
-
"mappings": "6OAGA,OAASA,6BAAAA,MAAiC,2CAC1C,OAASC,sBAAAA,MAA0B,oCACnC,OAASC,kBAAAA,MAAsB,2BAC/B,OACEC,UAAAA,EACAC,oBAAAA,GACAC,aAAAA,GACAC,aAAAA,GACAC,gBAAAA,GACAC,iBAAAA,GACAC,kBAAAA,OACK,iBACP,OAASC,iBAAAA,MAA6C,UACtD,OAASC,WAAAA,OAAe,iBACxB,OAAgBC,eAAAA,EAAaC,SAAAA,GAAOC,cAAAA,GAAYC,UAAAA,GAAQC,YAAAA,OAAgB,QAexE,IAAMC,EAAY,iBAEZC,EAAgB,CACpBC,MAAO,CACT,EAQMC,GAAqCC,GAAA,CACzC,GAAM,CACJC,KAAM,CAAEC,OAAAA,EAAQC,WAAAA,EAAYC,MAAAA,CAAK,EACjCC,QAAAA,CAAO,EACLL,EAEJ,GAAI,OAAOI,GAAU,SACnB,MAAM,IAAIE,MACR,wHAAA,EAIJ,GAAM,CACJC,OAAQ,CACNC,OAAQ,CAAEC,IAAAA,CAAG,EACbC,UAAAA,CAAS,EAEXC,gBAAAA,CAAe,EACbC,GAAA,EACEC,EAAYC,GAA8B,IAAA,EAC1C,CAAEC,KAAAA,CAAI,EAAKC,EAAA,EACXC,EAAYC,GAAA,EACZ,CAACC,CAAA,EAAUC,EAAA,EAEX,CACJC,aAAAA,EACAC,WAAY,CAAEC,WAAAA,CAAU,CAAE,EACxBP,EAAA,EACEQ,EAAaC,EAAA,EACb,CA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aACZX,UAAW,GAAG9E,CAAA,iBACd0F,SAAU,CAAC9D,EACXgE,KAAK,IACLC,QAAUM,GAAA,CACRA,EAAEC,eAAc,EAChB3C,EAAA,CACF,EACAqC,MAAK,GACLR,KAAK,SACLS,QAAShE,EAAE,qBAAA,YAOrB8C,EAAC,MAAA,CAAIC,UAAW,GAAG9E,CAAA,iBAA0BA,CAAA,sBAC3CiF,EAAChC,EAAA,CAAsB6B,UAAW,GAAG9E,CAAA,gCACnCiF,EAAC,SAAA,CAAOH,UAAW,GAAG9E,CAAA,sBACnBK,GAAM0E,UAAYhD,EAAE,kBAAA,MAGzBkD,EAAC,MAAA,CAAIH,UAAW,GAAG9E,CAAA,6BAChBqG,EAAehE,EAAkBiE,OAAOC,SAAUzE,CAAA,UAKxDtB,EAAQyE,EAACjC,EAAA,CAAewD,OAAQ1C,IAAmB,KACnDC,EACCkB,EAACwB,EAAA,CACCpG,KAAMC,EACNoG,WAAYhE,EACZiE,YAAa5E,EAAE,oBAAqB,CAClC6E,MAAOP,EAAehE,EAAkBiE,OAAOC,SAAUzE,CAAA,CAC3D,CAAA,EACA+E,WAAW,SACXC,mBAAoB1C,EACpBzC,WAAYA,EACZoF,iBAAkB1E,EAAkBO,OAEpC,IAAA,GAGV,EAEaoE,GAAmB5G,GAE5B6E,EAACgC,EAAA,CAA+B,GAAG7G,EAAO8G,QAAO,YAC/CjC,EAAC9E,GAAA,CAAW,GAAGC",
|
|
6
|
-
"names": ["useLexicalComposerContext", "useLexicalEditable", "getTranslation", "Button", "formatDrawerSlug", "Thumbnail", "useConfig", "useEditDepth", "usePayloadAPI", "useTranslation", "$getNodeByKey", "isImage", "useCallback", "useId", "useReducer", "useRef", "useState", "baseClass", "initialParams", "depth", "Component", "props", "data", "fields", "relationTo", "value", "nodeKey", "Error", "config", "routes", "api", "serverURL", "getEntityConfig", "useConfig", "uploadRef", "useRef", "uuid", "useEditorConfigContext", "editDepth", "useEditDepth", "editor", "useLexicalComposerContext", "editorConfig", "fieldProps", "schemaPath", "isEditable", "useLexicalEditable", "i18n", "t", "useTranslation", "cacheBust", "dispatchCacheBust", "useReducer", "state", "relatedCollection", "useState", "collectionSlug", "componentID", "useId", "extraFieldsDrawerSlug", "formatDrawerSlug", "slug", "toggleDrawer", "useLexicalDrawer", "closeDocumentDrawer", "DocumentDrawer", "DocumentDrawerToggler", "useLexicalDocumentDrawer", "id", "setParams", "usePayloadAPI", "thumbnailSRC", "thumbnailURL", "url", "removeUpload", "useCallback", "update", "$getNodeByKey", "remove", "updateUpload", "hasExtraFields", "resolvedFeatureMap", "get", "sanitizedClientFeatureProps", "collections", "onExtraFieldsDrawerSubmit", "_", "uploadNode", "newData", "getData", "setData", "aspectRatio", "width", "height", "_jsxs", "className", "filename", "ref", "_jsx", "Thumbnail", "fileSrc", "isImage", "mimeType", "size", "role", "Button", "buttonStyle", "disabled", "el", "icon", "onClick", "round", "tooltip", "dispatchCommand", "INSERT_UPLOAD_WITH_DRAWER_COMMAND", "replace", "e", "preventDefault", "getTranslation", "labels", "singular", "onSave", "FieldsDrawer", "drawerSlug", "drawerTitle", "label", "featureKey", "handleDrawerSubmit", "schemaPathSuffix", "UploadComponent", "EnabledRelationshipsCondition", "uploads"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EnabledRelationshipsCondition.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/client/utils/EnabledRelationshipsCondition.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AA2B9B,eAAO,MAAM,6BAA6B,EAAE,KAAK,CAAC,EAAE,CAAC;IACnD,QAAQ,EAAE,GAAG,CAAA;IACb,iBAAiB,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAmBA,CAAA"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { c as _c } from "react/compiler-runtime";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
import { useAuth, useConfig, useEntityVisibility } from '@payloadcms/ui';
|
|
6
|
-
import * as React from 'react';
|
|
7
|
-
const filterRichTextCollections = (collections, options) => {
|
|
8
|
-
return collections.filter(({
|
|
9
|
-
slug,
|
|
10
|
-
admin: {
|
|
11
|
-
enableRichTextRelationship
|
|
12
|
-
},
|
|
13
|
-
upload
|
|
14
|
-
}) => {
|
|
15
|
-
if (!options?.visibleEntities?.collections.includes(slug)) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
if (options?.uploads) {
|
|
19
|
-
return enableRichTextRelationship && Boolean(upload) === true;
|
|
20
|
-
}
|
|
21
|
-
return upload ? false : enableRichTextRelationship;
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
export const EnabledRelationshipsCondition = props => {
|
|
25
|
-
const $ = _c(12);
|
|
26
|
-
const {
|
|
27
|
-
children,
|
|
28
|
-
FallbackComponent,
|
|
29
|
-
uploads: t0,
|
|
30
|
-
...rest
|
|
31
|
-
} = props;
|
|
32
|
-
const uploads = t0 === undefined ? false : t0;
|
|
33
|
-
const {
|
|
34
|
-
config: t1
|
|
35
|
-
} = useConfig();
|
|
36
|
-
const {
|
|
37
|
-
collections
|
|
38
|
-
} = t1;
|
|
39
|
-
const {
|
|
40
|
-
user
|
|
41
|
-
} = useAuth();
|
|
42
|
-
const {
|
|
43
|
-
visibleEntities
|
|
44
|
-
} = useEntityVisibility();
|
|
45
|
-
let t2;
|
|
46
|
-
if ($[0] !== collections || $[1] !== uploads || $[2] !== user || $[3] !== visibleEntities) {
|
|
47
|
-
t2 = () => filterRichTextCollections(collections, {
|
|
48
|
-
uploads,
|
|
49
|
-
user,
|
|
50
|
-
visibleEntities
|
|
51
|
-
}).map(_temp);
|
|
52
|
-
$[0] = collections;
|
|
53
|
-
$[1] = uploads;
|
|
54
|
-
$[2] = user;
|
|
55
|
-
$[3] = visibleEntities;
|
|
56
|
-
$[4] = t2;
|
|
57
|
-
} else {
|
|
58
|
-
t2 = $[4];
|
|
59
|
-
}
|
|
60
|
-
const [enabledCollectionSlugs] = React.useState(t2);
|
|
61
|
-
if (!enabledCollectionSlugs.length) {
|
|
62
|
-
return FallbackComponent ? _jsx(FallbackComponent, {
|
|
63
|
-
...rest
|
|
64
|
-
}) : null;
|
|
65
|
-
}
|
|
66
|
-
let t3;
|
|
67
|
-
if ($[5] !== children || $[6] !== enabledCollectionSlugs || $[7] !== rest) {
|
|
68
|
-
let t4;
|
|
69
|
-
if ($[9] !== enabledCollectionSlugs || $[10] !== rest) {
|
|
70
|
-
t4 = {
|
|
71
|
-
...rest,
|
|
72
|
-
enabledCollectionSlugs
|
|
73
|
-
};
|
|
74
|
-
$[9] = enabledCollectionSlugs;
|
|
75
|
-
$[10] = rest;
|
|
76
|
-
$[11] = t4;
|
|
77
|
-
} else {
|
|
78
|
-
t4 = $[11];
|
|
79
|
-
}
|
|
80
|
-
t3 = React.cloneElement(children, t4);
|
|
81
|
-
$[5] = children;
|
|
82
|
-
$[6] = enabledCollectionSlugs;
|
|
83
|
-
$[7] = rest;
|
|
84
|
-
$[8] = t3;
|
|
85
|
-
} else {
|
|
86
|
-
t3 = $[8];
|
|
87
|
-
}
|
|
88
|
-
return t3;
|
|
89
|
-
};
|
|
90
|
-
function _temp(t0) {
|
|
91
|
-
const {
|
|
92
|
-
slug
|
|
93
|
-
} = t0;
|
|
94
|
-
return slug;
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=EnabledRelationshipsCondition.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EnabledRelationshipsCondition.js","names":["c","_c","useAuth","useConfig","useEntityVisibility","React","filterRichTextCollections","collections","options","filter","slug","admin","enableRichTextRelationship","upload","visibleEntities","includes","uploads","Boolean","EnabledRelationshipsCondition","props","$","children","FallbackComponent","t0","rest","undefined","config","t1","user","t2","map","_temp","enabledCollectionSlugs","useState","length","_jsx","t3","t4","cloneElement"],"sources":["../../../../../src/features/relationship/client/utils/EnabledRelationshipsCondition.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig, ClientUser, VisibleEntities } from 'payload'\n\nimport { useAuth, useConfig, useEntityVisibility } from '@payloadcms/ui'\nimport * as React from 'react'\n\ntype Options = {\n uploads: boolean\n user: ClientUser\n visibleEntities?: VisibleEntities\n}\n\ntype FilteredCollectionsT = (\n collections: ClientCollectionConfig[],\n options?: Options,\n) => ClientCollectionConfig[]\n\nconst filterRichTextCollections: FilteredCollectionsT = (collections, options) => {\n return collections.filter(({ slug, admin: { enableRichTextRelationship }, upload }) => {\n if (!options?.visibleEntities?.collections.includes(slug)) {\n return false\n }\n\n if (options?.uploads) {\n return enableRichTextRelationship && Boolean(upload) === true\n }\n\n return upload ? false : enableRichTextRelationship\n })\n}\n\nexport const EnabledRelationshipsCondition: React.FC<{\n children: any\n FallbackComponent?: React.FC\n uploads?: boolean\n}> = (props) => {\n const { children, FallbackComponent, uploads = false, ...rest } = props\n const {\n config: { collections },\n } = useConfig()\n const { user } = useAuth()\n const { visibleEntities } = useEntityVisibility()\n\n const [enabledCollectionSlugs] = React.useState(() =>\n filterRichTextCollections(collections, { uploads, user: user!, visibleEntities }).map(\n ({ slug }) => slug,\n ),\n )\n\n if (!enabledCollectionSlugs.length) {\n return FallbackComponent ? <FallbackComponent {...rest} /> : null\n }\n\n return React.cloneElement(children, { ...rest, enabledCollectionSlugs })\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,OAAO,EAAEC,SAAS,EAAEC,mBAAmB,QAAQ;AACxD,YAAYC,KAAA,MAAW;AAavB,MAAMC,yBAAA,GAAkDA,CAACC,WAAA,EAAaC,OAAA;EACpE,OAAOD,WAAA,CAAYE,MAAM,CAAC,CAAC;IAAEC,IAAI;IAAEC,KAAA,EAAO;MAAEC;IAA0B,CAAE;IAAEC;EAAM,CAAE;IAChF,I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