@payloadcms/ui 3.0.0-beta.23 → 3.0.0-beta.24

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.
@@ -1 +1 @@
1
- {"version":3,"file":"DrawerContent.d.ts","sourceRoot":"","sources":["../../../src/elements/DocumentDrawer/DrawerContent.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAG/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAerD,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAuG/D,CAAA"}
1
+ {"version":3,"file":"DrawerContent.d.ts","sourceRoot":"","sources":["../../../src/elements/DocumentDrawer/DrawerContent.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAG/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAerD,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAyG/D,CAAA"}
@@ -15,23 +15,23 @@ import { Gutter } from '../Gutter/index.js';
15
15
  import { IDLabel } from '../IDLabel/index.js';
16
16
  import { RenderTitle } from '../RenderTitle/index.js';
17
17
  import { baseClass } from './index.js';
18
- export const DocumentDrawerContent = ({ id, Header, collectionSlug, drawerSlug, onSave: onSaveFromProps })=>{
18
+ export const DocumentDrawerContent = ({ id: existingDocID, Header, collectionSlug, drawerSlug, onSave: onSaveFromProps })=>{
19
19
  const { useModal } = facelessUIImport;
20
20
  const config = useConfig();
21
21
  const { routes: { api: apiRoute }, serverURL } = config;
22
22
  const { closeModal, modalState, toggleModal } = useModal();
23
23
  const locale = useLocale();
24
24
  const { t } = useTranslation();
25
- const [createdID, setCreatedID] = useState();
25
+ const [docID, setDocID] = useState(existingDocID);
26
26
  const [isOpen, setIsOpen] = useState(false);
27
27
  const [collectionConfig] = useRelatedCollections(collectionSlug);
28
28
  const { formQueryParams } = useFormQueryParams();
29
29
  const formattedQueryParams = queryString.stringify(formQueryParams);
30
30
  const { componentMap } = useComponentMap();
31
31
  const { Edit } = componentMap[`${collectionSlug ? 'collections' : 'globals'}`][collectionSlug];
32
- const isEditing = Boolean(id);
33
- const apiURL = id ? `${serverURL}${apiRoute}/${collectionSlug}/${id}?locale=${locale.code}` : null;
34
- const action = `${serverURL}${apiRoute}/${collectionSlug}${isEditing ? `/${id}` : ''}?${formattedQueryParams}`;
32
+ const isEditing = Boolean(docID);
33
+ const apiURL = docID ? `${serverURL}${apiRoute}/${collectionSlug}/${docID}?locale=${locale.code}` : null;
34
+ const action = `${serverURL}${apiRoute}/${collectionSlug}${isEditing ? `/${docID}` : ''}?${formattedQueryParams}`;
35
35
  useEffect(()=>{
36
36
  setIsOpen(Boolean(modalState[drawerSlug]?.isOpen));
37
37
  }, [
@@ -50,7 +50,7 @@ export const DocumentDrawerContent = ({ id, Header, collectionSlug, drawerSlug,
50
50
  t
51
51
  ]);
52
52
  const onSave = useCallback((args)=>{
53
- setCreatedID(args.doc.id);
53
+ setDocID(args.doc.id);
54
54
  if (typeof onSaveFromProps === 'function') {
55
55
  void onSaveFromProps({
56
56
  ...args,
@@ -87,7 +87,7 @@ export const DocumentDrawerContent = ({ id, Header, collectionSlug, drawerSlug,
87
87
  // Same reason as above. We need to fully-fetch the docPreferences from the server. This is done in DocumentInfoProvider if we set it to null here.
88
88
  hasSavePermission: null,
89
89
  // isLoading,
90
- id: id || createdID,
90
+ id: docID,
91
91
  isEditing: isEditing,
92
92
  onLoadError: onLoadError,
93
93
  onSave: onSave
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/elements/DocumentDrawer/DrawerContent.tsx"],"sourcesContent":["'use client'\n\nimport * as facelessUIImport from '@faceless-ui/modal'\nimport queryString from 'qs'\nimport React, { useCallback, useEffect, useState } from 'react'\nimport { toast } from 'react-toastify'\n\nimport type { DocumentDrawerProps } from './types.js'\n\nimport { useRelatedCollections } from '../../fields/Relationship/AddNew/useRelatedCollections.js'\nimport { X } from '../../icons/X/index.js'\nimport { useComponentMap } from '../../providers/ComponentMap/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { DocumentInfoProvider, useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useFormQueryParams } from '../../providers/FormQueryParams/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { Gutter } from '../Gutter/index.js'\nimport { IDLabel } from '../IDLabel/index.js'\nimport { RenderTitle } from '../RenderTitle/index.js'\nimport { baseClass } from './index.js'\n\nexport const DocumentDrawerContent: React.FC<DocumentDrawerProps> = ({\n id,\n Header,\n collectionSlug,\n drawerSlug,\n onSave: onSaveFromProps,\n}) => {\n const { useModal } = facelessUIImport\n\n const config = useConfig()\n\n const {\n routes: { api: apiRoute },\n serverURL,\n } = config\n\n const { closeModal, modalState, toggleModal } = useModal()\n const locale = useLocale()\n const { t } = useTranslation()\n const [createdID, setCreatedID] = useState()\n const [isOpen, setIsOpen] = useState(false)\n const [collectionConfig] = useRelatedCollections(collectionSlug)\n const { formQueryParams } = useFormQueryParams()\n const formattedQueryParams = queryString.stringify(formQueryParams)\n\n const { componentMap } = useComponentMap()\n\n const { Edit } = componentMap[`${collectionSlug ? 'collections' : 'globals'}`][collectionSlug]\n const isEditing = Boolean(id)\n const apiURL = id ? `${serverURL}${apiRoute}/${collectionSlug}/${id}?locale=${locale.code}` : null\n const action = `${serverURL}${apiRoute}/${collectionSlug}${\n isEditing ? `/${id}` : ''\n }?${formattedQueryParams}`\n\n useEffect(() => {\n setIsOpen(Boolean(modalState[drawerSlug]?.isOpen))\n }, [modalState, drawerSlug])\n\n const onLoadError = React.useCallback(\n (data) => {\n if (isOpen) {\n closeModal(drawerSlug)\n toast.error(data.errors?.[0].message || t('error:unspecific'))\n }\n },\n [closeModal, drawerSlug, isOpen, t],\n )\n\n const onSave = useCallback<DocumentDrawerProps['onSave']>(\n (args) => {\n setCreatedID(args.doc.id)\n if (typeof onSaveFromProps === 'function') {\n void onSaveFromProps({\n ...args,\n collectionConfig,\n })\n }\n },\n [onSaveFromProps, collectionConfig],\n )\n\n return (\n <DocumentInfoProvider\n BeforeDocument={\n <Gutter className={`${baseClass}__header`}>\n <div className={`${baseClass}__header-content`}>\n <h2 className={`${baseClass}__header-text`}>\n {Header || <RenderTitle element=\"span\" />}\n </h2>\n {/* TODO: the `button` HTML element breaks CSS transitions on the drawer for some reason...\n i.e. changing to a `div` element will fix the animation issue but will break accessibility\n */}\n <button\n aria-label={t('general:close')}\n className={`${baseClass}__header-close`}\n onClick={() => toggleModal(drawerSlug)}\n type=\"button\"\n >\n <X />\n </button>\n </div>\n <DocumentTitle />\n </Gutter>\n }\n action={action}\n apiURL={apiURL}\n collectionSlug={collectionConfig.slug}\n disableActions\n disableLeaveWithoutSaving\n // Do NOT pass in the docPermissions we have here. This is because the permissions we have here do not have their where: { } returns resolved.\n // If we set it to null though, the DocumentInfoProvider will fully-fetch the permissions from the server, and the where: { } returns will be resolved.\n docPermissions={null}\n // Same reason as above. We need to fully-fetch the docPreferences from the server. This is done in DocumentInfoProvider if we set it to null here.\n hasSavePermission={null}\n // isLoading,\n id={id || createdID}\n isEditing={isEditing}\n onLoadError={onLoadError}\n onSave={onSave}\n >\n {Edit}\n </DocumentInfoProvider>\n )\n}\n\nconst DocumentTitle: React.FC = () => {\n const { id, title } = useDocumentInfo()\n return id && id !== title ? <IDLabel id={id.toString()} /> : null\n}\n"],"names":["facelessUIImport","queryString","React","useCallback","useEffect","useState","toast","useRelatedCollections","X","useComponentMap","useConfig","DocumentInfoProvider","useDocumentInfo","useFormQueryParams","useLocale","useTranslation","Gutter","IDLabel","RenderTitle","baseClass","DocumentDrawerContent","id","Header","collectionSlug","drawerSlug","onSave","onSaveFromProps","useModal","config","routes","api","apiRoute","serverURL","closeModal","modalState","toggleModal","locale","t","createdID","setCreatedID","isOpen","setIsOpen","collectionConfig","formQueryParams","formattedQueryParams","stringify","componentMap","Edit","isEditing","Boolean","apiURL","code","action","onLoadError","data","error","errors","message","args","doc","BeforeDocument","className","div","h2","element","button","aria-label","onClick","type","DocumentTitle","slug","disableActions","disableLeaveWithoutSaving","docPermissions","hasSavePermission","title","toString"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,YAAYA,sBAAsB,qBAAoB;AACtD,OAAOC,iBAAiB,KAAI;AAC5B,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAC/D,SAASC,KAAK,QAAQ,iBAAgB;AAItC,SAASC,qBAAqB,QAAQ,4DAA2D;AACjG,SAASC,CAAC,QAAQ,yBAAwB;AAC1C,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,oBAAoB,EAAEC,eAAe,QAAQ,wCAAuC;AAC7F,SAASC,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,MAAM,QAAQ,qBAAoB;AAC3C,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,SAAS,QAAQ,aAAY;AAEtC,OAAO,MAAMC,wBAAuD,CAAC,EACnEC,EAAE,EACFC,MAAM,EACNC,cAAc,EACdC,UAAU,EACVC,QAAQC,eAAe,EACxB;IACC,MAAM,EAAEC,QAAQ,EAAE,GAAG3B;IAErB,MAAM4B,SAASlB;IAEf,MAAM,EACJmB,QAAQ,EAAEC,KAAKC,QAAQ,EAAE,EACzBC,SAAS,EACV,GAAGJ;IAEJ,MAAM,EAAEK,UAAU,EAAEC,UAAU,EAAEC,WAAW,EAAE,GAAGR;IAChD,MAAM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B;YACF;QACF;IACF,GACA;QAAChB;QAAiBgB;KAAiB;IAGrC,qBACE,oBAAC/B;QACCiD,8BACE,oBAAC5C;YAAO6C,WAAW,CAAC,EAAE1C,UAAU,QAAQ,CAAC;yBACvC,oBAAC2C;YAAID,WAAW,CAAC,EAAE1C,UAAU,gBAAgB,CAAC;yBAC5C,oBAAC4C;YAAGF,WAAW,CAAC,EAAE1C,UAAU,aAAa,CAAC;WACvCG,wBAAU,oBAACJ;YAAY8C,SAAQ;2BAKlC,oBAACC;YACCC,cAAY7B,EAAE;YACdwB,WAAW,CAAC,EAAE1C,UAAU,cAAc,CAAC;YACvCgD,SAAS,IAAMhC,YAAYX;YAC3B4C,MAAK;yBAEL,oBAAC5D,0BAGL,oBAAC6D;QAGLjB,QAAQA;QACRF,QAAQA;QACR3B,gBAAgBmB,iBAAiB4B,IAAI;QACrCC,gBAAAA;QACAC,2BAAAA;QACA,8IAA8I;QAC9I,uJAAuJ;QACvJC,gBAAgB;QAChB,mJAAmJ;QACnJC,mBAAmB;QACnB,aAAa;QACbrD,IAAIA,MAAMiB;QACVU,WAAWA;QACXK,aAAaA;QACb5B,QAAQA;OAEPsB;AAGP,EAAC;AAED,MAAMsB,gBAA0B;IAC9B,MAAM,EAAEhD,EAAE,EAAEsD,KAAK,EAAE,GAAG/D;IACtB,OAAOS,MAAMA,OAAOsD,sBAAQ,oBAAC1D;QAAQI,IAAIA,GAAGuD,QAAQ;SAAS;AAC/D"}
1
+ {"version":3,"sources":["../../../src/elements/DocumentDrawer/DrawerContent.tsx"],"sourcesContent":["'use client'\n\nimport * as facelessUIImport from '@faceless-ui/modal'\nimport queryString from 'qs'\nimport React, { useCallback, useEffect, useState } from 'react'\nimport { toast } from 'react-toastify'\n\nimport type { DocumentDrawerProps } from './types.js'\n\nimport { useRelatedCollections } from '../../fields/Relationship/AddNew/useRelatedCollections.js'\nimport { X } from '../../icons/X/index.js'\nimport { useComponentMap } from '../../providers/ComponentMap/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { DocumentInfoProvider, useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useFormQueryParams } from '../../providers/FormQueryParams/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { Gutter } from '../Gutter/index.js'\nimport { IDLabel } from '../IDLabel/index.js'\nimport { RenderTitle } from '../RenderTitle/index.js'\nimport { baseClass } from './index.js'\n\nexport const DocumentDrawerContent: React.FC<DocumentDrawerProps> = ({\n id: existingDocID,\n Header,\n collectionSlug,\n drawerSlug,\n onSave: onSaveFromProps,\n}) => {\n const { useModal } = facelessUIImport\n\n const config = useConfig()\n\n const {\n routes: { api: apiRoute },\n serverURL,\n } = config\n\n const { closeModal, modalState, toggleModal } = useModal()\n const locale = useLocale()\n const { t } = useTranslation()\n const [docID, setDocID] = useState(existingDocID)\n const [isOpen, setIsOpen] = useState(false)\n const [collectionConfig] = useRelatedCollections(collectionSlug)\n const { formQueryParams } = useFormQueryParams()\n const formattedQueryParams = queryString.stringify(formQueryParams)\n\n const { componentMap } = useComponentMap()\n\n const { Edit } = componentMap[`${collectionSlug ? 'collections' : 'globals'}`][collectionSlug]\n const isEditing = Boolean(docID)\n const apiURL = docID\n ? `${serverURL}${apiRoute}/${collectionSlug}/${docID}?locale=${locale.code}`\n : null\n const action = `${serverURL}${apiRoute}/${collectionSlug}${\n isEditing ? `/${docID}` : ''\n }?${formattedQueryParams}`\n\n useEffect(() => {\n setIsOpen(Boolean(modalState[drawerSlug]?.isOpen))\n }, [modalState, drawerSlug])\n\n const onLoadError = React.useCallback(\n (data) => {\n if (isOpen) {\n closeModal(drawerSlug)\n toast.error(data.errors?.[0].message || t('error:unspecific'))\n }\n },\n [closeModal, drawerSlug, isOpen, t],\n )\n\n const onSave = useCallback<DocumentDrawerProps['onSave']>(\n (args) => {\n setDocID(args.doc.id)\n if (typeof onSaveFromProps === 'function') {\n void onSaveFromProps({\n ...args,\n collectionConfig,\n })\n }\n },\n [onSaveFromProps, collectionConfig],\n )\n\n return (\n <DocumentInfoProvider\n BeforeDocument={\n <Gutter className={`${baseClass}__header`}>\n <div className={`${baseClass}__header-content`}>\n <h2 className={`${baseClass}__header-text`}>\n {Header || <RenderTitle element=\"span\" />}\n </h2>\n {/* TODO: the `button` HTML element breaks CSS transitions on the drawer for some reason...\n i.e. changing to a `div` element will fix the animation issue but will break accessibility\n */}\n <button\n aria-label={t('general:close')}\n className={`${baseClass}__header-close`}\n onClick={() => toggleModal(drawerSlug)}\n type=\"button\"\n >\n <X />\n </button>\n </div>\n <DocumentTitle />\n </Gutter>\n }\n action={action}\n apiURL={apiURL}\n collectionSlug={collectionConfig.slug}\n disableActions\n disableLeaveWithoutSaving\n // Do NOT pass in the docPermissions we have here. This is because the permissions we have here do not have their where: { } returns resolved.\n // If we set it to null though, the DocumentInfoProvider will fully-fetch the permissions from the server, and the where: { } returns will be resolved.\n docPermissions={null}\n // Same reason as above. We need to fully-fetch the docPreferences from the server. This is done in DocumentInfoProvider if we set it to null here.\n hasSavePermission={null}\n // isLoading,\n id={docID}\n isEditing={isEditing}\n onLoadError={onLoadError}\n onSave={onSave}\n >\n {Edit}\n </DocumentInfoProvider>\n )\n}\n\nconst DocumentTitle: React.FC = () => {\n const { id, title } = useDocumentInfo()\n return id && id !== title ? <IDLabel id={id.toString()} /> : null\n}\n"],"names":["facelessUIImport","queryString","React","useCallback","useEffect","useState","toast","useRelatedCollections","X","useComponentMap","useConfig","DocumentInfoProvider","useDocumentInfo","useFormQueryParams","useLocale","useTranslation","Gutter","IDLabel","RenderTitle","baseClass","DocumentDrawerContent","id","existingDocID","Header","collectionSlug","drawerSlug","onSave","onSaveFromProps","useModal","config","routes","api","apiRoute","serverURL","closeModal","modalState","toggleModal","locale","t","docID","setDocID","isOpen","setIsOpen","collectionConfig","formQueryParams","formattedQueryParams","stringify","componentMap","Edit","isEditing","Boolean","apiURL","code","action","onLoadError","data","error","errors","message","args","doc","BeforeDocument","className","div","h2","element","button","aria-label","onClick","type","DocumentTitle","slug","disableActions","disableLeaveWithoutSaving","docPermissions","hasSavePermission","title","toString"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,YAAYA,sBAAsB,qBAAoB;AACtD,OAAOC,iBAAiB,KAAI;AAC5B,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAC/D,SAASC,KAAK,QAAQ,iBAAgB;AAItC,SAASC,qBAAqB,QAAQ,4DAA2D;AACjG,SAASC,CAAC,QAAQ,yBAAwB;AAC1C,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,oBAAoB,EAAEC,eAAe,QAAQ,wCAAuC;AAC7F,SAASC,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,MAAM,QAAQ,qBAAoB;AAC3C,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,SAAS,QAAQ,aAAY;AAEtC,OAAO,MAAMC,wBAAuD,CAAC,EACnEC,IAAIC,aAAa,EACjBC,MAAM,EACNC,cAAc,EACdC,UAAU,EACVC,QAAQC,eAAe,EACxB;IACC,MAAM,EAAEC,QAAQ,EAAE,GAAG5B;IAErB,MAAM6B,SAASnB;IAEf,MAAM,EACJoB,QAAQ,EAAEC,KAAKC,QAAQ,EAAE,EACzBC,SAAS,EACV,GAAGJ;IAEJ,MAAM,EAAEK,UAAU,EAAEC,UAAU,EAAEC,WAAW,EAAE,GAAGR;IAChD,MAAMS,SAASvB;IACf,MAAM,EAAEwB,CAAC,EAAE,GAAGvB;IACd,MAAM,CAACwB,OAAOC,SAAS,GA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ts","sourceRoot":"","sources":["../../../src/elements/Save/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAA;AASrC,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAiC1D,CAAA;AAED,KAAK,KAAK,GAAG;IACX,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAClC,CAAA;AAED,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAIhC,CAAA"}
@@ -1,16 +1,20 @@
1
1
  'use client';
2
2
  import React, { useRef } from 'react';
3
- import { useForm } from '../../forms/Form/context.js';
3
+ import { useForm, useFormModified } from '../../forms/Form/context.js';
4
4
  import { FormSubmit } from '../../forms/Submit/index.js';
5
5
  import { useHotkey } from '../../hooks/useHotkey.js';
6
6
  import { useEditDepth } from '../../providers/EditDepth/index.js';
7
+ import { useOperation } from '../../providers/Operation/index.js';
7
8
  import { useTranslation } from '../../providers/Translation/index.js';
8
9
  export const DefaultSaveButton = ({ label: labelProp })=>{
9
10
  const { t } = useTranslation();
10
11
  const { submit } = useForm();
12
+ const modified = useFormModified();
11
13
  const label = labelProp || t('general:save');
12
14
  const ref = useRef(null);
13
15
  const editDepth = useEditDepth();
16
+ const operation = useOperation();
17
+ const forceDisable = operation === 'update' && !modified;
14
18
  useHotkey({
15
19
  cmdCtrlKey: true,
16
20
  editDepth,
@@ -18,6 +22,7 @@ export const DefaultSaveButton = ({ label: labelProp })=>{
18
22
  's'
19
23
  ]
20
24
  }, (e)=>{
25
+ if (forceDisable) return;
21
26
  e.preventDefault();
22
27
  e.stopPropagation();
23
28
  if (ref?.current) {
@@ -26,6 +31,7 @@ export const DefaultSaveButton = ({ label: labelProp })=>{
26
31
  });
27
32
  return /*#__PURE__*/ React.createElement(FormSubmit, {
28
33
  buttonId: "action-save",
34
+ disabled: forceDisable,
29
35
  onClick: ()=>submit(),
30
36
  ref: ref,
31
37
  size: "small",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/elements/Save/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { useRef } from 'react'\n\nimport { useForm } from '../../forms/Form/context.js'\nimport { FormSubmit } from '../../forms/Submit/index.js'\nimport { useHotkey } from '../../hooks/useHotkey.js'\nimport { useEditDepth } from '../../providers/EditDepth/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\n\nexport const DefaultSaveButton: React.FC<{ label?: string }> = ({ label: labelProp }) => {\n const { t } = useTranslation()\n const { submit } = useForm()\n const label = labelProp || t('general:save')\n const ref = useRef<HTMLButtonElement>(null)\n const editDepth = useEditDepth()\n\n useHotkey({ cmdCtrlKey: true, editDepth, keyCodes: ['s'] }, (e) => {\n e.preventDefault()\n e.stopPropagation()\n if (ref?.current) {\n ref.current.click()\n }\n })\n\n return (\n <FormSubmit\n buttonId=\"action-save\"\n onClick={() => submit()}\n ref={ref}\n size=\"small\"\n type=\"button\"\n >\n {label}\n </FormSubmit>\n )\n}\n\ntype Props = {\n CustomComponent?: React.ReactNode\n}\n\nexport const Save: React.FC<Props> = ({ CustomComponent }) => {\n if (CustomComponent) return CustomComponent\n\n return <DefaultSaveButton />\n}\n"],"names":["React","useRef","useForm","FormSubmit","useHotkey","useEditDepth","useTranslation","DefaultSaveButton","label","labelProp","t","submit","ref","editDepth","cmdCtrlKey","keyCodes","e","preventDefault","stopPropagation","current","click","buttonId","onClick","size","type","Save","CustomComponent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,OAAOA,SAASC,MAAM,QAAQ,QAAO;AAErC,SAASC,OAAO,QAAQ,8BAA6B;AACrD,SAASC,UAAU,QAAQ,8BAA6B;AACxD,SAASC,SAAS,QAAQ,2BAA0B;AACpD,SAASC,YAAY,QAAQ,qCAAoC;AACjE,SAASC,cAAc,QAAQ,uCAAsC;AAErE,OAAO,MAAMC,oBAAkD,CAAC,EAAEC,OAAOC,SAAS,EAAE;IAClF,MAAM,EAAEC,CAAC,EAAE,GAAGJ;IACd,MAAM,EAAEK,MAAM,EAAE,GAAGT;IACnB,MAAMM,QAAQC,aAAaC,EAAE;IAC7B,MAAME,MAAMX,OAA0B;IACtC,MAAMY,YAAYR;IAElBD,UAAU;QAAEU,YAAY;QAAMD;QAAWE,UAAU;YAAC;SAAI;IAAC,GAAG,CAACC;QAC3DA,EAAEC,cAAc;QAChBD,EAAEE,eAAe;QACjB,IAAIN,KAAKO,SAAS;YAChBP,IAAIO,OAAO,CAACC,KAAK;QACnB;IACF;IAEA,qBACE,oBAACjB;QACCkB,UAAS;QACTC,SAAS,IAAMX;QACfC,KAAKA;QACLW,MAAK;QACLC,MAAK;OAEJhB;AAGP,EAAC;AAMD,OAAO,MAAMiB,OAAwB,CAAC,EAAEC,eAAe,EAAE;IACvD,IAAIA,iBAAiB,OAAOA;IAE5B,qBAAO,oBAACnB;AACV,EAAC"}
1
+ {"version":3,"sources":["../../../src/elements/Save/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { useRef } from 'react'\n\nimport { useForm, useFormModified } from '../../forms/Form/context.js'\nimport { FormSubmit } from '../../forms/Submit/index.js'\nimport { useHotkey } from '../../hooks/useHotkey.js'\nimport { useEditDepth } from '../../providers/EditDepth/index.js'\nimport { useOperation } from '../../providers/Operation/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\n\nexport const DefaultSaveButton: React.FC<{ label?: string }> = ({ label: labelProp }) => {\n const { t } = useTranslation()\n const { submit } = useForm()\n const modified = useFormModified()\n const label = labelProp || t('general:save')\n const ref = useRef<HTMLButtonElement>(null)\n const editDepth = useEditDepth()\n const operation = useOperation()\n\n const forceDisable = operation === 'update' && !modified\n\n useHotkey({ cmdCtrlKey: true, editDepth, keyCodes: ['s'] }, (e) => {\n if (forceDisable) return\n\n e.preventDefault()\n e.stopPropagation()\n if (ref?.current) {\n ref.current.click()\n }\n })\n\n return (\n <FormSubmit\n buttonId=\"action-save\"\n disabled={forceDisable}\n onClick={() => submit()}\n ref={ref}\n size=\"small\"\n type=\"button\"\n >\n {label}\n </FormSubmit>\n )\n}\n\ntype Props = {\n CustomComponent?: React.ReactNode\n}\n\nexport const Save: React.FC<Props> = ({ CustomComponent }) => {\n if (CustomComponent) return CustomComponent\n\n return <DefaultSaveButton />\n}\n"],"names":["React","useRef","useForm","useFormModified","FormSubmit","useHotkey","useEditDepth","useOperation","useTranslation","DefaultSaveButton","label","labelProp","t","submit","modified","ref","editDepth","operation","forceDisable","cmdCtrlKey","keyCodes","e","preventDefault","stopPropagation","current","click","buttonId","disabled","onClick","size","type","Save","CustomComponent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,OAAOA,SAASC,MAAM,QAAQ,QAAO;AAErC,SAASC,OAAO,EAAEC,eAAe,QAAQ,8BAA6B;AACtE,SAASC,UAAU,QAAQ,8BAA6B;AACxD,SAASC,SAAS,QAAQ,2BAA0B;AACpD,SAASC,YAAY,QAAQ,qCAAoC;AACjE,SAASC,YAAY,QAAQ,qCAAoC;AACjE,SAASC,cAAc,QAAQ,uCAAsC;AAErE,OAAO,MAAMC,oBAAkD,CAAC,EAAEC,OAAOC,SAAS,EAAE;IAClF,MAAM,EAAEC,CAAC,EAAE,GAAGJ;IACd,MAAM,EAAEK,MAAM,EAAE,GAAGX;IACnB,MAAMY,WAAWX;IACjB,MAAMO,QAAQC,aAAaC,EAAE;IAC7B,MAAMG,MAAMd,OAA0B;IACtC,MAAMe,YAAYV;IAClB,MAAMW,YAAYV;IAElB,MAAMW,eAAeD,cAAc,YAAY,CAACH;IAEhDT,UAAU;QAAEc,YAAY;QAAMH;QAAWI,UAAU;YAAC;SAAI;IAAC,GAAG,CAACC;QAC3D,IAAIH,cAAc;QAElBG,EAAEC,cAAc;QAChBD,EAAEE,eAAe;QACjB,IAAIR,KAAKS,SAAS;YAChBT,IAAIS,OAAO,CAACC,KAAK;QACnB;IACF;IAEA,qBACE,oBAACrB;QACCsB,UAAS;QACTC,UAAUT;QACVU,SAAS,IAAMf;QACfE,KAAKA;QACLc,MAAK;QACLC,MAAK;OAEJpB;AAGP,EAAC;AAMD,OAAO,MAAMqB,OAAwB,CAAC,EAAEC,eAAe,EAAE;IACvD,IAAIA,iBAAiB,OAAOA;IAE5B,qBAAO,oBAACvB;AACV,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/SaveDraft/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAA;AA8ElD,KAAK,KAAK,GAAG;IACX,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAClC,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAIrC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/SaveDraft/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAkFlD,KAAK,KAAK,GAAG;IACX,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAClC,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAIrC,CAAA"}
@@ -7,6 +7,7 @@ import { useConfig } from '../../providers/Config/index.js';
7
7
  import { useDocumentInfo } from '../../providers/DocumentInfo/index.js';
8
8
  import { useEditDepth } from '../../providers/EditDepth/index.js';
9
9
  import { useLocale } from '../../providers/Locale/index.js';
10
+ import { useOperation } from '../../providers/Operation/index.js';
10
11
  import { useTranslation } from '../../providers/Translation/index.js';
11
12
  const baseClass = 'save-draft';
12
13
  const DefaultSaveDraftButton = ()=>{
@@ -18,7 +19,10 @@ const DefaultSaveDraftButton = ()=>{
18
19
  const editDepth = useEditDepth();
19
20
  const { t } = useTranslation();
20
21
  const { submit } = useForm();
22
+ const operation = useOperation();
23
+ const forceDisable = operation === 'update' && !modified;
21
24
  const saveDraft = useCallback(async ()=>{
25
+ if (forceDisable) return;
22
26
  const search = `?locale=${locale}&depth=0&fallback-locale=null&draft=true`;
23
27
  let action;
24
28
  let method = 'POST';
@@ -44,7 +48,8 @@ const DefaultSaveDraftButton = ()=>{
44
48
  serverURL,
45
49
  api,
46
50
  locale,
47
- id
51
+ id,
52
+ forceDisable
48
53
  ]);
49
54
  useHotkey({
50
55
  cmdCtrlKey: true,
@@ -53,9 +58,7 @@ const DefaultSaveDraftButton = ()=>{
53
58
  's'
54
59
  ]
55
60
  }, (e)=>{
56
- if (!modified) {
57
- return;
58
- }
61
+ if (forceDisable) return;
59
62
  e.preventDefault();
60
63
  e.stopPropagation();
61
64
  if (ref?.current) {
@@ -66,7 +69,7 @@ const DefaultSaveDraftButton = ()=>{
66
69
  buttonId: "action-save-draft",
67
70
  buttonStyle: "secondary",
68
71
  className: baseClass,
69
- disabled: !modified,
72
+ disabled: forceDisable,
70
73
  onClick: saveDraft,
71
74
  ref: ref,
72
75
  size: "small",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/elements/SaveDraft/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { useCallback, useRef } from 'react'\n\nimport { useForm, useFormModified } from '../../forms/Form/context.js'\nimport { FormSubmit } from '../../forms/Submit/index.js'\nimport { useHotkey } from '../../hooks/useHotkey.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useEditDepth } from '../../providers/EditDepth/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\n\nconst baseClass = 'save-draft'\n\nconst DefaultSaveDraftButton: React.FC = () => {\n const {\n routes: { api },\n serverURL,\n } = useConfig()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const modified = useFormModified()\n const { code: locale } = useLocale()\n const ref = useRef<HTMLButtonElement>(null)\n const editDepth = useEditDepth()\n const { t } = useTranslation()\n const { submit } = useForm()\n\n const saveDraft = useCallback(async () => {\n const search = `?locale=${locale}&depth=0&fallback-locale=null&draft=true`\n let action\n let method = 'POST'\n\n if (collectionSlug) {\n action = `${serverURL}${api}/${collectionSlug}${id ? `/${id}` : ''}${search}`\n if (id) method = 'PATCH'\n }\n\n if (globalSlug) {\n action = `${serverURL}${api}/globals/${globalSlug}${search}`\n }\n\n await submit({\n action,\n method,\n overrides: {\n _status: 'draft',\n },\n skipValidation: true,\n })\n }, [submit, collectionSlug, globalSlug, serverURL, api, locale, id])\n\n useHotkey({ cmdCtrlKey: true, editDepth, keyCodes: ['s'] }, (e) => {\n if (!modified) {\n return\n }\n\n e.preventDefault()\n e.stopPropagation()\n if (ref?.current) {\n ref.current.click()\n }\n })\n\n return (\n <FormSubmit\n buttonId=\"action-save-draft\"\n buttonStyle=\"secondary\"\n className={baseClass}\n disabled={!modified}\n onClick={saveDraft}\n ref={ref}\n size=\"small\"\n type=\"button\"\n >\n {t('version:saveDraft')}\n </FormSubmit>\n )\n}\n\ntype Props = {\n CustomComponent?: React.ReactNode\n}\n\nexport const SaveDraft: React.FC<Props> = ({ CustomComponent }) => {\n if (CustomComponent) return CustomComponent\n\n return <DefaultSaveDraftButton />\n}\n"],"names":["React","useCallback","useRef","useForm","useFormModified","FormSubmit","useHotkey","useConfig","useDocumentInfo","useEditDepth","useLocale","useTranslation","baseClass","DefaultSaveDraftButton","routes","api","serverURL","id","collectionSlug","globalSlug","modified","code","locale","ref","editDepth","t","submit","saveDraft","search","action","method","overrides","_status","skipValidation","cmdCtrlKey","keyCodes","e","preventDefault","stopPropagation","current","click","buttonId","buttonStyle","className","disabled","onClick","size","type","SaveDraft","CustomComponent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,OAAOA,SAASC,WAAW,EAAEC,MAAM,QAAQ,QAAO;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AAG;IAEnEX,UAAU;QAAE4B,YAAY;QAAMV;QAAWW,UAAU;YAAC;SAAI;IAAC,GAAG,CAACC;QAC3D,IAAI,CAAChB,UAAU;YACb;QACF;QAEAgB,EAAEC,cAAc;QAChBD,EAAEE,eAAe;QACjB,IAAIf,KAAKgB,SAAS;YAChBhB,IAAIgB,OAAO,CAACC,KAAK;QACnB;IACF;IAEA,qBACE,oBAACnC;QACCoC,UAAS;QACTC,aAAY;QACZC,WAAW/B;QACXgC,UAAU,CAACxB;QACXyB,SAASlB;QACTJ,KAAKA;QACLuB,MAAK;QACLC,MAAK;OAEJtB,EAAE;AAGT;AAMA,OAAO,MAAMuB,YAA6B,CAAC,EAAEC,eAAe,EAAE;IAC5D,IAAIA,iBAAiB,OAAOA;IAE5B,qBAAO,oBAACpC;AACV,EAAC"}
1
+ {"version":3,"sources":["../../../src/elements/SaveDraft/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { useCallback, useRef } from 'react'\n\nimport { useForm, useFormModified } from '../../forms/Form/context.js'\nimport { FormSubmit } from '../../forms/Submit/index.js'\nimport { useHotkey } from '../../hooks/useHotkey.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useEditDepth } from '../../providers/EditDepth/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useOperation } from '../../providers/Operation/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\n\nconst baseClass = 'save-draft'\n\nconst DefaultSaveDraftButton: React.FC = () => {\n const {\n routes: { api },\n serverURL,\n } = useConfig()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const modified = useFormModified()\n const { code: locale } = useLocale()\n const ref = useRef<HTMLButtonElement>(null)\n const editDepth = useEditDepth()\n const { t } = useTranslation()\n const { submit } = useForm()\n const operation = useOperation()\n\n const forceDisable = operation === 'update' && !modified\n\n const saveDraft = useCallback(async () => {\n if (forceDisable) return\n\n const search = `?locale=${locale}&depth=0&fallback-locale=null&draft=true`\n let action\n let method = 'POST'\n\n if (collectionSlug) {\n action = `${serverURL}${api}/${collectionSlug}${id ? `/${id}` : ''}${search}`\n if (id) method = 'PATCH'\n }\n\n if (globalSlug) {\n action = `${serverURL}${api}/globals/${globalSlug}${search}`\n }\n\n await submit({\n action,\n method,\n overrides: {\n _status: 'draft',\n },\n skipValidation: true,\n })\n }, [submit, collectionSlug, globalSlug, serverURL, api, locale, id, forceDisable])\n\n useHotkey({ cmdCtrlKey: true, editDepth, keyCodes: ['s'] }, (e) => {\n if (forceDisable) return\n\n e.preventDefault()\n e.stopPropagation()\n if (ref?.current) {\n ref.current.click()\n }\n })\n\n return (\n <FormSubmit\n buttonId=\"action-save-draft\"\n buttonStyle=\"secondary\"\n className={baseClass}\n disabled={forceDisable}\n onClick={saveDraft}\n ref={ref}\n size=\"small\"\n type=\"button\"\n >\n {t('version:saveDraft')}\n </FormSubmit>\n )\n}\n\ntype Props = {\n CustomComponent?: React.ReactNode\n}\n\nexport const SaveDraft: React.FC<Props> = ({ CustomComponent }) => {\n if (CustomComponent) return CustomComponent\n\n return <DefaultSaveDraftButton />\n}\n"],"names":["React","useCallback","useRef","useForm","useFormModified","FormSubmit","useHotkey","useConfig","useDocumentInfo","useEditDepth","useLocale","useOperation","useTranslation","baseClass","DefaultSaveDraftButton","routes","api","serverURL","id","collectionSlug","globalSlug","modified","code","locale","ref","editDepth","t","submit","operation","forceDisable","saveDraft","search","action","method","overrides","_status","skipValidation","cmdCtrlKey","keyCodes","e","preventDefault","stopPropagation","current","click","buttonId","buttonStyle","className","disabled","onClick","size","type","SaveDraft","CustomComponent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,OAAOA,SAASC,WAAW,EAAEC,MAAM,QAAQ,QAAO;AAElD,SAASC,OAAO,EAAEC,eAAe,QAAQ,8BAA6B;AACtE,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F,GAAG;QAACT;QAAQR;QAAgBC;QAAYH;QAAWD;QAAKO;QAAQL;QAAIW;KAAa;IAEjFvB,UAAU;QAAE+B,YAAY;QAAMZ;QAAWa,UAAU;YAAC;SAAI;IAAC,GAAG,CAACC;QAC3D,IAAIV,cAAc;QAElBU,EAAEC,cAAc;QAChBD,EAAEE,eAAe;QACjB,IAAIjB,KAAKkB,SAAS;YAChBlB,IAAIkB,OAAO,CAACC,KAAK;QACnB;IACF;IAEA,qBACE,oBAACtC;QACCuC,UAAS;QACTC,aAAY;QACZC,WAAWjC;QACXkC,UAAUlB;QACVmB,SAASlB;QACTN,KAAKA;QACLyB,MAAK;QACLC,MAAK;OAEJxB,EAAE;AAGT;AAMA,OAAO,MAAMyB,YAA6B,CAAC,EAAEC,eAAe,EAAE;IAC5D,IAAIA,iBAAiB,OAAOA;IAE5B,qBAAO,oBAACtC;AACV,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/elements/Table/DefaultCell/fields/Checkbox/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAA;AAE9D,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAIrE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/elements/Table/DefaultCell/fields/Checkbox/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAA;AAG9D,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAOrE,CAAA"}
@@ -1,7 +1,11 @@
1
1
  'use client';
2
+ import { useTranslation } from '@payloadcms/ui/providers/Translation';
2
3
  import React from 'react';
3
- export const CheckboxCell = ({ cellData })=>/*#__PURE__*/ React.createElement("code", {
4
+ export const CheckboxCell = ({ cellData })=>{
5
+ const { t } = useTranslation();
6
+ return /*#__PURE__*/ React.createElement("code", {
4
7
  className: "bool-cell"
5
- }, /*#__PURE__*/ React.createElement("span", null, JSON.stringify(cellData)));
8
+ }, /*#__PURE__*/ React.createElement("span", null, t(`general:${cellData}`).toLowerCase()));
9
+ };
6
10
 
7
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/elements/Table/DefaultCell/fields/Checkbox/index.tsx"],"sourcesContent":["'use client'\nimport type { DefaultCellComponentProps } from 'payload/types'\n\nimport React from 'react'\n\nimport './index.scss'\n\nexport const CheckboxCell: React.FC<DefaultCellComponentProps<boolean>> = ({ cellData }) => (\n <code className=\"bool-cell\">\n <span>{JSON.stringify(cellData)}</span>\n </code>\n)\n"],"names":["React","CheckboxCell","cellData","code","className","span","JSON","stringify"],"rangeMappings":";;;;","mappings":"AAAA;AAGA,OAAOA,WAAW,QAAO;AAIzB,OAAO,MAAMC,eAA6D,CAAC,EAAEC,QAAQ,EAAE,iBACrF,oBAACC;QAAKC,WAAU;qBACd,oBAACC,cAAMC,KAAKC,SAAS,CAACL,YAEzB"}
1
+ {"version":3,"sources":["../../../../../../src/elements/Table/DefaultCell/fields/Checkbox/index.tsx"],"sourcesContent":["'use client'\nimport type { DefaultCellComponentProps } from 'payload/types'\n\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React from 'react'\n\nimport './index.scss'\n\nexport const CheckboxCell: React.FC<DefaultCellComponentProps<boolean>> = ({ cellData }) => {\n const { t } = useTranslation()\n return (\n <code className=\"bool-cell\">\n <span>{t(`general:${cellData}`).toLowerCase()}</span>\n </code>\n )\n}\n"],"names":["useTranslation","React","CheckboxCell","cellData","t","code","className","span","toLowerCase"],"rangeMappings":";;;;;;;;","mappings":"AAAA;AAGA,SAASA,cAAc,QAAQ,uCAAsC;AACrE,OAAOC,WAAW,QAAO;AAIzB,OAAO,MAAMC,eAA6D,CAAC,EAAEC,QAAQ,EAAE;IACrF,MAAM,EAAEC,CAAC,EAAE,GAAGJ;IACd,qBACE,oBAACK;QAAKC,WAAU;qBACd,oBAACC,cAAMH,EAAE,CAAC,QAAQ,EAAED,SAAS,CAAC,EAAEK,WAAW;AAGjD,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/Table/DefaultCell/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,kBAAkB,EAA6B,MAAM,eAAe,CAAA;AAYlF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAoHpD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/Table/DefaultCell/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,kBAAkB,EAA6B,MAAM,eAAe,CAAA;AAYlF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAqHpD,CAAA"}
@@ -45,7 +45,7 @@ export const DefaultCell = (props)=>{
45
45
  rowData: rowData
46
46
  }));
47
47
  }
48
- const DefaultCellComponent = cellComponents[fieldType];
48
+ const DefaultCellComponent = typeof cellData !== 'undefined' && cellComponents[fieldType];
49
49
  let CellComponent = cellData && (CellComponentOverride ? /*#__PURE__*/ React.createElement(TableCellProvider, {
50
50
  richTextComponentMap: richTextComponentMap
51
51
  }, CellComponentOverride) : null);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/elements/Table/DefaultCell/index.tsx"],"sourcesContent":["'use client'\nimport LinkImport from 'next/link.js'\nimport React from 'react' // TODO: abstract this out to support all routers\n\nimport type { CellComponentProps, DefaultCellComponentProps } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { TableCellProvider, useTableCell } from '@payloadcms/ui/elements/Table'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\n\nimport { CodeCell } from './fields/Code/index.js'\nimport { cellComponents } from './fields/index.js'\n\nconst Link = (LinkImport.default || LinkImport) as unknown as typeof LinkImport.default\n\nexport const DefaultCell: React.FC<CellComponentProps> = (props) => {\n const {\n name,\n CellComponentOverride,\n className: classNameFromProps,\n fieldType,\n isFieldAffectingData,\n label,\n onClick: onClickFromProps,\n richTextComponentMap,\n } = props\n\n const { i18n } = useTranslation()\n\n const {\n routes: { admin: adminRoute },\n } = useConfig()\n\n const cellContext = useTableCell()\n\n const { cellData, cellProps, columnIndex, customCellContext, rowData } = cellContext || {}\n\n const { className: classNameFromContext, link, onClick: onClickFromContext } = cellProps || {}\n\n const className = classNameFromProps || classNameFromContext\n\n const onClick = onClickFromProps || onClickFromContext\n\n let WrapElement: React.ComponentType<any> | string = 'span'\n\n const wrapElementProps: {\n className?: string\n href?: string\n onClick?: () => void\n type?: 'button'\n } = {\n className,\n }\n\n const isLink = link !== undefined ? link : columnIndex === 0\n\n if (isLink) {\n WrapElement = Link\n wrapElementProps.href = customCellContext?.collectionSlug\n ? `${adminRoute}/collections/${customCellContext?.collectionSlug}/${rowData.id}`\n : ''\n }\n\n if (typeof onClick === 'function') {\n WrapElement = 'button'\n wrapElementProps.type = 'button'\n wrapElementProps.onClick = () => {\n onClick({\n cellData,\n collectionSlug: customCellContext?.collectionSlug,\n rowData,\n })\n }\n }\n\n if (name === 'id') {\n return (\n <WrapElement {...wrapElementProps}>\n <CodeCell cellData={`ID: ${cellData}`} name={name} nowrap rowData={rowData} />\n </WrapElement>\n )\n }\n\n const DefaultCellComponent: React.FC<DefaultCellComponentProps> = cellComponents[fieldType]\n\n let CellComponent: React.ReactNode =\n cellData &&\n (CellComponentOverride ? ( // CellComponentOverride is used for richText\n <TableCellProvider richTextComponentMap={richTextComponentMap}>\n {CellComponentOverride}\n </TableCellProvider>\n ) : null)\n\n if (!CellComponent && DefaultCellComponent) {\n CellComponent = (\n <DefaultCellComponent\n cellData={cellData}\n customCellContext={customCellContext}\n rowData={rowData}\n {...props}\n />\n )\n } else if (!CellComponent && !DefaultCellComponent) {\n // DefaultCellComponent does not exist for certain field types like `text`\n if (customCellContext.uploadConfig && isFieldAffectingData && name === 'filename') {\n const FileCellComponent = cellComponents.File\n CellComponent = (\n <FileCellComponent\n cellData={cellData}\n customCellContext={customCellContext}\n rowData={rowData}\n {...props}\n />\n )\n } else {\n return (\n <WrapElement {...wrapElementProps}>\n {(cellData === '' || typeof cellData === 'undefined') &&\n 'label' in props &&\n i18n.t('general:noLabel', {\n label: getTranslation(label || 'data', i18n),\n })}\n {typeof cellData === 'string' && cellData}\n {typeof cellData === 'number' && cellData}\n {typeof cellData === 'object' && JSON.stringify(cellData)}\n </WrapElement>\n )\n }\n }\n\n return <WrapElement {...wrapElementProps}>{CellComponent}</WrapElement>\n}\n"],"names":["LinkImport","React","getTranslation","TableCellProvider","useTableCell","useConfig","useTranslation","CodeCell","cellComponents","Link","default","DefaultCell","props","name","CellComponentOverride","className","classNameFromProps","fieldType","isFieldAffectingData","label","onClick","onClickFromProps","richTextComponentMap","i18n","routes","admin","adminRoute","cellContext","cellData","cellProps","columnIndex","customCellContext","rowData","classNameFromContext","link","onClickFromContext","WrapElement","wrapElementProps","isLink","undefined","href","collectionSlug","id","type","nowrap","DefaultCellComponent","CellComponent","uploadConfig","FileCellComponent","File","t","JSON","stringify"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,OAAOA,gBAAgB,eAAc;AACrC,OAAOC,WAAW,QAAO,CAAC,iDAAiD;AAI3E,SAASC,cAAc,QAAQ,2BAA0B;AACz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gBACAa,gBAAgBV,mBAAmBU;gBACnCT;YACF;QACF;IACF;IAEA,IAAInB,SAAS,MAAM;QACjB,qBACE,oBAACuB,aAAgBC,gCACf,oBAAC9B;YAASqB,UAAU,CAAC,IAAI,EAAEA,SAAS,CAAC;YAAEf,MAAMA;YAAM+B,QAAAA;YAAOZ,SAASA;;IAGzE;IAEA,MAAMa,uBAA4DrC,cAAc,CAACS,UAAU;IAE3F,IAAI6B,gBACFlB,YACCd,CAAAA,sCACC,oBAACX;QAAkBmB,sBAAsBA;OACtCR,yBAED,IAAG;IAET,IAAI,CAACgC,iBAAiBD,sBAAsB;QAC1CC,8BACE,oBAACD;YACCjB,UAAUA;YACVG,mBAAmBA;YACnBC,SAASA;YACR,GAAGpB,KAAK;;IAGf,OAAO,IAAI,CAACkC,iBAAiB,CAACD,sBAAsB;QAClD,0EAA0E;QAC1E,IAAId,kBAAkBgB,YAAY,IAAI7B,wBAAwBL,SAAS,YAAY;YACjF,MAAMmC,oBAAoBxC,eAAeyC,IAAI;YAC7CH,8BACE,oBAACE;gBACCpB,UAAUA;gBACVG,mBAAmBA;gBACnBC,SAASA;gBACR,GAAGpB,KAAK;;QAGf,OAAO;YACL,qBACE,oBAACwB,aAAgBC,kBACd,AAACT,CAAAA,aAAa,MAAM,OAAOA,aAAa,WAAU,KACjD,WAAWhB,SACXW,KAAK2B,CAAC,CAAC,mBAAmB;gBACxB/B,OAAOjB,eAAeiB,SAAS,QAAQI;YACzC,IACD,OAAOK,aAAa,YAAYA,UAChC,OAAOA,aAAa,YAAYA,UAChC,OAAOA,aAAa,YAAYuB,KAAKC,SAAS,CAACxB;QAGtD;IACF;IAEA,qBAAO,oBAACQ,aAAgBC,kBAAmBS;AAC7C,EAAC"}
1
+ {"version":3,"sources":["../../../../src/elements/Table/DefaultCell/index.tsx"],"sourcesContent":["'use client'\nimport LinkImport from 'next/link.js'\nimport React from 'react' // TODO: abstract this out to support all routers\n\nimport type { CellComponentProps, DefaultCellComponentProps } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { TableCellProvider, useTableCell } from '@payloadcms/ui/elements/Table'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\n\nimport { CodeCell } from './fields/Code/index.js'\nimport { cellComponents } from './fields/index.js'\n\nconst Link = (LinkImport.default || LinkImport) as unknown as typeof LinkImport.default\n\nexport const DefaultCell: React.FC<CellComponentProps> = (props) => {\n const {\n name,\n CellComponentOverride,\n className: classNameFromProps,\n fieldType,\n isFieldAffectingData,\n label,\n onClick: onClickFromProps,\n richTextComponentMap,\n } = props\n\n const { i18n } = useTranslation()\n\n const {\n routes: { admin: adminRoute },\n } = useConfig()\n\n const cellContext = useTableCell()\n\n const { cellData, cellProps, columnIndex, customCellContext, rowData } = cellContext || {}\n\n const { className: classNameFromContext, link, onClick: onClickFromContext } = cellProps || {}\n\n const className = classNameFromProps || classNameFromContext\n\n const onClick = onClickFromProps || onClickFromContext\n\n let WrapElement: React.ComponentType<any> | string = 'span'\n\n const wrapElementProps: {\n className?: string\n href?: string\n onClick?: () => void\n type?: 'button'\n } = {\n className,\n }\n\n const isLink = link !== undefined ? link : columnIndex === 0\n\n if (isLink) {\n WrapElement = Link\n wrapElementProps.href = customCellContext?.collectionSlug\n ? `${adminRoute}/collections/${customCellContext?.collectionSlug}/${rowData.id}`\n : ''\n }\n\n if (typeof onClick === 'function') {\n WrapElement = 'button'\n wrapElementProps.type = 'button'\n wrapElementProps.onClick = () => {\n onClick({\n cellData,\n collectionSlug: customCellContext?.collectionSlug,\n rowData,\n })\n }\n }\n\n if (name === 'id') {\n return (\n <WrapElement {...wrapElementProps}>\n <CodeCell cellData={`ID: ${cellData}`} name={name} nowrap rowData={rowData} />\n </WrapElement>\n )\n }\n\n const DefaultCellComponent: React.FC<DefaultCellComponentProps> =\n typeof cellData !== 'undefined' && cellComponents[fieldType]\n\n let CellComponent: React.ReactNode =\n cellData &&\n (CellComponentOverride ? ( // CellComponentOverride is used for richText\n <TableCellProvider richTextComponentMap={richTextComponentMap}>\n {CellComponentOverride}\n </TableCellProvider>\n ) : null)\n\n if (!CellComponent && DefaultCellComponent) {\n CellComponent = (\n <DefaultCellComponent\n cellData={cellData}\n customCellContext={customCellContext}\n rowData={rowData}\n {...props}\n />\n )\n } else if (!CellComponent && !DefaultCellComponent) {\n // DefaultCellComponent does not exist for certain field types like `text`\n if (customCellContext.uploadConfig && isFieldAffectingData && name === 'filename') {\n const FileCellComponent = cellComponents.File\n CellComponent = (\n <FileCellComponent\n cellData={cellData}\n customCellContext={customCellContext}\n rowData={rowData}\n {...props}\n />\n )\n } else {\n return (\n <WrapElement {...wrapElementProps}>\n {(cellData === '' || typeof cellData === 'undefined') &&\n 'label' in props &&\n i18n.t('general:noLabel', {\n label: getTranslation(label || 'data', i18n),\n })}\n {typeof cellData === 'string' && cellData}\n {typeof cellData === 'number' && cellData}\n {typeof cellData === 'object' && JSON.stringify(cellData)}\n </WrapElement>\n )\n }\n }\n\n return <WrapElement {...wrapElementProps}>{CellComponent}</WrapElement>\n}\n"],"names":["LinkImport","React","getTranslation","TableCellProvider","useTableCell","useConfig","useTranslation","CodeCell","cellComponents","Link","default","DefaultCell","props","name","CellComponentOverride","className","classNameFromProps","fieldType","isFieldAffectingData","label","onClick","onClickFromProps","richTextComponentMap","i18n","routes","admin","adminRoute","cellContext","cellData","cellProps","columnIndex","customCellContext","rowData","classNameFromContext","link","onClickFromContext","WrapElement","wrapElementProps","isLink","undefined","href","collectionSlug","id","type","nowrap","DefaultCellComponent","CellComponent","uploadConfig","FileCellComponent","File","t","JSON","stringify"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,OAAOA,gBAAgB,eAAc;AACrC,OAAOC,WAAW,QAAO,CAAC,iDAAiD;AAI3E,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC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gBAAgBV,mBAAmBU;gBACnCT;YACF;QACF;IACF;IAEA,IAAInB,SAAS,MAAM;QACjB,qBACE,oBAACuB,aAAgBC,gCACf,oBAAC9B;YAASqB,UAAU,CAAC,IAAI,EAAEA,SAAS,CAAC;YAAEf,MAAMA;YAAM+B,QAAAA;YAAOZ,SAASA;;IAGzE;IAEA,MAAMa,uBACJ,OAAOjB,aAAa,eAAepB,cAAc,CAACS,UAAU;IAE9D,IAAI6B,gBACFlB,YACCd,CAAAA,sCACC,oBAACX;QAAkBmB,sBAAsBA;OACtCR,yBAED,IAAG;IAET,IAAI,CAACgC,iBAAiBD,sBAAsB;QAC1CC,8BACE,oBAACD;YACCjB,UAAUA;YACVG,mBAAmBA;YACnBC,SAASA;YACR,GAAGpB,KAAK;;IAGf,OAAO,IAAI,CAACkC,iBAAiB,CAACD,sBAAsB;QAClD,0EAA0E;QAC1E,IAAId,kBAAkBgB,YAAY,IAAI7B,wBAAwBL,SAAS,YAAY;YACjF,MAAMmC,oBAAoBxC,eAAeyC,IAAI;YAC7CH,8BACE,oBAACE;gBACCpB,UAAUA;gBACVG,mBAAmBA;gBACnBC,SAASA;gBACR,GAAGpB,KAAK;;QAGf,OAAO;YACL,qBACE,oBAACwB,aAAgBC,kBACd,AAACT,CAAAA,aAAa,MAAM,OAAOA,aAAa,WAAU,KACjD,WAAWhB,SACXW,KAAK2B,CAAC,CAAC,mBAAmB;gBACxB/B,OAAOjB,eAAeiB,SAAS,QAAQI;YACzC,IACD,OAAOK,aAAa,YAAYA,UAChC,OAAOA,aAAa,YAAYA,UAChC,OAAOA,aAAa,YAAYuB,KAAKC,SAAS,CAACxB;QAGtD;IACF;IAEA,qBAAO,oBAACQ,aAAgBC,kBAAmBS;AAC7C,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/ui",
3
- "version": "3.0.0-beta.23",
3
+ "version": "3.0.0-beta.24",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "repository": {
6
6
  "type": "git",
@@ -113,7 +113,7 @@
113
113
  "react-toastify": "10.0.4",
114
114
  "use-context-selector": "1.4.1",
115
115
  "uuid": "9.0.1",
116
- "@payloadcms/translations": "3.0.0-beta.23"
116
+ "@payloadcms/translations": "3.0.0-beta.24"
117
117
  },
118
118
  "devDependencies": {
119
119
  "@types/body-scroll-lock": "^3.1.0",
@@ -133,14 +133,14 @@
133
133
  "terser-webpack-plugin": "^5.3.10",
134
134
  "webpack": "^5.78.0",
135
135
  "webpack-cli": "^5.1.4",
136
- "payload": "3.0.0-beta.23",
137
- "@payloadcms/eslint-config": "1.1.1"
136
+ "@payloadcms/eslint-config": "1.1.1",
137
+ "payload": "3.0.0-beta.24"
138
138
  },
139
139
  "peerDependencies": {
140
140
  "next": "^14.3.0-canary.7",
141
141
  "react": "^18.0.0",
142
142
  "react-dom": "^18.0.0",
143
- "payload": "3.0.0-beta.23"
143
+ "payload": "3.0.0-beta.24"
144
144
  },
145
145
  "engines": {
146
146
  "node": ">=18.20.2"