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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("zod"), require("react"), require("react-dom"), require("@udecode/cn"), require("@udecode/plate"), require("@udecode/plate-common"), require("@udecode/plate-slash-command"), require("slate-react"), require("@udecode/plate-code-block"), require("@monaco-editor/react"), require("@headlessui/react"), require("class-variance-authority"), require("lucide-react"), require("mermaid"), require("@udecode/plate-heading"), require("@ariakit/react"), require("@udecode/plate-combobox"), require("@udecode/plate-table"), require("@udecode/plate-resizable"), require("@radix-ui/react-popover"), require("@radix-ui/react-slot"), require("@radix-ui/react-dropdown-menu"), require("@radix-ui/react-separator"), require("final-form-arrays"), require("final-form-set-field-data"), require("final-form"), require("react-final-form"), require("prop-types"), require("react-beautiful-dnd"), require("react-color"), require("color-string"), require("react-dropzone"), require("clsx"), require("tailwind-merge"), require("cmdk"), require("is-hotkey"), require("slate"), require("lodash.get"), require("moment"), require("date-fns"), require("@udecode/plate-link"), require("@radix-ui/react-toolbar"), require("@radix-ui/react-tooltip"), require("@udecode/plate-paragraph"), require("@udecode/plate-block-quote"), require("@udecode/plate-floating"), require("@react-hook/window-size"), require("graphql"), require("graphql-tag"), require("@tinacms/schema-tools"), require("yup"), require("@graphql-inspector/core"), require("react-router-dom"), require("@tinacms/mdx")) : typeof define === "function" && define.amd ? define(["exports", "zod", "react", "react-dom", "@udecode/cn", "@udecode/plate", "@udecode/plate-common", "@udecode/plate-slash-command", "slate-react", "@udecode/plate-code-block", "@monaco-editor/react", "@headlessui/react", "class-variance-authority", "lucide-react", "mermaid", "@udecode/plate-heading", "@ariakit/react", "@udecode/plate-combobox", "@udecode/plate-table", "@udecode/plate-resizable", "@radix-ui/react-popover", "@radix-ui/react-slot", "@radix-ui/react-dropdown-menu", "@radix-ui/react-separator", "final-form-arrays", "final-form-set-field-data", "final-form", "react-final-form", "prop-types", "react-beautiful-dnd", "react-color", "color-string", "react-dropzone", "clsx", "tailwind-merge", "cmdk", "is-hotkey", "slate", "lodash.get", "moment", "date-fns", "@udecode/plate-link", "@radix-ui/react-toolbar", "@radix-ui/react-tooltip", "@udecode/plate-paragraph", "@udecode/plate-block-quote", "@udecode/plate-floating", "@react-hook/window-size", "graphql", "graphql-tag", "@tinacms/schema-tools", "yup", "@graphql-inspector/core", "react-router-dom", "@tinacms/mdx"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
3
- })(this, function(exports2, zod, React, reactDom, cn$1, plate, plateCommon, plateSlashCommand, slateReact, plateCodeBlock, MonacoEditor, react, classVarianceAuthority, lucideReact, mermaid, plateHeading, react$1, plateCombobox, plateTable, plateResizable, PopoverPrimitive, reactSlot, DropdownMenuPrimitive, SeparatorPrimitive, arrayMutators, setFieldData, finalForm, reactFinalForm, PropTypes, reactBeautifulDnd, pkg$1, pkg, dropzone, clsx, tailwindMerge, cmdk, isHotkey, slate, get, moment, dateFns, plateLink, ToolbarPrimitive, TooltipPrimitive, plateParagraph, plateBlockQuote, plateFloating, windowSize, graphql, gql, schemaTools, yup, core, reactRouterDom, mdx) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("zod"), require("react"), require("react-dom"), require("@udecode/cn"), require("@udecode/plate"), require("@udecode/plate-common"), require("@udecode/plate-slash-command"), require("slate-react"), require("@udecode/plate-code-block"), require("@monaco-editor/react"), require("@headlessui/react"), require("class-variance-authority"), require("lucide-react"), require("mermaid"), require("@udecode/plate-heading"), require("@ariakit/react"), require("@udecode/plate-combobox"), require("@udecode/plate-table"), require("@udecode/plate-resizable"), require("@radix-ui/react-popover"), require("@radix-ui/react-slot"), require("@radix-ui/react-dropdown-menu"), require("@radix-ui/react-separator"), require("final-form-arrays"), require("final-form-set-field-data"), require("final-form"), require("react-final-form"), require("prop-types"), require("react-beautiful-dnd"), require("react-color"), require("color-string"), require("react-dropzone"), require("clsx"), require("tailwind-merge"), require("cmdk"), require("is-hotkey"), require("slate"), require("@react-hook/window-size"), require("lodash.get"), require("moment"), require("date-fns"), require("@udecode/plate-link"), require("@radix-ui/react-toolbar"), require("@radix-ui/react-tooltip"), require("@udecode/plate-paragraph"), require("@udecode/plate-block-quote"), require("@udecode/plate-floating"), require("graphql"), require("graphql-tag"), require("@tinacms/schema-tools"), require("@graphql-inspector/core"), require("yup"), require("react-router-dom"), require("@tinacms/mdx")) : typeof define === "function" && define.amd ? define(["exports", "zod", "react", "react-dom", "@udecode/cn", "@udecode/plate", "@udecode/plate-common", "@udecode/plate-slash-command", "slate-react", "@udecode/plate-code-block", "@monaco-editor/react", "@headlessui/react", "class-variance-authority", "lucide-react", "mermaid", "@udecode/plate-heading", "@ariakit/react", "@udecode/plate-combobox", "@udecode/plate-table", "@udecode/plate-resizable", "@radix-ui/react-popover", "@radix-ui/react-slot", "@radix-ui/react-dropdown-menu", "@radix-ui/react-separator", "final-form-arrays", "final-form-set-field-data", "final-form", "react-final-form", "prop-types", "react-beautiful-dnd", "react-color", "color-string", "react-dropzone", "clsx", "tailwind-merge", "cmdk", "is-hotkey", "slate", "@react-hook/window-size", "lodash.get", "moment", "date-fns", "@udecode/plate-link", "@radix-ui/react-toolbar", "@radix-ui/react-tooltip", "@udecode/plate-paragraph", "@udecode/plate-block-quote", "@udecode/plate-floating", "graphql", "graphql-tag", "@tinacms/schema-tools", "@graphql-inspector/core", "yup", "react-router-dom", "@tinacms/mdx"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
3
+ })(this, function(exports2, zod, React, reactDom, cn$1, plate, plateCommon, plateSlashCommand, slateReact, plateCodeBlock, MonacoEditor, react, classVarianceAuthority, lucideReact, mermaid, plateHeading, react$1, plateCombobox, plateTable, plateResizable, PopoverPrimitive, reactSlot, DropdownMenuPrimitive, SeparatorPrimitive, arrayMutators, setFieldData, finalForm, reactFinalForm, PropTypes, reactBeautifulDnd, pkg$1, pkg, dropzone, clsx, tailwindMerge, cmdk, isHotkey, slate, windowSize, get, moment, dateFns, plateLink, ToolbarPrimitive, TooltipPrimitive, plateParagraph, plateBlockQuote, plateFloating, graphql, gql, schemaTools, core, yup, reactRouterDom, mdx) {
4
4
  "use strict";var __defProp = Object.defineProperty;
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
6
  var __publicField = (obj, key, value) => {
@@ -5305,7 +5305,9 @@ flowchart TD
5305
5305
  }, [value, input, optionSets]);
5306
5306
  React__namespace.useEffect(() => {
5307
5307
  if (field.experimental___filter && optionSets.length > 0) {
5308
- setFilteredOptionsList(field.experimental___filter(optionSets, void 0));
5308
+ setFilteredOptionsList(
5309
+ field.experimental___filter(optionSets, void 0)
5310
+ );
5309
5311
  } else {
5310
5312
  setFilteredOptionsList(optionSets);
5311
5313
  }
@@ -5675,7 +5677,9 @@ flowchart TD
5675
5677
  onClick: () => {
5676
5678
  const state = tinaForm.finalForm.getState();
5677
5679
  if (state.invalid === true) {
5678
- cms.alerts.error("Cannot navigate away from an invalid form.");
5680
+ cms.alerts.error(
5681
+ "Cannot navigate away from an invalid form."
5682
+ );
5679
5683
  return;
5680
5684
  }
5681
5685
  cms.dispatch({
@@ -6259,7 +6263,9 @@ flowchart TD
6259
6263
  onClick: () => {
6260
6264
  const state = tinaForm.finalForm.getState();
6261
6265
  if (state.invalid === true) {
6262
- cms.alerts.error("Cannot navigate away from an invalid form.");
6266
+ cms.alerts.error(
6267
+ "Cannot navigate away from an invalid form."
6268
+ );
6263
6269
  return;
6264
6270
  }
6265
6271
  cms.dispatch({
@@ -6741,28 +6747,28 @@ flowchart TD
6741
6747
  }
6742
6748
  renderDayHeaders() {
6743
6749
  const locale = this.props.viewDate.localeData();
6744
- let dayItems = getDaysOfWeek(locale).map((day, index) => /* @__PURE__ */ React.createElement("th", { key: day + index, className: "dow" }, day));
6750
+ const dayItems = getDaysOfWeek(locale).map((day, index) => /* @__PURE__ */ React.createElement("th", { key: day + index, className: "dow" }, day));
6745
6751
  return /* @__PURE__ */ React.createElement("tr", null, dayItems);
6746
6752
  }
6747
6753
  renderDays() {
6748
6754
  const date = this.props.viewDate;
6749
6755
  const startOfMonth = date.clone().startOf("month");
6750
6756
  const endOfMonth = date.clone().endOf("month");
6751
- let rows = [[], [], [], [], [], []];
6752
- let startDate = date.clone().subtract(1, "months");
6757
+ const rows = [[], [], [], [], [], []];
6758
+ const startDate = date.clone().subtract(1, "months");
6753
6759
  startDate.date(startDate.daysInMonth()).startOf("week");
6754
- let endDate = startDate.clone().add(42, "d");
6760
+ const endDate = startDate.clone().add(42, "d");
6755
6761
  let i = 0;
6756
6762
  while (startDate.isBefore(endDate)) {
6757
- let row = getRow$2(rows, i++);
6763
+ const row = getRow$2(rows, i++);
6758
6764
  row.push(this.renderDay(startDate, startOfMonth, endOfMonth));
6759
6765
  startDate.add(1, "d");
6760
6766
  }
6761
6767
  return rows.map((r, i2) => /* @__PURE__ */ React.createElement("tr", { key: `${endDate.month()}_${i2}` }, r));
6762
6768
  }
6763
6769
  renderDay(date, startOfMonth, endOfMonth) {
6764
- let selectedDate = this.props.selectedDate;
6765
- let dayProps = {
6770
+ const selectedDate = this.props.selectedDate;
6771
+ const dayProps = {
6766
6772
  key: date.format("M_D"),
6767
6773
  "data-value": date.date(),
6768
6774
  "data-month": date.month(),
@@ -6816,7 +6822,7 @@ flowchart TD
6816
6822
  }
6817
6823
  function getDaysOfWeek(locale) {
6818
6824
  const first = locale.firstDayOfWeek();
6819
- let dow = [];
6825
+ const dow = [];
6820
6826
  let i = 0;
6821
6827
  locale._weekdaysMin.forEach(function(day) {
6822
6828
  dow[(7 + i++ - first) % 7] = day;
@@ -6834,7 +6840,7 @@ flowchart TD
6834
6840
  return /* @__PURE__ */ React.createElement("div", { className: "rdtMonths" }, /* @__PURE__ */ React.createElement("table", null, /* @__PURE__ */ React.createElement("thead", null, this.renderNavigation())), /* @__PURE__ */ React.createElement("table", null, /* @__PURE__ */ React.createElement("tbody", null, this.renderMonths())));
6835
6841
  }
6836
6842
  renderNavigation() {
6837
- let year = this.props.viewDate.year();
6843
+ const year = this.props.viewDate.year();
6838
6844
  return /* @__PURE__ */ React.createElement(
6839
6845
  ViewNavigation,
6840
6846
  {
@@ -6847,9 +6853,9 @@ flowchart TD
6847
6853
  );
6848
6854
  }
6849
6855
  renderMonths() {
6850
- let rows = [[], [], []];
6856
+ const rows = [[], [], []];
6851
6857
  for (let month = 0; month < 12; month++) {
6852
- let row = getRow$1(rows, month);
6858
+ const row = getRow$1(rows, month);
6853
6859
  row.push(this.renderMonth(month));
6854
6860
  }
6855
6861
  return rows.map((months, i) => /* @__PURE__ */ React.createElement("tr", { key: i }, months));
@@ -6866,7 +6872,7 @@ flowchart TD
6866
6872
  if (selectedDate && selectedDate.year() === this.props.viewDate.year() && selectedDate.month() === month) {
6867
6873
  className += " rdtActive";
6868
6874
  }
6869
- let props = { key: month, className, "data-value": month, onClick };
6875
+ const props = { key: month, className, "data-value": month, onClick };
6870
6876
  if (this.props.renderMonth) {
6871
6877
  return this.props.renderMonth(
6872
6878
  props,
@@ -6878,11 +6884,11 @@ flowchart TD
6878
6884
  return /* @__PURE__ */ React.createElement("td", { ...props }, this.getMonthText(month));
6879
6885
  }
6880
6886
  isDisabledMonth(month) {
6881
- let isValidDate = this.props.isValidDate;
6887
+ const isValidDate = this.props.isValidDate;
6882
6888
  if (!isValidDate) {
6883
6889
  return false;
6884
6890
  }
6885
- let date = this.props.viewDate.clone().set({ month });
6891
+ const date = this.props.viewDate.clone().set({ month });
6886
6892
  let day = date.endOf("month").date() + 1;
6887
6893
  while (day-- > 1) {
6888
6894
  if (isValidDate(date.date(day))) {
@@ -6934,9 +6940,9 @@ flowchart TD
6934
6940
  }
6935
6941
  renderYears() {
6936
6942
  const viewYear = this.getViewYear();
6937
- let rows = [[], [], []];
6943
+ const rows = [[], [], []];
6938
6944
  for (let year = viewYear - 1; year < viewYear + 11; year++) {
6939
- let row = getRow(rows, year - viewYear);
6945
+ const row = getRow(rows, year - viewYear);
6940
6946
  row.push(this.renderYear(year));
6941
6947
  }
6942
6948
  return rows.map((years, i) => /* @__PURE__ */ React.createElement("tr", { key: i }, years));
@@ -6953,7 +6959,7 @@ flowchart TD
6953
6959
  if (selectedYear === year) {
6954
6960
  className += " rdtActive";
6955
6961
  }
6956
- let props = { key: year, className, "data-value": year, onClick };
6962
+ const props = { key: year, className, "data-value": year, onClick };
6957
6963
  return this.props.renderYear(
6958
6964
  props,
6959
6965
  year,
@@ -6967,15 +6973,15 @@ flowchart TD
6967
6973
  return this.props.selectedDate && this.props.selectedDate.year();
6968
6974
  }
6969
6975
  isDisabledYear(year) {
6970
- let cache = this.disabledYearsCache;
6976
+ const cache = this.disabledYearsCache;
6971
6977
  if (cache[year] !== void 0) {
6972
6978
  return cache[year];
6973
6979
  }
6974
- let isValidDate = this.props.isValidDate;
6980
+ const isValidDate = this.props.isValidDate;
6975
6981
  if (!isValidDate) {
6976
6982
  return false;
6977
6983
  }
6978
- let date = this.props.viewDate.clone().set({ year });
6984
+ const date = this.props.viewDate.clone().set({ year });
6979
6985
  let day = date.endOf("year").dayOfYear() + 1;
6980
6986
  while (day-- > 1) {
6981
6987
  if (isValidDate(date.dayOfYear(day))) {
@@ -7022,7 +7028,7 @@ flowchart TD
7022
7028
  }
7023
7029
  };
7024
7030
  function createConstraints(overrideTimeConstraints) {
7025
- let constraints = {};
7031
+ const constraints = {};
7026
7032
  Object.keys(timeConstraints).forEach((type) => {
7027
7033
  constraints[type] = {
7028
7034
  ...timeConstraints[type],
@@ -7038,7 +7044,7 @@ flowchart TD
7038
7044
  this.state = this.getTimeParts(props.selectedDate || props.viewDate);
7039
7045
  }
7040
7046
  render() {
7041
- let items2 = [];
7047
+ const items2 = [];
7042
7048
  const timeParts = this.state;
7043
7049
  this.getCounters().forEach((c, i) => {
7044
7050
  if (i && c !== "ampm") {
@@ -7100,8 +7106,8 @@ flowchart TD
7100
7106
  }
7101
7107
  if (type === "ampm")
7102
7108
  return this.toggleDayPart();
7103
- let update = {};
7104
- let body = document.body;
7109
+ const update = {};
7110
+ const body = document.body;
7105
7111
  update[type] = this[action](type);
7106
7112
  this.setState(update);
7107
7113
  this.timer = setTimeout(() => {
@@ -7144,8 +7150,8 @@ flowchart TD
7144
7150
  return pad(type, value);
7145
7151
  }
7146
7152
  getCounters() {
7147
- let counters = [];
7148
- let format2 = this.props.timeFormat;
7153
+ const counters = [];
7154
+ const format2 = this.props.timeFormat;
7149
7155
  if (format2.toLowerCase().indexOf("h") !== -1) {
7150
7156
  counters.push("hours");
7151
7157
  if (format2.indexOf("m") !== -1) {
@@ -7277,7 +7283,7 @@ flowchart TD
7277
7283
  __publicField(this, "_renderCalendar", () => {
7278
7284
  const props = this.props;
7279
7285
  const state = this.state;
7280
- let viewProps = {
7286
+ const viewProps = {
7281
7287
  viewDate: state.viewDate.clone(),
7282
7288
  selectedDate: this.getSelectedDate(),
7283
7289
  isValidDate: props.isValidDate,
@@ -7320,10 +7326,10 @@ flowchart TD
7320
7326
  __publicField(this, "viewToMethod", { days: "date", months: "month", years: "year" });
7321
7327
  __publicField(this, "nextView", { days: "time", months: "days", years: "months" });
7322
7328
  __publicField(this, "_updateDate", (e) => {
7323
- let state = this.state;
7324
- let currentView = state.currentView;
7325
- let updateOnView = this.getUpdateOn(this.getFormat("date"));
7326
- let viewDate = this.state.viewDate.clone();
7329
+ const state = this.state;
7330
+ const currentView = state.currentView;
7331
+ const updateOnView = this.getUpdateOn(this.getFormat("date"));
7332
+ const viewDate = this.state.viewDate.clone();
7327
7333
  viewDate[this.viewToMethod[currentView]](
7328
7334
  parseInt(e.target.getAttribute("data-value"), 10)
7329
7335
  );
@@ -7331,7 +7337,7 @@ flowchart TD
7331
7337
  viewDate.month(parseInt(e.target.getAttribute("data-month"), 10));
7332
7338
  viewDate.year(parseInt(e.target.getAttribute("data-year"), 10));
7333
7339
  }
7334
- let update = { viewDate };
7340
+ const update = { viewDate };
7335
7341
  if (currentView === updateOnView) {
7336
7342
  update.selectedDate = viewDate.clone();
7337
7343
  update.inputValue = viewDate.format(this.getFormat("datetime"));
@@ -7345,7 +7351,7 @@ flowchart TD
7345
7351
  this.setState(update);
7346
7352
  });
7347
7353
  __publicField(this, "_viewNavigate", (modifier, unit) => {
7348
- let viewDate = this.state.viewDate.clone();
7354
+ const viewDate = this.state.viewDate.clone();
7349
7355
  viewDate.add(modifier, unit);
7350
7356
  if (modifier > 0) {
7351
7357
  this.props.onNavigateForward(modifier, unit);
@@ -7355,7 +7361,7 @@ flowchart TD
7355
7361
  this.setState({ viewDate });
7356
7362
  });
7357
7363
  __publicField(this, "_setTime", (type, value) => {
7358
- let date = (this.getSelectedDate() || this.state.viewDate).clone();
7364
+ const date = (this.getSelectedDate() || this.state.viewDate).clone();
7359
7365
  date[type](value);
7360
7366
  if (!this.props.value) {
7361
7367
  this.setState({
@@ -7379,7 +7385,7 @@ flowchart TD
7379
7385
  });
7380
7386
  });
7381
7387
  __publicField(this, "_handleClickOutside", () => {
7382
- let props = this.props;
7388
+ const props = this.props;
7383
7389
  if (props.input && this.state.open && props.open === void 0 && props.closeOnClickOutside) {
7384
7390
  this._closeCalendar();
7385
7391
  }
@@ -7394,7 +7400,7 @@ flowchart TD
7394
7400
  return;
7395
7401
  const value = e.target ? e.target.value : e;
7396
7402
  const localMoment = this.localMoment(value, this.getFormat("datetime"));
7397
- let update = { inputValue: value };
7403
+ const update = { inputValue: value };
7398
7404
  if (localMoment.isValid()) {
7399
7405
  update.selectedDate = localMoment;
7400
7406
  update.viewDate = localMoment.clone().startOf("month");
@@ -7458,9 +7464,9 @@ flowchart TD
7458
7464
  return this.props.renderView(this.state.currentView, this._renderCalendar);
7459
7465
  }
7460
7466
  getInitialState() {
7461
- let props = this.props;
7462
- let inputFormat = this.getFormat("datetime");
7463
- let selectedDate = this.parseDate(
7467
+ const props = this.props;
7468
+ const inputFormat = this.getFormat("datetime");
7469
+ const selectedDate = this.parseDate(
7464
7470
  props.value || props.initialValue,
7465
7471
  inputFormat
7466
7472
  );
@@ -7491,7 +7497,7 @@ flowchart TD
7491
7497
  return this.getInitialDate();
7492
7498
  }
7493
7499
  getInitialDate() {
7494
- let m = this.localMoment();
7500
+ const m = this.localMoment();
7495
7501
  m.hour(0).minute(0).second(0).millisecond(0);
7496
7502
  return m;
7497
7503
  }
@@ -7511,8 +7517,8 @@ flowchart TD
7511
7517
  }
7512
7518
  getClassName() {
7513
7519
  let cn2 = "rdt";
7514
- let props = this.props;
7515
- let propCn = props.className;
7520
+ const props = this.props;
7521
+ const propCn = props.className;
7516
7522
  if (Array.isArray(propCn)) {
7517
7523
  cn2 += " " + propCn.join(" ");
7518
7524
  } else if (propCn) {
@@ -7545,14 +7551,14 @@ flowchart TD
7545
7551
  return viewModes.DAYS;
7546
7552
  }
7547
7553
  getLocaleData() {
7548
- let p = this.props;
7554
+ const p = this.props;
7549
7555
  return this.localMoment(
7550
7556
  p.value || p.defaultValue || /* @__PURE__ */ new Date()
7551
7557
  ).localeData();
7552
7558
  }
7553
7559
  getDateFormat() {
7554
7560
  const locale = this.getLocaleData();
7555
- let format2 = this.props.dateFormat;
7561
+ const format2 = this.props.dateFormat;
7556
7562
  if (format2 === true)
7557
7563
  return locale.longDateFormat("L");
7558
7564
  if (format2)
@@ -7561,7 +7567,7 @@ flowchart TD
7561
7567
  }
7562
7568
  getTimeFormat() {
7563
7569
  const locale = this.getLocaleData();
7564
- let format2 = this.props.timeFormat;
7570
+ const format2 = this.props.timeFormat;
7565
7571
  if (format2 === true) {
7566
7572
  return locale.longDateFormat("LT");
7567
7573
  }
@@ -7573,12 +7579,12 @@ flowchart TD
7573
7579
  } else if (type === "time") {
7574
7580
  return this.getTimeFormat();
7575
7581
  }
7576
- let dateFormat = this.getDateFormat();
7577
- let timeFormat = this.getTimeFormat();
7582
+ const dateFormat = this.getDateFormat();
7583
+ const timeFormat = this.getTimeFormat();
7578
7584
  return dateFormat && timeFormat ? dateFormat + " " + timeFormat : dateFormat || timeFormat;
7579
7585
  }
7580
7586
  updateTime(op, amount, type, toSelected) {
7581
- let update = {};
7587
+ const update = {};
7582
7588
  const date = toSelected ? "selectedDate" : "viewDate";
7583
7589
  update[date] = this.state[date].clone()[op](amount, type);
7584
7590
  this.setState(update);
@@ -7611,7 +7617,7 @@ flowchart TD
7611
7617
  if (prevProps === this.props)
7612
7618
  return;
7613
7619
  let needsUpdate = false;
7614
- let thisProps = this.props;
7620
+ const thisProps = this.props;
7615
7621
  ["locale", "utc", "displayZone", "dateFormat", "timeFormat"].forEach(
7616
7622
  function(p) {
7617
7623
  prevProps[p] !== thisProps[p] && (needsUpdate = true);
@@ -7627,8 +7633,8 @@ flowchart TD
7627
7633
  }
7628
7634
  regenerateDates() {
7629
7635
  const props = this.props;
7630
- let viewDate = this.state.viewDate.clone();
7631
- let selectedDate = this.state.selectedDate && this.state.selectedDate.clone();
7636
+ const viewDate = this.state.viewDate.clone();
7637
+ const selectedDate = this.state.selectedDate && this.state.selectedDate.clone();
7632
7638
  if (props.locale) {
7633
7639
  viewDate.locale(props.locale);
7634
7640
  selectedDate && selectedDate.locale(props.locale);
@@ -7643,7 +7649,7 @@ flowchart TD
7643
7649
  viewDate.locale();
7644
7650
  selectedDate && selectedDate.locale();
7645
7651
  }
7646
- let update = { viewDate, selectedDate };
7652
+ const update = { viewDate, selectedDate };
7647
7653
  if (selectedDate && selectedDate.isValid()) {
7648
7654
  update.inputValue = selectedDate.format(this.getFormat("datetime"));
7649
7655
  }
@@ -7652,7 +7658,7 @@ flowchart TD
7652
7658
  getSelectedDate() {
7653
7659
  if (this.props.value === void 0)
7654
7660
  return this.state.selectedDate;
7655
- let selectedDate = this.parseDate(
7661
+ const selectedDate = this.parseDate(
7656
7662
  this.props.value,
7657
7663
  this.getFormat("datetime")
7658
7664
  );
@@ -7671,7 +7677,7 @@ flowchart TD
7671
7677
  return "";
7672
7678
  }
7673
7679
  getInputValue() {
7674
- let selectedDate = this.getSelectedDate();
7680
+ const selectedDate = this.getSelectedDate();
7675
7681
  return selectedDate ? selectedDate.format(this.getFormat("datetime")) : this.state.inputValue;
7676
7682
  }
7677
7683
  /**
@@ -7681,7 +7687,7 @@ flowchart TD
7681
7687
  * @public
7682
7688
  */
7683
7689
  setViewDate(date) {
7684
- let logError = function() {
7690
+ const logError = function() {
7685
7691
  return log("Invalid date passed to the `setViewDate` method: " + date);
7686
7692
  };
7687
7693
  if (!date)
@@ -7777,7 +7783,7 @@ flowchart TD
7777
7783
  // Make moment accessible through the Datetime class
7778
7784
  __publicField(Datetime, "moment", moment);
7779
7785
  function log(message, method) {
7780
- let con = typeof window !== "undefined" && window.console;
7786
+ const con = typeof window !== "undefined" && window.console;
7781
7787
  if (!con)
7782
7788
  return;
7783
7789
  if (!method) {
@@ -8600,7 +8606,10 @@ flowchart TD
8600
8606
  label: "View in GitHub",
8601
8607
  Icon: /* @__PURE__ */ React__namespace.createElement(BiLinkExternal, { className: "w-5 h-auto text-blue-500 opacity-70" }),
8602
8608
  onMouseDown: () => {
8603
- window.open(branch.githubPullRequestUrl, "_blank");
8609
+ window.open(
8610
+ branch.githubPullRequestUrl,
8611
+ "_blank"
8612
+ );
8604
8613
  }
8605
8614
  },
8606
8615
  typeof previewFunction === "function" && ((_b2 = previewFunction({ branch: branch.name })) == null ? void 0 : _b2.url) && {
@@ -8906,7 +8915,9 @@ flowchart TD
8906
8915
  } else {
8907
8916
  events = event;
8908
8917
  }
8909
- const newListeners = events.map((event2) => new Listener(event2, callback));
8918
+ const newListeners = events.map(
8919
+ (event2) => new Listener(event2, callback)
8920
+ );
8910
8921
  newListeners.forEach((newListener) => this.listeners.add(newListener));
8911
8922
  return () => {
8912
8923
  newListeners.forEach((listener) => this.listeners.delete(listener));
@@ -9262,9 +9273,7 @@ flowchart TD
9262
9273
  const deleteStartTime = Date.now();
9263
9274
  while (true) {
9264
9275
  await new Promise((resolve) => setTimeout(resolve, 1e3));
9265
- const { error, message } = await this.api.getRequestStatus(
9266
- requestId
9267
- );
9276
+ const { error, message } = await this.api.getRequestStatus(requestId);
9268
9277
  if (error !== void 0) {
9269
9278
  if (error) {
9270
9279
  throw new Error(message);
@@ -9599,7 +9608,7 @@ flowchart TD
9599
9608
  return this.add("error", message, timeout);
9600
9609
  }
9601
9610
  };
9602
- const NoFormsPlaceholder = () => /* @__PURE__ */ React__namespace.createElement(
9611
+ const SidebarLoadingPlaceholder = () => /* @__PURE__ */ React__namespace.createElement(
9603
9612
  "div",
9604
9613
  {
9605
9614
  className: "relative flex flex-col items-center justify-center text-center p-5 pb-16 w-full h-full overflow-y-auto",
@@ -9612,25 +9621,8 @@ flowchart TD
9612
9621
  animationDuration: "150ms"
9613
9622
  }
9614
9623
  },
9615
- /* @__PURE__ */ React__namespace.createElement(Emoji$1, { className: "pb-5" }, "🔎"),
9616
- /* @__PURE__ */ React__namespace.createElement("p", { className: "block pb-5" }, "Looks like there's ", /* @__PURE__ */ React__namespace.createElement("br", null), "nothing to edit on ", /* @__PURE__ */ React__namespace.createElement("br", null), "this page."),
9617
- /* @__PURE__ */ React__namespace.createElement("p", { className: "block" }, /* @__PURE__ */ React__namespace.createElement(
9618
- Button$1,
9619
- {
9620
- href: "https://tina.io/docs/tinacms-context/",
9621
- target: "_blank",
9622
- as: "a"
9623
- },
9624
- /* @__PURE__ */ React__namespace.createElement(Emoji$1, { className: "mr-1.5" }, "📖"),
9625
- " Contextual Editing"
9626
- ))
9627
- );
9628
- const Emoji$1 = ({ className = "", ...props }) => /* @__PURE__ */ React__namespace.createElement(
9629
- "span",
9630
- {
9631
- className: `text-[24px] leading-none inline-block ${className}`,
9632
- ...props
9633
- }
9624
+ /* @__PURE__ */ React__namespace.createElement("p", { className: "block pb-5" }, "Please wait while TinaCMS", /* @__PURE__ */ React__namespace.createElement("br", null), "loads your content"),
9625
+ /* @__PURE__ */ React__namespace.createElement(LoadingDots, { color: "var(--tina-color-primary)" })
9634
9626
  );
9635
9627
  class SidebarState {
9636
9628
  constructor(events, options = {}) {
@@ -9645,7 +9637,7 @@ flowchart TD
9645
9637
  };
9646
9638
  this.position = options.position || "displace";
9647
9639
  this.renderNav = options.renderNav || true;
9648
- this.placeholder = options.placeholder || NoFormsPlaceholder;
9640
+ this.loadingPlaceholder = options.placeholder || SidebarLoadingPlaceholder;
9649
9641
  if ((_a = options.buttons) == null ? void 0 : _a.save) {
9650
9642
  this.buttons.save = options.buttons.save;
9651
9643
  }
@@ -9719,238 +9711,6 @@ flowchart TD
9719
9711
  children
9720
9712
  )));
9721
9713
  };
9722
- const Item = ({
9723
- item,
9724
- depth,
9725
- setActiveFormId
9726
- }) => {
9727
- const cms = useCMS();
9728
- const depths = ["pl-6", "pl-10", "pl-14"];
9729
- const form = React__namespace.useMemo(
9730
- () => cms.state.forms.find(({ tinaForm }) => item.formId === tinaForm.id),
9731
- [item.formId]
9732
- );
9733
- return /* @__PURE__ */ React__namespace.createElement(
9734
- "button",
9735
- {
9736
- type: "button",
9737
- key: item.path,
9738
- onClick: () => setActiveFormId(item.formId),
9739
- 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`
9740
- },
9741
- /* @__PURE__ */ React__namespace.createElement(BiEdit, { className: "opacity-70 w-5 h-auto text-blue-500 flex-none" }),
9742
- /* @__PURE__ */ React__namespace.createElement("div", { className: "flex-1 flex flex-col gap-0.5 items-start" }, /* @__PURE__ */ React__namespace.createElement("div", { className: "group-hover:text-blue-500 font-sans text-xs font-semibold text-gray-700 whitespace-normal" }, form.tinaForm.label), /* @__PURE__ */ React__namespace.createElement("div", { className: "group-hover:text-blue-500 text-base truncate leading-tight text-gray-600" }, form.tinaForm.id))
9743
- );
9744
- };
9745
- const FormListItem = ({
9746
- item,
9747
- depth,
9748
- setActiveFormId
9749
- }) => {
9750
- var _a;
9751
- return /* @__PURE__ */ React__namespace.createElement("div", { className: "divide-y divide-gray-200" }, /* @__PURE__ */ React__namespace.createElement(Item, { setActiveFormId, item, depth }), item.subItems && /* @__PURE__ */ React__namespace.createElement("ul", { className: "divide-y divide-gray-200" }, (_a = item.subItems) == null ? void 0 : _a.map((subItem) => {
9752
- if (subItem.type === "document") {
9753
- return /* @__PURE__ */ React__namespace.createElement("li", { key: subItem.formId }, /* @__PURE__ */ React__namespace.createElement(
9754
- Item,
9755
- {
9756
- setActiveFormId,
9757
- depth: depth + 1,
9758
- item: subItem
9759
- }
9760
- ));
9761
- }
9762
- })));
9763
- };
9764
- const FormLists = (props) => {
9765
- const cms = useCMS();
9766
- return /* @__PURE__ */ React__namespace.createElement(
9767
- react.Transition,
9768
- {
9769
- appear: true,
9770
- show: true,
9771
- as: "div",
9772
- enter: "transition-all ease-out duration-150",
9773
- enterFrom: "opacity-0 -translate-x-1/2",
9774
- enterTo: "opacity-100",
9775
- leave: "transition-all ease-out duration-150",
9776
- leaveFrom: "opacity-100",
9777
- leaveTo: "opacity-0 -translate-x-1/2"
9778
- },
9779
- cms.state.formLists.map((formList, index) => /* @__PURE__ */ React__namespace.createElement("div", { key: `${formList.id}-${index}`, className: "pt-16" }, /* @__PURE__ */ React__namespace.createElement(
9780
- FormList,
9781
- {
9782
- isEditing: props.isEditing,
9783
- setActiveFormId: (id) => {
9784
- cms.dispatch({ type: "forms:set-active-form-id", value: id });
9785
- },
9786
- formList
9787
- }
9788
- )))
9789
- );
9790
- };
9791
- const FormList = (props) => {
9792
- const cms = useCMS();
9793
- const listItems = React__namespace.useMemo(() => {
9794
- var _a;
9795
- const orderedListItems = [];
9796
- const globalItems = [];
9797
- const topItems = [];
9798
- props.formList.items.forEach((item) => {
9799
- if (item.type === "document") {
9800
- const form = cms.state.forms.find(
9801
- ({ tinaForm }) => tinaForm.id === item.formId
9802
- );
9803
- if (form.tinaForm.global) {
9804
- globalItems.push(item);
9805
- } else {
9806
- orderedListItems.push(item);
9807
- }
9808
- } else {
9809
- orderedListItems.push(item);
9810
- }
9811
- });
9812
- if (((_a = orderedListItems[0]) == null ? void 0 : _a.type) === "document") {
9813
- topItems.push({ type: "list", label: "Documents" });
9814
- }
9815
- let extra = [];
9816
- if (globalItems.length) {
9817
- extra = [{ type: "list", label: "Global Documents" }, ...globalItems];
9818
- }
9819
- return [...topItems, ...orderedListItems, ...extra];
9820
- }, [JSON.stringify(props.formList.items)]);
9821
- return /* @__PURE__ */ React__namespace.createElement("ul", null, /* @__PURE__ */ React__namespace.createElement("li", { className: "divide-y divide-gray-200" }, listItems.map((item, index) => {
9822
- if (item.type === "list") {
9823
- return /* @__PURE__ */ React__namespace.createElement(
9824
- "div",
9825
- {
9826
- key: item.label,
9827
- className: `relative group text-left w-full bg-white shadow-sm
9828
- 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"}`
9829
- },
9830
- /* @__PURE__ */ React__namespace.createElement(
9831
- "span",
9832
- {
9833
- className: "text-sm tracking-wide font-bold text-gray-700 uppercase"
9834
- },
9835
- item.label
9836
- )
9837
- );
9838
- }
9839
- return /* @__PURE__ */ React__namespace.createElement(
9840
- FormListItem,
9841
- {
9842
- setActiveFormId: (id) => props.setActiveFormId(id),
9843
- key: item.formId,
9844
- item,
9845
- depth: 0
9846
- }
9847
- );
9848
- })));
9849
- };
9850
- const FormsView = ({
9851
- children
9852
- }) => {
9853
- const cms = useCMS$1();
9854
- const { setFormIsPristine } = React__namespace.useContext(SidebarContext);
9855
- const isMultiform = cms.state.forms.length > 1;
9856
- const activeForm = cms.state.forms.find(
9857
- ({ tinaForm }) => tinaForm.id === cms.state.activeFormId
9858
- );
9859
- const isEditing = !!activeForm;
9860
- if (!cms.state.formLists.length) {
9861
- return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, " ", children, " ");
9862
- }
9863
- if (isMultiform && !activeForm) {
9864
- return /* @__PURE__ */ React__namespace.createElement(FormLists, { isEditing });
9865
- }
9866
- const formMetas = cms.plugins.all("form:meta");
9867
- return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, activeForm && /* @__PURE__ */ React__namespace.createElement(FormWrapper$1, { isEditing, isMultiform }, isMultiform && /* @__PURE__ */ React__namespace.createElement(MultiformFormHeader, { activeForm }), !isMultiform && /* @__PURE__ */ React__namespace.createElement(FormHeader, { activeForm }), formMetas == null ? void 0 : formMetas.map((meta) => /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, { key: meta.name }, /* @__PURE__ */ React__namespace.createElement(meta.Component, null))), /* @__PURE__ */ React__namespace.createElement(FormBuilder, { form: activeForm, onPristineChange: setFormIsPristine })));
9868
- };
9869
- const FormWrapper$1 = ({ isEditing, children }) => {
9870
- return /* @__PURE__ */ React__namespace.createElement(
9871
- "div",
9872
- {
9873
- className: "flex-1 flex flex-col flex-nowrap overflow-hidden h-full w-full relative bg-white",
9874
- style: isEditing ? {
9875
- transform: "none",
9876
- animationName: "fly-in-left",
9877
- animationDuration: "150ms",
9878
- animationDelay: "0",
9879
- animationIterationCount: 1,
9880
- animationTimingFunction: "ease-out"
9881
- } : {
9882
- transform: "translate3d(100%, 0, 0)"
9883
- }
9884
- },
9885
- children
9886
- );
9887
- };
9888
- const MultiformFormHeader = ({
9889
- activeForm
9890
- }) => {
9891
- const cms = useCMS$1();
9892
- const { formIsPristine } = React__namespace.useContext(SidebarContext);
9893
- return /* @__PURE__ */ React__namespace.createElement(
9894
- "div",
9895
- {
9896
- className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
9897
- },
9898
- /* @__PURE__ */ React__namespace.createElement("div", { className: "max-w-form mx-auto flex gap-2 justify-between items-center" }, /* @__PURE__ */ React__namespace.createElement(
9899
- "button",
9900
- {
9901
- type: "button",
9902
- className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
9903
- onClick: () => {
9904
- const state = activeForm.tinaForm.finalForm.getState();
9905
- if (state.invalid === true) {
9906
- cms.alerts.error("Cannot navigate away from an invalid form.");
9907
- } else {
9908
- cms.dispatch({ type: "forms:set-active-form-id", value: null });
9909
- }
9910
- }
9911
- },
9912
- /* @__PURE__ */ React__namespace.createElement(BiDotsVertical, { className: "h-auto w-5 inline-block opacity-70" })
9913
- ), /* @__PURE__ */ React__namespace.createElement(
9914
- "button",
9915
- {
9916
- type: "button",
9917
- className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
9918
- onClick: () => {
9919
- const collectionName = cms.api.tina.schema.getCollectionByFullPath(
9920
- cms.state.activeFormId
9921
- ).name;
9922
- window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
9923
- }
9924
- },
9925
- /* @__PURE__ */ React__namespace.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
9926
- ), /* @__PURE__ */ React__namespace.createElement("span", { className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0" }, "/"), /* @__PURE__ */ React__namespace.createElement("span", { className: "block w-full text-sm leading-tight whitespace-nowrap truncate" }, activeForm.tinaForm.label || activeForm.tinaForm.id), /* @__PURE__ */ React__namespace.createElement(FormStatus, { pristine: formIsPristine }))
9927
- );
9928
- };
9929
- const FormHeader = ({ activeForm }) => {
9930
- const { formIsPristine } = React__namespace.useContext(SidebarContext);
9931
- const cms = useCMS$1();
9932
- const shortFormLabel = activeForm.tinaForm.label ? activeForm.tinaForm.label.replace(/^.*[\\\/]/, "") : false;
9933
- return /* @__PURE__ */ React__namespace.createElement(
9934
- "div",
9935
- {
9936
- className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
9937
- },
9938
- /* @__PURE__ */ React__namespace.createElement("div", { className: "max-w-form mx-auto flex gap-2 justify-between items-center" }, /* @__PURE__ */ React__namespace.createElement(
9939
- "button",
9940
- {
9941
- type: "button",
9942
- className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
9943
- onClick: () => {
9944
- const collectionName = cms.api.tina.schema.getCollectionByFullPath(
9945
- cms.state.activeFormId
9946
- ).name;
9947
- window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
9948
- }
9949
- },
9950
- /* @__PURE__ */ React__namespace.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
9951
- ), shortFormLabel && /* @__PURE__ */ React__namespace.createElement("span", { className: "block w-full text-sm leading-tight whitespace-nowrap truncate" }, shortFormLabel), /* @__PURE__ */ React__namespace.createElement(FormStatus, { pristine: formIsPristine }))
9952
- );
9953
- };
9954
9714
  function ImFilesEmpty(props) {
9955
9715
  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);
9956
9716
  }
@@ -10193,7 +9953,7 @@ flowchart TD
10193
9953
  "Event Log"
10194
9954
  ));
10195
9955
  };
10196
- const version = "2.7.2";
9956
+ const version = "2.7.4";
10197
9957
  const Nav = ({
10198
9958
  isLocalMode,
10199
9959
  className = "",
@@ -10435,6 +10195,293 @@ flowchart TD
10435
10195
  /* @__PURE__ */ React__namespace.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" })
10436
10196
  );
10437
10197
  };
10198
+ const Item = ({
10199
+ item,
10200
+ depth,
10201
+ setActiveFormId
10202
+ }) => {
10203
+ const cms = useCMS();
10204
+ const depths = ["pl-6", "pl-10", "pl-14"];
10205
+ const form = React__namespace.useMemo(
10206
+ () => cms.state.forms.find(({ tinaForm }) => item.formId === tinaForm.id),
10207
+ [item.formId]
10208
+ );
10209
+ return /* @__PURE__ */ React__namespace.createElement(
10210
+ "button",
10211
+ {
10212
+ type: "button",
10213
+ key: item.path,
10214
+ onClick: () => setActiveFormId(item.formId),
10215
+ 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`
10216
+ },
10217
+ /* @__PURE__ */ React__namespace.createElement(BiEdit, { className: "opacity-70 w-5 h-auto text-blue-500 flex-none" }),
10218
+ /* @__PURE__ */ React__namespace.createElement("div", { className: "flex-1 flex flex-col gap-0.5 items-start" }, /* @__PURE__ */ React__namespace.createElement("div", { className: "group-hover:text-blue-500 font-sans text-xs font-semibold text-gray-700 whitespace-normal" }, form.tinaForm.label), /* @__PURE__ */ React__namespace.createElement("div", { className: "group-hover:text-blue-500 text-base truncate leading-tight text-gray-600" }, form.tinaForm.id))
10219
+ );
10220
+ };
10221
+ const FormListItem = ({
10222
+ item,
10223
+ depth,
10224
+ setActiveFormId
10225
+ }) => {
10226
+ var _a;
10227
+ return /* @__PURE__ */ React__namespace.createElement("div", { className: "divide-y divide-gray-200" }, /* @__PURE__ */ React__namespace.createElement(Item, { setActiveFormId, item, depth }), item.subItems && /* @__PURE__ */ React__namespace.createElement("ul", { className: "divide-y divide-gray-200" }, (_a = item.subItems) == null ? void 0 : _a.map((subItem) => {
10228
+ if (subItem.type === "document") {
10229
+ return /* @__PURE__ */ React__namespace.createElement("li", { key: subItem.formId }, /* @__PURE__ */ React__namespace.createElement(
10230
+ Item,
10231
+ {
10232
+ setActiveFormId,
10233
+ depth: depth + 1,
10234
+ item: subItem
10235
+ }
10236
+ ));
10237
+ }
10238
+ })));
10239
+ };
10240
+ const FormLists = (props) => {
10241
+ const cms = useCMS();
10242
+ return /* @__PURE__ */ React__namespace.createElement(
10243
+ react.Transition,
10244
+ {
10245
+ appear: true,
10246
+ show: true,
10247
+ as: "div",
10248
+ enter: "transition-all ease-out duration-150",
10249
+ enterFrom: "opacity-0 -translate-x-1/2",
10250
+ enterTo: "opacity-100",
10251
+ leave: "transition-all ease-out duration-150",
10252
+ leaveFrom: "opacity-100",
10253
+ leaveTo: "opacity-0 -translate-x-1/2"
10254
+ },
10255
+ cms.state.formLists.map((formList, index) => /* @__PURE__ */ React__namespace.createElement("div", { key: `${formList.id}-${index}`, className: "pt-16" }, /* @__PURE__ */ React__namespace.createElement(
10256
+ FormList,
10257
+ {
10258
+ isEditing: props.isEditing,
10259
+ setActiveFormId: (id) => {
10260
+ cms.dispatch({ type: "forms:set-active-form-id", value: id });
10261
+ },
10262
+ formList
10263
+ }
10264
+ )))
10265
+ );
10266
+ };
10267
+ const FormList = (props) => {
10268
+ const cms = useCMS();
10269
+ const listItems = React__namespace.useMemo(() => {
10270
+ var _a;
10271
+ const orderedListItems = [];
10272
+ const globalItems = [];
10273
+ const topItems = [];
10274
+ props.formList.items.forEach((item) => {
10275
+ if (item.type === "document") {
10276
+ const form = cms.state.forms.find(
10277
+ ({ tinaForm }) => tinaForm.id === item.formId
10278
+ );
10279
+ if (form.tinaForm.global) {
10280
+ globalItems.push(item);
10281
+ } else {
10282
+ orderedListItems.push(item);
10283
+ }
10284
+ } else {
10285
+ orderedListItems.push(item);
10286
+ }
10287
+ });
10288
+ if (((_a = orderedListItems[0]) == null ? void 0 : _a.type) === "document") {
10289
+ topItems.push({ type: "list", label: "Documents" });
10290
+ }
10291
+ let extra = [];
10292
+ if (globalItems.length) {
10293
+ extra = [{ type: "list", label: "Global Documents" }, ...globalItems];
10294
+ }
10295
+ return [...topItems, ...orderedListItems, ...extra];
10296
+ }, [JSON.stringify(props.formList.items)]);
10297
+ return /* @__PURE__ */ React__namespace.createElement("ul", null, /* @__PURE__ */ React__namespace.createElement("li", { className: "divide-y divide-gray-200" }, listItems.map((item, index) => {
10298
+ if (item.type === "list") {
10299
+ return /* @__PURE__ */ React__namespace.createElement(
10300
+ "div",
10301
+ {
10302
+ key: item.label,
10303
+ className: `relative group text-left w-full bg-white shadow-sm
10304
+ 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"}`
10305
+ },
10306
+ /* @__PURE__ */ React__namespace.createElement(
10307
+ "span",
10308
+ {
10309
+ className: "text-sm tracking-wide font-bold text-gray-700 uppercase"
10310
+ },
10311
+ item.label
10312
+ )
10313
+ );
10314
+ }
10315
+ return /* @__PURE__ */ React__namespace.createElement(
10316
+ FormListItem,
10317
+ {
10318
+ setActiveFormId: (id) => props.setActiveFormId(id),
10319
+ key: item.formId,
10320
+ item,
10321
+ depth: 0
10322
+ }
10323
+ );
10324
+ })));
10325
+ };
10326
+ const SidebarNoFormsPlaceholder = () => /* @__PURE__ */ React__namespace.createElement(
10327
+ "div",
10328
+ {
10329
+ className: "relative flex flex-col items-center justify-center text-center p-5 pb-16 w-full h-full overflow-y-auto",
10330
+ style: {
10331
+ animationName: "fade-in",
10332
+ animationDelay: "300ms",
10333
+ animationTimingFunction: "ease-out",
10334
+ animationIterationCount: 1,
10335
+ animationFillMode: "both",
10336
+ animationDuration: "150ms"
10337
+ }
10338
+ },
10339
+ /* @__PURE__ */ React__namespace.createElement("p", { className: "block pb-5" }, "Looks like there's ", /* @__PURE__ */ React__namespace.createElement("br", null), "nothing to edit on ", /* @__PURE__ */ React__namespace.createElement("br", null), "this page."),
10340
+ /* @__PURE__ */ React__namespace.createElement("p", { className: "block pt-5" }, /* @__PURE__ */ React__namespace.createElement(
10341
+ Button$1,
10342
+ {
10343
+ href: "https://tina.io/docs/contextual-editing/overview",
10344
+ target: "_blank",
10345
+ as: "a"
10346
+ },
10347
+ /* @__PURE__ */ React__namespace.createElement(Emoji$1, { className: "mr-1.5" }, "📖"),
10348
+ " Contextual Editing Docs"
10349
+ ))
10350
+ );
10351
+ const Emoji$1 = ({ className = "", ...props }) => /* @__PURE__ */ React__namespace.createElement(
10352
+ "span",
10353
+ {
10354
+ className: `text-[24px] leading-none inline-block ${className}`,
10355
+ ...props
10356
+ }
10357
+ );
10358
+ const minimumTimeToShowLoadingIndicator = 1e3;
10359
+ const FormsView = ({ loadingPlaceholder } = {}) => {
10360
+ const cms = useCMS$1();
10361
+ const { setFormIsPristine } = React__namespace.useContext(SidebarContext);
10362
+ const [isShowingLoading, setIsShowingLoading] = React__namespace.useState(true);
10363
+ const [initialLoadComplete, setInitialLoadComplete] = React__namespace.useState(false);
10364
+ React__namespace.useEffect(() => {
10365
+ if (cms.state.isLoadingContent) {
10366
+ setIsShowingLoading(true);
10367
+ const timer = setTimeout(() => {
10368
+ if (!cms.state.isLoadingContent) {
10369
+ setIsShowingLoading(false);
10370
+ setInitialLoadComplete(true);
10371
+ }
10372
+ }, minimumTimeToShowLoadingIndicator);
10373
+ return () => clearTimeout(timer);
10374
+ } else {
10375
+ const timer = setTimeout(() => {
10376
+ setIsShowingLoading(false);
10377
+ setInitialLoadComplete(true);
10378
+ }, minimumTimeToShowLoadingIndicator);
10379
+ return () => clearTimeout(timer);
10380
+ }
10381
+ }, [cms.state.isLoadingContent]);
10382
+ if (isShowingLoading || !initialLoadComplete) {
10383
+ const LoadingPlaceholder = loadingPlaceholder || SidebarLoadingPlaceholder;
10384
+ return /* @__PURE__ */ React__namespace.createElement(LoadingPlaceholder, null);
10385
+ }
10386
+ if (!cms.state.formLists.length) {
10387
+ return /* @__PURE__ */ React__namespace.createElement(SidebarNoFormsPlaceholder, null);
10388
+ }
10389
+ const isMultiform = cms.state.forms.length > 1;
10390
+ const activeForm = cms.state.forms.find(
10391
+ ({ tinaForm }) => tinaForm.id === cms.state.activeFormId
10392
+ );
10393
+ const isEditing = !!activeForm;
10394
+ if (isMultiform && !activeForm) {
10395
+ return /* @__PURE__ */ React__namespace.createElement(FormLists, { isEditing });
10396
+ }
10397
+ const formMetas = cms.plugins.all("form:meta");
10398
+ return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, activeForm && /* @__PURE__ */ React__namespace.createElement(FormWrapper$1, { isEditing, isMultiform }, isMultiform && /* @__PURE__ */ React__namespace.createElement(MultiformFormHeader, { activeForm }), !isMultiform && /* @__PURE__ */ React__namespace.createElement(FormHeader, { activeForm }), formMetas == null ? void 0 : formMetas.map((meta) => /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, { key: meta.name }, /* @__PURE__ */ React__namespace.createElement(meta.Component, null))), /* @__PURE__ */ React__namespace.createElement(FormBuilder, { form: activeForm, onPristineChange: setFormIsPristine })));
10399
+ };
10400
+ const FormWrapper$1 = ({ isEditing, children }) => {
10401
+ return /* @__PURE__ */ React__namespace.createElement(
10402
+ "div",
10403
+ {
10404
+ className: "flex-1 flex flex-col flex-nowrap overflow-hidden h-full w-full relative bg-white",
10405
+ style: isEditing ? {
10406
+ transform: "none",
10407
+ animationName: "fly-in-left",
10408
+ animationDuration: "150ms",
10409
+ animationDelay: "0",
10410
+ animationIterationCount: 1,
10411
+ animationTimingFunction: "ease-out"
10412
+ } : {
10413
+ transform: "translate3d(100%, 0, 0)"
10414
+ }
10415
+ },
10416
+ children
10417
+ );
10418
+ };
10419
+ const MultiformFormHeader = ({
10420
+ activeForm
10421
+ }) => {
10422
+ const cms = useCMS$1();
10423
+ const { formIsPristine } = React__namespace.useContext(SidebarContext);
10424
+ return /* @__PURE__ */ React__namespace.createElement(
10425
+ "div",
10426
+ {
10427
+ className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
10428
+ },
10429
+ /* @__PURE__ */ React__namespace.createElement("div", { className: "max-w-form mx-auto flex gap-2 justify-between items-center" }, /* @__PURE__ */ React__namespace.createElement(
10430
+ "button",
10431
+ {
10432
+ type: "button",
10433
+ className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
10434
+ onClick: () => {
10435
+ const state = activeForm.tinaForm.finalForm.getState();
10436
+ if (state.invalid === true) {
10437
+ cms.alerts.error("Cannot navigate away from an invalid form.");
10438
+ } else {
10439
+ cms.dispatch({ type: "forms:set-active-form-id", value: null });
10440
+ }
10441
+ }
10442
+ },
10443
+ /* @__PURE__ */ React__namespace.createElement(BiDotsVertical, { className: "h-auto w-5 inline-block opacity-70" })
10444
+ ), /* @__PURE__ */ React__namespace.createElement(
10445
+ "button",
10446
+ {
10447
+ type: "button",
10448
+ className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
10449
+ onClick: () => {
10450
+ const collectionName = cms.api.tina.schema.getCollectionByFullPath(
10451
+ cms.state.activeFormId
10452
+ ).name;
10453
+ window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
10454
+ }
10455
+ },
10456
+ /* @__PURE__ */ React__namespace.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
10457
+ ), /* @__PURE__ */ React__namespace.createElement("span", { className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0" }, "/"), /* @__PURE__ */ React__namespace.createElement("span", { className: "block w-full text-sm leading-tight whitespace-nowrap truncate" }, activeForm.tinaForm.label || activeForm.tinaForm.id), /* @__PURE__ */ React__namespace.createElement(FormStatus, { pristine: formIsPristine }))
10458
+ );
10459
+ };
10460
+ const FormHeader = ({ activeForm }) => {
10461
+ const { formIsPristine } = React__namespace.useContext(SidebarContext);
10462
+ const cms = useCMS$1();
10463
+ const shortFormLabel = activeForm.tinaForm.label ? activeForm.tinaForm.label.replace(/^.*[\\\/]/, "") : false;
10464
+ return /* @__PURE__ */ React__namespace.createElement(
10465
+ "div",
10466
+ {
10467
+ className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
10468
+ },
10469
+ /* @__PURE__ */ React__namespace.createElement("div", { className: "max-w-form mx-auto flex gap-2 justify-between items-center" }, /* @__PURE__ */ React__namespace.createElement(
10470
+ "button",
10471
+ {
10472
+ type: "button",
10473
+ className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
10474
+ onClick: () => {
10475
+ const collectionName = cms.api.tina.schema.getCollectionByFullPath(
10476
+ cms.state.activeFormId
10477
+ ).name;
10478
+ window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
10479
+ }
10480
+ },
10481
+ /* @__PURE__ */ React__namespace.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
10482
+ ), shortFormLabel && /* @__PURE__ */ React__namespace.createElement("span", { className: "block w-full text-sm leading-tight whitespace-nowrap truncate" }, shortFormLabel), /* @__PURE__ */ React__namespace.createElement(FormStatus, { pristine: formIsPristine }))
10483
+ );
10484
+ };
10438
10485
  const SidebarContext = React__namespace.createContext(null);
10439
10486
  const minPreviewWidth = 440;
10440
10487
  const minSidebarWidth = 360;
@@ -10653,7 +10700,7 @@ flowchart TD
10653
10700
  isLocalMode: (_d = (_c = cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.isLocalMode,
10654
10701
  branchingEnabled
10655
10702
  }
10656
- ), /* @__PURE__ */ React__namespace.createElement(FormsView, null, /* @__PURE__ */ React__namespace.createElement(sidebar.placeholder, null)), activeScreen && /* @__PURE__ */ React__namespace.createElement(
10703
+ ), /* @__PURE__ */ React__namespace.createElement(FormsView, { loadingPlaceholder: sidebar.loadingPlaceholder }), activeScreen && /* @__PURE__ */ React__namespace.createElement(
10657
10704
  ScreenPluginModal,
10658
10705
  {
10659
10706
  screen: activeScreen,
@@ -11419,7 +11466,10 @@ flowchart TD
11419
11466
  const observer = new IntersectionObserver((entries) => {
11420
11467
  const target = entries[0];
11421
11468
  if (target.isIntersecting && list.nextOffset) {
11422
- setOffsetHistory((offsetHistory2) => [...offsetHistory2, list.nextOffset]);
11469
+ setOffsetHistory((offsetHistory2) => [
11470
+ ...offsetHistory2,
11471
+ list.nextOffset
11472
+ ]);
11423
11473
  }
11424
11474
  });
11425
11475
  if (loaderRef.current) {
@@ -12014,6 +12064,7 @@ flowchart TD
12014
12064
  forms: [],
12015
12065
  formLists: [],
12016
12066
  editingMode: "basic",
12067
+ isLoadingContent: false,
12017
12068
  quickEditSupported: false,
12018
12069
  sidebarDisplayState: ((_a = cms == null ? void 0 : cms.sidebar) == null ? void 0 : _a.defaultState) || "open"
12019
12070
  };
@@ -12073,7 +12124,12 @@ flowchart TD
12073
12124
  }
12074
12125
  });
12075
12126
  }
12076
- return { ...state, activeFormId, formLists: nextFormLists };
12127
+ return {
12128
+ ...state,
12129
+ activeFormId,
12130
+ formLists: nextFormLists,
12131
+ isLoadingContent: false
12132
+ };
12077
12133
  }
12078
12134
  case "form-lists:remove": {
12079
12135
  const nextFormLists = state.formLists.filter(
@@ -12142,6 +12198,9 @@ flowchart TD
12142
12198
  }
12143
12199
  return { ...state, sidebarDisplayState: action.value };
12144
12200
  }
12201
+ case "sidebar:set-loading-state": {
12202
+ return { ...state, isLoadingContent: action.value };
12203
+ }
12145
12204
  default:
12146
12205
  throw new Error(`Unhandled action ${action.type}`);
12147
12206
  }
@@ -12383,7 +12442,9 @@ flowchart TD
12383
12442
  if (activeEle) {
12384
12443
  setDisplay(true);
12385
12444
  setPosition(activeEle.getBoundingClientRect());
12386
- const iframe = document.getElementById("tina-iframe");
12445
+ const iframe = document.getElementById(
12446
+ "tina-iframe"
12447
+ );
12387
12448
  if (iframe) {
12388
12449
  setIframePosition(iframe.getBoundingClientRect());
12389
12450
  }
@@ -12825,7 +12886,6 @@ flowchart TD
12825
12886
  }) => {
12826
12887
  const cms = useCMS$1();
12827
12888
  const tinaApi = cms.api.tina;
12828
- tinaApi.branch;
12829
12889
  const [disabled, setDisabled] = React__namespace.useState(false);
12830
12890
  const [newBranchName, setNewBranchName] = React__namespace.useState("");
12831
12891
  const [error, setError] = React__namespace.useState("");
@@ -12851,10 +12911,10 @@ flowchart TD
12851
12911
  const newUrl = window.location.href.replace(hash, newHash);
12852
12912
  window.location.href = newUrl;
12853
12913
  };
12854
- return /* @__PURE__ */ React__namespace.createElement(Modal, null, /* @__PURE__ */ React__namespace.createElement(PopupModal, null, /* @__PURE__ */ React__namespace.createElement(ModalHeader, { close: close2 }, /* @__PURE__ */ React__namespace.createElement(BiGitBranch, { className: "w-6 h-auto mr-1 text-blue-500 opacity-70" }), " ", "Create Branch"), /* @__PURE__ */ React__namespace.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React__namespace.createElement("p", { className: "text-base text-gray-700 mb-2" }, "This branch is ", /* @__PURE__ */ React__namespace.createElement("strong", null, "protected"), ". Create a new branch to save your changes."), /* @__PURE__ */ React__namespace.createElement(
12914
+ return /* @__PURE__ */ React__namespace.createElement(Modal, null, /* @__PURE__ */ React__namespace.createElement(PopupModal, null, /* @__PURE__ */ React__namespace.createElement(ModalHeader, { close: close2 }, /* @__PURE__ */ React__namespace.createElement(BiGitBranch, { className: "w-6 h-auto mr-1 text-blue-500 opacity-70" }), " ", "Create Branch"), /* @__PURE__ */ React__namespace.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React__namespace.createElement("p", { className: "text-lg text-gray-700 font-bold mb-2" }, "This content is protected 🚧"), /* @__PURE__ */ React__namespace.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__namespace.createElement(
12855
12915
  PrefixedTextField,
12856
12916
  {
12857
- placeholder: "Branch Name",
12917
+ placeholder: "e.g. {{PAGE-NAME}}-updates",
12858
12918
  value: newBranchName,
12859
12919
  onChange: (e) => {
12860
12920
  setError("");
@@ -13001,7 +13061,9 @@ flowchart TD
13001
13061
  const { fieldName } = useTemplates();
13002
13062
  const { handleClose, handleRemove, handleSelect, isExpanded } = useEmbedHandles(editor, element, fieldName);
13003
13063
  useHotkey("enter", () => {
13004
- plateCommon.insertNodes(editor, [{ type: plate.ELEMENT_PARAGRAPH, children: [{ text: "" }] }]);
13064
+ plateCommon.insertNodes(editor, [
13065
+ { type: plate.ELEMENT_PARAGRAPH, children: [{ text: "" }] }
13066
+ ]);
13005
13067
  });
13006
13068
  return /* @__PURE__ */ React.createElement("span", { ...attributes, className: "" }, children, element.url ? /* @__PURE__ */ React.createElement(
13007
13069
  "div",
@@ -13144,7 +13206,9 @@ flowchart TD
13144
13206
  const { templates, fieldName } = useTemplates();
13145
13207
  const { handleClose, handleRemove, handleSelect, isExpanded } = useEmbedHandles(editor, element, fieldName);
13146
13208
  useHotkey("enter", () => {
13147
- plateCommon.insertNodes(editor, [{ type: plate.ELEMENT_PARAGRAPH, children: [{ text: "" }] }]);
13209
+ plateCommon.insertNodes(editor, [
13210
+ { type: plate.ELEMENT_PARAGRAPH, children: [{ text: "" }] }
13211
+ ]);
13148
13212
  });
13149
13213
  useHotkey("space", () => {
13150
13214
  plateCommon.insertNodes(editor, [{ text: " " }], {
@@ -13200,7 +13264,9 @@ flowchart TD
13200
13264
  const { templates, fieldName } = useTemplates();
13201
13265
  const { handleClose, handleRemove, handleSelect, isExpanded } = useEmbedHandles(editor, element, fieldName);
13202
13266
  useHotkey("enter", () => {
13203
- plateCommon.insertNodes(editor, [{ type: plate.ELEMENT_PARAGRAPH, children: [{ text: "" }] }]);
13267
+ plateCommon.insertNodes(editor, [
13268
+ { type: plate.ELEMENT_PARAGRAPH, children: [{ text: "" }] }
13269
+ ]);
13204
13270
  });
13205
13271
  const activeTemplate = templates.find(
13206
13272
  (template) => template.name === element.name
@@ -14059,7 +14125,9 @@ flowchart TD
14059
14125
  const CONTAINER_MD_BREAKPOINT = 448;
14060
14126
  const FLOAT_BUTTON_WIDTH = 25;
14061
14127
  const HEADING_LABEL = "Headings";
14062
- const ToolbarContext = React.createContext(void 0);
14128
+ const ToolbarContext = React.createContext(
14129
+ void 0
14130
+ );
14063
14131
  const ToolbarProvider = ({
14064
14132
  tinaForm,
14065
14133
  templates,
@@ -30271,7 +30339,14 @@ flowchart TD
30271
30339
  const AUTH_TOKEN_KEY = "tinacms-auth";
30272
30340
  const authenticate = (clientId, frontendUrl) => {
30273
30341
  return new Promise((resolve) => {
30274
- let authTab;
30342
+ const origin = `${window.location.protocol}//${window.location.host}`;
30343
+ const authTab = popupWindow(
30344
+ `${frontendUrl}/signin?clientId=${clientId}&origin=${origin}`,
30345
+ "_blank",
30346
+ window,
30347
+ 1e3,
30348
+ 700
30349
+ );
30275
30350
  window.addEventListener("message", function(e) {
30276
30351
  if (e.data.source === TINA_LOGIN_EVENT) {
30277
30352
  if (authTab) {
@@ -30284,14 +30359,6 @@ flowchart TD
30284
30359
  });
30285
30360
  }
30286
30361
  });
30287
- const origin = `${window.location.protocol}//${window.location.host}`;
30288
- authTab = popupWindow(
30289
- `${frontendUrl}/signin?clientId=${clientId}&origin=${origin}`,
30290
- "_blank",
30291
- window,
30292
- 1e3,
30293
- 700
30294
- );
30295
30362
  });
30296
30363
  };
30297
30364
  const DefaultSessionProvider = ({
@@ -30997,56 +31064,6 @@ mutation addPendingDocumentMutation(
30997
31064
  !submitting && name
30998
31065
  );
30999
31066
  };
31000
- const TINA_AUTH_CONFIG = "tina_auth_config";
31001
- const useTinaAuthRedirect = () => {
31002
- React.useEffect(() => {
31003
- const urlParams = new URLSearchParams(window.location.search);
31004
- const config = {
31005
- code: urlParams.get("code") || "",
31006
- scope: urlParams.get("scope") || "email",
31007
- state: urlParams.get("state")
31008
- };
31009
- if (!config.code) {
31010
- return;
31011
- }
31012
- localStorage[TINA_AUTH_CONFIG] = JSON.stringify(config);
31013
- }, []);
31014
- };
31015
- const createClient = ({
31016
- clientId,
31017
- isLocalClient = true,
31018
- branch,
31019
- tinaioConfig,
31020
- schema,
31021
- apiUrl,
31022
- tinaGraphQLVersion
31023
- }) => {
31024
- return isLocalClient ? new LocalClient({ customContentApiUrl: apiUrl, schema }) : new Client({
31025
- clientId: clientId || "",
31026
- branch: branch || "main",
31027
- tokenStorage: "LOCAL_STORAGE",
31028
- tinaioConfig,
31029
- schema,
31030
- tinaGraphQLVersion
31031
- });
31032
- };
31033
- function assertShape(value, yupSchema, errorMessage) {
31034
- const shape = yupSchema(yup__namespace);
31035
- try {
31036
- shape.validateSync(value);
31037
- } catch (e) {
31038
- const message = errorMessage || `Failed to assertShape - ${e.message}`;
31039
- throw new Error(message);
31040
- }
31041
- }
31042
- function safeAssertShape(value, yupSchema) {
31043
- try {
31044
- assertShape(value, yupSchema);
31045
- return true;
31046
- } catch (e) {
31047
- return false;
31048
- }
31049
- }
31050
31067
  class TinaAdminApi {
31051
31068
  constructor(cms) {
31052
31069
  var _a, _b, _c, _d;
@@ -31393,6 +31410,56 @@ mutation addPendingDocumentMutation(
31393
31410
  );
31394
31411
  }
31395
31412
  }
31413
+ const createClient = ({
31414
+ clientId,
31415
+ isLocalClient = true,
31416
+ branch,
31417
+ tinaioConfig,
31418
+ schema,
31419
+ apiUrl,
31420
+ tinaGraphQLVersion
31421
+ }) => {
31422
+ return isLocalClient ? new LocalClient({ customContentApiUrl: apiUrl, schema }) : new Client({
31423
+ clientId: clientId || "",
31424
+ branch: branch || "main",
31425
+ tokenStorage: "LOCAL_STORAGE",
31426
+ tinaioConfig,
31427
+ schema,
31428
+ tinaGraphQLVersion
31429
+ });
31430
+ };
31431
+ function assertShape(value, yupSchema, errorMessage) {
31432
+ const shape = yupSchema(yup__namespace);
31433
+ try {
31434
+ shape.validateSync(value);
31435
+ } catch (e) {
31436
+ const message = errorMessage || `Failed to assertShape - ${e.message}`;
31437
+ throw new Error(message);
31438
+ }
31439
+ }
31440
+ function safeAssertShape(value, yupSchema) {
31441
+ try {
31442
+ assertShape(value, yupSchema);
31443
+ return true;
31444
+ } catch (e) {
31445
+ return false;
31446
+ }
31447
+ }
31448
+ const TINA_AUTH_CONFIG = "tina_auth_config";
31449
+ const useTinaAuthRedirect = () => {
31450
+ React.useEffect(() => {
31451
+ const urlParams = new URLSearchParams(window.location.search);
31452
+ const config = {
31453
+ code: urlParams.get("code") || "",
31454
+ scope: urlParams.get("scope") || "email",
31455
+ state: urlParams.get("state")
31456
+ };
31457
+ if (!config.code) {
31458
+ return;
31459
+ }
31460
+ localStorage[TINA_AUTH_CONFIG] = JSON.stringify(config);
31461
+ }, []);
31462
+ };
31396
31463
  function sleep(ms) {
31397
31464
  return new Promise((resolve) => setTimeout(resolve, ms));
31398
31465
  }
@@ -31729,6 +31796,9 @@ mutation addPendingDocumentMutation(
31729
31796
  cms.flags.set("branch-switcher", true);
31730
31797
  client.usingEditorialWorkflow = true;
31731
31798
  client.protectedBranches = project.protectedBranches;
31799
+ if (!project.metadata[currentBranch]) {
31800
+ setCurrentBranch(project.defaultBranch || "main");
31801
+ }
31732
31802
  }
31733
31803
  });
31734
31804
  };
@@ -31741,7 +31811,7 @@ mutation addPendingDocumentMutation(
31741
31811
  }
31742
31812
  });
31743
31813
  return unsubscribe;
31744
- }, [isTinaCloud, cms]);
31814
+ }, [currentBranch, isTinaCloud, cms]);
31745
31815
  return /* @__PURE__ */ React.createElement(SessionProvider, { basePath: "/api/tina/auth" }, /* @__PURE__ */ React.createElement(
31746
31816
  BranchDataProvider,
31747
31817
  {
@@ -32594,6 +32664,35 @@ This will work when developing locally but NOT when deployed to production.
32594
32664
  }) => {
32595
32665
  return /* @__PURE__ */ React.createElement("div", { className: "flex flex-col justify-center items-center h-screen bg-gray-100" }, /* @__PURE__ */ React.createElement("div", { className: "text-red-500 text-4xl mb-6 flex items-center" }, /* @__PURE__ */ React.createElement(BiError, { className: "w-12 h-auto fill-current text-red-400 opacity-70 mr-1" }), " ", title), /* @__PURE__ */ React.createElement("p", { className: "text-gray-700 text-xl mb-8" }, errorMessage), /* @__PURE__ */ React.createElement(Button$1, { variant: "danger", onClick: () => window.location.reload() }, /* @__PURE__ */ React.createElement(BiSync, { className: "w-7 h-auto fill-current opacity-70 mr-1" }), " Reload"));
32596
32666
  };
32667
+ const isValidSortKey = (sortKey, collection) => {
32668
+ if (collection.fields) {
32669
+ const sortKeys = collection.fields.map((x) => x.name);
32670
+ return sortKeys.includes(sortKey);
32671
+ } else if (collection.templates) {
32672
+ const collectionMap = {};
32673
+ const conflictedFields = /* @__PURE__ */ new Set();
32674
+ for (const template of collection.templates) {
32675
+ for (const field of template.fields) {
32676
+ if (collectionMap[field.name]) {
32677
+ if (collectionMap[field.name].type !== field.type) {
32678
+ conflictedFields.add(field.name);
32679
+ }
32680
+ } else {
32681
+ collectionMap[field.name] = field;
32682
+ }
32683
+ }
32684
+ }
32685
+ for (const key in conflictedFields) {
32686
+ delete collectionMap[key];
32687
+ }
32688
+ for (const key in collectionMap) {
32689
+ if (key === sortKey) {
32690
+ return true;
32691
+ }
32692
+ }
32693
+ return false;
32694
+ }
32695
+ };
32597
32696
  const useGetCollection = (cms, collectionName, includeDocuments = true, folder, after = "", sortKey, filterArgs) => {
32598
32697
  const api = new TinaAdminApi(cms);
32599
32698
  const schema = cms.api.tina.schema;
@@ -32605,10 +32704,9 @@ This will work when developing locally but NOT when deployed to production.
32605
32704
  React.useEffect(() => {
32606
32705
  let cancelled = false;
32607
32706
  const fetchCollection = async () => {
32608
- var _a;
32609
32707
  if (await api.isAuthenticated() && !folder.loading && !cancelled) {
32610
32708
  const { name, order } = JSON.parse(sortKey || "{}");
32611
- const validSortKey = ((_a = collectionExtra.fields) == null ? void 0 : _a.map((x) => x.name).includes(name)) ? name : void 0;
32709
+ const validSortKey = isValidSortKey(name, collectionExtra) ? name : void 0;
32612
32710
  try {
32613
32711
  const collection2 = await api.fetchCollection(
32614
32712
  collectionName,
@@ -33060,7 +33158,9 @@ This will work when developing locally but NOT when deployed to production.
33060
33158
  safeSubmit: async () => {
33061
33159
  try {
33062
33160
  await admin.deleteDocument(vars);
33063
- cms.alerts.info("Document was successfully deleted");
33161
+ cms.alerts.info(
33162
+ "Document was successfully deleted"
33163
+ );
33064
33164
  reFetchCollection();
33065
33165
  } catch (error) {
33066
33166
  cms.alerts.warn(
@@ -33089,7 +33189,9 @@ This will work when developing locally but NOT when deployed to production.
33089
33189
  relativePath: vars.relativePath,
33090
33190
  newRelativePath
33091
33191
  });
33092
- cms.alerts.info("Document was successfully renamed");
33192
+ cms.alerts.info(
33193
+ "Document was successfully renamed"
33194
+ );
33093
33195
  reFetchCollection();
33094
33196
  } catch (error) {
33095
33197
  if (error.message.indexOf("has references")) {
@@ -33189,7 +33291,9 @@ This will work when developing locally but NOT when deployed to production.
33189
33291
  name: "sort",
33190
33292
  value: sortKey,
33191
33293
  onChange: (e) => {
33192
- const val = JSON.parse(e.target.value);
33294
+ const val = JSON.parse(
33295
+ e.target.value
33296
+ );
33193
33297
  setEndCursor("");
33194
33298
  setPrevCursors([]);
33195
33299
  window == null ? void 0 : window.localStorage.setItem(
@@ -33978,7 +34082,10 @@ This will work when developing locally but NOT when deployed to production.
33978
34082
  const fetchDocument = async () => {
33979
34083
  if (api.isAuthenticated()) {
33980
34084
  try {
33981
- const response = await api.fetchDocument(collectionName, relativePath2);
34085
+ const response = await api.fetchDocument(
34086
+ collectionName,
34087
+ relativePath2
34088
+ );
33982
34089
  setDocument(response.document);
33983
34090
  } catch (error2) {
33984
34091
  cms.alerts.error(