tinacms 2.7.2 → 2.7.4

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.mjs CHANGED
@@ -43,6 +43,7 @@ import { twMerge } from "tailwind-merge";
43
43
  import { Command as Command$1 } from "cmdk";
44
44
  import { isHotkey } from "is-hotkey";
45
45
  import { Transforms, Element, Range, Path, Node, Editor as Editor$1 } from "slate";
46
+ import { useWindowWidth } from "@react-hook/window-size";
46
47
  import get from "lodash.get";
47
48
  import moment from "moment";
48
49
  import { formatDistanceToNow } from "date-fns";
@@ -52,13 +53,12 @@ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
52
53
  import { ELEMENT_PARAGRAPH as ELEMENT_PARAGRAPH$1 } from "@udecode/plate-paragraph";
53
54
  import { ELEMENT_BLOCKQUOTE as ELEMENT_BLOCKQUOTE$1 } from "@udecode/plate-block-quote";
54
55
  import { useFloatingToolbarState, offset, flip, useFloatingToolbar } from "@udecode/plate-floating";
55
- import { useWindowWidth } from "@react-hook/window-size";
56
56
  import { getIntrospectionQuery, buildClientSchema, print, parse as parse$3, buildSchema } from "graphql";
57
57
  import gql from "graphql-tag";
58
58
  import { TinaSchema, addNamespaceToSchema, parseURL, resolveForm, normalizePath, validateSchema } from "@tinacms/schema-tools";
59
59
  import { NAMER, resolveField } from "@tinacms/schema-tools";
60
- import * as yup from "yup";
61
60
  import { diff } from "@graphql-inspector/core";
61
+ import * as yup from "yup";
62
62
  import { NavLink, useNavigate, useLocation, useParams, Link, useSearchParams, HashRouter, Routes, Route } from "react-router-dom";
63
63
  import { stringifyMDX } from "@tinacms/mdx";
64
64
  const ModalProvider = ({ children }) => {
@@ -5332,7 +5332,9 @@ const Combobox = ({ cms, input, field }) => {
5332
5332
  }, [value, input, optionSets]);
