tinacms 1.5.12 → 1.5.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,36 +2,31 @@
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("zod"), require("@tinacms/toolkit"), require("graphql"), require("graphql-tag"), require("@tinacms/schema-tools"), require("react"), require("yup"), require("@tinacms/sharedctx"), require("@graphql-inspector/core"), require("react-router-dom"), require("@headlessui/react"), require("@react-hook/window-size")) : typeof define === "function" && define.amd ? define(["exports", "zod", "@tinacms/toolkit", "graphql", "graphql-tag", "@tinacms/schema-tools", "react", "yup", "@tinacms/sharedctx", "@graphql-inspector/core", "react-router-dom", "@headlessui/react", "@react-hook/window-size"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
3
3
  })(this, function(exports2, zod, toolkit, graphql, gql$1, schemaTools, React, yup, sharedctx, core, reactRouterDom, react, windowSize) {
4
4
  "use strict";
5
- function _interopDefaultLegacy(e) {
6
- return e && typeof e === "object" && "default" in e ? e : { "default": e };
7
- }
8
- function _interopNamespace(e) {
9
- if (e && e.__esModule)
10
- return e;
11
- var n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
5
+ function _interopNamespaceDefault(e) {
6
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
12
7
  if (e) {
13
- Object.keys(e).forEach(function(k) {
8
+ for (const k in e) {
14
9
  if (k !== "default") {
15
- var d = Object.getOwnPropertyDescriptor(e, k);
10
+ const d = Object.getOwnPropertyDescriptor(e, k);
16
11
  Object.defineProperty(n, k, d.get ? d : {
17
12
  enumerable: true,
18
- get: function() {
19
- return e[k];
20
- }
13
+ get: () => e[k]
21
14
  });
22
15
  }
23
- });
16
+ }
24
17
  }
25
- n["default"] = e;
18
+ n.default = e;
26
19
  return Object.freeze(n);
27
20
  }
28
- var gql__default = /* @__PURE__ */ _interopDefaultLegacy(gql$1);
29
- var React__default = /* @__PURE__ */ _interopDefaultLegacy(React);
30
- var yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
21
+ const yup__namespace = /* @__PURE__ */ _interopNamespaceDefault(yup);
31
22
  function popupWindow(url, title, window2, w, h) {
32
23
  const y = window2.top.outerHeight / 2 + window2.top.screenY - h / 2;
33
24
  const x = window2.top.outerWidth / 2 + window2.top.screenX - w / 2;
34
- return window2.open(url, title, "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=" + w + ", height=" + h + ", top=" + y + ", left=" + x);
25
+ return window2.open(
26
+ url,
27
+ title,
28
+ "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=" + w + ", height=" + h + ", top=" + y + ", left=" + x
29
+ );
35
30
  }
36
31
  const TINA_LOGIN_EVENT = "tinaCloudLogin";
37
32
  const AUTH_TOKEN_KEY = "tinacms-auth";
@@ -51,7 +46,13 @@
51
46
  }
52
47
  });
53
48
  const origin = `${window.location.protocol}//${window.location.host}`;
54
- authTab = popupWindow(`${frontendUrl}/signin?clientId=${clientId}&origin=${origin}`, "_blank", window, 1e3, 700);
49
+ authTab = popupWindow(
50
+ `${frontendUrl}/signin?clientId=${clientId}&origin=${origin}`,
51
+ "_blank",
52
+ window,
53
+ 1e3,
54
+ 700
55
+ );
55
56
  });
56
57
  };
57
58
  class StringBuilder {
@@ -87,7 +88,10 @@
87
88
  }
88
89
  }
89
90
  }
90
- (_b = (_a = data.children) == null ? void 0 : _a.forEach) == null ? void 0 : _b.call(_a, (child) => extractText(child, acc, indexableNodeTypes));
91
+ (_b = (_a = data.children) == null ? void 0 : _a.forEach) == null ? void 0 : _b.call(
92
+ _a,
93
+ (child) => extractText(child, acc, indexableNodeTypes)
94
+ );
91
95
  }
92
96
  };
