@payloadcms/richtext-slate 3.0.0-alpha.54 → 3.0.0-alpha.55

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.
@@ -42,7 +42,7 @@ const UploadElement = ({ enabledCollectionSlugs })=>{
42
42
  const [{ data }, { setParams }] = usePayloadAPI(`${serverURL}${api}/${relatedCollection.slug}/${value?.id}`, {
43
43
  initialParams
44
44
  });
45
- const thumbnailSRC = data?.thumbnailURL;
45
+ const thumbnailSRC = data?.thumbnailURL || data?.url;
46
46
  const removeUpload = useCallback(()=>{
47
47
  const elementPath = ReactEditor.findPath(editor, element);
48
48
  Transforms.removeNodes(editor, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/elements/upload/Element/index.tsx"],"sourcesContent":["'use client'\n\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\nimport type { ClientCollectionConfig } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button } from '@payloadcms/ui/elements/Button'\nimport { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer'\nimport { DrawerToggler, useDrawerSlug } from '@payloadcms/ui/elements/Drawer'\nimport { useListDrawer } from '@payloadcms/ui/elements/ListDrawer'\nimport { File } from '@payloadcms/ui/graphics/File'\nimport usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React, { useCallback, useReducer, useState } from 'react'\nimport { Transforms } from 'slate'\nimport { ReactEditor, useFocused, useSelected, useSlateStatic } from 'slate-react'\n\nimport type { UploadElementType } from '../types.js'\n\nimport { useElement } from '../../../providers/ElementProvider.js'\nimport { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js'\nimport { uploadFieldsSchemaPath, uploadName } from '../shared.js'\nimport { UploadDrawer } from './UploadDrawer/index.js'\nimport './index.scss'\n\nconst baseClass = 'rich-text-upload'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = FormFieldBase & {\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n}\n\nconst UploadElement: React.FC<Props & { enabledCollectionSlugs?: string[] }> = ({\n enabledCollectionSlugs,\n}) => {\n const {\n attributes,\n children,\n element: { relationTo, value },\n element,\n fieldProps,\n schemaPath,\n } = useElement<UploadElementType>()\n\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection, setRelatedCollection] = useState<ClientCollectionConfig>(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const drawerSlug = useDrawerSlug('upload-drawer')\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer: closeListDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: relatedCollection.slug,\n })\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value?.id,\n collectionSlug: relatedCollection.slug,\n })\n\n const editor = useSlateStatic()\n const selected = useSelected()\n const focused = useFocused()\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value?.id}`,\n { initialParams },\n )\n\n const thumbnailSRC = data?.thumbnailURL\n\n const removeUpload = useCallback(() => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.removeNodes(editor, { at: elementPath })\n }, [editor, element])\n\n const updateUpload = useCallback(\n (json) => {\n const { doc } = json\n\n const newNode = {\n fields: doc,\n }\n\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.setNodes(editor, newNode, { at: elementPath })\n\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 closeDrawer()\n },\n [editor, element, setParams, cacheBust, closeDrawer],\n )\n\n const swapUpload = React.useCallback(\n ({ collectionSlug, docID }) => {\n const newNode = {\n type: uploadName,\n children: [{ text: ' ' }],\n relationTo: collectionSlug,\n value: { id: docID },\n }\n\n const elementPath = ReactEditor.findPath(editor, element)\n\n setRelatedCollection(collections.find((coll) => coll.slug === collectionSlug))\n\n Transforms.setNodes(editor, newNode, { at: elementPath })\n\n dispatchCacheBust()\n closeListDrawer()\n },\n [closeListDrawer, editor, element, collections],\n )\n\n const relatedFieldSchemaPath = `${uploadFieldsSchemaPath}.${relatedCollection.slug}`\n const customFieldsMap = fieldProps.richTextComponentMap.get(relatedFieldSchemaPath)\n\n return (\n <div\n className={[baseClass, selected && focused && `${baseClass}--selected`]\n .filter(Boolean)\n .join(' ')}\n contentEditable={false}\n {...attributes}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__topRow`}>\n {/* TODO: migrate to use Thumbnail component */}\n <div className={`${baseClass}__thumbnail`}>\n {thumbnailSRC ? <img alt={data?.filename} src={thumbnailSRC} /> : <File />}\n </div>\n <div className={`${baseClass}__topRowRightPanel`}>\n <div className={`${baseClass}__collectionLabel`}>\n {getTranslation(relatedCollection.labels.singular, i18n)}\n </div>\n <div className={`${baseClass}__actions`}>\n {Boolean(customFieldsMap) && (\n <DrawerToggler\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={fieldProps?.readOnly}\n slug={drawerSlug}\n >\n <Button\n buttonStyle=\"icon-label\"\n el=\"div\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n }}\n round\n tooltip={t('fields:editRelationship')}\n />\n </DrawerToggler>\n )}\n <ListDrawerToggler\n className={`${baseClass}__list-drawer-toggler`}\n disabled={fieldProps?.readOnly}\n >\n <Button\n buttonStyle=\"icon-label\"\n disabled={fieldProps?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n // do nothing\n }}\n round\n tooltip={t('fields:swapUpload')}\n />\n </ListDrawerToggler>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={fieldProps?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeUpload()\n }}\n round\n tooltip={t('fields:removeUpload')}\n />\n </div>\n </div>\n </div>\n <div className={`${baseClass}__bottomRow`}>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <strong>{data?.filename}</strong>\n </DocumentDrawerToggler>\n </div>\n </div>\n {children}\n {value?.id && <DocumentDrawer onSave={updateUpload} />}\n <ListDrawer onSelect={swapUpload} />\n <UploadDrawer {...{ drawerSlug, element, fieldProps, relatedCollection, schemaPath }} />\n </div>\n )\n}\n\nexport const Element = (props: Props): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <UploadElement {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["getTranslation","Button","useDocumentDrawer","DrawerToggler","useDrawerSlug","useListDrawer","File","usePayloadAPI","useConfig","useTranslation","React","useCallback","useReducer","useState","Transforms","ReactEditor","useFocused","useSelected","useSlateStatic","useElement","EnabledRelationshipsCondition","uploadFieldsSchemaPath","uploadName","UploadDrawer","baseClass","initialParams","depth","UploadElement","enabledCollectionSlugs","attributes","children","element","relationTo","value","fieldProps","schemaPath","collections","routes","api","serverURL","i18n","t","cacheBust","dispatchCacheBust","state","relatedCollection","setRelatedCollection","find","coll","slug","drawerSlug","ListDrawer","ListDrawerToggler","closeDrawer","closeListDrawer","collectionSlugs","selectedCollection","DocumentDrawer","DocumentDrawerToggler","id","collectionSlug","editor","selected","focused","data","setParams","thumbnailSRC","thumbnailURL","removeUpload","elementPath","findPath","removeNodes","at","updateUpload","json","doc","newNode","fields","setNodes","swapUpload","docID","type","text","relatedFieldSchemaPath","customFieldsMap","richTextComponentMap","get","div","className","filter","Boolean","join","contentEditable","img","alt","filename","src","labels","singular","disabled","readOnly","buttonStyle","el","icon","onClick","e","preventDefault","round","tooltip","strong","onSave","onSelect","Element","props","uploads"],"mappings":"AAAA;AAKA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,MAAM,Q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W,CAAC,EAAEhE,UAAU,uBAAuB,CAAC;QAChD2E,UAAUjE,YAAYkE;QACtBnD,MAAMC;qBAEN,oBAACjD;QACCoG,aAAY;QACZC,IAAG;QACHC,MAAK;QACLC,SAAS,CAACC;YACRA,EAAEC,cAAc;QAClB;QACAC,OAAAA;QACAC,SAASnE,EAAE;uBAIjB,oBAACW;QACCoC,WAAW,CAAC,EAAEhE,UAAU,qBAAqB,CAAC;QAC9C2E,UAAUjE,YAAYkE;qBAEtB,oBAACnG;QACCoG,aAAY;QACZF,UAAUjE,YAAYkE;QACtBE,IAAG;QACHC,MAAK;QACLC,SAAS;QACP,aAAa;QACf;QACAG,OAAAA;QACAC,SAASnE,EAAE;uBAGf,oBAACxC;QACCoG,aAAY;QACZb,WAAW,CAAC,EAAEhE,UAAU,cAAc,CAAC;QACvC2E,UAAUjE,YAAYkE;QACtBG,MAAK;QACLC,SAAS,CAACC;YACRA,EAAEC,cAAc;YAChBtC;QACF;QACAuC,OAAAA;QACAC,SAASnE,EAAE;yBAKnB,oBAAC8C;QAAIC,WAAW,CAAC,EAAEhE,UAAU,WAAW,CAAC;qBACvC,oBAACkC;QAAsB8B,WAAW,CAAC,EAAEhE,UAAU,oBAAoB,CAAC;qBAClE,oBAACqF,gBAAQ7C,MAAM+B,cAIpBjE,UACAG,OAAO0B,oBAAM,oBAACF;QAAeqD,QAAQrC;sBACtC,oBAACtB;QAAW4D,UAAUhC;sBACtB,oBAACxD,cAAiB;QAAE2B;QAAYnB;QAASG;QAAYW;QAAmBV;IAAW;AAGzF;AAEA,OAAO,MAAM6E,UAAU,CAACC;IACtB,qBACE,oBAAC7F;QAA+B,GAAG6F,KAAK;QAAEC,SAAAA;qBACxC,oBAACvF,eAAkBsF;AAGzB,EAAC"}
1
+ {"version":3,"sources":["../../../../../src/field/elements/upload/Element/index.tsx"],"sourcesContent":["'use client'\n\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\nimport type { ClientCollectionConfig } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button } from '@payloadcms/ui/elements/Button'\nimport { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer'\nimport { DrawerToggler, useDrawerSlug } from '@payloadcms/ui/elements/Drawer'\nimport { useListDrawer } from '@payloadcms/ui/elements/ListDrawer'\nimport { File } from '@payloadcms/ui/graphics/File'\nimport usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React, { useCallback, useReducer, useState } from 'react'\nimport { Transforms } from 'slate'\nimport { ReactEditor, useFocused, useSelected, useSlateStatic } from 'slate-react'\n\nimport type { UploadElementType } from '../types.js'\n\nimport { useElement } from '../../../providers/ElementProvider.js'\nimport { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js'\nimport { uploadFieldsSchemaPath, uploadName } from '../shared.js'\nimport { UploadDrawer } from './UploadDrawer/index.js'\nimport './index.scss'\n\nconst baseClass = 'rich-text-upload'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = FormFieldBase & {\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n}\n\nconst UploadElement: React.FC<Props & { enabledCollectionSlugs?: string[] }> = ({\n enabledCollectionSlugs,\n}) => {\n const {\n attributes,\n children,\n element: { relationTo, value },\n element,\n fieldProps,\n schemaPath,\n } = useElement<UploadElementType>()\n\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection, setRelatedCollection] = useState<ClientCollectionConfig>(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const drawerSlug = useDrawerSlug('upload-drawer')\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer: closeListDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: relatedCollection.slug,\n })\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value?.id,\n collectionSlug: relatedCollection.slug,\n })\n\n const editor = useSlateStatic()\n const selected = useSelected()\n const focused = useFocused()\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value?.id}`,\n { initialParams },\n )\n\n const thumbnailSRC = data?.thumbnailURL || data?.url\n\n const removeUpload = useCallback(() => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.removeNodes(editor, { at: elementPath })\n }, [editor, element])\n\n const updateUpload = useCallback(\n (json) => {\n const { doc } = json\n\n const newNode = {\n fields: doc,\n }\n\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.setNodes(editor, newNode, { at: elementPath })\n\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 closeDrawer()\n },\n [editor, element, setParams, cacheBust, closeDrawer],\n )\n\n const swapUpload = React.useCallback(\n ({ collectionSlug, docID }) => {\n const newNode = {\n type: uploadName,\n children: [{ text: ' ' }],\n relationTo: collectionSlug,\n value: { id: docID },\n }\n\n const elementPath = ReactEditor.findPath(editor, element)\n\n setRelatedCollection(collections.find((coll) => coll.slug === collectionSlug))\n\n Transforms.setNodes(editor, newNode, { at: elementPath })\n\n dispatchCacheBust()\n closeListDrawer()\n },\n [closeListDrawer, editor, element, collections],\n )\n\n const relatedFieldSchemaPath = `${uploadFieldsSchemaPath}.${relatedCollection.slug}`\n const customFieldsMap = fieldProps.richTextComponentMap.get(relatedFieldSchemaPath)\n\n return (\n <div\n className={[baseClass, selected && focused && `${baseClass}--selected`]\n .filter(Boolean)\n .join(' ')}\n contentEditable={false}\n {...attributes}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__topRow`}>\n {/* TODO: migrate to use Thumbnail component */}\n <div className={`${baseClass}__thumbnail`}>\n {thumbnailSRC ? <img alt={data?.filename} src={thumbnailSRC} /> : <File />}\n </div>\n <div className={`${baseClass}__topRowRightPanel`}>\n <div className={`${baseClass}__collectionLabel`}>\n {getTranslation(relatedCollection.labels.singular, i18n)}\n </div>\n <div className={`${baseClass}__actions`}>\n {Boolean(customFieldsMap) && (\n <DrawerToggler\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={fieldProps?.readOnly}\n slug={drawerSlug}\n >\n <Button\n buttonStyle=\"icon-label\"\n el=\"div\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n }}\n round\n tooltip={t('fields:editRelationship')}\n />\n </DrawerToggler>\n )}\n <ListDrawerToggler\n className={`${baseClass}__list-drawer-toggler`}\n disabled={fieldProps?.readOnly}\n >\n <Button\n buttonStyle=\"icon-label\"\n disabled={fieldProps?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n // do nothing\n }}\n round\n tooltip={t('fields:swapUpload')}\n />\n </ListDrawerToggler>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={fieldProps?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeUpload()\n }}\n round\n tooltip={t('fields:removeUpload')}\n />\n </div>\n </div>\n </div>\n <div className={`${baseClass}__bottomRow`}>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <strong>{data?.filename}</strong>\n </DocumentDrawerToggler>\n </div>\n </div>\n {children}\n {value?.id && <DocumentDrawer onSave={updateUpload} />}\n <ListDrawer onSelect={swapUpload} />\n <UploadDrawer {...{ drawerSlug, element, fieldProps, relatedCollection, schemaPath }} />\n </div>\n )\n}\n\nexport const Element = (props: Props): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <UploadElement {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["getTranslation","Button","useDocumentDrawer","DrawerToggler","useDrawerSlug","useListDrawer","File","usePayloadAPI","useConfig","useTranslation","React","useCallback","useReducer","useState","Transforms","ReactEditor","useFocused","useSelected","useSlateStatic","useElement","EnabledRelationshipsCondition","uploadFieldsSchemaPath","uploadName","UploadDrawer","baseClass","initialParams","depth","UploadElement","enabledCollectionSlugs","attributes","children","element","relationTo","value","fieldProps","schemaPath","collections","routes","api","serverURL","i18n","t","cacheBust","dispatchCacheBust","state","relatedCollection","setRelatedCollection","find","coll","slug","drawerSlug","ListDrawer","ListDrawerToggler","closeDrawer","closeListDrawer","collectionSlugs","selectedCollection","DocumentDrawer","DocumentDrawerToggler","id","collectionSlug","editor","selected","focused","data","setParams","thumbnailSRC","thumbnailURL","url","removeUpload","elementPath","findPath","removeNodes","at","updateUpload","json","doc","newNode","fields","setNodes","swapUpload","docID","type","text","relatedFieldSchemaPath","customFieldsMap","richTextComponentMap","get","div","className","filter","Boolean","join","contentEditable","img","alt","filename","src","labels","singular","disabled","readOnly","buttonStyle","el","icon","onClick","e","preventDefault","round","tooltip","strong","onSave","onSelect","Element","props","uploads"],"mappings":"AAAA;AAKA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,MAAM,QAAQ,iCAAgC;AACvD,SAASC,iBAAiB,QAAQ,yCAAwC;AAC1E,SAASC,aAAa,EAAEC,aAAa,QAAQ,iCAAgC;AAC7E,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,IAAI,QAAQ,+BAA8B;AACnD,OAAOC,mBAAmB,qCAAoC;AAC9D,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,OAAOC,SAASC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,QAAO;AAChE,SAASC,UAAU,QAAQ,QAAO;AAClC,SAASC,WAAW,EAAEC,UAAU,EAAEC,WAAW,EAAEC,cAAc,QAAQ,cAAa;AAIlF,SAASC,UAAU,QAAQ,wCAAuC;AAClE,SAASC,6BAA6B,QAAQ,yCAAwC;AACtF,SAASC,sBAAsB,EAAEC,UAAU,QAAQ,eAAc;AACjE,SAASC,YAAY,QAA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AAS,CAACC;YACRA,EAAEC,cAAc;YAChBtC;QACF;QACAuC,OAAAA;QACAC,SAASpE,EAAE;yBAKnB,oBAAC+C;QAAIC,WAAW,CAAC,EAAEjE,UAAU,WAAW,CAAC;qBACvC,oBAACkC;QAAsB+B,WAAW,CAAC,EAAEjE,UAAU,oBAAoB,CAAC;qBAClE,oBAACsF,gBAAQ9C,MAAMgC,cAIpBlE,UACAG,OAAO0B,oBAAM,oBAACF;QAAesD,QAAQrC;sBACtC,oBAACvB;QAAW6D,UAAUhC;sBACtB,oBAACzD,cAAiB;QAAE2B;QAAYnB;QAASG;QAAYW;QAAmBV;IAAW;AAGzF;AAEA,OAAO,MAAM8E,UAAU,CAACC;IACtB,qBACE,oBAAC9F;QAA+B,GAAG8F,KAAK;QAAEC,SAAAA;qBACxC,oBAACxF,eAAkBuF;AAGzB,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-slate",
3
- "version": "3.0.0-alpha.54",
3
+ "version": "3.0.0-alpha.55",
4
4
  "description": "The officially supported Slate richtext adapter for Payload",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,14 +25,14 @@
25
25
  "devDependencies": {
26
26
  "@types/node": "20.5.7",
27
27
  "@types/react": "18.2.15",
28
- "@payloadcms/ui": "3.0.0-alpha.54",
29
- "payload": "3.0.0-alpha.54",
30
- "@payloadcms/eslint-config": "1.1.1"
28
+ "@payloadcms/ui": "3.0.0-alpha.55",
29
+ "@payloadcms/eslint-config": "1.1.1",
30
+ "payload": "3.0.0-alpha.55"
31
31
  },
32
32
  "peerDependencies": {
33
- "payload": "3.0.0-alpha.54",
34
- "@payloadcms/translations": "3.0.0-alpha.54",
35
- "@payloadcms/ui": "3.0.0-alpha.54"
33
+ "payload": "3.0.0-alpha.55",
34
+ "@payloadcms/ui": "3.0.0-alpha.55",
35
+ "@payloadcms/translations": "3.0.0-alpha.54"
36
36
  },
37
37
  "exports": null,
38
38
  "publishConfig": {