tinacms 1.5.10 → 1.5.12

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.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { EventBus, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, useLocalStorage, TinaCMS, BranchSwitcherPlugin, BranchDataProvider, TinaProvider, TinaMediaStore, DummyMediaStore, useCMS, Nav, BranchBanner, LocalWarning, BillingWarning, Select, Message, OverflowMenu, CursorPaginator, Input, PopupModal, BaseTextField, Form, wrapFieldsWithMeta, FormStatus, FormBuilder } from "@tinacms/toolkit";
2
+ import { EventBus, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, useLocalStorage, TinaCMS, BranchSwitcherPlugin, BranchDataProvider, TinaProvider, TinaMediaStore, DummyMediaStore, useCMS, Nav, BranchBanner, LocalWarning, BillingWarning, CreateBranchModel, Select, Message, OverflowMenu, CursorPaginator, Input, PopupModal, BaseTextField, Form, wrapFieldsWithMeta, FormStatus, FormBuilder, useBranchData, formatBranchName } from "@tinacms/toolkit";
3
3
  export * from "@tinacms/toolkit";
4
4
  export { MdxFieldPluginExtendible } from "@tinacms/toolkit";
5
5
  import { getIntrospectionQuery, buildClientSchema, print, parse, buildSchema } from "graphql";
@@ -191,7 +191,9 @@ const parseRefForBranchName = (ref) => {
191
191
  return matches[1];
192
192
  };
193
193
  const ListBranchResponse = z.object({
194
- name: z.string()
194
+ name: z.string(),
195
+ protected: z.boolean().optional().default(false),
196
+ githubPullRequestUrl: z.string().optional()
195
197
  }).array();