93
97
  const relativePath = (path, collection) => {
@@ -121,16 +125,35 @@
121
125
  if (data[f.name]) {
122
126
  if (f.type === "object") {
123
127
  if (isList) {
124
- data[f.name] = data[f.name].map((obj) => processDocumentForIndexing(obj, path, collection, textIndexLength, f));
128
+ data[f.name] = data[f.name].map(
129
+ (obj) => processDocumentForIndexing(
130
+ obj,
131
+ path,
132
+ collection,
133
+ textIndexLength,
134
+ f
135
+ )
136
+ );
125
137
  } else {
126
- data[f.name] = processDocumentForIndexing(data[f.name], path, collection, textIndexLength, f);
138
+ data[f.name] = processDocumentForIndexing(
139
+ data[f.name],
140
+ path,
141
+ collection,
142
+ textIndexLength,
143
+ f
144
+ );
127
145
  }
128
146
  } else if (f.type === "string") {
129
147
  const fieldTextIndexLength = f.maxSearchIndexFieldLength || textIndexLength;
130
148
  if (isList) {
131
- data[f.name] = data[f.name].map((value) => processTextFieldValue(value, fieldTextIndexLength));
149
+ data[f.name] = data[f.name].map(
150
+ (value) => processTextFieldValue(value, fieldTextIndexLength)
151
+ );
132
152
  } else {
133
- data[f.name] = processTextFieldValue(data[f.name], fieldTextIndexLength);
153
+ data[f.name] = processTextFieldValue(
154
+ data[f.name],
155
+ fieldTextIndexLength
156
+ );
134
157
  }
135
158
  } else if (f.type === "rich-text") {
136
159
  const fieldTextIndexLength = f.maxSearchIndexFieldLength || textIndexLength;
@@ -220,14 +243,14 @@
220
243
  timestamp: zod.z.number().optional()
221
244
  });
222
245
  function asyncPoll(fn, pollInterval = 5 * 1e3, pollTimeout = 30 * 1e3) {
223
- const endTime = new Date().getTime() + pollTimeout;
246
+ const endTime = (/* @__PURE__ */ new Date()).getTime() + pollTimeout;
224
247
  let stop = false;
225
248
  const cancel = () => {
226
249
  stop = true;
227
250
  };
228
251
  const checkCondition = (resolve, reject) => {
229
252
  Promise.resolve(fn()).then((result) => {
230
- const now = new Date().getTime();
253
+ const now = (/* @__PURE__ */ new Date()).getTime();
231
254
  if (stop) {
232
255
  reject(new Error("AsyncPoller: cancelled"));
233
256
  } else if (result.done) {
@@ -288,11 +311,14 @@ mutation addPendingDocumentMutation(
288
311
  return this.gqlSchema;
289
312
  };
290
313
  this.getOptimizedQuery = async (documentNode) => {
291
- const data = await this.request(`query GetOptimizedQuery($queryString: String!) {
314
+ const data = await this.request(
315
+ `query GetOptimizedQuery($queryString: String!) {
292
316
  getOptimizedQuery(queryString: $queryString)
293
- }`, {
294
- variables: { queryString: graphql.print(documentNode) }
295
- });
317
+ }`,
318
+ {
319
+ variables: { queryString: graphql.print(documentNode) }
320
+ }
321
+ );
296
322
  return graphql.parse(data.getOptimizedQuery);
297
323
  };
298
324
  this.tinaGraphQLVersion = options.tinaGraphQLVersion;
@@ -320,9 +346,12 @@ mutation addPendingDocumentMutation(
320
346
  this.options.customContentApiUrl = options.schema.config.contentApiUrlOverride;
321
347
  }
322
348
  this.setBranch(options.branch);
323
- this.events.subscribe("branch:change", ({ branchName }) => {
324
- this.setBranch(branchName);
325
- });
349
+ this.events.subscribe(
350
+ "branch:change",
351
+ ({ branchName }) => {
352
+ this.setBranch(branchName);
353
+ }
354
+ );
326
355
  this.clientId = options.clientId;
327
356
  switch (tokenStorage) {
328
357
  case "LOCAL_STORAGE":
@@ -360,7 +389,9 @@ mutation addPendingDocumentMutation(
360
389
  break;
361
390
  case "CUSTOM":
362
391
  if (!options.getTokenFn) {
363
- throw new Error("When CUSTOM token storage is selected, a getTokenFn must be provided");
392
+ throw new Error(
393
+ "When CUSTOM token storage is selected, a getTokenFn must be provided"
394
+ );
364
395
  }
365
396
  this.getToken = options.getTokenFn;
366
397
  break;
@@ -372,6 +403,9 @@ mutation addPendingDocumentMutation(
372
403
  get isLocalMode() {
373
404
  return false;
374
405
  }
406
+ get isCustomContentApi() {
407
+ return !!this.options.customContentApiUrl;
408
+ }
375
409
  setBranch(branchName) {
376
410
  var _a, _b, _c, _d;
377
411
  const encodedBranch = encodeURIComponent(branchName);
@@ -397,7 +431,7 @@ mutation addPendingDocumentMutation(
397
431
  method: "POST",
398
432
  headers,
399
433
  body: JSON.stringify({
400
- query: typeof query === "function" ? graphql.print(query(gql__default["default"])) : query,
434
+ query: typeof query === "function" ? graphql.print(query(gql$1)) : query,
401
435
  variables
402
436
  })
403
437
  });
@@ -418,8 +452,10 @@ mutation addPendingDocumentMutation(
418
452
  }
419
453
  const json = await res.json();
420
454
  if (json.errors) {
421
- throw new Error(`Unable to fetch, errors:
422
- ${json.errors.map((error) => error.message).join("\n")}`);
455
+ throw new Error(
456
+ `Unable to fetch, errors:
457
+ ${json.errors.map((error) => error.message).join("\n")}`
458
+ );
423
459
  }
424
460
  return json.data;
425
461
  }
@@ -429,20 +465,26 @@ mutation addPendingDocumentMutation(
429
465
  async checkSyncStatus({
430
466
  assetsSyncing
431
467
  }) {
432
- const res = await this.fetchWithToken(`${this.assetsApiUrl}/v1/${this.clientId}/syncStatus`, {
433
- method: "POST",
434
- headers: {
435
- "Content-Type": "application/json"
436
- },
437
- body: JSON.stringify({ assetsSyncing })
438
- });
468
+ const res = await this.fetchWithToken(
469
+ `${this.assetsApiUrl}/v1/${this.clientId}/syncStatus`,
470
+ {
471
+ method: "POST",
472
+ headers: {
473
+ "Content-Type": "application/json"
474
+ },
475
+ body: JSON.stringify({ assetsSyncing })
476
+ }
477
+ );
439
478
  const jsonRes = await res.json();
440
479
  return jsonRes;
441
480
  }
442
481
  async getProject() {
443
- const res = await this.fetchWithToken(`${this.identityApiUrl}/v2/apps/${this.clientId}`, {
444
- method: "GET"
445
- });
482
+ const res = await this.fetchWithToken(
483
+ `${this.identityApiUrl}/v2/apps/${this.clientId}`,
484
+ {
485
+ method: "GET"
486
+ }
487
+ );
446
488
  const val = await res.json();
447
489
  return val;
448
490
  }
@@ -465,7 +507,9 @@ mutation addPendingDocumentMutation(
465
507
  }
466
508
  });
467
509
  if (!res.ok) {
468
- throw new Error(`There was an error creating a new branch. ${res.statusText}`);
510
+ throw new Error(
511
+ `There was an error creating a new branch. ${res.statusText}`
512
+ );
469
513
  }
470
514
  const values = await res.json();
471
515
  return values;
@@ -480,15 +524,20 @@ mutation addPendingDocumentMutation(
480
524
  events: []
481
525
  };
482
526
  } else {
483
- return (await this.fetchWithToken(`${this.contentApiBase}/events/${this.clientId}/${this.branch}?limit=${limit || 1}${cursor ? `&cursor=${cursor}` : ""}`, { method: "GET" })).json();
527
+ return (await this.fetchWithToken(
528
+ `${this.contentApiBase}/events/${this.clientId}/${this.branch}?limit=${limit || 1}${cursor ? `&cursor=${cursor}` : ""}`,
529
+ { method: "GET" }
530
+ )).json();
484
531
  }
485
532
  }
486
533
  parseJwt(token) {
487
534
  const base64Url = token.split(".")[1];
488
535
  const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
489
- const jsonPayload = decodeURIComponent(atob(base64).split("").map(function(c) {
490
- return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
491
- }).join(""));
536
+ const jsonPayload = decodeURIComponent(
537
+ atob(base64).split("").map(function(c) {
538
+ return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
539
+ }).join("")
540
+ );
492
541
  return JSON.parse(jsonPayload);
493
542
  }
494
543
  async getRefreshedToken(tokens) {
@@ -538,6 +587,15 @@ mutation addPendingDocumentMutation(
538
587
  this.setToken(token);
539
588
  return token;
540
589
  }
590
+ /**
591
+ * Wraps the normal fetch function with same API but adds the authorization header token.
592
+ *
593
+ * @example
594
+ * const test = await tinaCloudClient.fetchWithToken(`/mycustomAPI/thing/one`) // the token will be passed in the authorization header
595
+ *
596
+ * @param input fetch function input
597
+ * @param init fetch function init
598
+ */
541
599
  async fetchWithToken(input, init) {
542
600
  const headers = (init == null ? void 0 : init.headers) || {};
543
601
  const token = await this.getToken();
@@ -596,29 +654,39 @@ mutation addPendingDocumentMutation(
596
654
  waitForIndexStatus({ ref }) {
597
655
  let unknownCount = 0;
598
656
  try {
599
- const [prom, cancel] = asyncPoll(async () => {
600
- try {
601
- const result = await this.getIndexStatus({ ref });
602
- if (!(result.status === "inprogress" || result.status === "unknown")) {
603
- return Promise.resolve({
604
- done: true,
605
- data: result
606
- });
607
- } else {
608
- if (result.status === "unknown") {
609
- unknownCount++;
610
- if (unknownCount > 5) {
611
- throw new Error("AsyncPoller: status unknown for too long, please check indexing progress the Tina Cloud dashboard");
657
+ const [prom, cancel] = asyncPoll(
658
+ async () => {
659
+ try {
660
+ const result = await this.getIndexStatus({ ref });
661
+ if (!(result.status === "inprogress" || result.status === "unknown")) {
662
+ return Promise.resolve({
663
+ done: true,
664
+ data: result
665
+ });
666
+ } else {
667
+ if (result.status === "unknown") {
668
+ unknownCount++;
669
+ if (unknownCount > 5) {
670
+ throw new Error(
671
+ "AsyncPoller: status unknown for too long, please check indexing progress the Tina Cloud dashboard"
672
+ );
673
+ }
612
674
  }
675
+ return Promise.resolve({
676
+ done: false
677
+ });
613
678
  }
614
- return Promise.resolve({
615
- done: false
616
- });
679
+ } catch (err) {
680
+ return Promise.reject(err);
617
681
  }
618
- } catch (err) {
619
- return Promise.reject(err);
620
- }
621
- }, 5e3, 9e5);
682
+ },
683
+ // interval is 5s
684
+ 5e3,
685
+ // interval
686
+ // timeout is 15 min
687
+ 9e5
688
+ // timeout
689
+ );
622
690
  return [prom, cancel];
623
691
  } catch (error) {
624
692
  if (error.message === "AsyncPoller: reached timeout") {
@@ -708,6 +776,7 @@ mutation addPendingDocumentMutation(
708
776
  get isLocalMode() {
709
777
  return true;
710
778
  }
779
+ // These functions allow the local client to have a login state so that we can correctly call the "OnLogin" callback. This is important for things like preview mode
711
780
  async logout() {
712
781
  localStorage.removeItem(LOCAL_CLIENT_KEY);
713
782
  }
@@ -727,25 +796,33 @@ mutation addPendingDocumentMutation(
727
796
  const q = queryToSearchIndexQuery(query);
728
797
  const opt = optionsToSearchIndexOptions(options);
729
798
  const optionsParam = opt["PAGE"] ? `&options=${JSON.stringify(opt)}` : "";
730
- const res = await this.client.fetchWithToken(`${this.client.contentApiBase}/searchIndex/${this.client.clientId}/${this.client.getBranch()}?q=${JSON.stringify(q)}${optionsParam}`);
799
+ const res = await this.client.fetchWithToken(
800
+ `${this.client.contentApiBase}/searchIndex/${this.client.clientId}/${this.client.getBranch()}?q=${JSON.stringify(q)}${optionsParam}`
801
+ );
731
802
  return parseSearchIndexResponse(await res.json(), options);
732
803
  }
733
804
  async del(ids) {
734
- const res = await this.client.fetchWithToken(`${this.client.contentApiBase}/searchIndex/${this.client.clientId}/${this.client.getBranch()}?ids=${ids.join(",")}`, {
735
- method: "DELETE"
736
- });
805
+ const res = await this.client.fetchWithToken(
806
+ `${this.client.contentApiBase}/searchIndex/${this.client.clientId}/${this.client.getBranch()}?ids=${ids.join(",")}`,
807
+ {
808
+ method: "DELETE"
809
+ }
810
+ );
737
811
  if (res.status !== 200) {
738
812
  throw new Error("Failed to update search index");
739
813
  }
740
814
  }
741
815
  async put(docs) {
742
- const res = await this.client.fetchWithToken(`${this.client.contentApiBase}/searchIndex/${this.client.clientId}/${this.client.getBranch()}`, {
743
- method: "POST",
744
- body: JSON.stringify({ docs }),
745
- headers: {
746
- "Content-Type": "application/json"
816
+ const res = await this.client.fetchWithToken(
817
+ `${this.client.contentApiBase}/searchIndex/${this.client.clientId}/${this.client.getBranch()}`,
818
+ {
819
+ method: "POST",
820
+ body: JSON.stringify({ docs }),
821
+ headers: {
822
+ "Content-Type": "application/json"
823
+ }
747
824
  }
748
- });
825
+ );
749
826
  if (res.status !== 200) {
750
827
  throw new Error("Failed to update search index");
751
828
  }
@@ -762,7 +839,9 @@ mutation addPendingDocumentMutation(
762
839
  const q = queryToSearchIndexQuery(query);
763
840
  const opt = optionsToSearchIndexOptions(options);
764
841
  const optionsParam = opt["PAGE"] ? `&options=${JSON.stringify(opt)}` : "";
765
- const res = await this.client.fetchWithToken(`http://localhost:4001/searchIndex?q=${JSON.stringify(q)}${optionsParam}`);
842
+ const res = await this.client.fetchWithToken(
843
+ `http://localhost:4001/searchIndex?q=${JSON.stringify(q)}${optionsParam}`
844
+ );
766
845
  return parseSearchIndexResponse(await res.json(), options);
767
846
  }
768
847
  del(ids) {
@@ -776,17 +855,9 @@ mutation addPendingDocumentMutation(
776
855
  }
777
856
  }
778
857
  function ModalBuilder(modalProps) {
779
- return /* @__PURE__ */ React__default["default"].createElement(toolkit.Modal, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalPopup, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalHeader, null, modalProps.title), /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalBody, {
780
- padded: true
781
- }, /* @__PURE__ */ React__default["default"].createElement("p", null, modalProps.message), modalProps.error && /* @__PURE__ */ React__default["default"].createElement(ErrorLabel, null, modalProps.error)), /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalActions, null, modalProps.actions.map((action) => /* @__PURE__ */ React__default["default"].createElement(AsyncButton, {
782
- key: action.name,
783
- ...action
784
- })))));
858
+ return /* @__PURE__ */ React.createElement(toolkit.Modal, null, /* @__PURE__ */ React.createElement(toolkit.ModalPopup, null, /* @__PURE__ */ React.createElement(toolkit.ModalHeader, null, modalProps.title), /* @__PURE__ */ React.createElement(toolkit.ModalBody, { padded: true }, /* @__PURE__ */ React.createElement("p", null, modalProps.message), modalProps.error && /* @__PURE__ */ React.createElement(ErrorLabel, null, modalProps.error)), /* @__PURE__ */ React.createElement(toolkit.ModalActions, null, modalProps.actions.map((action) => /* @__PURE__ */ React.createElement(AsyncButton, { key: action.name, ...action })))));
785
859
  }
786
- const ErrorLabel = ({ style = {}, ...props }) => /* @__PURE__ */ React__default["default"].createElement("p", {
787
- style: { ...style, color: "var(--tina-color-error)" },
788
- ...props
789
- });
860
+ const ErrorLabel = ({ style = {}, ...props }) => /* @__PURE__ */ React.createElement("p", { style: { ...style, color: "var(--tina-color-error)" }, ...props });
790
861
  const AsyncButton = ({ name, primary, action }) => {
791
862
  const [submitting, setSubmitting] = React.useState(false);
792
863
  const onClick = React.useCallback(async () => {
@@ -799,13 +870,18 @@ mutation addPendingDocumentMutation(
799
870
  throw e;
800
871
  }
801
872
  }, [action, setSubmitting]);
802
- return /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
803
- "data-test": name.replace(/\s/g, "-").toLowerCase(),
804
- variant: primary ? "primary" : "secondary",
805
- onClick,
806
- busy: submitting,
807
- disabled: submitting
808
- }, submitting && /* @__PURE__ */ React__default["default"].createElement(toolkit.LoadingDots, null), !submitting && name);
873
+ return /* @__PURE__ */ React.createElement(
874
+ toolkit.Button,
875
+ {
876
+ "data-test": name.replace(/\s/g, "-").toLowerCase(),
877
+ variant: primary ? "primary" : "secondary",
878
+ onClick,
879
+ busy: submitting,
880
+ disabled: submitting
881
+ },
882
+ submitting && /* @__PURE__ */ React.createElement(toolkit.LoadingDots, null),
883
+ !submitting && name
884
+ );
809
885
  };
810
886
  const TINA_AUTH_CONFIG = "tina_auth_config";
811
887
  const useTinaAuthRedirect = () => {
@@ -886,16 +962,27 @@ mutation addPendingDocumentMutation(
886
962
  return this.schema.getCollections();
887
963
  }
888
964
  async renameDocument({ collection, relativePath: relativePath2, newRelativePath }) {
889
- await this.api.request(`#graphql
965
+ await this.api.request(
966
+ `#graphql
890
967
  mutation RenameDocument($collection: String!, $relativePath: String! $newRelativePath: String!) {
891
968
  updateDocument(collection: $collection, relativePath: $relativePath, params: {relativePath: $newRelativePath}){
892
969
  __typename
893
970
  }
894
971
  }
895
- `, { variables: { collection, relativePath: relativePath2, newRelativePath } });
972
+ `,
973
+ { variables: { collection, relativePath: relativePath2, newRelativePath } }
974
+ );
896
975
  if (this.searchClient) {
897
- const { document: doc } = await this.fetchDocument(collection.name, newRelativePath);
898
- const processed = processDocumentForIndexing(doc["_values"], `${collection.path}/${newRelativePath}`, collection, this.maxSearchIndexFieldLength);
976
+ const { document: doc } = await this.fetchDocument(
977
+ collection.name,
978
+ newRelativePath
979
+ );
980
+ const processed = processDocumentForIndexing(
981
+ doc["_values"],
982
+ `${collection.path}/${newRelativePath}`,
983
+ collection,
984
+ this.maxSearchIndexFieldLength
985
+ );
899
986
  await this.searchClient.put([processed]);
900
987
  await this.searchClient.del([`${collection.name}:${relativePath2}`]);
901
988
  }
@@ -905,12 +992,15 @@ mutation addPendingDocumentMutation(
905
992
  relativePath: relativePath2
906
993
  }) {
907
994
  var _a;
908
- await this.api.request(`#graphql
995
+ await this.api.request(
996
+ `#graphql
909
997
  mutation DeleteDocument($collection: String!, $relativePath: String! ){
910
998
  deleteDocument(collection: $collection, relativePath: $relativePath){
911
999
  __typename
912
1000
  }
913
- }`, { variables: { collection, relativePath: relativePath2 } });
1001
+ }`,
1002
+ { variables: { collection, relativePath: relativePath2 } }
1003
+ );
914
1004
  await ((_a = this.searchClient) == null ? void 0 : _a.del([`${collection}:${relativePath2}`]));
915
1005
  }
916
1006
  async fetchCollection(collectionName, includeDocuments, folder = "", after, sortKey, order, filterArgs) {
@@ -949,7 +1039,8 @@ mutation addPendingDocumentMutation(
949
1039
  }
950
1040
  if (includeDocuments === true) {
951
1041
  const sort = sortKey || this.schema.getIsTitleFieldName(collectionName);
952
- const response = order === "asc" ? await this.api.request(`#graphql
1042
+ const response = order === "asc" ? await this.api.request(
1043
+ `#graphql
953
1044
  query($collection: String!, $includeDocuments: Boolean!, $sort: String, $limit: Float, $after: String, $filter: DocumentFilter, $folder: String){
954
1045
  collection(collection: $collection){
955
1046
  name
@@ -987,17 +1078,20 @@ mutation addPendingDocumentMutation(
987
1078
  }
988
1079
  }
989
1080
  }
990
- }`, {
991
- variables: {
992
- collection: collectionName,
993
- includeDocuments,
994
- folder,
995
- sort,
996
- limit: 50,
997
- after,
998
- filter
1081
+ }`,
1082
+ {
1083
+ variables: {
1084
+ collection: collectionName,
1085
+ includeDocuments,
1086
+ folder,
1087
+ sort,
1088
+ limit: 50,
1089
+ after,
1090
+ filter
1091
+ }
999
1092
  }
1000
- }) : await this.api.request(`#graphql
1093
+ ) : await this.api.request(
1094
+ `#graphql
1001
1095
  query($collection: String!, $includeDocuments: Boolean!, $sort: String, $limit: Float, $after: String, $filter: DocumentFilter, $folder: String) {
1002
1096
  collection(collection: $collection){
1003
1097
  name
@@ -1035,24 +1129,28 @@ mutation addPendingDocumentMutation(
1035
1129
  }
1036
1130
  }
1037
1131
  }
1038
- }`, {
1039
- variables: {
1040
- collection: collectionName,
1041
- includeDocuments,
1042
- folder,
1043
- sort,
1044
- limit: 50,
1045
- after,
1046
- filter
1132
+ }`,
1133
+ {
1134
+ variables: {
1135
+ collection: collectionName,
1136
+ includeDocuments,
1137
+ folder,
1138
+ sort,
1139
+ limit: 50,
1140
+ after,
1141
+ filter
1142
+ }
1047
1143
  }
1048
- });
1144
+ );
1049
1145
  return response.collection;
1050
1146
  } else {
1051
1147
  try {
1052
1148
  const collection = this.schema.getCollection(collectionName);
1053
1149
  return collection;
1054
1150
  } catch (e) {
1055
- console.error(`[TinaAdminAPI] Unable to fetchCollection(): ${e.message}`);
1151
+ console.error(
1152
+ `[TinaAdminAPI] Unable to fetchCollection(): ${e.message}`
1153
+ );
1056
1154
  return void 0;
1057
1155
  }
1058
1156
  }
@@ -1094,45 +1192,67 @@ mutation addPendingDocumentMutation(
1094
1192
  return response;
1095
1193
  }
1096
1194
  async createDocument(collection, relativePath2, params) {
1097
- const response = await this.api.request(`#graphql
1195
+ const response = await this.api.request(
1196
+ `#graphql
1098
1197
  mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
1099
1198
  createDocument(
1100
1199
  collection: $collection,
1101
1200
  relativePath: $relativePath,
1102
1201
  params: $params
1103
1202
  ){__typename}
1104
- }`, {
1105
- variables: {
1106
- collection: collection.name,
1107
- relativePath: relativePath2,
1108
- params
1203
+ }`,
1204
+ {
1205
+ variables: {
1206
+ collection: collection.name,
1207
+ relativePath: relativePath2,
1208
+ params
1209
+ }
1109
1210
  }
1110
- });
1211
+ );
1111
1212
  if (this.searchClient) {
1112
- const { document: doc } = await this.fetchDocument(collection.name, relativePath2);
1113
- const processed = processDocumentForIndexing(doc["_values"], `${collection.path}/${relativePath2}`, collection, this.maxSearchIndexFieldLength);
1213
+ const { document: doc } = await this.fetchDocument(
1214
+ collection.name,
1215
+ relativePath2
1216
+ );
1217
+ const processed = processDocumentForIndexing(
1218
+ doc["_values"],
1219
+ `${collection.path}/${relativePath2}`,
1220
+ collection,
1221
+ this.maxSearchIndexFieldLength
1222
+ );
1114
1223
  await this.searchClient.put([processed]);
1115
1224
  }
1116
1225
  return response;
1117
1226
  }
1118
1227
  async updateDocument(collection, relativePath2, params) {
1119
- const response = await this.api.request(`#graphql
1228
+ const response = await this.api.request(
1229
+ `#graphql
1120
1230
  mutation($collection: String!, $relativePath: String!, $params: DocumentUpdateMutation!) {
1121
1231
  updateDocument(
1122
1232
  collection: $collection,
1123
1233
  relativePath: $relativePath,
1124
1234
  params: $params
1125
1235
  ){__typename}
1126
- }`, {
1127
- variables: {
1128
- collection: collection.name,
1129
- relativePath: relativePath2,
1130
- params
1236
+ }`,
1237
+ {
1238
+ variables: {
1239
+ collection: collection.name,
1240
+ relativePath: relativePath2,
1241
+ params
1242
+ }
1131
1243
  }
1132
- });
1244
+ );
1133
1245
  if (this.searchClient) {
1134
- const { document: doc } = await this.fetchDocument(collection.name, relativePath2);
1135
- const processed = processDocumentForIndexing(doc["_values"], `${collection.path}/${relativePath2}`, collection, this.maxSearchIndexFieldLength);
1246
+ const { document: doc } = await this.fetchDocument(
1247
+ collection.name,
1248
+ relativePath2
1249
+ );
1250
+ const processed = processDocumentForIndexing(
1251
+ doc["_values"],
1252
+ `${collection.path}/${relativePath2}`,
1253
+ collection,
1254
+ this.maxSearchIndexFieldLength
1255
+ );
1136
1256
  await this.searchClient.put([processed]);
1137
1257
  }
1138
1258
  return response;
@@ -1152,7 +1272,7 @@ mutation addPendingDocumentMutation(
1152
1272
  const isTinaCloud = !client.isLocalMode && !((_e = (_d = (_c = (_b = (_a = client.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.config) == null ? void 0 : _c.admin) == null ? void 0 : _d.auth) == null ? void 0 : _e.customAuth);
1153
1273
  const [activeModal, setActiveModal] = React.useState(null);
1154
1274
  const [showChildren, setShowChildren] = React.useState(false);
1155
- React__default["default"].useEffect(() => {
1275
+ React.useEffect(() => {
1156
1276
  client.isAuthenticated().then((isAuthenticated) => {
1157
1277
  if (isAuthenticated) {
1158
1278
  setShowChildren(true);
@@ -1178,45 +1298,54 @@ mutation addPendingDocumentMutation(
1178
1298
  setActiveModal(null);
1179
1299
  }
1180
1300
  }) : [];
1181
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, activeModal === "authenticate" && /* @__PURE__ */ React__default["default"].createElement(ModalBuilder, {
1182
- title: isTinaCloud ? "Tina Cloud Authorization" : "Enter into edit mode",
1183
- message: isTinaCloud ? "To save edits, Tina Cloud authorization is required. On save, changes will get commited using your account." : "To save edits, enter into edit mode. On save, changes will saved to the local filesystem.",
1184
- close,
1185
- actions: [
1186
- ...otherModalActions,
1187
- {
1188
- action: async () => {
1189
- sharedctx.setEditing(false);
1190
- window.location.reload();
1191
- },
1192
- name: "Close",
1193
- primary: false
1194
- },
1195
- {
1196
- name: isTinaCloud ? "Continue to Tina Cloud" : "Enter Edit Mode",
1197
- action: async () => {
1198
- const token = await client.authenticate();
1199
- if (typeof (client == null ? void 0 : client.onLogin) === "function") {
1200
- await (client == null ? void 0 : client.onLogin({ token }));
1201
- }
1202
- onAuthSuccess();
1301
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, activeModal === "authenticate" && /* @__PURE__ */ React.createElement(
1302
+ ModalBuilder,
1303
+ {
1304
+ title: isTinaCloud ? "Tina Cloud Authorization" : "Enter into edit mode",
1305
+ message: isTinaCloud ? "To save edits, Tina Cloud authorization is required. On save, changes will get commited using your account." : "To save edits, enter into edit mode. On save, changes will saved to the local filesystem.",
1306
+ close,
1307
+ actions: [
1308
+ ...otherModalActions,
1309
+ {
1310
+ action: async () => {
1311
+ sharedctx.setEditing(false);
1312
+ window.location.reload();
1313
+ },
1314
+ name: "Close",
1315
+ primary: false
1203
1316
  },
1204
- primary: true
1205
- }
1206
- ]
1207
- }), showChildren ? children : loginScreen ? loginScreen : null);
1317
+ {
1318
+ name: isTinaCloud ? "Continue to Tina Cloud" : "Enter Edit Mode",
1319
+ action: async () => {
1320
+ const token = await client.authenticate();
1321
+ if (typeof (client == null ? void 0 : client.onLogin) === "function") {
1322
+ await (client == null ? void 0 : client.onLogin({ token }));
1323
+ }
1324
+ onAuthSuccess();
1325
+ },
1326
+ primary: true
1327
+ }
1328
+ ]
1329
+ }
1330
+ ), showChildren ? children : loginScreen ? loginScreen : null);
1208
1331
  };
1209
1332
  const TinaCloudProvider = (props) => {
1210
1333
  var _a, _b, _c, _d, _e;
1211
1334
  const baseBranch = props.branch || "main";
1212
- const [currentBranch, setCurrentBranch] = toolkit.useLocalStorage("tinacms-current-branch", baseBranch);
1335
+ const [currentBranch, setCurrentBranch] = toolkit.useLocalStorage(
1336
+ "tinacms-current-branch",
1337
+ baseBranch
1338
+ );
1213
1339
  useTinaAuthRedirect();
1214
- const cms = React__default["default"].useMemo(() => props.cms || new toolkit.TinaCMS({
1215
- enabled: true,
1216
- sidebar: true,
1217
- isLocalClient: props.isLocalClient,
1218
- clientId: props.clientId
1219
- }), [props.cms]);
1340
+ const cms = React.useMemo(
1341
+ () => props.cms || new toolkit.TinaCMS({
1342
+ enabled: true,
1343
+ sidebar: true,
1344
+ isLocalClient: props.isLocalClient,
1345
+ clientId: props.clientId
1346
+ }),
1347
+ [props.cms]
1348
+ );
1220
1349
  if (!cms.api.tina) {
1221
1350
  cms.registerApi("tina", createClient({ ...props, branch: currentBranch }));
1222
1351
  } else {
@@ -1247,7 +1376,12 @@ mutation addPendingDocumentMutation(
1247
1376
  const hasTinaMedia = Boolean((_b2 = (_a2 = props.schema.config) == null ? void 0 : _a2.media) == null ? void 0 : _b2.tina);
1248
1377
  if (hasTinaMedia) {
1249
1378
  cms.media.store = new toolkit.TinaMediaStore(cms);
1250
- } else if (((_d2 = (_c2 = props.schema.config) == null ? void 0 : _c2.media) == null ? void 0 : _d2.loadCustomStore) || props.mediaStore) {
1379
+ } else if (
1380
+ /*
1381
+ Has tina custom media (set up in the schema or define schema)
1382
+ */
1383
+ ((_d2 = (_c2 = props.schema.config) == null ? void 0 : _c2.media) == null ? void 0 : _d2.loadCustomStore) || props.mediaStore
1384
+ ) {
1251
1385
  const mediaStoreFromProps = ((_f = (_e2 = props.schema.config) == null ? void 0 : _e2.media) == null ? void 0 : _f.loadCustomStore) || props.mediaStore;
1252
1386
  if ((_g = mediaStoreFromProps.prototype) == null ? void 0 : _g.persist) {
1253
1387
  cms.media.store = new mediaStoreFromProps(cms.api.tina);
@@ -1274,15 +1408,17 @@ mutation addPendingDocumentMutation(
1274
1408
  return newBranch;
1275
1409
  };
1276
1410
  setupMedia();
1277
- const [branchingEnabled, setBranchingEnabled] = React__default["default"].useState(() => cms.flags.get("branch-switcher"));
1278
- React__default["default"].useEffect(() => {
1411
+ const [branchingEnabled, setBranchingEnabled] = React.useState(
1412
+ () => cms.flags.get("branch-switcher")
1413
+ );
1414
+ React.useEffect(() => {
1279
1415
  cms.events.subscribe("flag:set", ({ key, value }) => {
1280
1416
  if (key === "branch-switcher") {
1281
1417
  setBranchingEnabled(value);
1282
1418
  }
1283
1419
  });
1284
1420
  }, [cms.events]);
1285
- React__default["default"].useEffect(() => {
1421
+ React.useEffect(() => {
1286
1422
  let branchSwitcher;
1287
1423
  if (branchingEnabled) {
1288
1424
  branchSwitcher = new toolkit.BranchSwitcherPlugin({
@@ -1298,12 +1434,12 @@ mutation addPendingDocumentMutation(
1298
1434
  }
1299
1435
  };
1300
1436
  }, [branchingEnabled, props.branch]);
1301
- React__default["default"].useEffect(() => {
1437
+ React.useEffect(() => {
1302
1438
  if (props.cmsCallback) {
1303
1439
  props.cmsCallback(cms);
1304
1440
  }
1305
1441
  }, []);
1306
- React__default["default"].useEffect(() => {
1442
+ React.useEffect(() => {
1307
1443
  const setupEditorialWorkflow = () => {
1308
1444
  client.getProject().then((project) => {
1309
1445
  var _a2;
@@ -1324,20 +1460,19 @@ mutation addPendingDocumentMutation(
1324
1460
  });
1325
1461
  return unsubscribe;
1326
1462
  }, [isTinaCloud, cms]);
1327
- return /* @__PURE__ */ React__default["default"].createElement(toolkit.BranchDataProvider, {
1328
- currentBranch,
1329
- setCurrentBranch: (b) => {
1330
- setCurrentBranch(b);
1331
- }
1332
- }, /* @__PURE__ */ React__default["default"].createElement(toolkit.TinaProvider, {
1333
- cms
1334
- }, /* @__PURE__ */ React__default["default"].createElement(AuthWallInner, {
1335
- ...props,
1336
- cms
1337
- })));
1463
+ return /* @__PURE__ */ React.createElement(
1464
+ toolkit.BranchDataProvider,
1465
+ {
1466
+ currentBranch,
1467
+ setCurrentBranch: (b) => {
1468
+ setCurrentBranch(b);
1469
+ }
1470
+ },
1471
+ /* @__PURE__ */ React.createElement(toolkit.TinaProvider, { cms }, /* @__PURE__ */ React.createElement(AuthWallInner, { ...props, cms }))
1472
+ );
1338
1473
  };
1339
1474
  const TinaCloudAuthWall = TinaCloudProvider;
1340
- var styles = `.tina-tailwind {
1475
+ const styles = `.tina-tailwind {
1341
1476
  line-height: 1.5;
1342
1477
  -webkit-text-size-adjust: 100%;
1343
1478
  -moz-tab-size: 4;
@@ -2886,7 +3021,9 @@ mutation addPendingDocumentMutation(
2886
3021
  }
2887
3022
  async onSubmit({ collection, template, relativePath: relativePath2 }, cms) {
2888
3023
  try {
2889
- const selectedCollection = this.collections.find((collectionItem) => collectionItem.slug === collection);
3024
+ const selectedCollection = this.collections.find(
3025
+ (collectionItem) => collectionItem.slug === collection
3026
+ );
2890
3027
  const collectionFormat = selectedCollection.format;
2891
3028
  const extensionLength = -1 * (collectionFormat.length + 1);
2892
3029
  let relativePathWithExt = relativePath2;
@@ -2922,12 +3059,13 @@ mutation addPendingDocumentMutation(
2922
3059
  }
2923
3060
  const useDocumentCreatorPlugin = (args) => {
2924
3061
  const cms = toolkit.useCMS();
2925
- const [values, setValues] = React__default["default"].useState({});
2926
- const [plugin, setPlugin] = React__default["default"].useState(null);
2927
- React__default["default"].useEffect(() => {
3062
+ const [values, setValues] = React.useState({});
3063
+ const [plugin, setPlugin] = React.useState(null);
3064
+ React.useEffect(() => {
2928
3065
  const run = async () => {
2929
3066
  var _a;
2930
- const res = await cms.api.tina.request((gql2) => gql2`
3067
+ const res = await cms.api.tina.request(
3068
+ (gql2) => gql2`
2931
3069
  {
2932
3070
  collections {
2933
3071
  label
@@ -2936,7 +3074,9 @@ mutation addPendingDocumentMutation(
2936
3074
  templates
2937
3075
  }
2938
3076
  }
2939
- `, { variables: {} });
3077
+ `,
3078
+ { variables: {} }
3079
+ );
2940
3080
  const allCollectionOptions = [];
2941
3081
  res.collections.forEach((collection) => {
2942
3082
  const value = collection.slug;
@@ -2960,72 +3100,76 @@ mutation addPendingDocumentMutation(
2960
3100
  { value: "", label: "Choose Template" }
2961
3101
  ];
2962
3102
  if (values.collection) {
2963
- const filteredCollection = res.collections.find((c) => c.slug === values.collection);
3103
+ const filteredCollection = res.collections.find(
3104
+ (c) => c.slug === values.collection
3105
+ );
2964
3106
  (_a = filteredCollection == null ? void 0 : filteredCollection.templates) == null ? void 0 : _a.forEach((template) => {
2965
3107
  templateOptions.push({ value: template.name, label: template.label });
2966
3108
  });
2967
3109
  }
2968
- setPlugin(new ContentCreatorPlugin({
2969
- label: "Add Document",
2970
- onNewDocument: args && args.onNewDocument,
2971
- collections: res.collections,
2972
- onChange: async ({ values: values2 }) => {
2973
- setValues(values2);
2974
- },
2975
- initialValues: values,
2976
- fields: [
2977
- {
2978
- component: "select",
2979
- name: "collection",
2980
- label: "Collection",
2981
- description: "Select the collection.",
2982
- options: collectionOptions,
2983
- validate: async (value, allValues, meta) => {
2984
- if (!value) {
2985
- return true;
2986
- }
2987
- }
3110
+ setPlugin(
3111
+ new ContentCreatorPlugin({
3112
+ label: "Add Document",
3113
+ onNewDocument: args && args.onNewDocument,
3114
+ collections: res.collections,
3115
+ onChange: async ({ values: values2 }) => {
3116
+ setValues(values2);
2988
3117
  },
2989
- {
2990
- component: "select",
2991
- name: "template",
2992
- label: "Template",
2993
- description: "Select the template.",
2994
- options: templateOptions,
2995
- validate: async (value, allValues, meta) => {
2996
- if (!value && templateOptions.length > 1) {
2997
- if (meta.dirty) {
2998
- return "Required";
3118
+ initialValues: values,
3119
+ fields: [
3120
+ {
3121
+ component: "select",
3122
+ name: "collection",
3123
+ label: "Collection",
3124
+ description: "Select the collection.",
3125
+ options: collectionOptions,
3126
+ validate: async (value, allValues, meta) => {
3127
+ if (!value) {
3128
+ return true;
2999
3129
  }
3000
- return true;
3001
3130
  }
3002
- }
3003
- },
3004
- {
3005
- component: "text",
3006
- name: "relativePath",
3007
- label: "Name",
3008
- description: `A unique name for the content. Example: "newPost" or "blog_022021`,
3009
- placeholder: "newPost",
3010
- validate: (value, allValues, meta) => {
3011
- if (!value) {
3012
- if (meta.dirty) {
3013
- return "Required";
3131
+ },
3132
+ {
3133
+ component: "select",
3134
+ name: "template",
3135
+ label: "Template",
3136
+ description: "Select the template.",
3137
+ options: templateOptions,
3138
+ validate: async (value, allValues, meta) => {
3139
+ if (!value && templateOptions.length > 1) {
3140
+ if (meta.dirty) {
3141
+ return "Required";
3142
+ }
3143
+ return true;
3014
3144
  }
3015
- return true;
3016
3145
  }
3017
- const isValid = /^[_a-zA-Z0-9][\-_a-zA-Z0-9]*$/.test(value);
3018
- if (value && !isValid) {
3019
- return "Must begin with a-z, A-Z, 0-9, or _ and contain only a-z, A-Z, 0-9, - or _";
3146
+ },
3147
+ {
3148
+ component: "text",
3149
+ name: "relativePath",
3150
+ label: "Name",
3151
+ description: `A unique name for the content. Example: "newPost" or "blog_022021`,
3152
+ placeholder: "newPost",
3153
+ validate: (value, allValues, meta) => {
3154
+ if (!value) {
3155
+ if (meta.dirty) {
3156
+ return "Required";
3157
+ }
3158
+ return true;
3159
+ }
3160
+ const isValid = /^[_a-zA-Z0-9][\-_a-zA-Z0-9]*$/.test(value);
3161
+ if (value && !isValid) {
3162
+ return "Must begin with a-z, A-Z, 0-9, or _ and contain only a-z, A-Z, 0-9, - or _";
3163
+ }
3020
3164
  }
3021
3165
  }
3022
- }
3023
- ]
3024
- }));
3166
+ ]
3167
+ })
3168
+ );
3025
3169
  };
3026
3170
  run();
3027
3171
  }, [cms]);
3028
- React__default["default"].useEffect(() => {
3172
+ React.useEffect(() => {
3029
3173
  if (plugin) {
3030
3174
  cms.plugins.add(plugin);
3031
3175
  }
@@ -3048,7 +3192,7 @@ mutation addPendingDocumentMutation(
3048
3192
  color: "white",
3049
3193
  margin: "1rem 0"
3050
3194
  };
3051
- class ErrorBoundary extends React__default["default"].Component {
3195
+ class ErrorBoundary extends React.Component {
3052
3196
  constructor(props) {
3053
3197
  super(props);
3054
3198
  this.state = {
@@ -3060,44 +3204,75 @@ mutation addPendingDocumentMutation(
3060
3204
  static getDerivedStateFromError(error) {
3061
3205
  return { hasError: true, message: error.message };
3062
3206
  }
3207
+ /**
3208
+ * Ideally we can track the last valid state and provide a button to go back, which
3209
+ * would just reset the form to that state. This isn't ideal for many cases though,
3210
+ * in general you'd probably want to push through the invalid state until you arrive at
3211
+ * a new state which you are happy with. So we should offer the opportunity to try rendering
3212
+ * again in the new, hopefully valid, state.
3213
+ */
3063
3214
  render() {
3064
3215
  if (this.state.hasError && !this.state.pageRefresh) {
3065
- return /* @__PURE__ */ React__default["default"].createElement("div", {
3066
- style: {
3067
- background: "#efefef",
3068
- height: "100vh",
3069
- display: "flex",
3070
- alignItems: "center",
3071
- justifyContent: "center"
3072
- }
3073
- }, /* @__PURE__ */ React__default["default"].createElement("style", null, " body { margin: 0; } "), /* @__PURE__ */ React__default["default"].createElement("div", {
3074
- style: {
3075
- background: "#fff",
3076
- maxWidth: "400px",
3077
- padding: "20px",
3078
- fontFamily: "'Inter', sans-serif",
3079
- borderRadius: "5px",
3080
- boxShadow: "0 6px 24px rgb(0 37 91 / 5%), 0 2px 4px rgb(0 37 91 / 3%)"
3081
- }
3082
- }, /* @__PURE__ */ React__default["default"].createElement("h3", {
3083
- style: { color: "#eb6337" }
3084
- }, "TinaCMS Render Error"), /* @__PURE__ */ React__default["default"].createElement("p", null, "Tina caught an error while updating the page:"), /* @__PURE__ */ React__default["default"].createElement("pre", {
3085
- style: { marginTop: "1rem", overflowX: "auto" }
3086
- }, this.state.message), /* @__PURE__ */ React__default["default"].createElement("br", null), /* @__PURE__ */ React__default["default"].createElement("p", null, `If you've just updated the form, undo your most recent changes and click "refresh". If after a few refreshes, you're still encountering this error. There is a bigger issue with the site. Please reach out to your site admin.`), /* @__PURE__ */ React__default["default"].createElement("p", null, "See our", " ", /* @__PURE__ */ React__default["default"].createElement("a", {
3087
- className: "text-gray-600",
3088
- style: { textDecoration: "underline" },
3089
- href: "https://tina.io/docs/errors/faq/",
3090
- target: "_blank"
3091
- }, " ", "Error FAQ", " "), " ", "for more information."), /* @__PURE__ */ React__default["default"].createElement("button", {
3092
- style: errorButtonStyles,
3093
- onClick: () => {
3094
- this.setState({ pageRefresh: true });
3095
- setTimeout(() => this.setState({ hasError: false, pageRefresh: false }), 3e3);
3096
- }
3097
- }, "Refresh")));
3216
+ return /* @__PURE__ */ React.createElement(
3217
+ "div",
3218
+ {
3219
+ style: {
3220
+ background: "#efefef",
3221
+ height: "100vh",
3222
+ display: "flex",
3223
+ alignItems: "center",
3224
+ justifyContent: "center"
3225
+ }
3226
+ },
3227
+ /* @__PURE__ */ React.createElement("style", null, " body { margin: 0; } "),
3228
+ /* @__PURE__ */ React.createElement(
3229
+ "div",
3230
+ {
3231
+ style: {
3232
+ background: "#fff",
3233
+ maxWidth: "400px",
3234
+ padding: "20px",
3235
+ fontFamily: "'Inter', sans-serif",
3236
+ borderRadius: "5px",
3237
+ boxShadow: "0 6px 24px rgb(0 37 91 / 5%), 0 2px 4px rgb(0 37 91 / 3%)"
3238
+ }
3239
+ },
3240
+ /* @__PURE__ */ React.createElement("h3", { style: { color: "#eb6337" } }, "TinaCMS Render Error"),
3241
+ /* @__PURE__ */ React.createElement("p", null, "Tina caught an error while updating the page:"),
3242
+ /* @__PURE__ */ React.createElement("pre", { style: { marginTop: "1rem", overflowX: "auto" } }, this.state.message),
3243
+ /* @__PURE__ */ React.createElement("br", null),
3244
+ /* @__PURE__ */ React.createElement("p", null, `If you've just updated the form, undo your most recent changes and click "refresh". If after a few refreshes, you're still encountering this error. There is a bigger issue with the site. Please reach out to your site admin.`),
3245
+ /* @__PURE__ */ React.createElement("p", null, "See our", " ", /* @__PURE__ */ React.createElement(
3246
+ "a",
3247
+ {
3248
+ className: "text-gray-600",
3249
+ style: { textDecoration: "underline" },
3250
+ href: "https://tina.io/docs/errors/faq/",
3251
+ target: "_blank"
3252
+ },
3253
+ " ",
3254
+ "Error FAQ",
3255
+ " "
3256
+ ), " ", "for more information."),
3257
+ /* @__PURE__ */ React.createElement(
3258
+ "button",
3259
+ {
3260
+ style: errorButtonStyles,
3261
+ onClick: () => {
3262
+ this.setState({ pageRefresh: true });
3263
+ setTimeout(
3264
+ () => this.setState({ hasError: false, pageRefresh: false }),
3265
+ 3e3
3266
+ );
3267
+ }
3268
+ },
3269
+ "Refresh"
3270
+ )
3271
+ )
3272
+ );
3098
3273
  }
3099
3274
  if (this.state.pageRefresh) {
3100
- return /* @__PURE__ */ React__default["default"].createElement(Loader, null, "Let's try that again.");
3275
+ return /* @__PURE__ */ React.createElement(Loader, null, "Let's try that again.");
3101
3276
  }
3102
3277
  return this.props.children;
3103
3278
  }
@@ -3111,130 +3286,157 @@ mutation addPendingDocumentMutation(
3111
3286
  }) => {
3112
3287
  var _a, _b, _c, _d, _e;
3113
3288
  if (props == null ? void 0 : props.apiURL) {
3114
- console.warn("The apiURL prop is deprecated. Please see https://tina.io/blog/tina-v-0.68.14 for information on how to upgrade to the new API");
3289
+ console.warn(
3290
+ "The apiURL prop is deprecated. Please see https://tina.io/blog/tina-v-0.68.14 for information on how to upgrade to the new API"
3291
+ );
3115
3292
  }
3116
3293
  const apiURL = ((_a = props == null ? void 0 : props.client) == null ? void 0 : _a.apiUrl) || (props == null ? void 0 : props.apiURL);
3117
3294
  const isLocalOverride = (_d = (_c = (_b = schema == null ? void 0 : schema.config) == null ? void 0 : _b.admin) == null ? void 0 : _c.auth) == null ? void 0 : _d.useLocalAuth;
3118
3295
  const { branch, clientId, isLocalClient } = apiURL ? schemaTools.parseURL(apiURL) : {
3119
3296
  branch: props.branch,
3120
3297
  clientId: props.clientId,
3298
+ // @ts-expect-error this is for backwards compatibility
3121
3299
  isLocalClient: props == null ? void 0 : props.isLocalClient
3122
3300
  };
3123
- if (typeof isLocalClient === "undefined" || !isLocalClient && (!branch || !clientId) && !schema.config.contentApiUrlOverride) {
3124
- throw new Error("Invalid setup. See https://tina.io/docs/tina-cloud/connecting-site/ for more information.");
3301
+ if (
3302
+ // Check if local client is defined
3303
+ typeof isLocalClient === "undefined" || // If in not in localMode check if clientId and branch are defined
3304
+ !isLocalClient && (!branch || !clientId) && // if they pass a custom apiURL, we don't need to throw an error
3305
+ !schema.config.contentApiUrlOverride
3306
+ ) {
3307
+ throw new Error(
3308
+ "Invalid setup. See https://tina.io/docs/tina-cloud/connecting-site/ for more information."
3309
+ );
3125
3310
  }
3126
3311
  if (!schema) {
3127
- throw new Error("`schema` is required to be passed as a property to `TinaProvider`. You can learn more about this change here: https://github.com/tinacms/tinacms/pull/2823");
3312
+ throw new Error(
3313
+ "`schema` is required to be passed as a property to `TinaProvider`. You can learn more about this change here: https://github.com/tinacms/tinacms/pull/2823"
3314
+ );
3128
3315
  }
3129
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement(TinaCloudProvider, {
3130
- branch,
3131
- clientId: clientId || ((_e = schema == null ? void 0 : schema.config) == null ? void 0 : _e.clientId),
3132
- tinaioConfig: props.tinaioConfig,
3133
- isLocalClient: isLocalOverride || isLocalClient,
3134
- cmsCallback: props.cmsCallback,
3135
- mediaStore: props.mediaStore,
3136
- apiUrl: apiURL,
3137
- schema: { ...schema, config: { ...schema.config, ...props } },
3138
- tinaGraphQLVersion: props.tinaGraphQLVersion
3139
- }, /* @__PURE__ */ React__default["default"].createElement("style", null, styles), /* @__PURE__ */ React__default["default"].createElement(ErrorBoundary, null, props.children)));
3316
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
3317
+ TinaCloudProvider,
3318
+ {
3319
+ branch,
3320
+ clientId: clientId || ((_e = schema == null ? void 0 : schema.config) == null ? void 0 : _e.clientId),
3321
+ tinaioConfig: props.tinaioConfig,
3322
+ isLocalClient: isLocalOverride || isLocalClient,
3323
+ cmsCallback: props.cmsCallback,
3324
+ mediaStore: props.mediaStore,
3325
+ apiUrl: apiURL,
3326
+ schema: { ...schema, config: { ...schema.config, ...props } },
3327
+ tinaGraphQLVersion: props.tinaGraphQLVersion
3328
+ },
3329
+ /* @__PURE__ */ React.createElement("style", null, styles),
3330
+ /* @__PURE__ */ React.createElement(ErrorBoundary, null, props.children)
3331
+ ));
3140
3332
  };
3141
3333
  const Loader = (props) => {
3142
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("div", {
3143
- style: {
3144
- position: "fixed",
3145
- background: "rgba(0, 0, 0, 0.5)",
3146
- inset: 0,
3147
- zIndex: 200,
3148
- opacity: "0.8",
3149
- display: "flex",
3150
- alignItems: "center",
3151
- justifyContent: "center",
3152
- padding: "40px"
3153
- }
3154
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
3155
- style: {
3156
- background: "#f6f6f9",
3157
- boxShadow: "0px 2px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.1)",
3158
- borderRadius: "5px",
3159
- padding: "40px 32px",
3160
- width: "460px",
3161
- maxWidth: "90%",
3162
- display: "flex",
3163
- alignItems: "center",
3164
- justifyContent: "center",
3165
- flexDirection: "column"
3166
- }
3167
- }, /* @__PURE__ */ React__default["default"].createElement("svg", {
3168
- style: {
3169
- width: "64px",
3170
- color: "#2296fe",
3171
- marginTop: "-8px",
3172
- marginBottom: "16px"
3334
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
3335
+ "div",
3336
+ {
3337
+ style: {
3338
+ position: "fixed",
3339
+ background: "rgba(0, 0, 0, 0.5)",
3340
+ inset: 0,
3341
+ zIndex: 200,
3342
+ opacity: "0.8",
3343
+ display: "flex",
3344
+ alignItems: "center",
3345
+ justifyContent: "center",
3346
+ padding: "40px"
3347
+ }
3173
3348
  },
3174
- version: "1.1",
3175
- id: "L5",
3176
- xmlns: "http://www.w3.org/2000/svg",
3177
- xmlnsXlink: "http://www.w3.org/1999/xlink",
3178
- x: "0px",
3179
- y: "0px",
3180
- viewBox: "0 0 100 64",
3181
- enableBackground: "new 0 0 0 0",
3182
- xmlSpace: "preserve"
3183
- }, /* @__PURE__ */ React__default["default"].createElement("circle", {
3184
- fill: "currentColor",
3185
- stroke: "none",
3186
- cx: 6,
3187
- cy: 32,
3188
- r: 6
3189
- }, /* @__PURE__ */ React__default["default"].createElement("animateTransform", {
3190
- attributeName: "transform",
3191
- dur: "1s",
3192
- type: "translate",
3193
- values: "0 15 ; 0 -15; 0 15",
3194
- calcMode: "spline",
3195
- keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
3196
- repeatCount: "indefinite",
3197
- begin: "0.1"
3198
- })), /* @__PURE__ */ React__default["default"].createElement("circle", {
3199
- fill: "currentColor",
3200
- stroke: "none",
3201
- cx: 30,
3202
- cy: 32,
3203
- r: 6
3204
- }, /* @__PURE__ */ React__default["default"].createElement("animateTransform", {
3205
- attributeName: "transform",
3206
- dur: "1s",
3207
- type: "translate",
3208
- values: "0 15 ; 0 -10; 0 15",
3209
- calcMode: "spline",
3210
- keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
3211
- repeatCount: "indefinite",
3212
- begin: "0.2"
3213
- })), /* @__PURE__ */ React__default["default"].createElement("circle", {
3214
- fill: "currentColor",
3215
- stroke: "none",
3216
- cx: 54,
3217
- cy: 32,
3218
- r: 6
3219
- }, /* @__PURE__ */ React__default["default"].createElement("animateTransform", {
3220
- attributeName: "transform",
3221
- dur: "1s",
3222
- type: "translate",
3223
- values: "0 15 ; 0 -5; 0 15",
3224
- calcMode: "spline",
3225
- keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
3226
- repeatCount: "indefinite",
3227
- begin: "0.3"
3228
- }))), /* @__PURE__ */ React__default["default"].createElement("p", {
3229
- style: {
3230
- fontSize: "18px",
3231
- color: "#252336",
3232
- textAlign: "center",
3233
- lineHeight: "1.3",
3234
- fontFamily: "'Inter', sans-serif",
3235
- fontWeight: "normal"
3236
- }
3237
- }, "Please wait, Tina is loading data..."))), props.children);
3349
+ /* @__PURE__ */ React.createElement(
3350
+ "div",
3351
+ {
3352
+ style: {
3353
+ background: "#f6f6f9",
3354
+ boxShadow: "0px 2px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.1)",
3355
+ borderRadius: "5px",
3356
+ padding: "40px 32px",
3357
+ width: "460px",
3358
+ maxWidth: "90%",
3359
+ display: "flex",
3360
+ alignItems: "center",
3361
+ justifyContent: "center",
3362
+ flexDirection: "column"
3363
+ }
3364
+ },
3365
+ /* @__PURE__ */ React.createElement(
3366
+ "svg",
3367
+ {
3368
+ style: {
3369
+ width: "64px",
3370
+ color: "#2296fe",
3371
+ marginTop: "-8px",
3372
+ marginBottom: "16px"
3373
+ },
3374
+ version: "1.1",
3375
+ id: "L5",
3376
+ xmlns: "http://www.w3.org/2000/svg",
3377
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
3378
+ x: "0px",
3379
+ y: "0px",
3380
+ viewBox: "0 0 100 64",
3381
+ enableBackground: "new 0 0 0 0",
3382
+ xmlSpace: "preserve"
3383
+ },
3384
+ /* @__PURE__ */ React.createElement("circle", { fill: "currentColor", stroke: "none", cx: 6, cy: 32, r: 6 }, /* @__PURE__ */ React.createElement(
3385
+ "animateTransform",
3386
+ {
3387
+ attributeName: "transform",
3388
+ dur: "1s",
3389
+ type: "translate",
3390
+ values: "0 15 ; 0 -15; 0 15",
3391
+ calcMode: "spline",
3392
+ keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
3393
+ repeatCount: "indefinite",
3394
+ begin: "0.1"
3395
+ }
3396
+ )),
3397
+ /* @__PURE__ */ React.createElement("circle", { fill: "currentColor", stroke: "none", cx: 30, cy: 32, r: 6 }, /* @__PURE__ */ React.createElement(
3398
+ "animateTransform",
3399
+ {
3400
+ attributeName: "transform",
3401
+ dur: "1s",
3402
+ type: "translate",
3403
+ values: "0 15 ; 0 -10; 0 15",
3404
+ calcMode: "spline",
3405
+ keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
3406
+ repeatCount: "indefinite",
3407
+ begin: "0.2"
3408
+ }
3409
+ )),
3410
+ /* @__PURE__ */ React.createElement("circle", { fill: "currentColor", stroke: "none", cx: 54, cy: 32, r: 6 }, /* @__PURE__ */ React.createElement(
3411
+ "animateTransform",
3412
+ {
3413
+ attributeName: "transform",
3414
+ dur: "1s",
3415
+ type: "translate",
3416
+ values: "0 15 ; 0 -5; 0 15",
3417
+ calcMode: "spline",
3418
+ keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
3419
+ repeatCount: "indefinite",
3420
+ begin: "0.3"
3421
+ }
3422
+ ))
3423
+ ),
3424
+ /* @__PURE__ */ React.createElement(
3425
+ "p",
3426
+ {
3427
+ style: {
3428
+ fontSize: "18px",
3429
+ color: "#252336",
3430
+ textAlign: "center",
3431
+ lineHeight: "1.3",
3432
+ fontFamily: "'Inter', sans-serif",
3433
+ fontWeight: "normal"
3434
+ }
3435
+ },
3436
+ "Please wait, Tina is loading data..."
3437
+ )
3438
+ )
3439
+ ), props.children);
3238
3440
  };
3239
3441
  const getStaticPropsForTina = async ({
3240
3442
  query,
@@ -3242,17 +3444,21 @@ mutation addPendingDocumentMutation(
3242
3444
  }) => {
3243
3445
  try {
3244
3446
  const data = await staticRequest({ query, variables });
3245
- return JSON.parse(JSON.stringify({
3246
- data,
3247
- query,
3248
- variables
3249
- }));
3447
+ return JSON.parse(
3448
+ JSON.stringify({
3449
+ data,
3450
+ query,
3451
+ variables
3452
+ })
3453
+ );
3250
3454
  } catch (e) {
3251
- return JSON.parse(JSON.stringify({
3252
- data: {},
3253
- query,
3254
- variables
3255
- }));
3455
+ return JSON.parse(
3456
+ JSON.stringify({
3457
+ data: {},
3458
+ query,
3459
+ variables
3460
+ })
3461
+ );
3256
3462
  }
3257
3463
  };
3258
3464
  function is_server() {
@@ -3282,20 +3488,24 @@ This will work when developing locally but NOT when deployed to production.
3282
3488
  return str;
3283
3489
  }
3284
3490
  const Layout = ({ children }) => {
3285
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("style", null, styles), /* @__PURE__ */ React__default["default"].createElement("div", {
3286
- className: "tina-tailwind",
3287
- style: {
3288
- position: "fixed",
3289
- top: 0,
3290
- left: 0,
3291
- width: "100%",
3292
- height: "100%",
3293
- overflow: "auto",
3294
- background: "#F6F6F9",
3295
- fontFamily: "'Inter', sans-serif",
3296
- zIndex: 9999
3297
- }
3298
- }, children));
3491
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("style", null, styles), /* @__PURE__ */ React.createElement(
3492
+ "div",
3493
+ {
3494
+ className: "tina-tailwind",
3495
+ style: {
3496
+ position: "fixed",
3497
+ top: 0,
3498
+ left: 0,
3499
+ width: "100%",
3500
+ height: "100%",
3501
+ overflow: "auto",
3502
+ background: "#F6F6F9",
3503
+ fontFamily: "'Inter', sans-serif",
3504
+ zIndex: 9999
3505
+ }
3506
+ },
3507
+ children
3508
+ ));
3299
3509
  };
3300
3510
  var DefaultContext = {
3301
3511
  color: void 0,
@@ -3304,7 +3514,7 @@ This will work when developing locally but NOT when deployed to production.
3304
3514
  style: void 0,
3305
3515
  attr: void 0
3306
3516
  };
3307
- var IconContext = React__default["default"].createContext && React__default["default"].createContext(DefaultContext);
3517
+ var IconContext = React.createContext && React.createContext(DefaultContext);
3308
3518
  var __assign = globalThis && globalThis.__assign || function() {
3309
3519
  __assign = Object.assign || function(t) {
3310
3520
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -3331,14 +3541,14 @@ This will work when developing locally but NOT when deployed to production.
3331
3541
  };
3332
3542
  function Tree2Element(tree) {
3333
3543
  return tree && tree.map(function(node, i) {
3334
- return React__default["default"].createElement(node.tag, __assign({
3544
+ return React.createElement(node.tag, __assign({
3335
3545
  key: i
3336
3546
  }, node.attr), Tree2Element(node.child));
3337
3547
  });
3338
3548
  }
3339
3549
  function GenIcon(data) {
3340
3550
  return function(props) {
3341
- return React__default["default"].createElement(IconBase, __assign({
3551
+ return React.createElement(IconBase, __assign({
3342
3552
  attr: __assign({}, data.attr)
3343
3553
  }, props), Tree2Element(data.child));
3344
3554
  };
@@ -3352,7 +3562,7 @@ This will work when developing locally but NOT when deployed to production.
3352
3562
  className = conf.className;
3353
3563
  if (props.className)
3354
3564
  className = (className ? className + " " : "") + props.className;
3355
- return React__default["default"].createElement("svg", __assign({
3565
+ return React.createElement("svg", __assign({
3356
3566
  stroke: "currentColor",
3357
3567
  fill: "currentColor",
3358
3568
  strokeWidth: "0"
@@ -3364,9 +3574,9 @@ This will work when developing locally but NOT when deployed to production.
3364
3574
  height: computedSize,
3365
3575
  width: computedSize,
3366
3576
  xmlns: "http://www.w3.org/2000/svg"
3367
- }), title && React__default["default"].createElement("title", null, title), props.children);
3577
+ }), title && React.createElement("title", null, title), props.children);
3368
3578
  };
3369
- return IconContext !== void 0 ? React__default["default"].createElement(IconContext.Consumer, null, function(conf) {
3579
+ return IconContext !== void 0 ? React.createElement(IconContext.Consumer, null, function(conf) {
3370
3580
  return elem(conf);
3371
3581
  }) : elem(DefaultContext);
3372
3582
  }
@@ -3436,144 +3646,167 @@ This will work when developing locally but NOT when deployed to production.
3436
3646
  const collectionsInfo = useGetCollections(cms);
3437
3647
  const screens = cms.plugins.getType("screen").all();
3438
3648
  const cloudConfigs = cms.plugins.getType("cloud-config").all();
3439
- const [menuIsOpen, setMenuIsOpen] = React__default["default"].useState(false);
3649
+ const [menuIsOpen, setMenuIsOpen] = React.useState(false);
3440
3650
  const isLocalMode = (_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode;
3441
3651
  const navBreakpoint = 1e3;
3442
3652
  const windowWidth = windowSize.useWindowWidth();
3443
3653
  const renderDesktopNav = windowWidth > navBreakpoint;
3444
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, renderDesktopNav && /* @__PURE__ */ React__default["default"].createElement(toolkit.Nav, {
3445
- isLocalMode,
3446
- sidebarWidth: 360,
3447
- showCollections: true,
3448
- collectionsInfo,
3449
- screens,
3450
- cloudConfigs,
3451
- contentCreators: [],
3452
- RenderNavSite: ({ view }) => /* @__PURE__ */ React__default["default"].createElement(SidebarLink, {
3453
- label: view.name,
3454
- to: `/screens/${slugify(view.name)}`,
3455
- Icon: view.Icon ? view.Icon : ImFilesEmpty
3456
- }),
3457
- RenderNavCloud: ({ config }) => /* @__PURE__ */ React__default["default"].createElement(SidebarCloudLink, {
3458
- config
3459
- }),
3460
- RenderNavCollection: ({ collection }) => /* @__PURE__ */ React__default["default"].createElement(SidebarLink, {
3461
- label: collection.label ? collection.label : collection.name,
3462
- to: `/collections/${collection.name}/~`,
3463
- Icon: ImFilesEmpty
3464
- })
3465
- }), !renderDesktopNav && /* @__PURE__ */ React__default["default"].createElement(react.Transition, {
3466
- show: menuIsOpen
3467
- }, /* @__PURE__ */ React__default["default"].createElement(react.Transition.Child, {
3468
- as: React__default["default"].Fragment,
3469
- enter: "transform transition-all ease-out duration-300",
3470
- enterFrom: "opacity-0 -translate-x-full",
3471
- enterTo: "opacity-100 translate-x-0",
3472
- leave: "transform transition-all ease-in duration-200",
3473
- leaveFrom: "opacity-100 translate-x-0",
3474
- leaveTo: "opacity-0 -translate-x-full"
3475
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
3476
- className: "fixed left-0 top-0 z-overlay h-full transform"
3477
- }, /* @__PURE__ */ React__default["default"].createElement(toolkit.Nav, {
3478
- isLocalMode,
3479
- className: "rounded-r-md",
3480
- sidebarWidth: 360,
3481
- showCollections: true,
3482
- collectionsInfo,
3483
- screens,
3484
- cloudConfigs,
3485
- contentCreators: [],
3486
- RenderNavSite: ({ view }) => /* @__PURE__ */ React__default["default"].createElement(SidebarLink, {
3487
- label: view.name,
3488
- to: `/screens/${slugify(view.name)}`,
3489
- Icon: view.Icon ? view.Icon : ImFilesEmpty,
3490
- onClick: () => {
3491
- setMenuIsOpen(false);
3492
- }
3493
- }),
3494
- RenderNavCloud: ({ config }) => /* @__PURE__ */ React__default["default"].createElement(SidebarCloudLink, {
3495
- config
3496
- }),
3497
- RenderNavCollection: ({ collection }) => /* @__PURE__ */ React__default["default"].createElement(SidebarLink, {
3498
- label: collection.label ? collection.label : collection.name,
3499
- to: `/collections/${collection.name}/~`,
3500
- Icon: ImFilesEmpty,
3501
- onClick: () => {
3502
- setMenuIsOpen(false);
3503
- }
3504
- })
3505
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
3506
- className: "absolute top-8 right-0 transform translate-x-full overflow-hidden"
3507
- }, /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
3508
- rounded: "right",
3509
- variant: "secondary",
3510
- onClick: () => {
3511
- setMenuIsOpen(false);
3654
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, renderDesktopNav && /* @__PURE__ */ React.createElement(
3655
+ toolkit.Nav,
3656
+ {
3657
+ isLocalMode,
3658
+ sidebarWidth: 360,
3659
+ showCollections: true,
3660
+ collectionsInfo,
3661
+ screens,
3662
+ cloudConfigs,
3663
+ contentCreators: [],
3664
+ RenderNavSite: ({ view }) => /* @__PURE__ */ React.createElement(
3665
+ SidebarLink,
3666
+ {
3667
+ label: view.name,
3668
+ to: `/screens/${slugify(view.name)}`,
3669
+ Icon: view.Icon ? view.Icon : ImFilesEmpty
3670
+ }
3671
+ ),
3672
+ RenderNavCloud: ({ config }) => /* @__PURE__ */ React.createElement(SidebarCloudLink, { config }),
3673
+ RenderNavCollection: ({ collection }) => /* @__PURE__ */ React.createElement(
3674
+ SidebarLink,
3675
+ {
3676
+ label: collection.label ? collection.label : collection.name,
3677
+ to: `/collections/${collection.name}/~`,
3678
+ Icon: ImFilesEmpty
3679
+ }
3680
+ )
3681
+ }
3682
+ ), !renderDesktopNav && /* @__PURE__ */ React.createElement(react.Transition, { show: menuIsOpen }, /* @__PURE__ */ React.createElement(
3683
+ react.Transition.Child,
3684
+ {
3685
+ as: React.Fragment,
3686
+ enter: "transform transition-all ease-out duration-300",
3687
+ enterFrom: "opacity-0 -translate-x-full",
3688
+ enterTo: "opacity-100 translate-x-0",
3689
+ leave: "transform transition-all ease-in duration-200",
3690
+ leaveFrom: "opacity-100 translate-x-0",
3691
+ leaveTo: "opacity-0 -translate-x-full"
3512
3692
  },
3513
- className: `transition-opacity duration-150 ease-out`
3514
- }, /* @__PURE__ */ React__default["default"].createElement(IoMdClose, {
3515
- className: "h-6 w-auto"
3516
- })))))), /* @__PURE__ */ React__default["default"].createElement(react.Transition.Child, {
3517
- as: React__default["default"].Fragment,
3518
- enter: "ease-out duration-300",
3519
- enterFrom: "opacity-0",
3520
- enterTo: "opacity-80",
3521
- entered: "opacity-80",
3522
- leave: "ease-in duration-200",
3523
- leaveFrom: "opacity-80",
3524
- leaveTo: "opacity-0"
3525
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
3526
- onClick: () => {
3527
- setMenuIsOpen(false);
3693
+ /* @__PURE__ */ React.createElement("div", { className: "fixed left-0 top-0 z-overlay h-full transform" }, /* @__PURE__ */ React.createElement(
3694
+ toolkit.Nav,
3695
+ {
3696
+ isLocalMode,
3697
+ className: "rounded-r-md",
3698
+ sidebarWidth: 360,
3699
+ showCollections: true,
3700
+ collectionsInfo,
3701
+ screens,
3702
+ cloudConfigs,
3703
+ contentCreators: [],
3704
+ RenderNavSite: ({ view }) => /* @__PURE__ */ React.createElement(
3705
+ SidebarLink,
3706
+ {
3707
+ label: view.name,
3708
+ to: `/screens/${slugify(view.name)}`,
3709
+ Icon: view.Icon ? view.Icon : ImFilesEmpty,
3710
+ onClick: () => {
3711
+ setMenuIsOpen(false);
3712
+ }
3713
+ }
3714
+ ),
3715
+ RenderNavCloud: ({ config }) => /* @__PURE__ */ React.createElement(SidebarCloudLink, { config }),
3716
+ RenderNavCollection: ({ collection }) => /* @__PURE__ */ React.createElement(
3717
+ SidebarLink,
3718
+ {
3719
+ label: collection.label ? collection.label : collection.name,
3720
+ to: `/collections/${collection.name}/~`,
3721
+ Icon: ImFilesEmpty,
3722
+ onClick: () => {
3723
+ setMenuIsOpen(false);
3724
+ }
3725
+ }
3726
+ )
3727
+ },
3728
+ /* @__PURE__ */ React.createElement("div", { className: "absolute top-8 right-0 transform translate-x-full overflow-hidden" }, /* @__PURE__ */ React.createElement(
3729
+ toolkit.Button,
3730
+ {
3731
+ rounded: "right",
3732
+ variant: "secondary",
3733
+ onClick: () => {
3734
+ setMenuIsOpen(false);
3735
+ },
3736
+ className: `transition-opacity duration-150 ease-out`
3737
+ },
3738
+ /* @__PURE__ */ React.createElement(IoMdClose, { className: "h-6 w-auto" })
3739
+ ))
3740
+ ))
3741
+ ), /* @__PURE__ */ React.createElement(
3742
+ react.Transition.Child,
3743
+ {
3744
+ as: React.Fragment,
3745
+ enter: "ease-out duration-300",
3746
+ enterFrom: "opacity-0",
3747
+ enterTo: "opacity-80",
3748
+ entered: "opacity-80",
3749
+ leave: "ease-in duration-200",
3750
+ leaveFrom: "opacity-80",
3751
+ leaveTo: "opacity-0"
3528
3752
  },
3529
- className: "fixed z-menu inset-0 bg-gradient-to-br from-gray-800 via-gray-900 to-black"
3530
- }))), !renderDesktopNav && /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
3531
- rounded: "right",
3532
- variant: "secondary",
3533
- onClick: () => {
3534
- setMenuIsOpen(true);
3753
+ /* @__PURE__ */ React.createElement(
3754
+ "div",
3755
+ {
3756
+ onClick: () => {
3757
+ setMenuIsOpen(false);
3758
+ },
3759
+ className: "fixed z-menu inset-0 bg-gradient-to-br from-gray-800 via-gray-900 to-black"
3760
+ }
3761
+ )
3762
+ )), !renderDesktopNav && /* @__PURE__ */ React.createElement(
3763
+ toolkit.Button,
3764
+ {
3765
+ rounded: "right",
3766
+ variant: "secondary",
3767
+ onClick: () => {
3768
+ setMenuIsOpen(true);
3769
+ },
3770
+ className: `pointer-events-auto -ml-px absolute left-0 z-50 ${isLocalMode ? `top-10` : `top-4`}`
3535
3771
  },
3536
- className: `pointer-events-auto -ml-px absolute left-0 z-50 ${isLocalMode ? `top-10` : `top-4`}`
3537
- }, /* @__PURE__ */ React__default["default"].createElement(BiMenu, {
3538
- className: "h-7 w-auto"
3539
- })));
3772
+ /* @__PURE__ */ React.createElement(BiMenu, { className: "h-7 w-auto" })
3773
+ ));
3540
3774
  };
3541
3775
  const SidebarLink = (props) => {
3542
3776
  const { to, label, Icon } = props;
3543
- return /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.NavLink, {
3544
- className: ({ isActive }) => {
3545
- return `text-base tracking-wide ${isActive ? "text-blue-600" : "text-gray-500"} hover:text-blue-600 flex items-center opacity-90 hover:opacity-100`;
3546
- },
3547
- onClick: props.onClick ? props.onClick : () => {
3777
+ return /* @__PURE__ */ React.createElement(
3778
+ reactRouterDom.NavLink,
3779
+ {
3780
+ className: ({ isActive }) => {
3781
+ return `text-base tracking-wide ${isActive ? "text-blue-600" : "text-gray-500"} hover:text-blue-600 flex items-center opacity-90 hover:opacity-100`;
3782
+ },
3783
+ onClick: props.onClick ? props.onClick : () => {
3784
+ },
3785
+ to
3548
3786
  },
3549
- to
3550
- }, /* @__PURE__ */ React__default["default"].createElement(Icon, {
3551
- className: "mr-2 h-6 opacity-80 w-auto"
3552
- }), " ", label);
3787
+ /* @__PURE__ */ React.createElement(Icon, { className: "mr-2 h-6 opacity-80 w-auto" }),
3788
+ " ",
3789
+ label
3790
+ );
3553
3791
  };
3554
3792
  const SidebarCloudLink = ({ config }) => {
3555
3793
  if (config.text) {
3556
- return /* @__PURE__ */ React__default["default"].createElement("span", {
3557
- className: "text-base tracking-wide text-gray-500 flex items-center opacity-90"
3558
- }, config.text, " ", /* @__PURE__ */ React__default["default"].createElement("a", {
3559
- target: "_blank",
3560
- className: "ml-1 text-blue-600 hover:opacity-60",
3561
- href: config.link.href
3562
- }, config.link.text));
3794
+ return /* @__PURE__ */ React.createElement("span", { className: "text-base tracking-wide text-gray-500 flex items-center opacity-90" }, config.text, " ", /* @__PURE__ */ React.createElement(
3795
+ "a",
3796
+ {
3797
+ target: "_blank",
3798
+ className: "ml-1 text-blue-600 hover:opacity-60",
3799
+ href: config.link.href
3800
+ },
3801
+ config.link.text
3802
+ ));
3563
3803
  }
3564
- return /* @__PURE__ */ React__default["default"].createElement("span", {
3565
- className: "text-base tracking-wide text-gray-500 hover:text-blue-600 flex items-center opacity-90 hover:opacity-100"
3566
- }, /* @__PURE__ */ React__default["default"].createElement(config.Icon, {
3567
- className: "mr-2 h-6 opacity-80 w-auto"
3568
- }), /* @__PURE__ */ React__default["default"].createElement("a", {
3569
- target: "_blank",
3570
- href: config.link.href
3571
- }, config.link.text));
3804
+ return /* @__PURE__ */ React.createElement("span", { className: "text-base tracking-wide text-gray-500 hover:text-blue-600 flex items-center opacity-90 hover:opacity-100" }, /* @__PURE__ */ React.createElement(config.Icon, { className: "mr-2 h-6 opacity-80 w-auto" }), /* @__PURE__ */ React.createElement("a", { target: "_blank", href: config.link.href }, config.link.text));
3572
3805
  };
3573
3806
  const GetCMS = ({ children }) => {
3574
3807
  try {
3575
3808
  const cms = toolkit.useCMS();
3576
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(cms));
3809
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children(cms));
3577
3810
  } catch (e) {
3578
3811
  return null;
3579
3812
  }
@@ -3585,54 +3818,45 @@ This will work when developing locally but NOT when deployed to production.
3585
3818
  message,
3586
3819
  children
3587
3820
  }) => {
3588
- return /* @__PURE__ */ React__default["default"].createElement("div", {
3589
- className: "h-screen w-full bg-gradient-to-b from-blue-900 to-gray-900 flex items-center justify-center px-4 py-6"
3590
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
3591
- className: "bg-white rounded-lg overflow-hidden shadow-lg w-full max-w-lg"
3592
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
3593
- className: "px-5 py-4 border-b border-gray-150"
3594
- }, /* @__PURE__ */ React__default["default"].createElement("h2", {
3595
- className: "text-2xl font-sans tracking-wide text-gray-700 flex items-center gap-0.5"
3596
- }, /* @__PURE__ */ React__default["default"].createElement("svg", {
3597
- viewBox: "0 0 32 32",
3598
- fill: "#EC4815",
3599
- xmlns: "http://www.w3.org/2000/svg",
3600
- className: "w-10 h-auto"
3601
- }, /* @__PURE__ */ React__default["default"].createElement("path", {
3602
- d: "M18.6466 14.5553C19.9018 13.5141 20.458 7.36086 21.0014 5.14903C21.5447 2.9372 23.7919 3.04938 23.7919 3.04938C23.7919 3.04938 23.2085 4.06764 23.4464 4.82751C23.6844 5.58738 25.3145 6.26662 25.3145 6.26662L24.9629 7.19622C24.9629 7.19622 24.2288 7.10204 23.7919 7.9785C23.355 8.85496 24.3392 17.4442 24.3392 17.4442C24.3392 17.4442 21.4469 22.7275 21.4469 24.9206C21.4469 27.1136 22.4819 28.9515 22.4819 28.9515H21.0296C21.0296 28.9515 18.899 26.4086 18.462 25.1378C18.0251 23.8669 18.1998 22.596 18.1998 22.596C18.1998 22.596 15.8839 22.4646 13.8303 22.596C11.7767 22.7275 10.4072 24.498 10.16 25.4884C9.91287 26.4787 9.81048 28.9515 9.81048 28.9515H8.66211C7.96315 26.7882 7.40803 26.0129 7.70918 24.9206C8.54334 21.8949 8.37949 20.1788 8.18635 19.4145C7.99321 18.6501 6.68552 17.983 6.68552 17.983C7.32609 16.6741 7.97996 16.0452 10.7926 15.9796C13.6052 15.914 17.3915 15.5965 18.6466 14.5553Z"
3603
- }), /* @__PURE__ */ React__default["default"].createElement("path", {
3604
- d: "M11.1268 24.7939C11.1268 24.7939 11.4236 27.5481 13.0001 28.9516H14.3511C13.0001 27.4166 12.8527 23.4155 12.8527 23.4155C12.1656 23.6399 11.3045 24.3846 11.1268 24.7939Z"
3605
- })), /* @__PURE__ */ React__default["default"].createElement("span", null, "Tina"))), message && /* @__PURE__ */ React__default["default"].createElement("div", {
3606
- className: "px-5 pt-4"
3607
- }, /* @__PURE__ */ React__default["default"].createElement("p", {
3608
- className: "text-base font-sans leading-normal"
3609
- }, message)), /* @__PURE__ */ React__default["default"].createElement("div", {
3610
- className: "px-5 py-4 flex gap-4 w-full justify-between"
3611
- }, children)));
3821
+ return /* @__PURE__ */ React.createElement("div", { className: "h-screen w-full bg-gradient-to-b from-blue-900 to-gray-900 flex items-center justify-center px-4 py-6" }, /* @__PURE__ */ React.createElement("div", { className: "bg-white rounded-lg overflow-hidden shadow-lg w-full max-w-lg" }, /* @__PURE__ */ React.createElement("div", { className: "px-5 py-4 border-b border-gray-150" }, /* @__PURE__ */ React.createElement("h2", { className: "text-2xl font-sans tracking-wide text-gray-700 flex items-center gap-0.5" }, /* @__PURE__ */ React.createElement(
3822
+ "svg",
3823
+ {
3824
+ viewBox: "0 0 32 32",
3825
+ fill: "#EC4815",
3826
+ xmlns: "http://www.w3.org/2000/svg",
3827
+ className: "w-10 h-auto"
3828
+ },
3829
+ /* @__PURE__ */ React.createElement("path", { d: "M18.6466 14.5553C19.9018 13.5141 20.458 7.36086 21.0014 5.14903C21.5447 2.9372 23.7919 3.04938 23.7919 3.04938C23.7919 3.04938 23.2085 4.06764 23.4464 4.82751C23.6844 5.58738 25.3145 6.26662 25.3145 6.26662L24.9629 7.19622C24.9629 7.19622 24.2288 7.10204 23.7919 7.9785C23.355 8.85496 24.3392 17.4442 24.3392 17.4442C24.3392 17.4442 21.4469 22.7275 21.4469 24.9206C21.4469 27.1136 22.4819 28.9515 22.4819 28.9515H21.0296C21.0296 28.9515 18.899 26.4086 18.462 25.1378C18.0251 23.8669 18.1998 22.596 18.1998 22.596C18.1998 22.596 15.8839 22.4646 13.8303 22.596C11.7767 22.7275 10.4072 24.498 10.16 25.4884C9.91287 26.4787 9.81048 28.9515 9.81048 28.9515H8.66211C7.96315 26.7882 7.40803 26.0129 7.70918 24.9206C8.54334 21.8949 8.37949 20.1788 8.18635 19.4145C7.99321 18.6501 6.68552 17.983 6.68552 17.983C7.32609 16.6741 7.97996 16.0452 10.7926 15.9796C13.6052 15.914 17.3915 15.5965 18.6466 14.5553Z" }),
3830
+ /* @__PURE__ */ React.createElement("path", { d: "M11.1268 24.7939C11.1268 24.7939 11.4236 27.5481 13.0001 28.9516H14.3511C13.0001 27.4166 12.8527 23.4155 12.8527 23.4155C12.1656 23.6399 11.3045 24.3846 11.1268 24.7939Z" })
3831
+ ), /* @__PURE__ */ React.createElement("span", null, "Tina"))), message && /* @__PURE__ */ React.createElement("div", { className: "px-5 pt-4" }, /* @__PURE__ */ React.createElement("p", { className: "text-base font-sans leading-normal" }, message)), /* @__PURE__ */ React.createElement("div", { className: "px-5 py-4 flex gap-4 w-full justify-between" }, children)));
3612
3832
  };
3613
3833
  const LoginPage = () => {
3614
3834
  const { setEdit } = sharedctx.useEditState();
3615
3835
  const login = () => setEdit(true);
3616
- return /* @__PURE__ */ React__default["default"].createElement(AuthTemplate, null, /* @__PURE__ */ React__default["default"].createElement("div", {
3617
- className: "flex w-full flex-1 gap-4 items-center justify-end"
3618
- }, /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
3619
- onClick: () => {
3620
- window.location.href = "/";
3836
+ return /* @__PURE__ */ React.createElement(AuthTemplate, null, /* @__PURE__ */ React.createElement("div", { className: "flex w-full flex-1 gap-4 items-center justify-end" }, /* @__PURE__ */ React.createElement(
3837
+ toolkit.Button,
3838
+ {
3839
+ onClick: () => {
3840
+ window.location.href = "/";
3841
+ },
3842
+ variant: "white",
3843
+ size: "custom",
3844
+ className: "text-base h-12 px-6 flex-shrink-0 flex-grow-0"
3621
3845
  },
3622
- variant: "white",
3623
- size: "custom",
3624
- className: "text-base h-12 px-6 flex-shrink-0 flex-grow-0"
3625
- }, /* @__PURE__ */ React__default["default"].createElement(MdOutlineArrowBack, {
3626
- className: "w-6 h-auto mr-1.5 opacity-80"
3627
- }), " Back To Site"), /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
3628
- onClick: () => login(),
3629
- variant: "primary",
3630
- size: "custom",
3631
- className: "text-base h-12 px-6 flex-1",
3632
- type: "submit"
3633
- }, /* @__PURE__ */ React__default["default"].createElement(BiLogIn, {
3634
- className: "w-6 h-auto mr-2 opacity-80"
3635
- }), " Edit With Tina")));
3846
+ /* @__PURE__ */ React.createElement(MdOutlineArrowBack, { className: "w-6 h-auto mr-1.5 opacity-80" }),
3847
+ " Back To Site"
3848
+ ), /* @__PURE__ */ React.createElement(
3849
+ toolkit.Button,
3850
+ {
3851
+ onClick: () => login(),
3852
+ variant: "primary",
3853
+ size: "custom",
3854
+ className: "text-base h-12 px-6 flex-1",
3855
+ type: "submit"
3856
+ },
3857
+ /* @__PURE__ */ React.createElement(BiLogIn, { className: "w-6 h-auto mr-2 opacity-80" }),
3858
+ " Edit With Tina"
3859
+ )));
3636
3860
  };
3637
3861
  const LogoutRedirect = () => {
3638
3862
  const cms = toolkit.useCMS();
@@ -3654,33 +3878,37 @@ This will work when developing locally but NOT when deployed to production.
3654
3878
  window.location.href = slug;
3655
3879
  });
3656
3880
  }, []);
3657
- return /* @__PURE__ */ React__default["default"].createElement("div", null, "Redirecting to ", slug, " ...");
3881
+ return /* @__PURE__ */ React.createElement("div", null, "Redirecting to ", slug, " ...");
3658
3882
  };
3659
3883
  const logout = () => {
3660
3884
  sharedctx.setEditing(false);
3661
3885
  window.location.href = "/";
3662
3886
  };
3663
3887
  const LogoutPage = () => {
3664
- return /* @__PURE__ */ React__default["default"].createElement(AuthTemplate, null, /* @__PURE__ */ React__default["default"].createElement("div", {
3665
- className: "flex w-full flex-1 gap-4 items-center justify-end"
3666
- }, /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
3667
- onClick: () => {
3668
- window.location.href = "/";
3888
+ return /* @__PURE__ */ React.createElement(AuthTemplate, null, /* @__PURE__ */ React.createElement("div", { className: "flex w-full flex-1 gap-4 items-center justify-end" }, /* @__PURE__ */ React.createElement(
3889
+ toolkit.Button,
3890
+ {
3891
+ onClick: () => {
3892
+ window.location.href = "/";
3893
+ },
3894
+ variant: "white",
3895
+ size: "custom",
3896
+ className: "text-base h-12 px-6 flex-shrink-0 flex-grow-0"
3897
+ },
3898
+ /* @__PURE__ */ React.createElement(MdOutlineArrowBack, { className: "w-6 h-auto mr-1.5 opacity-80" }),
3899
+ " Back To Site"
3900
+ ), /* @__PURE__ */ React.createElement(
3901
+ toolkit.Button,
3902
+ {
3903
+ onClick: () => logout(),
3904
+ type: "submit",
3905
+ variant: "primary",
3906
+ size: "custom",
3907
+ className: "text-base h-12 px-6 flex-1"
3669
3908
  },
3670
- variant: "white",
3671
- size: "custom",
3672
- className: "text-base h-12 px-6 flex-shrink-0 flex-grow-0"
3673
- }, /* @__PURE__ */ React__default["default"].createElement(MdOutlineArrowBack, {
3674
- className: "w-6 h-auto mr-1.5 opacity-80"
3675
- }), " Back To Site"), /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
3676
- onClick: () => logout(),
3677
- type: "submit",
3678
- variant: "primary",
3679
- size: "custom",
3680
- className: "text-base h-12 px-6 flex-1"
3681
- }, /* @__PURE__ */ React__default["default"].createElement(BiLogOut, {
3682
- className: "w-6 h-auto mr-1.5 opacity-80"
3683
- }), " Log Out of Tina")));
3909
+ /* @__PURE__ */ React.createElement(BiLogOut, { className: "w-6 h-auto mr-1.5 opacity-80" }),
3910
+ " Log Out of Tina"
3911
+ )));
3684
3912
  };
3685
3913
  const PageWrapper = ({
3686
3914
  children
@@ -3688,172 +3916,153 @@ This will work when developing locally but NOT when deployed to production.
3688
3916
  var _a, _b;
3689
3917
  const cms = toolkit.useCMS();
3690
3918
  const isLocalMode = (_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode;
3691
- const [branchingEnabled, setBranchingEnabled] = React__default["default"].useState(() => cms.flags.get("branch-switcher"));
3692
- React__default["default"].useEffect(() => {
3919
+ const [branchingEnabled, setBranchingEnabled] = React.useState(
3920
+ () => cms.flags.get("branch-switcher")
3921
+ );
3922
+ React.useEffect(() => {
3693
3923
  cms.events.subscribe("flag:set", ({ key, value }) => {
3694
3924
  if (key === "branch-switcher") {
3695
3925
  setBranchingEnabled(value);
3696
3926
  }
3697
3927
  });
3698
3928
  }, [cms.events]);
3699
- return /* @__PURE__ */ React__default["default"].createElement("div", {
3700
- className: "relative left-0 w-full h-full bg-gradient-to-b from-gray-50/50 to-gray-50 shadow-2xl overflow-y-auto transition-opacity duration-300 ease-out flex flex-col opacity-100"
3701
- }, branchingEnabled && !isLocalMode && /* @__PURE__ */ React__default["default"].createElement(toolkit.BranchBanner, null), children);
3929
+ return /* @__PURE__ */ React.createElement("div", { className: "relative left-0 w-full h-full bg-gradient-to-b from-gray-50/50 to-gray-50 shadow-2xl overflow-y-auto transition-opacity duration-300 ease-out flex flex-col opacity-100" }, branchingEnabled && !isLocalMode && /* @__PURE__ */ React.createElement(toolkit.BranchBanner, null), children);
3702
3930
  };
3703
3931
  const PageHeader = ({
3704
3932
  isLocalMode,
3705
3933
  children
3706
3934
  }) => {
3707
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, isLocalMode && /* @__PURE__ */ React__default["default"].createElement(toolkit.LocalWarning, null), !isLocalMode && /* @__PURE__ */ React__default["default"].createElement(toolkit.BillingWarning, null), /* @__PURE__ */ React__default["default"].createElement("div", {
3708
- className: "pt-12 px-12"
3709
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
3710
- className: "w-full mx-auto max-w-screen-xl"
3711
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
3712
- className: "w-full flex justify-between items-end"
3713
- }, children))));
3935
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, isLocalMode && /* @__PURE__ */ React.createElement(toolkit.LocalWarning, null), !isLocalMode && /* @__PURE__ */ React.createElement(toolkit.BillingWarning, null), /* @__PURE__ */ React.createElement("div", { className: "pt-12 px-12" }, /* @__PURE__ */ React.createElement("div", { className: "w-full mx-auto max-w-screen-xl" }, /* @__PURE__ */ React.createElement("div", { className: "w-full flex justify-between items-end" }, children))));
3714
3936
  };
3715
3937
  const PageBody = ({
3716
3938
  children
3717
- }) => /* @__PURE__ */ React__default["default"].createElement("div", {
3718
- className: "py-8 px-12"
3719
- }, children);
3939
+ }) => /* @__PURE__ */ React.createElement("div", { className: "py-8 px-12" }, children);
3720
3940
  const PageBodyNarrow = ({
3721
3941
  children
3722
- }) => /* @__PURE__ */ React__default["default"].createElement("div", {
3723
- className: "py-10 px-12"
3724
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
3725
- className: "w-full mx-auto max-w-screen-xl"
3726
- }, children));
3942
+ }) => /* @__PURE__ */ React.createElement("div", { className: "py-10 px-12" }, /* @__PURE__ */ React.createElement("div", { className: "w-full mx-auto max-w-screen-xl" }, children));
3727
3943
  const DashboardPage = () => {
3728
- return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => {
3944
+ return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => {
3729
3945
  var _a, _b;
3730
- return /* @__PURE__ */ React__default["default"].createElement(PageWrapper, null, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement(PageHeader, {
3731
- isLocalMode: (_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode
3732
- }, /* @__PURE__ */ React__default["default"].createElement("h3", {
3733
- className: "text-2xl font-sans text-gray-700"
3734
- }, "Welcome to Tina!")), /* @__PURE__ */ React__default["default"].createElement(PageBodyNarrow, null, "This is your dashboard for editing or creating content. Select a collection on the left to begin.")));
3946
+ return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PageHeader, { isLocalMode: (_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode }, /* @__PURE__ */ React.createElement("h3", { className: "text-2xl font-sans text-gray-700" }, "Welcome to Tina!")), /* @__PURE__ */ React.createElement(PageBodyNarrow, null, "This is your dashboard for editing or creating content. Select a collection on the left to begin.")));
3735
3947
  });
3736
3948
  };
3737
3949
  function RiHome2Line(props) {
3738
3950
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "g", "attr": {}, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0z" } }, { "tag": "path", "attr": { "d": "M19 21H5a1 1 0 0 1-1-1v-9H1l10.327-9.388a1 1 0 0 1 1.346 0L23 11h-3v9a1 1 0 0 1-1 1zM6 19h12V9.157l-6-5.454-6 5.454V19z" } }] }] })(props);
3739
3951
  }
3740
- const LoadingPage = () => /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("div", {
3741
- style: {
3742
- position: "absolute",
3743
- top: 0,
3744
- left: 0,
3745
- width: "100%",
3746
- height: "100%",
3747
- zIndex: 200,
3748
- opacity: "0.8",
3749
- display: "flex",
3750
- alignItems: "start",
3751
- justifyContent: "center",
3752
- padding: "120px 40px 40px 40px"
3753
- }
3754
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
3755
- style: {
3756
- background: "#FFF",
3757
- border: "1px solid #EDECF3",
3758
- boxShadow: "0px 2px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.1)",
3759
- borderRadius: "8px",
3760
- padding: "32px 24px",
3761
- width: "460px",
3762
- maxWidth: "90%",
3763
- display: "flex",
3764
- alignItems: "center",
3765
- justifyContent: "center",
3766
- flexDirection: "column"
3767
- }
3768
- }, /* @__PURE__ */ React__default["default"].createElement("svg", {
3769
- style: {
3770
- width: "64px",
3771
- color: "#2296fe",
3772
- marginTop: "-8px",
3773
- marginBottom: "16px"
3952
+ const LoadingPage = () => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
3953
+ "div",
3954
+ {
3955
+ style: {
3956
+ position: "absolute",
3957
+ top: 0,
3958
+ left: 0,
3959
+ width: "100%",
3960
+ height: "100%",
3961
+ zIndex: 200,
3962
+ opacity: "0.8",
3963
+ display: "flex",
3964
+ alignItems: "start",
3965
+ justifyContent: "center",
3966
+ padding: "120px 40px 40px 40px"
3967
+ }
3774
3968
  },
3775
- version: "1.1",
3776
- id: "L5",
3777
- xmlns: "http://www.w3.org/2000/svg",
3778
- xmlnsXlink: "http://www.w3.org/1999/xlink",
3779
- x: "0px",
3780
- y: "0px",
3781
- viewBox: "0 0 100 64",
3782
- enableBackground: "new 0 0 0 0",
3783
- xmlSpace: "preserve"
3784
- }, /* @__PURE__ */ React__default["default"].createElement("circle", {
3785
- fill: "currentColor",
3786
- stroke: "none",
3787
- cx: 6,
3788
- cy: 32,
3789
- r: 6
3790
- }, /* @__PURE__ */ React__default["default"].createElement("animateTransform", {
3791
- attributeName: "transform",
3792
- dur: "1s",
3793
- type: "translate",
3794
- values: "0 15 ; 0 -15; 0 15",
3795
- calcMode: "spline",
3796
- keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
3797
- repeatCount: "indefinite",
3798
- begin: "0.1"
3799
- })), /* @__PURE__ */ React__default["default"].createElement("circle", {
3800
- fill: "currentColor",
3801
- stroke: "none",
3802
- cx: 30,
3803
- cy: 32,
3804
- r: 6
3805
- }, /* @__PURE__ */ React__default["default"].createElement("animateTransform", {
3806
- attributeName: "transform",
3807
- dur: "1s",
3808
- type: "translate",
3809
- values: "0 15 ; 0 -10; 0 15",
3810
- calcMode: "spline",
3811
- keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
3812
- repeatCount: "indefinite",
3813
- begin: "0.2"
3814
- })), /* @__PURE__ */ React__default["default"].createElement("circle", {
3815
- fill: "currentColor",
3816
- stroke: "none",
3817
- cx: 54,
3818
- cy: 32,
3819
- r: 6
3820
- }, /* @__PURE__ */ React__default["default"].createElement("animateTransform", {
3821
- attributeName: "transform",
3822
- dur: "1s",
3823
- type: "translate",
3824
- values: "0 15 ; 0 -5; 0 15",
3825
- calcMode: "spline",
3826
- keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
3827
- repeatCount: "indefinite",
3828
- begin: "0.3"
3829
- }))), /* @__PURE__ */ React__default["default"].createElement("p", {
3830
- style: {
3831
- fontSize: "16px",
3832
- color: "#716c7f",
3833
- textAlign: "center",
3834
- lineHeight: "1.3",
3835
- fontFamily: "'Inter', sans-serif",
3836
- fontWeight: "normal"
3837
- }
3838
- }, "Please wait, Tina is loading data..."))));
3969
+ /* @__PURE__ */ React.createElement(
3970
+ "div",
3971
+ {
3972
+ style: {
3973
+ background: "#FFF",
3974
+ border: "1px solid #EDECF3",
3975
+ boxShadow: "0px 2px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.1)",
3976
+ borderRadius: "8px",
3977
+ padding: "32px 24px",
3978
+ width: "460px",
3979
+ maxWidth: "90%",
3980
+ display: "flex",
3981
+ alignItems: "center",
3982
+ justifyContent: "center",
3983
+ flexDirection: "column"
3984
+ }
3985
+ },
3986
+ /* @__PURE__ */ React.createElement(
3987
+ "svg",
3988
+ {
3989
+ style: {
3990
+ width: "64px",
3991
+ color: "#2296fe",
3992
+ marginTop: "-8px",
3993
+ marginBottom: "16px"
3994
+ },
3995
+ version: "1.1",
3996
+ id: "L5",
3997
+ xmlns: "http://www.w3.org/2000/svg",
3998
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
3999
+ x: "0px",
4000
+ y: "0px",
4001
+ viewBox: "0 0 100 64",
4002
+ enableBackground: "new 0 0 0 0",
4003
+ xmlSpace: "preserve"
4004
+ },
4005
+ /* @__PURE__ */ React.createElement("circle", { fill: "currentColor", stroke: "none", cx: 6, cy: 32, r: 6 }, /* @__PURE__ */ React.createElement(
4006
+ "animateTransform",
4007
+ {
4008
+ attributeName: "transform",
4009
+ dur: "1s",
4010
+ type: "translate",
4011
+ values: "0 15 ; 0 -15; 0 15",
4012
+ calcMode: "spline",
4013
+ keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
4014
+ repeatCount: "indefinite",
4015
+ begin: "0.1"
4016
+ }
4017
+ )),
4018
+ /* @__PURE__ */ React.createElement("circle", { fill: "currentColor", stroke: "none", cx: 30, cy: 32, r: 6 }, /* @__PURE__ */ React.createElement(
4019
+ "animateTransform",
4020
+ {
4021
+ attributeName: "transform",
4022
+ dur: "1s",
4023
+ type: "translate",
4024
+ values: "0 15 ; 0 -10; 0 15",
4025
+ calcMode: "spline",
4026
+ keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
4027
+ repeatCount: "indefinite",
4028
+ begin: "0.2"
4029
+ }
4030
+ )),
4031
+ /* @__PURE__ */ React.createElement("circle", { fill: "currentColor", stroke: "none", cx: 54, cy: 32, r: 6 }, /* @__PURE__ */ React.createElement(
4032
+ "animateTransform",
4033
+ {
4034
+ attributeName: "transform",
4035
+ dur: "1s",
4036
+ type: "translate",
4037
+ values: "0 15 ; 0 -5; 0 15",
4038
+ calcMode: "spline",
4039
+ keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
4040
+ repeatCount: "indefinite",
4041
+ begin: "0.3"
4042
+ }
4043
+ ))
4044
+ ),
4045
+ /* @__PURE__ */ React.createElement(
4046
+ "p",
4047
+ {
4048
+ style: {
4049
+ fontSize: "16px",
4050
+ color: "#716c7f",
4051
+ textAlign: "center",
4052
+ lineHeight: "1.3",
4053
+ fontFamily: "'Inter', sans-serif",
4054
+ fontWeight: "normal"
4055
+ }
4056
+ },
4057
+ "Please wait, Tina is loading data..."
4058
+ )
4059
+ )
4060
+ ));
3839
4061
  const FullscreenError = ({
3840
4062
  title = "Error",
3841
4063
  errorMessage = "It looks like something went wrong."
3842
4064
  }) => {
3843
- return /* @__PURE__ */ React__default["default"].createElement("div", {
3844
- className: "flex flex-col justify-center items-center h-screen bg-gray-100"
3845
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
3846
- className: "text-red-500 text-4xl mb-6 flex items-center"
3847
- }, /* @__PURE__ */ React__default["default"].createElement(BiError, {
3848
- className: "w-12 h-auto fill-current text-red-400 opacity-70 mr-1"
3849
- }), " ", title), /* @__PURE__ */ React__default["default"].createElement("p", {
3850
- className: "text-gray-700 text-xl mb-8"
3851
- }, errorMessage), /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
3852
- variant: "danger",
3853
- onClick: () => window.location.reload()
3854
- }, /* @__PURE__ */ React__default["default"].createElement(BiSync, {
3855
- className: "w-7 h-auto fill-current opacity-70 mr-1"
3856
- }), " Reload"));
4065
+ return /* @__PURE__ */ React.createElement("div", { className: "flex flex-col justify-center items-center h-screen bg-gray-100" }, /* @__PURE__ */ React.createElement("div", { className: "text-red-500 text-4xl mb-6 flex items-center" }, /* @__PURE__ */ React.createElement(BiError, { className: "w-12 h-auto fill-current text-red-400 opacity-70 mr-1" }), " ", title), /* @__PURE__ */ React.createElement("p", { className: "text-gray-700 text-xl mb-8" }, errorMessage), /* @__PURE__ */ React.createElement(toolkit.Button, { variant: "danger", onClick: () => window.location.reload() }, /* @__PURE__ */ React.createElement(BiSync, { className: "w-7 h-auto fill-current opacity-70 mr-1" }), " Reload"));
3857
4066
  };
3858
4067
  const useGetCollection = (cms, collectionName, includeDocuments = true, folder, after = "", sortKey, filterArgs) => {
3859
4068
  const api = new TinaAdminApi(cms);
@@ -3871,10 +4080,20 @@ This will work when developing locally but NOT when deployed to production.
3871
4080
  const { name, order } = JSON.parse(sortKey || "{}");
3872
4081
  const validSortKey = ((_a = collectionExtra.fields) == null ? void 0 : _a.map((x) => x.name).includes(name)) ? name : void 0;
3873
4082
  try {
3874
- const collection2 = await api.fetchCollection(collectionName, includeDocuments, (filterArgs == null ? void 0 : filterArgs.filterField) ? "" : folder.fullyQualifiedName, after, validSortKey, order, filterArgs);
4083
+ const collection2 = await api.fetchCollection(
4084
+ collectionName,
4085
+ includeDocuments,
4086
+ (filterArgs == null ? void 0 : filterArgs.filterField) ? "" : folder.fullyQualifiedName,
4087
+ after,
4088
+ validSortKey,
4089
+ order,
4090
+ filterArgs
4091
+ );
3875
4092
  setCollection(collection2);
3876
4093
  } catch (error2) {
3877
- cms.alerts.error(`[${error2.name}] GetCollection failed: ${error2.message}`);
4094
+ cms.alerts.error(
4095
+ `[${error2.name}] GetCollection failed: ${error2.message}`
4096
+ );
3878
4097
  console.error(error2);
3879
4098
  setCollection(void 0);
3880
4099
  setError(error2);
@@ -3914,14 +4133,19 @@ This will work when developing locally but NOT when deployed to production.
3914
4133
  const searchCollection = async () => {
3915
4134
  if (await api.isAuthenticated() && !folder.loading && !cancelled) {
3916
4135
  try {
3917
- const response = await cms.api.search.query(`${search} AND _collection:${collectionName}`, {
3918
- limit: 15,
3919
- cursor: after
3920
- });
3921
- const docs = await Promise.allSettled(response.results.map((result) => {
3922
- const [collection2, relativePath2] = result._id.split(":");
3923
- return api.fetchDocument(collection2, relativePath2, false);
3924
- }));
4136
+ const response = await cms.api.search.query(
4137
+ `${search} AND _collection:${collectionName}`,
4138
+ {
4139
+ limit: 15,
4140
+ cursor: after
4141
+ }
4142
+ );
4143
+ const docs = await Promise.allSettled(
4144
+ response.results.map((result) => {
4145
+ const [collection2, relativePath2] = result._id.split(":");
4146
+ return api.fetchDocument(collection2, relativePath2, false);
4147
+ })
4148
+ );
3925
4149
  const edges = docs.filter((p) => {
3926
4150
  var _a;
3927
4151
  return p.status === "fulfilled" && !!((_a = p.value) == null ? void 0 : _a.document);
@@ -3943,7 +4167,9 @@ This will work when developing locally but NOT when deployed to production.
3943
4167
  }
3944
4168
  });
3945
4169
  } catch (error2) {
3946
- cms.alerts.error(`[${error2.name}] GetCollection failed: ${error2.message}`);
4170
+ cms.alerts.error(
4171
+ `[${error2.name}] GetCollection failed: ${error2.message}`
4172
+ );
3947
4173
  console.error(error2);
3948
4174
  setCollection(void 0);
3949
4175
  setError(error2);
@@ -3982,27 +4208,52 @@ This will work when developing locally but NOT when deployed to production.
3982
4208
  search
3983
4209
  }) => {
3984
4210
  const navigate = reactRouterDom.useNavigate();
3985
- const { collection, loading, error, reFetchCollection, collectionExtra } = search ? useSearchCollection(cms, collectionName, includeDocuments, folder, startCursor || "", search) : useGetCollection(cms, collectionName, includeDocuments, folder, startCursor || "", sortKey, filterArgs) || {};
4211
+ const { collection, loading, error, reFetchCollection, collectionExtra } = search ? useSearchCollection(
4212
+ cms,
4213
+ collectionName,
4214
+ includeDocuments,
4215
+ folder,
4216
+ startCursor || "",
4217
+ search
4218
+ ) : useGetCollection(
4219
+ cms,
4220
+ collectionName,
4221
+ includeDocuments,
4222
+ folder,
4223
+ startCursor || "",
4224
+ sortKey,
4225
+ filterArgs
4226
+ ) || {};
3986
4227
  React.useEffect(() => {
3987
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
4228
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
3988
4229
  if (loading)
3989
4230
  return;
3990
- const collectionDefinition = cms.api.tina.schema.getCollection(collection.name);
3991
- const allowCreate = (_c = (_b = (_a = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _a.allowedActions) == null ? void 0 : _b.create) != null ? _c : true;
3992
- const allowDelete = (_f = (_e = (_d = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _d.allowedActions) == null ? void 0 : _e.delete) != null ? _f : true;
4231
+ const collectionDefinition = cms.api.tina.schema.getCollection(
4232
+ collection.name
4233
+ );
4234
+ const allowCreate = ((_b = (_a = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _a.allowedActions) == null ? void 0 : _b.create) ?? true;
4235
+ const allowDelete = ((_d = (_c = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _c.allowedActions) == null ? void 0 : _d.delete) ?? true;
3993
4236
  const collectionResponse = collection;
3994
- if (!allowCreate && !allowDelete && ((_h = (_g = collectionResponse.documents) == null ? void 0 : _g.edges) == null ? void 0 : _h.length) === 1 && ((_k = (_j = (_i = collectionResponse.documents) == null ? void 0 : _i.edges[0]) == null ? void 0 : _j.node) == null ? void 0 : _k.__typename) !== "Folder") {
4237
+ if (!allowCreate && !allowDelete && // Check there is only one document
4238
+ ((_f = (_e = collectionResponse.documents) == null ? void 0 : _e.edges) == null ? void 0 : _f.length) === 1 && // Check to make sure the file is not a folder
4239
+ ((_i = (_h = (_g = collectionResponse.documents) == null ? void 0 : _g.edges[0]) == null ? void 0 : _h.node) == null ? void 0 : _i.__typename) !== "Folder") {
3995
4240
  const doc = collectionResponse.documents.edges[0].node;
3996
- handleNavigate(navigate, cms, collectionResponse, collectionDefinition, doc);
4241
+ handleNavigate(
4242
+ navigate,
4243
+ cms,
4244
+ collectionResponse,
4245
+ collectionDefinition,
4246
+ doc
4247
+ );
3997
4248
  }
3998
4249
  }, [(collection == null ? void 0 : collection.name) || "", loading]);
3999
4250
  if (error) {
4000
- return /* @__PURE__ */ React__default["default"].createElement(FullscreenError, null);
4251
+ return /* @__PURE__ */ React.createElement(FullscreenError, null);
4001
4252
  }
4002
4253
  if (loading) {
4003
- return /* @__PURE__ */ React__default["default"].createElement(LoadingPage, null);
4254
+ return /* @__PURE__ */ React.createElement(LoadingPage, null);
4004
4255
  }
4005
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(collection, loading, reFetchCollection, collectionExtra));
4256
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collection, loading, reFetchCollection, collectionExtra));
4006
4257
  };
4007
4258
  const folderRegex = /^.*\/~\/*(.*)$/;
4008
4259
  const parentFolder = (folder) => {
@@ -4048,43 +4299,38 @@ This will work when developing locally but NOT when deployed to production.
4048
4299
  folder,
4049
4300
  collectionName
4050
4301
  }) => {
4051
- return /* @__PURE__ */ React__default["default"].createElement(react.Menu, {
4052
- as: "div",
4053
- className: "relative inline-block text-left"
4054
- }, () => /* @__PURE__ */ React__default["default"].createElement("div", null, /* @__PURE__ */ React__default["default"].createElement("div", null, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Button, {
4055
- className: "icon-parent inline-flex items-center font-medium focus:outline-none focus:ring-2 focus:shadow-outline text-center rounded-full justify-center transition-all duration-150 ease-out shadow text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 text-sm h-10 px-6"
4056
- }, "Create New ", /* @__PURE__ */ React__default["default"].createElement(BiPlus, {
4057
- className: "w-5 h-full ml-1 opacity-70"
4058
- }))), /* @__PURE__ */ React__default["default"].createElement(react.Transition, {
4059
- as: React.Fragment,
4060
- enter: "transition ease-out duration-100",
4061
- enterFrom: "transform opacity-0 scale-95",
4062
- enterTo: "transform opacity-100 scale-100",
4063
- leave: "transition ease-in duration-75",
4064
- leaveFrom: "transform opacity-100 scale-100",
4065
- leaveTo: "transform opacity-0 scale-95"
4066
- }, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Items, {
4067
- className: "origin-top-right absolute right-0 mt-2 z-menu w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none"
4068
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
4069
- className: "py-1"
4070
- }, templates.map((template) => /* @__PURE__ */ React__default["default"].createElement(react.Menu.Item, {
4071
- key: `${template.label}-${template.name}`
4072
- }, ({ active }) => /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
4073
- to: `/${folder.fullyQualifiedName ? [
4074
- "collections",
4075
- "new",
4076
- collectionName,
4077
- template.name,
4078
- "~",
4079
- folder.name
4080
- ].join("/") : [
4081
- "collections",
4082
- "new",
4083
- collectionName,
4084
- template.name
4085
- ].join("/")}`,
4086
- className: `w-full text-md px-4 py-2 tracking-wide flex items-center transition ease-out duration-100 ${active ? "text-blue-600 opacity-100 bg-gray-50" : "opacity-80 text-gray-600"}`
4087
- }, template.label))))))));
4302
+ return /* @__PURE__ */ React.createElement(react.Menu, { as: "div", className: "relative inline-block text-left" }, () => /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(react.Menu.Button, { className: "icon-parent inline-flex items-center font-medium focus:outline-none focus:ring-2 focus:shadow-outline text-center rounded-full justify-center transition-all duration-150 ease-out shadow text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 text-sm h-10 px-6" }, "Create New ", /* @__PURE__ */ React.createElement(BiPlus, { className: "w-5 h-full ml-1 opacity-70" }))), /* @__PURE__ */ React.createElement(
4303
+ react.Transition,
4304
+ {
4305
+ as: React.Fragment,
4306
+ enter: "transition ease-out duration-100",
4307
+ enterFrom: "transform opacity-0 scale-95",
4308
+ enterTo: "transform opacity-100 scale-100",
4309
+ leave: "transition ease-in duration-75",
4310
+ leaveFrom: "transform opacity-100 scale-100",
4311
+ leaveTo: "transform opacity-0 scale-95"
4312
+ },
4313
+ /* @__PURE__ */ React.createElement(react.Menu.Items, { className: "origin-top-right absolute right-0 mt-2 z-menu w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none" }, /* @__PURE__ */ React.createElement("div", { className: "py-1" }, templates.map((template) => /* @__PURE__ */ React.createElement(react.Menu.Item, { key: `${template.label}-${template.name}` }, ({ active }) => /* @__PURE__ */ React.createElement(
4314
+ reactRouterDom.Link,
4315
+ {
4316
+ to: `/${folder.fullyQualifiedName ? [
4317
+ "collections",
4318
+ "new",
4319
+ collectionName,
4320
+ template.name,
4321
+ "~",
4322
+ folder.name
4323
+ ].join("/") : [
4324
+ "collections",
4325
+ "new",
4326
+ collectionName,
4327
+ template.name
4328
+ ].join("/")}`,
4329
+ className: `w-full text-md px-4 py-2 tracking-wide flex items-center transition ease-out duration-100 ${active ? "text-blue-600 opacity-100 bg-gray-50" : "opacity-80 text-gray-600"}`
4330
+ },
4331
+ template.label
4332
+ )))))
4333
+ )));
4088
4334
  };
4089
4335
  const handleNavigate = (navigate, cms, collection, collectionDefinition, document) => {
4090
4336
  var _a, _b;
@@ -4103,15 +4349,18 @@ This will work when developing locally but NOT when deployed to production.
4103
4349
  return null;
4104
4350
  } else {
4105
4351
  const pathToDoc = document._sys.breadcrumbs;
4106
- navigate(`/${["collections", "edit", collection.name, ...pathToDoc].join("/")}`, { replace: true });
4352
+ navigate(
4353
+ `/${["collections", "edit", collection.name, ...pathToDoc].join("/")}`,
4354
+ { replace: true }
4355
+ );
4107
4356
  }
4108
4357
  };
4109
4358
  const CollectionListPage = () => {
4110
4359
  const navigate = reactRouterDom.useNavigate();
4111
4360
  const { collectionName } = reactRouterDom.useParams();
4112
- const [deleteModalOpen, setDeleteModalOpen] = React__default["default"].useState(false);
4113
- const [renameModalOpen, setRenameModalOpen] = React__default["default"].useState(false);
4114
- const [vars, setVars] = React__default["default"].useState({
4361
+ const [deleteModalOpen, setDeleteModalOpen] = React.useState(false);
4362
+ const [renameModalOpen, setRenameModalOpen] = React.useState(false);
4363
+ const [vars, setVars] = React.useState({
4115
4364
  collection: collectionName,
4116
4365
  relativePath: "",
4117
4366
  newRelativePath: "",
@@ -4124,10 +4373,13 @@ This will work when developing locally but NOT when deployed to production.
4124
4373
  });
4125
4374
  const [endCursor, setEndCursor] = React.useState("");
4126
4375
  const [prevCursors, setPrevCursors] = React.useState([]);
4127
- const [sortKey, setSortKey] = React.useState(isSSR ? "" : window.localStorage.getItem(`${LOCAL_STORAGE_KEY}.${collectionName}`) || JSON.stringify({
4128
- order: "asc",
4129
- name: ""
4130
- }));
4376
+ const [sortKey, setSortKey] = React.useState(
4377
+ // set sort key to cached value if it exists
4378
+ isSSR ? "" : window.localStorage.getItem(`${LOCAL_STORAGE_KEY}.${collectionName}`) || JSON.stringify({
4379
+ order: "asc",
4380
+ name: ""
4381
+ })
4382
+ );
4131
4383
  const [search, setSearch] = React.useState("");
4132
4384
  const [searchInput, setSearchInput] = React.useState("");
4133
4385
  const { order = "asc", name: sortName } = JSON.parse(sortKey || "{}");
@@ -4135,10 +4387,12 @@ This will work when developing locally but NOT when deployed to production.
4135
4387
  const loc = reactRouterDom.useLocation();
4136
4388
  const folder = useCollectionFolder();
4137
4389
  React.useEffect(() => {
4138
- setSortKey(window.localStorage.getItem(`${LOCAL_STORAGE_KEY}.${collectionName}`) || JSON.stringify({
4139
- order: "asc",
4140
- name: ""
4141
- }));
4390
+ setSortKey(
4391
+ window.localStorage.getItem(`${LOCAL_STORAGE_KEY}.${collectionName}`) || JSON.stringify({
4392
+ order: "asc",
4393
+ name: ""
4394
+ })
4395
+ );
4142
4396
  setEndCursor("");
4143
4397
  setPrevCursors([]);
4144
4398
  setSearch("");
@@ -4158,378 +4412,413 @@ This will work when developing locally but NOT when deployed to production.
4158
4412
  booleanEquals: null
4159
4413
  }));
4160
4414
  }, [collectionName]);
4161
- return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => {
4162
- return /* @__PURE__ */ React__default["default"].createElement(PageWrapper, null, /* @__PURE__ */ React__default["default"].createElement(GetCollection, {
4163
- cms,
4164
- collectionName,
4165
- includeDocuments: true,
4166
- startCursor: endCursor,
4167
- sortKey,
4168
- folder,
4169
- filterArgs: collectionName === vars.collection ? vars : {
4170
- collection: collectionName,
4171
- relativePath: "",
4172
- newRelativePath: "",
4173
- filterField: "",
4174
- startsWith: "",
4175
- endsWith: "",
4176
- before: "",
4177
- after: "",
4178
- booleanEquals: null
4179
- },
4180
- search
4181
- }, (collection, _loading, reFetchCollection, collectionExtra) => {
4182
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
4183
- collection.documents.totalCount;
4184
- const documents = collection.documents.edges;
4185
- const admin = cms.api.admin;
4186
- const pageInfo = collection.documents.pageInfo;
4187
- const fields = (_a = collectionExtra.fields) == null ? void 0 : _a.filter((x) => ["string", "number", "datetime", "boolean"].includes(x.type));
4188
- const sortField = fields == null ? void 0 : fields.find((field) => field.name === sortName);
4189
- const searchEnabled = !!((_d = (_c = (_b = cms.api.tina.schema) == null ? void 0 : _b.config) == null ? void 0 : _c.config) == null ? void 0 : _d.search);
4190
- const collectionDefinition = cms.api.tina.schema.getCollection(collection.name);
4191
- const allowCreate = (_g = (_f = (_e = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _e.allowedActions) == null ? void 0 : _f.create) != null ? _g : true;
4192
- const allowDelete = (_j = (_i = (_h = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _h.allowedActions) == null ? void 0 : _i.delete) != null ? _j : true;
4193
- const folderView = folder.fullyQualifiedName !== "";
4194
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, deleteModalOpen && !cms.api.tina.usingProtectedBranch() && /* @__PURE__ */ React__default["default"].createElement(DeleteModal, {
4195
- filename: vars.relativePath,
4196
- deleteFunc: async () => {
4197
- try {
4198
- await admin.deleteDocument(vars);
4199
- cms.alerts.info("Document was successfully deleted");
4200
- reFetchCollection();
4201
- } catch (error) {
4202
- cms.alerts.warn("Document was not deleted, ask a developer for help or check the console for an error message");
4203
- console.error(error);
4204
- throw error;
4205
- }
4206
- },
4207
- close: () => setDeleteModalOpen(false)
4208
- }), deleteModalOpen && cms.api.tina.usingProtectedBranch() && /* @__PURE__ */ React__default["default"].createElement(toolkit.CreateBranchModel, {
4209
- crudType: "delete",
4210
- relativePath: collectionExtra.path + "/" + vars.relativePath,
4211
- values: vars,
4212
- close: () => setDeleteModalOpen(false),
4213
- safeSubmit: async () => {
4214
- try {
4215
- await admin.deleteDocument(vars);
4216
- cms.alerts.info("Document was successfully deleted");
4217
- reFetchCollection();
4218
- } catch (error) {
4219
- cms.alerts.warn("Document was not deleted, ask a developer for help or check the console for an error message");
4220
- console.error(error);
4221
- throw error;
4222
- }
4223
- }
4224
- }), renameModalOpen && /* @__PURE__ */ React__default["default"].createElement(RenameModal, {
4225
- filename: vars.relativePath,
4226
- newRelativePath: vars.newRelativePath,
4227
- setNewRelativePath: (newRelativePath) => {
4228
- setVars((vars2) => {
4229
- return { ...vars2, newRelativePath };
4230
- });
4231
- },
4232
- renameFunc: async () => {
4233
- const newRelativePath = `${vars.newRelativePath}.${collection.format}`;
4234
- try {
4235
- await admin.renameDocument({
4236
- collection: vars.collection,
4237
- relativePath: vars.relativePath,
4238
- newRelativePath
4239
- });
4240
- cms.alerts.info("Document was successfully renamed");
4241
- reFetchCollection();
4242
- } catch (error) {
4243
- cms.alerts.warn("Document was not renamed, ask a developer for help or check the console for an error message");
4244
- console.error(error);
4245
- throw error;
4415
+ return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => {
4416
+ return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(
4417
+ GetCollection,
4418
+ {
4419
+ cms,
4420
+ collectionName,
4421
+ includeDocuments: true,
4422
+ startCursor: endCursor,
4423
+ sortKey,
4424
+ folder,
4425
+ filterArgs: (
4426
+ // only pass filter args if the collection is the same as the current route
4427
+ // We need this hear because this runs before the useEffect above
4428
+ collectionName === vars.collection ? vars : {
4429
+ collection: collectionName,
4430
+ relativePath: "",
4431
+ newRelativePath: "",
4432
+ filterField: "",
4433
+ startsWith: "",
4434
+ endsWith: "",
4435
+ before: "",
4436
+ after: "",
4437
+ booleanEquals: null
4246
4438
  }
4247
- },
4248
- close: () => setRenameModalOpen(false)
4249
- }), /* @__PURE__ */ React__default["default"].createElement(PageHeader, {
4250
- isLocalMode: (_l = (_k = cms == null ? void 0 : cms.api) == null ? void 0 : _k.tina) == null ? void 0 : _l.isLocalMode
4251
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
4252
- className: "w-full grid grid-flow-col items-end gap-4"
4253
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
4254
- className: "flex flex-col gap-4"
4255
- }, /* @__PURE__ */ React__default["default"].createElement("h3", {
4256
- className: "font-sans text-2xl text-gray-700"
4257
- }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React__default["default"].createElement("div", {
4258
- className: "flex gap-4 items-start flex-wrap"
4259
- }, (fields == null ? void 0 : fields.length) > 0 && /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, !search && /* @__PURE__ */ React__default["default"].createElement("div", {
4260
- className: "flex flex-col gap-2 items-start"
4261
- }, /* @__PURE__ */ React__default["default"].createElement("label", {
4262
- htmlFor: "sort",
4263
- className: "block font-sans text-xs font-semibold text-gray-500 whitespace-normal"
4264
- }, "Sort by"), /* @__PURE__ */ React__default["default"].createElement(toolkit.Select, {
4265
- name: "sort",
4266
- options: [
4439
+ ),
4440
+ search
4441
+ },
4442
+ (collection, _loading, reFetchCollection, collectionExtra) => {
4443
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4444
+ collection.documents.totalCount;
4445
+ const documents = collection.documents.edges;
4446
+ const admin = cms.api.admin;
4447
+ const pageInfo = collection.documents.pageInfo;
4448
+ const fields = (_a = collectionExtra.fields) == null ? void 0 : _a.filter(
4449
+ (x) => (
4450
+ // only allow sortable fields
4451
+ ["string", "number", "datetime", "boolean"].includes(x.type)
4452
+ )
4453
+ );
4454
+ const sortField = fields == null ? void 0 : fields.find(
4455
+ (field) => field.name === sortName
4456
+ );
4457
+ const searchEnabled = !!((_d = (_c = (_b = cms.api.tina.schema) == null ? void 0 : _b.config) == null ? void 0 : _c.config) == null ? void 0 : _d.search);
4458
+ const collectionDefinition = cms.api.tina.schema.getCollection(
4459
+ collection.name
4460
+ );
4461
+ const allowCreate = ((_f = (_e = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _e.allowedActions) == null ? void 0 : _f.create) ?? true;
4462
+ const allowDelete = ((_h = (_g = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _g.allowedActions) == null ? void 0 : _h.delete) ?? true;
4463
+ const folderView = folder.fullyQualifiedName !== "";
4464
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, deleteModalOpen && !cms.api.tina.usingProtectedBranch() && /* @__PURE__ */ React.createElement(
4465
+ DeleteModal,
4267
4466
  {
4268
- label: "Default",
4269
- value: JSON.stringify({
4270
- order: "asc",
4271
- name: ""
4272
- })
4273
- },
4274
- ...fields.map((x) => [
4275
- {
4276
- label: (x.label || x.name) + (x.type === "datetime" ? " (Oldest First)" : " (Ascending)"),
4277
- value: JSON.stringify({
4278
- name: x.name,
4279
- order: "asc"
4280
- })
4467
+ filename: vars.relativePath,
4468
+ deleteFunc: async () => {
4469
+ try {
4470
+ await admin.deleteDocument(vars);
4471
+ cms.alerts.info(
4472
+ "Document was successfully deleted"
4473
+ );
4474
+ reFetchCollection();
4475
+ } catch (error) {
4476
+ cms.alerts.warn(
4477
+ "Document was not deleted, ask a developer for help or check the console for an error message"
4478
+ );
4479
+ console.error(error);
4480
+ throw error;
4481
+ }
4281
4482
  },
4282
- {
4283
- label: (x.label || x.name) + (x.type === "datetime" ? " (Newest First)" : " (Descending)"),
4284
- value: JSON.stringify({
4285
- name: x.name,
4286
- order: "desc"
4287
- })
4288
- }
4289
- ]).flat()
4290
- ],
4291
- input: {
4292
- id: "sort",
4293
- name: "sort",
4294
- value: sortKey,
4295
- onChange: (e) => {
4296
- const val = JSON.parse(e.target.value);
4297
- setEndCursor("");
4298
- setPrevCursors([]);
4299
- window == null ? void 0 : window.localStorage.setItem(`${LOCAL_STORAGE_KEY}.${collectionName}`, e.target.value);
4300
- setSortKey(e.target.value);
4301
- setSortOrder(val.order);
4483
+ close: () => setDeleteModalOpen(false)
4302
4484
  }
4303
- }
4304
- })), /* @__PURE__ */ React__default["default"].createElement("div", {
4305
- className: "flex flex-1 flex-col gap-2 items-start w-full"
4306
- }, searchEnabled ? /* @__PURE__ */ React__default["default"].createElement(SearchInput, {
4307
- loading: _loading,
4308
- search,
4309
- setSearch,
4310
- searchInput,
4311
- setSearchInput
4312
- }) : /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("label", {
4313
- className: "block font-sans text-xs font-semibold text-gray-500 whitespace-normal"
4314
- }, "Search"), /* @__PURE__ */ React__default["default"].createElement(toolkit.Message, {
4315
- link: "https://tina.io/docs/reference/search/overview",
4316
- linkLabel: "Read The Docs",
4317
- type: "info",
4318
- size: "small"
4319
- }, "Search not configured.")))))), /* @__PURE__ */ React__default["default"].createElement("div", {
4320
- className: "flex self-end justify-self-end"
4321
- }, !collection.templates && allowCreate && /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
4322
- to: `/${folder.fullyQualifiedName ? [
4323
- "collections",
4324
- "new",
4325
- collectionName,
4326
- "~",
4327
- folder.name
4328
- ].join("/") : ["collections", "new", collectionName].join("/")}`,
4329
- className: "icon-parent inline-flex items-center font-medium focus:outline-none focus:ring-2 focus:shadow-outline text-center rounded-full justify-center transition-all duration-150 ease-out whitespace-nowrap shadow text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 text-sm h-10 px-6"
4330
- }, "Create New", " ", /* @__PURE__ */ React__default["default"].createElement(BiPlus, {
4331
- className: "w-5 h-full ml-1 opacity-70"
4332
- })), collection.templates && allowCreate && /* @__PURE__ */ React__default["default"].createElement(TemplateMenu, {
4333
- collectionName,
4334
- templates: collection.templates,
4335
- folder
4336
- })))), /* @__PURE__ */ React__default["default"].createElement(PageBody, null, /* @__PURE__ */ React__default["default"].createElement("div", {
4337
- className: "w-full mx-auto max-w-screen-xl"
4338
- }, sortField && !sortField.required && /* @__PURE__ */ React__default["default"].createElement("p", {
4339
- className: "mb-4 text-gray-500"
4340
- }, /* @__PURE__ */ React__default["default"].createElement("em", null, "Sorting on a non-required field. Some documents may be excluded (if they don't have a value for", " ", sortName, ")")), documents.length > 0 ? /* @__PURE__ */ React__default["default"].createElement("table", {
4341
- className: "table-auto shadow bg-white border-b border-gray-200 w-full max-w-full rounded-lg"
4342
- }, /* @__PURE__ */ React__default["default"].createElement("tbody", {
4343
- className: "divide-y divide-gray-150"
4344
- }, folder.name && !search && /* @__PURE__ */ React__default["default"].createElement("tr", null, /* @__PURE__ */ React__default["default"].createElement("td", {
4345
- colSpan: 5
4346
- }, /* @__PURE__ */ React__default["default"].createElement(Breadcrumb, {
4347
- folder,
4348
- navigate,
4349
- collectionName
4350
- }))), documents.map((document) => {
4351
- var _a2;
4352
- if (document.node.__typename === "Folder") {
4353
- return /* @__PURE__ */ React__default["default"].createElement("tr", {
4354
- key: `folder-${document.node.path}`
4355
- }, /* @__PURE__ */ React__default["default"].createElement("td", {
4356
- className: "pl-5 pr-3 py-3 truncate max-w-0"
4357
- }, /* @__PURE__ */ React__default["default"].createElement("a", {
4358
- className: "text-blue-600 hover:text-blue-400 flex items-center gap-3 cursor-pointer truncate",
4359
- onClick: () => {
4360
- navigate(`/${[
4361
- "collections",
4362
- collectionName,
4363
- document.node.path
4364
- ].join("/")}`, { replace: true });
4485
+ ), deleteModalOpen && cms.api.tina.usingProtectedBranch() && /* @__PURE__ */ React.createElement(
4486
+ toolkit.CreateBranchModel,
4487
+ {
4488
+ crudType: "delete",
4489
+ relativePath: collectionExtra.path + "/" + vars.relativePath,
4490
+ values: vars,
4491
+ close: () => setDeleteModalOpen(false),
4492
+ safeSubmit: async () => {
4493
+ try {
4494
+ await admin.deleteDocument(vars);
4495
+ cms.alerts.info("Document was successfully deleted");
4496
+ reFetchCollection();
4497
+ } catch (error) {
4498
+ cms.alerts.warn(
4499
+ "Document was not deleted, ask a developer for help or check the console for an error message"
4500
+ );
4501
+ console.error(error);
4502
+ throw error;
4503
+ }
4365
4504
  }
4366
- }, /* @__PURE__ */ React__default["default"].createElement(BiFolder, {
4367
- className: "inline-block h-6 w-auto flex-shrink-0 opacity-70"
4368
- }), /* @__PURE__ */ React__default["default"].createElement("span", {
4369
- className: "truncate block"
4370
- }, /* @__PURE__ */ React__default["default"].createElement("span", {
4371
- className: "block text-xs text-gray-400 mb-1 uppercase"
4372
- }, "Name"), /* @__PURE__ */ React__default["default"].createElement("span", {
4373
- className: "h-5 leading-5 block truncate"
4374
- }, /* @__PURE__ */ React__default["default"].createElement("span", null, document.node.name))))), /* @__PURE__ */ React__default["default"].createElement("td", {
4375
- className: "px-3 py-3 truncate max-w-0",
4376
- colSpan: 4
4377
- }, /* @__PURE__ */ React__default["default"].createElement("span", {
4378
- className: "block text-xs text-gray-400 mb-1 uppercase"
4379
- }, "Path"), /* @__PURE__ */ React__default["default"].createElement("span", {
4380
- className: "leading-5 block text-sm font-medium text-gray-900 truncate"
4381
- }, document.node.path.substring(2).split("/").map((node) => {
4382
- return /* @__PURE__ */ React__default["default"].createElement("span", {
4383
- key: node
4384
- }, /* @__PURE__ */ React__default["default"].createElement("span", {
4385
- className: "text-gray-300 pr-0.5"
4386
- }, "/"), /* @__PURE__ */ React__default["default"].createElement("span", {
4387
- className: "pr-0.5"
4388
- }, node));
4389
- }))));
4390
- }
4391
- const hasTitle = Boolean(document.node._sys.title);
4392
- const subfolders = document.node._sys.breadcrumbs.slice(0, -1).join("/");
4393
- return /* @__PURE__ */ React__default["default"].createElement("tr", {
4394
- key: `document-${document.node._sys.relativePath}`,
4395
- className: ""
4396
- }, /* @__PURE__ */ React__default["default"].createElement("td", {
4397
- className: "pl-5 pr-3 py-3 truncate max-w-0",
4398
- colSpan: hasTitle ? 1 : 2
4399
- }, /* @__PURE__ */ React__default["default"].createElement("a", {
4400
- className: "text-blue-600 hover:text-blue-400 flex items-center gap-3 cursor-pointer truncate",
4401
- onClick: () => {
4402
- handleNavigate(navigate, cms, collection, collectionDefinition, document.node);
4403
4505
  }
4404
- }, /* @__PURE__ */ React__default["default"].createElement(BiFile, {
4405
- className: "inline-block h-6 w-auto flex-shrink-0 opacity-70"
4406
- }), /* @__PURE__ */ React__default["default"].createElement("span", {
4407
- className: "truncate block"
4408
- }, /* @__PURE__ */ React__default["default"].createElement("span", {
4409
- className: "block text-xs text-gray-400 mb-1 uppercase"
4410
- }, hasTitle ? "Title" : "Filename"), /* @__PURE__ */ React__default["default"].createElement("span", {
4411
- className: "h-5 leading-5 block truncate"
4412
- }, !folderView && !hasTitle && subfolders && /* @__PURE__ */ React__default["default"].createElement("span", {
4413
- className: "text-xs text-gray-400"
4414
- }, `${subfolders}/`), /* @__PURE__ */ React__default["default"].createElement("span", null, hasTitle ? (_a2 = document.node._sys) == null ? void 0 : _a2.title : document.node._sys.filename))))), hasTitle && /* @__PURE__ */ React__default["default"].createElement("td", {
4415
- className: "px-3 py-3 truncate max-w-0"
4416
- }, /* @__PURE__ */ React__default["default"].createElement("span", {
4417
- className: "block text-xs text-gray-400 mb-1 uppercase"
4418
- }, "Filename"), /* @__PURE__ */ React__default["default"].createElement("span", {
4419
- className: "h-5 leading-5 block text-sm font-medium text-gray-900 truncate"
4420
- }, !folderView && subfolders && /* @__PURE__ */ React__default["default"].createElement("span", {
4421
- className: "text-xs text-gray-400"
4422
- }, `${subfolders}/`), /* @__PURE__ */ React__default["default"].createElement("span", null, document.node._sys.filename))), /* @__PURE__ */ React__default["default"].createElement("td", {
4423
- className: "px-3 py-3 truncate w-[15%]"
4424
- }, /* @__PURE__ */ React__default["default"].createElement("span", {
4425
- className: "block text-xs text-gray-400 mb-1 uppercase"
4426
- }, "Extension"), /* @__PURE__ */ React__default["default"].createElement("span", {
4427
- className: "h-5 leading-5 block text-sm font-medium text-gray-900"
4428
- }, document.node._sys.extension)), /* @__PURE__ */ React__default["default"].createElement("td", {
4429
- className: "px-3 py-3 truncate w-[15%]"
4430
- }, /* @__PURE__ */ React__default["default"].createElement("span", {
4431
- className: "block text-xs text-gray-400 mb-1 uppercase"
4432
- }, "Template"), /* @__PURE__ */ React__default["default"].createElement("span", {
4433
- className: "h-5 leading-5 block text-sm font-medium text-gray-900"
4434
- }, document.node._sys.template)), /* @__PURE__ */ React__default["default"].createElement("td", {
4435
- className: "w-0"
4436
- }, /* @__PURE__ */ React__default["default"].createElement(toolkit.OverflowMenu, {
4437
- toolbarItems: [
4438
- {
4439
- name: "edit",
4440
- label: "Edit in Admin",
4441
- Icon: /* @__PURE__ */ React__default["default"].createElement(BiEdit, {
4442
- size: "1.3rem"
4443
- }),
4444
- onMouseDown: () => {
4445
- const pathToDoc = document.node._sys.breadcrumbs;
4446
- if (folder.fullyQualifiedName) {
4447
- pathToDoc.unshift("~");
4448
- }
4449
- navigate(`/${[
4450
- "collections",
4451
- "edit",
4452
- collectionName,
4453
- ...pathToDoc
4454
- ].join("/")}`, { replace: true });
4506
+ ), renameModalOpen && /* @__PURE__ */ React.createElement(
4507
+ RenameModal,
4508
+ {
4509
+ filename: vars.relativePath,
4510
+ newRelativePath: vars.newRelativePath,
4511
+ setNewRelativePath: (newRelativePath) => {
4512
+ setVars((vars2) => {
4513
+ return { ...vars2, newRelativePath };
4514
+ });
4515
+ },
4516
+ renameFunc: async () => {
4517
+ const newRelativePath = `${vars.newRelativePath}.${collection.format}`;
4518
+ try {
4519
+ await admin.renameDocument({
4520
+ collection: vars.collection,
4521
+ relativePath: vars.relativePath,
4522
+ newRelativePath
4523
+ });
4524
+ cms.alerts.info("Document was successfully renamed");
4525
+ reFetchCollection();
4526
+ } catch (error) {
4527
+ cms.alerts.warn(
4528
+ "Document was not renamed, ask a developer for help or check the console for an error message"
4529
+ );
4530
+ console.error(error);
4531
+ throw error;
4455
4532
  }
4456
4533
  },
4457
- allowCreate && {
4458
- name: "duplicate",
4459
- label: "Duplicate",
4460
- Icon: /* @__PURE__ */ React__default["default"].createElement(BiCopy, {
4461
- size: "1.3rem"
4462
- }),
4463
- onMouseDown: () => {
4464
- const pathToDoc = document.node._sys.breadcrumbs;
4465
- if (folder.fullyQualifiedName) {
4466
- pathToDoc.unshift("~");
4534
+ close: () => setRenameModalOpen(false)
4535
+ }
4536
+ ), /* @__PURE__ */ React.createElement(PageHeader, { isLocalMode: (_j = (_i = cms == null ? void 0 : cms.api) == null ? void 0 : _i.tina) == null ? void 0 : _j.isLocalMode }, /* @__PURE__ */ React.createElement("div", { className: "w-full grid grid-flow-col items-end gap-4" }, /* @__PURE__ */ React.createElement("div", { className: "flex flex-col gap-4" }, /* @__PURE__ */ React.createElement("h3", { className: "font-sans text-2xl text-gray-700" }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React.createElement("div", { className: "flex gap-4 items-start flex-wrap" }, (fields == null ? void 0 : fields.length) > 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, !search && /* @__PURE__ */ React.createElement("div", { className: "flex flex-col gap-2 items-start" }, /* @__PURE__ */ React.createElement(
4537
+ "label",
4538
+ {
4539
+ htmlFor: "sort",
4540
+ className: "block font-sans text-xs font-semibold text-gray-500 whitespace-normal"
4541
+ },
4542
+ "Sort by"
4543
+ ), /* @__PURE__ */ React.createElement(
4544
+ toolkit.Select,
4545
+ {
4546
+ name: "sort",
4547
+ options: [
4548
+ {
4549
+ label: "Default",
4550
+ value: JSON.stringify({
4551
+ order: "asc",
4552
+ name: ""
4553
+ })
4554
+ },
4555
+ ...fields.map((x) => [
4556
+ {
4557
+ label: (x.label || x.name) + (x.type === "datetime" ? " (Oldest First)" : " (Ascending)"),
4558
+ value: JSON.stringify({
4559
+ name: x.name,
4560
+ order: "asc"
4561
+ })
4562
+ },
4563
+ {
4564
+ label: (x.label || x.name) + (x.type === "datetime" ? " (Newest First)" : " (Descending)"),
4565
+ value: JSON.stringify({
4566
+ name: x.name,
4567
+ order: "desc"
4568
+ })
4467
4569
  }
4468
- navigate(`/${[
4469
- "collections",
4470
- "duplicate",
4471
- collectionName,
4472
- ...pathToDoc
4473
- ].join("/")}`, { replace: true });
4570
+ ]).flat()
4571
+ ],
4572
+ input: {
4573
+ id: "sort",
4574
+ name: "sort",
4575
+ value: sortKey,
4576
+ onChange: (e) => {
4577
+ const val = JSON.parse(e.target.value);
4578
+ setEndCursor("");
4579
+ setPrevCursors([]);
4580
+ window == null ? void 0 : window.localStorage.setItem(
4581
+ `${LOCAL_STORAGE_KEY}.${collectionName}`,
4582
+ e.target.value
4583
+ );
4584
+ setSortKey(e.target.value);
4585
+ setSortOrder(val.order);
4474
4586
  }
4587
+ }
4588
+ }
4589
+ )), /* @__PURE__ */ React.createElement("div", { className: "flex flex-1 flex-col gap-2 items-start w-full" }, searchEnabled ? /* @__PURE__ */ React.createElement(
4590
+ SearchInput,
4591
+ {
4592
+ loading: _loading,
4593
+ search,
4594
+ setSearch,
4595
+ searchInput,
4596
+ setSearchInput
4597
+ }
4598
+ ) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("label", { className: "block font-sans text-xs font-semibold text-gray-500 whitespace-normal" }, "Search"), /* @__PURE__ */ React.createElement(
4599
+ toolkit.Message,
4600
+ {
4601
+ link: "https://tina.io/docs/reference/search/overview",
4602
+ linkLabel: "Read The Docs",
4603
+ type: "info",
4604
+ size: "small"
4605
+ },
4606
+ "Search not configured."
4607
+ )))))), /* @__PURE__ */ React.createElement("div", { className: "flex self-end justify-self-end" }, !collection.templates && allowCreate && /* @__PURE__ */ React.createElement(
4608
+ reactRouterDom.Link,
4609
+ {
4610
+ to: `/${folder.fullyQualifiedName ? [
4611
+ "collections",
4612
+ "new",
4613
+ collectionName,
4614
+ "~",
4615
+ folder.name
4616
+ ].join("/") : ["collections", "new", collectionName].join(
4617
+ "/"
4618
+ )}`,
4619
+ className: "icon-parent inline-flex items-center font-medium focus:outline-none focus:ring-2 focus:shadow-outline text-center rounded-full justify-center transition-all duration-150 ease-out whitespace-nowrap shadow text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 text-sm h-10 px-6"
4620
+ },
4621
+ "Create New",
4622
+ " ",
4623
+ /* @__PURE__ */ React.createElement(BiPlus, { className: "w-5 h-full ml-1 opacity-70" })
4624
+ ), collection.templates && allowCreate && /* @__PURE__ */ React.createElement(
4625
+ TemplateMenu,
4626
+ {
4627
+ collectionName,
4628
+ templates: collection.templates,
4629
+ folder
4630
+ }
4631
+ )))), /* @__PURE__ */ React.createElement(PageBody, null, /* @__PURE__ */ React.createElement("div", { className: "w-full mx-auto max-w-screen-xl" }, sortField && !sortField.required && /* @__PURE__ */ React.createElement("p", { className: "mb-4 text-gray-500" }, /* @__PURE__ */ React.createElement("em", null, "Sorting on a non-required field. Some documents may be excluded (if they don't have a value for", " ", sortName, ")")), documents.length > 0 ? /* @__PURE__ */ React.createElement("table", { className: "table-auto shadow bg-white border-b border-gray-200 w-full max-w-full rounded-lg" }, /* @__PURE__ */ React.createElement("tbody", { className: "divide-y divide-gray-150" }, folder.name && !search && /* @__PURE__ */ React.createElement("tr", null, /* @__PURE__ */ React.createElement("td", { colSpan: 5 }, /* @__PURE__ */ React.createElement(
4632
+ Breadcrumb,
4633
+ {
4634
+ folder,
4635
+ navigate,
4636
+ collectionName
4637
+ }
4638
+ ))), documents.map((document) => {
4639
+ var _a2;
4640
+ if (document.node.__typename === "Folder") {
4641
+ return /* @__PURE__ */ React.createElement("tr", { key: `folder-${document.node.path}` }, /* @__PURE__ */ React.createElement("td", { className: "pl-5 pr-3 py-3 truncate max-w-0" }, /* @__PURE__ */ React.createElement(
4642
+ "a",
4643
+ {
4644
+ className: "text-blue-600 hover:text-blue-400 flex items-center gap-3 cursor-pointer truncate",
4645
+ onClick: () => {
4646
+ navigate(
4647
+ `/${[
4648
+ "collections",
4649
+ collectionName,
4650
+ document.node.path
4651
+ ].join("/")}`,
4652
+ { replace: true }
4653
+ );
4654
+ }
4655
+ },
4656
+ /* @__PURE__ */ React.createElement(BiFolder, { className: "inline-block h-6 w-auto flex-shrink-0 opacity-70" }),
4657
+ /* @__PURE__ */ React.createElement("span", { className: "truncate block" }, /* @__PURE__ */ React.createElement("span", { className: "block text-xs text-gray-400 mb-1 uppercase" }, "Name"), /* @__PURE__ */ React.createElement("span", { className: "h-5 leading-5 block truncate" }, /* @__PURE__ */ React.createElement("span", null, document.node.name)))
4658
+ )), /* @__PURE__ */ React.createElement(
4659
+ "td",
4660
+ {
4661
+ className: "px-3 py-3 truncate max-w-0",
4662
+ colSpan: 4
4663
+ },
4664
+ /* @__PURE__ */ React.createElement("span", { className: "block text-xs text-gray-400 mb-1 uppercase" }, "Path"),
4665
+ /* @__PURE__ */ React.createElement("span", { className: "leading-5 block text-sm font-medium text-gray-900 truncate" }, document.node.path.substring(2).split("/").map((node) => {
4666
+ return /* @__PURE__ */ React.createElement("span", { key: node }, /* @__PURE__ */ React.createElement("span", { className: "text-gray-300 pr-0.5" }, "/"), /* @__PURE__ */ React.createElement("span", { className: "pr-0.5" }, node));
4667
+ }))
4668
+ ));
4669
+ }
4670
+ const hasTitle = Boolean(
4671
+ document.node._sys.title
4672
+ );
4673
+ const subfolders = document.node._sys.breadcrumbs.slice(0, -1).join("/");
4674
+ return /* @__PURE__ */ React.createElement(
4675
+ "tr",
4676
+ {
4677
+ key: `document-${document.node._sys.relativePath}`,
4678
+ className: ""
4475
4679
  },
4476
- allowDelete && {
4477
- name: "delete",
4478
- label: "Delete",
4479
- Icon: /* @__PURE__ */ React__default["default"].createElement(BiTrash, {
4480
- size: "1.3rem",
4481
- className: "text-red-500"
4482
- }),
4483
- onMouseDown: () => {
4484
- setVars((old) => ({
4485
- ...old,
4486
- collection: collectionName,
4487
- relativePath: document.node._sys.breadcrumbs.join("/") + document.node._sys.extension,
4488
- newRelativePath: ""
4489
- }));
4490
- setDeleteModalOpen(true);
4680
+ /* @__PURE__ */ React.createElement(
4681
+ "td",
4682
+ {
4683
+ className: "pl-5 pr-3 py-3 truncate max-w-0",
4684
+ colSpan: hasTitle ? 1 : 2
4685
+ },
4686
+ /* @__PURE__ */ React.createElement(
4687
+ "a",
4688
+ {
4689
+ className: "text-blue-600 hover:text-blue-400 flex items-center gap-3 cursor-pointer truncate",
4690
+ onClick: () => {
4691
+ handleNavigate(
4692
+ navigate,
4693
+ cms,
4694
+ collection,
4695
+ collectionDefinition,
4696
+ document.node
4697
+ );
4698
+ }
4699
+ },
4700
+ /* @__PURE__ */ React.createElement(BiFile, { className: "inline-block h-6 w-auto flex-shrink-0 opacity-70" }),
4701
+ /* @__PURE__ */ React.createElement("span", { className: "truncate block" }, /* @__PURE__ */ React.createElement("span", { className: "block text-xs text-gray-400 mb-1 uppercase" }, hasTitle ? "Title" : "Filename"), /* @__PURE__ */ React.createElement("span", { className: "h-5 leading-5 block truncate" }, !folderView && !hasTitle && subfolders && /* @__PURE__ */ React.createElement("span", { className: "text-xs text-gray-400" }, `${subfolders}/`), /* @__PURE__ */ React.createElement("span", null, hasTitle ? (_a2 = document.node._sys) == null ? void 0 : _a2.title : document.node._sys.filename)))
4702
+ )
4703
+ ),
4704
+ hasTitle && /* @__PURE__ */ React.createElement("td", { className: "px-3 py-3 truncate max-w-0" }, /* @__PURE__ */ React.createElement("span", { className: "block text-xs text-gray-400 mb-1 uppercase" }, "Filename"), /* @__PURE__ */ React.createElement("span", { className: "h-5 leading-5 block text-sm font-medium text-gray-900 truncate" }, !folderView && subfolders && /* @__PURE__ */ React.createElement("span", { className: "text-xs text-gray-400" }, `${subfolders}/`), /* @__PURE__ */ React.createElement("span", null, document.node._sys.filename))),
4705
+ /* @__PURE__ */ React.createElement("td", { className: "px-3 py-3 truncate w-[15%]" }, /* @__PURE__ */ React.createElement("span", { className: "block text-xs text-gray-400 mb-1 uppercase" }, "Extension"), /* @__PURE__ */ React.createElement("span", { className: "h-5 leading-5 block text-sm font-medium text-gray-900" }, document.node._sys.extension)),
4706
+ /* @__PURE__ */ React.createElement("td", { className: "px-3 py-3 truncate w-[15%]" }, /* @__PURE__ */ React.createElement("span", { className: "block text-xs text-gray-400 mb-1 uppercase" }, "Template"), /* @__PURE__ */ React.createElement("span", { className: "h-5 leading-5 block text-sm font-medium text-gray-900" }, document.node._sys.template)),
4707
+ /* @__PURE__ */ React.createElement("td", { className: "w-0" }, /* @__PURE__ */ React.createElement(
4708
+ toolkit.OverflowMenu,
4709
+ {
4710
+ toolbarItems: [
4711
+ {
4712
+ name: "edit",
4713
+ label: "Edit in Admin",
4714
+ Icon: /* @__PURE__ */ React.createElement(BiEdit, { size: "1.3rem" }),
4715
+ onMouseDown: () => {
4716
+ const pathToDoc = document.node._sys.breadcrumbs;
4717
+ if (folder.fullyQualifiedName) {
4718
+ pathToDoc.unshift("~");
4719
+ }
4720
+ navigate(
4721
+ `/${[
4722
+ "collections",
4723
+ "edit",
4724
+ collectionName,
4725
+ ...pathToDoc
4726
+ ].join("/")}`,
4727
+ { replace: true }
4728
+ );
4729
+ }
4730
+ },
4731
+ allowCreate && {
4732
+ name: "duplicate",
4733
+ label: "Duplicate",
4734
+ Icon: /* @__PURE__ */ React.createElement(BiCopy, { size: "1.3rem" }),
4735
+ onMouseDown: () => {
4736
+ const pathToDoc = document.node._sys.breadcrumbs;
4737
+ if (folder.fullyQualifiedName) {
4738
+ pathToDoc.unshift("~");
4739
+ }
4740
+ navigate(
4741
+ `/${[
4742
+ "collections",
4743
+ "duplicate",
4744
+ collectionName,
4745
+ ...pathToDoc
4746
+ ].join("/")}`,
4747
+ { replace: true }
4748
+ );
4749
+ }
4750
+ },
4751
+ allowDelete && {
4752
+ name: "delete",
4753
+ label: "Delete",
4754
+ Icon: /* @__PURE__ */ React.createElement(
4755
+ BiTrash,
4756
+ {
4757
+ size: "1.3rem",
4758
+ className: "text-red-500"
4759
+ }
4760
+ ),
4761
+ onMouseDown: () => {
4762
+ setVars((old) => ({
4763
+ ...old,
4764
+ collection: collectionName,
4765
+ relativePath: document.node._sys.breadcrumbs.join(
4766
+ "/"
4767
+ ) + document.node._sys.extension,
4768
+ newRelativePath: ""
4769
+ }));
4770
+ setDeleteModalOpen(true);
4771
+ }
4772
+ },
4773
+ allowDelete && {
4774
+ name: "rename",
4775
+ label: "Rename",
4776
+ Icon: /* @__PURE__ */ React.createElement(
4777
+ BiRename,
4778
+ {
4779
+ size: "1.3rem",
4780
+ className: "text-red-500"
4781
+ }
4782
+ ),
4783
+ onMouseDown: () => {
4784
+ setVars((old) => ({
4785
+ ...old,
4786
+ collection: collectionName,
4787
+ relativePath: document.node._sys.breadcrumbs.join(
4788
+ "/"
4789
+ ) + document.node._sys.extension,
4790
+ newRelativePath: ""
4791
+ }));
4792
+ setRenameModalOpen(true);
4793
+ }
4794
+ }
4795
+ ].filter(Boolean)
4491
4796
  }
4797
+ ))
4798
+ );
4799
+ }))) : /* @__PURE__ */ React.createElement(NoDocumentsPlaceholder, null), /* @__PURE__ */ React.createElement("div", { className: "pt-4" }, /* @__PURE__ */ React.createElement(
4800
+ toolkit.CursorPaginator,
4801
+ {
4802
+ variant: "white",
4803
+ hasNext: sortOrder === "asc" ? pageInfo == null ? void 0 : pageInfo.hasNextPage : pageInfo.hasPreviousPage,
4804
+ navigateNext: () => {
4805
+ const newState = [...prevCursors, endCursor];
4806
+ setPrevCursors(newState);
4807
+ setEndCursor(pageInfo == null ? void 0 : pageInfo.endCursor);
4492
4808
  },
4493
- allowDelete && {
4494
- name: "rename",
4495
- label: "Rename",
4496
- Icon: /* @__PURE__ */ React__default["default"].createElement(BiRename, {
4497
- size: "1.3rem",
4498
- className: "text-red-500"
4499
- }),
4500
- onMouseDown: () => {
4501
- setVars((old) => ({
4502
- ...old,
4503
- collection: collectionName,
4504
- relativePath: document.node._sys.breadcrumbs.join("/") + document.node._sys.extension,
4505
- newRelativePath: ""
4506
- }));
4507
- setRenameModalOpen(true);
4809
+ hasPrev: prevCursors.length > 0,
4810
+ navigatePrev: () => {
4811
+ const prev = prevCursors[prevCursors.length - 1];
4812
+ if (typeof prev === "string") {
4813
+ const newState = prevCursors.slice(0, -1);
4814
+ setPrevCursors(newState);
4815
+ setEndCursor(prev);
4508
4816
  }
4509
4817
  }
4510
- ].filter(Boolean)
4511
- })));
4512
- }))) : /* @__PURE__ */ React__default["default"].createElement(NoDocumentsPlaceholder, null), /* @__PURE__ */ React__default["default"].createElement("div", {
4513
- className: "pt-4"
4514
- }, /* @__PURE__ */ React__default["default"].createElement(toolkit.CursorPaginator, {
4515
- variant: "white",
4516
- hasNext: sortOrder === "asc" ? pageInfo == null ? void 0 : pageInfo.hasNextPage : pageInfo.hasPreviousPage,
4517
- navigateNext: () => {
4518
- const newState = [...prevCursors, endCursor];
4519
- setPrevCursors(newState);
4520
- setEndCursor(pageInfo == null ? void 0 : pageInfo.endCursor);
4521
- },
4522
- hasPrev: prevCursors.length > 0,
4523
- navigatePrev: () => {
4524
- const prev = prevCursors[prevCursors.length - 1];
4525
- if (typeof prev === "string") {
4526
- const newState = prevCursors.slice(0, -1);
4527
- setPrevCursors(newState);
4528
- setEndCursor(prev);
4529
4818
  }
4530
- }
4531
- })))));
4532
- }));
4819
+ )))));
4820
+ }
4821
+ ));
4533
4822
  });
4534
4823
  };
4535
4824
  const SearchInput = ({
@@ -4547,112 +4836,119 @@ This will work when developing locally but NOT when deployed to production.
4547
4836
  setSearchLoaded(true);
4548
4837
  }
4549
4838
  }, [loading]);
4550
- return /* @__PURE__ */ React__default["default"].createElement("form", {
4551
- className: "flex flex-1 flex-col gap-2 items-start w-full"
4552
- }, /* @__PURE__ */ React__default["default"].createElement("label", {
4553
- htmlFor: "search",
4554
- className: "block font-sans text-xs font-semibold text-gray-500 whitespace-normal"
4555
- }, "Search"), /* @__PURE__ */ React__default["default"].createElement("div", {
4556
- className: "flex flex-wrap items-center gap-3"
4557
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
4558
- className: "flex-1 min-w-[200px]"
4559
- }, /* @__PURE__ */ React__default["default"].createElement(toolkit.Input, {
4560
- type: "text",
4561
- name: "search",
4562
- placeholder: "Search",
4563
- value: searchInput,
4564
- onChange: (e) => {
4565
- setSearchInput(e.target.value);
4839
+ return /* @__PURE__ */ React.createElement("form", { className: "flex flex-1 flex-col gap-2 items-start w-full" }, /* @__PURE__ */ React.createElement(
4840
+ "label",
4841
+ {
4842
+ htmlFor: "search",
4843
+ className: "block font-sans text-xs font-semibold text-gray-500 whitespace-normal"
4844
+ },
4845
+ "Search"
4846
+ ), /* @__PURE__ */ React.createElement("div", { className: "flex flex-wrap items-center gap-3" }, /* @__PURE__ */ React.createElement("div", { className: "flex-1 min-w-[200px]" }, /* @__PURE__ */ React.createElement(
4847
+ toolkit.Input,
4848
+ {
4849
+ type: "text",
4850
+ name: "search",
4851
+ placeholder: "Search",
4852
+ value: searchInput,
4853
+ onChange: (e) => {
4854
+ setSearchInput(e.target.value);
4855
+ }
4566
4856
  }
4567
- })), /* @__PURE__ */ React__default["default"].createElement("div", {
4568
- className: "flex gap-3"
4569
- }, /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
4570
- onClick: () => {
4571
- setSearch(searchInput);
4572
- setSearchLoaded(false);
4857
+ )), /* @__PURE__ */ React.createElement("div", { className: "flex gap-3" }, /* @__PURE__ */ React.createElement(
4858
+ toolkit.Button,
4859
+ {
4860
+ onClick: () => {
4861
+ setSearch(searchInput);
4862
+ setSearchLoaded(false);
4863
+ },
4864
+ variant: "primary",
4865
+ type: "submit"
4573
4866
  },
4574
- variant: "primary",
4575
- type: "submit"
4576
- }, "Search ", /* @__PURE__ */ React__default["default"].createElement(BiSearch, {
4577
- className: "w-5 h-full ml-1.5 opacity-70"
4578
- })), search && searchLoaded && /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
4579
- onClick: () => {
4580
- setSearch("");
4581
- setSearchInput("");
4867
+ "Search ",
4868
+ /* @__PURE__ */ React.createElement(BiSearch, { className: "w-5 h-full ml-1.5 opacity-70" })
4869
+ ), search && searchLoaded && /* @__PURE__ */ React.createElement(
4870
+ toolkit.Button,
4871
+ {
4872
+ onClick: () => {
4873
+ setSearch("");
4874
+ setSearchInput("");
4875
+ },
4876
+ variant: "white"
4582
4877
  },
4583
- variant: "white"
4584
- }, "Clear ", /* @__PURE__ */ React__default["default"].createElement(BiX, {
4585
- className: "w-5 h-full ml-1 opacity-70"
4586
- })))));
4878
+ "Clear ",
4879
+ /* @__PURE__ */ React.createElement(BiX, { className: "w-5 h-full ml-1 opacity-70" })
4880
+ ))));
4587
4881
  };
4588
4882
  const Breadcrumb = ({ folder, navigate, collectionName }) => {
4589
4883
  const folderArray = folder.name.split("/");
4590
- return /* @__PURE__ */ React__default["default"].createElement("div", {
4591
- className: "w-full bg-gray-50/30 flex items-stretch"
4592
- }, /* @__PURE__ */ React__default["default"].createElement("button", {
4593
- onClick: () => {
4594
- const folders = folder.fullyQualifiedName.split("/");
4595
- navigate(`/${[
4596
- "collections",
4597
- collectionName,
4598
- ...folders.slice(0, folders.length - 1)
4599
- ].join("/")}`, { replace: true });
4600
- },
4601
- className: "px-3 py-2 bg-white hover:bg-gray-50/50 transition ease-out duration-100 border-r border-gray-100 text-blue-500 hover:text-blue-600"
4602
- }, /* @__PURE__ */ React__default["default"].createElement(BiArrowBack, {
4603
- className: "w-6 h-full opacity-70"
4604
- })), /* @__PURE__ */ React__default["default"].createElement("span", {
4605
- className: "px-3 py-2 text-gray-600 flex flex-wrap items-center justify-start gap-1"
4606
- }, /* @__PURE__ */ React__default["default"].createElement("button", {
4607
- onClick: () => {
4608
- navigate(`/collections/${collectionName}/~`, {
4609
- replace: true
4610
- });
4611
- },
4612
- className: "shrink-0 bg-transparent p-0 border-0 text-blue-400 hover:text-blue-500 transition-all ease-out duration-100 opacity-70 hover:opacity-100"
4613
- }, /* @__PURE__ */ React__default["default"].createElement(RiHome2Line, {
4614
- className: "w-5 h-auto"
4615
- })), folderArray.map((node, index) => {
4616
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("span", {
4617
- className: "text-gray-200 shrink-0"
4618
- }, "/"), index < folderArray.length - 1 ? /* @__PURE__ */ React__default["default"].createElement("button", {
4619
- className: "bg-transparent whitespace-nowrap truncate p-0 border-0 text-blue-500 hover:text-blue-600 transition-all ease-out duration-100 underline underline-offset-2 decoration-1 decoration-blue-200 hover:decoration-blue-400",
4884
+ return /* @__PURE__ */ React.createElement("div", { className: "w-full bg-gray-50/30 flex items-stretch" }, /* @__PURE__ */ React.createElement(
4885
+ "button",
4886
+ {
4620
4887
  onClick: () => {
4621
4888
  const folders = folder.fullyQualifiedName.split("/");
4622
- navigate(`/${[
4623
- "collections",
4624
- collectionName,
4625
- ...folders.slice(0, folders.length - (folders.length - (index + 2)))
4626
- ].join("/")}`, { replace: true });
4627
- }
4628
- }, node) : /* @__PURE__ */ React__default["default"].createElement("span", {
4629
- className: "whitespace-nowrap truncate"
4630
- }, node));
4889
+ navigate(
4890
+ `/${[
4891
+ "collections",
4892
+ collectionName,
4893
+ ...folders.slice(0, folders.length - 1)
4894
+ ].join("/")}`,
4895
+ { replace: true }
4896
+ );
4897
+ },
4898
+ className: "px-3 py-2 bg-white hover:bg-gray-50/50 transition ease-out duration-100 border-r border-gray-100 text-blue-500 hover:text-blue-600"
4899
+ },
4900
+ /* @__PURE__ */ React.createElement(BiArrowBack, { className: "w-6 h-full opacity-70" })
4901
+ ), /* @__PURE__ */ React.createElement("span", { className: "px-3 py-2 text-gray-600 flex flex-wrap items-center justify-start gap-1" }, /* @__PURE__ */ React.createElement(
4902
+ "button",
4903
+ {
4904
+ onClick: () => {
4905
+ navigate(`/collections/${collectionName}/~`, {
4906
+ replace: true
4907
+ });
4908
+ },
4909
+ className: "shrink-0 bg-transparent p-0 border-0 text-blue-400 hover:text-blue-500 transition-all ease-out duration-100 opacity-70 hover:opacity-100"
4910
+ },
4911
+ /* @__PURE__ */ React.createElement(RiHome2Line, { className: "w-5 h-auto" })
4912
+ ), folderArray.map((node, index) => {
4913
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", { className: "text-gray-200 shrink-0" }, "/"), index < folderArray.length - 1 ? /* @__PURE__ */ React.createElement(
4914
+ "button",
4915
+ {
4916
+ className: "bg-transparent whitespace-nowrap truncate p-0 border-0 text-blue-500 hover:text-blue-600 transition-all ease-out duration-100 underline underline-offset-2 decoration-1 decoration-blue-200 hover:decoration-blue-400",
4917
+ onClick: () => {
4918
+ const folders = folder.fullyQualifiedName.split("/");
4919
+ navigate(
4920
+ `/${[
4921
+ "collections",
4922
+ collectionName,
4923
+ ...folders.slice(
4924
+ 0,
4925
+ folders.length - (folders.length - (index + 2))
4926
+ )
4927
+ ].join("/")}`,
4928
+ { replace: true }
4929
+ );
4930
+ }
4931
+ },
4932
+ node
4933
+ ) : /* @__PURE__ */ React.createElement("span", { className: "whitespace-nowrap truncate" }, node));
4631
4934
  })));
4632
4935
  };
4633
4936
  const NoDocumentsPlaceholder = () => {
4634
- return /* @__PURE__ */ React__default["default"].createElement("div", {
4635
- 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"
4636
- }, /* @__PURE__ */ React__default["default"].createElement("p", {
4637
- className: "text-base italic font-medium text-gray-300"
4638
- }, "No documents found."));
4937
+ 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."));
4639
4938
  };
4640
4939
  const DeleteModal = ({ close: close2, deleteFunc, filename }) => {
4641
- return /* @__PURE__ */ React__default["default"].createElement(toolkit.Modal, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.PopupModal, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalHeader, {
4642
- close: close2
4643
- }, "Delete ", filename), /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalBody, {
4644
- padded: true
4645
- }, /* @__PURE__ */ React__default["default"].createElement("p", null, `Are you sure you want to delete ${filename}?`)), /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalActions, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
4646
- style: { flexGrow: 2 },
4647
- onClick: close2
4648
- }, "Cancel"), /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
4649
- style: { flexGrow: 3 },
4650
- variant: "danger",
4651
- onClick: async () => {
4652
- await deleteFunc();
4653
- close2();
4654
- }
4655
- }, "Delete"))));
4940
+ return /* @__PURE__ */ React.createElement(toolkit.Modal, null, /* @__PURE__ */ React.createElement(toolkit.PopupModal, null, /* @__PURE__ */ React.createElement(toolkit.ModalHeader, { close: close2 }, "Delete ", filename), /* @__PURE__ */ React.createElement(toolkit.ModalBody, { padded: true }, /* @__PURE__ */ React.createElement("p", null, `Are you sure you want to delete ${filename}?`)), /* @__PURE__ */ React.createElement(toolkit.ModalActions, null, /* @__PURE__ */ React.createElement(toolkit.Button, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React.createElement(
4941
+ toolkit.Button,
4942
+ {
4943
+ style: { flexGrow: 3 },
4944
+ variant: "danger",
4945
+ onClick: async () => {
4946
+ await deleteFunc();
4947
+ close2();
4948
+ }
4949
+ },
4950
+ "Delete"
4951
+ ))));
4656
4952
  };
4657
4953
  const RenameModal = ({
4658
4954
  close: close2,
@@ -4661,27 +4957,25 @@ This will work when developing locally but NOT when deployed to production.
4661
4957
  newRelativePath,
4662
4958
  setNewRelativePath
4663
4959
  }) => {
4664
- return /* @__PURE__ */ React__default["default"].createElement(toolkit.Modal, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.PopupModal, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalHeader, {
4665
- close: close2
4666
- }, "Rename ", filename), /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalBody, {
4667
- padded: true
4668
- }, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("p", {
4669
- className: "mb-4"
4670
- }, "Are you sure you want to rename ", /* @__PURE__ */ React__default["default"].createElement("strong", null, filename), "? TinaCMS uses the filename as the ID; renaming this file could result in unresolved references."), /* @__PURE__ */ React__default["default"].createElement(toolkit.BaseTextField, {
4671
- placeholder: "Enter a new name for the document's file",
4672
- value: newRelativePath,
4673
- onChange: (event) => setNewRelativePath(event.target.value)
4674
- }))), /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalActions, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
4675
- style: { flexGrow: 2 },
4676
- onClick: close2
4677
- }, "Cancel"), /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
4678
- style: { flexGrow: 3 },
4679
- variant: "primary",
4680
- onClick: async () => {
4681
- await renameFunc();
4682
- close2();
4960
+ return /* @__PURE__ */ React.createElement(toolkit.Modal, null, /* @__PURE__ */ React.createElement(toolkit.PopupModal, null, /* @__PURE__ */ React.createElement(toolkit.ModalHeader, { close: close2 }, "Rename ", filename), /* @__PURE__ */ React.createElement(toolkit.ModalBody, { padded: true }, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", { className: "mb-4" }, "Are you sure you want to rename ", /* @__PURE__ */ React.createElement("strong", null, filename), "? TinaCMS uses the filename as the ID; renaming this file could result in unresolved references."), /* @__PURE__ */ React.createElement(
4961
+ toolkit.BaseTextField,
4962
+ {
4963
+ placeholder: "Enter a new name for the document's file",
4964
+ value: newRelativePath,
4965
+ onChange: (event) => setNewRelativePath(event.target.value)
4683
4966
  }
4684
- }, "Rename"))));
4967
+ ))), /* @__PURE__ */ React.createElement(toolkit.ModalActions, null, /* @__PURE__ */ React.createElement(toolkit.Button, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React.createElement(
4968
+ toolkit.Button,
4969
+ {
4970
+ style: { flexGrow: 3 },
4971
+ variant: "primary",
4972
+ onClick: async () => {
4973
+ await renameFunc();
4974
+ close2();
4975
+ }
4976
+ },
4977
+ "Rename"
4978
+ ))));
4685
4979
  };
4686
4980
  function FaLock(props) {
4687
4981
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 448 512" }, "child": [{ "tag": "path", "attr": { "d": "M400 224h-24v-72C376 68.2 307.8 0 224 0S72 68.2 72 152v72H48c-26.5 0-48 21.5-48 48v192c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V272c0-26.5-21.5-48-48-48zm-104 0H152v-72c0-39.7 32.3-72 72-72s72 32.3 72 72v72z" } }] })(props);
@@ -4710,42 +5004,64 @@ This will work when developing locally but NOT when deployed to production.
4710
5004
  const CollectionCreatePage = () => {
4711
5005
  const folder = useCollectionFolder();
4712
5006
  const { collectionName, templateName } = reactRouterDom.useParams();
4713
- return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => /* @__PURE__ */ React__default["default"].createElement(GetCollection, {
4714
- cms,
4715
- collectionName,
4716
- folder,
4717
- includeDocuments: false
4718
- }, (collection) => {
4719
- const mutationInfo = {
4720
- includeCollection: true,
4721
- includeTemplate: !!collection.templates
4722
- };
4723
- return /* @__PURE__ */ React__default["default"].createElement(RenderForm$1, {
5007
+ return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => /* @__PURE__ */ React.createElement(
5008
+ GetCollection,
5009
+ {
4724
5010
  cms,
4725
- collection,
4726
- templateName,
4727
- mutationInfo,
4728
- folder
4729
- });
4730
- }));
5011
+ collectionName,
5012
+ folder,
5013
+ includeDocuments: false
5014
+ },
5015
+ (collection) => {
5016
+ const mutationInfo = {
5017
+ includeCollection: true,
5018
+ includeTemplate: !!collection.templates
5019
+ };
5020
+ return /* @__PURE__ */ React.createElement(
5021
+ RenderForm$1,
5022
+ {
5023
+ cms,
5024
+ collection,
5025
+ templateName,
5026
+ mutationInfo,
5027
+ folder
5028
+ }
5029
+ );
5030
+ }
5031
+ ));
4731
5032
  };
