tinacms 0.0.0-bbf2f81-20241024004604 → 0.0.0-bbfd415-20241202040226

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.
@@ -25,6 +25,9 @@ export interface DocumentNode {
25
25
  }
26
26
  export interface DocumentForm {
27
27
  _values: Object;
28
+ _sys?: {
29
+ hasReferences?: boolean;
30
+ };
28
31
  }
29
32
  export interface DocumentSys {
30
33
  _sys: {
@@ -1,2 +1,3 @@
1
1
  import type { Cache } from './index';
2
+ export declare const makeCacheDir: (dir: string, fs: any, path: any, os: any) => Promise<string>;
2
3
  export declare const NodeCache: (dir: string) => Promise<Cache>;
package/dist/client.js CHANGED
@@ -105,21 +105,27 @@
105
105
  const client = new TinaClient(args);
106
106
  return client;
107
107
  }
108
- const makeCacheDir = async (dir, fs) => {
109
- const path = await Promise.resolve().then(() => __viteBrowserExternal$1);
110
- const os = await Promise.resolve().then(() => __viteBrowserExternal$1);
111
- const parts = dir.split(path.sep).filter(Boolean);
108
+ const makeCacheDir = async (dir, fs, path, os) => {
109
+ const pathParts = dir.split(path.sep).filter(Boolean);
110
+ const cacheHash = pathParts[pathParts.length - 1];
111
+ const rootUser = pathParts[0];
112
112
  let cacheDir = dir;
113
- if (!fs.existsSync(path.join(path.sep, parts[0]))) {
114
- cacheDir = path.join(os.tmpdir(), parts[parts.length - 1]);
113
+ if (!fs.existsSync(path.join(path.sep, rootUser))) {
114
+ cacheDir = path.join(os.tmpdir(), cacheHash);
115
+ }
116
+ try {
117
+ fs.mkdirSync(cacheDir, { recursive: true });
118
+ } catch (error) {
119
+ throw new Error(`Failed to create cache directory: ${error.message}`);
115
120
  }
116
- fs.mkdirSync(cacheDir, { recursive: true });
117
121
  return cacheDir;
118
122
  };
119
123
  const NodeCache = async (dir) => {
120
- const fs = await Promise.resolve().then(() => __viteBrowserExternal$1);
121
- const { createHash } = await Promise.resolve().then(() => __viteBrowserExternal$1);
122
- const cacheDir = await makeCacheDir(dir, fs);
124
+ const fs = require("node:fs");
125
+ const path = require("node:path");
126
+ const os = require("node:os");
127
+ const { createHash } = require("node:crypto");
128
+ const cacheDir = await makeCacheDir(dir, fs, path, os);
123
129
  return {
124
130
  makeKey: (key) => {
125
131
  const input = key && key instanceof Object ? JSON.stringify(key) : key || "";
@@ -147,12 +153,8 @@
147
153
  };
148
154
  const nodeCache = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
149
155
  __proto__: null,
150
- NodeCache
151
- }, Symbol.toStringTag, { value: "Module" }));
152
- const __viteBrowserExternal = {};
153
- const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
154
- __proto__: null,
155
- default: __viteBrowserExternal
156
+ NodeCache,
157
+ makeCacheDir
156
158
  }, Symbol.toStringTag, { value: "Module" }));
157
159
  exports2.TINA_HOST = TINA_HOST;
158
160
  exports2.TinaClient = TinaClient;
package/dist/client.mjs CHANGED
@@ -24,7 +24,7 @@ class TinaClient {
24
24
  }
25
25
  try {
26
26
  if (this.cacheDir && typeof window === "undefined" && typeof require !== "undefined") {
27
- const { NodeCache } = await import("./node-cache-7fa2452c.mjs");
27
+ const { NodeCache } = await import("./node-cache-4c336858.mjs");
28
28
  this.cache = await NodeCache(this.cacheDir);
29
29
  }
30
30
  } catch (e) {
package/dist/index.d.ts CHANGED
@@ -53,7 +53,7 @@ export type TinaCollection = Collection;
53
53
  export type TinaCloudSchema = Schema;
54
54
  export declare const defineSchema: (config: Schema) => Schema<false>;
55
55
  export declare const defineLegacyConfig: (config: Omit<TinaCMSProviderDefaultProps, "children">) => Omit<TinaCMSProviderDefaultProps, "children">;
56
- interface MediaStoreClass {
56
+ export interface MediaStoreClass {
57
57
  new (...args: any[]): MediaStore;
58
58
  }
59
59
  export declare const defineStaticConfig: (config: Config<(cms: TinaCMS) => TinaCMS, formifyCallback, DocumentCreatorCallback, MediaStoreClass>) => Config<(cms: TinaCMS) => TinaCMS, formifyCallback, import("./hooks/use-content-creator").DocumentCreatorArgs, MediaStoreClass, undefined>;
package/dist/index.js CHANGED
@@ -774,6 +774,22 @@ var __publicField = (obj, key, value) => {
774
774
  );
775
775
  };
776
776
  }