5333
5333
  React.useEffect(() => {
5334
5334
  if (field.experimental___filter && optionSets.length > 0) {
5335
- setFilteredOptionsList(field.experimental___filter(optionSets, void 0));
5335
+ setFilteredOptionsList(
5336
+ field.experimental___filter(optionSets, void 0)
5337
+ );
5336
5338
  } else {
5337
5339
  setFilteredOptionsList(optionSets);
5338
5340
  }
@@ -5702,7 +5704,9 @@ const Item$2 = ({
5702
5704
  onClick: () => {
5703
5705
  const state = tinaForm.finalForm.getState();
5704
5706
  if (state.invalid === true) {
5705
- cms.alerts.error("Cannot navigate away from an invalid form.");
5707
+ cms.alerts.error(
5708
+ "Cannot navigate away from an invalid form."
5709
+ );
5706
5710
  return;
5707
5711
  }
5708
5712
  cms.dispatch({
@@ -6286,7 +6290,9 @@ const BlockListItem = ({
6286
6290
  onClick: () => {
6287
6291
  const state = tinaForm.finalForm.getState();
6288
6292
  if (state.invalid === true) {
6289
- cms.alerts.error("Cannot navigate away from an invalid form.");
6293
+ cms.alerts.error(
6294
+ "Cannot navigate away from an invalid form."
6295
+ );
6290
6296
  return;
6291
6297
  }
6292
6298
  cms.dispatch({
@@ -6768,28 +6774,28 @@ class DaysView extends React__default.Component {
6768
6774
  }
6769
6775
  renderDayHeaders() {
6770
6776
  const locale = this.props.viewDate.localeData();
6771
- let dayItems = getDaysOfWeek(locale).map((day, index) => /* @__PURE__ */ React__default.createElement("th", { key: day + index, className: "dow" }, day));
6777
+ const dayItems = getDaysOfWeek(locale).map((day, index) => /* @__PURE__ */ React__default.createElement("th", { key: day + index, className: "dow" }, day));
6772
6778
  return /* @__PURE__ */ React__default.createElement("tr", null, dayItems);
6773
6779
  }
6774
6780
  renderDays() {
6775
6781
  const date = this.props.viewDate;
6776
6782
  const startOfMonth = date.clone().startOf("month");
6777
6783
  const endOfMonth = date.clone().endOf("month");
6778
- let rows = [[], [], [], [], [], []];
6779
- let startDate = date.clone().subtract(1, "months");
6784
+ const rows = [[], [], [], [], [], []];
6785
+ const startDate = date.clone().subtract(1, "months");
6780
6786
  startDate.date(startDate.daysInMonth()).startOf("week");
6781
- let endDate = startDate.clone().add(42, "d");
6787
+ const endDate = startDate.clone().add(42, "d");
6782
6788
  let i = 0;
6783
6789
  while (startDate.isBefore(endDate)) {
6784
- let row = getRow$2(rows, i++);
6790
+ const row = getRow$2(rows, i++);
6785
6791
  row.push(this.renderDay(startDate, startOfMonth, endOfMonth));
6786
6792
  startDate.add(1, "d");
6787
6793
  }
6788
6794
  return rows.map((r, i2) => /* @__PURE__ */ React__default.createElement("tr", { key: `${endDate.month()}_${i2}` }, r));
6789
6795
  }
6790
6796
  renderDay(date, startOfMonth, endOfMonth) {
6791
- let selectedDate = this.props.selectedDate;
6792
- let dayProps = {
6797
+ const selectedDate = this.props.selectedDate;
6798
+ const dayProps = {
6793
6799
  key: date.format("M_D"),
6794
6800
  "data-value": date.date(),
6795
6801
  "data-month": date.month(),
@@ -6843,7 +6849,7 @@ function getRow$2(rows, day) {
6843
6849
  }
6844
6850
  function getDaysOfWeek(locale) {
6845
6851
  const first = locale.firstDayOfWeek();
6846
- let dow = [];
6852
+ const dow = [];
6847
6853
  let i = 0;
6848
6854
  locale._weekdaysMin.forEach(function(day) {
6849
6855
  dow[(7 + i++ - first) % 7] = day;
@@ -6861,7 +6867,7 @@ class MonthsView extends React__default.Component {
6861
6867
  return /* @__PURE__ */ React__default.createElement("div", { className: "rdtMonths" }, /* @__PURE__ */ React__default.createElement("table", null, /* @__PURE__ */ React__default.createElement("thead", null, this.renderNavigation())), /* @__PURE__ */ React__default.createElement("table", null, /* @__PURE__ */ React__default.createElement("tbody", null, this.renderMonths())));
6862
6868
  }
6863
6869
  renderNavigation() {
6864
- let year = this.props.viewDate.year();
6870
+ const year = this.props.viewDate.year();
6865
6871
  return /* @__PURE__ */ React__default.createElement(
6866
6872
  ViewNavigation,
6867
6873
  {
@@ -6874,9 +6880,9 @@ class MonthsView extends React__default.Component {
6874
6880
  );
6875
6881
  }
6876
6882
  renderMonths() {
6877
- let rows = [[], [], []];
6883
+ const rows = [[], [], []];
6878
6884
  for (let month = 0; month < 12; month++) {
6879
- let row = getRow$1(rows, month);
6885
+ const row = getRow$1(rows, month);
6880
6886
  row.push(this.renderMonth(month));
6881
6887
  }
6882
6888
  return rows.map((months, i) => /* @__PURE__ */ React__default.createElement("tr", { key: i }, months));
@@ -6893,7 +6899,7 @@ class MonthsView extends React__default.Component {
6893
6899
  if (selectedDate && selectedDate.year() === this.props.viewDate.year() && selectedDate.month() === month) {
6894
6900
  className += " rdtActive";
6895
6901
  }
6896
- let props = { key: month, className, "data-value": month, onClick };
6902
+ const props = { key: month, className, "data-value": month, onClick };
6897
6903
  if (this.props.renderMonth) {
6898
6904
  return this.props.renderMonth(
6899
6905
  props,
@@ -6905,11 +6911,11 @@ class MonthsView extends React__default.Component {
6905
6911
  return /* @__PURE__ */ React__default.createElement("td", { ...props }, this.getMonthText(month));
6906
6912
  }
6907
6913
  isDisabledMonth(month) {
6908
- let isValidDate = this.props.isValidDate;
6914
+ const isValidDate = this.props.isValidDate;
6909
6915
  if (!isValidDate) {
6910
6916
  return false;
6911
6917
  }
6912
- let date = this.props.viewDate.clone().set({ month });
6918
+ const date = this.props.viewDate.clone().set({ month });
6913
6919
  let day = date.endOf("month").date() + 1;
6914
6920
  while (day-- > 1) {
6915
6921
  if (isValidDate(date.date(day))) {
@@ -6961,9 +6967,9 @@ class YearsView extends React__default.Component {
6961
6967
  }
6962
6968
  renderYears() {
6963
6969
  const viewYear = this.getViewYear();
6964
- let rows = [[], [], []];
6970
+ const rows = [[], [], []];
6965
6971
  for (let year = viewYear - 1; year < viewYear + 11; year++) {
6966
- let row = getRow(rows, year - viewYear);
6972
+ const row = getRow(rows, year - viewYear);
6967
6973
  row.push(this.renderYear(year));
6968
6974
  }
6969
6975
  return rows.map((years, i) => /* @__PURE__ */ React__default.createElement("tr", { key: i }, years));
@@ -6980,7 +6986,7 @@ class YearsView extends React__default.Component {
6980
6986
  if (selectedYear === year) {
6981
6987
  className += " rdtActive";
6982
6988
  }
6983
- let props = { key: year, className, "data-value": year, onClick };
6989
+ const props = { key: year, className, "data-value": year, onClick };
6984
6990
  return this.props.renderYear(
6985
6991
  props,
6986
6992
  year,
@@ -6994,15 +7000,15 @@ class YearsView extends React__default.Component {
6994
7000
  return this.props.selectedDate && this.props.selectedDate.year();
6995
7001
  }
6996
7002
  isDisabledYear(year) {
6997
- let cache = this.disabledYearsCache;
7003
+ const cache = this.disabledYearsCache;
6998
7004
  if (cache[year] !== void 0) {
6999
7005
  return cache[year];
7000
7006
  }
7001
- let isValidDate = this.props.isValidDate;
7007
+ const isValidDate = this.props.isValidDate;
7002
7008
  if (!isValidDate) {
7003
7009
  return false;
7004
7010
  }
7005
- let date = this.props.viewDate.clone().set({ year });
7011
+ const date = this.props.viewDate.clone().set({ year });
7006
7012
  let day = date.endOf("year").dayOfYear() + 1;
7007
7013
  while (day-- > 1) {
7008
7014
  if (isValidDate(date.dayOfYear(day))) {
@@ -7049,7 +7055,7 @@ const timeConstraints = {
7049
7055
  }
7050
7056
  };
7051
7057
  function createConstraints(overrideTimeConstraints) {
7052
- let constraints = {};
7058
+ const constraints = {};
7053
7059
  Object.keys(timeConstraints).forEach((type) => {
7054
7060
  constraints[type] = {
7055
7061
  ...timeConstraints[type],
@@ -7065,7 +7071,7 @@ class TimeView extends React__default.Component {
7065
7071
  this.state = this.getTimeParts(props.selectedDate || props.viewDate);
7066
7072
  }
7067
7073
  render() {
7068
- let items2 = [];
7074
+ const items2 = [];
7069
7075
  const timeParts = this.state;
7070
7076
  this.getCounters().forEach((c, i) => {
7071
7077
  if (i && c !== "ampm") {
@@ -7127,8 +7133,8 @@ class TimeView extends React__default.Component {
7127
7133
  }
7128
7134
  if (type === "ampm")
7129
7135
  return this.toggleDayPart();
7130
- let update = {};
7131
- let body = document.body;
7136
+ const update = {};
7137
+ const body = document.body;
7132
7138
  update[type] = this[action](type);
7133
7139
  this.setState(update);
7134
7140
  this.timer = setTimeout(() => {
@@ -7171,8 +7177,8 @@ class TimeView extends React__default.Component {
7171
7177
  return pad(type, value);
7172
7178
  }
7173
7179
  getCounters() {
7174
- let counters = [];
7175
- let format2 = this.props.timeFormat;
7180
+ const counters = [];
7181
+ const format2 = this.props.timeFormat;
7176
7182
  if (format2.toLowerCase().indexOf("h") !== -1) {
7177
7183
  counters.push("hours");
7178
7184
  if (format2.indexOf("m") !== -1) {
@@ -7304,7 +7310,7 @@ class Datetime extends React__default.Component {
7304
7310
  __publicField(this, "_renderCalendar", () => {
7305
7311
  const props = this.props;
7306
7312
  const state = this.state;
7307
- let viewProps = {
7313
+ const viewProps = {
7308
7314
  viewDate: state.viewDate.clone(),
7309
7315
  selectedDate: this.getSelectedDate(),
7310
7316
  isValidDate: props.isValidDate,
@@ -7347,10 +7353,10 @@ class Datetime extends React__default.Component {
7347
7353
  __publicField(this, "viewToMethod", { days: "date", months: "month", years: "year" });
7348
7354
  __publicField(this, "nextView", { days: "time", months: "days", years: "months" });
7349
7355
  __publicField(this, "_updateDate", (e) => {
7350
- let state = this.state;
7351
- let currentView = state.currentView;
7352
- let updateOnView = this.getUpdateOn(this.getFormat("date"));
7353
- let viewDate = this.state.viewDate.clone();
7356
+ const state = this.state;
7357
+ const currentView = state.currentView;
7358
+ const updateOnView = this.getUpdateOn(this.getFormat("date"));
7359
+ const viewDate = this.state.viewDate.clone();
7354
7360
  viewDate[this.viewToMethod[currentView]](
7355
7361
  parseInt(e.target.getAttribute("data-value"), 10)
7356
7362
  );
@@ -7358,7 +7364,7 @@ class Datetime extends React__default.Component {
7358
7364
  viewDate.month(parseInt(e.target.getAttribute("data-month"), 10));
7359
7365
  viewDate.year(parseInt(e.target.getAttribute("data-year"), 10));
7360
7366
  }
7361
- let update = { viewDate };
7367
+ const update = { viewDate };
7362
7368
  if (currentView === updateOnView) {
7363
7369
  update.selectedDate = viewDate.clone();
7364
7370
  update.inputValue = viewDate.format(this.getFormat("datetime"));
@@ -7372,7 +7378,7 @@ class Datetime extends React__default.Component {
7372
7378
  this.setState(update);
7373
7379
  });
7374
7380
  __publicField(this, "_viewNavigate", (modifier, unit) => {
7375
- let viewDate = this.state.viewDate.clone();
7381
+ const viewDate = this.state.viewDate.clone();
7376
7382
  viewDate.add(modifier, unit);
7377
7383
  if (modifier > 0) {
7378
7384
  this.props.onNavigateForward(modifier, unit);
@@ -7382,7 +7388,7 @@ class Datetime extends React__default.Component {
7382
7388
  this.setState({ viewDate });
7383
7389
  });
7384
7390
  __publicField(this, "_setTime", (type, value) => {
7385
- let date = (this.getSelectedDate() || this.state.viewDate).clone();
7391
+ const date = (this.getSelectedDate() || this.state.viewDate).clone();
7386
7392
  date[type](value);
7387
7393
  if (!this.props.value) {
7388
7394
  this.setState({
@@ -7406,7 +7412,7 @@ class Datetime extends React__default.Component {
7406
7412
  });
7407
7413
  });
7408
7414
  __publicField(this, "_handleClickOutside", () => {
7409
- let props = this.props;
7415
+ const props = this.props;
7410
7416
  if (props.input && this.state.open && props.open === void 0 && props.closeOnClickOutside) {
7411
7417
  this._closeCalendar();
7412
7418
  }
@@ -7421,7 +7427,7 @@ class Datetime extends React__default.Component {
7421
7427
  return;
7422
7428
  const value = e.target ? e.target.value : e;
7423
7429
  const localMoment = this.localMoment(value, this.getFormat("datetime"));
7424
- let update = { inputValue: value };
7430
+ const update = { inputValue: value };
7425
7431
  if (localMoment.isValid()) {
7426
7432
  update.selectedDate = localMoment;
7427
7433
  update.viewDate = localMoment.clone().startOf("month");
@@ -7485,9 +7491,9 @@ class Datetime extends React__default.Component {
7485
7491
  return this.props.renderView(this.state.currentView, this._renderCalendar);
7486
7492
  }
7487
7493
  getInitialState() {
7488
- let props = this.props;
7489
- let inputFormat = this.getFormat("datetime");
7490
- let selectedDate = this.parseDate(
7494
+ const props = this.props;
7495
+ const inputFormat = this.getFormat("datetime");
7496
+ const selectedDate = this.parseDate(
7491
7497
  props.value || props.initialValue,
7492
7498
  inputFormat
7493
7499
  );
@@ -7518,7 +7524,7 @@ class Datetime extends React__default.Component {
7518
7524
  return this.getInitialDate();
7519
7525
  }
7520
7526
  getInitialDate() {
7521
- let m = this.localMoment();
7527
+ const m = this.localMoment();
7522
7528
  m.hour(0).minute(0).second(0).millisecond(0);
7523
7529
  return m;
7524
7530
  }
@@ -7538,8 +7544,8 @@ class Datetime extends React__default.Component {
7538
7544
  }
7539
7545
  getClassName() {
7540
7546
  let cn2 = "rdt";
7541
- let props = this.props;
7542
- let propCn = props.className;
7547
+ const props = this.props;
7548
+ const propCn = props.className;
7543
7549
  if (Array.isArray(propCn)) {
7544
7550
  cn2 += " " + propCn.join(" ");
7545
7551
  } else if (propCn) {
@@ -7572,14 +7578,14 @@ class Datetime extends React__default.Component {
7572
7578
  return viewModes.DAYS;
7573
7579
  }
7574
7580
  getLocaleData() {
7575
- let p = this.props;
7581
+ const p = this.props;
7576
7582
  return this.localMoment(
7577
7583
  p.value || p.defaultValue || /* @__PURE__ */ new Date()
7578
7584
  ).localeData();
7579
7585
  }
7580
7586
  getDateFormat() {
7581
7587
  const locale = this.getLocaleData();
7582
- let format2 = this.props.dateFormat;
7588
+ const format2 = this.props.dateFormat;
7583
7589
  if (format2 === true)
7584
7590
  return locale.longDateFormat("L");
7585
7591
  if (format2)
@@ -7588,7 +7594,7 @@ class Datetime extends React__default.Component {
7588
7594
  }
7589
7595
  getTimeFormat() {
7590
7596
  const locale = this.getLocaleData();
7591
- let format2 = this.props.timeFormat;
7597
+ const format2 = this.props.timeFormat;
7592
7598
  if (format2 === true) {
7593
7599
  return locale.longDateFormat("LT");
7594
7600
  }
@@ -7600,12 +7606,12 @@ class Datetime extends React__default.Component {
7600
7606
  } else if (type === "time") {
7601
7607
  return this.getTimeFormat();
7602
7608
  }
7603
- let dateFormat = this.getDateFormat();
7604
- let timeFormat = this.getTimeFormat();
7609
+ const dateFormat = this.getDateFormat();
7610
+ const timeFormat = this.getTimeFormat();
7605
7611
  return dateFormat && timeFormat ? dateFormat + " " + timeFormat : dateFormat || timeFormat;
7606
7612
  }
7607
7613
  updateTime(op, amount, type, toSelected) {
7608
- let update = {};
7614
+ const update = {};
7609
7615
  const date = toSelected ? "selectedDate" : "viewDate";
7610
7616
  update[date] = this.state[date].clone()[op](amount, type);
7611
7617
  this.setState(update);
@@ -7638,7 +7644,7 @@ class Datetime extends React__default.Component {
7638
7644
  if (prevProps === this.props)
7639
7645
  return;
7640
7646
  let needsUpdate = false;
7641
- let thisProps = this.props;
7647
+ const thisProps = this.props;
7642
7648
  ["locale", "utc", "displayZone", "dateFormat", "timeFormat"].forEach(
7643
7649
  function(p) {
7644
7650
  prevProps[p] !== thisProps[p] && (needsUpdate = true);
@@ -7654,8 +7660,8 @@ class Datetime extends React__default.Component {
7654
7660
  }
7655
7661
  regenerateDates() {
7656
7662
  const props = this.props;
7657
- let viewDate = this.state.viewDate.clone();
7658
- let selectedDate = this.state.selectedDate && this.state.selectedDate.clone();
7663
+ const viewDate = this.state.viewDate.clone();
7664
+ const selectedDate = this.state.selectedDate && this.state.selectedDate.clone();
7659
7665
  if (props.locale) {
7660
7666
  viewDate.locale(props.locale);
7661
7667
  selectedDate && selectedDate.locale(props.locale);
@@ -7670,7 +7676,7 @@ class Datetime extends React__default.Component {
7670
7676
  viewDate.locale();
7671
7677
  selectedDate && selectedDate.locale();
7672
7678
  }
7673
- let update = { viewDate, selectedDate };
7679
+ const update = { viewDate, selectedDate };
7674
7680
  if (selectedDate && selectedDate.isValid()) {
7675
7681
  update.inputValue = selectedDate.format(this.getFormat("datetime"));
7676
7682
  }
@@ -7679,7 +7685,7 @@ class Datetime extends React__default.Component {
7679
7685
  getSelectedDate() {
7680
7686
  if (this.props.value === void 0)
7681
7687
  return this.state.selectedDate;
7682
- let selectedDate = this.parseDate(
7688
+ const selectedDate = this.parseDate(
7683
7689
  this.props.value,
7684
7690
  this.getFormat("datetime")
7685
7691
  );
@@ -7698,7 +7704,7 @@ class Datetime extends React__default.Component {
7698
7704
  return "";
7699
7705
  }
7700
7706
  getInputValue() {
7701
- let selectedDate = this.getSelectedDate();
7707
+ const selectedDate = this.getSelectedDate();
7702
7708
  return selectedDate ? selectedDate.format(this.getFormat("datetime")) : this.state.inputValue;
7703
7709
  }
7704
7710
  /**
@@ -7708,7 +7714,7 @@ class Datetime extends React__default.Component {
7708
7714
  * @public
7709
7715
  */
7710
7716
  setViewDate(date) {
7711
- let logError = function() {
7717
+ const logError = function() {
7712
7718
  return log("Invalid date passed to the `setViewDate` method: " + date);
7713
7719
  };
7714
7720
  if (!date)
@@ -7804,7 +7810,7 @@ __publicField(Datetime, "defaultProps", {
7804
7810
  // Make moment accessible through the Datetime class
7805
7811
  __publicField(Datetime, "moment", moment);
7806
7812
  function log(message, method) {
7807
- let con = typeof window !== "undefined" && window.console;
7813
+ const con = typeof window !== "undefined" && window.console;
7808
7814
  if (!con)
7809
7815
  return;
7810
7816
  if (!method) {
@@ -8627,7 +8633,10 @@ const BranchSelector = ({
8627
8633
  label: "View in GitHub",
8628
8634
  Icon: /* @__PURE__ */ React.createElement(BiLinkExternal, { className: "w-5 h-auto text-blue-500 opacity-70" }),
8629
8635
  onMouseDown: () => {
8630
- window.open(branch.githubPullRequestUrl, "_blank");
8636
+ window.open(
8637
+ branch.githubPullRequestUrl,
8638
+ "_blank"
8639
+ );
8631
8640
  }
8632
8641
  },
8633
8642
  typeof previewFunction === "function" && ((_b2 = previewFunction({ branch: branch.name })) == null ? void 0 : _b2.url) && {
@@ -8933,7 +8942,9 @@ class EventBus {
8933
8942
  } else {
8934
8943
  events = event;
8935
8944
  }
8936
- const newListeners = events.map((event2) => new Listener(event2, callback));
8945
+ const newListeners = events.map(
8946
+ (event2) => new Listener(event2, callback)
8947
+ );
8937
8948
  newListeners.forEach((newListener) => this.listeners.add(newListener));
8938
8949
  return () => {
8939
8950
  newListeners.forEach((listener) => this.listeners.delete(listener));
@@ -9289,9 +9300,7 @@ class TinaMediaStore {
9289
9300
  const deleteStartTime = Date.now();
9290
9301
  while (true) {
9291
9302
  await new Promise((resolve) => setTimeout(resolve, 1e3));
9292
- const { error, message } = await this.api.getRequestStatus(
9293
- requestId
9294
- );
9303
+ const { error, message } = await this.api.getRequestStatus(requestId);
9295
9304
  if (error !== void 0) {
9296
9305
  if (error) {
9297
9306
  throw new Error(message);
@@ -9626,7 +9635,7 @@ let Alerts$1 = class Alerts {
9626
9635
  return this.add("error", message, timeout);
9627
9636
  }
9628
9637
  };
9629
- const NoFormsPlaceholder = () => /* @__PURE__ */ React.createElement(
9638
+ const SidebarLoadingPlaceholder = () => /* @__PURE__ */ React.createElement(
9630
9639
  "div",
9631
9640
  {
9632
9641
  className: "relative flex flex-col items-center justify-center text-center p-5 pb-16 w-full h-full overflow-y-auto",
@@ -9639,25 +9648,8 @@ const NoFormsPlaceholder = () => /* @__PURE__ */ React.createElement(
9639
9648
  animationDuration: "150ms"
9640
9649
  }
9641
9650
  },
9642
- /* @__PURE__ */ React.createElement(Emoji$1, { className: "pb-5" }, "🔎"),
9643
- /* @__PURE__ */ React.createElement("p", { className: "block pb-5" }, "Looks like there's ", /* @__PURE__ */ React.createElement("br", null), "nothing to edit on ", /* @__PURE__ */ React.createElement("br", null), "this page."),
9644
- /* @__PURE__ */ React.createElement("p", { className: "block" }, /* @__PURE__ */ React.createElement(
9645
- Button$1,
9646
- {
9647
- href: "https://tina.io/docs/tinacms-context/",
9648
- target: "_blank",
9649
- as: "a"
9650
- },
9651
- /* @__PURE__ */ React.createElement(Emoji$1, { className: "mr-1.5" }, "📖"),
9652
- " Contextual Editing"
9653
- ))
9654
- );
9655
- const Emoji$1 = ({ className = "", ...props }) => /* @__PURE__ */ React.createElement(
9656
- "span",
9657
- {
9658
- className: `text-[24px] leading-none inline-block ${className}`,
9659
- ...props
9660
- }
9651
+ /* @__PURE__ */ React.createElement("p", { className: "block pb-5" }, "Please wait while TinaCMS", /* @__PURE__ */ React.createElement("br", null), "loads your content"),
9652
+ /* @__PURE__ */ React.createElement(LoadingDots, { color: "var(--tina-color-primary)" })
9661
9653
  );
9662
9654
  class SidebarState {
9663
9655
  constructor(events, options = {}) {
@@ -9672,7 +9664,7 @@ class SidebarState {
9672
9664
  };
9673
9665
  this.position = options.position || "displace";
9674
9666
  this.renderNav = options.renderNav || true;
9675
- this.placeholder = options.placeholder || NoFormsPlaceholder;
9667
+ this.loadingPlaceholder = options.placeholder || SidebarLoadingPlaceholder;
9676
9668
  if ((_a = options.buttons) == null ? void 0 : _a.save) {
9677
9669
  this.buttons.save = options.buttons.save;
9678
9670
  }
@@ -9746,238 +9738,6 @@ const ModalLayout = ({ children, name, close: close2, layout }) => {
9746
9738
  children
9747
9739
  )));
9748
9740
  };
9749
- const Item = ({
9750
- item,
9751
- depth,
9752
- setActiveFormId
9753
- }) => {
9754
- const cms = useCMS();
9755
- const depths = ["pl-6", "pl-10", "pl-14"];
9756
- const form = React.useMemo(
9757
- () => cms.state.forms.find(({ tinaForm }) => item.formId === tinaForm.id),
9758
- [item.formId]
9759
- );
9760
- return /* @__PURE__ */ React.createElement(
9761
- "button",
9762
- {
9763
- type: "button",
9764
- key: item.path,
9765
- onClick: () => setActiveFormId(item.formId),
9766
- className: `${depths[depth] || "pl-12"} pr-6 py-3 w-full h-full bg-transparent border-none text-lg text-gray-700 group hover:bg-gray-50 transition-all ease-out duration-150 flex items-center justify-between gap-2`
9767
- },
9768
- /* @__PURE__ */ React.createElement(BiEdit, { className: "opacity-70 w-5 h-auto text-blue-500 flex-none" }),
9769
- /* @__PURE__ */ React.createElement("div", { className: "flex-1 flex flex-col gap-0.5 items-start" }, /* @__PURE__ */ React.createElement("div", { className: "group-hover:text-blue-500 font-sans text-xs font-semibold text-gray-700 whitespace-normal" }, form.tinaForm.label), /* @__PURE__ */ React.createElement("div", { className: "group-hover:text-blue-500 text-base truncate leading-tight text-gray-600" }, form.tinaForm.id))
9770
- );
9771
- };
9772
- const FormListItem = ({
9773
- item,
9774
- depth,
9775
- setActiveFormId
9776
- }) => {
9777
- var _a;
9778
- return /* @__PURE__ */ React.createElement("div", { className: "divide-y divide-gray-200" }, /* @__PURE__ */ React.createElement(Item, { setActiveFormId, item, depth }), item.subItems && /* @__PURE__ */ React.createElement("ul", { className: "divide-y divide-gray-200" }, (_a = item.subItems) == null ? void 0 : _a.map((subItem) => {
9779
- if (subItem.type === "document") {
9780
- return /* @__PURE__ */ React.createElement("li", { key: subItem.formId }, /* @__PURE__ */ React.createElement(
9781
- Item,
9782
- {
9783
- setActiveFormId,
9784
- depth: depth + 1,
9785
- item: subItem
9786
- }
9787
- ));
9788
- }
9789
- })));
9790
- };
9791
- const FormLists = (props) => {
9792
- const cms = useCMS();
9793
- return /* @__PURE__ */ React.createElement(
9794
- Transition,
9795
- {
9796
- appear: true,
9797
- show: true,
9798
- as: "div",
9799
- enter: "transition-all ease-out duration-150",
9800
- enterFrom: "opacity-0 -translate-x-1/2",
9801
- enterTo: "opacity-100",
9802
- leave: "transition-all ease-out duration-150",
9803
- leaveFrom: "opacity-100",
9804
- leaveTo: "opacity-0 -translate-x-1/2"
9805
- },
9806
- cms.state.formLists.map((formList, index) => /* @__PURE__ */ React.createElement("div", { key: `${formList.id}-${index}`, className: "pt-16" }, /* @__PURE__ */ React.createElement(
9807
- FormList,
9808
- {
9809
- isEditing: props.isEditing,
9810
- setActiveFormId: (id) => {
9811
- cms.dispatch({ type: "forms:set-active-form-id", value: id });
9812
- },
9813
- formList
9814
- }
9815
- )))
9816
- );
9817
- };
9818
- const FormList = (props) => {
9819
- const cms = useCMS();
9820
- const listItems = React.useMemo(() => {
9821
- var _a;
9822
- const orderedListItems = [];
9823
- const globalItems = [];
9824
- const topItems = [];
9825
- props.formList.items.forEach((item) => {
9826
- if (item.type === "document") {
9827
- const form = cms.state.forms.find(
9828
- ({ tinaForm }) => tinaForm.id === item.formId
9829
- );
9830
- if (form.tinaForm.global) {
9831
- globalItems.push(item);
9832
- } else {
9833
- orderedListItems.push(item);
9834
- }
9835
- } else {
9836
- orderedListItems.push(item);
9837
- }
9838
- });
9839
- if (((_a = orderedListItems[0]) == null ? void 0 : _a.type) === "document") {
9840
- topItems.push({ type: "list", label: "Documents" });
9841
- }
9842
- let extra = [];
9843
- if (globalItems.length) {
9844
- extra = [{ type: "list", label: "Global Documents" }, ...globalItems];
9845
- }
9846
- return [...topItems, ...orderedListItems, ...extra];
9847
- }, [JSON.stringify(props.formList.items)]);
9848
- return /* @__PURE__ */ React.createElement("ul", null, /* @__PURE__ */ React.createElement("li", { className: "divide-y divide-gray-200" }, listItems.map((item, index) => {
9849
- if (item.type === "list") {
9850
- return /* @__PURE__ */ React.createElement(
9851
- "div",
9852
- {
9853
- key: item.label,
9854
- className: `relative group text-left w-full bg-white shadow-sm
9855
- border-gray-100 px-6 -mt-px pb-3 ${index > 0 ? "pt-6 bg-gradient-to-b from-gray-50 via-white to-white" : "pt-3"}`
9856
- },
9857
- /* @__PURE__ */ React.createElement(
9858
- "span",
9859
- {
9860
- className: "text-sm tracking-wide font-bold text-gray-700 uppercase"
9861
- },
9862
- item.label
9863
- )
9864
- );
9865
- }
9866
- return /* @__PURE__ */ React.createElement(
9867
- FormListItem,
9868
- {
9869
- setActiveFormId: (id) => props.setActiveFormId(id),
9870
- key: item.formId,
9871
- item,
9872
- depth: 0
9873
- }
9874
- );
9875
- })));
9876
- };
9877
- const FormsView = ({
9878
- children
9879
- }) => {
9880
- const cms = useCMS$1();
9881
- const { setFormIsPristine } = React.useContext(SidebarContext);
9882
- const isMultiform = cms.state.forms.length > 1;
9883
- const activeForm = cms.state.forms.find(
9884
- ({ tinaForm }) => tinaForm.id === cms.state.activeFormId
9885
- );
9886
- const isEditing = !!activeForm;
9887
- if (!cms.state.formLists.length) {
9888
- return /* @__PURE__ */ React.createElement(React.Fragment, null, " ", children, " ");
9889
- }
9890
- if (isMultiform && !activeForm) {
9891
- return /* @__PURE__ */ React.createElement(FormLists, { isEditing });
9892
- }
9893
- const formMetas = cms.plugins.all("form:meta");
9894
- return /* @__PURE__ */ React.createElement(React.Fragment, null, activeForm && /* @__PURE__ */ React.createElement(FormWrapper$1, { isEditing, isMultiform }, isMultiform && /* @__PURE__ */ React.createElement(MultiformFormHeader, { activeForm }), !isMultiform && /* @__PURE__ */ React.createElement(FormHeader, { activeForm }), formMetas == null ? void 0 : formMetas.map((meta) => /* @__PURE__ */ React.createElement(React.Fragment, { key: meta.name }, /* @__PURE__ */ React.createElement(meta.Component, null))), /* @__PURE__ */ React.createElement(FormBuilder, { form: activeForm, onPristineChange: setFormIsPristine })));
9895
- };
9896
- const FormWrapper$1 = ({ isEditing, children }) => {
9897
- return /* @__PURE__ */ React.createElement(
9898
- "div",
9899
- {
9900
- className: "flex-1 flex flex-col flex-nowrap overflow-hidden h-full w-full relative bg-white",
9901
- style: isEditing ? {
9902
- transform: "none",
9903
- animationName: "fly-in-left",
9904
- animationDuration: "150ms",
9905
- animationDelay: "0",
9906
- animationIterationCount: 1,
9907
- animationTimingFunction: "ease-out"
9908
- } : {
9909
- transform: "translate3d(100%, 0, 0)"
9910
- }
9911
- },
9912
- children
9913
- );
9914
- };
9915
- const MultiformFormHeader = ({
9916
- activeForm
9917
- }) => {
9918
- const cms = useCMS$1();
9919
- const { formIsPristine } = React.useContext(SidebarContext);
9920
- return /* @__PURE__ */ React.createElement(
9921
- "div",
9922
- {
9923
- className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
9924
- },
9925
- /* @__PURE__ */ React.createElement("div", { className: "max-w-form mx-auto flex gap-2 justify-between items-center" }, /* @__PURE__ */ React.createElement(
9926
- "button",
9927
- {
9928
- type: "button",
9929
- className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
9930
- onClick: () => {
9931
- const state = activeForm.tinaForm.finalForm.getState();
9932
- if (state.invalid === true) {
9933
- cms.alerts.error("Cannot navigate away from an invalid form.");
9934
- } else {
9935
- cms.dispatch({ type: "forms:set-active-form-id", value: null });
9936
- }
9937
- }
9938
- },
9939
- /* @__PURE__ */ React.createElement(BiDotsVertical, { className: "h-auto w-5 inline-block opacity-70" })
9940
- ), /* @__PURE__ */ React.createElement(
9941
- "button",
9942
- {
9943
- type: "button",
9944
- className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
9945
- onClick: () => {
9946
- const collectionName = cms.api.tina.schema.getCollectionByFullPath(
9947
- cms.state.activeFormId
9948
- ).name;
9949
- window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
9950
- }
9951
- },
9952
- /* @__PURE__ */ React.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
9953
- ), /* @__PURE__ */ React.createElement("span", { className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0" }, "/"), /* @__PURE__ */ React.createElement("span", { className: "block w-full text-sm leading-tight whitespace-nowrap truncate" }, activeForm.tinaForm.label || activeForm.tinaForm.id), /* @__PURE__ */ React.createElement(FormStatus, { pristine: formIsPristine }))
9954
- );
9955
- };
9956
- const FormHeader = ({ activeForm }) => {
9957
- const { formIsPristine } = React.useContext(SidebarContext);
9958
- const cms = useCMS$1();
9959
- const shortFormLabel = activeForm.tinaForm.label ? activeForm.tinaForm.label.replace(/^.*[\\\/]/, "") : false;
9960
- return /* @__PURE__ */ React.createElement(
9961
- "div",
9962
- {
9963
- className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
9964
- },
9965
- /* @__PURE__ */ React.createElement("div", { className: "max-w-form mx-auto flex gap-2 justify-between items-center" }, /* @__PURE__ */ React.createElement(
9966
- "button",
9967
- {
9968
- type: "button",
9969
- className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
9970
- onClick: () => {
9971
- const collectionName = cms.api.tina.schema.getCollectionByFullPath(
9972
- cms.state.activeFormId
9973
- ).name;
9974
- window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
9975
- }
9976
- },
9977
- /* @__PURE__ */ React.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
9978
- ), shortFormLabel && /* @__PURE__ */ React.createElement("span", { className: "block w-full text-sm leading-tight whitespace-nowrap truncate" }, shortFormLabel), /* @__PURE__ */ React.createElement(FormStatus, { pristine: formIsPristine }))
9979
- );
9980
- };
9981
9741
  function ImFilesEmpty(props) {
9982
9742
  return GenIcon({ "tag": "svg", "attr": { "version": "1.1", "viewBox": "0 0 16 16" }, "child": [{ "tag": "path", "attr": { "d": "M14.341 5.579c-0.347-0.473-0.831-1.027-1.362-1.558s-1.085-1.015-1.558-1.362c-0.806-0.591-1.197-0.659-1.421-0.659h-5.75c-0.689 0-1.25 0.561-1.25 1.25v11.5c0 0.689 0.561 1.25 1.25 1.25h9.5c0.689 0 1.25-0.561 1.25-1.25v-7.75c0-0.224-0.068-0.615-0.659-1.421zM12.271 4.729c0.48 0.48 0.856 0.912 1.134 1.271h-2.406v-2.405c0.359 0.278 0.792 0.654 1.271 1.134v0zM14 14.75c0 0.136-0.114 0.25-0.25 0.25h-9.5c-0.136 0-0.25-0.114-0.25-0.25v-11.5c0-0.135 0.114-0.25 0.25-0.25 0 0 5.749-0 5.75 0v3.5c0 0.276 0.224 0.5 0.5 0.5h3.5v7.75z" }, "child": [] }, { "tag": "path", "attr": { "d": "M9.421 0.659c-0.806-0.591-1.197-0.659-1.421-0.659h-5.75c-0.689 0-1.25 0.561-1.25 1.25v11.5c0 0.604 0.43 1.109 1 1.225v-12.725c0-0.135 0.115-0.25 0.25-0.25h7.607c-0.151-0.124-0.297-0.238-0.437-0.341z" }, "child": [] }] })(props);
9983
9743
  }
@@ -10220,7 +9980,7 @@ const SyncStatus = ({ cms, setEventsOpen }) => {
10220
9980
  "Event Log"
10221
9981
  ));
10222
9982
  };
10223
- const version = "2.7.2";
9983
+ const version = "2.7.4";
10224
9984
  const Nav = ({
10225
9985
  isLocalMode,
10226
9986
  className = "",
@@ -10462,6 +10222,293 @@ const ResizeHandle = () => {
10462
10222
  /* @__PURE__ */ React.createElement("span", { className: "absolute top-1/2 left-1/2 h-4/6 w-px bg-gray-200 transform -translate-y-1/2 -translate-x-1/2 opacity-30 transition-opacity duration-150 ease-out group-hover:opacity-100" })
10463
10223
  );
10464
10224
  };
10225
+ const Item = ({
10226
+ item,
10227
+ depth,
10228
+ setActiveFormId
10229
+ }) => {
10230
+ const cms = useCMS();
10231
+ const depths = ["pl-6", "pl-10", "pl-14"];
10232
+ const form = React.useMemo(
10233
+ () => cms.state.forms.find(({ tinaForm }) => item.formId === tinaForm.id),
10234
+ [item.formId]
10235
+ );
10236
+ return /* @__PURE__ */ React.createElement(
10237
+ "button",
10238
+ {
10239
+ type: "button",
10240
+ key: item.path,
10241
+ onClick: () => setActiveFormId(item.formId),
10242
+ className: `${depths[depth] || "pl-12"} pr-6 py-3 w-full h-full bg-transparent border-none text-lg text-gray-700 group hover:bg-gray-50 transition-all ease-out duration-150 flex items-center justify-between gap-2`
10243
+ },
10244
+ /* @__PURE__ */ React.createElement(BiEdit, { className: "opacity-70 w-5 h-auto text-blue-500 flex-none" }),
10245
+ /* @__PURE__ */ React.createElement("div", { className: "flex-1 flex flex-col gap-0.5 items-start" }, /* @__PURE__ */ React.createElement("div", { className: "group-hover:text-blue-500 font-sans text-xs font-semibold text-gray-700 whitespace-normal" }, form.tinaForm.label), /* @__PURE__ */ React.createElement("div", { className: "group-hover:text-blue-500 text-base truncate leading-tight text-gray-600" }, form.tinaForm.id))
10246
+ );
10247
+ };
10248
+ const FormListItem = ({
10249
+ item,
10250
+ depth,
10251
+ setActiveFormId
10252
+ }) => {
10253
+ var _a;
10254
+ return /* @__PURE__ */ React.createElement("div", { className: "divide-y divide-gray-200" }, /* @__PURE__ */ React.createElement(Item, { setActiveFormId, item, depth }), item.subItems && /* @__PURE__ */ React.createElement("ul", { className: "divide-y divide-gray-200" }, (_a = item.subItems) == null ? void 0 : _a.map((subItem) => {
10255
+ if (subItem.type === "document") {
10256
+ return /* @__PURE__ */ React.createElement("li", { key: subItem.formId }, /* @__PURE__ */ React.createElement(
10257
+ Item,
10258
+ {
10259
+ setActiveFormId,
10260
+ depth: depth + 1,
10261
+ item: subItem
10262
+ }
10263
+ ));
10264
+ }
10265
+ })));
10266
+ };
10267
+ const FormLists = (props) => {
10268
+ const cms = useCMS();
10269
+ return /* @__PURE__ */ React.createElement(
10270
+ Transition,
10271
+ {
10272
+ appear: true,
10273
+ show: true,
10274
+ as: "div",
10275
+ enter: "transition-all ease-out duration-150",
10276
+ enterFrom: "opacity-0 -translate-x-1/2",
10277
+ enterTo: "opacity-100",
10278
+ leave: "transition-all ease-out duration-150",
10279
+ leaveFrom: "opacity-100",
10280
+ leaveTo: "opacity-0 -translate-x-1/2"
10281
+ },
10282
+ cms.state.formLists.map((formList, index) => /* @__PURE__ */ React.createElement("div", { key: `${formList.id}-${index}`, className: "pt-16" }, /* @__PURE__ */ React.createElement(
10283
+ FormList,
10284
+ {
10285
+ isEditing: props.isEditing,
10286
+ setActiveFormId: (id) => {
10287
+ cms.dispatch({ type: "forms:set-active-form-id", value: id });
10288
+ },
10289
+ formList
10290
+ }
10291
+ )))
10292
+ );
10293
+ };
10294
+ const FormList = (props) => {
10295
+ const cms = useCMS();
10296
+ const listItems = React.useMemo(() => {
10297
+ var _a;
10298
+ const orderedListItems = [];
10299
+ const globalItems = [];
10300
+ const topItems = [];
10301
+ props.formList.items.forEach((item) => {
10302
+ if (item.type === "document") {
10303
+ const form = cms.state.forms.find(
10304
+ ({ tinaForm }) => tinaForm.id === item.formId
10305
+ );
10306
+ if (form.tinaForm.global) {
10307
+ globalItems.push(item);
10308
+ } else {
10309
+ orderedListItems.push(item);
10310
+ }
10311
+ } else {
10312
+ orderedListItems.push(item);
10313
+ }
10314
+ });
10315
+ if (((_a = orderedListItems[0]) == null ? void 0 : _a.type) === "document") {
10316
+ topItems.push({ type: "list", label: "Documents" });
10317
+ }
10318
+ let extra = [];
10319
+ if (globalItems.length) {
10320
+ extra = [{ type: "list", label: "Global Documents" }, ...globalItems];
10321
+ }
10322
+ return [...topItems, ...orderedListItems, ...extra];
10323
+ }, [JSON.stringify(props.formList.items)]);
10324
+ return /* @__PURE__ */ React.createElement("ul", null, /* @__PURE__ */ React.createElement("li", { className: "divide-y divide-gray-200" }, listItems.map((item, index) => {
10325
+ if (item.type === "list") {
10326
+ return /* @__PURE__ */ React.createElement(
10327
+ "div",
10328
+ {
10329
+ key: item.label,
10330
+ className: `relative group text-left w-full bg-white shadow-sm
10331
+ border-gray-100 px-6 -mt-px pb-3 ${index > 0 ? "pt-6 bg-gradient-to-b from-gray-50 via-white to-white" : "pt-3"}`
10332
+ },
10333
+ /* @__PURE__ */ React.createElement(
10334
+ "span",
10335
+ {
10336
+ className: "text-sm tracking-wide font-bold text-gray-700 uppercase"
10337
+ },
10338
+ item.label
10339
+ )
10340
+ );
10341
+ }
10342
+ return /* @__PURE__ */ React.createElement(
10343
+ FormListItem,
10344
+ {
10345
+ setActiveFormId: (id) => props.setActiveFormId(id),
10346
+ key: item.formId,
10347
+ item,
10348
+ depth: 0
10349
+ }
10350
+ );
10351
+ })));
10352
+ };
10353
+ const SidebarNoFormsPlaceholder = () => /* @__PURE__ */ React.createElement(
10354
+ "div",
10355
+ {
10356
+ className: "relative flex flex-col items-center justify-center text-center p-5 pb-16 w-full h-full overflow-y-auto",
10357
+ style: {
10358
+ animationName: "fade-in",
10359
+ animationDelay: "300ms",
10360
+ animationTimingFunction: "ease-out",
10361
+ animationIterationCount: 1,
10362
+ animationFillMode: "both",
10363
+ animationDuration: "150ms"
10364
+ }
10365
+ },
10366
+ /* @__PURE__ */ React.createElement("p", { className: "block pb-5" }, "Looks like there's ", /* @__PURE__ */ React.createElement("br", null), "nothing to edit on ", /* @__PURE__ */ React.createElement("br", null), "this page."),
10367
+ /* @__PURE__ */ React.createElement("p", { className: "block pt-5" }, /* @__PURE__ */ React.createElement(
10368
+ Button$1,
10369
+ {
10370
+ href: "https://tina.io/docs/contextual-editing/overview",
10371
+ target: "_blank",
10372
+ as: "a"
10373
+ },
10374
+ /* @__PURE__ */ React.createElement(Emoji$1, { className: "mr-1.5" }, "📖"),
10375
+ " Contextual Editing Docs"
10376
+ ))
10377
+ );
10378
+ const Emoji$1 = ({ className = "", ...props }) => /* @__PURE__ */ React.createElement(
10379
+ "span",
10380
+ {
10381
+ className: `text-[24px] leading-none inline-block ${className}`,
10382
+ ...props
10383
+ }
10384
+ );
10385
+ const minimumTimeToShowLoadingIndicator = 1e3;
10386
+ const FormsView = ({ loadingPlaceholder } = {}) => {
10387
+ const cms = useCMS$1();
10388
+ const { setFormIsPristine } = React.useContext(SidebarContext);
10389
+ const [isShowingLoading, setIsShowingLoading] = React.useState(true);
10390
+ const [initialLoadComplete, setInitialLoadComplete] = React.useState(false);
10391
+ React.useEffect(() => {
10392
+ if (cms.state.isLoadingContent) {
10393
+ setIsShowingLoading(true);
10394
+ const timer = setTimeout(() => {
10395
+ if (!cms.state.isLoadingContent) {
10396
+ setIsShowingLoading(false);
10397
+ setInitialLoadComplete(true);
10398
+ }
10399
+ }, minimumTimeToShowLoadingIndicator);
10400
+ return () => clearTimeout(timer);
10401
+ } else {
10402
+ const timer = setTimeout(() => {
10403
+ setIsShowingLoading(false);
10404
+ setInitialLoadComplete(true);
10405
+ }, minimumTimeToShowLoadingIndicator);
10406
+ return () => clearTimeout(timer);
10407
+ }
10408
+ }, [cms.state.isLoadingContent]);
10409
+ if (isShowingLoading || !initialLoadComplete) {
10410
+ const LoadingPlaceholder = loadingPlaceholder || SidebarLoadingPlaceholder;
10411
+ return /* @__PURE__ */ React.createElement(LoadingPlaceholder, null);
10412
+ }
10413
+ if (!cms.state.formLists.length) {
10414
+ return /* @__PURE__ */ React.createElement(SidebarNoFormsPlaceholder, null);
10415
+ }
10416
+ const isMultiform = cms.state.forms.length > 1;
10417
+ const activeForm = cms.state.forms.find(
10418
+ ({ tinaForm }) => tinaForm.id === cms.state.activeFormId
10419
+ );
10420
+ const isEditing = !!activeForm;
10421
+ if (isMultiform && !activeForm) {
10422
+ return /* @__PURE__ */ React.createElement(FormLists, { isEditing });
10423
+ }
10424
+ const formMetas = cms.plugins.all("form:meta");
10425
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, activeForm && /* @__PURE__ */ React.createElement(FormWrapper$1, { isEditing, isMultiform }, isMultiform && /* @__PURE__ */ React.createElement(MultiformFormHeader, { activeForm }), !isMultiform && /* @__PURE__ */ React.createElement(FormHeader, { activeForm }), formMetas == null ? void 0 : formMetas.map((meta) => /* @__PURE__ */ React.createElement(React.Fragment, { key: meta.name }, /* @__PURE__ */ React.createElement(meta.Component, null))), /* @__PURE__ */ React.createElement(FormBuilder, { form: activeForm, onPristineChange: setFormIsPristine })));
10426
+ };
10427
+ const FormWrapper$1 = ({ isEditing, children }) => {
10428
+ return /* @__PURE__ */ React.createElement(
10429
+ "div",
10430
+ {
10431
+ className: "flex-1 flex flex-col flex-nowrap overflow-hidden h-full w-full relative bg-white",
10432
+ style: isEditing ? {
10433
+ transform: "none",
10434
+ animationName: "fly-in-left",
10435
+ animationDuration: "150ms",
10436
+ animationDelay: "0",
10437
+ animationIterationCount: 1,
10438
+ animationTimingFunction: "ease-out"
10439
+ } : {
10440
+ transform: "translate3d(100%, 0, 0)"
10441
+ }
10442
+ },
10443
+ children
10444
+ );
10445
+ };
10446
+ const MultiformFormHeader = ({
10447
+ activeForm
10448
+ }) => {
10449
+ const cms = useCMS$1();
10450
+ const { formIsPristine } = React.useContext(SidebarContext);
10451
+ return /* @__PURE__ */ React.createElement(
10452
+ "div",
10453
+ {
10454
+ className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
10455
+ },
10456
+ /* @__PURE__ */ React.createElement("div", { className: "max-w-form mx-auto flex gap-2 justify-between items-center" }, /* @__PURE__ */ React.createElement(
10457
+ "button",
10458
+ {
10459
+ type: "button",
10460
+ className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
10461
+ onClick: () => {
10462
+ const state = activeForm.tinaForm.finalForm.getState();
10463
+ if (state.invalid === true) {
10464
+ cms.alerts.error("Cannot navigate away from an invalid form.");
10465
+ } else {
10466
+ cms.dispatch({ type: "forms:set-active-form-id", value: null });
10467
+ }
10468
+ }
10469
+ },
10470
+ /* @__PURE__ */ React.createElement(BiDotsVertical, { className: "h-auto w-5 inline-block opacity-70" })
10471
+ ), /* @__PURE__ */ React.createElement(
10472
+ "button",
10473
+ {
10474
+ type: "button",
10475
+ className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
10476
+ onClick: () => {
10477
+ const collectionName = cms.api.tina.schema.getCollectionByFullPath(
10478
+ cms.state.activeFormId
10479
+ ).name;
10480
+ window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
10481
+ }
10482
+ },
10483
+ /* @__PURE__ */ React.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
10484
+ ), /* @__PURE__ */ React.createElement("span", { className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0" }, "/"), /* @__PURE__ */ React.createElement("span", { className: "block w-full text-sm leading-tight whitespace-nowrap truncate" }, activeForm.tinaForm.label || activeForm.tinaForm.id), /* @__PURE__ */ React.createElement(FormStatus, { pristine: formIsPristine }))
10485
+ );
10486
+ };
10487
+ const FormHeader = ({ activeForm }) => {
10488
+ const { formIsPristine } = React.useContext(SidebarContext);
10489
+ const cms = useCMS$1();
10490
+ const shortFormLabel = activeForm.tinaForm.label ? activeForm.tinaForm.label.replace(/^.*[\\\/]/, "") : false;
10491
+ return /* @__PURE__ */ React.createElement(
10492
+ "div",
10493
+ {
10494
+ className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
10495
+ },
10496
+ /* @__PURE__ */ React.createElement("div", { className: "max-w-form mx-auto flex gap-2 justify-between items-center" }, /* @__PURE__ */ React.createElement(
10497
+ "button",
10498
+ {
10499
+ type: "button",
10500
+ className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
10501
+ onClick: () => {
10502
+ const collectionName = cms.api.tina.schema.getCollectionByFullPath(
10503
+ cms.state.activeFormId
10504
+ ).name;
10505
+ window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
10506
+ }
10507
+ },
10508
+ /* @__PURE__ */ React.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
10509
+ ), shortFormLabel && /* @__PURE__ */ React.createElement("span", { className: "block w-full text-sm leading-tight whitespace-nowrap truncate" }, shortFormLabel), /* @__PURE__ */ React.createElement(FormStatus, { pristine: formIsPristine }))
10510
+ );
10511
+ };
10465
10512
  const SidebarContext = React.createContext(null);
10466
10513
  const minPreviewWidth = 440;
10467
10514
  const minSidebarWidth = 360;
@@ -10680,7 +10727,7 @@ const Sidebar$1 = ({
10680
10727
  isLocalMode: (_d = (_c = cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.isLocalMode,
10681
10728
  branchingEnabled
10682
10729
  }
10683
- ), /* @__PURE__ */ React.createElement(FormsView, null, /* @__PURE__ */ React.createElement(sidebar.placeholder, null)), activeScreen && /* @__PURE__ */ React.createElement(
10730
+ ), /* @__PURE__ */ React.createElement(FormsView, { loadingPlaceholder: sidebar.loadingPlaceholder }), activeScreen && /* @__PURE__ */ React.createElement(
10684
10731
  ScreenPluginModal,
10685
10732
  {
10686
10733
  screen: activeScreen,
@@ -11446,7 +11493,10 @@ function MediaPicker({
11446
11493
  const observer = new IntersectionObserver((entries) => {
11447
11494
  const target = entries[0];
11448
11495
  if (target.isIntersecting && list.nextOffset) {
11449
- setOffsetHistory((offsetHistory2) => [...offsetHistory2, list.nextOffset]);
11496
+ setOffsetHistory((offsetHistory2) => [
11497
+ ...offsetHistory2,
11498
+ list.nextOffset
11499
+ ]);
11450
11500
  }
11451
11501
  });
11452
11502
  if (loaderRef.current) {
@@ -12041,6 +12091,7 @@ const initialState = (cms) => {
12041
12091
  forms: [],
12042
12092
  formLists: [],
12043
12093
  editingMode: "basic",
12094
+ isLoadingContent: false,
12044
12095
  quickEditSupported: false,
12045
12096
  sidebarDisplayState: ((_a = cms == null ? void 0 : cms.sidebar) == null ? void 0 : _a.defaultState) || "open"
12046
12097
  };
@@ -12100,7 +12151,12 @@ function tinaReducer(state, action) {
12100
12151
  }
12101
12152
  });
12102
12153
  }
12103
- return { ...state, activeFormId, formLists: nextFormLists };
12154
+ return {
12155
+ ...state,
12156
+ activeFormId,
12157
+ formLists: nextFormLists,
12158
+ isLoadingContent: false
12159
+ };
12104
12160
  }
12105
12161
  case "form-lists:remove": {
12106
12162
  const nextFormLists = state.formLists.filter(
@@ -12169,6 +12225,9 @@ function tinaReducer(state, action) {
12169
12225
  }
12170
12226
  return { ...state, sidebarDisplayState: action.value };
12171
12227
  }
12228
+ case "sidebar:set-loading-state": {
12229
+ return { ...state, isLoadingContent: action.value };
12230
+ }
12172
12231
  default:
12173
12232
  throw new Error(`Unhandled action ${action.type}`);
12174
12233
  }
@@ -12410,7 +12469,9 @@ const ActiveFieldIndicator = () => {
12410
12469
  if (activeEle) {
12411
12470
  setDisplay(true);
12412
12471
  setPosition(activeEle.getBoundingClientRect());
12413
- const iframe = document.getElementById("tina-iframe");
12472
+ const iframe = document.getElementById(
12473
+ "tina-iframe"
12474
+ );
12414
12475
  if (iframe) {
12415
12476
  setIframePosition(iframe.getBoundingClientRect());
12416
12477
  }
@@ -12852,7 +12913,6 @@ const CreateBranchModel = ({
12852
12913
  }) => {
12853
12914
  const cms = useCMS$1();
12854
12915
  const tinaApi = cms.api.tina;
12855
- tinaApi.branch;
12856
12916
  const [disabled, setDisabled] = React.useState(false);
12857
12917
  const [newBranchName, setNewBranchName] = React.useState("");
12858
12918
  const [error, setError] = React.useState("");
@@ -12878,10 +12938,10 @@ const CreateBranchModel = ({
12878
12938
  const newUrl = window.location.href.replace(hash, newHash);
12879
12939
  window.location.href = newUrl;
12880
12940
  };
12881
- return /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, { close: close2 }, /* @__PURE__ */ React.createElement(BiGitBranch, { className: "w-6 h-auto mr-1 text-blue-500 opacity-70" }), " ", "Create Branch"), /* @__PURE__ */ React.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React.createElement("p", { className: "text-base text-gray-700 mb-2" }, "This branch is ", /* @__PURE__ */ React.createElement("strong", null, "protected"), ". Create a new branch to save your changes."), /* @__PURE__ */ React.createElement(
12941
+ return /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, { close: close2 }, /* @__PURE__ */ React.createElement(BiGitBranch, { className: "w-6 h-auto mr-1 text-blue-500 opacity-70" }), " ", "Create Branch"), /* @__PURE__ */ React.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React.createElement("p", { className: "text-lg text-gray-700 font-bold mb-2" }, "This content is protected 🚧"), /* @__PURE__ */ React.createElement("p", { className: "text-sm text-gray-700 mb-4" }, "To make changes, you need to create a copy then get it approved and merged for it to go live."), /* @__PURE__ */ React.createElement(
12882
12942
  PrefixedTextField,
12883
12943
  {
12884
- placeholder: "Branch Name",
12944
+ placeholder: "e.g. {{PAGE-NAME}}-updates",
12885
12945
  value: newBranchName,
12886
12946
  onChange: (e) => {
12887
12947
  setError("");
@@ -13028,7 +13088,9 @@ const ImgEmbed = ({
13028
13088
  const { fieldName } = useTemplates();
13029
13089
  const { handleClose, handleRemove, handleSelect, isExpanded } = useEmbedHandles(editor, element, fieldName);
13030
13090
  useHotkey("enter", () => {
13031
- insertNodes(editor, [{ type: ELEMENT_PARAGRAPH, children: [{ text: "" }] }]);
13091
+ insertNodes(editor, [
13092
+ { type: ELEMENT_PARAGRAPH, children: [{ text: "" }] }
13093
+ ]);
13032
13094
  });
13033
13095
  return /* @__PURE__ */ React__default.createElement("span", { ...attributes, className: "" }, children, element.url ? /* @__PURE__ */ React__default.createElement(
13034
13096
  "div",
@@ -13171,7 +13233,9 @@ const InlineEmbed = ({
13171
13233
  const { templates, fieldName } = useTemplates();
13172
13234
  const { handleClose, handleRemove, handleSelect, isExpanded } = useEmbedHandles(editor, element, fieldName);
13173
13235
  useHotkey("enter", () => {
13174
- insertNodes(editor, [{ type: ELEMENT_PARAGRAPH, children: [{ text: "" }] }]);
13236
+ insertNodes(editor, [
13237
+ { type: ELEMENT_PARAGRAPH, children: [{ text: "" }] }
13238
+ ]);
13175
13239
  });
13176
13240
  useHotkey("space", () => {
13177
13241
  insertNodes(editor, [{ text: " " }], {
@@ -13227,7 +13291,9 @@ const BlockEmbed = ({
13227
13291
  const { templates, fieldName } = useTemplates();
13228
13292
  const { handleClose, handleRemove, handleSelect, isExpanded } = useEmbedHandles(editor, element, fieldName);
13229
13293
  useHotkey("enter", () => {
13230
- insertNodes(editor, [{ type: ELEMENT_PARAGRAPH, children: [{ text: "" }] }]);
13294
+ insertNodes(editor, [
13295
+ { type: ELEMENT_PARAGRAPH, children: [{ text: "" }] }
13296
+ ]);
13231
13297
  });
13232
13298
  const activeTemplate = templates.find(
13233
13299
  (template) => template.name === element.name
@@ -14086,7 +14152,9 @@ const EMBED_ICON_WIDTH = 78;
14086
14152
  const CONTAINER_MD_BREAKPOINT = 448;
14087
14153
  const FLOAT_BUTTON_WIDTH = 25;
14088
14154
  const HEADING_LABEL = "Headings";
14089
- const ToolbarContext = createContext(void 0);
14155
+ const ToolbarContext = createContext(
14156
+ void 0
14157
+ );
14090
14158
  const ToolbarProvider = ({
14091
14159
  tinaForm,
14092
14160
  templates,
@@ -30298,7 +30366,14 @@ const TINA_LOGIN_EVENT = "tinaCloudLogin";
30298
30366
  const AUTH_TOKEN_KEY = "tinacms-auth";
30299
30367
  const authenticate = (clientId, frontendUrl) => {
30300
30368
  return new Promise((resolve) => {
30301
- let authTab;
30369
+ const origin = `${window.location.protocol}//${window.location.host}`;
30370
+ const authTab = popupWindow(
30371
+ `${frontendUrl}/signin?clientId=${clientId}&origin=${origin}`,
30372
+ "_blank",
30373
+ window,
30374
+ 1e3,
30375
+ 700
30376
+ );
30302
30377
  window.addEventListener("message", function(e) {
30303
30378
  if (e.data.source === TINA_LOGIN_EVENT) {
30304
30379
  if (authTab) {
@@ -30311,14 +30386,6 @@ const authenticate = (clientId, frontendUrl) => {
30311
30386
  });
30312
30387
  }
30313
30388
  });
30314
- const origin = `${window.location.protocol}//${window.location.host}`;
30315
- authTab = popupWindow(
30316
- `${frontendUrl}/signin?clientId=${clientId}&origin=${origin}`,
30317
- "_blank",
30318
- window,
30319
- 1e3,
30320
- 700
30321
- );
30322
30389
  });
30323
30390
  };
30324
30391
  const DefaultSessionProvider = ({
@@ -31024,56 +31091,6 @@ const AsyncButton = ({ name, primary, action }) => {
31024
31091
  !submitting && name
31025
31092
  );
31026
31093
  };
31027
- const TINA_AUTH_CONFIG = "tina_auth_config";
31028
- const useTinaAuthRedirect = () => {
31029
- useEffect(() => {
31030
- const urlParams = new URLSearchParams(window.location.search);
31031
- const config = {
31032
- code: urlParams.get("code") || "",
31033
- scope: urlParams.get("scope") || "email",
31034
- state: urlParams.get("state")
31035
- };
31036
- if (!config.code) {
31037
- return;
31038
- }
31039
- localStorage[TINA_AUTH_CONFIG] = JSON.stringify(config);
31040
- }, []);
31041
- };
31042
- const createClient = ({
31043
- clientId,
31044
- isLocalClient = true,
31045
- branch,
31046
- tinaioConfig,
31047
- schema,
31048
- apiUrl,
31049
- tinaGraphQLVersion
31050
- }) => {
31051
- return isLocalClient ? new LocalClient({ customContentApiUrl: apiUrl, schema }) : new Client({
31052
- clientId: clientId || "",
31053
- branch: branch || "main",
31054
- tokenStorage: "LOCAL_STORAGE",
31055
- tinaioConfig,
31056
- schema,
31057
- tinaGraphQLVersion
31058
- });
31059
- };
31060
- function assertShape(value, yupSchema, errorMessage) {
31061
- const shape = yupSchema(yup);
31062
- try {
31063
- shape.validateSync(value);
31064
- } catch (e) {
31065
- const message = errorMessage || `Failed to assertShape - ${e.message}`;
31066
- throw new Error(message);
31067
- }
31068
- }
31069
- function safeAssertShape(value, yupSchema) {
31070
- try {
31071
- assertShape(value, yupSchema);
31072
- return true;
31073
- } catch (e) {
31074
- return false;
31075
- }
31076
- }
31077
31094
  class TinaAdminApi {
31078
31095
  constructor(cms) {
31079
31096
  var _a, _b, _c, _d;
@@ -31420,6 +31437,56 @@ class TinaAdminApi {
31420
31437
  );
31421
31438
  }
31422
31439
  }
31440
+ const createClient = ({
31441
+ clientId,
31442
+ isLocalClient = true,
31443
+ branch,
31444
+ tinaioConfig,
31445
+ schema,
31446
+ apiUrl,
31447
+ tinaGraphQLVersion
31448
+ }) => {
31449
+ return isLocalClient ? new LocalClient({ customContentApiUrl: apiUrl, schema }) : new Client({
31450
+ clientId: clientId || "",
31451
+ branch: branch || "main",
31452
+ tokenStorage: "LOCAL_STORAGE",
31453
+ tinaioConfig,
31454
+ schema,
31455
+ tinaGraphQLVersion
31456
+ });
31457
+ };
31458
+ function assertShape(value, yupSchema, errorMessage) {
31459
+ const shape = yupSchema(yup);
31460
+ try {
31461
+ shape.validateSync(value);
31462
+ } catch (e) {
31463
+ const message = errorMessage || `Failed to assertShape - ${e.message}`;
31464
+ throw new Error(message);
31465
+ }
31466
+ }
31467
+ function safeAssertShape(value, yupSchema) {
31468
+ try {
31469
+ assertShape(value, yupSchema);
31470
+ return true;
31471
+ } catch (e) {
31472
+ return false;
31473
+ }
31474
+ }
31475
+ const TINA_AUTH_CONFIG = "tina_auth_config";
31476
+ const useTinaAuthRedirect = () => {
31477
+ useEffect(() => {
31478
+ const urlParams = new URLSearchParams(window.location.search);
31479
+ const config = {
31480
+ code: urlParams.get("code") || "",
31481
+ scope: urlParams.get("scope") || "email",
31482
+ state: urlParams.get("state")
31483
+ };
31484
+ if (!config.code) {
31485
+ return;
31486
+ }
31487
+ localStorage[TINA_AUTH_CONFIG] = JSON.stringify(config);
31488
+ }, []);
31489
+ };
31423
31490
  function sleep(ms) {
31424
31491
  return new Promise((resolve) => setTimeout(resolve, ms));
31425
31492
  }
@@ -31756,6 +31823,9 @@ const TinaCloudProvider = (props) => {
31756
31823
  cms.flags.set("branch-switcher", true);
31757
31824
  client.usingEditorialWorkflow = true;
31758
31825
  client.protectedBranches = project.protectedBranches;
31826
+ if (!project.metadata[currentBranch]) {
31827
+ setCurrentBranch(project.defaultBranch || "main");
31828
+ }
31759
31829
  }
31760
31830
  });
31761
31831
  };
@@ -31768,7 +31838,7 @@ const TinaCloudProvider = (props) => {
31768
31838
  }
31769
31839
  });
31770
31840
  return unsubscribe;
31771
- }, [isTinaCloud, cms]);
31841
+ }, [currentBranch, isTinaCloud, cms]);
31772
31842
  return /* @__PURE__ */ React__default.createElement(SessionProvider, { basePath: "/api/tina/auth" }, /* @__PURE__ */ React__default.createElement(
31773
31843
  BranchDataProvider,
31774
31844
  {
@@ -32621,6 +32691,35 @@ const FullscreenError = ({
32621
32691
  }) => {
32622
32692
  return /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-col justify-center items-center h-screen bg-gray-100" }, /* @__PURE__ */ React__default.createElement("div", { className: "text-red-500 text-4xl mb-6 flex items-center" }, /* @__PURE__ */ React__default.createElement(BiError, { className: "w-12 h-auto fill-current text-red-400 opacity-70 mr-1" }), " ", title), /* @__PURE__ */ React__default.createElement("p", { className: "text-gray-700 text-xl mb-8" }, errorMessage), /* @__PURE__ */ React__default.createElement(Button$1, { variant: "danger", onClick: () => window.location.reload() }, /* @__PURE__ */ React__default.createElement(BiSync, { className: "w-7 h-auto fill-current opacity-70 mr-1" }), " Reload"));
32623
32693
  };
32694
+ const isValidSortKey = (sortKey, collection) => {
32695
+ if (collection.fields) {
32696
+ const sortKeys = collection.fields.map((x) => x.name);
32697
+ return sortKeys.includes(sortKey);
32698
+ } else if (collection.templates) {
32699
+ const collectionMap = {};
32700
+ const conflictedFields = /* @__PURE__ */ new Set();
32701
+ for (const template of collection.templates) {
32702
+ for (const field of template.fields) {
32703
+ if (collectionMap[field.name]) {
32704
+ if (collectionMap[field.name].type !== field.type) {
32705
+ conflictedFields.add(field.name);
32706
+ }
32707
+ } else {
32708
+ collectionMap[field.name] = field;
32709
+ }
32710
+ }
32711
+ }
32712
+ for (const key in conflictedFields) {
32713
+ delete collectionMap[key];
32714
+ }
32715
+ for (const key in collectionMap) {
32716
+ if (key === sortKey) {
32717
+ return true;
32718
+ }
32719
+ }
32720
+ return false;
32721
+ }
32722
+ };
32624
32723
  const useGetCollection = (cms, collectionName, includeDocuments = true, folder, after = "", sortKey, filterArgs) => {
32625
32724
  const api = new TinaAdminApi(cms);
32626
32725
  const schema = cms.api.tina.schema;
@@ -32632,10 +32731,9 @@ const useGetCollection = (cms, collectionName, includeDocuments = true, folder,
32632
32731
  useEffect(() => {
32633
32732
  let cancelled = false;
32634
32733
  const fetchCollection = async () => {
32635
- var _a;
32636
32734
  if (await api.isAuthenticated() && !folder.loading && !cancelled) {
32637
32735
  const { name, order } = JSON.parse(sortKey || "{}");
32638
- const validSortKey = ((_a = collectionExtra.fields) == null ? void 0 : _a.map((x) => x.name).includes(name)) ? name : void 0;
32736
+ const validSortKey = isValidSortKey(name, collectionExtra) ? name : void 0;
32639
32737
  try {
32640
32738
  const collection2 = await api.fetchCollection(
32641
32739
  collectionName,
@@ -33087,7 +33185,9 @@ const CollectionListPage = () => {
33087
33185
  safeSubmit: async () => {
33088
33186
  try {
33089
33187
  await admin.deleteDocument(vars);
33090
- cms.alerts.info("Document was successfully deleted");
33188
+ cms.alerts.info(
33189
+ "Document was successfully deleted"
33190
+ );
33091
33191
  reFetchCollection();
33092
33192
  } catch (error) {
33093
33193
  cms.alerts.warn(
@@ -33116,7 +33216,9 @@ const CollectionListPage = () => {
33116
33216
  relativePath: vars.relativePath,
33117
33217
  newRelativePath
33118
33218
  });
33119
- cms.alerts.info("Document was successfully renamed");
33219
+ cms.alerts.info(
33220
+ "Document was successfully renamed"
33221
+ );
33120
33222
  reFetchCollection();
33121
33223
  } catch (error) {
33122
33224
  if (error.message.indexOf("has references")) {
@@ -33216,7 +33318,9 @@ const CollectionListPage = () => {
33216
33318
  name: "sort",
33217
33319
  value: sortKey,
33218
33320
  onChange: (e) => {
33219
- const val = JSON.parse(e.target.value);
33321
+ const val = JSON.parse(
33322
+ e.target.value
33323
+ );
33220
33324
  setEndCursor("");
33221
33325
  setPrevCursors([]);
33222
33326
  window == null ? void 0 : window.localStorage.setItem(
@@ -34005,7 +34109,10 @@ const useGetDocument = (cms, collectionName, relativePath2) => {
34005
34109
  const fetchDocument = async () => {
34006
34110
  if (api.isAuthenticated()) {
34007
34111
  try {
34008
- const response = await api.fetchDocument(collectionName, relativePath2);
34112
+ const response = await api.fetchDocument(
34113
+ collectionName,
34114
+ relativePath2
34115
+ );
34009
34116
  setDocument(response.document);
34010
34117
  } catch (error2) {
34011
34118
  cms.alerts.error(