4732
5033
  const FilenameInput = (props) => {
4733
- const [filenameTouched, setFilenameTouched] = React__default["default"].useState(false);
4734
- return /* @__PURE__ */ React__default["default"].createElement("div", {
4735
- className: "group relative block cursor-pointer",
4736
- onClick: () => {
4737
- setFilenameTouched(true);
4738
- }
4739
- }, /* @__PURE__ */ React__default["default"].createElement("input", {
4740
- type: "text",
4741
- className: `shadow-inner focus:shadow-outline focus:border-blue-500 focus:outline-none block text-base pr-3 truncate py-2 w-full border transition-all ease-out duration-150 focus:text-gray-900 rounded-md ${props.readonly || !filenameTouched ? "bg-gray-50 text-gray-300 border-gray-150 pointer-events-none pl-8 group-hover:bg-white group-hover:text-gray-600 group-hover:border-gray-200" : "bg-white text-gray-600 border-gray-200 pl-3"}`,
4742
- ...props,
4743
- disabled: props.readonly || !filenameTouched
4744
- }), /* @__PURE__ */ React__default["default"].createElement(FaLock, {
4745
- className: `text-gray-400 absolute top-1/2 left-2 -translate-y-1/2 pointer-events-none h-5 w-auto transition-opacity duration-150 ease-out ${!filenameTouched && !props.readonly ? "opacity-20 group-hover:opacity-0 group-active:opacity-0" : "opacity-0"}`
4746
- }), /* @__PURE__ */ React__default["default"].createElement(FaUnlock, {
4747
- className: `text-blue-500 absolute top-1/2 left-2 -translate-y-1/2 pointer-events-none h-5 w-auto transition-opacity duration-150 ease-out ${!filenameTouched && !props.readonly ? "opacity-0 group-hover:opacity-80 group-active:opacity-80" : "opacity-0"}`
4748
- }));
5034
+ const [filenameTouched, setFilenameTouched] = React.useState(false);
5035
+ return /* @__PURE__ */ React.createElement(
5036
+ "div",
5037
+ {
5038
+ className: "group relative block cursor-pointer",
5039
+ onClick: () => {
5040
+ setFilenameTouched(true);
5041
+ }
5042
+ },
5043
+ /* @__PURE__ */ React.createElement(
5044
+ "input",
5045
+ {
5046
+ type: "text",
5047
+ className: `shadow-inner focus:shadow-outline focus:border-blue-500 focus:outline-none block text-base pr-3 truncate py-2 w-full border transition-all ease-out duration-150 focus:text-gray-900 rounded-md ${props.readonly || !filenameTouched ? "bg-gray-50 text-gray-300 border-gray-150 pointer-events-none pl-8 group-hover:bg-white group-hover:text-gray-600 group-hover:border-gray-200" : "bg-white text-gray-600 border-gray-200 pl-3"}`,
5048
+ ...props,
5049
+ disabled: props.readonly || !filenameTouched
5050
+ }
5051
+ ),
5052
+ /* @__PURE__ */ React.createElement(
5053
+ FaLock,
5054
+ {
5055
+ className: `text-gray-400 absolute top-1/2 left-2 -translate-y-1/2 pointer-events-none h-5 w-auto transition-opacity duration-150 ease-out ${!filenameTouched && !props.readonly ? "opacity-20 group-hover:opacity-0 group-active:opacity-0" : "opacity-0"}`
5056
+ }
5057
+ ),
5058
+ /* @__PURE__ */ React.createElement(
5059
+ FaUnlock,
5060
+ {
5061
+ className: `text-blue-500 absolute top-1/2 left-2 -translate-y-1/2 pointer-events-none h-5 w-auto transition-opacity duration-150 ease-out ${!filenameTouched && !props.readonly ? "opacity-0 group-hover:opacity-80 group-active:opacity-80" : "opacity-0"}`
5062
+ }
5063
+ )
5064
+ );
4749
5065
  };