777
+ function wrapFieldWithNoHeader(Field) {
778
+ return (props) => {
779
+ return /* @__PURE__ */ React__namespace.createElement(
780
+ FieldMeta,
781
+ {
782
+ name: props.input.name,
783
+ label: false,
784
+ description: "",
785
+ error: props.meta.error,
786
+ index: props.index,
787
+ tinaForm: props.tinaForm
788
+ },
789
+ /* @__PURE__ */ React__namespace.createElement(Field, { ...props })
790
+ );
791
+ };
792
+ }
777
793
  function wrapFieldWithError(Field) {
778
794
  return (props) => {
779
795
  return /* @__PURE__ */ React__namespace.createElement(
@@ -846,6 +862,16 @@ var __publicField = (obj, key, value) => {
846
862
  className,
847
863
  ...props
848
864
  }) => {
865
+ if (typeof children === "string") {
866
+ return /* @__PURE__ */ React__namespace.createElement(
867
+ "span",
868
+ {
869
+ className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
870
+ ...props,
871
+ dangerouslySetInnerHTML: { __html: children }
872
+ }
873
+ );
874
+ }
849
875
  return /* @__PURE__ */ React__namespace.createElement(
850
876
  "span",
851
877
  {
@@ -5710,10 +5736,11 @@ flowchart TD
5710
5736
  return /* @__PURE__ */ React.createElement(
5711
5737
  "button",
5712
5738
  {
5713
- className: `w-8 px-1 py-2.5 flex items-center justify-center hover:bg-gray-50 text-gray-200 hover:text-red-500 ${disabled && "pointer-events-none opacity-30 cursor-not-allowed"}`,
5739
+ type: "button",
5740
+ className: `w-8 px-1 py-2.5 flex items-center justify-center text-gray-200 hover:opacity-100 opacity-30 hover:bg-gray-50 ${disabled && "pointer-events-none opacity-30 cursor-not-allowed"}`,
5714
5741
  onClick
5715
5742
  },
5716
- /* @__PURE__ */ React.createElement(TrashIcon, { className: "fill-current transition-colors ease-out duration-100" })
5743
+ /* @__PURE__ */ React.createElement(TrashIcon, { className: "h-5 w-auto fill-current text-red-500 transition-colors duration-150 ease-out" })
5717
5744
  );
5718
5745
  };
5719
5746
  const DragHandle = ({ isDragging }) => {
@@ -5791,27 +5818,35 @@ flowchart TD
5791
5818
  ))))
5792
5819
  ))));
5793
5820
  };