196
198
  const IndexStatusResponse = z.object({
197
199
  status: z.union([
@@ -230,6 +232,8 @@ class Client {
230
232
  constructor({ tokenStorage = "MEMORY", ...options }) {
231
233
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P;
232
234
  this.events = new EventBus();
235
+ this.protectedBranches = [];
236
+ this.usingEditorialWorkflow = false;
233
237
  this.addPendingContent = async (props) => {
234
238
  const mutation = `#graphql
235
239
  mutation addPendingDocumentMutation(
@@ -420,6 +424,41 @@ mutation addPendingDocumentMutation(
420
424
  const jsonRes = await res.json();
421
425
  return jsonRes;
422
426
  }
427
+ async getProject() {
428
+ const res = await this.fetchWithToken(`${this.identityApiUrl}/v2/apps/${this.clientId}`, {
429
+ method: "GET"
430
+ });
431
+ const val = await res.json();
432
+ return val;
433
+ }
434
+ async createPullRequest({
435
+ baseBranch,
436
+ branch,
437
+ title
438
+ }) {
439
+ const url = `${this.contentApiBase}/github/${this.clientId}/create_pull_request`;
440
+ try {
441
+ const res = await this.fetchWithToken(url, {
442
+ method: "POST",
443
+ body: JSON.stringify({
444
+ baseBranch,
445
+ branch,
446
+ title
447
+ }),
448
+ headers: {
449
+ "Content-Type": "application/json"
450
+ }
451
+ });
452
+ if (!res.ok) {
453
+ throw new Error(`There was an error creating a new branch. ${res.statusText}`);
454
+ }
455
+ const values = await res.json();
456
+ return values;
457
+ } catch (error) {
458
+ console.error("There was an error creating a new branch.", error);
459
+ throw error;
460
+ }
461
+ }
423
462
  async fetchEvents(limit, cursor) {
424
463
  if (this.isLocalMode) {
425
464
  return {
@@ -437,12 +476,6 @@ mutation addPendingDocumentMutation(
437
476
  }).join(""));
438
477
  return JSON.parse(jsonPayload);
439
478
  }
440
- async getProject() {
441
- const res = await this.fetchWithToken(`${this.identityApiUrl}/v2/apps/${this.clientId}`, {
442
- method: "GET"
443
- });
444
- return res.json();
445
- }
446
479
  async getRefreshedToken(tokens) {
447
480
  const { access_token, id_token, refresh_token } = JSON.parse(tokens);
448
481
  const { exp, iss, client_id } = this.parseJwt(access_token);
@@ -546,6 +579,7 @@ mutation addPendingDocumentMutation(
546
579
  }
547
580
  }
548
581
  waitForIndexStatus({ ref }) {
582
+ let unknownCount = 0;
549
583
  try {
550
584
  const [prom, cancel] = asyncPoll(async () => {
551
585
  try {
@@ -556,6 +590,12 @@ mutation addPendingDocumentMutation(
556
590
  data: result
557
591
  });
558
592
  } else {
593
+ if (result.status === "unknown") {
594
+ unknownCount++;
595
+ if (unknownCount > 5) {
596
+ throw new Error("AsyncPoller: status unknown for too long, please check indexing progress the Tina Cloud dashboard");
597
+ }
598
+ }
559
599
  return Promise.resolve({
560
600
  done: false
561
601
  });
@@ -568,9 +608,8 @@ mutation addPendingDocumentMutation(
568
608
  } catch (error) {
569
609
  if (error.message === "AsyncPoller: reached timeout") {
570
610
  console.warn(error);
571
- return {
572
- status: "timeout"
573
- };
611
+ return [Promise.resolve({ status: "timeout" }), () => {
612
+ }];
574
613
  }
575
614
  throw error;
576
615
  }
@@ -582,7 +621,7 @@ mutation addPendingDocumentMutation(
582
621
  const parsedResult = IndexStatusResponse.parse(result);
583
622
  return parsedResult;
584
623
  }
585
- async listBranches() {
624
+ async listBranches(args) {
586
625
  try {
587
626
  const url = `${this.contentApiBase}/github/${this.clientId}/list_branches`;
588
627
  const res = await this.fetchWithToken(url, {
@@ -590,6 +629,9 @@ mutation addPendingDocumentMutation(
590
629
  });
591
630
  const branches = await res.json();
592
631
  const parsedBranches = ListBranchResponse.parse(branches);
632
+ if ((args == null ? void 0 : args.includeIndexStatus) === false) {
633
+ return parsedBranches;
634
+ }
593
635
  const indexStatusPromises = parsedBranches.map(async (branch) => {
594
636
  const indexStatus2 = await this.getIndexStatus({ ref: branch.name });
595
637
  return {
@@ -597,6 +639,7 @@ mutation addPendingDocumentMutation(
597
639
  indexStatus: indexStatus2
598
640
  };
599
641
  });
642
+ this.protectedBranches = parsedBranches.filter((x) => x.protected).map((x) => x.name);
600
643
  const indexStatus = await Promise.all(indexStatusPromises);
601
644
  return indexStatus;
602
645
  } catch (error) {
@@ -604,6 +647,10 @@ mutation addPendingDocumentMutation(
604
647
  throw error;
605
648
  }
606
649
  }
650
+ usingProtectedBranch() {
651
+ var _a;
652
+ return this.usingEditorialWorkflow && ((_a = this.protectedBranches) == null ? void 0 : _a.includes(this.branch));
653
+ }
607
654
  async createBranch({ baseBranch, branchName }) {
608
655
  const url = `${this.contentApiBase}/github/${this.clientId}/create_branch`;
609
656
  try {
@@ -617,10 +664,16 @@ mutation addPendingDocumentMutation(
617
664
  "Content-Type": "application/json"
618
665
  }
619
666
  });
620
- return await res.json().then((r) => parseRefForBranchName(r.data.ref));
667
+ if (!res.ok) {
668
+ console.error("There was an error creating a new branch.");
669
+ const error = await res.json();
670
+ throw new Error(error == null ? void 0 : error.message);
671
+ }
672
+ const values = await res.json();
673
+ return parseRefForBranchName(values.data.ref);
621
674
  } catch (error) {
622
675
  console.error("There was an error creating a new branch.", error);
623
- return null;
676
+ throw error;
624
677
  }
625
678
  }
626
679
  }
@@ -1100,6 +1153,7 @@ const AuthWallInner = ({
1100
1153
  if (await client.isAuthenticated()) {
1101
1154
  setShowChildren(true);
1102
1155
  setActiveModal(null);
1156
+ cms.events.dispatch({ type: "cms:login" });
1103
1157
  } else {
1104
1158
  throw new Error("No access to repo");
1105
1159
  }
@@ -1138,6 +1192,7 @@ const AuthWallInner = ({
1138
1192
  }), showChildren ? children : loginScreen ? loginScreen : null);
1139
1193
  };
1140
1194
  const TinaCloudProvider = (props) => {
1195
+ var _a, _b, _c, _d, _e;
1141
1196
  const baseBranch = props.branch || "main";
1142
1197
  const [currentBranch, setCurrentBranch] = useLocalStorage("tinacms-current-branch", baseBranch);
1143
1198
  useTinaAuthRedirect();
@@ -1153,16 +1208,16 @@ const TinaCloudProvider = (props) => {
1153
1208
  cms.api.tina.setBranch(currentBranch);
1154
1209
  }
1155
1210
  useEffect(() => {
1156
- var _a, _b, _c, _d;
1211
+ var _a2, _b2, _c2, _d2;
1157
1212
  let searchClient;
1158
1213
  if (props.isLocalClient) {
1159
1214
  searchClient = new LocalSearchClient(cms.api.tina);
1160
1215
  } else {
1161
- const hasTinaSearch = Boolean((_b = (_a = props.schema.config) == null ? void 0 : _a.search) == null ? void 0 : _b.tina);
1216
+ const hasTinaSearch = Boolean((_b2 = (_a2 = props.schema.config) == null ? void 0 : _a2.search) == null ? void 0 : _b2.tina);
1162
1217
  if (hasTinaSearch) {
1163
1218
  searchClient = new TinaCMSSearchClient(cms.api.tina);
1164
1219
  } else {
1165
- searchClient = (_d = (_c = props.schema.config) == null ? void 0 : _c.search) == null ? void 0 : _d.searchClient;
1220
+ searchClient = (_d2 = (_c2 = props.schema.config) == null ? void 0 : _c2.search) == null ? void 0 : _d2.searchClient;
1166
1221
  }
1167
1222
  }
1168
1223
  if (searchClient) {
@@ -1173,12 +1228,12 @@ const TinaCloudProvider = (props) => {
1173
1228
  cms.registerApi("admin", new TinaAdminApi(cms));
1174
1229
  }
1175
1230
  const setupMedia = async () => {
1176
- var _a, _b, _c, _d, _e, _f, _g;
1177
- const hasTinaMedia = Boolean((_b = (_a = props.schema.config) == null ? void 0 : _a.media) == null ? void 0 : _b.tina);
1231
+ var _a2, _b2, _c2, _d2, _e2, _f, _g;
1232
+ const hasTinaMedia = Boolean((_b2 = (_a2 = props.schema.config) == null ? void 0 : _a2.media) == null ? void 0 : _b2.tina);
1178
1233
  if (hasTinaMedia) {
1179
1234
  cms.media.store = new TinaMediaStore(cms);
1180
- } else if (((_d = (_c = props.schema.config) == null ? void 0 : _c.media) == null ? void 0 : _d.loadCustomStore) || props.mediaStore) {
1181
- const mediaStoreFromProps = ((_f = (_e = props.schema.config) == null ? void 0 : _e.media) == null ? void 0 : _f.loadCustomStore) || props.mediaStore;
1235
+ } else if (((_d2 = (_c2 = props.schema.config) == null ? void 0 : _c2.media) == null ? void 0 : _d2.loadCustomStore) || props.mediaStore) {
1236
+ const mediaStoreFromProps = ((_f = (_e2 = props.schema.config) == null ? void 0 : _e2.media) == null ? void 0 : _f.loadCustomStore) || props.mediaStore;
1182
1237
  if ((_g = mediaStoreFromProps.prototype) == null ? void 0 : _g.persist) {
1183
1238
  cms.media.store = new mediaStoreFromProps(cms.api.tina);
1184
1239
  } else {
@@ -1189,6 +1244,8 @@ const TinaCloudProvider = (props) => {
1189
1244
  cms.media.store = new DummyMediaStore();
1190
1245
  }
1191
1246
  };
1247
+ const client = cms.api.tina;
1248
+ 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);
1192
1249
  const handleListBranches = async () => {
1193
1250
  const { owner, repo } = props;
1194
1251
  const branches = await cms.api.tina.listBranches({ owner, repo });
@@ -1231,6 +1288,27 @@ const TinaCloudProvider = (props) => {
1231
1288
  props.cmsCallback(cms);
1232
1289
  }
1233
1290
  }, []);
1291
+ React.useEffect(() => {
1292
+ const setupEditorialWorkflow = () => {
1293
+ client.getProject().then((project) => {
1294
+ var _a2;
1295
+ if ((_a2 = project == null ? void 0 : project.features) == null ? void 0 : _a2.includes("editorial-workflow")) {
1296
+ cms.flags.set("branch-switcher", true);
1297
+ client.usingEditorialWorkflow = true;
1298
+ client.protectedBranches = project.protectedBranches;
1299
+ }
1300
+ });
1301
+ };
1302
+ if (isTinaCloud) {
1303
+ setupEditorialWorkflow();
1304
+ }
1305
+ const unsubscribe = cms.events.subscribe("cms:login", () => {
1306
+ if (isTinaCloud) {
1307
+ setupEditorialWorkflow();
1308
+ }
1309
+ });
1310
+ return unsubscribe;
1311
+ }, [isTinaCloud, cms]);
1234
1312
  return /* @__PURE__ */ React.createElement(BranchDataProvider, {
1235
1313
  currentBranch,
1236
1314
  setCurrentBranch: (b) => {
@@ -1560,6 +1638,343 @@ var styles = `.tina-tailwind {
1560
1638
  --tw-backdrop-saturate: ;
1561
1639
  --tw-backdrop-sepia: ;
1562
1640
  }
1641
+ .tina-prose {
1642
+ color: var(--tw-prose-body);
1643
+ max-width: 65ch;
1644
+ }
1645
+ .tina-prose :where([class~="lead"]):not(:where([class~="not-tina-prose"] *)) {
1646
+ color: var(--tw-prose-lead);
1647
+ font-size: 1.25em;
1648
+ line-height: 1.6;
1649
+ margin-top: 1.2em;
1650
+ margin-bottom: 1.2em;
1651
+ }
1652
+ .tina-prose :where(a):not(:where([class~="not-tina-prose"] *)) {
1653
+ color: var(--tw-prose-links);
1654
+ text-decoration: underline;
1655
+ font-weight: 500;
1656
+ }
1657
+ .tina-prose :where(strong):not(:where([class~="not-tina-prose"] *)) {
1658
+ color: var(--tw-prose-bold);
1659
+ font-weight: 600;
1660
+ }
1661
+ .tina-prose :where(ol):not(:where([class~="not-tina-prose"] *)) {
1662
+ list-style-type: decimal;
1663
+ padding-left: 1.625em;
1664
+ }
1665
+ .tina-prose :where(ol[type="A"]):not(:where([class~="not-tina-prose"] *)) {
1666
+ list-style-type: upper-alpha;
1667
+ }
1668
+ .tina-prose :where(ol[type="a"]):not(:where([class~="not-tina-prose"] *)) {
1669
+ list-style-type: lower-alpha;
1670
+ }
1671
+ .tina-prose :where(ol[type="A" s]):not(:where([class~="not-tina-prose"] *)) {
1672
+ list-style-type: upper-alpha;
1673
+ }
1674
+ .tina-prose :where(ol[type="a" s]):not(:where([class~="not-tina-prose"] *)) {
1675
+ list-style-type: lower-alpha;
1676
+ }
1677
+ .tina-prose :where(ol[type="I"]):not(:where([class~="not-tina-prose"] *)) {
1678
+ list-style-type: upper-roman;
1679
+ }
1680
+ .tina-prose :where(ol[type="i"]):not(:where([class~="not-tina-prose"] *)) {
1681
+ list-style-type: lower-roman;
1682
+ }
1683
+ .tina-prose :where(ol[type="I" s]):not(:where([class~="not-tina-prose"] *)) {
1684
+ list-style-type: upper-roman;
1685
+ }
1686
+ .tina-prose :where(ol[type="i" s]):not(:where([class~="not-tina-prose"] *)) {
1687
+ list-style-type: lower-roman;
1688
+ }
1689
+ .tina-prose :where(ol[type="1"]):not(:where([class~="not-tina-prose"] *)) {
1690
+ list-style-type: decimal;
1691
+ }
1692
+ .tina-prose :where(ul):not(:where([class~="not-tina-prose"] *)) {
1693
+ list-style-type: disc;
1694
+ padding-left: 1.625em;
1695
+ }
1696
+ .tina-prose :where(ol > li):not(:where([class~="not-tina-prose"] *))::marker {
1697
+ font-weight: 400;
1698
+ color: var(--tw-prose-counters);
1699
+ }
1700
+ .tina-prose :where(ul > li):not(:where([class~="not-tina-prose"] *))::marker {
1701
+ color: var(--tw-prose-bullets);
1702
+ }
1703
+ .tina-prose :where(hr):not(:where([class~="not-tina-prose"] *)) {
1704
+ border-color: var(--tw-prose-hr);
1705
+ border-top-width: 1px;
1706
+ margin-top: 3em;
1707
+ margin-bottom: 3em;
1708
+ }
1709
+ .tina-prose :where(blockquote):not(:where([class~="not-tina-prose"] *)) {
1710
+ font-weight: 500;
1711
+ font-style: italic;
1712
+ color: var(--tw-prose-quotes);
1713
+ border-left-width: 0.25rem;
1714
+ border-left-color: var(--tw-prose-quote-borders);
1715
+ quotes: "\\201C""\\201D""\\2018""\\2019";
1716
+ margin-top: 1.6em;
1717
+ margin-bottom: 1.6em;
1718
+ padding-left: 1em;
1719
+ }
1720
+ .tina-prose :where(blockquote p:first-of-type):not(:where([class~="not-tina-prose"] *))::before {
1721
+ content: open-quote;
1722
+ }
1723
+ .tina-prose :where(blockquote p:last-of-type):not(:where([class~="not-tina-prose"] *))::after {
1724
+ content: close-quote;
1725
+ }
1726
+ .tina-prose :where(h1):not(:where([class~="not-tina-prose"] *)) {
1727
+ color: var(--tw-prose-headings);
1728
+ font-weight: 800;
1729
+ font-size: 2.25em;
1730
+ margin-top: 0;
1731
+ margin-bottom: 0.8888889em;
1732
+ line-height: 1.1111111;
1733
+ }
1734
+ .tina-prose :where(h1 strong):not(:where([class~="not-tina-prose"] *)) {
1735
+ font-weight: 900;
1736
+ }
1737
+ .tina-prose :where(h2):not(:where([class~="not-tina-prose"] *)) {
1738
+ color: var(--tw-prose-headings);
1739
+ font-weight: 700;
1740
+ font-size: 1.5em;
1741
+ margin-top: 2em;
1742
+ margin-bottom: 1em;
1743
+ line-height: 1.3333333;
1744
+ }
1745
+ .tina-prose :where(h2 strong):not(:where([class~="not-tina-prose"] *)) {
1746
+ font-weight: 800;
1747
+ }
1748
+ .tina-prose :where(h3):not(:where([class~="not-tina-prose"] *)) {
1749
+ color: var(--tw-prose-headings);
1750
+ font-weight: 600;
1751
+ font-size: 1.25em;
1752
+ margin-top: 1.6em;
1753
+ margin-bottom: 0.6em;
1754
+ line-height: 1.6;
1755
+ }
1756
+ .tina-prose :where(h3 strong):not(:where([class~="not-tina-prose"] *)) {
1757
+ font-weight: 700;
1758
+ }
1759
+ .tina-prose :where(h4):not(:where([class~="not-tina-prose"] *)) {
1760
+ color: var(--tw-prose-headings);
1761
+ font-weight: 600;
1762
+ margin-top: 1.5em;
1763
+ margin-bottom: 0.5em;
1764
+ line-height: 1.5;
1765
+ }
1766
+ .tina-prose :where(h4 strong):not(:where([class~="not-tina-prose"] *)) {
1767
+ font-weight: 700;
1768
+ }
1769
+ .tina-prose :where(figure > *):not(:where([class~="not-tina-prose"] *)) {
1770
+ margin-top: 0;
1771
+ margin-bottom: 0;
1772
+ }
1773
+ .tina-prose :where(figcaption):not(:where([class~="not-tina-prose"] *)) {
1774
+ color: var(--tw-prose-captions);
1775
+ font-size: 0.875em;
1776
+ line-height: 1.4285714;
1777
+ margin-top: 0.8571429em;
1778
+ }
1779
+ .tina-prose :where(code):not(:where([class~="not-tina-prose"] *)) {
1780
+ color: var(--tw-prose-code);
1781
+ font-weight: 600;
1782
+ font-size: 0.875em;
1783
+ }
1784
+ .tina-prose :where(code):not(:where([class~="not-tina-prose"] *))::before {
1785
+ content: "\`";
1786
+ }
1787
+ .tina-prose :where(code):not(:where([class~="not-tina-prose"] *))::after {
1788
+ content: "\`";
1789
+ }
1790
+ .tina-prose :where(a code):not(:where([class~="not-tina-prose"] *)) {
1791
+ color: var(--tw-prose-links);
1792
+ }
1793
+ .tina-prose :where(pre):not(:where([class~="not-tina-prose"] *)) {
1794
+ color: var(--tw-prose-pre-code);
1795
+ background-color: var(--tw-prose-pre-bg);
1796
+ overflow-x: auto;
1797
+ font-weight: 400;
1798
+ font-size: 0.875em;
1799
+ line-height: 1.7142857;
1800
+ margin-top: 1.7142857em;
1801
+ margin-bottom: 1.7142857em;
1802
+ border-radius: 0.375rem;
1803
+ padding-top: 0.8571429em;
1804
+ padding-right: 1.1428571em;
1805
+ padding-bottom: 0.8571429em;
1806
+ padding-left: 1.1428571em;
1807
+ }
1808
+ .tina-prose :where(pre code):not(:where([class~="not-tina-prose"] *)) {
1809
+ background-color: transparent;
1810
+ border-width: 0;
1811
+ border-radius: 0;
1812
+ padding: 0;
1813
+ font-weight: inherit;
1814
+ color: inherit;
1815
+ font-size: inherit;
1816
+ font-family: inherit;
1817
+ line-height: inherit;
1818
+ }
1819
+ .tina-prose :where(pre code):not(:where([class~="not-tina-prose"] *))::before {
1820
+ content: none;
1821
+ }
1822
+ .tina-prose :where(pre code):not(:where([class~="not-tina-prose"] *))::after {
1823
+ content: none;
1824
+ }
1825
+ .tina-prose :where(table):not(:where([class~="not-tina-prose"] *)) {
1826
+ width: 100%;
1827
+ table-layout: auto;
1828
+ text-align: left;
1829
+ margin-top: 2em;
1830
+ margin-bottom: 2em;
1831
+ font-size: 0.875em;
1832
+ line-height: 1.7142857;
1833
+ }
1834
+ .tina-prose :where(thead):not(:where([class~="not-tina-prose"] *)) {
1835
+ border-bottom-width: 1px;
1836
+ border-bottom-color: var(--tw-prose-th-borders);
1837
+ }
1838
+ .tina-prose :where(thead th):not(:where([class~="not-tina-prose"] *)) {
1839
+ color: var(--tw-prose-headings);
1840
+ font-weight: 600;
1841
+ vertical-align: bottom;
1842
+ padding-right: 0.5714286em;
1843
+ padding-bottom: 0.5714286em;
1844
+ padding-left: 0.5714286em;
1845
+ }
1846
+ .tina-prose :where(tbody tr):not(:where([class~="not-tina-prose"] *)) {
1847
+ border-bottom-width: 1px;
1848
+ border-bottom-color: var(--tw-prose-td-borders);
1849
+ }
1850
+ .tina-prose :where(tbody tr:last-child):not(:where([class~="not-tina-prose"] *)) {
1851
+ border-bottom-width: 0;
1852
+ }
1853
+ .tina-prose :where(tbody td):not(:where([class~="not-tina-prose"] *)) {
1854
+ vertical-align: baseline;
1855
+ padding-top: 0.5714286em;
1856
+ padding-right: 0.5714286em;
1857
+ padding-bottom: 0.5714286em;
1858
+ padding-left: 0.5714286em;
1859
+ }
1860
+ .tina-prose {
1861
+ --tw-prose-body: #374151;
1862
+ --tw-prose-headings: #111827;
1863
+ --tw-prose-lead: #4b5563;
1864
+ --tw-prose-links: #111827;
1865
+ --tw-prose-bold: #111827;
1866
+ --tw-prose-counters: #6b7280;
1867
+ --tw-prose-bullets: #d1d5db;
1868
+ --tw-prose-hr: #e5e7eb;
1869
+ --tw-prose-quotes: #111827;
1870
+ --tw-prose-quote-borders: #e5e7eb;
1871
+ --tw-prose-captions: #6b7280;
1872
+ --tw-prose-code: #111827;
1873
+ --tw-prose-pre-code: #e5e7eb;
1874
+ --tw-prose-pre-bg: #1f2937;
1875
+ --tw-prose-th-borders: #d1d5db;
1876
+ --tw-prose-td-borders: #e5e7eb;
1877
+ --tw-prose-invert-body: #d1d5db;
1878
+ --tw-prose-invert-headings: #fff;
1879
+ --tw-prose-invert-lead: #9ca3af;
1880
+ --tw-prose-invert-links: #fff;
1881
+ --tw-prose-invert-bold: #fff;
1882
+ --tw-prose-invert-counters: #9ca3af;
1883
+ --tw-prose-invert-bullets: #4b5563;
1884
+ --tw-prose-invert-hr: #374151;
1885
+ --tw-prose-invert-quotes: #f3f4f6;
1886
+ --tw-prose-invert-quote-borders: #374151;
1887
+ --tw-prose-invert-captions: #9ca3af;
1888
+ --tw-prose-invert-code: #fff;
1889
+ --tw-prose-invert-pre-code: #d1d5db;
1890
+ --tw-prose-invert-pre-bg: rgb(0 0 0 / 50%);
1891
+ --tw-prose-invert-th-borders: #4b5563;
1892
+ --tw-prose-invert-td-borders: #374151;
1893
+ font-size: 1rem;
1894
+ line-height: 1.75;
1895
+ }
1896
+ .tina-prose :where(p):not(:where([class~="not-tina-prose"] *)) {
1897
+ margin-top: 1.25em;
1898
+ margin-bottom: 1.25em;
1899
+ }
1900
+ .tina-prose :where(img):not(:where([class~="not-tina-prose"] *)) {
1901
+ margin-top: 2em;
1902
+ margin-bottom: 2em;
1903
+ }
1904
+ .tina-prose :where(video):not(:where([class~="not-tina-prose"] *)) {
1905
+ margin-top: 2em;
1906
+ margin-bottom: 2em;
1907
+ }
1908
+ .tina-prose :where(figure):not(:where([class~="not-tina-prose"] *)) {
1909
+ margin-top: 2em;
1910
+ margin-bottom: 2em;
1911
+ }
1912
+ .tina-prose :where(h2 code):not(:where([class~="not-tina-prose"] *)) {
1913
+ font-size: 0.875em;
1914
+ }
1915
+ .tina-prose :where(h3 code):not(:where([class~="not-tina-prose"] *)) {
1916
+ font-size: 0.9em;
1917
+ }
1918
+ .tina-prose :where(li):not(:where([class~="not-tina-prose"] *)) {
1919
+ margin-top: 0.5em;
1920
+ margin-bottom: 0.5em;
1921
+ }
1922
+ .tina-prose :where(ol > li):not(:where([class~="not-tina-prose"] *)) {
1923
+ padding-left: 0.375em;
1924
+ }
1925
+ .tina-prose :where(ul > li):not(:where([class~="not-tina-prose"] *)) {
1926
+ padding-left: 0.375em;
1927
+ }
1928
+ .tina-prose > :where(ul > li p):not(:where([class~="not-tina-prose"] *)) {
1929
+ margin-top: 0.75em;
1930
+ margin-bottom: 0.75em;
1931
+ }
1932
+ .tina-prose > :where(ul > li > *:first-child):not(:where([class~="not-tina-prose"] *)) {
1933
+ margin-top: 1.25em;
1934
+ }
1935
+ .tina-prose > :where(ul > li > *:last-child):not(:where([class~="not-tina-prose"] *)) {
1936
+ margin-bottom: 1.25em;
1937
+ }
1938
+ .tina-prose > :where(ol > li > *:first-child):not(:where([class~="not-tina-prose"] *)) {
1939
+ margin-top: 1.25em;
1940
+ }
1941
+ .tina-prose > :where(ol > li > *:last-child):not(:where([class~="not-tina-prose"] *)) {
1942
+ margin-bottom: 1.25em;
1943
+ }
1944
+ .tina-prose :where(ul ul, ul ol, ol ul, ol ol):not(:where([class~="not-tina-prose"] *)) {
1945
+ margin-top: 0.75em;
1946
+ margin-bottom: 0.75em;
1947
+ }
1948
+ .tina-prose :where(hr + *):not(:where([class~="not-tina-prose"] *)) {
1949
+ margin-top: 0;
1950
+ }
1951
+ .tina-prose :where(h2 + *):not(:where([class~="not-tina-prose"] *)) {
1952
+ margin-top: 0;
1953
+ }
1954
+ .tina-prose :where(h3 + *):not(:where([class~="not-tina-prose"] *)) {
1955
+ margin-top: 0;
1956
+ }
1957
+ .tina-prose :where(h4 + *):not(:where([class~="not-tina-prose"] *)) {
1958
+ margin-top: 0;
1959
+ }
1960
+ .tina-prose :where(thead th:first-child):not(:where([class~="not-tina-prose"] *)) {
1961
+ padding-left: 0;
1962
+ }
1963
+ .tina-prose :where(thead th:last-child):not(:where([class~="not-tina-prose"] *)) {
1964
+ padding-right: 0;
1965
+ }
1966
+ .tina-prose :where(tbody td:first-child):not(:where([class~="not-tina-prose"] *)) {
1967
+ padding-left: 0;
1968
+ }
1969
+ .tina-prose :where(tbody td:last-child):not(:where([class~="not-tina-prose"] *)) {
1970
+ padding-right: 0;
1971
+ }
1972
+ .tina-prose > :where(:first-child):not(:where([class~="not-tina-prose"] *)) {
1973
+ margin-top: 0;
1974
+ }
1975
+ .tina-prose > :where(:last-child):not(:where([class~="not-tina-prose"] *)) {
1976
+ margin-bottom: 0;
1977
+ }
1563
1978
  .tina-tailwind .pointer-events-none {
1564
1979
  pointer-events: none;
1565
1980
  }
@@ -1621,21 +2036,16 @@ var styles = `.tina-tailwind {
1621
2036
  margin-left: auto;
1622
2037
  margin-right: auto;
1623
2038
  }
2039
+ .tina-tailwind .my-8 {
2040
+ margin-top: 32px;
2041
+ margin-bottom: 32px;
2042
+ }
1624
2043
  .tina-tailwind .-ml-px {
1625
2044
  margin-left: -1px;
1626
2045
  }
1627
- .tina-tailwind .-mt-0 {
1628
- margin-top: -0px;
1629
- }
1630
- .tina-tailwind .-mt-0\\.5 {
1631
- margin-top: -2px;
1632
- }
1633
2046
  .tina-tailwind .mb-1 {
1634
2047
  margin-bottom: 4px;
1635
2048
  }
1636
- .tina-tailwind .mb-2 {
1637
- margin-bottom: 8px;
1638
- }
1639
2049
  .tina-tailwind .mb-4 {
1640
2050
  margin-bottom: 16px;
1641
2051
  }
@@ -1738,9 +2148,15 @@ var styles = `.tina-tailwind {
1738
2148
  .tina-tailwind .min-w-\\[200px\\] {
1739
2149
  min-width: 200px;
1740
2150
  }
2151
+ .tina-tailwind .min-w-\\[48px\\] {
2152
+ min-width: 48px;
2153
+ }
1741
2154
  .tina-tailwind .max-w-0 {
1742
2155
  max-width: 0rem;
1743
2156
  }
2157
+ .tina-tailwind .max-w-5xl {
2158
+ max-width: 64rem;
2159
+ }
1744
2160
  .tina-tailwind .max-w-form {
1745
2161
  max-width: 900px;
1746
2162
  }
@@ -1759,12 +2175,21 @@ var styles = `.tina-tailwind {
1759
2175
  .tina-tailwind .flex-shrink-0 {
1760
2176
  flex-shrink: 0;
1761
2177
  }
2178
+ .tina-tailwind .shrink {
2179
+ flex-shrink: 1;
2180
+ }
1762
2181
  .tina-tailwind .shrink-0 {
1763
2182
  flex-shrink: 0;
1764
2183
  }
1765
2184
  .tina-tailwind .flex-grow-0 {
1766
2185
  flex-grow: 0;
1767
2186
  }
2187
+ .tina-tailwind .grow-0 {
2188
+ flex-grow: 0;
2189
+ }
2190
+ .tina-tailwind .basis-0 {
2191
+ flex-basis: 0px;
2192
+ }
1768
2193
  .tina-tailwind .table-auto {
1769
2194
  table-layout: auto;
1770
2195
  }
@@ -1800,6 +2225,15 @@ var styles = `.tina-tailwind {
1800
2225
  .tina-tailwind .transform {
1801
2226
  transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
1802
2227
  }
2228
+ @keyframes spin {
2229
+
2230
+ to {
2231
+ transform: rotate(360deg);
2232
+ }
2233
+ }
2234
+ .tina-tailwind .animate-spin {
2235
+ animation: spin 1s linear infinite;
2236
+ }
1803
2237
  .tina-tailwind .cursor-pointer {
1804
2238
  cursor: pointer;
1805
2239
  }
@@ -1845,6 +2279,9 @@ var styles = `.tina-tailwind {
1845
2279
  .tina-tailwind .gap-1 {
1846
2280
  gap: 4px;
1847
2281
  }
2282
+ .tina-tailwind .gap-1\\.5 {
2283
+ gap: 6px;
2284
+ }
1848
2285
  .tina-tailwind .gap-2 {
1849
2286
  gap: 8px;
1850
2287
  }
@@ -1872,6 +2309,9 @@ var styles = `.tina-tailwind {
1872
2309
  .tina-tailwind .overflow-hidden {
1873
2310
  overflow: hidden;
1874
2311
  }
2312
+ .tina-tailwind .overflow-scroll {
2313
+ overflow: scroll;
2314
+ }
1875
2315
  .tina-tailwind .overflow-y-auto {
1876
2316
  overflow-y: auto;
1877
2317
  }
@@ -1911,6 +2351,9 @@ var styles = `.tina-tailwind {
1911
2351
  .tina-tailwind .border-b {
1912
2352
  border-bottom-width: 1px;
1913
2353
  }
2354
+ .tina-tailwind .border-l-2 {
2355
+ border-left-width: 2px;
2356
+ }
1914
2357
  .tina-tailwind .border-r {
1915
2358
  border-right-width: 1px;
1916
2359
  }
@@ -1988,10 +2431,20 @@ var styles = `.tina-tailwind {
1988
2431
  .tina-tailwind .p-0 {
1989
2432
  padding: 0px;
1990
2433
  }
2434
+ .tina-tailwind .p-6 {
2435
+ padding: 24px;
2436
+ }
2437
+ .tina-tailwind .p-8 {
2438
+ padding: 32px;
2439
+ }
1991
2440
  .tina-tailwind .px-12 {
1992
2441
  padding-left: 48px;
1993
2442
  padding-right: 48px;
1994
2443
  }
2444
+ .tina-tailwind .px-2 {
2445
+ padding-left: 8px;
2446
+ padding-right: 8px;
2447
+ }
1995
2448
  .tina-tailwind .px-20 {
1996
2449
  padding-left: 80px;
1997
2450
  padding-right: 80px;
@@ -2044,12 +2497,18 @@ var styles = `.tina-tailwind {
2044
2497
  padding-top: 32px;
2045
2498
  padding-bottom: 32px;
2046
2499
  }
2500
+ .tina-tailwind .pb-4 {
2501
+ padding-bottom: 16px;
2502
+ }
2047
2503
  .tina-tailwind .pl-18 {
2048
2504
  padding-left: 72px;
2049
2505
  }
2050
2506
  .tina-tailwind .pl-3 {
2051
2507
  padding-left: 12px;
2052
2508
  }
2509
+ .tina-tailwind .pl-4 {
2510
+ padding-left: 16px;
2511
+ }
2053
2512
  .tina-tailwind .pl-5 {
2054
2513
  padding-left: 20px;
2055
2514
  }
@@ -2068,6 +2527,9 @@ var styles = `.tina-tailwind {
2068
2527
  .tina-tailwind .pt-12 {
2069
2528
  padding-top: 48px;
2070
2529
  }
2530
+ .tina-tailwind .pt-3 {
2531
+ padding-top: 12px;
2532
+ }
2071
2533
  .tina-tailwind .pt-4 {
2072
2534
  padding-top: 16px;
2073
2535
  }
@@ -2077,6 +2539,9 @@ var styles = `.tina-tailwind {
2077
2539
  .tina-tailwind .text-center {
2078
2540
  text-align: center;
2079
2541
  }
2542
+ .tina-tailwind .font-mono {
2543
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
2544
+ }
2080
2545
  .tina-tailwind .font-sans {
2081
2546
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
2082
2547
  }
@@ -2108,6 +2573,9 @@ var styles = `.tina-tailwind {
2108
2573
  font-size: 13px;
2109
2574
  line-height: 1.33;
2110
2575
  }
2576
+ .tina-tailwind .font-bold {
2577
+ font-weight: 700;
2578
+ }
2111
2579
  .tina-tailwind .font-medium {
2112
2580
  font-weight: 500;
2113
2581
  }
@@ -2144,9 +2612,6 @@ var styles = `.tina-tailwind {
2144
2612
  --tw-text-opacity: 1;
2145
2613
  color: rgb(5 116 228 / var(--tw-text-opacity));
2146
2614
  }
2147
- .tina-tailwind .text-current {
2148
- color: currentColor;
2149
- }
2150
2615
  .tina-tailwind .text-gray-200 {
2151
2616
  --tw-text-opacity: 1;
2152
2617
  color: rgb(225 221 236 / var(--tw-text-opacity));
@@ -2175,6 +2640,10 @@ var styles = `.tina-tailwind {
2175
2640
  --tw-text-opacity: 1;
2176
2641
  color: rgb(37 35 54 / var(--tw-text-opacity));
2177
2642
  }
2643
+ .tina-tailwind .text-orange-600 {
2644
+ --tw-text-opacity: 1;
2645
+ color: rgb(220 68 25 / var(--tw-text-opacity));
2646
+ }
2178
2647
  .tina-tailwind .text-red-400 {
2179
2648
  --tw-text-opacity: 1;
2180
2649
  color: rgb(248 113 113 / var(--tw-text-opacity));
@@ -2183,6 +2652,10 @@ var styles = `.tina-tailwind {
2183
2652
  --tw-text-opacity: 1;
2184
2653
  color: rgb(239 68 68 / var(--tw-text-opacity));
2185
2654
  }
2655
+ .tina-tailwind .text-red-700 {
2656
+ --tw-text-opacity: 1;
2657
+ color: rgb(185 28 28 / var(--tw-text-opacity));
2658
+ }
2186
2659
  .tina-tailwind .text-white {
2187
2660
  --tw-text-opacity: 1;
2188
2661
  color: rgb(255 255 255 / var(--tw-text-opacity));
@@ -2208,8 +2681,8 @@ var styles = `.tina-tailwind {
2208
2681
  .tina-tailwind .opacity-20 {
2209
2682
  opacity: .2;
2210
2683
  }
2211
- .tina-tailwind .opacity-50 {
2212
- opacity: .5;
2684
+ .tina-tailwind .opacity-30 {
2685
+ opacity: .3;
2213
2686
  }
2214
2687
  .tina-tailwind .opacity-70 {
2215
2688
  opacity: .7;
@@ -2268,11 +2741,6 @@ var styles = `.tina-tailwind {
2268
2741
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
2269
2742
  transition-duration: 150ms;
2270
2743
  }
2271
- .tina-tailwind .transition-colors {
2272
- transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
2273
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
2274
- transition-duration: 150ms;
2275
- }
2276
2744
  .tina-tailwind .transition-opacity {
2277
2745
  transition-property: opacity;
2278
2746
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
@@ -2328,6 +2796,9 @@ var styles = `.tina-tailwind {
2328
2796
  --tw-text-opacity: 1;
2329
2797
  color: rgb(5 116 228 / var(--tw-text-opacity));
2330
2798
  }
2799
+ .tina-tailwind .hover\\:underline:hover {
2800
+ text-decoration-line: underline;
2801
+ }
2331
2802
  .tina-tailwind .hover\\:decoration-blue-400:hover {
2332
2803
  text-decoration-color: #2296fe;
2333
2804
  }
@@ -2341,17 +2812,10 @@ var styles = `.tina-tailwind {
2341
2812
  --tw-border-opacity: 1;
2342
2813
  border-color: rgb(0 132 255 / var(--tw-border-opacity));
2343
2814
  }
2344
- .tina-tailwind .focus\\:text-blue-400:focus {
2345
- --tw-text-opacity: 1;
2346
- color: rgb(34 150 254 / var(--tw-text-opacity));
2347
- }
2348
2815
  .tina-tailwind .focus\\:text-gray-900:focus {
2349
2816
  --tw-text-opacity: 1;
2350
2817
  color: rgb(37 35 54 / var(--tw-text-opacity));
2351
2818
  }
2352
- .tina-tailwind .focus\\:underline:focus {
2353
- text-decoration-line: underline;
2354
- }
2355
2819
  .tina-tailwind .focus\\:shadow-outline:focus {
2356
2820
  --tw-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5);
2357
2821
  --tw-shadow-colored: 0 0 0 3px var(--tw-shadow-color);
@@ -2582,8 +3046,6 @@ class ErrorBoundary extends React.Component {
2582
3046
  return { hasError: true, message: error.message };
2583
3047
  }
2584
3048
  render() {
2585
- const branchData = window.localStorage && window.localStorage.getItem("tinacms-current-branch");
2586
- const hasBranchData = branchData && branchData.length > 0;
2587
3049
  if (this.state.hasError && !this.state.pageRefresh) {
2588
3050
  return /* @__PURE__ */ React.createElement("div", {
2589
3051
  style: {
@@ -2617,18 +3079,7 @@ class ErrorBoundary extends React.Component {
2617
3079
  this.setState({ pageRefresh: true });
2618
3080
  setTimeout(() => this.setState({ hasError: false, pageRefresh: false }), 3e3);
2619
3081
  }
2620
- }, "Refresh"), hasBranchData && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", null, `If you're using the branch switcher, you may currently be on a "stale" branch that has been deleted or whose content is not compatible with the latest version of the site's layout. Click the button below to switch back to the default branch for this deployment.`), /* @__PURE__ */ React.createElement("p", null, "See our", " ", /* @__PURE__ */ React.createElement("a", {
2621
- className: "text-gray-600",
2622
- style: { textDecoration: "underline" },
2623
- href: "https://tina.io/docs/errors/faq/",
2624
- target: "_blank"
2625
- }, " ", "Error FAQ", " "), " ", "for more information."), /* @__PURE__ */ React.createElement("button", {
2626
- style: errorButtonStyles,
2627
- onClick: () => {
2628
- window.localStorage.removeItem("tinacms-current-branch");
2629
- window.location.reload();
2630
- }
2631
- }, "Switch to default branch"))));
3082
+ }, "Refresh")));
2632
3083
  }
2633
3084
  if (this.state.pageRefresh) {
2634
3085
  return /* @__PURE__ */ React.createElement(Loader, null, "Let's try that again.");
@@ -2932,6 +3383,9 @@ function BiFile(props) {
2932
3383
  function BiFolder(props) {
2933
3384
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M20 5h-8.586L9.707 3.293A.997.997 0 0 0 9 3H4c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h16c1.103 0 2-.897 2-2V7c0-1.103-.897-2-2-2zM4 19V7h16l.002 12H4z" } }] })(props);
2934
3385
  }
3386
+ function BiLoaderAlt(props) {
3387
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M12 22c5.421 0 10-4.579 10-10h-2c0 4.337-3.663 8-8 8s-8-3.663-8-8c0-4.336 3.663-8 8-8V2C6.579 2 2 6.58 2 12c0 5.421 4.579 10 10 10z" } }] })(props);
3388
+ }
2935
3389
  function BiLogIn(props) {
2936
3390
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "m13 16 5-4-5-4v3H4v2h9z" } }, { "tag": "path", "attr": { "d": "M20 3h-9c-1.103 0-2 .897-2 2v4h2V5h9v14h-9v-4H9v4c0 1.103.897 2 2 2h9c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2z" } }] })(props);
2937
3391
  }
@@ -3672,6 +4126,8 @@ const CollectionListPage = () => {
3672
4126
  }));
3673
4127
  setEndCursor("");
3674
4128
  setPrevCursors([]);
4129
+ setSearch("");
4130
+ setSearchInput("");
3675
4131
  }, [loc]);
3676
4132
  useEffect(() => {
3677
4133
  setVars((old) => ({
@@ -3720,7 +4176,7 @@ const CollectionListPage = () => {
3720
4176
  const allowCreate = (_g = (_f = (_e = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _e.allowedActions) == null ? void 0 : _f.create) != null ? _g : true;
3721
4177
  const allowDelete = (_j = (_i = (_h = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _h.allowedActions) == null ? void 0 : _i.delete) != null ? _j : true;
3722
4178
  const folderView = folder.fullyQualifiedName !== "";
3723
- return /* @__PURE__ */ React.createElement(React.Fragment, null, deleteModalOpen && /* @__PURE__ */ React.createElement(DeleteModal, {
4179
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, deleteModalOpen && !cms.api.tina.usingProtectedBranch() && /* @__PURE__ */ React.createElement(DeleteModal, {
3724
4180
  filename: vars.relativePath,
3725
4181
  deleteFunc: async () => {
3726
4182
  try {
@@ -3734,6 +4190,22 @@ const CollectionListPage = () => {
3734
4190
  }
3735
4191
  },
3736
4192
  close: () => setDeleteModalOpen(false)
4193
+ }), deleteModalOpen && cms.api.tina.usingProtectedBranch() && /* @__PURE__ */ React.createElement(CreateBranchModel, {
4194
+ crudType: "delete",
4195
+ relativePath: collectionExtra.path + "/" + vars.relativePath,
4196
+ values: vars,
4197
+ close: () => setDeleteModalOpen(false),
4198
+ safeSubmit: async () => {
4199
+ try {
4200
+ await admin.deleteDocument(vars);
4201
+ cms.alerts.info("Document was successfully deleted");
4202
+ reFetchCollection();
4203
+ } catch (error) {
4204
+ cms.alerts.warn("Document was not deleted, ask a developer for help or check the console for an error message");
4205
+ console.error(error);
4206
+ throw error;
4207
+ }
4208
+ }
3737
4209
  }), renameModalOpen && /* @__PURE__ */ React.createElement(RenameModal, {
3738
4210
  filename: vars.relativePath,
3739
4211
  newRelativePath: vars.newRelativePath,
@@ -4196,9 +4668,6 @@ const RenameModal = ({
4196
4668
  }
4197
4669
  }, "Rename"))));
4198
4670
  };
4199
- function HiChevronRight(props) {
4200
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "d": "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z", "clipRule": "evenodd" } }] })(props);
4201
- }
4202
4671
  function FaLock(props) {
4203
4672
  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);
4204
4673
  }
@@ -4299,17 +4768,22 @@ const RenderForm$1 = ({
4299
4768
  const defaultItem = customDefaults || ((_d = template.ui) == null ? void 0 : _d.defaultItem) || (template == null ? void 0 : template.defaultItem);
4300
4769
  const form = useMemo(() => {
4301
4770
  var _a2, _b2;
4771
+ const folderName = folder.fullyQualifiedName ? folder.name : "";
4302
4772
  return new Form({
4773
+ crudType: "create",
4303
4774
  initialValues: typeof defaultItem === "function" ? defaultItem() : defaultItem,
4304
4775
  extraSubscribeValues: { active: true, submitting: true, touched: true },
4305
4776
  onChange: (values) => {
4306
- var _a3;
4307
- if (slugFunction && (values == null ? void 0 : values.active) !== "filename" && !(values == null ? void 0 : values.submitting) && !((_a3 = values.touched) == null ? void 0 : _a3.filename)) {
4777
+ var _a3, _b3;
4778
+ if (!(values == null ? void 0 : values.submitting)) {
4779
+ form.relativePath = schemaCollection.path + folderName + `/${(_a3 = values == null ? void 0 : values.values) == null ? void 0 : _a3.filename}.${schemaCollection.format || "md"}`;
4780
+ }
4781
+ if (slugFunction && (values == null ? void 0 : values.active) !== "filename" && !(values == null ? void 0 : values.submitting) && !((_b3 = values.touched) == null ? void 0 : _b3.filename)) {
4308
4782
  const value = slugFunction(values == null ? void 0 : values.values);
4309
4783
  form.finalForm.change("filename", value);
4310
4784
  }
4311
4785
  },
4312
- id: "create-form",
4786
+ id: schemaCollection.path + folderName + `/new-post.${schemaCollection.format || "md"}`,
4313
4787
  label: "form",
4314
4788
  fields: [
4315
4789
  ...formInfo.fields,
@@ -4353,8 +4827,8 @@ const RenderForm$1 = ({
4353
4827
  ],
4354
4828
  onSubmit: async (values) => {
4355
4829
  try {
4356
- const folderName = folder.fullyQualifiedName ? folder.name : "";
4357
- await createDocument(cms, collection, template, mutationInfo, folderName, values);
4830
+ const folderName2 = folder.fullyQualifiedName ? folder.name : "";
4831
+ await createDocument(cms, collection, template, mutationInfo, folderName2, values);
4358
4832
  cms.alerts.success("Document created!");
4359
4833
  setTimeout(() => {
4360
4834
  navigate(`/collections/${collection.name}${folder.fullyQualifiedName ? `/${folder.fullyQualifiedName}` : ""}`);
@@ -4389,21 +4863,17 @@ const RenderForm$1 = ({
4389
4863
  }
4390
4864
  const activeForm = cms.state.forms.find(({ tinaForm }) => tinaForm.id === form.id);
4391
4865
  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(LocalWarning, null) : /* @__PURE__ */ React.createElement(BillingWarning, null), /* @__PURE__ */ React.createElement("div", {
4392
- className: `py-4 border-b border-gray-200 bg-white ${headerPadding}`
4866
+ className: `pt-3 pb-4 border-b border-gray-200 bg-white w-full grow-0 shrink basis-0 flex justify-center ${headerPadding}`
4393
4867
  }, /* @__PURE__ */ React.createElement("div", {
4394
- className: "max-w-form mx-auto"
4395
- }, /* @__PURE__ */ React.createElement("div", {
4396
- className: "mb-2"
4397
- }, /* @__PURE__ */ React.createElement("span", {
4398
- className: "block text-sm leading-tight uppercase text-gray-400 mb-1"
4868
+ className: "w-full max-w-form flex gap-1.5 justify-between items-center"
4399
4869
  }, /* @__PURE__ */ React.createElement(Link, {
4400
4870
  to: `/collections/${collection.name}${folder.fullyQualifiedName ? `/${folder.fullyQualifiedName}` : ""}`,
4401
- className: "inline-block text-current hover:text-blue-400 focus:underline focus:outline-none focus:text-blue-400 font-medium transition-colors duration-150 ease-out"
4402
- }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React.createElement(HiChevronRight, {
4403
- className: "inline-block -mt-0.5 opacity-50"
4404
- })), /* @__PURE__ */ React.createElement("span", {
4405
- className: "text-xl text-gray-700 font-medium leading-tight"
4406
- }, "Create New")), /* @__PURE__ */ React.createElement(FormStatus, {
4871
+ 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"
4872
+ }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React.createElement("span", {
4873
+ className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0"
4874
+ }, "/"), /* @__PURE__ */ React.createElement("span", {
4875
+ className: "flex-1 w-full text-sm leading-tight whitespace-nowrap truncate"
4876
+ }, "Create New"), /* @__PURE__ */ React.createElement(FormStatus, {
4407
4877
  pristine: formIsPristine
4408
4878
  }))), activeForm && /* @__PURE__ */ React.createElement(FormBuilder, {
4409
4879
  form: activeForm,
@@ -4549,7 +5019,7 @@ const RenderForm = ({
4549
5019
  });
4550
5020
  const form = useMemo(() => {
4551
5021
  return new Form({
4552
- id: "update-form",
5022
+ id: `${schemaCollection.path}/${relativePath2}`,
4553
5023
  label: "form",
4554
5024
  fields: formInfo.fields,
4555
5025
  initialValues: document._values,
@@ -4581,21 +5051,17 @@ const RenderForm = ({
4581
5051
  }
4582
5052
  const activeForm = cms.state.forms.find(({ tinaForm }) => tinaForm.id === form.id);
4583
5053
  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(LocalWarning, null) : /* @__PURE__ */ React.createElement(BillingWarning, null), /* @__PURE__ */ React.createElement("div", {
4584
- className: `py-4 border-b border-gray-200 bg-white ${headerPadding}`
4585
- }, /* @__PURE__ */ React.createElement("div", {
4586
- className: "max-w-form mx-auto"
5054
+ className: `pt-3 pb-4 border-b border-gray-200 bg-white w-full grow-0 shrink basis-0 flex justify-center ${headerPadding}`
4587
5055
  }, /* @__PURE__ */ React.createElement("div", {
4588
- className: "mb-2"
4589
- }, /* @__PURE__ */ React.createElement("span", {
4590
- className: "block text-sm leading-tight uppercase text-gray-400 mb-1"
5056
+ className: "w-full max-w-form flex gap-1.5 justify-between items-center"
4591
5057
  }, /* @__PURE__ */ React.createElement(Link, {
4592
5058
  to: `/collections/${collection.name}/~${parentFolder2}`,
4593
- className: "inline-block text-current hover:text-blue-400 focus:underline focus:outline-none focus:text-blue-400 font-medium transition-colors duration-150 ease-out"
4594
- }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React.createElement(HiChevronRight, {
4595
- className: "inline-block -mt-0.5 opacity-50"
4596
- })), /* @__PURE__ */ React.createElement("span", {
4597
- className: "text-xl text-gray-700 font-medium leading-tight"
4598
- }, "Edit ", `${filename}.${collection.format}`)), /* @__PURE__ */ React.createElement(FormStatus, {
5059
+ 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"
5060
+ }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React.createElement("span", {
5061
+ className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0"
5062
+ }, "/"), /* @__PURE__ */ React.createElement("span", {
5063
+ className: "flex-1 w-full text-sm leading-tight whitespace-nowrap truncate"
5064
+ }, `${filename}.${collection.format}`), /* @__PURE__ */ React.createElement(FormStatus, {
4599
5065
  pristine: formIsPristine
4600
5066
  }))), activeForm && /* @__PURE__ */ React.createElement(FormBuilder, {
4601
5067
  form: activeForm,
@@ -4623,6 +5089,127 @@ const ScreenPage = () => {
4623
5089
  })));
4624
5090
  });
4625
5091
  };
5092
+ const IndexingPage = () => {
5093
+ const cms = useCMS();
5094
+ const tinaApi = cms.api.tina;
5095
+ const currentBranch = tinaApi.branch;
5096
+ const kind = localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.kind");
5097
+ const { setCurrentBranch } = useBranchData();
5098
+ const [state, setState] = React.useState(localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState"));
5099
+ const [errorMessage, setErrorMessage] = React.useState("");
5100
+ const [baseBranch, setBaseBranch] = React.useState(localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.baseBranch"));
5101
+ const [searchParams] = useSearchParams();
5102
+ const back = localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.back");
5103
+ const fullPath = localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.fullPath");
5104
+ const values = JSON.parse(localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.values"));
5105
+ const [branch, setBranch] = React.useState("tina/" + searchParams.get("branch"));
5106
+ useEffect(() => {
5107
+ const run = async () => {
5108
+ if (state === "starting") {
5109
+ try {
5110
+ console.log("starting", branch, formatBranchName(branch));
5111
+ const name = await tinaApi.createBranch({
5112
+ branchName: formatBranchName(branch),
5113
+ baseBranch: currentBranch
5114
+ });
5115
+ if (!name) {
5116
+ throw new Error("Branch creation failed.");
5117
+ }
5118
+ setBranch(name);
5119
+ localStorage.setItem("tina.createBranchState", "indexing");
5120
+ cms.alerts.success("Branch created.");
5121
+ setState("indexing");
5122
+ } catch (e) {
5123
+ console.error(e);
5124
+ cms.alerts.error("Branch creation failed: " + e.message);
5125
+ setErrorMessage("Branch creation failed, please try again. By refreshing the page.");
5126
+ setState("error");
5127
+ }
5128
+ }
5129
+ if (state === "indexing") {
5130
+ try {
5131
+ const [
5132
+ waitForIndexStatusPromise,
5133
+ _cancelWaitForIndexFunc
5134
+ ] = tinaApi.waitForIndexStatus({
5135
+ ref: branch
5136
+ });
5137
+ await waitForIndexStatusPromise;
5138
+ cms.alerts.success("Branch indexed.");
5139
+ localStorage.setItem("tina.createBranchState", "submitting");
5140
+ setState("submitting");
5141
+ } catch {
5142
+ cms.alerts.error("Branch indexing failed.");
5143
+ 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.');
5144
+ setState("error");
5145
+ }
5146
+ }
5147
+ if (state === "submitting") {
5148
+ try {
5149
+ setBaseBranch(tinaApi.branch);
5150
+ localStorage.setItem("tina.createBranchState.baseBranch", tinaApi.branch);
5151
+ setCurrentBranch(branch);
5152
+ const collection = tinaApi.schema.getCollectionByFullPath(fullPath);
5153
+ const api = new TinaAdminApi(cms);
5154
+ const params = api.schema.transformPayload(collection.name, values);
5155
+ const relativePath2 = fullPath.replace(`${collection.path}/`, "");
5156
+ if (await api.isAuthenticated()) {
5157
+ if (kind === "delete") {
5158
+ await api.deleteDocument(values);
5159
+ } else if (kind === "create") {
5160
+ await api.createDocument(collection, relativePath2, params);
5161
+ } else {
5162
+ await api.updateDocument(collection, relativePath2, params);
5163
+ }
5164
+ } else {
5165
+ const authMessage = `UpdateDocument failed: User is no longer authenticated; please login and try again.`;
5166
+ cms.alerts.error(authMessage);
5167
+ console.error(authMessage);
5168
+ return false;
5169
+ }
5170
+ localStorage.setItem("tina.createBranchState", "creatingPR");
5171
+ cms.alerts.success("Content saved.");
5172
+ setState("creatingPR");
5173
+ } catch (e) {
5174
+ console.error(e);
5175
+ cms.alerts.error("Content save failed.");
5176
+ setErrorMessage("Content save failed, please try again. If the problem persists please contact support.");
5177
+ setState("error");
5178
+ }
5179
+ }
5180
+ if (state === "creatingPR") {
5181
+ const foo = await tinaApi.createPullRequest({
5182
+ baseBranch,
5183
+ branch,
5184
+ title: "PR from TinaCMS"
5185
+ });
5186
+ console.log("PR created", foo);
5187
+ cms.alerts.success("Pull request created.");
5188
+ localStorage.setItem("tina.createBranchState", "done");
5189
+ setState("done");
5190
+ }
5191
+ if (state === "done") {
5192
+ window.location.href = back;
5193
+ }
5194
+ };
5195
+ if (fullPath && values && branch && back) {
5196
+ run();
5197
+ }
5198
+ }, [state]);
5199
+ if (!back || !fullPath || !values || !branch) {
5200
+ return /* @__PURE__ */ React.createElement(Wrapper, null, /* @__PURE__ */ React.createElement("p", null, "Missing params please try again."));
5201
+ }
5202
+ return /* @__PURE__ */ React.createElement(Wrapper, null, state !== "done" && state !== "error" && /* @__PURE__ */ React.createElement(BiLoaderAlt, {
5203
+ className: `opacity-70 text-blue-400 animate-spin w-10 h-auto`
5204
+ }), (state === "starting" || state === "creatingBranch") && /* @__PURE__ */ React.createElement("p", null, "Creating branch\u2026"), state === "indexing" && /* @__PURE__ */ React.createElement("p", null, "Indexing Content\u2026"), state === "submitting" && /* @__PURE__ */ React.createElement("p", null, "Saving content\u2026"), state === "creatingPR" && /* @__PURE__ */ React.createElement("p", null, "Creating Pull Request\u2026"), state === "error" && /* @__PURE__ */ React.createElement("p", {
5205
+ className: "flex items-center gap-1 text-red-700"
5206
+ }, /* @__PURE__ */ React.createElement(BiError, {
5207
+ className: "w-7 h-auto text-red-400 flex-shrink-0"
5208
+ }), " ", /* @__PURE__ */ React.createElement("b", null, "Error:"), " ", errorMessage, " "));
5209
+ };
5210
+ const Wrapper = ({ children }) => /* @__PURE__ */ React.createElement("div", {
5211
+ className: "w-full h-full flex flex-col justify-center items-center gap-4 p-6 text-xl text-gray-700"
5212
+ }, children);
4626
5213
  const Redirect = () => {
4627
5214
  React.useEffect(() => {
4628
5215
  if (window) {
@@ -4698,6 +5285,8 @@ const CheckSchema = ({
4698
5285
  const cms = useCMS();
4699
5286
  const api = new TinaAdminApi(cms);
4700
5287
  const url = api.api.contentApiUrl;
5288
+ const [schemaMissingError, setSchemaMissingError] = React.useState(false);
5289
+ const currentBranch = decodeURIComponent(cms.api.tina.branch);
4701
5290
  useEffect(() => {
4702
5291
  if (schemaJson && cms) {
4703
5292
  api.checkGraphqlSchema({
@@ -4706,10 +5295,32 @@ const CheckSchema = ({
4706
5295
  if (x === false) {
4707
5296
  cms.alerts.error("GraphQL Schema Mismatch. Editing may not work. If you just switched branches, try going back to the previous branch");
4708
5297
  }
5298
+ }).catch((e) => {
5299
+ if (e.message.includes("has not been indexed by Tina Cloud")) {
5300
+ setSchemaMissingError(true);
5301
+ } else {
5302
+ throw e;
5303
+ }
4709
5304
  });
4710
5305
  }
4711
5306
  }, [cms, JSON.stringify(schemaJson || {}), url]);
4712
- return children;
5307
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, schemaMissingError ? /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, null, "Branch Not Found"), /* @__PURE__ */ React.createElement(ModalBody, {
5308
+ padded: true
5309
+ }, /* @__PURE__ */ React.createElement("div", {
5310
+ className: "tina-prose"
5311
+ }, "The current branch (", /* @__PURE__ */ React.createElement("span", {
5312
+ className: "font-bold"
5313
+ }, currentBranch), ") has either been merged or deleted.")), /* @__PURE__ */ React.createElement(ModalActions, null, /* @__PURE__ */ React.createElement("div", {
5314
+ className: "flex-1"
5315
+ }), /* @__PURE__ */ React.createElement(Button, {
5316
+ style: { flexGrow: 1 },
5317
+ className: "w-full",
5318
+ variant: "primary",
5319
+ onClick: () => {
5320
+ window.localStorage.removeItem("tinacms-current-branch");
5321
+ window.location.reload();
5322
+ }
5323
+ }, "Switch back to default branch")))) : children);
4713
5324
  };
4714
5325
  const TinaAdmin = ({
4715
5326
  preview,
@@ -4735,7 +5346,7 @@ const TinaAdmin = ({
4735
5346
  return typeof ((_a2 = x == null ? void 0 : x.ui) == null ? void 0 : _a2.router) === "function";
4736
5347
  });
4737
5348
  const hasRouter = Boolean(collectionWithRouter);
4738
- return /* @__PURE__ */ React.createElement(CheckSchema, {
5349
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CheckSchema, {
4739
5350
  schemaJson
4740
5351
  }, /* @__PURE__ */ React.createElement(HashRouter, null, /* @__PURE__ */ React.createElement(SetPreviewFlag, {
4741
5352
  preview,
@@ -4749,6 +5360,11 @@ const TinaAdmin = ({
4749
5360
  }), /* @__PURE__ */ React.createElement(Route, {
4750
5361
  path: "graphql",
4751
5362
  element: /* @__PURE__ */ React.createElement(PlainLayout, null, /* @__PURE__ */ React.createElement(Playground, null))
5363
+ }), /* @__PURE__ */ React.createElement(Route, {
5364
+ path: "branch/new",
5365
+ element: /* @__PURE__ */ React.createElement(DefaultWrapper, {
5366
+ cms
5367
+ }, /* @__PURE__ */ React.createElement(IndexingPage, null))
4752
5368
  }), /* @__PURE__ */ React.createElement(Route, {
4753
5369
  path: "collections/new/:collectionName",
4754
5370
  element: /* @__PURE__ */ React.createElement(DefaultWrapper, {
@@ -4806,7 +5422,7 @@ const TinaAdmin = ({
4806
5422
  }, /* @__PURE__ */ React.createElement(DefaultWrapper, {
4807
5423
  cms
4808
5424
  }, /* @__PURE__ */ React.createElement(DashboardPage, null)))
4809
- }))));
5425
+ })))));
4810
5426
  } else {
4811
5427
  return /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement(HashRouter, null, /* @__PURE__ */ React.createElement(Routes, null, /* @__PURE__ */ React.createElement(Route, {
4812
5428
  path: "logout",