4750
5066
  const RenderForm$1 = ({
4751
5067
  cms,
@@ -4772,7 +5088,9 @@ This will work when developing locally but NOT when deployed to production.
4772
5088
  });
4773
5089
  let slugFunction = (_b = (_a = schemaCollection.ui) == null ? void 0 : _a.filename) == null ? void 0 : _b.slugify;
4774
5090
  if (!slugFunction) {
4775
- const titleField = (_c = template == null ? void 0 : template.fields.find((x) => x.required && x.type === "string" && x.isTitle)) == null ? void 0 : _c.name;
5091
+ const titleField = (_c = template == null ? void 0 : template.fields.find(
5092
+ (x) => x.required && x.type === "string" && x.isTitle
5093
+ )) == null ? void 0 : _c.name;
4776
5094
  if (titleField) {
4777
5095
  slugFunction = (values) => {
4778
5096
  var _a2;
@@ -4780,7 +5098,9 @@ This will work when developing locally but NOT when deployed to production.
4780
5098
  };
4781
5099
  }
4782
5100
  }
4783
- const defaultItem = customDefaults || ((_d = template.ui) == null ? void 0 : _d.defaultItem) || (template == null ? void 0 : template.defaultItem);
5101
+ const defaultItem = customDefaults || // @ts-ignore internal types aren't up to date
5102
+ ((_d = template.ui) == null ? void 0 : _d.defaultItem) || // @ts-ignore
5103
+ (template == null ? void 0 : template.defaultItem);
4784
5104
  const form = React.useMemo(() => {
4785
5105
  var _a2, _b2;
4786
5106
  const folderName = folder.fullyQualifiedName ? folder.name : "";
@@ -4807,13 +5127,16 @@ This will work when developing locally but NOT when deployed to production.
4807
5127
  label: "Filename",
4808
5128
  component: slugFunction ? toolkit.wrapFieldsWithMeta(({ field, input, meta }) => {
4809
5129
  var _a3, _b3;
4810
- return /* @__PURE__ */ React__default["default"].createElement(FilenameInput, {
4811
- readonly: (_b3 = (_a3 = schemaCollection == null ? void 0 : schemaCollection.ui) == null ? void 0 : _a3.filename) == null ? void 0 : _b3.readonly,
4812
- ...input
4813
- });
5130
+ return /* @__PURE__ */ React.createElement(
5131
+ FilenameInput,
5132
+ {
5133
+ readonly: (_b3 = (_a3 = schemaCollection == null ? void 0 : schemaCollection.ui) == null ? void 0 : _a3.filename) == null ? void 0 : _b3.readonly,
5134
+ ...input
5135
+ }
5136
+ );
4814
5137
  }) : "text",
4815
5138
  disabled: (_b2 = (_a2 = schemaCollection == null ? void 0 : schemaCollection.ui) == null ? void 0 : _a2.filename) == null ? void 0 : _b2.readonly,
4816
- description: /* @__PURE__ */ React__default["default"].createElement("span", null, "A unique filename for the content.", /* @__PURE__ */ React__default["default"].createElement("br", null), "Examples: ", /* @__PURE__ */ React__default["default"].createElement("code", null, "My_Document"), ", ", /* @__PURE__ */ React__default["default"].createElement("code", null, "My_Document.en"), ",", " ", /* @__PURE__ */ React__default["default"].createElement("code", null, "sub-folder/My_Document")),
5139
+ description: /* @__PURE__ */ React.createElement("span", null, "A unique filename for the content.", /* @__PURE__ */ React.createElement("br", null), "Examples: ", /* @__PURE__ */ React.createElement("code", null, "My_Document"), ", ", /* @__PURE__ */ React.createElement("code", null, "My_Document.en"), ",", " ", /* @__PURE__ */ React.createElement("code", null, "sub-folder/My_Document")),
4817
5140
  placeholder: `My_Document`,
4818
5141
  validate: (value, allValues, meta) => {
4819
5142
  var _a3, _b3;
@@ -4828,7 +5151,9 @@ This will work when developing locally but NOT when deployed to production.
4828
5151
  return "Must begin with a-z, A-Z, 0-9, or _ and contain only a-z, A-Z, 0-9, -, _, ., or /.";
4829
5152
  }
4830
5153
  if (((_a3 = schemaCollection.match) == null ? void 0 : _a3.exclude) || ((_b3 = schemaCollection.match) == null ? void 0 : _b3.include)) {
4831
- const filePath = `${schemaTools.normalizePath(schemaCollection.path)}/${value}.${schemaCollection.format || "md"}`;
5154
+ const filePath = `${schemaTools.normalizePath(
5155
+ schemaCollection.path
5156
+ )}/${value}.${schemaCollection.format || "md"}`;
4832
5157
  const match = schema.matchFiles({
4833
5158
  files: [filePath],
4834
5159
  collection: schemaCollection
@@ -4843,20 +5168,33 @@ This will work when developing locally but NOT when deployed to production.
4843
5168
  onSubmit: async (values) => {
4844
5169
  try {
4845
5170
  const folderName2 = folder.fullyQualifiedName ? folder.name : "";
4846
- await createDocument(cms, collection, template, mutationInfo, folderName2, values);
5171
+ await createDocument(
5172
+ cms,
5173
+ collection,
5174
+ template,
5175
+ mutationInfo,
5176
+ folderName2,
5177
+ values
5178
+ );
4847
5179
  cms.alerts.success("Document created!");
4848
5180
  setTimeout(() => {
4849
- navigate(`/collections/${collection.name}${folder.fullyQualifiedName ? `/${folder.fullyQualifiedName}` : ""}`);
5181
+ navigate(
5182
+ `/collections/${collection.name}${folder.fullyQualifiedName ? `/${folder.fullyQualifiedName}` : ""}`
5183
+ );
4850
5184
  }, 10);
4851
5185
  } catch (error) {
4852
5186
  console.error(error);
4853
5187
  const defaultErrorText = "There was a problem saving your document.";
4854
5188
  if (error.message.includes("already exists")) {
4855
- cms.alerts.error(`${defaultErrorText} The "Filename" is alredy used for another document, please modify it.`);
5189
+ cms.alerts.error(
5190
+ `${defaultErrorText} The "Filename" is alredy used for another document, please modify it.`
5191
+ );
4856
5192
  } else {
4857
5193
  cms.alerts.error(defaultErrorText);
4858
5194
  }
4859
- throw new Error(`[${error.name}] CreateDocument failed: ${error.message}`);
5195
+ throw new Error(
5196
+ `[${error.name}] CreateDocument failed: ${error.message}`
5197
+ );
4860
5198
  }
4861
5199
  }
4862
5200
  });
@@ -4865,7 +5203,7 @@ This will work when developing locally but NOT when deployed to production.
4865
5203
  const windowWidth = windowSize.useWindowWidth();
4866
5204
  const renderNavToggle = windowWidth < navBreakpoint + 1;
4867
5205
  const headerPadding = renderNavToggle ? "px-20" : "px-6";
4868
- React__default["default"].useEffect(() => {
5206
+ React.useEffect(() => {
4869
5207
  cms.dispatch({ type: "forms:add", value: form });
4870
5208
  cms.dispatch({ type: "forms:set-active-form-id", value: form.id });
4871
5209
  return () => {
@@ -4876,24 +5214,23 @@ This will work when developing locally but NOT when deployed to production.
4876
5214
  if (!cms.state.activeFormId) {
4877
5215
  return null;
4878
5216
  }
4879
- const activeForm = cms.state.forms.find(({ tinaForm }) => tinaForm.id === form.id);
4880
- return /* @__PURE__ */ React__default["default"].createElement(PageWrapper, null, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.isLocalMode) ? /* @__PURE__ */ React__default["default"].createElement(toolkit.LocalWarning, null) : /* @__PURE__ */ React__default["default"].createElement(toolkit.BillingWarning, null), /* @__PURE__ */ React__default["default"].createElement("div", {
4881
- className: `pt-3 pb-4 border-b border-gray-200 bg-white w-full grow-0 shrink basis-0 flex justify-center ${headerPadding}`
4882
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
4883
- className: "w-full max-w-form flex gap-1.5 justify-between items-center"
4884
- }, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
4885
- to: `/collections/${collection.name}${folder.fullyQualifiedName ? `/${folder.fullyQualifiedName}` : ""}`,
4886
- className: "flex-0 text-blue-500 hover:text-blue-400 hover:underline underline decoration-blue-200 hover:decoration-blue-400 text-sm leading-tight whitespace-nowrap truncate transition-all duration-150 ease-out"
4887
- }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React__default["default"].createElement("span", {
4888
- className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0"
4889
- }, "/"), /* @__PURE__ */ React__default["default"].createElement("span", {
4890
- className: "flex-1 w-full text-sm leading-tight whitespace-nowrap truncate"
4891
- }, "Create New"), /* @__PURE__ */ React__default["default"].createElement(toolkit.FormStatus, {
4892
- pristine: formIsPristine
4893
- }))), activeForm && /* @__PURE__ */ React__default["default"].createElement(toolkit.FormBuilder, {
4894
- form: activeForm,
4895
- onPristineChange: setFormIsPristine
4896
- })));
5217
+ const activeForm = cms.state.forms.find(
5218
+ ({ tinaForm }) => tinaForm.id === form.id
5219
+ );
5220
+ return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.isLocalMode) ? /* @__PURE__ */ React.createElement(toolkit.LocalWarning, null) : /* @__PURE__ */ React.createElement(toolkit.BillingWarning, null), /* @__PURE__ */ React.createElement(
5221
+ "div",
5222
+ {
5223
+ className: `pt-3 pb-4 border-b border-gray-200 bg-white w-full grow-0 shrink basis-0 flex justify-center ${headerPadding}`
5224
+ },
5225
+ /* @__PURE__ */ React.createElement("div", { className: "w-full max-w-form flex gap-1.5 justify-between items-center" }, /* @__PURE__ */ React.createElement(
5226
+ reactRouterDom.Link,
5227
+ {
5228
+ to: `/collections/${collection.name}${folder.fullyQualifiedName ? `/${folder.fullyQualifiedName}` : ""}`,
5229
+ className: "flex-0 text-blue-500 hover:text-blue-400 hover:underline underline decoration-blue-200 hover:decoration-blue-400 text-sm leading-tight whitespace-nowrap truncate transition-all duration-150 ease-out"
5230
+ },
5231
+ collection.label ? collection.label : collection.name
5232
+ ), /* @__PURE__ */ React.createElement("span", { className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0" }, "/"), /* @__PURE__ */ React.createElement("span", { className: "flex-1 w-full text-sm leading-tight whitespace-nowrap truncate" }, "Create New"), /* @__PURE__ */ React.createElement(toolkit.FormStatus, { pristine: formIsPristine }))
5233
+ ), activeForm && /* @__PURE__ */ React.createElement(toolkit.FormBuilder, { form: activeForm, onPristineChange: setFormIsPristine })));
4897
5234
  };
4898
5235
  const useGetDocument = (cms, collectionName, relativePath2) => {
4899
5236
  const api = new TinaAdminApi(cms);
@@ -4907,7 +5244,9 @@ This will work when developing locally but NOT when deployed to production.
4907
5244
  const response = await api.fetchDocument(collectionName, relativePath2);
4908
5245
  setDocument(response.document);
4909
5246
  } catch (error2) {
4910
- cms.alerts.error(`[${error2.name}] GetDocument failed: ${error2.message}`);
5247
+ cms.alerts.error(
5248
+ `[${error2.name}] GetDocument failed: ${error2.message}`
5249
+ );
4911
5250
  console.error(error2);
4912
5251
  setDocument(void 0);
4913
5252
  setError(error2);
@@ -4926,46 +5265,61 @@ This will work when developing locally but NOT when deployed to production.
4926
5265
  relativePath: relativePath2,
4927
5266
  children
4928
5267
  }) => {
4929
- const { document, loading, error } = useGetDocument(cms, collectionName, relativePath2);
5268
+ const { document, loading, error } = useGetDocument(
5269
+ cms,
5270
+ collectionName,
5271
+ relativePath2
5272
+ );
4930
5273
  if (error) {
4931
- return /* @__PURE__ */ React__default["default"].createElement(FullscreenError, null);
5274
+ return /* @__PURE__ */ React.createElement(FullscreenError, null);
4932
5275
  }
4933
5276
  if (loading) {
4934
- return /* @__PURE__ */ React__default["default"].createElement(LoadingPage, null);
5277
+ return /* @__PURE__ */ React.createElement(LoadingPage, null);
4935
5278
  }
4936
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(document, loading));
5279
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children(document, loading));
4937
5280
  };