5794
- const Group = wrapFieldWithError(({ tinaForm, field }) => {
5795
- const cms = useCMS$1();
5796
- React__namespace.useState(false);
5797
- return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(
5798
- Header,
5799
- {
5800
- onClick: () => {
5801
- const state = tinaForm.finalForm.getState();
5802
- if (state.invalid === true) {
5803
- cms.alerts.error("Cannot navigate away from an invalid form.");
5804
- return;
5821
+ const Group = wrapFieldWithNoHeader(
5822
+ ({ tinaForm, field }) => {
5823
+ const cms = useCMS$1();
5824
+ return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(
5825
+ Header,
5826
+ {
5827
+ onClick: () => {
5828
+ const state = tinaForm.finalForm.getState();
5829
+ if (state.invalid === true) {
5830
+ cms.alerts.error("Cannot navigate away from an invalid form.");
5831
+ return;
5832
+ }
5833
+ cms.dispatch({
5834
+ type: "forms:set-active-field-name",
5835
+ value: { formId: tinaForm.id, fieldName: field.name }
5836
+ });
5805
5837
  }
5806
- cms.dispatch({
5807
- type: "forms:set-active-field-name",
5808
- value: { formId: tinaForm.id, fieldName: field.name }
5809
- });
5810
- }
5811
- },
5812
- field.label || field.name
5813
- ));
5814
- });
5838
+ },
5839
+ field.label || field.name,
5840
+ field.description && /* @__PURE__ */ React__namespace.createElement(
5841
+ "span",
5842
+ {
5843
+ className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0`,
5844
+ dangerouslySetInnerHTML: { __html: field.description }
5845
+ }
5846
+ )
5847
+ ));
5848
+ }
5849
+ );
5815
5850
  const Header = ({ onClick, children }) => {
5816
5851
  return /* @__PURE__ */ React__namespace.createElement("div", { className: "pt-1 mb-5" }, /* @__PURE__ */ React__namespace.createElement(
5817
5852
  "button",
@@ -10308,7 +10343,7 @@ flowchart TD
10308
10343
  "Event Log"
10309
10344
  ));
10310
10345
  };
10311
- const version = "2.3.0";
10346
+ const version = "2.5.0";
10312
10347
  const Nav = ({
10313
10348
  isLocalMode,
10314
10349
  className = "",
@@ -14425,6 +14460,7 @@ flowchart TD
14425
14460
  ToolbarButton,
14426
14461
  {
14427
14462
  showArrow: false,
14463
+ "data-testid": "rich-text-editor-overflow-menu-button",
14428
14464
  className: "lg:min-w-[130px]",
14429
14465
  isDropdown: true,
14430
14466
  pressed: openState.open,
@@ -14478,7 +14514,17 @@ flowchart TD
14478
14514
  };
14479
14515
  const RawMarkdownToolbarButton = cn$1.withRef(({ clear, ...rest }, ref) => {
14480
14516
  const { props } = useRawMarkdownToolbarButton();
14481
- return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.raw, null));
14517
+ return /* @__PURE__ */ React.createElement(
14518
+ ToolbarButton,
14519
+ {
14520
+ ref,
14521
+ tooltip: "Link",
14522
+ ...rest,
14523
+ ...props,
14524
+ "data-testid": "markdown-button"
14525
+ },
14526
+ /* @__PURE__ */ React.createElement(Icons.raw, null)
14527
+ );
14482
14528
  });
14483
14529
  function TableDropdownMenu(props) {
14484
14530
  const tableSelected = plateCommon.useEditorSelector(
@@ -30077,6 +30123,7 @@ mutation addPendingDocumentMutation(
30077
30123
  relativePath
30078
30124
  filename
30079
30125
  extension
30126
+ hasReferences
30080
30127
  }
30081
30128
  }
30082
30129
  }
@@ -30168,6 +30215,9 @@ mutation addPendingDocumentMutation(
30168
30215
  document(collection:$collection, relativePath:$relativePath) {
30169
30216
  ... on Document {
30170
30217
  _values
30218
+ _sys {
30219
+ hasReferences
30220
+ }
30171
30221
  }
30172
30222
  }
30173
30223
  }`;
@@ -31894,6 +31944,23 @@ This will work when developing locally but NOT when deployed to production.
31894
31944
  DeleteModal,
31895
31945
  {
31896
31946
  filename: vars.relativePath,
31947
+ checkRefsFunc: async () => {
31948
+ var _a2, _b2;
31949
+ try {
31950
+ const doc = await admin.fetchDocument(
31951
+ collection.name,
31952
+ vars.relativePath,
31953
+ true
31954
+ );
31955
+ return (_b2 = (_a2 = doc == null ? void 0 : doc.document) == null ? void 0 : _a2._sys) == null ? void 0 : _b2.hasReferences;
31956
+ } catch (error) {
31957
+ cms.alerts.error(
31958
+ "Document was not found, ask a developer for help or check the console for an error message"
31959
+ );
31960
+ console.error(error);
31961
+ throw error;
31962
+ }
31963
+ },
31897
31964
  deleteFunc: async () => {
31898
31965
  try {
31899
31966
  await admin.deleteDocument(vars);
@@ -31902,6 +31969,12 @@ This will work when developing locally but NOT when deployed to production.
31902
31969
  );
31903
31970
  reFetchCollection();
31904
31971
  } catch (error) {
31972
+ if (error.message.indexOf("has references")) {
31973
+ cms.alerts.error(
31974
+ error.message.split("\n ").filter(Boolean)[1]
31975
+ );
31976
+ return;
31977
+ }
31905
31978
  cms.alerts.warn(
31906
31979
  "Document was not deleted, ask a developer for help or check the console for an error message"
31907
31980
  );
@@ -31953,6 +32026,12 @@ This will work when developing locally but NOT when deployed to production.
31953
32026
  cms.alerts.info("Document was successfully renamed");
31954
32027
  reFetchCollection();
31955
32028
  } catch (error) {
32029
+ if (error.message.indexOf("has references")) {
32030
+ cms.alerts.error(
32031
+ error.message.split("\n ").filter(Boolean)[1]
32032
+ );
32033
+ return;
32034
+ }
31956
32035
  cms.alerts.warn(
31957
32036
  "Document was not renamed, ask a developer for help or check the console for an error message"
31958
32037
  );
@@ -32426,8 +32505,19 @@ This will work when developing locally but NOT when deployed to production.
32426
32505
  const NoDocumentsPlaceholder = () => {
32427
32506
  return /* @__PURE__ */ React.createElement("div", { className: "text-center px-5 py-3 flex flex-col items-center justify-center shadow border border-gray-100 bg-gray-50 border-b border-gray-200 w-full max-w-full rounded-lg" }, /* @__PURE__ */ React.createElement("p", { className: "text-base italic font-medium text-gray-300" }, "No documents found."));
32428
32507
  };
32429
- const DeleteModal = ({ close: close2, deleteFunc, filename }) => {
32430
- return /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, { close: close2 }, "Delete ", filename), /* @__PURE__ */ React.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React.createElement("p", null, `Are you sure you want to delete ${filename}?`)), /* @__PURE__ */ React.createElement(ModalActions, null, /* @__PURE__ */ React.createElement(Button$1, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React.createElement(
32508
+ const DeleteModal = ({
32509
+ close: close2,
32510
+ deleteFunc,
32511
+ checkRefsFunc,
32512
+ filename
32513
+ }) => {
32514
+ const [hasRefs, setHasRefs] = React.useState();
32515
+ React.useEffect(() => {
32516
+ checkRefsFunc().then((result) => {
32517
+ setHasRefs(result);
32518
+ });
32519
+ }, [filename, checkRefsFunc]);
32520
+ return /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, { close: close2 }, "Delete ", filename), /* @__PURE__ */ React.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React.createElement("p", null, `Are you sure you want to delete ${filename}?${hasRefs ? " References to this document will also be deleted." : ""}`)), /* @__PURE__ */ React.createElement(ModalActions, null, /* @__PURE__ */ React.createElement(Button$1, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React.createElement(
32431
32521
  Button$1,
32432
32522
  {
32433
32523
  style: { flexGrow: 3 },
@@ -33794,6 +33884,7 @@ This will work when developing locally but NOT when deployed to production.
33794
33884
  exports2.useScreenPlugin = useScreenPlugin;
33795
33885
  exports2.useTinaAuthRedirect = useTinaAuthRedirect;
33796
33886
  exports2.wrapFieldWithError = wrapFieldWithError;
33887
+ exports2.wrapFieldWithNoHeader = wrapFieldWithNoHeader;
33797
33888
  exports2.wrapFieldsWithMeta = wrapFieldsWithMeta;
33798
33889
  Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
33799
33890
  });
package/dist/index.mjs CHANGED
@@ -801,6 +801,22 @@ function wrapFieldsWithMeta(Field2) {
801
801
  );
802
802
  };
803
803
  }
804
+ function wrapFieldWithNoHeader(Field2) {
805
+ return (props) => {
806
+ return /* @__PURE__ */ React.createElement(
807
+ FieldMeta,
808
+ {
809
+ name: props.input.name,
810
+ label: false,
811
+ description: "",
812
+ error: props.meta.error,
813
+ index: props.index,
814
+ tinaForm: props.tinaForm
815
+ },
816
+ /* @__PURE__ */ React.createElement(Field2, { ...props })
817
+ );
818
+ };
819
+ }
804
820
  function wrapFieldWithError(Field2) {
805
821
  return (props) => {
806
822
  return /* @__PURE__ */ React.createElement(
@@ -873,6 +889,16 @@ const FieldDescription = ({
873
889
  className,
874
890
  ...props
875
891
  }) => {
892
+ if (typeof children === "string") {
893
+ return /* @__PURE__ */ React.createElement(
894
+ "span",
895
+ {
896
+ className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
897
+ ...props,
898
+ dangerouslySetInnerHTML: { __html: children }
899
+ }
900
+ );
901
+ }
876
902
  return /* @__PURE__ */ React.createElement(
877
903
  "span",
878
904
  {
@@ -5737,10 +5763,11 @@ const ItemDeleteButton = ({ onClick, disabled = false }) => {
5737
5763
  return /* @__PURE__ */ React__default.createElement(
5738
5764
  "button",
5739
5765
  {
5740
- className: `w-8 px-1 py-2.5 flex items-center justify-center hover:bg-gray-50 text-gray-200 hover:text-red-500 ${disabled && "pointer-events-none opacity-30 cursor-not-allowed"}`,
5766
+ type: "button",
5767
+ className: `w-8 px-1 py-2.5 flex items-center justify-center text-gray-200 hover:opacity-100 opacity-30 hover:bg-gray-50 ${disabled && "pointer-events-none opacity-30 cursor-not-allowed"}`,
5741
5768
  onClick
5742
5769
  },
5743
- /* @__PURE__ */ React__default.createElement(TrashIcon, { className: "fill-current transition-colors ease-out duration-100" })
5770
+ /* @__PURE__ */ React__default.createElement(TrashIcon, { className: "h-5 w-auto fill-current text-red-500 transition-colors duration-150 ease-out" })
5744
5771
  );
5745
5772
  };
5746
5773
  const DragHandle = ({ isDragging }) => {
@@ -5818,27 +5845,35 @@ const BlockSelector = ({
5818
5845
  ))))
5819
5846
  ))));
5820
5847
  };
5821
- const Group = wrapFieldWithError(({ tinaForm, field }) => {
5822
- const cms = useCMS$1();
5823
- React.useState(false);
5824
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
5825
- Header,
5826
- {
5827
- onClick: () => {
5828
- const state = tinaForm.finalForm.getState();
5829
- if (state.invalid === true) {
5830
- cms.alerts.error("Cannot navigate away from an invalid form.");
5831
- return;
5848
+ const Group = wrapFieldWithNoHeader(
5849
+ ({ tinaForm, field }) => {
5850
+ const cms = useCMS$1();
5851
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
5852
+ Header,
5853
+ {
5854
+ onClick: () => {
5855
+ const state = tinaForm.finalForm.getState();
5856
+ if (state.invalid === true) {
5857
+ cms.alerts.error("Cannot navigate away from an invalid form.");
5858
+ return;
5859
+ }
5860
+ cms.dispatch({
5861
+ type: "forms:set-active-field-name",
5862
+ value: { formId: tinaForm.id, fieldName: field.name }
5863
+ });
5832
5864
  }
5833
- cms.dispatch({
5834
- type: "forms:set-active-field-name",
5835
- value: { formId: tinaForm.id, fieldName: field.name }
5836
- });
5837
- }
5838
- },
5839
- field.label || field.name
5840
- ));
5841
- });
5865
+ },
5866
+ field.label || field.name,
5867
+ field.description && /* @__PURE__ */ React.createElement(
5868
+ "span",
5869
+ {
5870
+ className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0`,
5871
+ dangerouslySetInnerHTML: { __html: field.description }
5872
+ }
5873
+ )
5874
+ ));
5875
+ }
5876
+ );
5842
5877
  const Header = ({ onClick, children }) => {
5843
5878
  return /* @__PURE__ */ React.createElement("div", { className: "pt-1 mb-5" }, /* @__PURE__ */ React.createElement(
5844
5879
  "button",
@@ -10335,7 +10370,7 @@ const SyncStatus = ({ cms, setEventsOpen }) => {
10335
10370
  "Event Log"
10336
10371
  ));
10337
10372
  };
10338
- const version = "2.3.0";
10373
+ const version = "2.5.0";
10339
10374
  const Nav = ({
10340
10375
  isLocalMode,
10341
10376
  className = "",
@@ -14452,6 +14487,7 @@ function OverflowMenu({
14452
14487
  ToolbarButton,
14453
14488
  {
14454
14489
  showArrow: false,
14490
+ "data-testid": "rich-text-editor-overflow-menu-button",
14455
14491
  className: "lg:min-w-[130px]",
14456
14492
  isDropdown: true,
14457
14493
  pressed: openState.open,
@@ -14505,7 +14541,17 @@ const useRawMarkdownToolbarButton = () => {
14505
14541
  };
14506
14542
  const RawMarkdownToolbarButton = withRef(({ clear, ...rest }, ref) => {
14507
14543
  const { props } = useRawMarkdownToolbarButton();
14508
- return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.raw, null));
14544
+ return /* @__PURE__ */ React__default.createElement(
14545
+ ToolbarButton,
14546
+ {
14547
+ ref,
14548
+ tooltip: "Link",
14549
+ ...rest,
14550
+ ...props,
14551
+ "data-testid": "markdown-button"
14552
+ },
14553
+ /* @__PURE__ */ React__default.createElement(Icons.raw, null)
14554
+ );
14509
14555
  });
14510
14556
  function TableDropdownMenu(props) {
14511
14557
  const tableSelected = useEditorSelector(
@@ -30104,6 +30150,7 @@ class TinaAdminApi {
30104
30150
  relativePath
30105
30151
  filename
30106
30152
  extension
30153
+ hasReferences
30107
30154
  }
30108
30155
  }
30109
30156
  }
@@ -30195,6 +30242,9 @@ class TinaAdminApi {
30195
30242
  document(collection:$collection, relativePath:$relativePath) {
30196
30243
  ... on Document {
30197
30244
  _values
30245
+ _sys {
30246
+ hasReferences
30247
+ }
30198
30248
  }
30199
30249
  }
30200
30250
  }`;
@@ -31921,6 +31971,23 @@ const CollectionListPage = () => {
31921
31971
  DeleteModal,
31922
31972
  {
31923
31973
  filename: vars.relativePath,
31974
+ checkRefsFunc: async () => {
31975
+ var _a2, _b2;
31976
+ try {
31977
+ const doc = await admin.fetchDocument(
31978
+ collection.name,
31979
+ vars.relativePath,
31980
+ true
31981
+ );
31982
+ return (_b2 = (_a2 = doc == null ? void 0 : doc.document) == null ? void 0 : _a2._sys) == null ? void 0 : _b2.hasReferences;
31983
+ } catch (error) {
31984
+ cms.alerts.error(
31985
+ "Document was not found, ask a developer for help or check the console for an error message"
31986
+ );
31987
+ console.error(error);
31988
+ throw error;
31989
+ }
31990
+ },
31924
31991
  deleteFunc: async () => {
31925
31992
  try {
31926
31993
  await admin.deleteDocument(vars);
@@ -31929,6 +31996,12 @@ const CollectionListPage = () => {
31929
31996
  );
31930
31997
  reFetchCollection();
31931
31998
  } catch (error) {
31999
+ if (error.message.indexOf("has references")) {
32000
+ cms.alerts.error(
32001
+ error.message.split("\n ").filter(Boolean)[1]
32002
+ );
32003
+ return;
32004
+ }
31932
32005
  cms.alerts.warn(
31933
32006
  "Document was not deleted, ask a developer for help or check the console for an error message"
31934
32007
  );
@@ -31980,6 +32053,12 @@ const CollectionListPage = () => {
31980
32053
  cms.alerts.info("Document was successfully renamed");
31981
32054
  reFetchCollection();
31982
32055
  } catch (error) {
32056
+ if (error.message.indexOf("has references")) {
32057
+ cms.alerts.error(
32058
+ error.message.split("\n ").filter(Boolean)[1]
32059
+ );
32060
+ return;
32061
+ }
31983
32062
  cms.alerts.warn(
31984
32063
  "Document was not renamed, ask a developer for help or check the console for an error message"
31985
32064
  );
@@ -32453,8 +32532,19 @@ const Breadcrumb = ({ folder, navigate, collectionName }) => {
32453
32532
  const NoDocumentsPlaceholder = () => {
32454
32533
  return /* @__PURE__ */ React__default.createElement("div", { className: "text-center px-5 py-3 flex flex-col items-center justify-center shadow border border-gray-100 bg-gray-50 border-b border-gray-200 w-full max-w-full rounded-lg" }, /* @__PURE__ */ React__default.createElement("p", { className: "text-base italic font-medium text-gray-300" }, "No documents found."));
32455
32534
  };
32456
- const DeleteModal = ({ close: close2, deleteFunc, filename }) => {
32457
- return /* @__PURE__ */ React__default.createElement(Modal, null, /* @__PURE__ */ React__default.createElement(PopupModal, null, /* @__PURE__ */ React__default.createElement(ModalHeader, { close: close2 }, "Delete ", filename), /* @__PURE__ */ React__default.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React__default.createElement("p", null, `Are you sure you want to delete ${filename}?`)), /* @__PURE__ */ React__default.createElement(ModalActions, null, /* @__PURE__ */ React__default.createElement(Button$1, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React__default.createElement(
32535
+ const DeleteModal = ({
32536
+ close: close2,
32537
+ deleteFunc,
32538
+ checkRefsFunc,
32539
+ filename
32540
+ }) => {
32541
+ const [hasRefs, setHasRefs] = React__default.useState();
32542
+ useEffect(() => {
32543
+ checkRefsFunc().then((result) => {
32544
+ setHasRefs(result);
32545
+ });
32546
+ }, [filename, checkRefsFunc]);
32547
+ return /* @__PURE__ */ React__default.createElement(Modal, null, /* @__PURE__ */ React__default.createElement(PopupModal, null, /* @__PURE__ */ React__default.createElement(ModalHeader, { close: close2 }, "Delete ", filename), /* @__PURE__ */ React__default.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React__default.createElement("p", null, `Are you sure you want to delete ${filename}?${hasRefs ? " References to this document will also be deleted." : ""}`)), /* @__PURE__ */ React__default.createElement(ModalActions, null, /* @__PURE__ */ React__default.createElement(Button$1, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React__default.createElement(
32458
32548
  Button$1,
32459
32549
  {
32460
32550
  style: { flexGrow: 3 },
@@ -33816,5 +33906,6 @@ export {
33816
33906
  useScreenPlugin,
33817
33907
  useTinaAuthRedirect,
33818
33908
  wrapFieldWithError,
33909
+ wrapFieldWithNoHeader,
33819
33910
  wrapFieldsWithMeta
33820
33911
  };
@@ -1,18 +1,24 @@
1
- const makeCacheDir = async (dir, fs) => {
2
- const path = await import("./__vite-browser-external-d06ac358.mjs");
3
- const os = await import("./__vite-browser-external-d06ac358.mjs");
4
- const parts = dir.split(path.sep).filter(Boolean);
1
+ const makeCacheDir = async (dir, fs, path, os) => {
2
+ const pathParts = dir.split(path.sep).filter(Boolean);
3
+ const cacheHash = pathParts[pathParts.length - 1];
4
+ const rootUser = pathParts[0];
5
5
  let cacheDir = dir;
6
- if (!fs.existsSync(path.join(path.sep, parts[0]))) {
7
- cacheDir = path.join(os.tmpdir(), parts[parts.length - 1]);
6
+ if (!fs.existsSync(path.join(path.sep, rootUser))) {
7
+ cacheDir = path.join(os.tmpdir(), cacheHash);
8
+ }
9
+ try {
10
+ fs.mkdirSync(cacheDir, { recursive: true });
11
+ } catch (error) {
12
+ throw new Error(`Failed to create cache directory: ${error.message}`);
8
13
  }
9
- fs.mkdirSync(cacheDir, { recursive: true });
10
14
  return cacheDir;
11
15
  };
12
16
  const NodeCache = async (dir) => {
13
- const fs = await import("./__vite-browser-external-d06ac358.mjs");
14
- const { createHash } = await import("./__vite-browser-external-d06ac358.mjs");
15
- const cacheDir = await makeCacheDir(dir, fs);
17
+ const fs = require("node:fs");
18
+ const path = require("node:path");
19
+ const os = require("node:os");
20
+ const { createHash } = require("node:crypto");
21
+ const cacheDir = await makeCacheDir(dir, fs, path, os);
16
22
  return {
17
23
  makeKey: (key) => {
18
24
  const input = key && key instanceof Object ? JSON.stringify(key) : key || "";
@@ -39,5 +45,6 @@ const NodeCache = async (dir) => {
39
45
  };
40
46
  };
41
47
  export {
42
- NodeCache
48
+ NodeCache,
49
+ makeCacheDir
43
50
  };
@@ -3,6 +3,14 @@ import { FieldProps } from './field-props';
3
3
  import { Form } from '../../forms';
4
4
  export type InputFieldType<ExtraFieldProps, InputProps> = FieldProps<InputProps> & ExtraFieldProps;
5
5
  export declare function wrapFieldsWithMeta<ExtraFieldProps = {}, InputProps = {}>(Field: React.FunctionComponent<InputFieldType<ExtraFieldProps, InputProps>> | React.ComponentClass<InputFieldType<ExtraFieldProps, InputProps>>): (props: InputFieldType<ExtraFieldProps, InputProps>) => React.JSX.Element;
6
+ /**
7
+ * Same as wrapFieldsWithMeta but excludes the label, and description useful for fields that render their label and description
8
+ */
9
+ export declare function wrapFieldWithNoHeader<ExtraFieldProps = {}, InputProps = {}>(Field: React.FunctionComponent<InputFieldType<ExtraFieldProps, InputProps>> | React.ComponentClass<InputFieldType<ExtraFieldProps, InputProps>>): (props: InputFieldType<ExtraFieldProps, InputProps>) => React.JSX.Element;
10
+ /**
11
+ * Same as above but excludes the label, useful for fields that have their own label
12
+ * @deprecated This function is deprecated and will be removed in future versions.
13
+ */
6
14
  export declare function wrapFieldWithError<ExtraFieldProps = {}, InputProps = {}>(Field: React.FunctionComponent<InputFieldType<ExtraFieldProps, InputProps>> | React.ComponentClass<InputFieldType<ExtraFieldProps, InputProps>>): (props: InputFieldType<ExtraFieldProps, InputProps>) => React.JSX.Element;
7
15
  interface FieldMetaProps extends React.HTMLAttributes<HTMLElement> {
8
16
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinacms",
3
- "version": "0.0.0-bbf2f81-20241024004604",
3
+ "version": "0.0.0-bbfd415-20241202040226",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "exports": {
@@ -60,21 +60,21 @@
60
60
  "typings": "dist/index.d.ts",
61
61
  "license": "Apache-2.0",
62
62
  "dependencies": {
63
- "@ariakit/react": "^0.4.11",
64
- "@floating-ui/dom": "^1.6.11",
63
+ "@ariakit/react": "^0.4.13",
64
+ "@floating-ui/dom": "^1.6.12",
65
65
  "@floating-ui/react-dom": "^2.1.2",
66
- "@graphql-inspector/core": "^6.1.0",
66
+ "@graphql-inspector/core": "^6.2.0",
67
67
  "@headlessui/react": "2.1.8",
68
68
  "@heroicons/react": "^1.0.6",
69
69
  "@monaco-editor/react": "4.4.5",
70
- "@radix-ui/react-checkbox": "^1.1.1",
71
- "@radix-ui/react-dialog": "^1.1.1",
72
- "@radix-ui/react-dropdown-menu": "^2.1.1",
73
- "@radix-ui/react-popover": "^1.1.1",
70
+ "@radix-ui/react-checkbox": "^1.1.2",
71
+ "@radix-ui/react-dialog": "^1.1.2",
72
+ "@radix-ui/react-dropdown-menu": "^2.1.2",
73
+ "@radix-ui/react-popover": "^1.1.2",
74
74
  "@radix-ui/react-separator": "^1.1.0",
75
75
  "@radix-ui/react-slot": "^1.1.0",
76
76
  "@radix-ui/react-toolbar": "^1.1.0",
77
- "@radix-ui/react-tooltip": "^1.1.2",
77
+ "@radix-ui/react-tooltip": "^1.1.4",
78
78
  "@react-hook/window-size": "^3.1.1",
79
79
  "@udecode/cn": "^33.0.0",
80
80
  "@udecode/plate": "^36.5.9",
@@ -94,7 +94,7 @@
94
94
  "@udecode/plate-table": "36.5.8",
95
95
  "class-variance-authority": "^0.7.0",
96
96
  "clsx": "^2.1.1",
97
- "cmdk": "^1.0.0",
97
+ "cmdk": "^1.0.4",
98
98
  "color-string": "^1.9.1",
99
99
  "crypto-js": "^4.2.0",
100
100
  "date-fns": "2.30.0",
@@ -125,18 +125,18 @@
125
125
  "slate-history": "^0.100.0",
126
126
  "slate-hyperscript": "^0.100.0",
127
127
  "slate-react": "^0.107.1",
128
- "tailwind-merge": "^2.5.2",
128
+ "tailwind-merge": "^2.5.4",
129
129
  "webfontloader": "1.6.28",
130
130
  "yup": "^1.4.0",
131
131
  "zod": "^3.23.8",
132
- "@tinacms/mdx": "1.5.0",
133
- "@tinacms/schema-tools": "1.6.6",
134
- "@tinacms/search": "1.0.33"
132
+ "@tinacms/mdx": "1.5.2",
133
+ "@tinacms/search": "1.0.35",
134
+ "@tinacms/schema-tools": "1.6.8"
135
135
  },
136
136
  "devDependencies": {
137
- "@graphql-tools/utils": "^10.5.4",
137
+ "@graphql-tools/utils": "^10.5.6",
138
138
  "@testing-library/dom": "^10.4.0",
139
- "@testing-library/jest-dom": "^6.5.0",
139
+ "@testing-library/jest-dom": "^6.6.3",
140
140
  "@testing-library/react": "^16.0.1",
141
141
  "@testing-library/user-event": "^14.5.2",
142
142
  "@types/atob": "^2.1.4",
@@ -144,14 +144,14 @@
144
144
  "@types/color-string": "^1.5.5",
145
145
  "@types/lodash.debounce": "^4.0.9",
146
146
  "@types/lodash.get": "^4.4.9",
147
- "@types/node": "^22.7.4",
147
+ "@types/node": "^22.9.0",
148
148
  "@types/prop-types": "^15.7.13",
149
- "@types/react": "^18.3.10",
149
+ "@types/react": "^18.3.12",
150
150
  "@types/react-beautiful-dnd": "^13.1.8",
151
151
  "@types/react-color": "^3.0.12",
152
- "@types/react-dom": "^18.3.0",
152
+ "@types/react-dom": "^18.3.1",
153
153
  "@types/yup": "^0.32.0",
154
- "happy-dom": "^14.12.3",
154
+ "happy-dom": "15.10.2",
155
155
  "identity-obj-proxy": "^3.0.0",
156
156
  "isomorphic-fetch": "^3.0.0",
157
157
  "jest-file-snapshot": "^0.7.0",
@@ -160,11 +160,11 @@
160
160
  "react-dom": "^18.3.1",
161
161
  "react-is": "^18.3.1",
162
162
  "tsc-alias": "^1.8.10",
163
- "tslib": "^2.7.0",
164
- "typescript": "^5.6.2",
165
- "vite": "^5.4.8",
166
- "vitest": "^2.1.1",
167
- "@tinacms/scripts": "1.3.0"
163
+ "tslib": "^2.8.1",
164
+ "typescript": "^5.6.3",
165
+ "vite": "^5.4.11",
166
+ "vitest": "^2.1.5",
167
+ "@tinacms/scripts": "1.3.1"
168
168
  },
169
169
  "peerDependencies": {
170
170
  "react": ">=16.14.0",
@@ -1,4 +0,0 @@
1
- const __viteBrowserExternal = {};
2
- export {
3
- __viteBrowserExternal as default
4
- };