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.js CHANGED
@@ -206,7 +206,9 @@
206
206
  return matches[1];
207
207
  };
208
208
  const ListBranchResponse = zod.z.object({
209
- name: zod.z.string()
209
+ name: zod.z.string(),
210
+ protected: zod.z.boolean().optional().default(false),
211
+ githubPullRequestUrl: zod.z.string().optional()
210
212
  }).array();
211
213
  const IndexStatusResponse = zod.z.object({
212
214
  status: zod.z.union([
@@ -245,6 +247,8 @@
245
247
  constructor({ tokenStorage = "MEMORY", ...options }) {
246
248
  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;
247
249
  this.events = new toolkit.EventBus();
250
+ this.protectedBranches = [];
251
+ this.usingEditorialWorkflow = false;
248
252
  this.addPendingContent = async (props) => {
249
253
  const mutation = `#graphql
250
254
  mutation addPendingDocumentMutation(
@@ -435,6 +439,41 @@ mutation addPendingDocumentMutation(
435
439
  const jsonRes = await res.json();
436
440
  return jsonRes;
437
441
  }
442
+ async getProject() {
443
+ const res = await this.fetchWithToken(`${this.identityApiUrl}/v2/apps/${this.clientId}`, {
444
+ method: "GET"
445
+ });
446
+ const val = await res.json();
447
+ return val;
448
+ }
449
+ async createPullRequest({
450
+ baseBranch,
451
+ branch,
452
+ title
453
+ }) {
454
+ const url = `${this.contentApiBase}/github/${this.clientId}/create_pull_request`;
455
+ try {
456
+ const res = await this.fetchWithToken(url, {
457
+ method: "POST",
458
+ body: JSON.stringify({
459
+ baseBranch,
460
+ branch,
461
+ title
462
+ }),
463
+ headers: {
464
+ "Content-Type": "application/json"
465
+ }
466
+ });
467
+ if (!res.ok) {
468
+ throw new Error(`There was an error creating a new branch. ${res.statusText}`);
469
+ }
470
+ const values = await res.json();
471
+ return values;
472
+ } catch (error) {
473
+ console.error("There was an error creating a new branch.", error);
474
+ throw error;
475
+ }
476
+ }
438
477
  async fetchEvents(limit, cursor) {
439
478
  if (this.isLocalMode) {
440
479
  return {
@@ -452,12 +491,6 @@ mutation addPendingDocumentMutation(
452
491
  }).join(""));
453
492
  return JSON.parse(jsonPayload);
454
493
  }
455
- async getProject() {
456
- const res = await this.fetchWithToken(`${this.identityApiUrl}/v2/apps/${this.clientId}`, {
457
- method: "GET"
458
- });
459
- return res.json();
460
- }
461
494
  async getRefreshedToken(tokens) {
462
495
  const { access_token, id_token, refresh_token } = JSON.parse(tokens);
463
496
  const { exp, iss, client_id } = this.parseJwt(access_token);
@@ -561,6 +594,7 @@ mutation addPendingDocumentMutation(
561
594
  }
562
595
  }
563
596
  waitForIndexStatus({ ref }) {
597
+ let unknownCount = 0;
564
598
  try {
565
599
  const [prom, cancel] = asyncPoll(async () => {
566
600
  try {
@@ -571,6 +605,12 @@ mutation addPendingDocumentMutation(
571
605
  data: result
572
606
  });
573
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");
612
+ }
613
+ }
574
614
  return Promise.resolve({
575
615
  done: false
576
616
  });
@@ -583,9 +623,8 @@ mutation addPendingDocumentMutation(
583
623
  } catch (error) {
584
624
  if (error.message === "AsyncPoller: reached timeout") {
585
625
  console.warn(error);
586
- return {
587
- status: "timeout"
588
- };
626
+ return [Promise.resolve({ status: "timeout" }), () => {
627
+ }];
589
628
  }
590
629
  throw error;
591
630
  }
@@ -597,7 +636,7 @@ mutation addPendingDocumentMutation(
597
636
  const parsedResult = IndexStatusResponse.parse(result);
598
637
  return parsedResult;
599
638
  }
600
- async listBranches() {
639
+ async listBranches(args) {
601
640
  try {
602
641
  const url = `${this.contentApiBase}/github/${this.clientId}/list_branches`;
603
642
  const res = await this.fetchWithToken(url, {
@@ -605,6 +644,9 @@ mutation addPendingDocumentMutation(
605
644
  });
606
645
  const branches = await res.json();
607
646
  const parsedBranches = ListBranchResponse.parse(branches);
647
+ if ((args == null ? void 0 : args.includeIndexStatus) === false) {
648
+ return parsedBranches;
649
+ }
608
650
  const indexStatusPromises = parsedBranches.map(async (branch) => {
609
651
  const indexStatus2 = await this.getIndexStatus({ ref: branch.name });
610
652
  return {
@@ -612,6 +654,7 @@ mutation addPendingDocumentMutation(
612
654
  indexStatus: indexStatus2
613
655
  };
614
656
  });
657
+ this.protectedBranches = parsedBranches.filter((x) => x.protected).map((x) => x.name);
615
658
  const indexStatus = await Promise.all(indexStatusPromises);
616
659
  return indexStatus;
617
660
  } catch (error) {
@@ -619,6 +662,10 @@ mutation addPendingDocumentMutation(
619
662
  throw error;
620
663
  }
621
664
  }
665
+ usingProtectedBranch() {
666
+ var _a;
667
+ return this.usingEditorialWorkflow && ((_a = this.protectedBranches) == null ? void 0 : _a.includes(this.branch));
668
+ }
622
669
  async createBranch({ baseBranch, branchName }) {
623
670
  const url = `${this.contentApiBase}/github/${this.clientId}/create_branch`;
624
671
  try {
@@ -632,10 +679,16 @@ mutation addPendingDocumentMutation(
632
679
  "Content-Type": "application/json"
633
680
  }
634
681
  });
635
- return await res.json().then((r) => parseRefForBranchName(r.data.ref));
682
+ if (!res.ok) {
683
+ console.error("There was an error creating a new branch.");
684
+ const error = await res.json();
685
+ throw new Error(error == null ? void 0 : error.message);
686
+ }
687
+ const values = await res.json();
688
+ return parseRefForBranchName(values.data.ref);
636
689
  } catch (error) {
637
690
  console.error("There was an error creating a new branch.", error);
638
- return null;
691
+ throw error;
639
692
  }
640
693
  }
641
694
  }
@@ -1115,6 +1168,7 @@ mutation addPendingDocumentMutation(
1115
1168
  if (await client.isAuthenticated()) {
1116
1169
  setShowChildren(true);
1117
1170
  setActiveModal(null);
1171
+ cms.events.dispatch({ type: "cms:login" });
1118
1172
  } else {
1119
1173
  throw new Error("No access to repo");
1120
1174
  }
@@ -1153,6 +1207,7 @@ mutation addPendingDocumentMutation(
1153
1207
  }), showChildren ? children : loginScreen ? loginScreen : null);
1154
1208
  };
1155
1209
  const TinaCloudProvider = (props) => {
1210
+ var _a, _b, _c, _d, _e;
1156
1211
  const baseBranch = props.branch || "main";
1157
1212
  const [currentBranch, setCurrentBranch] = toolkit.useLocalStorage("tinacms-current-branch", baseBranch);
1158
1213
  useTinaAuthRedirect();
@@ -1168,16 +1223,16 @@ mutation addPendingDocumentMutation(
1168
1223
  cms.api.tina.setBranch(currentBranch);
1169
1224
  }
1170
1225
  React.useEffect(() => {
1171
- var _a, _b, _c, _d;
1226
+ var _a2, _b2, _c2, _d2;
1172
1227
  let searchClient;
1173
1228
  if (props.isLocalClient) {
1174
1229
  searchClient = new LocalSearchClient(cms.api.tina);
1175
1230
  } else {
1176
- const hasTinaSearch = Boolean((_b = (_a = props.schema.config) == null ? void 0 : _a.search) == null ? void 0 : _b.tina);
1231
+ const hasTinaSearch = Boolean((_b2 = (_a2 = props.schema.config) == null ? void 0 : _a2.search) == null ? void 0 : _b2.tina);
1177
1232
  if (hasTinaSearch) {
1178
1233
  searchClient = new TinaCMSSearchClient(cms.api.tina);
1179
1234
  } else {
1180
- searchClient = (_d = (_c = props.schema.config) == null ? void 0 : _c.search) == null ? void 0 : _d.searchClient;
1235
+ searchClient = (_d2 = (_c2 = props.schema.config) == null ? void 0 : _c2.search) == null ? void 0 : _d2.searchClient;
1181
1236
  }
1182
1237
  }
1183
1238
  if (searchClient) {
@@ -1188,12 +1243,12 @@ mutation addPendingDocumentMutation(
1188
1243
  cms.registerApi("admin", new TinaAdminApi(cms));
1189
1244
  }
1190
1245
  const setupMedia = async () => {
1191
- var _a, _b, _c, _d, _e, _f, _g;
1192
- const hasTinaMedia = Boolean((_b = (_a = props.schema.config) == null ? void 0 : _a.media) == null ? void 0 : _b.tina);
1246
+ var _a2, _b2, _c2, _d2, _e2, _f, _g;
1247
+ const hasTinaMedia = Boolean((_b2 = (_a2 = props.schema.config) == null ? void 0 : _a2.media) == null ? void 0 : _b2.tina);
1193
1248
  if (hasTinaMedia) {
1194
1249
  cms.media.store = new toolkit.TinaMediaStore(cms);
1195
- } else if (((_d = (_c = props.schema.config) == null ? void 0 : _c.media) == null ? void 0 : _d.loadCustomStore) || props.mediaStore) {
1196
- const mediaStoreFromProps = ((_f = (_e = props.schema.config) == null ? void 0 : _e.media) == null ? void 0 : _f.loadCustomStore) || props.mediaStore;
1250
+ } else if (((_d2 = (_c2 = props.schema.config) == null ? void 0 : _c2.media) == null ? void 0 : _d2.loadCustomStore) || props.mediaStore) {
1251
+ const mediaStoreFromProps = ((_f = (_e2 = props.schema.config) == null ? void 0 : _e2.media) == null ? void 0 : _f.loadCustomStore) || props.mediaStore;
1197
1252
  if ((_g = mediaStoreFromProps.prototype) == null ? void 0 : _g.persist) {
1198
1253
  cms.media.store = new mediaStoreFromProps(cms.api.tina);
1199
1254
  } else {
@@ -1204,6 +1259,8 @@ mutation addPendingDocumentMutation(
1204
1259
  cms.media.store = new toolkit.DummyMediaStore();
1205
1260
  }
1206
1261
  };
1262
+ const client = cms.api.tina;
1263
+ 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);
1207
1264
  const handleListBranches = async () => {
1208
1265
  const { owner, repo } = props;
1209
1266
  const branches = await cms.api.tina.listBranches({ owner, repo });
@@ -1246,6 +1303,27 @@ mutation addPendingDocumentMutation(
1246
1303
  props.cmsCallback(cms);
1247
1304
  }
1248
1305
  }, []);
1306
+ React__default["default"].useEffect(() => {
1307
+ const setupEditorialWorkflow = () => {
1308
+ client.getProject().then((project) => {
1309
+ var _a2;
1310
+ if ((_a2 = project == null ? void 0 : project.features) == null ? void 0 : _a2.includes("editorial-workflow")) {
1311
+ cms.flags.set("branch-switcher", true);
1312
+ client.usingEditorialWorkflow = true;
1313
+ client.protectedBranches = project.protectedBranches;
1314
+ }
1315
+ });
1316
+ };
1317
+ if (isTinaCloud) {
1318
+ setupEditorialWorkflow();
1319
+ }
1320
+ const unsubscribe = cms.events.subscribe("cms:login", () => {
1321
+ if (isTinaCloud) {
1322
+ setupEditorialWorkflow();
1323
+ }
1324
+ });
1325
+ return unsubscribe;
1326
+ }, [isTinaCloud, cms]);
1249
1327
  return /* @__PURE__ */ React__default["default"].createElement(toolkit.BranchDataProvider, {
1250
1328
  currentBranch,
1251
1329
  setCurrentBranch: (b) => {
@@ -1575,6 +1653,343 @@ mutation addPendingDocumentMutation(
1575
1653
  --tw-backdrop-saturate: ;
1576
1654
  --tw-backdrop-sepia: ;
1577
1655
  }
1656
+ .tina-prose {
1657
+ color: var(--tw-prose-body);
1658
+ max-width: 65ch;
1659
+ }
1660
+ .tina-prose :where([class~="lead"]):not(:where([class~="not-tina-prose"] *)) {
1661
+ color: var(--tw-prose-lead);
1662
+ font-size: 1.25em;
1663
+ line-height: 1.6;
1664
+ margin-top: 1.2em;
1665
+ margin-bottom: 1.2em;
1666
+ }
1667
+ .tina-prose :where(a):not(:where([class~="not-tina-prose"] *)) {
1668
+ color: var(--tw-prose-links);
1669
+ text-decoration: underline;
1670
+ font-weight: 500;
1671
+ }
1672
+ .tina-prose :where(strong):not(:where([class~="not-tina-prose"] *)) {
1673
+ color: var(--tw-prose-bold);
1674
+ font-weight: 600;
1675
+ }
1676
+ .tina-prose :where(ol):not(:where([class~="not-tina-prose"] *)) {
1677
+ list-style-type: decimal;
1678
+ padding-left: 1.625em;
1679
+ }
1680
+ .tina-prose :where(ol[type="A"]):not(:where([class~="not-tina-prose"] *)) {
1681
+ list-style-type: upper-alpha;
1682
+ }
1683
+ .tina-prose :where(ol[type="a"]):not(:where([class~="not-tina-prose"] *)) {
1684
+ list-style-type: lower-alpha;
1685
+ }
1686
+ .tina-prose :where(ol[type="A" s]):not(:where([class~="not-tina-prose"] *)) {
1687
+ list-style-type: upper-alpha;
1688
+ }
1689
+ .tina-prose :where(ol[type="a" s]):not(:where([class~="not-tina-prose"] *)) {
1690
+ list-style-type: lower-alpha;
1691
+ }
1692
+ .tina-prose :where(ol[type="I"]):not(:where([class~="not-tina-prose"] *)) {
1693
+ list-style-type: upper-roman;
1694
+ }
1695
+ .tina-prose :where(ol[type="i"]):not(:where([class~="not-tina-prose"] *)) {
1696
+ list-style-type: lower-roman;
1697
+ }
1698
+ .tina-prose :where(ol[type="I" s]):not(:where([class~="not-tina-prose"] *)) {
1699
+ list-style-type: upper-roman;
1700
+ }
1701
+ .tina-prose :where(ol[type="i" s]):not(:where([class~="not-tina-prose"] *)) {
1702
+ list-style-type: lower-roman;
1703
+ }
1704
+ .tina-prose :where(ol[type="1"]):not(:where([class~="not-tina-prose"] *)) {
1705
+ list-style-type: decimal;
1706
+ }
1707
+ .tina-prose :where(ul):not(:where([class~="not-tina-prose"] *)) {
1708
+ list-style-type: disc;
1709
+ padding-left: 1.625em;
1710
+ }
1711
+ .tina-prose :where(ol > li):not(:where([class~="not-tina-prose"] *))::marker {
1712
+ font-weight: 400;
1713
+ color: var(--tw-prose-counters);
1714
+ }
1715
+ .tina-prose :where(ul > li):not(:where([class~="not-tina-prose"] *))::marker {
1716
+ color: var(--tw-prose-bullets);
1717
+ }
1718
+ .tina-prose :where(hr):not(:where([class~="not-tina-prose"] *)) {
1719
+ border-color: var(--tw-prose-hr);
1720
+ border-top-width: 1px;
1721
+ margin-top: 3em;
1722
+ margin-bottom: 3em;
1723
+ }
1724
+ .tina-prose :where(blockquote):not(:where([class~="not-tina-prose"] *)) {
1725
+ font-weight: 500;
1726
+ font-style: italic;
1727
+ color: var(--tw-prose-quotes);
1728
+ border-left-width: 0.25rem;
1729
+ border-left-color: var(--tw-prose-quote-borders);
1730
+ quotes: "\\201C""\\201D""\\2018""\\2019";
1731
+ margin-top: 1.6em;
1732
+ margin-bottom: 1.6em;
1733
+ padding-left: 1em;
1734
+ }
1735
+ .tina-prose :where(blockquote p:first-of-type):not(:where([class~="not-tina-prose"] *))::before {
1736
+ content: open-quote;
1737
+ }
1738
+ .tina-prose :where(blockquote p:last-of-type):not(:where([class~="not-tina-prose"] *))::after {
1739
+ content: close-quote;
1740
+ }
1741
+ .tina-prose :where(h1):not(:where([class~="not-tina-prose"] *)) {
1742
+ color: var(--tw-prose-headings);
1743
+ font-weight: 800;
1744
+ font-size: 2.25em;
1745
+ margin-top: 0;
1746
+ margin-bottom: 0.8888889em;
1747
+ line-height: 1.1111111;
1748
+ }
1749
+ .tina-prose :where(h1 strong):not(:where([class~="not-tina-prose"] *)) {
1750
+ font-weight: 900;
1751
+ }
1752
+ .tina-prose :where(h2):not(:where([class~="not-tina-prose"] *)) {
1753
+ color: var(--tw-prose-headings);
1754
+ font-weight: 700;
1755
+ font-size: 1.5em;
1756
+ margin-top: 2em;
1757
+ margin-bottom: 1em;
1758
+ line-height: 1.3333333;
1759
+ }
1760
+ .tina-prose :where(h2 strong):not(:where([class~="not-tina-prose"] *)) {
1761
+ font-weight: 800;
1762
+ }
1763
+ .tina-prose :where(h3):not(:where([class~="not-tina-prose"] *)) {
1764
+ color: var(--tw-prose-headings);
1765
+ font-weight: 600;
1766
+ font-size: 1.25em;
1767
+ margin-top: 1.6em;
1768
+ margin-bottom: 0.6em;
1769
+ line-height: 1.6;
1770
+ }
1771
+ .tina-prose :where(h3 strong):not(:where([class~="not-tina-prose"] *)) {
1772
+ font-weight: 700;
1773
+ }
1774
+ .tina-prose :where(h4):not(:where([class~="not-tina-prose"] *)) {
1775
+ color: var(--tw-prose-headings);
1776
+ font-weight: 600;
1777
+ margin-top: 1.5em;
1778
+ margin-bottom: 0.5em;
1779
+ line-height: 1.5;
1780
+ }
1781
+ .tina-prose :where(h4 strong):not(:where([class~="not-tina-prose"] *)) {
1782
+ font-weight: 700;
1783
+ }
1784
+ .tina-prose :where(figure > *):not(:where([class~="not-tina-prose"] *)) {
1785
+ margin-top: 0;
1786
+ margin-bottom: 0;
1787
+ }
1788
+ .tina-prose :where(figcaption):not(:where([class~="not-tina-prose"] *)) {
1789
+ color: var(--tw-prose-captions);
1790
+ font-size: 0.875em;
1791
+ line-height: 1.4285714;
1792
+ margin-top: 0.8571429em;
1793
+ }
1794
+ .tina-prose :where(code):not(:where([class~="not-tina-prose"] *)) {
1795
+ color: var(--tw-prose-code);
1796
+ font-weight: 600;
1797
+ font-size: 0.875em;
1798
+ }
1799
+ .tina-prose :where(code):not(:where([class~="not-tina-prose"] *))::before {
1800
+ content: "\`";
1801
+ }
1802
+ .tina-prose :where(code):not(:where([class~="not-tina-prose"] *))::after {
1803
+ content: "\`";
1804
+ }
1805
+ .tina-prose :where(a code):not(:where([class~="not-tina-prose"] *)) {
1806
+ color: var(--tw-prose-links);
1807
+ }
1808
+ .tina-prose :where(pre):not(:where([class~="not-tina-prose"] *)) {
1809
+ color: var(--tw-prose-pre-code);
1810
+ background-color: var(--tw-prose-pre-bg);
1811
+ overflow-x: auto;
1812
+ font-weight: 400;
1813
+ font-size: 0.875em;
1814
+ line-height: 1.7142857;
1815
+ margin-top: 1.7142857em;
1816
+ margin-bottom: 1.7142857em;
1817
+ border-radius: 0.375rem;
1818
+ padding-top: 0.8571429em;
1819
+ padding-right: 1.1428571em;
1820
+ padding-bottom: 0.8571429em;
1821
+ padding-left: 1.1428571em;
1822
+ }
1823
+ .tina-prose :where(pre code):not(:where([class~="not-tina-prose"] *)) {
1824
+ background-color: transparent;
1825
+ border-width: 0;
1826
+ border-radius: 0;
1827
+ padding: 0;
1828
+ font-weight: inherit;
1829
+ color: inherit;
1830
+ font-size: inherit;
1831
+ font-family: inherit;
1832
+ line-height: inherit;
1833
+ }
1834
+ .tina-prose :where(pre code):not(:where([class~="not-tina-prose"] *))::before {
1835
+ content: none;
1836
+ }
1837
+ .tina-prose :where(pre code):not(:where([class~="not-tina-prose"] *))::after {
1838
+ content: none;
1839
+ }
1840
+ .tina-prose :where(table):not(:where([class~="not-tina-prose"] *)) {
1841
+ width: 100%;
1842
+ table-layout: auto;
1843
+ text-align: left;
1844
+ margin-top: 2em;
1845
+ margin-bottom: 2em;
1846
+ font-size: 0.875em;
1847
+ line-height: 1.7142857;
1848
+ }
1849
+ .tina-prose :where(thead):not(:where([class~="not-tina-prose"] *)) {
1850
+ border-bottom-width: 1px;
1851
+ border-bottom-color: var(--tw-prose-th-borders);
1852
+ }
1853
+ .tina-prose :where(thead th):not(:where([class~="not-tina-prose"] *)) {
1854
+ color: var(--tw-prose-headings);
1855
+ font-weight: 600;
1856
+ vertical-align: bottom;
1857
+ padding-right: 0.5714286em;
1858
+ padding-bottom: 0.5714286em;
1859
+ padding-left: 0.5714286em;
1860
+ }
1861
+ .tina-prose :where(tbody tr):not(:where([class~="not-tina-prose"] *)) {
1862
+ border-bottom-width: 1px;
1863
+ border-bottom-color: var(--tw-prose-td-borders);
1864
+ }
1865
+ .tina-prose :where(tbody tr:last-child):not(:where([class~="not-tina-prose"] *)) {
1866
+ border-bottom-width: 0;
1867
+ }
1868
+ .tina-prose :where(tbody td):not(:where([class~="not-tina-prose"] *)) {
1869
+ vertical-align: baseline;
1870
+ padding-top: 0.5714286em;
1871
+ padding-right: 0.5714286em;
1872
+ padding-bottom: 0.5714286em;
1873
+ padding-left: 0.5714286em;
1874
+ }
1875
+ .tina-prose {
1876
+ --tw-prose-body: #374151;
1877
+ --tw-prose-headings: #111827;
1878
+ --tw-prose-lead: #4b5563;
1879
+ --tw-prose-links: #111827;
1880
+ --tw-prose-bold: #111827;
1881
+ --tw-prose-counters: #6b7280;
1882
+ --tw-prose-bullets: #d1d5db;
1883
+ --tw-prose-hr: #e5e7eb;
1884
+ --tw-prose-quotes: #111827;
1885
+ --tw-prose-quote-borders: #e5e7eb;
1886
+ --tw-prose-captions: #6b7280;
1887
+ --tw-prose-code: #111827;
1888
+ --tw-prose-pre-code: #e5e7eb;
1889
+ --tw-prose-pre-bg: #1f2937;
1890
+ --tw-prose-th-borders: #d1d5db;
1891
+ --tw-prose-td-borders: #e5e7eb;
1892
+ --tw-prose-invert-body: #d1d5db;
1893
+ --tw-prose-invert-headings: #fff;
1894
+ --tw-prose-invert-lead: #9ca3af;
1895
+ --tw-prose-invert-links: #fff;
1896
+ --tw-prose-invert-bold: #fff;
1897
+ --tw-prose-invert-counters: #9ca3af;
1898
+ --tw-prose-invert-bullets: #4b5563;
1899
+ --tw-prose-invert-hr: #374151;
1900
+ --tw-prose-invert-quotes: #f3f4f6;
1901
+ --tw-prose-invert-quote-borders: #374151;
1902
+ --tw-prose-invert-captions: #9ca3af;
1903
+ --tw-prose-invert-code: #fff;
1904
+ --tw-prose-invert-pre-code: #d1d5db;
1905
+ --tw-prose-invert-pre-bg: rgb(0 0 0 / 50%);
1906
+ --tw-prose-invert-th-borders: #4b5563;
1907
+ --tw-prose-invert-td-borders: #374151;
1908
+ font-size: 1rem;
1909
+ line-height: 1.75;
1910
+ }
1911
+ .tina-prose :where(p):not(:where([class~="not-tina-prose"] *)) {
1912
+ margin-top: 1.25em;
1913
+ margin-bottom: 1.25em;
1914
+ }
1915
+ .tina-prose :where(img):not(:where([class~="not-tina-prose"] *)) {
1916
+ margin-top: 2em;
1917
+ margin-bottom: 2em;
1918
+ }
1919
+ .tina-prose :where(video):not(:where([class~="not-tina-prose"] *)) {
1920
+ margin-top: 2em;
1921
+ margin-bottom: 2em;
1922
+ }
1923
+ .tina-prose :where(figure):not(:where([class~="not-tina-prose"] *)) {
1924
+ margin-top: 2em;
1925
+ margin-bottom: 2em;
1926
+ }
1927
+ .tina-prose :where(h2 code):not(:where([class~="not-tina-prose"] *)) {
1928
+ font-size: 0.875em;
1929
+ }
1930
+ .tina-prose :where(h3 code):not(:where([class~="not-tina-prose"] *)) {
1931
+ font-size: 0.9em;
1932
+ }
1933
+ .tina-prose :where(li):not(:where([class~="not-tina-prose"] *)) {
1934
+ margin-top: 0.5em;
1935
+ margin-bottom: 0.5em;
1936
+ }
1937
+ .tina-prose :where(ol > li):not(:where([class~="not-tina-prose"] *)) {
1938
+ padding-left: 0.375em;
1939
+ }
1940
+ .tina-prose :where(ul > li):not(:where([class~="not-tina-prose"] *)) {
1941
+ padding-left: 0.375em;
1942
+ }
1943
+ .tina-prose > :where(ul > li p):not(:where([class~="not-tina-prose"] *)) {
1944
+ margin-top: 0.75em;
1945
+ margin-bottom: 0.75em;
1946
+ }
1947
+ .tina-prose > :where(ul > li > *:first-child):not(:where([class~="not-tina-prose"] *)) {
1948
+ margin-top: 1.25em;
1949
+ }
1950
+ .tina-prose > :where(ul > li > *:last-child):not(:where([class~="not-tina-prose"] *)) {
1951
+ margin-bottom: 1.25em;
1952
+ }
1953
+ .tina-prose > :where(ol > li > *:first-child):not(:where([class~="not-tina-prose"] *)) {
1954
+ margin-top: 1.25em;
1955
+ }
1956
+ .tina-prose > :where(ol > li > *:last-child):not(:where([class~="not-tina-prose"] *)) {
1957
+ margin-bottom: 1.25em;
1958
+ }
1959
+ .tina-prose :where(ul ul, ul ol, ol ul, ol ol):not(:where([class~="not-tina-prose"] *)) {
1960
+ margin-top: 0.75em;
1961
+ margin-bottom: 0.75em;
1962
+ }
1963
+ .tina-prose :where(hr + *):not(:where([class~="not-tina-prose"] *)) {
1964
+ margin-top: 0;
1965
+ }
1966
+ .tina-prose :where(h2 + *):not(:where([class~="not-tina-prose"] *)) {
1967
+ margin-top: 0;
1968
+ }
1969
+ .tina-prose :where(h3 + *):not(:where([class~="not-tina-prose"] *)) {
1970
+ margin-top: 0;
1971
+ }
1972
+ .tina-prose :where(h4 + *):not(:where([class~="not-tina-prose"] *)) {
1973
+ margin-top: 0;
1974
+ }
1975
+ .tina-prose :where(thead th:first-child):not(:where([class~="not-tina-prose"] *)) {
1976
+ padding-left: 0;
1977
+ }
1978
+ .tina-prose :where(thead th:last-child):not(:where([class~="not-tina-prose"] *)) {
1979
+ padding-right: 0;
1980
+ }
1981
+ .tina-prose :where(tbody td:first-child):not(:where([class~="not-tina-prose"] *)) {
1982
+ padding-left: 0;
1983
+ }
1984
+ .tina-prose :where(tbody td:last-child):not(:where([class~="not-tina-prose"] *)) {
1985
+ padding-right: 0;
1986
+ }
1987
+ .tina-prose > :where(:first-child):not(:where([class~="not-tina-prose"] *)) {
1988
+ margin-top: 0;
1989
+ }
1990
+ .tina-prose > :where(:last-child):not(:where([class~="not-tina-prose"] *)) {
1991
+ margin-bottom: 0;
1992
+ }
1578
1993
  .tina-tailwind .pointer-events-none {
1579
1994
  pointer-events: none;
1580
1995
  }
@@ -1636,21 +2051,16 @@ mutation addPendingDocumentMutation(
1636
2051
  margin-left: auto;
1637
2052
  margin-right: auto;
1638
2053
  }
2054
+ .tina-tailwind .my-8 {
2055
+ margin-top: 32px;
2056
+ margin-bottom: 32px;
2057
+ }
1639
2058
  .tina-tailwind .-ml-px {
1640
2059
  margin-left: -1px;
1641
2060
  }
1642
- .tina-tailwind .-mt-0 {
1643
- margin-top: -0px;
1644
- }
1645
- .tina-tailwind .-mt-0\\.5 {
1646
- margin-top: -2px;
1647
- }
1648
2061
  .tina-tailwind .mb-1 {
1649
2062
  margin-bottom: 4px;
1650
2063
  }
1651
- .tina-tailwind .mb-2 {
1652
- margin-bottom: 8px;
1653
- }
1654
2064
  .tina-tailwind .mb-4 {
1655
2065
  margin-bottom: 16px;
1656
2066
  }
@@ -1753,9 +2163,15 @@ mutation addPendingDocumentMutation(
1753
2163
  .tina-tailwind .min-w-\\[200px\\] {
1754
2164
  min-width: 200px;
1755
2165
  }
2166
+ .tina-tailwind .min-w-\\[48px\\] {
2167
+ min-width: 48px;
2168
+ }
1756
2169
  .tina-tailwind .max-w-0 {
1757
2170
  max-width: 0rem;
1758
2171
  }
2172
+ .tina-tailwind .max-w-5xl {
2173
+ max-width: 64rem;
2174
+ }
1759
2175
  .tina-tailwind .max-w-form {
1760
2176
  max-width: 900px;
1761
2177
  }
@@ -1774,12 +2190,21 @@ mutation addPendingDocumentMutation(
1774
2190
  .tina-tailwind .flex-shrink-0 {
1775
2191
  flex-shrink: 0;
1776
2192
  }
2193
+ .tina-tailwind .shrink {
2194
+ flex-shrink: 1;
2195
+ }
1777
2196
  .tina-tailwind .shrink-0 {
1778
2197
  flex-shrink: 0;
1779
2198
  }
1780
2199
  .tina-tailwind .flex-grow-0 {
1781
2200
  flex-grow: 0;
1782
2201
  }
2202
+ .tina-tailwind .grow-0 {
2203
+ flex-grow: 0;
2204
+ }
2205
+ .tina-tailwind .basis-0 {
2206
+ flex-basis: 0px;
2207
+ }
1783
2208
  .tina-tailwind .table-auto {
1784
2209
  table-layout: auto;
1785
2210
  }
@@ -1815,6 +2240,15 @@ mutation addPendingDocumentMutation(
1815
2240
  .tina-tailwind .transform {
1816
2241
  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));
1817
2242
  }
2243
+ @keyframes spin {
2244
+
2245
+ to {
2246
+ transform: rotate(360deg);
2247
+ }
2248
+ }
2249
+ .tina-tailwind .animate-spin {
2250
+ animation: spin 1s linear infinite;
2251
+ }
1818
2252
  .tina-tailwind .cursor-pointer {
1819
2253
  cursor: pointer;
1820
2254
  }
@@ -1860,6 +2294,9 @@ mutation addPendingDocumentMutation(
1860
2294
  .tina-tailwind .gap-1 {
1861
2295
  gap: 4px;
1862
2296
  }
2297
+ .tina-tailwind .gap-1\\.5 {
2298
+ gap: 6px;
2299
+ }
1863
2300
  .tina-tailwind .gap-2 {
1864
2301
  gap: 8px;
1865
2302
  }
@@ -1887,6 +2324,9 @@ mutation addPendingDocumentMutation(
1887
2324
  .tina-tailwind .overflow-hidden {
1888
2325
  overflow: hidden;
1889
2326
  }
2327
+ .tina-tailwind .overflow-scroll {
2328
+ overflow: scroll;
2329
+ }
1890
2330
  .tina-tailwind .overflow-y-auto {
1891
2331
  overflow-y: auto;
1892
2332
  }
@@ -1926,6 +2366,9 @@ mutation addPendingDocumentMutation(
1926
2366
  .tina-tailwind .border-b {
1927
2367
  border-bottom-width: 1px;
1928
2368
  }
2369
+ .tina-tailwind .border-l-2 {
2370
+ border-left-width: 2px;
2371
+ }
1929
2372
  .tina-tailwind .border-r {
1930
2373
  border-right-width: 1px;
1931
2374
  }
@@ -2003,10 +2446,20 @@ mutation addPendingDocumentMutation(
2003
2446
  .tina-tailwind .p-0 {
2004
2447
  padding: 0px;
2005
2448
  }
2449
+ .tina-tailwind .p-6 {
2450
+ padding: 24px;
2451
+ }
2452
+ .tina-tailwind .p-8 {
2453
+ padding: 32px;
2454
+ }
2006
2455
  .tina-tailwind .px-12 {
2007
2456
  padding-left: 48px;
2008
2457
  padding-right: 48px;
2009
2458
  }
2459
+ .tina-tailwind .px-2 {
2460
+ padding-left: 8px;
2461
+ padding-right: 8px;
2462
+ }
2010
2463
  .tina-tailwind .px-20 {
2011
2464
  padding-left: 80px;
2012
2465
  padding-right: 80px;
@@ -2059,12 +2512,18 @@ mutation addPendingDocumentMutation(
2059
2512
  padding-top: 32px;
2060
2513
  padding-bottom: 32px;
2061
2514
  }
2515
+ .tina-tailwind .pb-4 {
2516
+ padding-bottom: 16px;
2517
+ }
2062
2518
  .tina-tailwind .pl-18 {
2063
2519
  padding-left: 72px;
2064
2520
  }
2065
2521
  .tina-tailwind .pl-3 {
2066
2522
  padding-left: 12px;
2067
2523
  }
2524
+ .tina-tailwind .pl-4 {
2525
+ padding-left: 16px;
2526
+ }
2068
2527
  .tina-tailwind .pl-5 {
2069
2528
  padding-left: 20px;
2070
2529
  }
@@ -2083,6 +2542,9 @@ mutation addPendingDocumentMutation(
2083
2542
  .tina-tailwind .pt-12 {
2084
2543
  padding-top: 48px;
2085
2544
  }
2545
+ .tina-tailwind .pt-3 {
2546
+ padding-top: 12px;
2547
+ }
2086
2548
  .tina-tailwind .pt-4 {
2087
2549
  padding-top: 16px;
2088
2550
  }
@@ -2092,6 +2554,9 @@ mutation addPendingDocumentMutation(
2092
2554
  .tina-tailwind .text-center {
2093
2555
  text-align: center;
2094
2556
  }
2557
+ .tina-tailwind .font-mono {
2558
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
2559
+ }
2095
2560
  .tina-tailwind .font-sans {
2096
2561
  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";
2097
2562
  }
@@ -2123,6 +2588,9 @@ mutation addPendingDocumentMutation(
2123
2588
  font-size: 13px;
2124
2589
  line-height: 1.33;
2125
2590
  }
2591
+ .tina-tailwind .font-bold {
2592
+ font-weight: 700;
2593
+ }
2126
2594
  .tina-tailwind .font-medium {
2127
2595
  font-weight: 500;
2128
2596
  }
@@ -2159,9 +2627,6 @@ mutation addPendingDocumentMutation(
2159
2627
  --tw-text-opacity: 1;
2160
2628
  color: rgb(5 116 228 / var(--tw-text-opacity));
2161
2629
  }
2162
- .tina-tailwind .text-current {
2163
- color: currentColor;
2164
- }
2165
2630
  .tina-tailwind .text-gray-200 {
2166
2631
  --tw-text-opacity: 1;
2167
2632
  color: rgb(225 221 236 / var(--tw-text-opacity));
@@ -2190,6 +2655,10 @@ mutation addPendingDocumentMutation(
2190
2655
  --tw-text-opacity: 1;
2191
2656
  color: rgb(37 35 54 / var(--tw-text-opacity));
2192
2657
  }
2658
+ .tina-tailwind .text-orange-600 {
2659
+ --tw-text-opacity: 1;
2660
+ color: rgb(220 68 25 / var(--tw-text-opacity));
2661
+ }
2193
2662
  .tina-tailwind .text-red-400 {
2194
2663
  --tw-text-opacity: 1;
2195
2664
  color: rgb(248 113 113 / var(--tw-text-opacity));
@@ -2198,6 +2667,10 @@ mutation addPendingDocumentMutation(
2198
2667
  --tw-text-opacity: 1;
2199
2668
  color: rgb(239 68 68 / var(--tw-text-opacity));
2200
2669
  }
2670
+ .tina-tailwind .text-red-700 {
2671
+ --tw-text-opacity: 1;
2672
+ color: rgb(185 28 28 / var(--tw-text-opacity));
2673
+ }
2201
2674
  .tina-tailwind .text-white {
2202
2675
  --tw-text-opacity: 1;
2203
2676
  color: rgb(255 255 255 / var(--tw-text-opacity));
@@ -2223,8 +2696,8 @@ mutation addPendingDocumentMutation(
2223
2696
  .tina-tailwind .opacity-20 {
2224
2697
  opacity: .2;
2225
2698
  }
2226
- .tina-tailwind .opacity-50 {
2227
- opacity: .5;
2699
+ .tina-tailwind .opacity-30 {
2700
+ opacity: .3;
2228
2701
  }
2229
2702
  .tina-tailwind .opacity-70 {
2230
2703
  opacity: .7;
@@ -2283,11 +2756,6 @@ mutation addPendingDocumentMutation(
2283
2756
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
2284
2757
  transition-duration: 150ms;
2285
2758
  }
2286
- .tina-tailwind .transition-colors {
2287
- transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
2288
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
2289
- transition-duration: 150ms;
2290
- }
2291
2759
  .tina-tailwind .transition-opacity {
2292
2760
  transition-property: opacity;
2293
2761
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
@@ -2343,6 +2811,9 @@ mutation addPendingDocumentMutation(
2343
2811
  --tw-text-opacity: 1;
2344
2812
  color: rgb(5 116 228 / var(--tw-text-opacity));
2345
2813
  }
2814
+ .tina-tailwind .hover\\:underline:hover {
2815
+ text-decoration-line: underline;
2816
+ }
2346
2817
  .tina-tailwind .hover\\:decoration-blue-400:hover {
2347
2818
  text-decoration-color: #2296fe;
2348
2819
  }
@@ -2356,17 +2827,10 @@ mutation addPendingDocumentMutation(
2356
2827
  --tw-border-opacity: 1;
2357
2828
  border-color: rgb(0 132 255 / var(--tw-border-opacity));
2358
2829
  }
2359
- .tina-tailwind .focus\\:text-blue-400:focus {
2360
- --tw-text-opacity: 1;
2361
- color: rgb(34 150 254 / var(--tw-text-opacity));
2362
- }
2363
2830
  .tina-tailwind .focus\\:text-gray-900:focus {
2364
2831
  --tw-text-opacity: 1;
2365
2832
  color: rgb(37 35 54 / var(--tw-text-opacity));
2366
2833
  }
2367
- .tina-tailwind .focus\\:underline:focus {
2368
- text-decoration-line: underline;
2369
- }
2370
2834
  .tina-tailwind .focus\\:shadow-outline:focus {
2371
2835
  --tw-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5);
2372
2836
  --tw-shadow-colored: 0 0 0 3px var(--tw-shadow-color);
@@ -2597,8 +3061,6 @@ mutation addPendingDocumentMutation(
2597
3061
  return { hasError: true, message: error.message };
2598
3062
  }
2599
3063
  render() {
2600
- const branchData = window.localStorage && window.localStorage.getItem("tinacms-current-branch");
2601
- const hasBranchData = branchData && branchData.length > 0;
2602
3064
  if (this.state.hasError && !this.state.pageRefresh) {
2603
3065
  return /* @__PURE__ */ React__default["default"].createElement("div", {
2604
3066
  style: {
@@ -2632,18 +3094,7 @@ mutation addPendingDocumentMutation(
2632
3094
  this.setState({ pageRefresh: true });
2633
3095
  setTimeout(() => this.setState({ hasError: false, pageRefresh: false }), 3e3);
2634
3096
  }
2635
- }, "Refresh"), hasBranchData && /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].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__default["default"].createElement("p", null, "See our", " ", /* @__PURE__ */ React__default["default"].createElement("a", {
2636
- className: "text-gray-600",
2637
- style: { textDecoration: "underline" },
2638
- href: "https://tina.io/docs/errors/faq/",
2639
- target: "_blank"
2640
- }, " ", "Error FAQ", " "), " ", "for more information."), /* @__PURE__ */ React__default["default"].createElement("button", {
2641
- style: errorButtonStyles,
2642
- onClick: () => {
2643
- window.localStorage.removeItem("tinacms-current-branch");
2644
- window.location.reload();
2645
- }
2646
- }, "Switch to default branch"))));
3097
+ }, "Refresh")));
2647
3098
  }
2648
3099
  if (this.state.pageRefresh) {
2649
3100
  return /* @__PURE__ */ React__default["default"].createElement(Loader, null, "Let's try that again.");
@@ -2947,6 +3398,9 @@ This will work when developing locally but NOT when deployed to production.
2947
3398
  function BiFolder(props) {
2948
3399
  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);
2949
3400
  }
3401
+ function BiLoaderAlt(props) {
3402
+ 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);
3403
+ }
2950
3404
  function BiLogIn(props) {
2951
3405
  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);
2952
3406
  }
@@ -3687,6 +4141,8 @@ This will work when developing locally but NOT when deployed to production.
3687
4141
  }));
3688
4142
  setEndCursor("");
3689
4143
  setPrevCursors([]);
4144
+ setSearch("");
4145
+ setSearchInput("");
3690
4146
  }, [loc]);
3691
4147
  React.useEffect(() => {
3692
4148
  setVars((old) => ({
@@ -3735,7 +4191,7 @@ This will work when developing locally but NOT when deployed to production.
3735
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;
3736
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;
3737
4193
  const folderView = folder.fullyQualifiedName !== "";
3738
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, deleteModalOpen && /* @__PURE__ */ React__default["default"].createElement(DeleteModal, {
4194
+ return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, deleteModalOpen && !cms.api.tina.usingProtectedBranch() && /* @__PURE__ */ React__default["default"].createElement(DeleteModal, {
3739
4195
  filename: vars.relativePath,
3740
4196
  deleteFunc: async () => {
3741
4197
  try {
@@ -3749,6 +4205,22 @@ This will work when developing locally but NOT when deployed to production.
3749
4205
  }
3750
4206
  },
3751
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
+ }
3752
4224
  }), renameModalOpen && /* @__PURE__ */ React__default["default"].createElement(RenameModal, {
3753
4225
  filename: vars.relativePath,
3754
4226
  newRelativePath: vars.newRelativePath,
@@ -4211,9 +4683,6 @@ This will work when developing locally but NOT when deployed to production.
4211
4683
  }
4212
4684
  }, "Rename"))));
4213
4685
  };
4214
- function HiChevronRight(props) {
4215
- 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);
4216
- }
4217
4686
  function FaLock(props) {
4218
4687
  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);
4219
4688
  }
@@ -4314,17 +4783,22 @@ This will work when developing locally but NOT when deployed to production.
4314
4783
  const defaultItem = customDefaults || ((_d = template.ui) == null ? void 0 : _d.defaultItem) || (template == null ? void 0 : template.defaultItem);
4315
4784
  const form = React.useMemo(() => {
4316
4785
  var _a2, _b2;
4786
+ const folderName = folder.fullyQualifiedName ? folder.name : "";
4317
4787
  return new toolkit.Form({
4788
+ crudType: "create",
4318
4789
  initialValues: typeof defaultItem === "function" ? defaultItem() : defaultItem,
4319
4790
  extraSubscribeValues: { active: true, submitting: true, touched: true },
4320
4791
  onChange: (values) => {
4321
- var _a3;
4322
- if (slugFunction && (values == null ? void 0 : values.active) !== "filename" && !(values == null ? void 0 : values.submitting) && !((_a3 = values.touched) == null ? void 0 : _a3.filename)) {
4792
+ var _a3, _b3;
4793
+ if (!(values == null ? void 0 : values.submitting)) {
4794
+ form.relativePath = schemaCollection.path + folderName + `/${(_a3 = values == null ? void 0 : values.values) == null ? void 0 : _a3.filename}.${schemaCollection.format || "md"}`;
4795
+ }
4796
+ if (slugFunction && (values == null ? void 0 : values.active) !== "filename" && !(values == null ? void 0 : values.submitting) && !((_b3 = values.touched) == null ? void 0 : _b3.filename)) {
4323
4797
  const value = slugFunction(values == null ? void 0 : values.values);
4324
4798
  form.finalForm.change("filename", value);
4325
4799
  }
4326
4800
  },
4327
- id: "create-form",
4801
+ id: schemaCollection.path + folderName + `/new-post.${schemaCollection.format || "md"}`,
4328
4802
  label: "form",
4329
4803
  fields: [
4330
4804
  ...formInfo.fields,
@@ -4368,8 +4842,8 @@ This will work when developing locally but NOT when deployed to production.
4368
4842
  ],
4369
4843
  onSubmit: async (values) => {
4370
4844
  try {
4371
- const folderName = folder.fullyQualifiedName ? folder.name : "";
4372
- await createDocument(cms, collection, template, mutationInfo, folderName, values);
4845
+ const folderName2 = folder.fullyQualifiedName ? folder.name : "";
4846
+ await createDocument(cms, collection, template, mutationInfo, folderName2, values);
4373
4847
  cms.alerts.success("Document created!");
4374
4848
  setTimeout(() => {
4375
4849
  navigate(`/collections/${collection.name}${folder.fullyQualifiedName ? `/${folder.fullyQualifiedName}` : ""}`);
@@ -4404,21 +4878,17 @@ This will work when developing locally but NOT when deployed to production.
4404
4878
  }
4405
4879
  const activeForm = cms.state.forms.find(({ tinaForm }) => tinaForm.id === form.id);
4406
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", {
4407
- className: `py-4 border-b border-gray-200 bg-white ${headerPadding}`
4408
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
4409
- className: "max-w-form mx-auto"
4881
+ className: `pt-3 pb-4 border-b border-gray-200 bg-white w-full grow-0 shrink basis-0 flex justify-center ${headerPadding}`
4410
4882
  }, /* @__PURE__ */ React__default["default"].createElement("div", {
4411
- className: "mb-2"
4412
- }, /* @__PURE__ */ React__default["default"].createElement("span", {
4413
- className: "block text-sm leading-tight uppercase text-gray-400 mb-1"
4883
+ className: "w-full max-w-form flex gap-1.5 justify-between items-center"
4414
4884
  }, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
4415
4885
  to: `/collections/${collection.name}${folder.fullyQualifiedName ? `/${folder.fullyQualifiedName}` : ""}`,
4416
- 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"
4417
- }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React__default["default"].createElement(HiChevronRight, {
4418
- className: "inline-block -mt-0.5 opacity-50"
4419
- })), /* @__PURE__ */ React__default["default"].createElement("span", {
4420
- className: "text-xl text-gray-700 font-medium leading-tight"
4421
- }, "Create New")), /* @__PURE__ */ React__default["default"].createElement(toolkit.FormStatus, {
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, {
4422
4892
  pristine: formIsPristine
4423
4893
  }))), activeForm && /* @__PURE__ */ React__default["default"].createElement(toolkit.FormBuilder, {
4424
4894
  form: activeForm,
@@ -4564,7 +5034,7 @@ This will work when developing locally but NOT when deployed to production.
4564
5034
  });
4565
5035
  const form = React.useMemo(() => {
4566
5036
  return new toolkit.Form({
4567
- id: "update-form",
5037
+ id: `${schemaCollection.path}/${relativePath2}`,
4568
5038
  label: "form",
4569
5039
  fields: formInfo.fields,
4570
5040
  initialValues: document._values,
@@ -4596,21 +5066,17 @@ This will work when developing locally but NOT when deployed to production.
4596
5066
  }
4597
5067
  const activeForm = cms.state.forms.find(({ tinaForm }) => tinaForm.id === form.id);
4598
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", {
4599
- className: `py-4 border-b border-gray-200 bg-white ${headerPadding}`
4600
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
4601
- className: "max-w-form mx-auto"
5069
+ className: `pt-3 pb-4 border-b border-gray-200 bg-white w-full grow-0 shrink basis-0 flex justify-center ${headerPadding}`
4602
5070
  }, /* @__PURE__ */ React__default["default"].createElement("div", {
4603
- className: "mb-2"
4604
- }, /* @__PURE__ */ React__default["default"].createElement("span", {
4605
- className: "block text-sm leading-tight uppercase text-gray-400 mb-1"
5071
+ className: "w-full max-w-form flex gap-1.5 justify-between items-center"
4606
5072
  }, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
4607
5073
  to: `/collections/${collection.name}/~${parentFolder2}`,
4608
- 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"
4609
- }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React__default["default"].createElement(HiChevronRight, {
4610
- className: "inline-block -mt-0.5 opacity-50"
4611
- })), /* @__PURE__ */ React__default["default"].createElement("span", {
4612
- className: "text-xl text-gray-700 font-medium leading-tight"
4613
- }, "Edit ", `${filename}.${collection.format}`)), /* @__PURE__ */ React__default["default"].createElement(toolkit.FormStatus, {
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, {
4614
5080
  pristine: formIsPristine
4615
5081
  }))), activeForm && /* @__PURE__ */ React__default["default"].createElement(toolkit.FormBuilder, {
4616
5082
  form: activeForm,
@@ -4638,6 +5104,127 @@ This will work when developing locally but NOT when deployed to production.
4638
5104
  })));
4639
5105
  });
4640
5106
  };
5107
+ const IndexingPage = () => {
5108
+ const cms = toolkit.useCMS();
5109
+ const tinaApi = cms.api.tina;
5110
+ const currentBranch = tinaApi.branch;
5111
+ const kind = localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.kind");
5112
+ 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"));
5116
+ const [searchParams] = reactRouterDom.useSearchParams();
5117
+ const back = localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.back");
5118
+ 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"));
5121
+ React.useEffect(() => {
5122
+ const run = async () => {
5123
+ if (state === "starting") {
5124
+ try {
5125
+ console.log("starting", branch, toolkit.formatBranchName(branch));
5126
+ const name = await tinaApi.createBranch({
5127
+ branchName: toolkit.formatBranchName(branch),
5128
+ baseBranch: currentBranch
5129
+ });
5130
+ if (!name) {
5131
+ throw new Error("Branch creation failed.");
5132
+ }
5133
+ setBranch(name);
5134
+ localStorage.setItem("tina.createBranchState", "indexing");
5135
+ cms.alerts.success("Branch created.");
5136
+ setState("indexing");
5137
+ } catch (e) {
5138
+ console.error(e);
5139
+ cms.alerts.error("Branch creation failed: " + e.message);
5140
+ setErrorMessage("Branch creation failed, please try again. By refreshing the page.");
5141
+ setState("error");
5142
+ }
5143
+ }
5144
+ if (state === "indexing") {
5145
+ try {
5146
+ const [
5147
+ waitForIndexStatusPromise,
5148
+ _cancelWaitForIndexFunc
5149
+ ] = tinaApi.waitForIndexStatus({
5150
+ ref: branch
5151
+ });
5152
+ await waitForIndexStatusPromise;
5153
+ cms.alerts.success("Branch indexed.");
5154
+ localStorage.setItem("tina.createBranchState", "submitting");
5155
+ setState("submitting");
5156
+ } catch {
5157
+ 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.');
5159
+ setState("error");
5160
+ }
5161
+ }
5162
+ if (state === "submitting") {
5163
+ try {
5164
+ setBaseBranch(tinaApi.branch);
5165
+ localStorage.setItem("tina.createBranchState.baseBranch", tinaApi.branch);
5166
+ setCurrentBranch(branch);
5167
+ const collection = tinaApi.schema.getCollectionByFullPath(fullPath);
5168
+ const api = new TinaAdminApi(cms);
5169
+ const params = api.schema.transformPayload(collection.name, values);
5170
+ const relativePath2 = fullPath.replace(`${collection.path}/`, "");
5171
+ if (await api.isAuthenticated()) {
5172
+ if (kind === "delete") {
5173
+ await api.deleteDocument(values);
5174
+ } else if (kind === "create") {
5175
+ await api.createDocument(collection, relativePath2, params);
5176
+ } else {
5177
+ await api.updateDocument(collection, relativePath2, params);
5178
+ }
5179
+ } else {
5180
+ const authMessage = `UpdateDocument failed: User is no longer authenticated; please login and try again.`;
5181
+ cms.alerts.error(authMessage);
5182
+ console.error(authMessage);
5183
+ return false;
5184
+ }
5185
+ localStorage.setItem("tina.createBranchState", "creatingPR");
5186
+ cms.alerts.success("Content saved.");
5187
+ setState("creatingPR");
5188
+ } catch (e) {
5189
+ console.error(e);
5190
+ cms.alerts.error("Content save failed.");
5191
+ setErrorMessage("Content save failed, please try again. If the problem persists please contact support.");
5192
+ setState("error");
5193
+ }
5194
+ }
5195
+ if (state === "creatingPR") {
5196
+ const foo = await tinaApi.createPullRequest({
5197
+ baseBranch,
5198
+ branch,
5199
+ title: "PR from TinaCMS"
5200
+ });
5201
+ console.log("PR created", foo);
5202
+ cms.alerts.success("Pull request created.");
5203
+ localStorage.setItem("tina.createBranchState", "done");
5204
+ setState("done");
5205
+ }
5206
+ if (state === "done") {
5207
+ window.location.href = back;
5208
+ }
5209
+ };
5210
+ if (fullPath && values && branch && back) {
5211
+ run();
5212
+ }
5213
+ }, [state]);
5214
+ 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."));
5216
+ }
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, " "));
5224
+ };
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);
4641
5228
  const Redirect = () => {
4642
5229
  React__default["default"].useEffect(() => {
4643
5230
  if (window) {
@@ -4713,6 +5300,8 @@ This will work when developing locally but NOT when deployed to production.
4713
5300
  const cms = toolkit.useCMS();
4714
5301
  const api = new TinaAdminApi(cms);
4715
5302
  const url = api.api.contentApiUrl;
5303
+ const [schemaMissingError, setSchemaMissingError] = React__default["default"].useState(false);
5304
+ const currentBranch = decodeURIComponent(cms.api.tina.branch);
4716
5305
  React.useEffect(() => {
4717
5306
  if (schemaJson && cms) {
4718
5307
  api.checkGraphqlSchema({
@@ -4721,10 +5310,32 @@ This will work when developing locally but NOT when deployed to production.
4721
5310
  if (x === false) {
4722
5311
  cms.alerts.error("GraphQL Schema Mismatch. Editing may not work. If you just switched branches, try going back to the previous branch");
4723
5312
  }
5313
+ }).catch((e) => {
5314
+ if (e.message.includes("has not been indexed by Tina Cloud")) {
5315
+ setSchemaMissingError(true);
5316
+ } else {
5317
+ throw e;
5318
+ }
4724
5319
  });
4725
5320
  }
4726
5321
  }, [cms, JSON.stringify(schemaJson || {}), url]);
4727
- return children;
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);
4728
5339
  };
4729
5340
  const TinaAdmin = ({
4730
5341
  preview,
@@ -4750,7 +5361,7 @@ This will work when developing locally but NOT when deployed to production.
4750
5361
  return typeof ((_a2 = x == null ? void 0 : x.ui) == null ? void 0 : _a2.router) === "function";
4751
5362
  });
4752
5363
  const hasRouter = Boolean(collectionWithRouter);
4753
- return /* @__PURE__ */ React__default["default"].createElement(CheckSchema, {
5364
+ return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement(CheckSchema, {
4754
5365
  schemaJson
4755
5366
  }, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.HashRouter, null, /* @__PURE__ */ React__default["default"].createElement(SetPreviewFlag, {
4756
5367
  preview,
@@ -4764,6 +5375,11 @@ This will work when developing locally but NOT when deployed to production.
4764
5375
  }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
4765
5376
  path: "graphql",
4766
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))
4767
5383
  }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
4768
5384
  path: "collections/new/:collectionName",
4769
5385
  element: /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
@@ -4821,7 +5437,7 @@ This will work when developing locally but NOT when deployed to production.
4821
5437
  }, /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
4822
5438
  cms
4823
5439
  }, /* @__PURE__ */ React__default["default"].createElement(DashboardPage, null)))
4824
- }))));
5440
+ })))));
4825
5441
  } else {
4826
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, {
4827
5443
  path: "logout",