4938
5281
  const CollectionDuplicatePage = () => {
4939
5282
  const folder = useCollectionFolder();
4940
5283
  const { collectionName, ...rest } = reactRouterDom.useParams();
4941
5284
  const { "*": filename } = rest;
4942
- return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => /* @__PURE__ */ React__default["default"].createElement(GetCollection, {
4943
- cms,
4944
- collectionName,
4945
- folder,
4946
- includeDocuments: false
4947
- }, (collection) => {
4948
- const relativePath2 = `${filename.startsWith("~/") ? filename.substring(2) : filename}.${collection.format}`;
4949
- const mutationInfo = {
4950
- includeCollection: true,
4951
- includeTemplate: !!collection.templates
4952
- };
4953
- return /* @__PURE__ */ React__default["default"].createElement(GetDocument, {
5285
+ return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => /* @__PURE__ */ React.createElement(
5286
+ GetCollection,
5287
+ {
4954
5288
  cms,
4955
- collectionName: collection.name,
4956
- relativePath: relativePath2
4957
- }, (document) => {
4958
- var _a;
4959
- return /* @__PURE__ */ React__default["default"].createElement(RenderForm$1, {
4960
- cms,
4961
- collection,
4962
- templateName: (_a = document._values) == null ? void 0 : _a._template,
4963
- folder: parentFolder(folder),
4964
- mutationInfo,
4965
- customDefaults: document._values
4966
- });
4967
- });
4968
- }));
5289
+ collectionName,
5290
+ folder,
5291
+ includeDocuments: false
5292
+ },
5293
+ (collection) => {
5294
+ const relativePath2 = `${filename.startsWith("~/") ? filename.substring(2) : filename}.${collection.format}`;
5295
+ const mutationInfo = {
5296
+ includeCollection: true,
5297
+ includeTemplate: !!collection.templates
5298
+ };
5299
+ return /* @__PURE__ */ React.createElement(
5300
+ GetDocument,
5301
+ {
5302
+ cms,
5303
+ collectionName: collection.name,
5304
+ relativePath: relativePath2
5305
+ },
5306
+ (document) => {
5307
+ var _a;
5308
+ return /* @__PURE__ */ React.createElement(
5309
+ RenderForm$1,
5310
+ {
5311
+ cms,
5312
+ collection,
5313
+ templateName: (_a = document._values) == null ? void 0 : _a._template,
5314
+ folder: parentFolder(folder),
5315
+ mutationInfo,
5316
+ customDefaults: document._values
5317
+ }
5318
+ );
5319
+ }
5320
+ );
5321
+ }
5322
+ ));
4969
5323
  };
4970
5324
  const updateDocument = async (cms, relativePath2, collection, mutationInfo, values) => {
4971
5325
  const api = new TinaAdminApi(cms);
@@ -4984,30 +5338,41 @@ This will work when developing locally but NOT when deployed to production.
4984
5338
  const folder = useCollectionFolder();
4985
5339
  const { "*": filename } = rest;
4986
5340
  const resolvedFile = folder.fullyQualifiedName ? folder.name : filename;
4987
- return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => /* @__PURE__ */ React__default["default"].createElement(GetCollection, {
4988
- cms,
4989
- collectionName,
4990
- folder,
4991
- includeDocuments: false
4992
- }, (collection) => {
4993
- const relativePath2 = `${resolvedFile}.${collection.format}`;
4994
- const mutationInfo = {
4995
- includeCollection: true,
4996
- includeTemplate: !!collection.templates
4997
- };
4998
- return /* @__PURE__ */ React__default["default"].createElement(PageWrapper, null, /* @__PURE__ */ React__default["default"].createElement(GetDocument, {
5341
+ return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => /* @__PURE__ */ React.createElement(
5342
+ GetCollection,
5343
+ {
4999
5344
  cms,
5000
- collectionName: collection.name,
5001
- relativePath: relativePath2
5002
- }, (document) => /* @__PURE__ */ React__default["default"].createElement(RenderForm, {
5003
- cms,
5004
- document,
5005
- filename: resolvedFile,
5006
- relativePath: relativePath2,
5007
- collection,
5008
- mutationInfo
5009
- })));
5010
- }));
5345
+ collectionName,
5346
+ folder,
5347
+ includeDocuments: false
5348
+ },
5349
+ (collection) => {
5350
+ const relativePath2 = `${resolvedFile}.${collection.format}`;
5351
+ const mutationInfo = {
5352
+ includeCollection: true,
5353
+ includeTemplate: !!collection.templates
5354
+ };
5355
+ return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(
5356
+ GetDocument,
5357
+ {
5358
+ cms,
5359
+ collectionName: collection.name,
5360
+ relativePath: relativePath2
5361
+ },
5362
+ (document) => /* @__PURE__ */ React.createElement(
5363
+ RenderForm,
5364
+ {
5365
+ cms,
5366
+ document,
5367
+ filename: resolvedFile,
5368
+ relativePath: relativePath2,
5369
+ collection,
5370
+ mutationInfo
5371
+ }
5372
+ )
5373
+ ));
5374
+ }
5375
+ ));
5011
5376
  };
5012
5377
  const RenderForm = ({
5013
5378
  cms,
@@ -5034,17 +5399,26 @@ This will work when developing locally but NOT when deployed to production.
5034
5399
  });
5035
5400
  const form = React.useMemo(() => {
5036
5401
  return new toolkit.Form({
5402
+ // id is the full document path
5037
5403
  id: `${schemaCollection.path}/${relativePath2}`,
5038
5404
  label: "form",
5039
5405
  fields: formInfo.fields,
5040
5406
  initialValues: document._values,
5041
5407
  onSubmit: async (values) => {
5042
5408
  try {
5043
- await updateDocument(cms, relativePath2, collection, mutationInfo, values);
5409
+ await updateDocument(
5410
+ cms,
5411
+ relativePath2,
5412
+ collection,
5413
+ mutationInfo,
5414
+ values
5415
+ );
5044
5416
  cms.alerts.success("Document updated!");
5045
5417
  } catch (error) {
5046
5418
  console.error(error);
5047
- throw new Error(`[${error.name}] UpdateDocument failed: ${error.message}`);
5419
+ throw new Error(
5420
+ `[${error.name}] UpdateDocument failed: ${error.message}`
5421
+ );
5048
5422
  }
5049
5423
  }
5050
5424
  });
@@ -5053,7 +5427,7 @@ This will work when developing locally but NOT when deployed to production.
5053
5427
  const windowWidth = windowSize.useWindowWidth();
5054
5428
  const renderNavToggle = windowWidth < navBreakpoint + 1;
5055
5429
  const headerPadding = renderNavToggle ? "px-20" : "px-6";
5056
- React__default["default"].useEffect(() => {
5430
+ React.useEffect(() => {
5057
5431
  cms.dispatch({ type: "forms:add", value: form });
5058
5432
  cms.dispatch({ type: "forms:set-active-form-id", value: form.id });
5059
5433
  return () => {
@@ -5064,44 +5438,37 @@ This will work when developing locally but NOT when deployed to production.
5064
5438
  if (!cms.state.activeFormId) {
5065
5439
  return null;
5066
5440
  }
5067
- const activeForm = cms.state.forms.find(({ tinaForm }) => tinaForm.id === form.id);
5068
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode) ? /* @__PURE__ */ React__default["default"].createElement(toolkit.LocalWarning, null) : /* @__PURE__ */ React__default["default"].createElement(toolkit.BillingWarning, null), /* @__PURE__ */ React__default["default"].createElement("div", {
5069
- className: `pt-3 pb-4 border-b border-gray-200 bg-white w-full grow-0 shrink basis-0 flex justify-center ${headerPadding}`
5070
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
5071
- className: "w-full max-w-form flex gap-1.5 justify-between items-center"
5072
- }, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
5073
- to: `/collections/${collection.name}/~${parentFolder2}`,
5074
- className: "flex-0 text-blue-500 hover:text-blue-400 hover:underline underline decoration-blue-200 hover:decoration-blue-400 text-sm leading-tight whitespace-nowrap truncate transition-all duration-150 ease-out"
5075
- }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React__default["default"].createElement("span", {
5076
- className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0"
5077
- }, "/"), /* @__PURE__ */ React__default["default"].createElement("span", {
5078
- className: "flex-1 w-full text-sm leading-tight whitespace-nowrap truncate"
5079
- }, `${filename}.${collection.format}`), /* @__PURE__ */ React__default["default"].createElement(toolkit.FormStatus, {
5080
- pristine: formIsPristine
5081
- }))), activeForm && /* @__PURE__ */ React__default["default"].createElement(toolkit.FormBuilder, {
5082
- form: activeForm,
5083
- onPristineChange: setFormIsPristine
5084
- }));
5441
+ const activeForm = cms.state.forms.find(
5442
+ ({ tinaForm }) => tinaForm.id === form.id
5443
+ );
5444
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode) ? /* @__PURE__ */ React.createElement(toolkit.LocalWarning, null) : /* @__PURE__ */ React.createElement(toolkit.BillingWarning, null), /* @__PURE__ */ React.createElement(
5445
+ "div",
5446
+ {
5447
+ className: `pt-3 pb-4 border-b border-gray-200 bg-white w-full grow-0 shrink basis-0 flex justify-center ${headerPadding}`
5448
+ },
5449
+ /* @__PURE__ */ React.createElement("div", { className: "w-full max-w-form flex gap-1.5 justify-between items-center" }, /* @__PURE__ */ React.createElement(
5450
+ reactRouterDom.Link,
5451
+ {
5452
+ to: `/collections/${collection.name}/~${parentFolder2}`,
5453
+ className: "flex-0 text-blue-500 hover:text-blue-400 hover:underline underline decoration-blue-200 hover:decoration-blue-400 text-sm leading-tight whitespace-nowrap truncate transition-all duration-150 ease-out"
5454
+ },
5455
+ collection.label ? collection.label : collection.name
5456
+ ), /* @__PURE__ */ React.createElement("span", { className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0" }, "/"), /* @__PURE__ */ React.createElement("span", { className: "flex-1 w-full text-sm leading-tight whitespace-nowrap truncate" }, `${filename}.${collection.format}`), /* @__PURE__ */ React.createElement(toolkit.FormStatus, { pristine: formIsPristine }))
5457
+ ), activeForm && /* @__PURE__ */ React.createElement(toolkit.FormBuilder, { form: activeForm, onPristineChange: setFormIsPristine }));
5085
5458
  };
5086
5459
  const ScreenPage = () => {
5087
5460
  const { screenName } = reactRouterDom.useParams();
5088
5461
  const navBreakpoint = 1e3;
5089
5462
  const windowWidth = windowSize.useWindowWidth();
5090
5463
  const renderNavToggle = windowWidth < navBreakpoint + 1;
5091
- return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => {
5464
+ return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => {
5092
5465
  var _a, _b;
5093
5466
  const screens = cms.plugins.getType("screen").all();
5094
- const selectedScreen = screens.find(({ name }) => slugify(name) === screenName);
5095
- return /* @__PURE__ */ React__default["default"].createElement("div", {
5096
- className: "relative w-full h-full flex flex-col items-stretch justify-between"
5097
- }, ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode) ? /* @__PURE__ */ React__default["default"].createElement(toolkit.LocalWarning, null) : /* @__PURE__ */ React__default["default"].createElement(toolkit.BillingWarning, null), renderNavToggle && /* @__PURE__ */ React__default["default"].createElement("div", {
5098
- className: `py-5 border-b border-gray-200 bg-white pl-18`
5099
- }, selectedScreen.name), /* @__PURE__ */ React__default["default"].createElement("div", {
5100
- className: "flex-1 overflow-y-auto relative flex flex-col items-stretch justify-between"
5101
- }, /* @__PURE__ */ React__default["default"].createElement(selectedScreen.Component, {
5102
- close: () => {
5103
- }
5104
- })));
5467
+ const selectedScreen = screens.find(
5468
+ ({ name }) => slugify(name) === screenName
5469
+ );
5470
+ return /* @__PURE__ */ React.createElement("div", { className: "relative w-full h-full flex flex-col items-stretch justify-between" }, ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode) ? /* @__PURE__ */ React.createElement(toolkit.LocalWarning, null) : /* @__PURE__ */ React.createElement(toolkit.BillingWarning, null), renderNavToggle && /* @__PURE__ */ React.createElement("div", { className: `py-5 border-b border-gray-200 bg-white pl-18` }, selectedScreen.name), /* @__PURE__ */ React.createElement("div", { className: "flex-1 overflow-y-auto relative flex flex-col items-stretch justify-between" }, /* @__PURE__ */ React.createElement(selectedScreen.Component, { close: () => {
5471
+ } })));
5105
5472
  });
5106
5473
  };
5107
5474
  const IndexingPage = () => {
@@ -5110,14 +5477,22 @@ This will work when developing locally but NOT when deployed to production.
5110
5477
  const currentBranch = tinaApi.branch;
5111
5478
  const kind = localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.kind");
5112
5479
  const { setCurrentBranch } = toolkit.useBranchData();
5113
- const [state, setState] = React__default["default"].useState(localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState"));
5114
- const [errorMessage, setErrorMessage] = React__default["default"].useState("");
5115
- const [baseBranch, setBaseBranch] = React__default["default"].useState(localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.baseBranch"));
5480
+ const [state, setState] = React.useState(
5481
+ localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState")
5482
+ );
5483
+ const [errorMessage, setErrorMessage] = React.useState("");
5484
+ const [baseBranch, setBaseBranch] = React.useState(
5485
+ localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.baseBranch")
5486
+ );
5116
5487
  const [searchParams] = reactRouterDom.useSearchParams();
5117
5488
  const back = localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.back");
5118
5489
  const fullPath = localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.fullPath");
5119
- const values = JSON.parse(localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.values"));
5120
- const [branch, setBranch] = React__default["default"].useState("tina/" + searchParams.get("branch"));
5490
+ const values = JSON.parse(
5491
+ localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.values")
5492
+ );
5493
+ const [branch, setBranch] = React.useState(
5494
+ "tina/" + searchParams.get("branch")
5495
+ );
5121
5496
  React.useEffect(() => {
5122
5497
  const run = async () => {
5123
5498
  if (state === "starting") {
@@ -5137,14 +5512,18 @@ This will work when developing locally but NOT when deployed to production.
5137
5512
  } catch (e) {
5138
5513
  console.error(e);
5139
5514
  cms.alerts.error("Branch creation failed: " + e.message);
5140
- setErrorMessage("Branch creation failed, please try again. By refreshing the page.");
5515
+ setErrorMessage(
5516
+ "Branch creation failed, please try again. By refreshing the page."
5517
+ );
5141
5518
  setState("error");
5142
5519
  }
5143
5520
  }
5144
5521
  if (state === "indexing") {
5145
5522
  try {
5146
5523
  const [
5524
+ // When this promise resolves, we know the index status is no longer 'inprogress' or 'unknown'
5147
5525
  waitForIndexStatusPromise,
5526
+ // Calling this function will cancel the polling
5148
5527
  _cancelWaitForIndexFunc
5149
5528
  ] = tinaApi.waitForIndexStatus({
5150
5529
  ref: branch
@@ -5155,14 +5534,19 @@ This will work when developing locally but NOT when deployed to production.
5155
5534
  setState("submitting");
5156
5535
  } catch {
5157
5536
  cms.alerts.error("Branch indexing failed.");
5158
- setErrorMessage('Branch indexing failed, please check the Tina Cloud dashboard for more information. To try again chick "re-index" on the branch in the dashboard.');
5537
+ setErrorMessage(
5538
+ 'Branch indexing failed, please check the Tina Cloud dashboard for more information. To try again chick "re-index" on the branch in the dashboard.'
5539
+ );
5159
5540
  setState("error");
5160
5541
  }
5161
5542
  }
5162
5543
  if (state === "submitting") {
5163
5544
  try {
5164
5545
  setBaseBranch(tinaApi.branch);
5165
- localStorage.setItem("tina.createBranchState.baseBranch", tinaApi.branch);
5546
+ localStorage.setItem(
5547
+ "tina.createBranchState.baseBranch",
5548
+ tinaApi.branch
5549
+ );
5166
5550
  setCurrentBranch(branch);
5167
5551
  const collection = tinaApi.schema.getCollectionByFullPath(fullPath);
5168
5552
  const api = new TinaAdminApi(cms);
@@ -5188,7 +5572,9 @@ This will work when developing locally but NOT when deployed to production.
5188
5572
  } catch (e) {
5189
5573
  console.error(e);
5190
5574
  cms.alerts.error("Content save failed.");
5191
- setErrorMessage("Content save failed, please try again. If the problem persists please contact support.");
5575
+ setErrorMessage(
5576
+ "Content save failed, please try again. If the problem persists please contact support."
5577
+ );
5192
5578
  setState("error");
5193
5579
  }
5194
5580
  }
@@ -5196,7 +5582,7 @@ This will work when developing locally but NOT when deployed to production.
5196
5582
  const foo = await tinaApi.createPullRequest({
5197
5583
  baseBranch,
5198
5584
  branch,
5199
- title: "PR from TinaCMS"
5585
+ title: `${branch.replace("tina/", "").replace("-", " ")} (PR from TinaCMS)`
5200
5586
  });
5201
5587
  console.log("PR created", foo);
5202
5588
  cms.alerts.success("Pull request created.");
@@ -5212,21 +5598,18 @@ This will work when developing locally but NOT when deployed to production.
5212
5598
  }
5213
5599
  }, [state]);
5214
5600
  if (!back || !fullPath || !values || !branch) {
5215
- return /* @__PURE__ */ React__default["default"].createElement(Wrapper, null, /* @__PURE__ */ React__default["default"].createElement("p", null, "Missing params please try again."));
5601
+ return /* @__PURE__ */ React.createElement(Wrapper, null, /* @__PURE__ */ React.createElement("p", null, "Missing params please try again."));
5216
5602
  }
5217
- return /* @__PURE__ */ React__default["default"].createElement(Wrapper, null, state !== "done" && state !== "error" && /* @__PURE__ */ React__default["default"].createElement(BiLoaderAlt, {
5218
- className: `opacity-70 text-blue-400 animate-spin w-10 h-auto`
5219
- }), (state === "starting" || state === "creatingBranch") && /* @__PURE__ */ React__default["default"].createElement("p", null, "Creating branch\u2026"), state === "indexing" && /* @__PURE__ */ React__default["default"].createElement("p", null, "Indexing Content\u2026"), state === "submitting" && /* @__PURE__ */ React__default["default"].createElement("p", null, "Saving content\u2026"), state === "creatingPR" && /* @__PURE__ */ React__default["default"].createElement("p", null, "Creating Pull Request\u2026"), state === "error" && /* @__PURE__ */ React__default["default"].createElement("p", {
5220
- className: "flex items-center gap-1 text-red-700"
5221
- }, /* @__PURE__ */ React__default["default"].createElement(BiError, {
5222
- className: "w-7 h-auto text-red-400 flex-shrink-0"
5223
- }), " ", /* @__PURE__ */ React__default["default"].createElement("b", null, "Error:"), " ", errorMessage, " "));
5603
+ return /* @__PURE__ */ React.createElement(Wrapper, null, state !== "done" && state !== "error" && /* @__PURE__ */ React.createElement(
5604
+ BiLoaderAlt,
5605
+ {
5606
+ className: `opacity-70 text-blue-400 animate-spin w-10 h-auto`
5607
+ }
5608
+ ), (state === "starting" || state === "creatingBranch") && /* @__PURE__ */ React.createElement("p", null, "Creating branch…"), state === "indexing" && /* @__PURE__ */ React.createElement("p", null, "Indexing Content…"), state === "submitting" && /* @__PURE__ */ React.createElement("p", null, "Saving content…"), state === "creatingPR" && /* @__PURE__ */ React.createElement("p", null, "Creating Pull Request…"), state === "error" && /* @__PURE__ */ React.createElement("p", { className: "flex items-center gap-1 text-red-700" }, /* @__PURE__ */ React.createElement(BiError, { className: "w-7 h-auto text-red-400 flex-shrink-0" }), " ", /* @__PURE__ */ React.createElement("b", null, "Error:"), " ", errorMessage, " "));
5224
5609
  };
5225
- const Wrapper = ({ children }) => /* @__PURE__ */ React__default["default"].createElement("div", {
5226
- className: "w-full h-full flex flex-col justify-center items-center gap-4 p-6 text-xl text-gray-700"
5227
- }, children);
5610
+ const Wrapper = ({ children }) => /* @__PURE__ */ React.createElement("div", { className: "w-full h-full flex flex-col justify-center items-center gap-4 p-6 text-xl text-gray-700" }, children);
5228
5611
  const Redirect = () => {
5229
- React__default["default"].useEffect(() => {
5612
+ React.useEffect(() => {
5230
5613
  if (window) {
5231
5614
  window.location.assign("/");
5232
5615
  }
@@ -5238,7 +5621,7 @@ This will work when developing locally but NOT when deployed to production.
5238
5621
  children
5239
5622
  }) => {
5240
5623
  const navigate = reactRouterDom.useNavigate();
5241
- React__default["default"].useEffect(() => {
5624
+ React.useEffect(() => {
5242
5625
  if (redirect) {
5243
5626
  navigate("/~");
5244
5627
  }
@@ -5249,7 +5632,7 @@ This will work when developing locally but NOT when deployed to production.
5249
5632
  preview,
5250
5633
  cms
5251
5634
  }) => {
5252
- React__default["default"].useEffect(() => {
5635
+ React.useEffect(() => {
5253
5636
  if (preview) {
5254
5637
  cms.flags.set("tina-iframe", true);
5255
5638
  }
@@ -5259,21 +5642,21 @@ This will work when developing locally but NOT when deployed to production.
5259
5642
  const PreviewInner = ({ preview, config }) => {
5260
5643
  const params = reactRouterDom.useParams();
5261
5644
  const navigate = reactRouterDom.useNavigate();
5262
- const [url, setURL] = React__default["default"].useState(`/${params["*"]}`);
5645
+ const [url, setURL] = React.useState(`/${params["*"]}`);
5263
5646
  const [reportedURL, setReportedURL] = React.useState(null);
5264
- const ref = React__default["default"].useRef(null);
5647
+ const ref = React.useRef(null);
5265
5648
  const paramURL = `/${params["*"]}`;
5266
- React__default["default"].useEffect(() => {
5649
+ React.useEffect(() => {
5267
5650
  if (reportedURL !== paramURL && paramURL) {
5268
5651
  setURL(paramURL);
5269
5652
  }
5270
5653
  }, [paramURL]);
5271
- React__default["default"].useEffect(() => {
5654
+ React.useEffect(() => {
5272
5655
  if ((reportedURL !== url || reportedURL !== paramURL) && reportedURL) {
5273
5656
  navigate(`/~${reportedURL}`);
5274
5657
  }
5275
5658
  }, [reportedURL]);
5276
- React__default["default"].useEffect(() => {
5659
+ React.useEffect(() => {
5277
5660
  setInterval(() => {
5278
5661
  var _a;
5279
5662
  if (ref.current) {
@@ -5287,11 +5670,7 @@ This will work when developing locally but NOT when deployed to production.
5287
5670
  }, 100);
5288
5671
  }, [ref.current]);
5289
5672
  const Preview = preview;
5290
- return /* @__PURE__ */ React__default["default"].createElement(Preview, {
5291
- url,
5292
- iframeRef: ref,
5293
- ...config
5294
- });
5673
+ return /* @__PURE__ */ React.createElement(Preview, { url, iframeRef: ref, ...config });
5295
5674
  };
5296
5675
  const CheckSchema = ({
5297
5676
  schemaJson,
@@ -5300,7 +5679,7 @@ This will work when developing locally but NOT when deployed to production.
5300
5679
  const cms = toolkit.useCMS();
5301
5680
  const api = new TinaAdminApi(cms);
5302
5681
  const url = api.api.contentApiUrl;
5303
- const [schemaMissingError, setSchemaMissingError] = React__default["default"].useState(false);
5682
+ const [schemaMissingError, setSchemaMissingError] = React.useState(false);
5304
5683
  const currentBranch = decodeURIComponent(cms.api.tina.branch);
5305
5684
  React.useEffect(() => {
5306
5685
  if (schemaJson && cms) {
@@ -5308,7 +5687,9 @@ This will work when developing locally but NOT when deployed to production.
5308
5687
  localSchema: schemaJson
5309
5688
  }).then((x) => {
5310
5689
  if (x === false) {
5311
- cms.alerts.error("GraphQL Schema Mismatch. Editing may not work. If you just switched branches, try going back to the previous branch");
5690
+ cms.alerts.error(
5691
+ "GraphQL Schema Mismatch. Editing may not work. If you just switched branches, try going back to the previous branch"
5692
+ );
5312
5693
  }
5313
5694
  }).catch((e) => {
5314
5695
  if (e.message.includes("has not been indexed by Tina Cloud")) {
@@ -5319,23 +5700,19 @@ This will work when developing locally but NOT when deployed to production.
5319
5700
  });
5320
5701
  }
5321
5702
  }, [cms, JSON.stringify(schemaJson || {}), url]);
5322
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, schemaMissingError ? /* @__PURE__ */ React__default["default"].createElement(toolkit.Modal, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.PopupModal, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalHeader, null, "Branch Not Found"), /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalBody, {
5323
- padded: true
5324
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
5325
- className: "tina-prose"
5326
- }, "The current branch (", /* @__PURE__ */ React__default["default"].createElement("span", {
5327
- className: "font-bold"
5328
- }, currentBranch), ") has either been merged or deleted.")), /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalActions, null, /* @__PURE__ */ React__default["default"].createElement("div", {
5329
- className: "flex-1"
5330
- }), /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
5331
- style: { flexGrow: 1 },
5332
- className: "w-full",
5333
- variant: "primary",
5334
- onClick: () => {
5335
- window.localStorage.removeItem("tinacms-current-branch");
5336
- window.location.reload();
5337
- }
5338
- }, "Switch back to default branch")))) : children);
5703
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, schemaMissingError ? /* @__PURE__ */ React.createElement(toolkit.Modal, null, /* @__PURE__ */ React.createElement(toolkit.PopupModal, null, /* @__PURE__ */ React.createElement(toolkit.ModalHeader, null, "Branch Not Found"), /* @__PURE__ */ React.createElement(toolkit.ModalBody, { padded: true }, /* @__PURE__ */ React.createElement("div", { className: "tina-prose" }, "The current branch (", /* @__PURE__ */ React.createElement("span", { className: "font-bold" }, currentBranch), ") has either been merged or deleted.")), /* @__PURE__ */ React.createElement(toolkit.ModalActions, null, /* @__PURE__ */ React.createElement("div", { className: "flex-1" }), /* @__PURE__ */ React.createElement(
5704
+ toolkit.Button,
5705
+ {
5706
+ style: { flexGrow: 1 },
5707
+ className: "w-full",
5708
+ variant: "primary",
5709
+ onClick: () => {
5710
+ window.localStorage.removeItem("tinacms-current-branch");
5711
+ window.location.reload();
5712
+ }
5713
+ },
5714
+ "Switch back to default branch"
5715
+ )))) : children);
5339
5716
  };
5340
5717
  const TinaAdmin = ({
5341
5718
  preview,
@@ -5349,9 +5726,9 @@ This will work when developing locally but NOT when deployed to production.
5349
5726
  return null;
5350
5727
  }
5351
5728
  if (!edit) {
5352
- return /* @__PURE__ */ React__default["default"].createElement(Layout, null, /* @__PURE__ */ React__default["default"].createElement(LoginPage, null));
5729
+ return /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement(LoginPage, null));
5353
5730
  }
5354
- return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => {
5731
+ return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => {
5355
5732
  var _a, _b, _c;
5356
5733
  const isTinaAdminEnabled = cms.flags.get("tina-admin") === false ? false : true;
5357
5734
  if (isTinaAdminEnabled) {
@@ -5361,91 +5738,99 @@ This will work when developing locally but NOT when deployed to production.
5361
5738
  return typeof ((_a2 = x == null ? void 0 : x.ui) == null ? void 0 : _a2.router) === "function";
5362
5739
  });
5363
5740
  const hasRouter = Boolean(collectionWithRouter);
5364
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement(CheckSchema, {
5365
- schemaJson
5366
- }, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.HashRouter, null, /* @__PURE__ */ React__default["default"].createElement(SetPreviewFlag, {
5367
- preview,
5368
- cms
5369
- }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Routes, null, preview && /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
5370
- path: "/~/*",
5371
- element: /* @__PURE__ */ React__default["default"].createElement(PreviewInner, {
5372
- config,
5373
- preview
5374
- })
5375
- }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
5376
- path: "graphql",
5377
- element: /* @__PURE__ */ React__default["default"].createElement(PlainLayout, null, /* @__PURE__ */ React__default["default"].createElement(Playground, null))
5378
- }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
5379
- path: "branch/new",
5380
- element: /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
5381
- cms
5382
- }, /* @__PURE__ */ React__default["default"].createElement(IndexingPage, null))
5383
- }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
5384
- path: "collections/new/:collectionName",
5385
- element: /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
5386
- cms
5387
- }, /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null))
5388
- }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
5389
- path: "collections/duplicate/:collectionName/~/*",
5390
- element: /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
5391
- cms
5392
- }, /* @__PURE__ */ React__default["default"].createElement(CollectionDuplicatePage, null))
5393
- }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
5394
- path: "collections/duplicate/:collectionName/*",
5395
- element: /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
5396
- cms
5397
- }, /* @__PURE__ */ React__default["default"].createElement(CollectionDuplicatePage, null))
5398
- }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
5399
- path: "collections/new/:collectionName/:templateName",
5400
- element: /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
5401
- cms
5402
- }, /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null))
5403
- }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
5404
- path: "collections/new/:collectionName/:templateName/~/*",
5405
- element: /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
5406
- cms
5407
- }, /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null))
5408
- }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
5409
- path: "collections/new/:collectionName/~/*",
5410
- element: /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
5411
- cms
5412
- }, /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null))
5413
- }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
5414
- path: "collections/edit/:collectionName/*",
5415
- element: /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
5416
- cms
5417
- }, /* @__PURE__ */ React__default["default"].createElement(CollectionUpdatePage, null))
5418
- }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
5419
- path: "collections/:collectionName/*",
5420
- element: /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
5421
- cms
5422
- }, /* @__PURE__ */ React__default["default"].createElement(CollectionListPage, null))
5423
- }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
5424
- path: "screens/:screenName",
5425
- element: /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
5426
- cms
5427
- }, /* @__PURE__ */ React__default["default"].createElement(ScreenPage, null))
5428
- }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
5429
- path: "logout",
5430
- element: /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
5431
- cms
5432
- }, /* @__PURE__ */ React__default["default"].createElement(LogoutRedirect, null))
5433
- }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
5434
- path: "/",
5435
- element: /* @__PURE__ */ React__default["default"].createElement(MaybeRedirectToPreview, {
5436
- redirect: !!preview && hasRouter
5437
- }, /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
5438
- cms
5439
- }, /* @__PURE__ */ React__default["default"].createElement(DashboardPage, null)))
5440
- })))));
5741
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CheckSchema, { schemaJson }, /* @__PURE__ */ React.createElement(reactRouterDom.HashRouter, null, /* @__PURE__ */ React.createElement(SetPreviewFlag, { preview, cms }), /* @__PURE__ */ React.createElement(reactRouterDom.Routes, null, preview && /* @__PURE__ */ React.createElement(
5742
+ reactRouterDom.Route,
5743
+ {
5744
+ path: "/~/*",
5745
+ element: /* @__PURE__ */ React.createElement(PreviewInner, { config, preview })
5746
+ }
5747
+ ), /* @__PURE__ */ React.createElement(
5748
+ reactRouterDom.Route,
5749
+ {
5750
+ path: "graphql",
5751
+ element: /* @__PURE__ */ React.createElement(PlainLayout, null, /* @__PURE__ */ React.createElement(Playground, null))
5752
+ }
5753
+ ), /* @__PURE__ */ React.createElement(
5754
+ reactRouterDom.Route,
5755
+ {
5756
+ path: "branch/new",
5757
+ element: /* @__PURE__ */ React.createElement(DefaultWrapper, { cms }, /* @__PURE__ */ React.createElement(IndexingPage, null))
5758
+ }
5759
+ ), /* @__PURE__ */ React.createElement(
5760
+ reactRouterDom.Route,
5761
+ {
5762
+ path: "collections/new/:collectionName",
5763
+ element: /* @__PURE__ */ React.createElement(DefaultWrapper, { cms }, /* @__PURE__ */ React.createElement(CollectionCreatePage, null))
5764
+ }
5765
+ ), /* @__PURE__ */ React.createElement(
5766
+ reactRouterDom.Route,
5767
+ {
5768
+ path: "collections/duplicate/:collectionName/~/*",
5769
+ element: /* @__PURE__ */ React.createElement(DefaultWrapper, { cms }, /* @__PURE__ */ React.createElement(CollectionDuplicatePage, null))
5770
+ }
5771
+ ), /* @__PURE__ */ React.createElement(
5772
+ reactRouterDom.Route,
5773
+ {
5774
+ path: "collections/duplicate/:collectionName/*",
5775
+ element: /* @__PURE__ */ React.createElement(DefaultWrapper, { cms }, /* @__PURE__ */ React.createElement(CollectionDuplicatePage, null))
5776
+ }
5777
+ ), /* @__PURE__ */ React.createElement(
5778
+ reactRouterDom.Route,
5779
+ {
5780
+ path: "collections/new/:collectionName/:templateName",
5781
+ element: /* @__PURE__ */ React.createElement(DefaultWrapper, { cms }, /* @__PURE__ */ React.createElement(CollectionCreatePage, null))
5782
+ }
5783
+ ), /* @__PURE__ */ React.createElement(
5784
+ reactRouterDom.Route,
5785
+ {
5786
+ path: "collections/new/:collectionName/:templateName/~/*",
5787
+ element: /* @__PURE__ */ React.createElement(DefaultWrapper, { cms }, /* @__PURE__ */ React.createElement(CollectionCreatePage, null))
5788
+ }
5789
+ ), /* @__PURE__ */ React.createElement(
5790
+ reactRouterDom.Route,
5791
+ {
5792
+ path: "collections/new/:collectionName/~/*",
5793
+ element: /* @__PURE__ */ React.createElement(DefaultWrapper, { cms }, /* @__PURE__ */ React.createElement(CollectionCreatePage, null))
5794
+ }
5795
+ ), /* @__PURE__ */ React.createElement(
5796
+ reactRouterDom.Route,
5797
+ {
5798
+ path: "collections/edit/:collectionName/*",
5799
+ element: /* @__PURE__ */ React.createElement(DefaultWrapper, { cms }, /* @__PURE__ */ React.createElement(CollectionUpdatePage, null))
5800
+ }
5801
+ ), /* @__PURE__ */ React.createElement(
5802
+ reactRouterDom.Route,
5803
+ {
5804
+ path: "collections/:collectionName/*",
5805
+ element: /* @__PURE__ */ React.createElement(DefaultWrapper, { cms }, /* @__PURE__ */ React.createElement(CollectionListPage, null))
5806
+ }
5807
+ ), /* @__PURE__ */ React.createElement(
5808
+ reactRouterDom.Route,
5809
+ {
5810
+ path: "screens/:screenName",
5811
+ element: /* @__PURE__ */ React.createElement(DefaultWrapper, { cms }, /* @__PURE__ */ React.createElement(ScreenPage, null))
5812
+ }
5813
+ ), /* @__PURE__ */ React.createElement(
5814
+ reactRouterDom.Route,
5815
+ {
5816
+ path: "logout",
5817
+ element: /* @__PURE__ */ React.createElement(DefaultWrapper, { cms }, /* @__PURE__ */ React.createElement(LogoutRedirect, null))
5818
+ }
5819
+ ), /* @__PURE__ */ React.createElement(
5820
+ reactRouterDom.Route,
5821
+ {
5822
+ path: "/",
5823
+ element: /* @__PURE__ */ React.createElement(
5824
+ MaybeRedirectToPreview,
5825
+ {
5826
+ redirect: !!preview && hasRouter
5827
+ },
5828
+ /* @__PURE__ */ React.createElement(DefaultWrapper, { cms }, /* @__PURE__ */ React.createElement(DashboardPage, null))
5829
+ )
5830
+ }
5831
+ )))));
5441
5832
  } else {
5442
- return /* @__PURE__ */ React__default["default"].createElement(Layout, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.HashRouter, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Routes, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
5443
- path: "logout",
5444
- element: /* @__PURE__ */ React__default["default"].createElement(LogoutPage, null)
5445
- }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
5446
- path: "/",
5447
- element: /* @__PURE__ */ React__default["default"].createElement(Redirect, null)
5448
- }))));
5833
+ return /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement(reactRouterDom.HashRouter, null, /* @__PURE__ */ React.createElement(reactRouterDom.Routes, null, /* @__PURE__ */ React.createElement(reactRouterDom.Route, { path: "logout", element: /* @__PURE__ */ React.createElement(LogoutPage, null) }), /* @__PURE__ */ React.createElement(reactRouterDom.Route, { path: "/", element: /* @__PURE__ */ React.createElement(Redirect, null) }))));
5449
5834
  }
5450
5835
  });
5451
5836
  };
@@ -5453,28 +5838,26 @@ This will work when developing locally but NOT when deployed to production.
5453
5838
  cms,
5454
5839
  children
5455
5840
  }) => {
5456
- return /* @__PURE__ */ React__default["default"].createElement(Layout, null, /* @__PURE__ */ React__default["default"].createElement("div", {
5457
- className: "flex items-stretch h-screen overflow-hidden"
5458
- }, /* @__PURE__ */ React__default["default"].createElement(Sidebar, {
5459
- cms
5460
- }), /* @__PURE__ */ React__default["default"].createElement("div", {
5461
- className: "flex-1 relative"
5462
- }, children)));
5841
+ return /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement("div", { className: "flex items-stretch h-screen overflow-hidden" }, /* @__PURE__ */ React.createElement(Sidebar, { cms }), /* @__PURE__ */ React.createElement("div", { className: "flex-1 relative" }, children)));
5463
5842
  };
5464
5843
  const PlainLayout = ({ children }) => {
5465
- return /* @__PURE__ */ React__default["default"].createElement("div", {
5466
- style: {
5467
- position: "fixed",
5468
- top: 0,
5469
- left: 0,
5470
- width: "100%",
5471
- height: "100%",
5472
- overflow: "auto",
5473
- background: "#F6F6F9",
5474
- fontFamily: "'Inter', sans-serif",
5475
- zIndex: 9999
5476
- }
5477
- }, children);
5844
+ return /* @__PURE__ */ React.createElement(
5845
+ "div",
5846
+ {
5847
+ style: {
5848
+ position: "fixed",
5849
+ top: 0,
5850
+ left: 0,
5851
+ width: "100%",
5852
+ height: "100%",
5853
+ overflow: "auto",
5854
+ background: "#F6F6F9",
5855
+ fontFamily: "'Inter', sans-serif",
5856
+ zIndex: 9999
5857
+ }
5858
+ },
5859
+ children
5860
+ );
5478
5861
  };
5479
5862
  class RouteMappingPlugin {
5480
5863
  constructor(mapper) {
@@ -5501,21 +5884,15 @@ This will work when developing locally but NOT when deployed to production.
5501
5884
  const defineConfig = defineStaticConfig;
5502
5885
  Object.defineProperty(exports2, "MdxFieldPluginExtendible", {
5503
5886
  enumerable: true,
5504
- get: function() {
5505
- return toolkit.MdxFieldPluginExtendible;
5506
- }
5887
+ get: () => toolkit.MdxFieldPluginExtendible
5507
5888
  });
5508
5889
  Object.defineProperty(exports2, "NAMER", {
5509
5890
  enumerable: true,
5510
- get: function() {
5511
- return schemaTools.NAMER;
5512
- }
5891
+ get: () => schemaTools.NAMER
5513
5892
  });
5514
5893
  Object.defineProperty(exports2, "resolveField", {
5515
5894
  enumerable: true,
5516
- get: function() {
5517
- return schemaTools.resolveField;
5518
- }
5895
+ get: () => schemaTools.resolveField
5519
5896
  });
5520
5897
  exports2.AuthWallInner = AuthWallInner;
5521
5898
  exports2.Client = Client;
@@ -5532,7 +5909,7 @@ This will work when developing locally but NOT when deployed to production.
5532
5909
  exports2.assertShape = assertShape;
5533
5910
  exports2.asyncPoll = asyncPoll;
5534
5911
  exports2.createClient = createClient;
5535
- exports2["default"] = TinaCMSProvider2;
5912
+ exports2.default = TinaCMSProvider2;
5536
5913
  exports2.defineConfig = defineConfig;
5537
5914
  exports2.defineLegacyConfig = defineLegacyConfig;
5538
5915
  exports2.defineSchema = defineSchema;
@@ -5543,13 +5920,11 @@ This will work when developing locally but NOT when deployed to production.
5543
5920
  exports2.staticRequest = staticRequest;
5544
5921
  exports2.useDocumentCreatorPlugin = useDocumentCreatorPlugin;
5545
5922
  exports2.useTinaAuthRedirect = useTinaAuthRedirect;
5546
- Object.keys(toolkit).forEach(function(k) {
5923
+ Object.keys(toolkit).forEach((k) => {
5547
5924
  if (k !== "default" && !exports2.hasOwnProperty(k))
5548
5925
  Object.defineProperty(exports2, k, {
5549
5926
  enumerable: true,
5550
- get: function() {
5551
- return toolkit[k];
5552
- }
5927
+ get: () => toolkit[k]
5553
5928
  });
5554
5929
  });
5555
5930
  Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });